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:增加预览、保存apis #800

Closed
wants to merge 2 commits into from

Conversation

yy-wow
Copy link
Collaborator

@yy-wow yy-wow commented Sep 14, 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. 预览增加beforePreview、afterPreview生命周期配置,previewMethod预览方法;
  2. 保存增加beforeSave、saved生命周期配置,saveMethod保存方法;
  3. 修复事件绑定弹窗不显示问题;
  4. 增加导出获取组件显示隐藏配置的方法

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced getCondition function to retrieve the current state of conditions, enhancing dynamic rendering capabilities.
    • Enhanced BindEventsDialog with improved visibility handling and asynchronous save operations.
    • Updated preview functionality to allow pre- and post-preview hooks for better customization.
    • Enhanced save operations with pre-save and post-save hooks for improved workflow flexibility.
  • Bug Fixes

    • Resolved visibility handling issues in the BindEventsDialog component.

These updates enhance user interactivity and provide more robust control over rendering and saving processes.

Copy link
Contributor

coderabbitai bot commented Sep 14, 2024

Walkthrough

The pull request introduces several enhancements across multiple files, focusing on the addition of the getCondition function for managing rendering conditions and improvements to dialog and save functionalities. Key changes include the integration of asynchronous operations in various methods, allowing for pre- and post-processing hooks, and modifications to how visibility states are handled in components. These updates collectively aim to enhance the modularity and flexibility of the rendering and saving processes.

Changes

File Path Change Summary
packages/canvas/render/src/RenderMain.js Added getCondition function to export for enhanced rendering capabilities.
packages/canvas/render/src/context.js Introduced getCondition to retrieve the current state of conditions.
packages/settings/events/src/components/BindEventsDialog.vue Modified visibility handling with :visible binding and updated confirm function to be asynchronous.
packages/toolbars/preview/src/Main.vue Enhanced preview function with asynchronous operations and hooks for pre- and post-preview actions.
packages/toolbars/save/src/Main.vue Updated openApi function to include pre-save and post-save hooks with asynchronous logic.
packages/toolbars/save/src/js/index.js Enhanced openCommon function with pre-save and post-save processes using getOptions.

Possibly related PRs

Suggested labels

ospp-2024, ready_for_review

Poem

🐰 In the garden where changes bloom,
New functions sprout, dispelling gloom.
With hooks for save and previews bright,
Our code hops forward, a joyful sight!
So let us cheer for the work that's done,
Together we thrive, coding's more fun! 🌼

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f4ecc76 and 6179d58.

Files selected for processing (1)
  • packages/toolbars/preview/src/Main.vue (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/toolbars/preview/src/Main.vue

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.

@github-actions github-actions bot added the refactor-main refactor/develop branch feature label Sep 14, 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

Outside diff range and nitpick comments (2)
packages/canvas/render/src/context.js (1)

54-55: LGTM! Consider adding a parameter to retrieve a specific condition.

The addition of the getCondition function is a good enhancement to the module's API, as it allows external access to the visibility states of conditions.

However, consider adding a parameter to the function to allow retrieving the visibility state of a specific condition, instead of returning the entire conditions object. This would provide more flexibility and could potentially improve performance by avoiding unnecessary data exposure.

-export const getCondition = () => conditions
+export const getCondition = (id) => id ? conditions[id] : conditions
packages/toolbars/preview/src/Main.vue (1)

Line range hint 38-84: Enhance the preview function with async operations and callbacks.

The changes to the preview function, making it an async function and incorporating the beforePreview, previewMethod, and afterPreview callbacks, enhance the flexibility and customization of the preview behavior. This allows for pre- and post-processing hooks and modular control over the preview process. The early exit based on the return value of previewMethod provides a way to conditionally prevent further execution of the preview logic.

Fix the unused afterPreview and undefined previewed issues.

The code assigns afterPreview from getOptions but never uses it. Additionally, it attempts to invoke previewed as a function, but it is not defined anywhere in the code.

Apply this diff to fix the issues:

-const { beforePreview, previewMethod, afterPreview } = getOptions(meta.id)
+const { beforePreview, previewMethod, previewed } = getOptions(meta.id)

// ...

if (typeof previewed === 'function') {
  await previewed()
}
Tools
GitHub Check: push-check

[failure] 39-39:
'afterPreview' is assigned a value but never used. Allowed unused vars must match /^_/u

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 80a36d6 and f4ecc76.

Files selected for processing (6)
  • packages/canvas/render/src/RenderMain.js (2 hunks)
  • packages/canvas/render/src/context.js (1 hunks)
  • packages/settings/events/src/components/BindEventsDialog.vue (4 hunks)
  • packages/toolbars/preview/src/Main.vue (3 hunks)
  • packages/toolbars/save/src/Main.vue (2 hunks)
  • packages/toolbars/save/src/js/index.js (3 hunks)
Additional context used
GitHub Check: push-check
packages/toolbars/preview/src/Main.vue

[failure] 39-39:
'afterPreview' is assigned a value but never used. Allowed unused vars must match /^_/u


[failure] 83-83:
'previewed' is not defined

Additional comments not posted (10)
packages/toolbars/save/src/js/index.js (3)

20-20: LGTM!

The import statement for getOptions is correct.


26-26: LGTM!

The import statement for meta is correct.


Line range hint 100-162: Great job on enhancing the save workflow!

The changes introduce a more flexible and customizable save workflow by integrating pre-save and post-save processes. The use of beforeSave, saveMethod, and saved options allows for additional logic to be executed before and after the save operation, providing more control over the save process.

The code changes are well-structured, follow the existing coding style, and align with the PR objectives and the AI-generated summary. The use of typeof checks ensures that the options are only invoked if they are functions, and the stop variable is used effectively to determine whether to continue with the original openCommon function call based on the result of saveMethod.

Overall, these enhancements greatly improve the modularity and extensibility of the save functionality.

packages/settings/events/src/components/BindEventsDialog.vue (4)

3-3: LGTM!

Replacing v-show with :visible binding aligns with Vue's best practices for handling component visibility.


11-11: LGTM!

Passing the dialogVisible prop to the BindEventsDialogSidebar component allows it to react to the dialog's visibility state, which is a good practice.


30-30: LGTM!

The getOptions and getMetaApi imports are correctly used later in the code for accessing options and meta API.


Line range hint 171-206: LGTM!

The changes to the confirm function are well-implemented:

  • Making it asynchronous allows for pre-processing the method before saving it, which enhances the flexibility of the save operation.
  • Constructing the method as an object improves the clarity and structure of the data being handled.
packages/toolbars/save/src/Main.vue (1)

107-130: LGTM!

The changes made to the openApi function significantly enhance its functionality and provide a more robust control flow for the save operation. The integration of pre-save and post-save hooks allows for greater flexibility and customization. The early exit on loading state prevents multiple save operations from being triggered simultaneously. The conditional execution of openCommon based on the result of saveMethod provides fine-grained control over the save behavior.

Overall, these modifications improve the modularity and extensibility of the save operation.

packages/canvas/render/src/RenderMain.js (2)

27-27: LGTM!

The export statement for getCondition is syntactically correct. The addition of this function to the exports suggests that it is a new getter introduced in the context module to retrieve a condition value.


444-444: LGTM!

The addition of getCondition to the api object is consistent with the export statement change and makes the function part of the module's public API. The code change is syntactically correct.

@@ -51,3 +51,5 @@ export const getContext = () => context
export const setCondition = (id, visible = false) => {
conditions[id] = visible
}

export const getCondition = () => conditions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以加末尾换行

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

@yy-wow yy-wow closed this Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor-main refactor/develop branch feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants