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: The plugin layout state is persisted using vueuse #766

Merged
merged 3 commits into from
Aug 31, 2024

Conversation

STATICHIT
Copy link

@STATICHIT STATICHIT commented Aug 27, 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

refactor: The plugin layout state is persisted using vueuse

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 dynamic plugin layout management with new functions for retrieving and changing plugin layouts.
    • Enhanced plugin accessibility through a centralized retrieval mechanism.
    • Added alignment options for multiple plugins, improving customization of their presentation.
  • Bug Fixes

    • Removed deprecated addons prop from components, streamlining plugin management.

Copy link
Contributor

coderabbitai bot commented Aug 27, 2024

Walkthrough

The changes involve modifications to multiple components and plugins, focusing on enhancing plugin management and layout configurations. Key updates include renaming variables for clarity, introducing new functions for layout retrieval and modification, removing the addons prop from several components, and adding alignment properties to plugin configurations.

Changes

Files Change Summary
packages/controller/src/useLayout.js Renamed pluginWidthStorage to pluginStorageReactive, updated related functions, and added getPluginsByLayout and changePluginLayout.
packages/design-core/config/addons.js Introduced a new plugin object for easier access to plugins and added the getPlugin function.
packages/design-core/src/App.vue Removed :addons prop from components and enhanced plugin object construction to include an alignment property.
packages/design-core/src/DesignPlugins.vue Removed addons prop and improved modularity with getPluginsByLayout for plugin retrieval.
packages/design-core/src/DesignSettings.vue Removed addons prop and utilized getPluginsByLayout for dynamic plugin management.
packages/plugins/*/index.js Updated option properties to include alignment options for various plugins, enhancing layout control.
packages/plugins/*/index.js Added alignment properties to the options object in several settings files.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant LayoutManager
    participant PluginManager

    User->>App: Interacts with the app
    App->>LayoutManager: Request layout information
    LayoutManager->>PluginManager: Get plugin layout
    PluginManager-->>LayoutManager: Return plugin data
    LayoutManager-->>App: Provide layout info
    App-->>User: Render updated UI
Loading

🐰 In a world of plugins so bright,
A rabbit hops with pure delight.
With layouts changed, and props set free,
The interface dances, oh so glee!
Alignments added, all in a row,
A joyful leap for plugins to flow!
🐇


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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2c576f6 and 01dcffd.

Files selected for processing (20)
  • packages/controller/src/useLayout.js (2 hunks)
  • packages/design-core/config/addons.js (1 hunks)
  • packages/design-core/src/App.vue (3 hunks)
  • packages/design-core/src/DesignPlugins.vue (4 hunks)
  • packages/design-core/src/DesignSettings.vue (3 hunks)
  • packages/plugins/block/index.js (1 hunks)
  • packages/plugins/bridge/index.js (1 hunks)
  • packages/plugins/data/index.js (1 hunks)
  • packages/plugins/datasource/index.js (1 hunks)
  • packages/plugins/help/index.js (1 hunks)
  • packages/plugins/i18n/index.js (1 hunks)
  • packages/plugins/materials/index.js (1 hunks)
  • packages/plugins/page/index.js (1 hunks)
  • packages/plugins/robot/index.js (1 hunks)
  • packages/plugins/schema/index.js (1 hunks)
  • packages/plugins/script/index.js (1 hunks)
  • packages/plugins/tree/index.js (1 hunks)
  • packages/settings/events/index.js (1 hunks)
  • packages/settings/props/index.js (1 hunks)
  • packages/settings/styles/index.js (1 hunks)
Additional comments not posted (26)
packages/plugins/help/index.js (1)

19-21: LGTM!

The changes enhance the configurability of the help plugin and improve the positioning of the help interface.

The code changes are approved.

packages/plugins/data/index.js (1)

20-22: LGTM!

The changes enhance the configuration of the component by specifying the alignment.

The code changes are approved.

packages/plugins/tree/index.js (1)

20-22: LGTM!

The changes enhance the configuration of the component by specifying the alignment.

The code changes are approved.

packages/plugins/bridge/index.js (1)

20-22: LGTM!

The addition of the align: 'leftTop' property enhances the layout configuration.

The code changes are approved.

packages/plugins/i18n/index.js (1)

21-22: LGTM!

The addition of the align: 'leftTop' property enhances the layout configuration.

The code changes are approved.

packages/plugins/robot/index.js (1)

20-22: LGTM!

The renaming of the option property to options and the addition of align: 'independence' enhances the configuration flexibility.

The code changes are approved.

packages/plugins/page/index.js (1)

20-22: LGTM! But verify the usage of the option property.

The addition of the align property enhances the customization capabilities of the plugin. Ensure that this change does not introduce any breaking changes.

The code changes are approved.

Run the following script to verify the usage of the option property:

Verification successful

Verify the usage of the option property

The search results show that the option property is used in multiple files across the codebase, including JSON configurations, JavaScript files, and Vue components. However, there is no indication of any breaking changes introduced by the addition of the align: 'leftTop' property within the option object in packages/plugins/page/index.js. The usage appears consistent with the existing code structure.

  • File: packages/plugins/page/index.js
    • Lines: 20-22
    • Code: option: { align: 'leftTop' }

The change seems to be a straightforward addition of an alignment option, enhancing customization without affecting other parts of the codebase adversely.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `option` property.

# Test: Search for the usage of the `option` property. Expect: No breaking changes.
rg --type javascript -A 5 $'option'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the `option` property without specifying a file type.

# Test: Search for the usage of the `option` property. Expect: No breaking changes.
rg -A 5 'option'

Length of output: 429128

packages/plugins/block/index.js (1)

20-22: LGTM! But verify the usage of the option property.

The addition of the align property enhances the customization capabilities of the plugin. Ensure that this change does not introduce any breaking changes.

The code changes are approved.

Run the following script to verify the usage of the option property:

packages/settings/events/index.js (1)

22-23: LGTM! But verify the usage of the options object.

The addition of the align property enhances the customization capabilities of the plugin. Ensure that this change does not introduce any breaking changes.

The code changes are approved.

Run the following script to verify the usage of the options object:

packages/plugins/schema/index.js (1)

21-21: LGTM!

The addition of the align property to the options object provides more flexibility in layout options.

The code changes are approved.

packages/settings/styles/index.js (1)

23-23: LGTM!

The addition of the align property to the options object provides more flexibility in layout options.

The code changes are approved.

packages/plugins/materials/index.js (1)

21-21: LGTM!

The addition of the align property to the options object provides more flexibility in layout options.

The code changes are approved.

packages/settings/props/index.js (1)

25-26: LGTM!

The addition of the align property enhances the configuration capabilities.

The code changes are approved.

packages/plugins/datasource/index.js (1)

21-23: LGTM!

The addition of the align property enhances the configuration capabilities.

The code changes are approved.

packages/plugins/script/index.js (1)

21-22: LGTM!

The addition of the align property enhances the configuration capabilities.

The code changes are approved.

packages/design-core/src/DesignSettings.vue (6)

52-52: LGTM!

The import statement for getPlugin is correct and aligns with the new plugin management approach.

The code changes are approved.


68-69: LGTM!

The initialization of components and iconComponents is correct and necessary for the subsequent plugin registration.

The code changes are approved.


73-75: LGTM!

The destructuring assignment from useLayout is correct and aligns with the new plugin management approach.

The code changes are approved.


79-87: LGTM!

The initialization of plugins and the registration of components, icons, and APIs are correct and align with the new plugin management approach.

The code changes are approved.


90-91: LGTM!

The initialization of activating and showMask is correct and necessary for the component's functionality.

The code changes are approved.


94-94: LGTM!

The initialization of state.leftList using getPluginLayout('rightTop') is correct and aligns with the new plugin management approach.

The code changes are approved.

packages/design-core/src/DesignPlugins.vue (5)

113-113: LGTM!

The import statement for getPlugin is correct and aligns with the new plugin management approach.

The code changes are approved.


135-136: LGTM!

The destructuring assignment from useLayout is correct and aligns with the new plugin management approach.

The code changes are approved.


138-139: LGTM!

The initialization of plugins and the registration of components, icons, and APIs are correct and align with the new plugin management approach.

The code changes are approved.


153-155: LGTM!

The initialization of state.topNavLists, state.bottomNavLists, and state.independence using getPluginLayout is correct and aligns with the new plugin management approach.

The code changes are approved.


153-155: LGTM!

The initialization of state using reactive is correct and necessary for the component's functionality.

The code changes are approved.

packages/design-core/config/addons.js Outdated Show resolved Hide resolved
packages/design-core/src/App.vue Outdated Show resolved Hide resolved
packages/controller/src/useLayout.js Outdated Show resolved Hide resolved
packages/controller/src/useLayout.js Outdated Show resolved Hide resolved
@hexqi hexqi added the ospp-2024 ospp-2024 label Aug 28, 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 01dcffd and e6e7a9d.

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

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 e6e7a9d and 27b95ce.

Files selected for processing (11)
  • packages/controller/src/useLayout.js (3 hunks)
  • packages/design-core/config/plugin.js (1 hunks)
  • packages/design-core/src/App.vue (3 hunks)
  • packages/design-core/src/DesignPlugins.vue (4 hunks)
  • packages/design-core/src/DesignSettings.vue (3 hunks)
  • packages/plugins/block/index.js (1 hunks)
  • packages/plugins/bridge/index.js (1 hunks)
  • packages/plugins/data/index.js (1 hunks)
  • packages/plugins/datasource/index.js (1 hunks)
  • packages/plugins/page/index.js (1 hunks)
  • packages/plugins/tree/index.js (1 hunks)
Files skipped from review as they are similar to previous changes (8)
  • packages/controller/src/useLayout.js
  • packages/design-core/src/App.vue
  • packages/plugins/block/index.js
  • packages/plugins/bridge/index.js
  • packages/plugins/data/index.js
  • packages/plugins/datasource/index.js
  • packages/plugins/page/index.js
  • packages/plugins/tree/index.js
Additional comments not posted (8)
packages/design-core/config/plugin.js (4)

1-1: Import statement is appropriate.

The import of addons is necessary for the configuration of plugins and settings.


3-6: Efficient transformation of plugins array to object map.

Using forEach to populate the plugin object from addons.plugins is efficient and maintains readability.


7-9: Consistent and efficient, but watch for potential key collisions.

The approach is consistent with the previous loop and efficient. However, ensure that there are no overlapping ids between plugins and settings to avoid data being overwritten.


11-13: Well-implemented retrieval function for plugins.

The getPlugin function is well-implemented, providing a clean interface for accessing plugin data and handling non-existent entries gracefully.

packages/design-core/src/DesignSettings.vue (2)

52-52: Appropriate import for plugin retrieval.

The import of getPlugin is essential for the new dynamic plugin handling mechanism in the component.


68-95: Enhanced flexibility and modularity in plugin management.

The changes in the setup function, including the use of getPluginsByLayout and dynamic registration of plugin APIs, significantly enhance the component's flexibility and modularity.

packages/design-core/src/DesignPlugins.vue (2)

113-113: Appropriate import for plugin retrieval.

The import of getPlugin is essential for the new dynamic plugin handling mechanism in the component.


Line range hint 135-161: Enhanced flexibility and modularity in plugin management.

The changes in the setup function, including the use of getPluginsByLayout and dynamic registration of plugin APIs, significantly enhance the component's flexibility and modularity.

@hexqi hexqi merged commit fa2ca2f into opentiny:ospp-2024/002-plugin-layout Aug 31, 2024
2 checks passed
@STATICHIT STATICHIT deleted the cj-plugin-area branch September 12, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ospp-2024 ospp-2024
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants