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:插件面板优化功能 #632

Merged

Conversation

STATICHIT
Copy link

@STATICHIT STATICHIT commented Jul 6, 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?

  1. Refactor: Complete plugin panel optimization functionality.
  2. Refactor: Redesign layouts for left and right side menus as well as the central canvas.
  3. Refactor: Implement the ability to fix panel states across all plugins.
  4. Refactor: Enable drag-and-drop customization of plugin widths across all plugins.
  5. Refactor: Maintain plugin fixed and width states within hooks.
    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 a new <plugin-panel> component for improved organization of event settings.
    • Enhanced layout management by utilizing the <plugin-panel> to encapsulate the collapse items.
  • Improvements

    • Transitioned to a standard <script> block for better state management with reactive and provide functionality.
    • Updated component registration to include the PluginPanel, enhancing modularity and interactivity.
  • Bug Fixes

    • Preserved original functionality of state management for collapse items while improving component hierarchy.

Copy link
Contributor

coderabbitai bot commented Jul 6, 2024

Walkthrough

The recent modifications significantly enhance the Vue components by introducing a plugin-panel for improved modularity and interactivity. Key updates include the addition of new props for flexible state management and a more organized structure for event handling. These changes streamline component interactions, ensuring a more cohesive and responsive application experience overall.

Changes

File(s) Change Summary
.../events/src/Main.vue Replaced <tiny-collapse> with <plugin-panel>, updated imports, transitioned to standard <script>, and introduced reactive state management.
.../page/src/Main.vue Added fixedPanels prop to <plugin-panel>, introduced plugin-name constant, and enhanced event handling with a new reactive object.
.../component/PluginPanel.vue Added dynamic width setting, new svg-button for panel management, and improved resizing logic.
.../data/src/Main.vue Refactored layout to use plugin-panel, introduced a tabbed interface for better state management.
.../settings/events/index.js Changed icon property to 'target', enhancing visual representation.
.../settings/props/index.js Updated icon property to 'form' for better identification.
.../settings/styles/index.js Changed icon property to 'display-inline' to enhance component styling.

Poem

In the meadow, where changes bloom,
New panels rise, dispelling gloom.
A rabbit hops with joy so bright,
Coding magic, day and night!
With every click and every flick,
The UI dances, oh so slick! 🐰✨


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.

@hexqi hexqi added the ospp-2024 ospp-2024 label Jul 8, 2024
@STATICHIT STATICHIT changed the title refactor: 完成插件面板优化功能 1.refactor: 完成插件面板优化功能 2.refactor:重新规划左右侧菜单以及中间画布布局,实现右侧插件固定面板功能 Jul 8, 2024
@hexqi hexqi closed this Jul 24, 2024
@Issues-translate-bot
Copy link

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


Because the PR does not need to be merged and the submitted code has been split into other PRs, close the PR first and you can continue to access the PR from the closed PR.

@hexqi hexqi reopened this Jul 24, 2024
@hexqi
Copy link
Collaborator

hexqi commented Jul 25, 2024

PR的标题可以修改下,使用英文,简短描述pr改动,例如:refactor(layout): optimize plugin panel: adjustable width and fixed right panel

@hexqi
Copy link
Collaborator

hexqi commented Jul 25, 2024

我在本地验证了下,拖拽的释放这块好像有些问题,有时候放开鼠标了仍处于拖拽状态,有点卡顿,这个作为TODO项在后续PR里面优化吧

@Issues-translate-bot
Copy link

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


I verified it locally and found that there seems to be some problem with the release of drag and drop. Sometimes when I release the mouse, it is still in the drag and drop state, which is a bit laggy. This should be optimized as a TODO item in subsequent PRs.

@STATICHIT STATICHIT changed the title 1.refactor: 完成插件面板优化功能 2.refactor:重新规划左右侧菜单以及中间画布布局,实现右侧插件固定面板功能 refactor完成插件面板优化功能 Jul 25, 2024
@STATICHIT STATICHIT changed the title refactor完成插件面板优化功能 refactor:插件面板优化功能 Jul 25, 2024
hexqi
hexqi previously approved these changes Jul 26, 2024
@hexqi
Copy link
Collaborator

hexqi commented Jul 26, 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 1f13f0c and 7775aed.

Files selected for processing (1)
  • packages/settings/events/src/Main.vue (1 hunks)
Additional comments not posted (6)
packages/settings/events/src/Main.vue (6)

37-51: Review setup function implementation.

The setup function initializes reactive state and provides it to the component's context. Ensure that the implementation is correct and follows best practices.


2-13: Ensure plugin-panel integration is correct.

The plugin-panel component is introduced with several props and an event. Ensure that these are correctly integrated and used within the component.

Verification successful

Verified plugin-panel integration is correct.

The plugin-panel component is correctly integrated with the appropriate props and events in packages/settings/events/src/Main.vue.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct integration of `plugin-panel` component.

# Test: Search for the `plugin-panel` component definition. Expect: Correct props and events.
rg --type vue -A 10 $'<plugin-panel'

Length of output: 65


Script:

#!/bin/bash
# Description: Verify the correct integration of `plugin-panel` component.

# Test: Search for the `plugin-panel` component definition. Expect: Correct props and events.
rg -A 10 '<plugin-panel'

Length of output: 11244


32-36: Check props definition.

The fixedPanels prop is defined as an array. Ensure that this prop is correctly used within the component.

Verification successful

The fixedPanels prop is correctly defined and used within the component.

The fixedPanels prop is utilized in various parts of the codebase, including prop bindings, class bindings, and conditional checks. The usage appears to be consistent with its definition as an array.

  • Example usages:
    • <plugin-panel title="属性" :fixed-panels="fixedPanels" ...>
    • :class="[fixedPanels?.includes(PLUGIN_NAME.Tutorial) && 'active']"
    • :tips="!fixedPanels?.includes(PLUGIN_NAME.Tutorial) ? '固定面板' : '解除固定面板'"

These usages indicate that the fixedPanels prop is being used correctly within the component.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct usage of `fixedPanels` prop.

# Test: Search for the `fixedPanels` prop usage. Expect: Correct usage.
rg --type vue -A 10 $'props: {'

Length of output: 112


Script:

#!/bin/bash
# Description: Verify the correct usage of `fixedPanels` prop.

# Test: Search for the `fixedPanels` prop usage. Expect: Correct usage.
rg --type vue 'fixedPanels'

Length of output: 55


Script:

#!/bin/bash
# Description: Verify the correct usage of `fixedPanels` prop.

# Find all .vue files and search for the `fixedPanels` prop usage.
fd -e vue -x rg 'fixedPanels' {}

Length of output: 2497


17-23: Verify imported components and hooks.

Ensure that the imported components (PluginPanel, SvgButton, BindEvents, AdvanceConfig, TinyCollapse, TinyCollapseItem) and hooks (useLayout) are correctly imported and used.


24-31: Ensure component registration is correct.

The components are registered within the export default block. Ensure that the registration is correct and all components are used within the template.


4-11: Check tiny-collapse and tiny-collapse-item usage.

The tiny-collapse and tiny-collapse-item components are used within the plugin-panel. Ensure that these components are correctly imported and used.

hexqi
hexqi previously approved these changes Jul 27, 2024
@hexqi
Copy link
Collaborator

hexqi commented Jul 27, 2024

有两个问题:
1.eslint检查没有通过,需要修改(点击details可以查看)
image
image

2.可以执行下面这条命令对从2c478ce开始所有commit重新提交添加签名(当前只有最新提交的一条是有签名的)(执行完后:wq保存,git push -f提交)
git rebase --exec 'GIT_COMMITTER_DATE="$(git log -1 --format=%at)" git commit --amend --no-edit -n -S' -i 2c478ce

@Issues-translate-bot
Copy link

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


There are two questions:

  1. The eslint check failed and needs to be modified (click details to view)
    image
    image

  2. You can execute the following command to sign all commits starting from 2c478ce (currently only the latest one is signed)
    git rebase --exec 'GIT_COMMITTER_DATE="$(git log -1 --format=%at)" git commit --amend --no-edit -n -S' -i 2c478ce

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

Outside diff range, codebase verification and nitpick comments (2)
packages/settings/events/src/Main.vue (1)

2-19: Ensure consistent use of component names.

The component name plugin-panel should follow the same naming conventions as other components (e.g., PluginPanel). Ensure consistency across the codebase.

-  <plugin-panel
+  <PluginPanel
packages/plugins/page/src/Main.vue (1)

2-2: Ensure consistent use of component names.

The component name plugin-panel should follow the same naming conventions as other components (e.g., PluginPanel). Ensure consistency across the codebase.

-  <plugin-panel :title="title" :fixed-panels="fixedPanels" :fixed-name="PLUGIN_NAME.Page" @close="pluginPanelClosed">
+  <PluginPanel :title="title" :fixed-panels="fixedPanels" :fixed-name="PLUGIN_NAME.Page" @close="pluginPanelClosed">
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7775aed and 8ed712c.

Files selected for processing (2)
  • packages/plugins/page/src/Main.vue (5 hunks)
  • packages/settings/events/src/Main.vue (1 hunks)
Additional comments not posted (7)
packages/settings/events/src/Main.vue (3)

10-17: Check for potential performance issues with large data sets.

Using v-model on tiny-collapse with potentially large data sets might cause performance issues. Ensure that the data binding is optimized.


24-29: Ensure all imports are necessary and used.

Verify that all imported components and functions are necessary and used within the script.


48-51: Ensure proper usage of provide/inject.

Ensure that the provided panelState is correctly injected and used in the child components.

packages/plugins/page/src/Main.vue (4)

Line range hint 10-10:
Ensure proper handling of ref attributes.

Ensure that the pageTreeRef is correctly used and managed within the component to avoid potential issues with reactivity.


45-45: Ensure all imports are necessary and used.

Verify that all imported components and functions are necessary and used within the script.


89-93: Ensure proper usage of provide/inject.

Ensure that the provided panelState is correctly injected and used in the child components.


156-156: Ensure proper usage of constants.

Ensure that the PLUGIN_NAME constant is correctly used and does not conflict with other constants or variables in the application.

packages/settings/events/src/Main.vue Show resolved Hide resolved
packages/plugins/page/src/Main.vue Show resolved Hide resolved
@STATICHIT STATICHIT force-pushed the ospp-2024/002-plugin-layout branch from 8ed712c to 7730e6d Compare July 27, 2024 10:56
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: 6

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8ed712c and 7730e6d.

Files selected for processing (30)
  • packages/canvas/src/components/container/CanvasFooter.vue (1 hunks)
  • packages/common/component/PluginPanel.vue (3 hunks)
  • packages/common/component/PluginSetting.vue (1 hunks)
  • packages/controller/src/useLayout.js (6 hunks)
  • packages/design-core/src/App.vue (5 hunks)
  • packages/design-core/src/DesignPlugins.vue (8 hunks)
  • packages/design-core/src/DesignSettings.vue (1 hunks)
  • packages/plugins/block/src/Main.vue (6 hunks)
  • packages/plugins/bridge/src/Main.vue (6 hunks)
  • packages/plugins/data/src/Main.vue (6 hunks)
  • packages/plugins/datasource/src/DataSourceForm.vue (4 hunks)
  • packages/plugins/datasource/src/DataSourceGlobalDataHandler.vue (4 hunks)
  • packages/plugins/datasource/src/DataSourceRemotePanel.vue (4 hunks)
  • packages/plugins/datasource/src/Main.vue (7 hunks)
  • packages/plugins/i18n/src/Main.vue (7 hunks)
  • packages/plugins/materials/src/Main.vue (6 hunks)
  • packages/plugins/materials/src/component/Main.vue (1 hunks)
  • packages/plugins/page/src/Main.vue (5 hunks)
  • packages/plugins/page/src/PageFolderSetting.vue (4 hunks)
  • packages/plugins/page/src/PageSetting.vue (4 hunks)
  • packages/plugins/schema/src/Main.vue (4 hunks)
  • packages/plugins/script/src/Main.vue (7 hunks)
  • packages/plugins/tree/src/Main.vue (6 hunks)
  • packages/settings/events/index.js (1 hunks)
  • packages/settings/events/src/Main.vue (1 hunks)
  • packages/settings/props/index.js (1 hunks)
  • packages/settings/props/src/Main.vue (2 hunks)
  • packages/settings/styles/index.js (1 hunks)
  • packages/settings/styles/src/Main.vue (5 hunks)
  • packages/theme/common/global.less (1 hunks)
Files skipped from review due to trivial changes (2)
  • packages/common/component/PluginSetting.vue
  • packages/settings/events/index.js
Files skipped from review as they are similar to previous changes (24)
  • packages/canvas/src/components/container/CanvasFooter.vue
  • packages/common/component/PluginPanel.vue
  • packages/controller/src/useLayout.js
  • packages/design-core/src/App.vue
  • packages/design-core/src/DesignPlugins.vue
  • packages/design-core/src/DesignSettings.vue
  • packages/plugins/block/src/Main.vue
  • packages/plugins/bridge/src/Main.vue
  • packages/plugins/datasource/src/DataSourceForm.vue
  • packages/plugins/datasource/src/DataSourceGlobalDataHandler.vue
  • packages/plugins/datasource/src/DataSourceRemotePanel.vue
  • packages/plugins/datasource/src/Main.vue
  • packages/plugins/i18n/src/Main.vue
  • packages/plugins/materials/src/Main.vue
  • packages/plugins/materials/src/component/Main.vue
  • packages/plugins/page/src/Main.vue
  • packages/plugins/page/src/PageFolderSetting.vue
  • packages/plugins/page/src/PageSetting.vue
  • packages/plugins/schema/src/Main.vue
  • packages/settings/props/index.js
  • packages/settings/props/src/Main.vue
  • packages/settings/styles/index.js
  • packages/settings/styles/src/Main.vue
  • packages/theme/common/global.less
Additional comments not posted (22)
packages/settings/events/src/Main.vue (5)

9-19: LGTM!

The plugin-panel component is well-structured and integrates the tiny-collapse component correctly.


38-42: Add prop validation.

Consider adding validation for the fixedPanels prop to ensure it meets the expected structure.


44-57: LGTM!

The setup function is well-structured and correctly uses useLayout and provide.


43-43: LGTM!

The emits section correctly declares the close event.


53-57: LGTM!

The return statement correctly returns necessary variables and functions.

packages/plugins/script/src/Main.vue (5)

9-27: LGTM!

The plugin-panel component is well-structured and integrates the monaco-editor component correctly.


56-59: Add prop validation.

Consider adding validation for the fixedPanels prop to ensure it meets the expected structure.


Line range hint 61-117:
LGTM!

The setup function is well-structured and correctly uses useHelp, useMethod, and provide.


61-61: LGTM!

The emits section correctly declares the close and fix-panel events.


Line range hint 107-117:
LGTM!

The return statement correctly returns necessary variables and functions.

packages/plugins/tree/src/Main.vue (5)

Line range hint 9-33:
LGTM!

The plugin-panel component is well-structured and integrates the tiny-grid component correctly.


97-106: Add prop validation.

Consider adding validation for the fixedPanels prop to ensure it meets the expected structure.


98-106: LGTM!

The setup function is well-structured and correctly uses useCanvas, useResource, and provide.


97-97: LGTM!

The emits section correctly declares the close and fix-panel events.


Line range hint 106-171:
LGTM!

The return statement correctly returns necessary variables and functions.

packages/plugins/data/src/Main.vue (7)

2-11: Ensure the plugin-panel component usage is correct.

The plugin-panel component is used correctly with the appropriate props and events. The scoped slots for the header and content are well-defined.


12-33: Review the tab and search functionality.

The tab and search functionality are implemented correctly. The tiny-tabs component is used for state management, and the tiny-search component is used for the search functionality. The tiny-button component is used for adding variables.


34-69: Review the dynamic panel rendering.

The dynamic panel rendering is implemented correctly. The data-source-list component is used to display the data source list, and the data-source-right-panel is conditionally rendered based on the isPanelShow state.


Line range hint 76-116: Ensure the new props and emits are correctly defined.

The new fixedPanels prop and fix-panel emit are correctly defined. The prop type is specified as Array.


Line range hint 117-137: Review the reactive state management and provide functionality.

The reactive state management and provide functionality are correctly implemented. The panelState object is used to share the emit event across components.


Line range hint 138-396: Review the methods for handling panel events and data operations.

The methods for handling panel events (openPanel, cancel, confirm, closePanel, etc.) and data operations (add, remove, removeStore, etc.) are correctly implemented. The logic for managing the state and interacting with the canvas API is well-defined.


518-518: Ensure the styles are correctly defined and scoped.

The styles for the data-source component and its child elements are correctly defined and scoped. The use of CSS variables ensures consistency with the design guidelines.

packages/settings/events/src/Main.vue Show resolved Hide resolved
packages/settings/events/src/Main.vue Show resolved Hide resolved
packages/plugins/script/src/Main.vue Show resolved Hide resolved
packages/plugins/script/src/Main.vue Show resolved Hide resolved
packages/plugins/tree/src/Main.vue Show resolved Hide resolved
packages/plugins/tree/src/Main.vue Show resolved Hide resolved
@STATICHIT
Copy link
Author

已完成所有commit的签名

@Issues-translate-bot
Copy link

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


Signing of all commits completed

@hexqi hexqi merged commit fe45952 into opentiny:ospp-2024/002-plugin-layout Jul 27, 2024
1 check passed
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.

None yet

5 participants