Skip to content

fix: menu type is not 'button' #6277

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ali-pay
Copy link
Contributor

@ali-pay ali-pay commented May 26, 2025

Description

fix: menu type is not 'button'

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • Bug Fixes
    • Updated form field visibility and validation rules to correctly respond to the "button" type instead of "action", ensuring accurate display and validation of form components based on menu item type.

Copy link

changeset-bot bot commented May 26, 2025

⚠️ No Changeset found

Latest commit: bbdb512

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented May 26, 2025

Walkthrough

The update modifies conditional logic in a form schema to use 'button' instead of 'action' as a menu item type. This affects the visibility, validation, and dependencies of several form fields, ensuring that the form now responds to the 'button' type for rendering and rules instead of 'action'.

Changes

File(s) Change Summary
playground/src/views/system/menu/modules/form.vue Updated conditional checks and dependencies from 'action' to 'button' for form field logic and visibility. Adjusted excluded type arrays from ['action', 'link'] to ['button', 'link'].

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Form
    participant Schema

    User->>Form: Selects menu item type
    Form->>Schema: Evaluates field conditions
    alt type is 'button'
        Schema->>Form: Show/validate fields for 'button'
    else type is not 'button'
        Schema->>Form: Hide/skip validation for those fields
    end
    Form->>User: Renders form with updated fields
Loading

Possibly related PRs

Suggested reviewers

  • anncwb
  • jinmao88
  • vince292007

Poem

A button, not an action, now leads the way,
In forms where menus come out to play.
Fields appear and vanish with glee,
Logic refined as clear as can be.
With every hop, the schema's tight—
A rabbit’s code, pure delight!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5330451 and bbdb512.

📒 Files selected for processing (1)
  • playground/src/views/system/menu/modules/form.vue (8 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test (windows-latest)
🔇 Additional comments (9)
playground/src/views/system/menu/modules/form.vue (9)

279-281: Correct exclusion of button type from badgeType field.

The badgeType field is appropriately hidden for 'button' type menus, maintaining the same logic as the previous 'action' type.


297-299: Consistent exclusion of button type from badge field.

The badge field correctly excludes 'button' type menus, maintaining consistency with the overall form logic.


316-318: Appropriate exclusion of button type from badgeVariants field.

The badgeVariants field is correctly hidden for 'button' type menus, following the established pattern for badge-related configurations.


327-329: Logical exclusion of button type from advanced settings divider.

The divider for advanced settings is appropriately hidden for both 'button' and 'link' types, as these simplified menu types don't require advanced configuration options.


374-376: Appropriate exclusion of button type from hideInMenu option.

The hideInMenu checkbox is correctly hidden for 'button' type menus, which makes sense as button-type menu items typically don't appear in navigation menus.


404-406: Logical exclusion of button type from hideInBreadcrumb option.

The hideInBreadcrumb checkbox is appropriately hidden for both 'button' and 'link' types, as these menu types typically don't participate in breadcrumb navigation.


419-421: Appropriate exclusion of button type from hideInTab option.

The hideInTab checkbox is correctly hidden for both 'button' and 'link' types, as these menu types typically don't appear as navigational tabs.


29-29:

✅ Verification successful

Verify that getMenuTypeOptions function includes the new 'button' type.

Since all references to 'action' have been changed to 'button', ensure that the getMenuTypeOptions() function on line 41 has been updated to return 'button' instead of 'action' in its options.


🏁 Script executed:

#!/bin/bash
# Description: Check the getMenuTypeOptions function implementation
# Expected: Should return 'button' type instead of 'action'

# Find and examine the getMenuTypeOptions function
ast-grep --pattern 'function getMenuTypeOptions() {
  $$$
}'

ast-grep --pattern 'const getMenuTypeOptions = () => {
  $$$
}'

# Also search for the file that exports this function
rg -A 10 "getMenuTypeOptions" --type ts --type js

Length of output: 4562


getMenuTypeOptions now returns "button"

  • Verified in playground/src/views/system/menu/data.ts (lines 6–22): the options array includes
    { color: 'error', label: $t('system.menu.typeButton'), value: 'button' }
    No changes needed in this function. Please scan the rest of the codebase for any leftover "action" references and update them as necessary.

243-248:

✅ Verification successful

Consistent implementation of menu type change from 'action' to 'button'.

The conditional logic has been properly updated to use 'button' instead of 'action' for both validation rules and field visibility. The authCode field now correctly requires validation for button-type menus.

However, please verify that this change has been implemented consistently across the entire codebase:


🏁 Script executed:

#!/bin/bash
# Description: Verify that all references to 'action' menu type have been updated to 'button'
# Expected: No remaining references to 'action' as a menu type in the codebase

# Search for potential remaining 'action' menu type references
rg -A 3 -B 3 "type.*===.*['\"]action['\"]" --type vue --type ts --type js
rg -A 3 -B 3 "values\.type.*['\"]action['\"]" --type vue --type ts --type js
rg -A 3 -B 3 "\[.*['\"]action['\"].*\]" --type vue --type ts --type js

# Check the getMenuTypeOptions function specifically
rg -A 10 "getMenuTypeOptions" --type vue --type ts --type js

Length of output: 412


🏁 Script executed:

#!/bin/bash
# Re-run verification using file globs instead of --type

# Search for direct comparisons to 'action'
rg -A3 -B3 "type.*===.*['\"]action['\"]" -g '*.vue' -g '*.ts' -g '*.js'

# Search for values.type checks against 'action'
rg -A3 -B3 "values\.type.*['\"]action['\"]" -g '*.vue' -g '*.ts' -g '*.js'

# Search for any array literals that include 'action'
rg -A3 -B3 "\[.*['\"]action['\"].*\]" -g '*.vue' -g '*.ts' -g '*.js'

# Inspect getMenuTypeOptions for any remaining 'action' labels
rg -A10 "getMenuTypeOptions" -g '*.vue' -g '*.ts' -g '*.js'

Length of output: 3431


Rename ‘action’ → ‘button’ applied globally

Ripgrep verification found no remaining comparisons or array entries using 'action' in .vue, .ts, or .js files. The getMenuTypeOptions in playground/src/views/system/menu/data.ts now correctly lists button, and form.vue uses button everywhere for visibility and validation rules.

All references have been updated—no further changes required.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant