Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/layout #575

Merged
merged 6 commits into from
Jun 14, 2024
Merged

Feat/layout #575

merged 6 commits into from
Jun 14, 2024

Conversation

lichunn
Copy link
Contributor

@lichunn lichunn commented Jun 12, 2024

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features
    • Enhanced the DesignCanvas component with dynamic component binding for CanvasContainer and CanvasFooter.
    • Updated DesignPlugins to utilize props.plugins for greater flexibility.
    • Simplified DesignSettings by removing redundant imports and defining a settings prop.
    • Improved DesignToolbars by using props.toolbars instead of a registry call.
    • Introduced dynamic component setup in App.vue for more streamlined registry usage.
    • Added a registry prop to Main.vue to manage the state and configuration of components.

Copy link
Contributor

coderabbitai bot commented Jun 12, 2024

Walkthrough

The recent changes simplify the DesignCanvas module by introducing dynamic components and removing redundant imports, refactor the DesignPlugins, DesignSettings, and DesignToolbars components to use props instead of a registry for configuration. Additionally, new files were added for exporting metadata and reorganized exports within the canvas module, aligning Layout, Canvas, and other components for a more streamlined setup.

Changes

Files Change Summaries
DesignCanvas.vue Replaced CanvasContainer and CanvasFooter components with dynamic components using :is binding.
DesignPlugins.vue Updated image paths, commented out external import, and used props.plugins instead of calling getMergeRegistry.
DesignSettings.vue, DesignToolbars.vue Removed registry function import, added props for settings and toolbars.
designer-demo/registry.js Imported Layout and Canvas, updated layout, and canvas properties to use new entities.
packages/canvas/DesignCanvas/index.js New file exporting DesignCanvas component with additional metadata.
packages/canvas/DesignCanvas/meta.js New file exporting an object with id property set to 'engine.canvas'.
packages/canvas/index.js Reorganized exports, combining DesignCanvas and canvas components into a default object.
packages/controller/src/hooks/mountHooks.js Removed the import statement for './useLayout'.
packages/design-core/index.js Expanded exports to include Layout and Canvas, removed export for CanvasBreadcrumb.
packages/design-core/src/App.vue Added setup function to dynamically fetch registry using getMergeRegistry.
packages/layout/index.js Renamed imported file to Main.vue, added import statement for useLayout.
packages/layout/src/Main.vue Introduced registry prop to manage state and configuration of components.
packages/canvas/DesignCanvas/src/DesignCanvas.vue Accessed properties within object returned by getMergeRegistry('canvas'), modified how components are assigned.

Sequence Diagrams

Updating the sequence diagrams to reflect how dynamic components and prop-based configurations are integrated:

DesignCanvas.vue Flow

sequenceDiagram
    participant User
    participant App
    participant DesignCanvas
    participant CanvasContainer
    participant CanvasFooter

    User->>App: Navigate to DesignCanvas
    App->>DesignCanvas: Load component
    DesignCanvas->>DesignCanvas: Bind dynamic components for CanvasContainer and CanvasFooter
    DesignCanvas->>CanvasContainer: Render component dynamically
    DesignCanvas->>CanvasFooter: Render component dynamically
    User->>DesignCanvas: Interact with canvas
Loading

DesignPlugins.vue Prop Flow

sequenceDiagram
    participant App
    participant DesignPlugins
    participant Props

    App->>DesignPlugins: Pass plugins as props
    DesignPlugins->>Props: Use props for plugin settings
Loading

Poem

🐇
In the realm of code, we thrive,
With dynamic styles, our dreams come alive.
Props replace the old and true,
Streamlining paths and saying adieu.
Together we craft with elegant grace,
🎨✨
A canvas refreshed, a brighter space.
🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4e6064e and 2c6491c.

Files ignored due to path filters (1)
  • packages/layout/assets/AI.png is excluded by !**/*.png
Files selected for processing (10)
  • designer-demo/registry.js (3 hunks)
  • packages/controller/src/hooks/mountHooks.js (1 hunks)
  • packages/design-core/index.js (1 hunks)
  • packages/design-core/src/App.vue (1 hunks)
  • packages/design-core/src/init.js (1 hunks)
  • packages/layout/index.js (1 hunks)
  • packages/layout/package.json (1 hunks)
  • packages/layout/src/DesignCanvas.vue (2 hunks)
  • packages/layout/src/DesignPlugins.vue (6 hunks)
  • packages/layout/src/Main.vue (2 hunks)
Files skipped from review due to trivial changes (2)
  • packages/controller/src/hooks/mountHooks.js
  • packages/design-core/src/init.js
Additional comments not posted (8)
packages/layout/index.js (2)

1-1: Ensure the new component path in the import statement is correct and accessible.

Verification successful

The import path for Main.vue is correct and the file exists.

  • packages/layout/index.js: The import statement for Main.vue is valid.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the existence of 'Main.vue' in the specified directory.

# Test: Check if the file exists. Expect: File should exist.
if [ -f ./packages/layout/src/Main.vue ]; then
  echo "File exists."
else
  echo "File does not exist."
fi

Length of output: 78


3-3: Adding useLayout hook import is a good practice for modularity, but ensure it's being used effectively within the module.

Verification successful

The useLayout hook is effectively utilized within the module, as evidenced by its usage in multiple components.

  • Main.vue
  • DesignToolbars.vue
  • DesignSettings.vue
  • DesignPlugins.vue
  • DesignCanvas.vue
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of 'useLayout' hook within the module.

# Test: Search for the usage of 'useLayout'. Expect: At least one usage.
rg --type js 'useLayout' ./packages/layout/src

Length of output: 1638

packages/layout/package.json (1)

15-20: The addition of new dependencies related to @opentiny/vue is noted. Ensure these versions are compatible with the existing project setup and do not introduce version conflicts.

Verification successful

The output shows that the dependencies for @opentiny/vue and related packages are consistently set to version ^3.14.0 or ~3.14.0 across multiple package.json files. This indicates that there are no apparent version conflicts within the repository for these dependencies.

  • The versions ^3.14.0 and ~3.14.0 are compatible with each other, as they both allow updates within the same minor version range.

Therefore, the addition of these dependencies in packages/layout/package.json should not introduce any version conflicts.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the compatibility of new dependencies with existing ones.

# Test: Check for version conflicts. Expect: No conflicts.
npm list --depth=0

Length of output: 91



Script:

#!/bin/bash
# Find all package.json files and extract dependencies to check for potential version conflicts.

# List all package.json files
fd package.json --exec cat {} \; > all_package_jsons.txt

# Extract dependencies from all package.json files
grep -E '"dependencies":|@opentiny/vue' all_package_jsons.txt

Length of output: 4380

packages/design-core/index.js (1)

33-34: The new exports for Layout, Canvas, CanvasContainer, and CanvasFooter are correctly implemented and align with the project's modular architecture.

packages/layout/src/Main.vue (2)

4-21: The modifications in the template to use registry for passing data to child components enhance modularity and maintainability.


71-75: The addition of the registry prop is well-defined and correctly typed, ensuring that the component can be more dynamically configured.

packages/layout/src/DesignCanvas.vue (1)

4-21: Switching to dynamic components using the :is binding enhances flexibility and reduces coupling in the template. Ensure that the old static components (CanvasContainer and CanvasFooter) are indeed no longer needed before removing the comments permanently.

packages/layout/src/DesignPlugins.vue (1)

61-61: The addition of an AI chatbot icon is a nice touch for user interaction. Ensure the image path is correct and accessible.

packages/layout/src/DesignCanvas.vue Outdated Show resolved Hide resolved
packages/layout/src/DesignPlugins.vue Outdated Show resolved Hide resolved
packages/design-core/src/App.vue Show resolved Hide resolved
designer-demo/registry.js Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2c6491c and cd677f3.

Files selected for processing (4)
  • packages/layout/src/DesignCanvas.vue (2 hunks)
  • packages/layout/src/DesignPlugins.vue (6 hunks)
  • packages/layout/src/DesignSettings.vue (1 hunks)
  • packages/layout/src/DesignToolbars.vue (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/layout/src/DesignSettings.vue
Files skipped from review as they are similar to previous changes (2)
  • packages/layout/src/DesignCanvas.vue
  • packages/layout/src/DesignPlugins.vue
Additional comments not posted (3)
packages/layout/src/DesignToolbars.vue (3)

Line range hint 1-12: Template section looks good and uses Vue features appropriately.


27-41: The props definition and usage in the setup function are clear and follow Vue best practices. However, consider adding comments to explain the logic within the forEach loop, especially how toolbars are categorized and APIs are registered.

[REFACTOR_SUGGESTion]

+    // Categorize toolbar items based on their alignment and register necessary APIs
     props.toolbars.forEach((item) => {
       if (item.align === 'right') {
         rightBar.push(item)
       } else if (item.align === 'center') {
         centerBar.push(item)
       } else {
         leftBar.push(item)
       }
       if (item.id === 'lock') {
         useLayout().registerPluginApi({ Lock: item.api })
       }
       if (item.id === 'save') {
         useLayout().registerPluginApi({ save: item.api })
       }
     })

Line range hint 63-125: The styling is well-organized and makes good use of LESS features and scoped styles. It adheres to best practices for maintainability and theming.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cd677f3 and 761fe61.

Files selected for processing (10)
  • designer-demo/registry.js (3 hunks)
  • packages/canvas/DesignCanvas/index.js (1 hunks)
  • packages/canvas/DesignCanvas/meta.js (1 hunks)
  • packages/canvas/DesignCanvas/src/DesignCanvas.vue (1 hunks)
  • packages/canvas/index.js (1 hunks)
  • packages/controller/src/hooks/mountHooks.js (1 hunks)
  • packages/design-core/index.js (1 hunks)
  • packages/design-core/src/App.vue (1 hunks)
  • packages/layout/index.js (1 hunks)
  • packages/layout/src/Main.vue (4 hunks)
Files skipped from review due to trivial changes (2)
  • packages/canvas/DesignCanvas/index.js
  • packages/canvas/DesignCanvas/meta.js
Files skipped from review as they are similar to previous changes (6)
  • designer-demo/registry.js
  • packages/controller/src/hooks/mountHooks.js
  • packages/design-core/index.js
  • packages/design-core/src/App.vue
  • packages/layout/index.js
  • packages/layout/src/Main.vue
Additional comments not posted (2)
packages/canvas/index.js (2)

18-18: The import of DesignCanvas is correctly added. Ensure that the file path and export from ./DesignCanvas are correctly set up.


20-23: The restructuring of the export default to include DesignCanvas alongside CanvasContainer and CanvasBreadcrumb is well-implemented. Verify that all modules importing this file handle the new structure correctly.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 761fe61 and 764a5b3.

Files selected for processing (2)
  • packages/design-core/src/App.vue (1 hunks)
  • packages/layout/index.js (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/design-core/src/App.vue
  • packages/layout/index.js

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 764a5b3 and 97097fe.

Files selected for processing (1)
  • packages/canvas/DesignCanvas/src/DesignCanvas.vue (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/canvas/DesignCanvas/src/DesignCanvas.vue

@hexqi hexqi merged commit 15db7af into opentiny:refactor/develop Jun 14, 2024
yy-wow pushed a commit to yy-wow/tiny-engine that referenced this pull request Oct 10, 2024
* feat:add layout

* feat: 调整layout导入

* feat: 把DesignCanvas移到canvas

* feat: 暂时不改entry

* fix: 添加注释
@coderabbitai coderabbitai bot mentioned this pull request Dec 27, 2024
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants