-
Notifications
You must be signed in to change notification settings - Fork 339
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
fix: optimize block and material scalability issue #788
fix: optimize block and material scalability issue #788
Conversation
WalkthroughThe changes involve modifying the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CanvasMenu
participant MetaAPI
User->>CanvasMenu: Request to view menu
CanvasMenu->>MetaAPI: Check for available blocks
MetaAPI-->>CanvasMenu: Return block availability
CanvasMenu->>User: Render SaveNewBlock if hasBlock is true
Tip We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord. 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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
Files selected for processing (3)
- packages/canvas/container/src/components/CanvasMenu.vue (2 hunks)
- packages/common/component/ProgressBar.vue (1 hunks)
- packages/plugins/materials/src/composable/useMaterial.js (1 hunks)
Additional comments not posted (4)
packages/common/component/ProgressBar.vue (1)
24-25
: LGTM!The code changes are approved. The modifications improve the reliability of the component by:
- Introducing a safeguard to check if the result of
getMetaApi
is null or undefined, and if it is falsy, assigning an empty object instead. This prevents potential runtime errors when attempting to destructuregetEditBlock
from a null or undefined value.- Altering the assignment of
editBlock
to include a conditional check. IfgetEditBlock
is defined,editBlock
is computed usingcomputed(getEditBlock)
. IfgetEditBlock
is not available,editBlock
is set tonull
. This ensures thateditBlock
will not attempt to compute a value from an undefined function, thus improving error handling and control flow.Overall, these changes enhance the robustness of the component by preventing potential errors related to undefined values and ensuring that the computed property is only created when appropriate.
packages/canvas/container/src/components/CanvasMenu.vue (2)
30-30
: LGTM!The conditional rendering of the
SaveNewBlock
component based on thehasBlock
property improves the component's responsiveness to the application's state.
230-230
: LGTM!The addition of the
hasBlock
property to the reactive properties is consistent with the changes made at line 30 and is correctly derived from thegetMetaApi(META_SERVICE.Block)
function.packages/plugins/materials/src/composable/useMaterial.js (1)
433-433
: LGTM!The new
addMaterials
function is a useful addition to the module. It provides a convenient way to add both components and blocks using a single function call. The implementation is clean, follows the existing code structure, and integrates well with the other functions in the module.
There was a problem hiding this 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
Files selected for processing (5)
- packages/canvas/container/src/components/CanvasMenu.vue (3 hunks)
- packages/common/component/index.js (2 hunks)
- packages/plugins/block/index.js (1 hunks)
- packages/plugins/block/src/Main.vue (1 hunks)
- packages/plugins/block/src/SaveNewBlock.vue (1 hunks)
Files skipped from review due to trivial changes (2)
- packages/common/component/index.js
- packages/plugins/block/src/SaveNewBlock.vue
Files skipped from review as they are similar to previous changes (1)
- packages/canvas/container/src/components/CanvasMenu.vue
Additional comments not posted (4)
packages/plugins/block/index.js (3)
16-16
: LGTM!The code changes are approved.
22-22
: LGTM!The code changes are approved.
23-25
: LGTM!The code changes are approved.
packages/plugins/block/src/Main.vue (1)
123-123
: LGTM!The import statement has been correctly updated to use the local
SaveNewBlock
component instead of importing it from the common library. This change allows for customization or specific functionality that may not be provided by the common library.
There was a problem hiding this 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
Outside diff range, codebase verification and nitpick comments (1)
packages/plugins/materials/src/meta/block/src/BlockPanel.vue (1)
1-181
: TheBlockPanel
component looks good overall. Here are a few suggestions to further improve it:
- The component is well-structured and modular, following Vue 3 best practices and utilizing the Composition API effectively.
- The component handles API errors gracefully and displays appropriate error messages to the user.
- To improve readability and maintainability, consider adding code comments to explain complex logic or important sections of the code.
- To enhance the separation of concerns, consider extracting the API calls (
fetchGroups
,fetchGroupBlocksById
,fetchGroupBlocksByIds
) into a separate service or composable. This will make the component more focused and easier to test.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/plugins/materials/src/meta/block/src/BlockPanel.vue (1 hunks)
- packages/plugins/materials/src/meta/block/src/Main.vue (1 hunks)
Additional comments not posted (4)
packages/plugins/materials/src/meta/block/src/Main.vue (4)
1-2
: LGTM!The changes to the template section look good:
- The conditional rendering of the
<block-panel>
component based onexistBlockModule
simplifies the template structure.- Passing down the attributes using
v-bind="$attrs"
allows for flexibility and reusability of the<block-panel>
component.
5-23
: LGTM!The changes to the script section look good:
- The imports have been streamlined to only include the necessary dependencies.
- The
BlockPanel
component is properly registered in thecomponents
option.- The setup function now focuses on retrieving the existence of the block module using
getMergeMeta('engine.plugins.blockmanage')
.- The
existBlockModule
variable is used to conditionally render the<block-panel>
component in the template section.
27-27
: Verify the styling responsibilities.The style section has been emptied, suggesting a potential shift in styling responsibilities to the
BlockPanel
component.Please confirm if the styling for the block panel is now handled within the
BlockPanel
component itself.
1-27
: Great refactoring!The overall changes in the
Main.vue
component are a step in the right direction:
- The refactoring improves the modularity and maintainability of the codebase by consolidating functionality into the
BlockPanel
component.- The changes align with the principles of component-driven development, reducing the complexity of the
Main.vue
component.- The conditional rendering based on
existBlockModule
ensures that the<block-panel>
is only rendered when the block module exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
当前问题 从用户注册表去掉区块模块后会报错无法启动,解决该报错后,画布中依然存在了新建区块的入口,且物料插件面板报错无法展开 物料模块没有导出加载bundle.json物料的api,不太方便使用 解决方法 从common包中移除SaveNewBlock组件,画布模块从区块注册表获取组件 物料插件根据区块模块存在情况渲染区块面板 物料模块导出增加addMaterials API,传入bundle对象即可加载物料 遗留 物料插件中要隐藏区块依然需要配置注册表,没有实现自动关联
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: N/A
当前问题
解决方法
遗留
What is the new behavior?
注册表移除区块后启动正常,画布右键不显示新建区块入口, 物料插件不报错
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
SaveNewBlock
component, enhancing responsiveness based on the application's state.SaveNewBlock
, to improve block management functionality.Bug Fixes
ProgressBar
component to prevent runtime errors related to undefined values.