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: supports plugin drag and plugin order state is persisted using … #794

Conversation

STATICHIT
Copy link

@STATICHIT STATICHIT commented Sep 10, 2024

…vueuse

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

1.支持左上,左下,右上三个位置的插件内部/跨越拖拽。
2.对插件顺序进行了持久化保存。

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 drag-and-drop functionality for rearranging plugins in the layout.
    • Added a new fixed position option for enhanced layout configuration.
    • Enhanced navigation panels with draggable components for dynamic item reordering.
  • Improvements

    • Improved plugin management through systematic alignment and indexing.
    • Streamlined user interaction in the navigation and settings components.
  • Dependencies

    • Added vue-draggable-next to enhance drag-and-drop capabilities.

@github-actions github-actions bot added enhancement New feature or request ospp-2024 ospp-2024 labels Sep 10, 2024
Copy link
Contributor

coderabbitai bot commented Sep 10, 2024

Walkthrough

The pull request introduces enhancements to the layout management system, including the addition of a fixed position option and improved plugin handling through drag-and-drop functionality. The DesignPlugins.vue and DesignSettings.vue components have been updated to utilize the VueDraggableNext component for dynamic item reordering. Additionally, the structure of plugin objects has been refined for better organization, and a new dependency, vue-draggable-next, has been added to support these features.

Changes

File Path Change Summary
packages/controller/src/useLayout.js Added fixed position option, modified getPluginsByLayout, introduced dragPluginLayout and isSameSide functions.
packages/design-core/package.json Added dependency: "vue-draggable-next": "2.1.0".
packages/design-core/src/App.vue Enhanced plugin processing logic, introduced alignment grouping and indexing for plugins.
packages/design-core/src/DesignPlugins.vue Integrated VueDraggableNext for dynamic navigation item reordering, added fixedNavLists and onEnd methods.
packages/design-core/src/DesignSettings.vue Implemented draggable interface with VueDraggableNext, updated clickMenu, added onEnd, dragPluginLayout, and isSameSide methods.
packages/plugins/help/index.js Modified align property in options from 'leftBottom' to 'fixed'.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DesignPlugins
    participant DesignSettings
    participant useLayout

    User->>DesignPlugins: Drag item
    DesignPlugins->>DesignPlugins: onEnd event triggered
    DesignPlugins->>useLayout: Call dragPluginLayout
    useLayout->>DesignPlugins: Update plugin positions
    DesignPlugins->>User: Reflect new order
Loading
sequenceDiagram
    participant User
    participant DesignSettings
    participant useLayout

    User->>DesignSettings: Drag item
    DesignSettings->>DesignSettings: onEnd event triggered
    DesignSettings->>useLayout: Call dragPluginLayout
    useLayout->>DesignSettings: Update layout
    DesignSettings->>User: Reflect new layout
Loading

Possibly related PRs

Poem

🐇 In a world of plugins, hopping around,
A fixed position now can be found.
With draggable magic, they dance and they play,
Rearranging their spots in a whimsical way.
So let’s celebrate this layout delight,
For every new change brings joy to our sight! 🌟


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 01a3d04 and 75ae8a3.

Files selected for processing (3)
  • packages/design-core/package.json (1 hunks)
  • packages/design-core/src/DesignPlugins.vue (11 hunks)
  • packages/design-core/src/DesignSettings.vue (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/design-core/package.json
Additional comments not posted (14)
packages/design-core/src/DesignSettings.vue (7)

21-36: LGTM!

The changes introduce drag-and-drop functionality for the plugin list using the vue-draggable-next component, which aligns with the PR objectives. The @end event binding to the onEnd method allows handling the end of the drag operation, and the class binding update ensures that the active class is correctly applied based on the current renderPanel.


46-46: LGTM!

The import statement for the VueDraggableNext component is correctly placed in the script section of the component, allowing its usage in the template.


53-54: LGTM!

The VueDraggableNext component is correctly registered in the components option of the Vue component, allowing its usage in the template.


72-73: LGTM!

The dragPluginLayout and isSameSide methods are correctly destructured from the useLayout composition function. These methods are likely related to the drag-and-drop functionality and are used to update the plugin layout and determine if two plugins are on the same side.


121-125: LGTM!

The onEnd method is correctly bound to the @end event of the vue-draggable-next component. The logic inside the method aligns with the expected behavior of updating the plugin layout when a drag operation ends. The use of the isSameSide method to determine if the source and destination are on the same side is a good approach to handle different scenarios, and calling the close method when they are not on the same side seems reasonable.


137-138: LGTM!

The rightFixedPanelsStorage and onEnd properties are correctly added to the returned object of the setup function, making them available in the template and other parts of the component. The rightFixedPanelsStorage property is likely related to storing the fixed panels on the right side, and the onEnd property refers to the onEnd method, which is triggered when a drag operation ends.


276-280: LGTM!

The added CSS styles for the ghost class are appropriate for styling an element during a drag operation. Setting the opacity to 0.5 creates a visual effect of the dragged item being semi-transparent, which is a common practice in drag-and-drop interfaces. The background color of #f2f2f2 provides a subtle visual distinction for the dragged item's original position.

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

Line range hint 6-37: LGTM!

The integration of the VueDraggableNext component for the top navigation panel is implemented correctly. The usage of state.topNavLists as the model and handling of the onEnd event to persist the order of the dragged items is appropriate.


40-65: LGTM!

The integration of the VueDraggableNext component for the bottom navigation panel is implemented correctly. The usage of state.bottomNavLists as the model and handling of the onEnd event to persist the order of the dragged items is appropriate.


Line range hint 66-87: LGTM!

The introduction of the new section for rendering fixed navigation items is implemented correctly. The usage of state.fixedNavLists to store and render the fixed navigation items is appropriate, and the rendering logic is consistent with the bottom navigation panel.


Line range hint 88-100: LGTM!

The conditional rendering of the state.independence item based on its existence in the state is implemented correctly. The rendering logic for the state.independence item is consistent with the other navigation items.


142-149: LGTM!

The import of the VueDraggableNext component and its addition to the components option is implemented correctly. This ensures that the component is available for use in the template to enable the drag-and-drop functionality.


Line range hint 172-195: LGTM!

The introduction of new properties and methods from the useLayout composition function is implemented correctly. The destructuring of PLUGIN_POSITION, dragPluginLayout, and isSameSide is appropriate for handling the plugin layout and positioning. The initialization of state.fixedNavLists with the plugins obtained from the PLUGIN_POSITION.fixed position ensures that the fixed plugins are rendered in the appropriate section.


Line range hint 253-274: LGTM!

The introduction of the onEnd method to handle the drag-and-drop end event is implemented correctly. The method appropriately calls the close method if the drag-and-drop operation is performed between different sides and updates the plugin layout using the dragPluginLayout method. The addition of onEnd to the returned object of the setup function makes it available for use in the template.


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ospp-2024 ospp-2024
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants