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

fix:table slot edit params should not get alert #802

Merged
merged 4 commits into from
Sep 28, 2024

Conversation

ianxinnew
Copy link
Contributor

@ianxinnew ianxinnew commented Sep 19, 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: #764

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Enhanced slot management functionality for improved user experience.
    • Streamlined validation process with more context for parameter settings.
    • Improved clarity in slot binding and unbinding processes, including user confirmation for unbinding.
  • Bug Fixes

    • Improved accuracy in slot index handling during toggling operations.

Sorry, something went wrong.

Copy link
Contributor

coderabbitai bot commented Sep 19, 2024

Warning

Rate limit exceeded

@chilingling has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 29 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between fd94caf and 4aed423.

Walkthrough

The changes involve updates to the slot management functions within the MetaJsSlot.vue component. Key modifications include corrections to function names and enhancements to parameter handling. The toggleSlot function now includes an additional parameter to control modal behavior, while both setParams and validParams functions have been updated to accept new parameters for improved functionality. The logic for updating slot parameters has been centralized, enhancing clarity and maintainability.

Changes

Files Change Summary
packages/common/component/MetaJsSlot.vue - Updated toggleSlot to include isSetParams parameter.
- Modified setParams to accept idx.
- Changed parmasStringValidator to paramsStringValidator.
- Updated validParmas to validParams and adjusted its parameters.
- Refactored slot parameter handling into updateSlotParams.

Suggested reviewers

  • hexqi

Poem

In the meadow, slots do play,
With new tweaks that brighten the day.
Parameters dance, logic flows,
A smoother path for all that grows.
Hopping along, we cheer with glee,
For changes made, oh joy to see! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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: 1

Outside diff range and nitpick comments (1)
packages/common/component/MetaJsSlot.vue (1)

137-138: Maintain Consistent Parameter Order in Function Definitions

The setParams function currently defines parameters as (slot, idx), whereas other functions like toggleSlot and validParams use (idx, slot). For consistency and better readability, consider changing the parameter order in setParams to (idx, slot).

Apply this diff to adjust the parameter order:

--- a/packages/common/component/MetaJsSlot.vue
+++ b/packages/common/component/MetaJsSlot.vue
@@ -137,7 +137,7 @@
 
-        const setParams = (slot, idx) => {
+        const setParams = (idx, slot) => {
           slot.bind && toggleSlot(idx, slot, true)
         }
 
@@ -143,7 +143,7 @@
             if (!tips) {
-              setParams(slot, idx)
+              setParams(idx, slot)
             }
           })
         }

Also, update any calls to setParams accordingly.

Also applies to: 144-144

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2ce7c4a and 0ea4b16.

Files selected for processing (1)
  • packages/common/component/MetaJsSlot.vue (5 hunks)
Additional comments not posted (1)
packages/common/component/MetaJsSlot.vue (1)

95-95: Enhance User Experience with isSetParams Parameter in toggleSlot

The addition of the isSetParams boolean parameter to the toggleSlot function allows for conditional execution of the confirmation modal. This prevents the modal from appearing when parameters are set programmatically, improving the user experience by streamlining interactions.

Also applies to: 115-115

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

🧹 Outside diff range and nitpick comments (2)
packages/common/component/MetaJsSlot.vue (2)

98-98: Typographical Error in Comment

There's a typo in the comment on line 98. The phrase "不根新在jsslot中的数据非响应式" should be corrected to "不更新在jsslot中的数据非响应式" to improve readability.


Line range hint 164-166: Handle Undefined Component Names in componentsMap

In the watchEffect, if componentName is not in componentsMap, state.currentComponent will be undefined. This could lead to errors if state.currentComponent is expected to have content and icon properties.

Consider providing a default value to handle cases where componentName is not found:

 watchEffect(() => {
   const componentName = useCanvas().getCurrentSchema()?.componentName
-  state.currentComponent = componentsMap[componentName]
+  state.currentComponent = componentsMap[componentName] || {
+    content: '',
+    icon: null
+  }
 })
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0ea4b16 and ab745b9.

📒 Files selected for processing (1)
  • packages/common/component/MetaJsSlot.vue (3 hunks)
🔇 Additional comments (2)
packages/common/component/MetaJsSlot.vue (2)

20-26: Correction of Validator and Function Names

Great job updating the validator and function names from parmasStringValidator to paramsStringValidator and validParmas to validParams. This improves code readability and prevents potential confusion.


176-177: 🛠️ Refactor suggestion

Unused Return Value: componentsMap May Not Need to Be Returned

The componentsMap object is returned from the setup function but is not used in the template. Since it's only used internally within the watchEffect, you may not need to return it.

Consider removing componentsMap from the returned object if it's not used in the template:

 return {
   toggleSlot,
   slotList,
   paramsPropPath,
   slotRef,
   paramsStringValidator,
   validParams,
   state,
-  componentsMap
 }

Likely invalid or redundant comment.

hexqi
hexqi previously approved these changes Sep 28, 2024
@chilingling chilingling changed the title fix:table notch saving error message fix:table slot edit params should not get alert Sep 28, 2024
@hexqi hexqi merged commit 4ea63ab into opentiny:develop Sep 28, 2024
1 check passed
chilingling added a commit to chilingling/tiny-engine that referenced this pull request Dec 4, 2024
* fix:table notch saving error message

* fix: change slotparams cause warning

* fix: change by review

* fix: typo parma -> param

---------

Co-authored-by: chilingling <michaelchiling1024@gmail.com>
kevinmoch pushed a commit that referenced this pull request Dec 4, 2024
* fix:table notch saving error message

* fix: change slotparams cause warning

* fix: change by review

* fix: typo parma -> param

---------

Co-authored-by: chilingling <michaelchiling1024@gmail.com>
@coderabbitai coderabbitai bot mentioned this pull request Dec 7, 2024
14 tasks
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

3 participants