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

refactor: base properties configurable via registry #555

Merged
merged 11 commits into from
Aug 12, 2024

Conversation

gene9831
Copy link
Collaborator

@gene9831 gene9831 commented Jun 7, 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

    • Introduced basePropertyOptions to the materials plugin for enhanced property configurations.
    • Added a new function patchBaseProps to improve schema property management.
  • Bug Fixes

    • Simplified Chinese language labels in various configuration files for better clarity.
  • Documentation

    • Updated Chinese labels in JSON files to reflect concise terminology.

Copy link
Contributor

coderabbitai bot commented Jun 7, 2024

Walkthrough

The recent changes enhance the basePropertyOptions feature while improving property handling across several modules. Key additions and modifications streamline the registration of components, making property management more flexible and efficient. The updates reflect a shift toward better organization and configurability in the codebase, particularly in handling schema properties and simplifying language labels.

Changes

Files Change Summary
packages/plugins/materials/index.js Added import for basePropertyOptions and included it in the options object.
packages/plugins/materials/src/composable/useMaterial.js Imported getOptions, meta, added patchBaseProps, and updated registerComponentToResource logic.
designer-demo/public/mock/bundle.json
mockServer/src/assets/json/bundle.json
mockServer/src/assets/json/appinfo.json
packages/engine-cli/template/designer/public/mock/bundle.json
Simplified Chinese labels from "其他配置" and "其他属性" to "其他".
packages/settings/design/src/schemas/grid.json
packages/settings/design/src/schemas/search.json
Simplified Chinese labels from "其他配置" and "其他属性" to "其他".

Poem

In files of code, new paths arise,
With basePropertyOptions a welcoming surprise.
Gone the old ways, and in the new,
Properties patched, cleaner to view.
A change well met, the code refined,
Progress forward, piece by line. 🐇✨


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 Configuration 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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d9fe200 and 9fa2326.

Files selected for processing (5)
  • packages/builtinComponent/src/meta/index.js (1 hunks)
  • packages/canvas/src/components/builtin/builtin.json (1 hunks)
  • packages/controller/src/hooks/useProperties.js (2 hunks)
  • packages/controller/src/hooks/useResource.js (3 hunks)
  • packages/design-core/public/mock/bundle.json (1 hunks)
Additional context used
Biome
packages/controller/src/hooks/useResource.js

[error] 447-448: Avoid the use of spread (...) syntax on accumulators. (lint/performance/noAccumulatingSpread)

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

Additional comments not posted (11)
packages/builtinComponent/src/meta/index.js (3)

20-33: The addition of the id property with its configuration looks good.


36-49: The addition of the className property with its configuration looks good.


52-65: The addition of the ref property with its configuration looks good.

packages/controller/src/hooks/useProperties.js (1)

Line range hint 1-1: Removal of patchOtherName function call simplifies property handling. Ensure this change does not affect other functionalities.

Verification successful

The removal of the patchOtherName function does not affect other functionalities as there are no remaining references to it in the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the removal of `patchOtherName` does not affect other functionalities.

# Test: Search for any remaining references to `patchOtherName`. Expect: No occurrences.
rg --type javascript $'patchOtherName'

Length of output: 72



Script:

#!/bin/bash
# Description: Verify that the removal of `patchOtherName` does not affect other functionalities.

# Test: Search for any remaining references to `patchOtherName`. Expect: No occurrences.
rg --type js $'patchOtherName'

Length of output: 29

packages/controller/src/hooks/useResource.js (1)

78-87: Handling of baseProps in registerComponent function is implemented correctly to avoid property duplication.

packages/canvas/src/components/builtin/builtin.json (3)

526-539: The addition of the id property in the JSON configuration is correctly implemented.


542-555: The addition of the className property in the JSON configuration is correctly implemented.


558-571: The addition of the ref property in the JSON configuration is correctly implemented.

packages/design-core/public/mock/bundle.json (3)

14296-14312: Configuration for the id property looks comprehensive and well-defined.


14313-14328: Configuration for the className property is consistent and correctly implemented.


14329-14344: Configuration for the ref property is consistent and aligns with the project's standards.

@gene9831 gene9831 marked this pull request as draft June 19, 2024 01:31
@gene9831 gene9831 marked this pull request as ready for review July 1, 2024 09:44
@gene9831
Copy link
Collaborator Author

gene9831 commented Jul 1, 2024

@coderabbitai review this pull request

Copy link
Contributor

coderabbitai bot commented Jul 1, 2024

@gene9831, I have reviewed the changes made in the pull request. Here are the key points:

  1. Introduction of New Properties: The addition of id, className, and ref across various components and their configurations is well-executed. These properties have been integrated with appropriate types, default values, and widgets which should enhance the configurability of the component materials.

  2. Removal of Redundant Code: The removal of the otherBaseKey object and the patchOtherName function in packages/controller/src/hooks/useProperties.js simplifies the property handling mechanism. This change, along with the removal of the function call from getProps, appears to streamline the codebase without affecting functionality.

  3. Modification in Function Parameters: The introduction of the baseProps parameter in the registerComponent function in packages/controller/src/hooks/useResource.js is a significant change. It's important to ensure that all calls to this function across the project have been updated to pass this new parameter.

  4. Documentation and Tests: As noted in the PR description, documentation and tests for these changes have not been updated. It is crucial to update the documentation to reflect these changes and add unit tests to ensure the new functionality works as expected and does not introduce regressions.

Please consider adding the necessary tests and updating the documentation. If you need help with generating unit tests or any further analysis, feel free to ask!

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Jul 1, 2024

@gene9831, I have reviewed the changes made in the pull request. Here are the key points:

  1. Introduction of New Properties: The addition of id, className, and ref across various components and their configurations is well-executed. These properties have been integrated with appropriate types, default values, and widgets which should enhance the configurability of the component materials.

  2. Removal of Redundant Code: The removal of the otherBaseKey object and the patchOtherName function in packages/controller/src/hooks/useProperties.js simplifies the property handling mechanism. This change, along with the removal of the function call from getProps, appears to streamline the codebase without affecting functionality.

  3. Modification in Function Parameters: The introduction of the baseProps parameter in the registerComponent function in packages/controller/src/hooks/useResource.js is a significant change. It's important to ensure that all calls to this function across the project have been updated to pass this new parameter.

  4. Documentation and Tests: As noted in the PR description, documentation and tests for these changes have not been updated. It is crucial to update the documentation to reflect these changes and add unit tests to ensure the new functionality works as expected and does not introduce regressions.

Please consider adding the necessary tests and updating the documentation. If you need help with generating unit tests or any further analysis, feel free to ask!

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@gene9831 gene9831 changed the title refactor: base properties configurable refactor: base properties configurable via registry Jul 2, 2024
@gene9831
Copy link
Collaborator Author

gene9831 commented Jul 2, 2024

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jul 2, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@gene9831
Copy link
Collaborator Author

gene9831 commented Jul 8, 2024

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jul 8, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Jul 8, 2024

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

Commits

Files that changed from the base of the PR and between 0c71520 and 53602de.

Files selected for processing (4)
  • packages/plugins/materials/index.js (1 hunks)
  • packages/plugins/materials/src/composable/useMaterial.js (2 hunks)
  • packages/plugins/materials/src/js/options.js (1 hunks)
  • packages/settings/props/src/composable/useProperties.js (2 hunks)
 ________________________
< EV: Electric Verifier. >
 ------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0c71520 and 53602de.

Files selected for processing (4)
  • packages/plugins/materials/index.js (1 hunks)
  • packages/plugins/materials/src/composable/useMaterial.js (2 hunks)
  • packages/plugins/materials/src/js/options.js (1 hunks)
  • packages/settings/props/src/composable/useProperties.js (2 hunks)
Files skipped from review due to trivial changes (1)
  • packages/plugins/materials/src/js/options.js
Additional comments not posted (8)
packages/plugins/materials/index.js (2)

20-20: Import statement looks good.

The import statement for basePropertyOptions is correctly added.


28-29: Integration of basePropertyOptions in options object looks good.

The basePropertyOptions is correctly included in the options object. Ensure that the basePropertyOptions is properly defined and used in the rest of the codebase.

packages/settings/props/src/composable/useProperties.js (3)

Line range hint 1-1: File header looks good.

The file header contains the correct licensing information.


Line range hint 1-1: Modification of getProps looks good.

The getProps function has been modified to remove the call to patchOtherName. Ensure that this modification does not affect the functionality.


Line range hint 1-1: Ensure removal of otherBaseKey and patchOtherName is justified.

The otherBaseKey and patchOtherName have been removed. Ensure that their functionality is no longer needed or is handled elsewhere.

Verification successful

Removal of otherBaseKey and patchOtherName is justified.

The search did not find any occurrences of otherBaseKey and patchOtherName in the codebase, indicating that their functionality is no longer needed.

  • otherBaseKey
  • patchOtherName
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `otherBaseKey` and `patchOtherName` are no longer needed.

# Test: Search for the usage of `otherBaseKey` and `patchOtherName`. Expect: No occurrences.
rg --type python $'otherBaseKey'
rg --type python $'patchOtherName'

Length of output: 127


Script:

#!/bin/bash
# Description: Verify that `otherBaseKey` and `patchOtherName` are no longer needed.

# Test: Search for the usage of `otherBaseKey` and `patchOtherName`. Expect: No occurrences.
rg --type js 'otherBaseKey'
rg --type js 'patchOtherName'

Length of output: 57

packages/plugins/materials/src/composable/useMaterial.js (3)

17-18: New import statements look good.

The import statements for getOptions and meta are correctly added.


80-106: Function patchBaseProps implementation looks good.

The patchBaseProps function is correctly implemented to handle base properties configuration. Ensure that getOptions and meta.id are correctly defined and used.


113-114: Modification of registerComponentToResource looks good.

The registerComponentToResource function has been correctly modified to incorporate patchBaseProps.

hexqi
hexqi previously approved these changes Jul 10, 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 53602de and 73ee6eb.

Files selected for processing (2)
  • packages/plugins/materials/src/composable/useMaterial.js (2 hunks)
  • packages/plugins/materials/src/js/options.js (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/plugins/materials/src/composable/useMaterial.js
  • packages/plugins/materials/src/js/options.js

hexqi
hexqi previously approved these changes Aug 9, 2024
@hexqi
Copy link
Collaborator

hexqi commented Aug 9, 2024

image
当前bundle物料文件里面,部分组件已经存在“其他”、“其他配置”、“其他属性”的分组,会出现多个其他分组,可以把这块都统一为“其他”

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


image
In the current bundle material file, some components already exist in the groups of "Others", "Other Configurations", and "Other Attributes". There will be multiple other groups. These can be unified into "Others"

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 73ee6eb and 68b074e.

Files selected for processing (1)
  • packages/plugins/materials/src/composable/useMaterial.js (2 hunks)
Additional comments not posted (3)
packages/plugins/materials/src/composable/useMaterial.js (3)

85-88: Ensure schemaProperties is an array.

The function checks if schemaProperties is an array and returns early if not. This is a good practice to prevent errors. Ensure that the calling code handles non-array cases appropriately.


90-112: Verify group matching logic and insertion position.

The logic for matching groups and inserting base properties based on insertPosition is well-implemented. However, verify that getOptions(meta.id) always returns valid data, and consider handling cases where basePropertyOptions might be undefined.


121-122: Integration of patchBaseProps in component registration.

The call to patchBaseProps ensures that schema properties are enhanced with base properties during component registration. Verify that all components passed to this function have their schema properties defined.

Verification successful

Schema Properties are Defined for Registered Components

The builtin.json file confirms that components registered through registerComponentToResource have their schema properties defined. The integration of patchBaseProps is valid and ensures that these properties are processed correctly during component registration.

  • The Builtin.data.materials structure includes schema properties for each component, supporting the intended functionality.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all components registered have their schema properties defined.

# Test: Search for `registerComponentToResource` usage and ensure schema properties are passed.
rg --type javascript $'registerComponentToResource'

Length of output: 85


Script:

#!/bin/bash
# Description: Verify that all components registered have their schema properties defined.

# Test: Search for `registerComponentToResource` usage and ensure schema properties are passed.
rg --type js $'registerComponentToResource'

Length of output: 551


Script:

#!/bin/bash
# Description: Verify the structure of `materials`, `Builtin.data.materials`, and `BuiltinComponentMaterials` to ensure schema properties are defined.

# Search for the definition and structure of `materials`.
rg --type js 'materials ='

# Search for the definition and structure of `Builtin.data.materials`.
rg --type js 'Builtin.data.materials ='

# Search for the definition and structure of `BuiltinComponentMaterials`.
rg --type js 'BuiltinComponentMaterials ='

Length of output: 458


Script:

#!/bin/bash
# Description: Search for the usage or definition of `Builtin` and `BuiltinComponentMaterials` to gather more information about their structure.

# Search for the definition or usage of `Builtin`.
rg --type js 'Builtin'

# Search for the definition or usage of `BuiltinComponentMaterials`.
rg --type js 'BuiltinComponentMaterials'

Length of output: 1589


Script:

#!/bin/bash
# Description: Inspect the contents of the `builtin.json` file to verify the presence of schema properties.

# Display the contents of `builtin.json` to check for schema properties.
cat packages/canvas/render/src/builtin/builtin.json

Length of output: 16103

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 68b074e and 4390b23.

Files selected for processing (6)
  • designer-demo/public/mock/bundle.json (2 hunks)
  • mockServer/src/assets/json/appinfo.json (4 hunks)
  • mockServer/src/assets/json/bundle.json (2 hunks)
  • packages/engine-cli/template/designer/public/mock/bundle.json (2 hunks)
  • packages/settings/design/src/schemas/grid.json (1 hunks)
  • packages/settings/design/src/schemas/search.json (1 hunks)
Files skipped from review due to trivial changes (6)
  • designer-demo/public/mock/bundle.json
  • mockServer/src/assets/json/appinfo.json
  • mockServer/src/assets/json/bundle.json
  • packages/engine-cli/template/designer/public/mock/bundle.json
  • packages/settings/design/src/schemas/grid.json
  • packages/settings/design/src/schemas/search.json

@hexqi hexqi merged commit 46be85d into opentiny:refactor/develop Aug 12, 2024
1 check passed
@gene9831 gene9831 deleted the refactor/base-properties branch August 13, 2024 09:44
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.

None yet

4 participants