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: switch selected component event name list still show the origin one #757

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

chilingling
Copy link
Member

@chilingling chilingling commented Aug 26, 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?

修复画布切换选择组件后,高级面板事件列表仍然显示原组件事件列表的bug

Issue Number: close #747

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Enhanced event management with a new computed property, renderEventList, for improved data handling.
    • Streamlined integration of event data, ensuring the event list is always up-to-date.
  • Bug Fixes

    • Resolved discrepancies in event data display by consolidating sources into a single reactive property.
  • Refactor

    • Renamed state variable from state.componentEvents to renderEventList for clarity and efficiency.

修复画布切换选择组件后,高级面板事件列表仍然显示原组件事件列表的bug
close opentiny#747
Copy link
Contributor

coderabbitai bot commented Aug 26, 2024

Walkthrough

The changes in the codebase include the renaming of a state variable to renderEventList and the introduction of a computed property that consolidates event data from two sources. Additionally, the watchEffect has been updated to track this new computed property, ensuring that the component responds correctly to event data changes.

Changes

Files Change Summary
packages/settings/events/src/components/BindEvents.vue Renamed state.componentEvents to renderEventList and introduced a computed property to merge event data. Updated bindings to use the new computed property.

Assessment against linked issues

Objective Addressed Explanation
Ensure event list updates correctly when switching components (#747)

Poem

In the garden where events play,
A rabbit hops, brightening the day.
With lists now clear and data bright,
Every switch brings pure delight!
Hooray for changes, oh so grand,
In our code, we take a stand! 🐇✨


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.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 76c23b7 and 84a8547.

Files selected for processing (1)
  • packages/settings/events/src/components/BindEvents.vue (5 hunks)
Additional comments not posted (3)
packages/settings/events/src/components/BindEvents.vue (3)

129-129: Ensure the computed property renderEventList correctly merges event data.

The computed property renderEventList merges state.componentEvent and state.componentEvents. Ensure that the merging logic is correct and does not introduce any conflicts or data loss.

Verify the merging logic of renderEventList by checking the computed property implementation.

Verification successful

Merging logic of renderEventList is standard. The computed property renderEventList correctly merges state.componentEvent and state.componentEvents using the spread operator. This logic will overwrite any overlapping keys from state.componentEvent with those from state.componentEvents, which is typical behavior for object merging in JavaScript. If this is the intended behavior, no changes are necessary.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the merging logic of `renderEventList`.

# Test: Search for the computed property implementation. Expect: Correct merging logic.
rg --type vue 'const renderEventList = computed'

Length of output: 78


Script:

#!/bin/bash
# Locate the BindEvents.vue file and search for the renderEventList computed property.
fd 'BindEvents.vue' | xargs rg 'const renderEventList = computed'

Length of output: 165


31-34: Ensure the computed property renderEventList is reactive.

The computed property renderEventList is used correctly to iterate over the event list. Ensure that renderEventList is reactive and updates as expected when state.componentEvent or state.componentEvents change.

Verify the reactivity of renderEventList by checking the computed property implementation and its dependencies.

Verification successful

The renderEventList computed property is reactive.

The renderEventList computed property combines state.componentEvent and state.componentEvents, ensuring it updates reactively when these dependencies change. This confirms that the computed property will reflect changes in the underlying state.

  • renderEventList is defined as computed(() => ({ ...state.componentEvent, ...state.componentEvents })), ensuring reactivity.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the reactivity of `renderEventList`.

# Test: Search for the computed property implementation. Expect: Correct implementation of reactivity.
rg --type vue 'const renderEventList = computed'

Length of output: 78


Script:

#!/bin/bash
# Description: Verify the reactivity of `renderEventList` in Vue files using ast-grep.

# Test: Search for the computed property implementation of `renderEventList`.
ast-grep --lang vue --pattern 'const renderEventList = computed($_)' 

Length of output: 177


Script:

#!/bin/bash
# Description: Search for the `computed` keyword in the `BindEvents.vue` file to find the `renderEventList` implementation.

# Test: Search for the `computed` keyword in the `BindEvents.vue` file.
rg 'computed' packages/settings/events/src/components/BindEvents.vue -A 5

Length of output: 1006


81-84: Ensure renderEventList is reactive in AddEventsDialog.

The computed property renderEventList is passed as a prop to AddEventsDialog. Ensure that renderEventList is reactive and updates as expected when state.componentEvent or state.componentEvents change.

Verify the reactivity of renderEventList by checking the computed property implementation and its dependencies.

Verification successful

renderEventList is Reactive in AddEventsDialog. The computed property renderEventList is reactive as it depends on state.componentEvent and state.componentEvents, which are updated within a watchEffect. This ensures that any changes to these states will trigger the recomputation of renderEventList.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the reactivity of `renderEventList`.

# Test: Search for the computed property implementation. Expect: Correct implementation of reactivity.
rg --type vue 'const renderEventList = computed'

Length of output: 78


Script:

#!/bin/bash
# Use ast-grep to find the implementation of the computed property `renderEventList` in Vue files.
ast-grep --lang javascript --pattern 'const renderEventList = computed($_)' 

Length of output: 166


Script:

#!/bin/bash
# Use rg to search for the definition of `renderEventList` in .vue files.
rg 'renderEventList' --glob '*.vue' -A 5

Length of output: 3595

packages/settings/events/src/components/BindEvents.vue Outdated Show resolved Hide resolved
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 84a8547 and d73745e.

Files selected for processing (1)
  • packages/settings/events/src/components/BindEvents.vue (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/settings/events/src/components/BindEvents.vue

@@ -43,7 +43,7 @@
<div class="action-item bind-action-item">
<div class="binding-name" @click="openActionDialog(action)">
<div>
{{ action.eventName }}<span>{{ state.componentEvents[action.eventName].label.zh_CN }}</span>
{{ action.eventName }}<span>{{ renderEventList[action.eventName]?.label?.zh_CN }}</span>
Copy link
Collaborator

Choose a reason for hiding this comment

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

zh_CN建议改用locale,label?.[locale]

@@ -126,18 +126,18 @@ export default {

const isBlock = computed(() => Boolean(pageState.isBlock))
const isEmpty = computed(() => Object.keys(state.bindActions).length === 0)
const renderEventList = computed(() => ({ ...state.componentEvent, ...state.componentEvents }))
Copy link
Collaborator

Choose a reason for hiding this comment

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

这两个变量能否换一个名字,难区分容易弄错,并且state.componentEvent看起来也并不是单个事件的意思

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.

🐛 [Bug]: 画布切换组件后绑定事件列表依然还是原组件的绑定事件列表
2 participants