这是indexloc提供的服务,不要输入任何密码
Skip to content

feat(cascadepolicy): disable inputs if cascade policy exists #4175

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

Merged
merged 12 commits into from
Jul 18, 2025

Conversation

ahorowitz123
Copy link
Contributor

@ahorowitz123 ahorowitz123 commented Jul 11, 2025

Overview

This PR enhances the cascade policy user experience by preventing modifications to cascade policy options when a cascade policy already exists. Instead of allowing potentially confusing edits, the interface now clearly communicates why options are disabled and how users can modify them.

Changes Made

Core Functionality

  • Simplified cascade policy detection: Renamed isExistingAIExtractionCascadePolicy to isExistingCascadePolicy to broaden the scope from AI-specific to general cascade policy detection
  • UI state management: All cascade policy controls (radio buttons, AI folder extraction toggle, AI agent selector) are now disabled when an existing cascade policy is present

User Experience Improvements

  • Informational notice: Added an InlineNotice component that appears when cascade policy options are disabled
  • Clear guidance: The notice explains that cascade policy cannot be edited directly and provides instructions to deactivate and re-enable the policy for modifications
  • Accessibility: Added proper ARIA labels for the information icon

Technical Implementation

  • Localization: Added new i18n strings for the disabled notice message and accessibility labels
  • Component updates: Modified CascadePolicy component to handle the new disabled state and display the notice
  • Test coverage: Updated and consolidated tests to verify the new behavior, removed outdated snapshot tests
  • Documentation: Added Storybook stories to demonstrate enabled vs disabled cascade policy states

Files Modified

  • src/features/metadata-instance-editor/CascadePolicy.js - Main component logic and UI updates
  • src/features/metadata-instance-editor/Instance.js - Simplified cascade policy flag logic
  • src/features/metadata-instance-editor/messages.js - Added new localization messages
  • i18n/en-US.properties - Added new localization strings
  • Test files and Storybook stories updated accordingly

User Impact

  • Improved UX: Users can no longer accidentally modify cascade policy settings that cannot be changed
  • Clear communication: Users understand why options are disabled and how to modify them
  • Better accessibility: Screen readers can properly announce the disabled state and reasoning
Screenshot 2025-07-17 at 11 02 37 AM

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a notice explaining that cascade policy options cannot be edited directly and instructions to reset them.
    • Cascade policy and related options are now visually disabled and display a notice when an existing cascade policy is present.
  • Bug Fixes

    • Improved handling of disabled state for cascade policy and AI folder extraction options to prevent unintended changes.
  • Tests

    • Updated and consolidated tests to reflect the new disabled state and notice behavior.
    • Added Storybook stories to visually test enabled and disabled cascade policy states.
  • Documentation

    • Added new localization strings for the cascade policy disabled notice message.

@ahorowitz123 ahorowitz123 requested review from a team as code owners July 11, 2025 17:39
Copy link

coderabbitai bot commented Jul 11, 2025

"""

Walkthrough

The changes simplify the cascade policy flag handling by renaming and consolidating the existing AI extraction cascade policy flag to a general cascade policy flag. The CascadePolicy component disables relevant controls and shows an inline notice when a cascade policy exists. Tests and localization messages are updated accordingly, and new Storybook stories demonstrate enabled and disabled states.

Changes

File(s) Change Summary
i18n/en-US.properties, src/features/metadata-instance-editor/messages.js Added new localization strings/messages for a notice explaining that cascade policy options are disabled when an existing cascade policy is present, including an ARIA label for the info icon.
src/features/metadata-instance-editor/CascadePolicy.js Renamed prop isExistingAIExtractionCascadePolicy to isExistingCascadePolicy; added an inline notice and disabled cascade policy controls (RadioButtons, Toggle, AgentSelector) when flag is true.
src/features/metadata-instance-editor/Instance.js Simplified cascade policy flag logic by replacing isExistingAIExtractionCascadePolicy with isExistingCascadePolicy based solely on cascade enablement; updated prop passed to CascadePolicy.
src/features/metadata-instance-editor/tests/CascadePolicy.test.js Refactored tests to remove snapshot testing; added test verifying inline notice rendering when cascade policy exists; removed tests related to old AI extraction cascade policy prop and toggle logic.
src/features/metadata-instance-editor/tests/Instance.test.js Consolidated and updated tests to reflect new cascade policy flag and disabling logic; explicitly enable cascade policy before toggling AI extraction in tests; removed redundant tests.
src/features/metadata-instance-editor/stories/tests/CascadePolicy-visual.stories.js Added Storybook stories demonstrating CascadePolicy component with cascade policy options enabled and disabled, showing the new disabling behavior and inline notice.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MetadataInstanceEditor
    participant CascadePolicy

    User->>MetadataInstanceEditor: Open metadata instance editor
    MetadataInstanceEditor->>CascadePolicy: Render with isExistingCascadePolicy flag
    CascadePolicy->>CascadePolicy: Check isExistingCascadePolicy
    alt Cascade Policy Exists
        CascadePolicy->>User: Show InlineNotice message
        CascadePolicy->>User: Disable cascade policy controls (RadioButtons, Toggle, AgentSelector)
    else No Existing Policy
        CascadePolicy->>User: Show enabled cascade policy controls
    end
Loading

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • patlm
  • greg-in-a-box

Poem

🐇 A cascade locked, no edits here,
Controls disabled, message clear.
The rabbit hops, with tests in tow,
Stories show the states we know.
Disable, notify, and then proceed—
A smoother flow for users' need! 🌿✨
"""


📜 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 c5f2ccf and afec233.

⛔ Files ignored due to path filters (2)
  • src/features/metadata-instance-editor/__tests__/__snapshots__/CascadePolicy.test.js.snap is excluded by !**/*.snap
  • src/features/metadata-instance-editor/__tests__/__snapshots__/Instance.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • i18n/en-US.properties (1 hunks)
  • src/features/metadata-instance-editor/CascadePolicy.js (7 hunks)
  • src/features/metadata-instance-editor/Instance.js (2 hunks)
  • src/features/metadata-instance-editor/__tests__/CascadePolicy.test.js (1 hunks)
  • src/features/metadata-instance-editor/__tests__/Instance.test.js (2 hunks)
  • src/features/metadata-instance-editor/messages.js (1 hunks)
  • src/features/metadata-instance-editor/stories/tests/CascadePolicy-visual.stories.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/features/metadata-instance-editor/messages.js
  • src/features/metadata-instance-editor/Instance.js
  • i18n/en-US.properties
  • src/features/metadata-instance-editor/stories/tests/CascadePolicy-visual.stories.js
  • src/features/metadata-instance-editor/tests/CascadePolicy.test.js
  • src/features/metadata-instance-editor/tests/Instance.test.js
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ahorowitz123
PR: box/box-ui-elements#4102
File: src/features/metadata-instance-editor/Instance.js:647-649
Timestamp: 2025-05-14T17:46:25.370Z
Learning: In the metadata-instance-editor component, `isExistingAIExtractionCascadePolicy` specifically checks if the cascade policy fetched from the backend has AI folder extraction enabled, using props rather than state to reflect the original server-side configuration rather than current UI state.
src/features/metadata-instance-editor/CascadePolicy.js (6)
Learnt from: ahorowitz123
PR: box/box-ui-elements#4102
File: src/features/metadata-instance-editor/Instance.js:647-649
Timestamp: 2025-05-14T17:46:25.370Z
Learning: In the metadata-instance-editor component, `isExistingAIExtractionCascadePolicy` specifically checks if the cascade policy fetched from the backend has AI folder extraction enabled, using props rather than state to reflect the original server-side configuration rather than current UI state.
Learnt from: jpan-box
PR: box/box-ui-elements#4166
File: src/elements/content-sidebar/SidebarNav.js:126-126
Timestamp: 2025-07-11T14:43:02.677Z
Learning: In the box-ui-elements repository, there's a file-type-based pattern for internationalization: TypeScript files (.tsx) predominantly use the modern useIntl hook (41 vs 15 files), while JavaScript files (.js) predominantly use the legacy injectIntl HOC (64 vs 5 files). New TypeScript components should use useIntl, while existing JavaScript components typically continue using injectIntl for consistency.
Learnt from: rafalmaksymiuk
PR: box/box-ui-elements#4160
File: src/elements/content-sidebar/SidebarToggle.js:21-27
Timestamp: 2025-06-25T13:09:54.538Z
Learning: The box-ui-elements project uses Flow for type annotations in JavaScript files, as indicated by @flow directives in file headers. Type annotations like `: Props` are valid Flow syntax, not TypeScript syntax.
Learnt from: rafalmaksymiuk
PR: box/box-ui-elements#4144
File: src/elements/content-sidebar/versions/VersionsList.js:24-33
Timestamp: 2025-06-17T13:30:02.172Z
Learning: In the box-ui-elements codebase, Flow components use .flow.js type definition files, not TypeScript .ts files. The InternalSidebarNavigation type is a union type where different variants may have different properties like versionId, and proper type safety is ensured through conditional checks in methods like getSelectedVersionId.
Learnt from: rafalmaksymiuk
PR: box/box-ui-elements#4160
File: src/elements/content-sidebar/SidebarToggle.js:13-19
Timestamp: 2025-06-25T13:09:45.168Z
Learning: Files with `@flow` or `@flow strict` comments at the top use Flow type syntax, not TypeScript. Flow type definitions like `type Props = { ... }` and type imports like `type { RouterHistory }` are valid Flow syntax and should not be flagged as TypeScript-only features.
Learnt from: rafalmaksymiuk
PR: box/box-ui-elements#4160
File: src/elements/content-sidebar/SidebarToggle.js:11-11
Timestamp: 2025-06-25T13:10:19.128Z
Learning: In the box-ui-elements codebase, Flow files support `import type` syntax for type-only imports. The `import type` statement is valid Flow syntax, not just TypeScript, and should not be flagged as an error when used in Flow files (indicated by @flow comments).
🧬 Code Graph Analysis (1)
src/features/metadata-instance-editor/CascadePolicy.js (1)
src/features/metadata-instance-editor/messages.js (1)
  • messages (3-249)
🪛 Biome (1.9.4)
src/features/metadata-instance-editor/CascadePolicy.js

[error] 61-61: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary
🔇 Additional comments (6)
src/features/metadata-instance-editor/CascadePolicy.js (6)

3-3: LGTM! Import changes support the new functionality.

The addition of useIntl for accessing formatted messages and InlineNotice for displaying the informational notice are correctly implemented.

Also applies to: 5-5


41-41: LGTM! Prop renaming generalizes cascade policy detection.

The renaming from isExistingAIExtractionCascadePolicy to isExistingCascadePolicy correctly generalizes the detection beyond AI-specific policies, aligning with the PR objectives.

Also applies to: 56-56


62-62: LGTM! Modern hook usage with proper destructuring.

The destructuring of formatMessage from useIntl() follows modern React patterns and addresses the previous review suggestion.


72-79: LGTM! Well-implemented informational notice with accessibility support.

The conditional InlineNotice effectively communicates why cascade policy options are disabled and provides clear guidance on how to modify the policy. The accessibility enhancement with the aria label is a nice touch.


127-127: LGTM! Comprehensive disabled state implementation.

All cascade policy-related controls (radio buttons, AI folder extraction toggle, and AI agent selector) are consistently disabled when an existing cascade policy exists, preventing potentially confusing or invalid edits.

Also applies to: 132-132, 149-149, 165-165


61-61: Static analysis false positive - Flow types are valid.

The static analysis tool incorrectly flags Flow type annotations as TypeScript-only syntax. This file uses Flow (indicated by the @flow directive), and the type annotations are valid Flow syntax.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

Copy link

@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

🧹 Nitpick comments (2)
src/features/metadata-instance-editor/messages.js (1)

210-215: Align tooltip punctuation and wording with surrounding messages.

Nearly all defaultMessage strings in this file terminate with a period and avoid repetitive phrasing. Adding the final period and replacing the second “policy” with “it” tightens the copy and keeps style consistent.

-            'Cascade policy cannot be edited. To change the policy, remove the current policy to set up a new one'
+            'Cascade policy cannot be edited. To change it, remove the current policy and set up a new one.'
i18n/en-US.properties (1)

1228-1228: Consider slight wording refinement for clarity

Rewrite the second sentence as “… and set up a new one” to make the sequence of actions clearer and avoid repeating “policy.”

-boxui.metadataInstanceEditor.cascadePolicyOptionsDisabledTooltip = Cascade policy cannot be edited. To change the policy, remove the current policy to set up a new one
+boxui.metadataInstanceEditor.cascadePolicyOptionsDisabledTooltip = Cascade policy cannot be edited. To change the policy, remove the current policy and set up a new one
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 035cffb and 70e305c.

⛔ Files ignored due to path filters (2)
  • src/features/metadata-instance-editor/__tests__/__snapshots__/CascadePolicy.test.js.snap is excluded by !**/*.snap
  • src/features/metadata-instance-editor/__tests__/__snapshots__/Instance.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • i18n/en-US.properties (1 hunks)
  • src/features/metadata-instance-editor/CascadePolicy.js (7 hunks)
  • src/features/metadata-instance-editor/Instance.js (2 hunks)
  • src/features/metadata-instance-editor/__tests__/CascadePolicy.test.js (0 hunks)
  • src/features/metadata-instance-editor/__tests__/Instance.test.js (2 hunks)
  • src/features/metadata-instance-editor/messages.js (1 hunks)
  • src/features/metadata-instance-editor/stories/tests/CascadePolicy-visual.stories.js (1 hunks)
💤 Files with no reviewable changes (1)
  • src/features/metadata-instance-editor/tests/CascadePolicy.test.js
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: ahorowitz123
PR: box/box-ui-elements#4102
File: src/features/metadata-instance-editor/Instance.js:647-649
Timestamp: 2025-05-14T17:46:25.370Z
Learning: In the metadata-instance-editor component, `isExistingAIExtractionCascadePolicy` specifically checks if the cascade policy fetched from the backend has AI folder extraction enabled, using props rather than state to reflect the original server-side configuration rather than current UI state.
src/features/metadata-instance-editor/messages.js (1)
Learnt from: ahorowitz123
PR: box/box-ui-elements#4102
File: src/features/metadata-instance-editor/Instance.js:647-649
Timestamp: 2025-05-14T17:46:25.370Z
Learning: In the metadata-instance-editor component, `isExistingAIExtractionCascadePolicy` specifically checks if the cascade policy fetched from the backend has AI folder extraction enabled, using props rather than state to reflect the original server-side configuration rather than current UI state.
i18n/en-US.properties (1)

undefined

<retrieved_learning>
Learnt from: ahorowitz123
PR: #4102
File: src/features/metadata-instance-editor/Instance.js:647-649
Timestamp: 2025-05-14T17:46:25.370Z
Learning: In the metadata-instance-editor component, isExistingAIExtractionCascadePolicy specifically checks if the cascade policy fetched from the backend has AI folder extraction enabled, using props rather than state to reflect the original server-side configuration rather than current UI state.
</retrieved_learning>

src/features/metadata-instance-editor/Instance.js (1)
Learnt from: ahorowitz123
PR: box/box-ui-elements#4102
File: src/features/metadata-instance-editor/Instance.js:647-649
Timestamp: 2025-05-14T17:46:25.370Z
Learning: In the metadata-instance-editor component, `isExistingAIExtractionCascadePolicy` specifically checks if the cascade policy fetched from the backend has AI folder extraction enabled, using props rather than state to reflect the original server-side configuration rather than current UI state.
src/features/metadata-instance-editor/stories/tests/CascadePolicy-visual.stories.js (1)
Learnt from: ahorowitz123
PR: box/box-ui-elements#4102
File: src/features/metadata-instance-editor/Instance.js:647-649
Timestamp: 2025-05-14T17:46:25.370Z
Learning: In the metadata-instance-editor component, `isExistingAIExtractionCascadePolicy` specifically checks if the cascade policy fetched from the backend has AI folder extraction enabled, using props rather than state to reflect the original server-side configuration rather than current UI state.
src/features/metadata-instance-editor/__tests__/Instance.test.js (1)
Learnt from: ahorowitz123
PR: box/box-ui-elements#4102
File: src/features/metadata-instance-editor/Instance.js:647-649
Timestamp: 2025-05-14T17:46:25.370Z
Learning: In the metadata-instance-editor component, `isExistingAIExtractionCascadePolicy` specifically checks if the cascade policy fetched from the backend has AI folder extraction enabled, using props rather than state to reflect the original server-side configuration rather than current UI state.
src/features/metadata-instance-editor/CascadePolicy.js (4)
Learnt from: ahorowitz123
PR: box/box-ui-elements#4102
File: src/features/metadata-instance-editor/Instance.js:647-649
Timestamp: 2025-05-14T17:46:25.370Z
Learning: In the metadata-instance-editor component, `isExistingAIExtractionCascadePolicy` specifically checks if the cascade policy fetched from the backend has AI folder extraction enabled, using props rather than state to reflect the original server-side configuration rather than current UI state.
Learnt from: rafalmaksymiuk
PR: box/box-ui-elements#4160
File: src/elements/content-sidebar/SidebarToggle.js:21-27
Timestamp: 2025-06-25T13:09:54.538Z
Learning: The box-ui-elements project uses Flow for type annotations in JavaScript files, as indicated by @flow directives in file headers. Type annotations like `: Props` are valid Flow syntax, not TypeScript syntax.
Learnt from: jpan-box
PR: box/box-ui-elements#4166
File: src/elements/content-sidebar/SidebarNav.js:126-126
Timestamp: 2025-07-11T14:43:02.641Z
Learning: In the box-ui-elements repository, there's a file-type-based pattern for internationalization: TypeScript files (.tsx) predominantly use the modern useIntl hook (41 vs 15 files), while JavaScript files (.js) predominantly use the legacy injectIntl HOC (64 vs 5 files). New TypeScript components should use useIntl, while existing JavaScript components typically continue using injectIntl for consistency.
Learnt from: rafalmaksymiuk
PR: box/box-ui-elements#4144
File: src/elements/content-sidebar/versions/VersionsList.js:24-33
Timestamp: 2025-06-17T13:30:02.172Z
Learning: In the box-ui-elements codebase, Flow components use .flow.js type definition files, not TypeScript .ts files. The InternalSidebarNavigation type is a union type where different variants may have different properties like versionId, and proper type safety is ensured through conditional checks in methods like getSelectedVersionId.
🪛 Biome (1.9.4)
src/features/metadata-instance-editor/CascadePolicy.js

[error] 52-55: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary
🔇 Additional comments (8)
src/features/metadata-instance-editor/Instance.js (2)

644-644: LGTM! Clean simplification of cascade policy logic.

The simplified logic correctly determines if a cascade policy exists by checking if cascading is enabled through props. This is cleaner than the previous approach and aligns well with the PR objective of disabling options when any cascade policy exists.


683-683: Prop renaming is consistent and clear.

The prop name isExistingCascadePolicy is more descriptive and aligns with the simplified logic in the component.

src/features/metadata-instance-editor/stories/tests/CascadePolicy-visual.stories.js (1)

1-61: Excellent visual test coverage for the tooltip functionality.

The Storybook stories provide comprehensive coverage of the enabled/disabled states and tooltip behavior:

  • Proper use of TooltipProvider wrapper
  • Clear test scenarios with descriptive names
  • Appropriate use of userEvent.hover() for testing tooltip visibility
  • Good reliance on Chromatic snapshots for visual verification

The stories effectively demonstrate the new UI behavior introduced by the cascade policy changes.

src/features/metadata-instance-editor/CascadePolicy.js (3)

48-71: Well-designed conditional tooltip wrapper component.

The MetadataEditorWrapper component provides a clean abstraction for conditionally wrapping children with a tooltip when cascade policy options are disabled. The implementation:

  • Properly handles the conditional rendering logic
  • Spreads additional props correctly with ...rest
  • Maintains clean separation of concerns
  • Uses the appropriate Blueprint Web Tooltip component

This is a good pattern for reusable conditional tooltip behavior.


142-147: Comprehensive disabled state implementation.

All interactive elements are properly disabled when isExistingCascadePolicy is true:

  • RadioButton components for cascade mode selection
  • Toggle for AI folder extraction
  • BoxAiAgentSelector component

This ensures users cannot modify cascade policy settings when a policy already exists, which aligns perfectly with the PR objective.

Also applies to: 167-167, 183-183


52-55: Ignore the static analysis warning - Flow syntax is correct.

The static analysis warning about TypeScript-only syntax is a false positive. Based on the retrieved learnings, this codebase uses Flow for type annotations in JavaScript files, and the syntax { children: React.Node, isExistingCascadePolicy?: boolean } is valid Flow syntax.

The warning can be safely ignored as Flow type annotations are the standard pattern in this codebase.

src/features/metadata-instance-editor/__tests__/Instance.test.js (2)

837-847: Improved test reliability with explicit cascade policy setup.

The tests now explicitly enable the cascade policy before testing AI extraction functionality:

  • Uses simplified cascadePolicy: { canEdit: true } prop
  • Explicitly clicks the cascade policy toggle before testing AI extraction
  • Makes the test flow more predictable and reliable

This is a good improvement that makes the test setup more explicit and easier to understand.

Also applies to: 896-904


874-891: Comprehensive test coverage for disabled state.

The consolidated test effectively verifies that all cascade policy options are properly disabled when a cascade policy exists:

  • Checks both skip and overwrite radio buttons are disabled
  • Verifies the AI toggle is disabled
  • Tests the core functionality introduced by this PR

The test structure is clean and provides good coverage of the new behavior.

@ahorowitz123
Copy link
Contributor Author

@CodeRabbit can you update the PR description with the changes

Copy link

coderabbitai bot commented Jul 17, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

I'll help you update the PR description with the changes. Let me first get the current PR description and then create an updated version that better reflects the actual changes made.


🏁 Script executed:

#!/bin/bash
# Get the current PR description
gh pr view 4175 --json title,body

Length of output: 2873


Now I'll create an updated PR description that provides more comprehensive information about the changes made:


🏁 Script executed:

#!/bin/bash
# Update the PR description with more comprehensive information
gh pr edit 4175 --body "## Overview

This PR enhances the cascade policy user experience by preventing modifications to cascade policy options when a cascade policy already exists. Instead of allowing potentially confusing edits, the interface now clearly communicates why options are disabled and how users can modify them.

## Changes Made

### Core Functionality
- **Simplified cascade policy detection**: Renamed \`isExistingAIExtractionCascadePolicy\` to \`isExistingCascadePolicy\` to broaden the scope from AI-specific to general cascade policy detection
- **UI state management**: All cascade policy controls (radio buttons, AI folder extraction toggle, AI agent selector) are now disabled when an existing cascade policy is present

### User Experience Improvements
- **Informational notice**: Added an \`InlineNotice\` component that appears when cascade policy options are disabled
- **Clear guidance**: The notice explains that cascade policy cannot be edited directly and provides instructions to deactivate and re-enable the policy for modifications
- **Accessibility**: Added proper ARIA labels for the information icon

### Technical Implementation
- **Localization**: Added new i18n strings for the disabled notice message and accessibility labels
- **Component updates**: Modified \`CascadePolicy\` component to handle the new disabled state and display the notice
- **Test coverage**: Updated and consolidated tests to verify the new behavior, removed outdated snapshot tests
- **Documentation**: Added Storybook stories to demonstrate enabled vs disabled cascade policy states

## Files Modified
- \`src/features/metadata-instance-editor/CascadePolicy.js\` - Main component logic and UI updates
- \`src/features/metadata-instance-editor/Instance.js\` - Simplified cascade policy flag logic
- \`src/features/metadata-instance-editor/messages.js\` - Added new localization messages
- \`i18n/en-US.properties\` - Added new localization strings
- Test files and Storybook stories updated accordingly

## User Impact
- **Improved UX**: Users can no longer accidentally modify cascade policy settings that cannot be changed
- **Clear communication**: Users understand why options are disabled and how to modify them
- **Better accessibility**: Screen readers can properly announce the disabled state and reasoning

<!--
Please add the \`ready-to-merge\` label when the pull request has received the appropriate approvals.
Using the \`ready-to-merge\` label adds your approved pull request to the merge queue where it waits to be merged.
Mergify will merge your pull request based on the queue assuming your pull request is still in a green state after the previous merge.

What to do when the \`ready-to-merge\` label is not working:

- Do you have two approvals?
  - At least two approvals are required in order to merge to the master branch.
- Are there any reviewers that are still requested for review?
  - If the pull request has received the necessary approvals, remove any additional reviewer requests that are pending.
    - e.g.
      - Three reviewers added comments but you already have two necessary approvals and the third reviewer's comments are no longer applicable. You can remove the third person as a reviewer or have them approve the pull request.
      - A team was added as a reviewer because of a change to a file but the file change has been undone. At this point, it should be safe to remove the team as a reviewer.
- Are there other pull requests at the front of the merge queue?
  - Mergify handles the queueing, your pull request will eventually get merged.

When to contact someone for assistance when trying to merge via \`ready-to-merge\` label:

- There are no other pull requests in the merge queue and your pull request has been sitting there with the \`ready-to-merge\` label for longer than a couple of hours.
- If you are unable to remove unnecessary reviewers from the pull request.
- If you are unable to add the \`ready-to-merge\` label.
  -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Added a notice explaining that cascade policy options cannot be edited directly and instructions to reset them.
  * Cascade policy and related options are now visually disabled and display a notice when an existing cascade policy is present.

* **Bug Fixes**
  * Improved handling of disabled state for cascade policy and AI folder extraction options to prevent unintended changes.

* **Tests**
  * Updated and consolidated tests to reflect the new disabled state and notice behavior.
  * Added Storybook stories to visually test enabled and disabled cascade policy states.

* **Documentation**
  * Added new localization strings for the cascade policy disabled notice message.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->"

Length of output: 4898


@ahorowitz123 I've successfully updated the PR description with comprehensive information about the changes made. The new description includes:

What was added:

Overview section - Explains the purpose and user experience enhancement

Detailed changes breakdown organized into:

  • Core functionality changes (prop renaming and UI state management)
  • User experience improvements (notice component and accessibility)
  • Technical implementation details (localization, tests, documentation)

Files modified section - Lists all the key files that were changed

User impact section - Explains the benefits to end users

The updated description provides a much clearer picture of what this PR accomplishes, making it easier for reviewers and future developers to understand the scope and impact of the changes. It maintains the original merge instructions and CodeRabbit summary while providing more comprehensive context about the cascade policy disabling functionality.

   🐇
╭─────╮
│ ✨📝 │
╰─────╯
  Updated!

🧠 Learnings used
Learnt from: ahorowitz123
PR: box/box-ui-elements#4102
File: src/features/metadata-instance-editor/Instance.js:647-649
Timestamp: 2025-05-14T17:46:25.370Z
Learning: In the metadata-instance-editor component, `isExistingAIExtractionCascadePolicy` specifically checks if the cascade policy fetched from the backend has AI folder extraction enabled, using props rather than state to reflect the original server-side configuration rather than current UI state.

bkepka-box
bkepka-box previously approved these changes Jul 18, 2025
jmcbgaston
jmcbgaston previously approved these changes Jul 18, 2025
@mergify mergify bot merged commit b6d778c into box:master Jul 18, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants