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: canvas 元应用改造2 (抽取CanvasLayout,面包屑导航去除元应用,api移动到engine.canvas顶层 ) #590

Merged
merged 5 commits into from
Jun 26, 2024

Conversation

rhlin
Copy link
Collaborator

@rhlin rhlin commented Jun 21, 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 design canvas with new layout and breadcrumb structure.
    • Introduced a CanvasLayout component for better structure and organization.
  • Bug Fixes

    • Fixed syntax error in configuration objects for improved reliability.
  • Refactor

    • Reorganized imports and export structures for better maintainability and code clarity.
    • Updated component imports and setup logic to enhance modularity and reusability.
  • Chores

    • Updated and cleaned up import statements and file structures across various components for consistency.

Copy link
Contributor

coderabbitai bot commented Jun 21, 2024

Walkthrough

The changes encompass significant updates across multiple components and modules, improving the functionality and structure of the canvas package. The key modifications include reorganizing imports, adding new components, and adjusting export structures to support a more modular and maintainable architecture. Additionally, the updates address various improvements in template rendering, setup logic, and dependency management in both new and existing files.

Changes

File(s) Change Summary
packages/canvas/DesignCanvas/index.js, packages/canvas/container/index.js Updated import and export statements; added and removed HOOK_NAME, api, apis, composable properties.
packages/canvas/DesignCanvas/src/DesignCanvas.vue Changed component structure, updated template rendering, and component imports.
packages/canvas/drag-drop/src/CanvasDragItem.vue Modified the getPluginApi call to update the plugin key.
packages/canvas/index.js Reorganized imports, exported additional components, adjusted export object structure; added/remoted components and metadata keys.
packages/canvas/layout/... (includes index.js, meta.js, src/CanvasLayout.vue) Introduced new files for the Canvas layout component and defined its metadata and export details.
packages/controller/js/... (includes constants.js, example.js) Minor formatting adjustments; updated copyright information.
packages/controller/src/composable/index.js Removed a trailing empty line.
packages/engine-cli/... (includes src/commands/create.js, template/designer/...) Added console log; fixed import and key-value pair syntax.
packages/entry/src/common.js Updated import statement to use single quotes.
packages/layout/index.js Removed trailing comma after the LayoutService import.
packages/plugins/block/src/composable/useBlock.js Consolidated imports into a single line.
packages/plugins/datasource/index.js Removed unnecessary line breaks in metas array declaration.
packages/settings/props/src/components/... (CodeEditor.vue, ModalContent.vue) Modified import statement; changed setup function structure.
packages/settings/styles/src/js/useStyle.js Modified the watch function dependencies and array structure.
packages/utils/src/utils/index.js Added a newline at the end of the file.
packages/canvas/breadcrumb/index.js Updated import statement to point to the correct component file.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CanvasLayout
    participant DesignCanvas
    participant CanvasBreadcrumb

    User->>DesignCanvas: Load Design Canvas
    DesignCanvas->>CanvasLayout: Initialize Layout
    CanvasLayout-->>DesignCanvas: Return Layout Component
    DesignCanvas->>CanvasBreadcrumb: Render Breadcrumb in Footer
    CanvasBreadcrumb-->>DesignCanvas: Return Breadcrumb Component
    DesignCanvas-->>User: Display Updated Canvas with Layout & Breadcrumb
Loading

Poem

In the canvas of dreams, code aligns,
Features and functions intertwined.
Layouts refreshed, imports refined,
A seamless flow, carefully designed.
Modular paths, so clear and bright,
Our code evolves to new heights.
🌱✨

Warning

Review ran into problems

Problems (1)
  • Git: Failed to clone repository. Please contact CodeRabbit support.

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.

@rhlin rhlin marked this pull request as ready for review June 21, 2024 09:21
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

Outside diff range and nitpick comments (3)
packages/utils/src/utils/index.js (1)

Line range hint 129-131: Reorder parameters to follow best practices.

The default parameter should follow the last required parameter to avoid confusion and potential bugs. Here's a suggested fix:

- export function generateRandomLetters(length = 1) {
+ export function generateRandomLetters(length) {
+   length = length || 1;
packages/settings/styles/src/js/useStyle.js (1)

Line range hint 81-92: Simplify mapping logic using .flatMap().

The current implementation uses .map().flat(), which can be simplified to .flatMap() for better readability and performance.

- res = expressRes
-   .map((item) => {
-     if (typeof item === 'string') {
-       return item
-     }
-     if (typeof item === 'object') {
-       return Object.keys(item)
-     }
-     return null
-   })
-   .flat()
-   .filter(Boolean)
+ res = expressRes.flatMap(item => {
+   if (typeof item === 'string') {
+     return item;
+   }
+   if (typeof item === 'object') {
+     return Object.keys(item);
+   }
+   return [];
+ }).filter(Boolean);
packages/plugins/block/src/composable/useBlock.js (1)

Line range hint 275-275: Adjust default parameter positioning in function signature.

The default parameter in the function signature should follow all required parameters to avoid confusion and potential bugs during function calls.

- const initBlock = async (block = {}, _langs = {}, isEdit) => {
+ const initBlock = async (block = {}, isEdit, _langs = {}) => {
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 54b8353 and 437d595.

Files selected for processing (23)
  • packages/canvas/DesignCanvas/index.js (1 hunks)
  • packages/canvas/DesignCanvas/src/DesignCanvas.vue (7 hunks)
  • packages/canvas/breadcrumb/src/CanvasBreadcrumb.vue (1 hunks)
  • packages/canvas/container/index.js (1 hunks)
  • packages/canvas/drag-drop/src/CanvasDragItem.vue (1 hunks)
  • packages/canvas/index.js (1 hunks)
  • packages/canvas/layout/index.js (1 hunks)
  • packages/canvas/layout/meta.js (1 hunks)
  • packages/canvas/layout/src/CanvasLayout.vue (1 hunks)
  • packages/controller/js/constants.js (2 hunks)
  • packages/controller/js/example.js (1 hunks)
  • packages/controller/src/composable/index.js (1 hunks)
  • packages/engine-cli/src/commands/create.js (1 hunks)
  • packages/engine-cli/template/designer/registry.js (1 hunks)
  • packages/engine-cli/template/designer/src/preview.js (1 hunks)
  • packages/entry/src/common.js (1 hunks)
  • packages/layout/index.js (1 hunks)
  • packages/plugins/block/src/composable/useBlock.js (1 hunks)
  • packages/plugins/datasource/index.js (1 hunks)
  • packages/settings/props/src/components/inputs/CodeEditor.vue (1 hunks)
  • packages/settings/props/src/components/modal/ModalContent.vue (1 hunks)
  • packages/settings/styles/src/js/useStyle.js (1 hunks)
  • packages/utils/src/utils/index.js (1 hunks)
Files not reviewed due to errors (1)
  • packages/canvas/DesignCanvas/src/DesignCanvas.vue (no review received)
Files skipped from review due to trivial changes (13)
  • packages/canvas/container/index.js
  • packages/canvas/layout/index.js
  • packages/canvas/layout/meta.js
  • packages/canvas/layout/src/CanvasLayout.vue
  • packages/controller/js/constants.js
  • packages/controller/js/example.js
  • packages/controller/src/composable/index.js
  • packages/engine-cli/src/commands/create.js
  • packages/engine-cli/template/designer/registry.js
  • packages/engine-cli/template/designer/src/preview.js
  • packages/entry/src/common.js
  • packages/layout/index.js
  • packages/plugins/datasource/index.js
Additional context used
Biome
packages/utils/src/utils/index.js

[error] 129-131: This default parameter should follow the last required parameter or should be a required parameter. (lint/style/useDefaultParameterLast)

The last required parameter is here:

A default parameter that precedes a required parameter cannot be omitted at call site.
Unsafe fix: Turn the parameter into a required parameter.

packages/settings/styles/src/js/useStyle.js

[error] 81-92: The call chain .map().flat() can be replaced with a single .flatMap() call. (lint/complexity/useFlatMap)

Safe fix: Replace the chain with .flatMap().

packages/plugins/block/src/composable/useBlock.js

[error] 275-275: This default parameter should follow the last required parameter or should be a required parameter. (lint/style/useDefaultParameterLast)

The last required parameter is here:

A default parameter that precedes a required parameter cannot be omitted at call site.
Unsafe fix: Turn the parameter into a required parameter.


[error] 275-275: This default parameter should follow the last required parameter or should be a required parameter. (lint/style/useDefaultParameterLast)

The last required parameter is here:

A default parameter that precedes a required parameter cannot be omitted at call site.
Unsafe fix: Turn the parameter into a required parameter.

Additional comments not posted (10)
packages/canvas/DesignCanvas/index.js (2)

4-4: Approved import addition

The addition of api from './src/api' is appropriate for the new functionalities being introduced in the export object.


7-11: Approved modifications to export object

The updated export structure, including apis and composable, aligns with the PR's goal of enhancing the module's functionality and integration capabilities.

packages/canvas/index.js (2)

18-18: Approved import addition

The addition of CanvasLayout from './layout' is correctly implemented and aligns with the structural changes intended by the PR.


21-29: Approved export restructuring

The restructuring of both named and default exports to include CanvasContainer, CanvasLayout, and DesignCanvas, along with modifications to components and metas, enhances the module's modularity and accessibility.

packages/canvas/drag-drop/src/CanvasDragItem.vue (1)

19-19: Approved API call update

Updating the getPluginApi call from 'engine.canvas.container' to 'engine.canvas' correctly centralizes API access, aligning with the PR's objectives.

packages/canvas/breadcrumb/src/CanvasBreadcrumb.vue (2)

4-4: Approved template update

The update to the template introducing conditional rendering based on data.length enhances user feedback and interface clarity.


24-33: Approved script updates

The updates to the script, including the getPluginApi call and the introduction of the selectFooterNode function, enhance the component's functionality and its integration with the canvas API.

packages/settings/props/src/components/modal/ModalContent.vue (1)

47-47: Verify removal of { emit } from setup function signature.

The removal of { emit } from the setup function signature might affect event handling if this component emits events. Please verify through testing or checking other parts of the application where this component is used.

packages/settings/props/src/components/inputs/CodeEditor.vue (1)

37-37: Setup function implementation looks good.

The setup function is well-structured and correctly uses Vue's composition API features like reactive, ref, and computed. Good job maintaining clean and maintainable code.

packages/plugins/block/src/composable/useBlock.js (1)

23-23: Consolidation of imports.

The imports from @opentiny/tiny-engine-entry could potentially be consolidated into a single line to enhance readability and maintain the consistency of import statements across the project.

- import { useCanvas, useTranslate, useEditorInfo, useBreadcrumb, useLayout } from '@opentiny/tiny-engine-entry'
+ import { useCanvas, useTranslate, useEditorInfo, useBreadcrumb, useLayout } from '@opentiny/tiny-engine-entry'

Likely invalid or redundant comment.

packages/settings/styles/src/js/useStyle.js Show resolved Hide resolved
chilingling
chilingling previously approved these changes Jun 24, 2024
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 437d595 and 06d348f.

Files selected for processing (1)
  • packages/canvas/breadcrumb/index.js (1 hunks)
Additional comments not posted (3)
packages/canvas/breadcrumb/index.js (3)

1-1: Import of HOOK_NAME is correct.

This import statement correctly pulls HOOK_NAME from '@opentiny/tiny-engine-entry', aligning with the project's module structure.


2-2: Updated import for CanvasBreadcrumb.

The change in the import path to './src/CanvasBreadcrumb.vue' is consistent with the restructuring mentioned in the PR summary.


Line range hint 5-10: Export structure review.

The export default statement integrates metaData, apis, and composable objects effectively. The structure promotes modularity and reusability, aligning with the architectural improvements mentioned in the PR.

@rhlin rhlin force-pushed the refactor-extra-canvas-api-2 branch from 06d348f to b13aff3 Compare June 25, 2024 08:14
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 06d348f and b13aff3.

Files selected for processing (2)
  • packages/canvas/breadcrumb/index.js (1 hunks)
  • packages/canvas/index.js (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/canvas/breadcrumb/index.js
  • packages/canvas/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 b13aff3 and b7523ce.

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

@hexqi hexqi merged commit 7cf169d into opentiny:refactor/develop Jun 26, 2024
yy-wow pushed a commit to yy-wow/tiny-engine that referenced this pull request Oct 10, 2024
opentiny#590)

* feat: canvas 元应用改造2 (抽取CanvasLayout,面包屑导航去除元应用,api移动到engine.canvas顶层 )

* fix: 解决code check问题

* fix: 修正引用路径错误

* fix: 解决解决merge过程中文件修改丢失
@coderabbitai coderabbitai bot mentioned this pull request Oct 10, 2024
14 tasks
@coderabbitai coderabbitai bot mentioned this pull request Nov 4, 2024
14 tasks
@coderabbitai coderabbitai bot mentioned this pull request Dec 16, 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.

3 participants