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: refactor wds menu and related components, widgets #33703

Merged
merged 6 commits into from
May 24, 2024
Merged

Conversation

KelvinOm
Copy link
Collaborator

@KelvinOm KelvinOm commented May 23, 2024

Description

  1. WDS menu component has been completely refactored. WDS headless component has been removed, we use react-aria-components instead. The menu component now has the ability to use submenus and icons for items.
  2. Rename components ActionGroup to ToolbarButtons and ButtonGrouptoInlineButtons`
  3. Make API of the ToolbarButtons, Menu, InlineButtons, Select consistent.
  4. Cosmetic refactoring of ToolbarButtons and InlineButtons and related widgets.

Fixes:
#32299
#32109

Automation

/ok-to-test tags="@tag.Anvil"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9210315418
Commit: b11c002
Cypress dashboard url: Click here!

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

@KelvinOm KelvinOm requested review from a team, riodeuno, jsartisan and marks0351 and removed request for a team May 23, 2024 14:39
@github-actions github-actions bot added the Bug Something isn't working label May 23, 2024
Copy link
Contributor

coderabbitai bot commented May 23, 2024

Walkthrough

Walkthrough

This update introduces significant enhancements and refactoring across various components of the design system. Key changes include the addition of new props to the Field component, reorganization and new functionality for the Menu component, introduction of InlineButtons and ToolbarButtons components, and updates to Select and Popover components. These modifications improve flexibility, accessibility, and usability of the components, while also refining their appearance and behavior.

Changes

File(s) Change Summary
.../Field/src/Field.tsx Added new props to FieldProps, adjusted necessityIndicator logic.
.../headless/src/index.ts Removed export of Menu component.
.../Icon/src/Icon.tsx Removed explicit type `
.../InlineButtons/src/InlineButton.tsx Introduced InlineButton component with state and item properties.
.../InlineButtons/src/InlineButtons.tsx Added functionality for rendering inline buttons with customizable properties.
.../InlineButtons/src/index.ts Exported InlineButtons and all types from types file.
.../InlineButtons/src/styles.module.css Renamed CSS class from .buttonGroup to .inlineButtons, added comments for style consistency.
.../InlineButtons/src/types.ts Refactored ButtonGroupProps to InlineButtonsProps, introduced InlineButtonsItem interface.
.../Menu/src/Menu.tsx Significant modifications to structure and functionality, added support for submenus, adjusted handling of disabled items and separators.
.../Menu/src/index.ts Reorganized exports, removed MenuList and Item, added MenuTrigger and all exports from types.
.../Menu/src/styles.module.css Adjusted styling for menu items, including padding and overflow properties.
.../Menu/src/types.ts Added properties to MenuProps, MenuItem, and MenuItemProps interfaces to support submenus and refine existing properties.
.../Menu/stories/Menu.stories.tsx Refactored rendering of menus and items, added handling for disabled items and items with icons.
.../Menu/stories/menuData.ts Defined arrays of menu items, submenus, and submenus with icons.
.../Popover/src/Popover.tsx Introduced Popover component wrapping Popover from react-aria-components, applying styles and passing down props.
.../Popover/src/index.ts Exported all from Popover module.
.../Select/src/ListBoxItem.tsx Provided custom ListBoxItem component for rendering list items with specific styling and typography.
.../Select/src/Select.tsx Replaced SpectrumSelect with HeadlessSelect, updated aria-label handling, adjusted classNames, modified rendering of ListBoxItem components within a Popover.
.../Select/src/styles.module.css Removed @import statement for colors, adjusted styles for .formField, .listBox, and .item classes, added padding rule for select items with icons.
.../Select/src/types.ts Updated SelectProps to extend SpectrumSelectProps excluding "slot" property, modified SelectItem to use id and label.
.../Select/stories/Select.stories.tsx Replaced import of SelectItem from types, added selectItems and selectItemsWithIcons, added WithIcons story.
.../ToolbarButtons/src/ToolbarButtons.tsx Introduced components for rendering toolbar buttons with customizable features, updated functionality for managing button states and actions.
.../ToolbarButtons/src/index.tsx Exported types from types.ts, exported ToolbarButtons component.
.../ToolbarButtons/src/styles.module.css Introduced styling rules for toolbar buttons, including alignment, spacing, and button appearance adjustments.
.../ToolbarButtons/src/types.ts Added TOOLBAR_BUTTONS_ALIGNMENTS constant, modified ToolbarButtonsProps interface, added ToolbarButtonsItem interface.
.../ToolbarButtons/src/useToolbarButtons.ts Renamed and restructured interfaces and functions, updated props and logic within useToolbarButtons function.
.../ToolbarButtons/stories/toolbarButtonsData.ts Defined arrays of toolbar button items with labels and optional icons for different engineering disciplines.
.../styles/src/index.ts Exported listItemStyles from "list-item.module.css".

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 9faab94 and b11c002.
Files ignored due to path filters (4)
  • app/client/package.json is excluded by !**/*.json
  • app/client/packages/design-system/headless/package.json is excluded by !**/*.json
  • app/client/packages/design-system/widgets/package.json is excluded by !**/*.json
  • app/client/yarn.lock is excluded by !**/*.lock, !**/*.lock
Files selected for processing (57)
  • app/client/packages/design-system/headless/src/components/Field/src/Field.tsx (2 hunks)
  • app/client/packages/design-system/headless/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Icon/src/Icon.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/InlineButtons/src/InlineButton.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/InlineButtons/src/InlineButtons.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/InlineButtons/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/InlineButtons/src/styles.module.css (2 hunks)
  • app/client/packages/design-system/widgets/src/components/InlineButtons/src/types.ts (2 hunks)
  • app/client/packages/design-system/widgets/src/components/InlineButtons/src/useInlineButtons.tsx (4 hunks)
  • app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/InlineButtons/stories/inlineButtonsData.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Menu/src/Menu.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Menu/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Menu/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Menu/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Menu/stories/Menu.stories.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Menu/stories/menuData.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Modal/stories/ModalExamples.tsx (3 hunks)
  • app/client/packages/design-system/widgets/src/components/Popover/src/Popover.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Popover/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Popover/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Select/src/ListBoxItem.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Select/src/Select.tsx (4 hunks)
  • app/client/packages/design-system/widgets/src/components/Select/src/styles.module.css (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Select/src/types.ts (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Select/stories/Select.stories.tsx (6 hunks)
  • app/client/packages/design-system/widgets/src/components/Select/stories/selectData.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/TextInput/stories/TextInput.stories.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButton.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/index.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/useToolbarButtons.ts (4 hunks)
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/toolbarButtonsData.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/styles/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/styles/src/list-item.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/testing/ComplexForm.tsx (3 hunks)
  • app/client/packages/storybook/.storybook/preview-head.html (1 hunks)
  • app/client/src/components/propertyControls/ButtonListControl.tsx (1 hunks)
  • app/client/src/components/propertyControls/ToolbarButtonListControl.tsx (1 hunks)
  • app/client/src/widgets/wds/WDSInlineButtonsWidget/component/index.tsx (3 hunks)
  • app/client/src/widgets/wds/WDSInlineButtonsWidget/component/types.ts (1 hunks)
  • app/client/src/widgets/wds/WDSInlineButtonsWidget/config/defaultsConfig.ts (3 hunks)
  • app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts (4 hunks)
  • app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/index.tsx (1 hunks)
  • app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/types.ts (1 hunks)
  • app/client/src/widgets/wds/WDSMenuButtonWidget/widget/index.tsx (3 hunks)
  • app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/HeaderCell.tsx (4 hunks)
  • app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/index.tsx (3 hunks)
  • app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/types.ts (1 hunks)
  • app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/defaultsConfig.ts (5 hunks)
  • app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/contentConfig.ts (2 hunks)
  • app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts (3 hunks)
  • app/client/src/widgets/wds/WDSToolbarButtonsWidget/widget/index.tsx (2 hunks)
Files not processed due to max files limit (1)
  • app/client/src/widgets/wds/WDSToolbarButtonsWidget/widget/types.ts
Files not summarized due to errors (3)
  • app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/contentConfig.ts: Error: Server error. Please try again later.
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx: Error: Server error. Please try again later.
  • app/client/packages/design-system/widgets/src/index.ts: Error: Server error. Please try again later.
Files not reviewed due to errors (3)
  • app/client/packages/design-system/widgets/src/components/Select/src/Select.tsx (no review received)
  • app/client/packages/design-system/headless/src/components/Field/src/Field.tsx (no review received)
  • app/client/packages/design-system/widgets/src/components/TextInput/stories/TextInput.stories.tsx (no review received)
Files skipped from review due to trivial changes (18)
  • app/client/packages/design-system/headless/src/index.ts
  • app/client/packages/design-system/widgets/src/components/Icon/src/Icon.tsx
  • app/client/packages/design-system/widgets/src/components/InlineButtons/src/index.ts
  • app/client/packages/design-system/widgets/src/components/InlineButtons/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/InlineButtons/stories/inlineButtonsData.ts
  • app/client/packages/design-system/widgets/src/components/Menu/src/index.ts
  • app/client/packages/design-system/widgets/src/components/Menu/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/Popover/src/index.ts
  • app/client/packages/design-system/widgets/src/components/Popover/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/Select/stories/Select.stories.tsx
  • app/client/packages/design-system/widgets/src/components/Select/stories/selectData.ts
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/index.tsx
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/toolbarButtonsData.ts
  • app/client/packages/design-system/widgets/src/styles/src/index.ts
  • app/client/packages/design-system/widgets/src/styles/src/list-item.module.css
  • app/client/packages/storybook/.storybook/preview-head.html
  • app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/HeaderCell.tsx
Additional comments not posted (57)
app/client/packages/design-system/widgets/src/components/Popover/src/Popover.tsx (1)

6-13: Well implemented use of HeadlessPopover with custom styles. The props handling is clean and effective.

app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/types.ts (1)

10-12: The extension of WidgetProps and InlineButtonsProps is correctly implemented. Good job on maintaining type safety and clarity.

app/client/packages/design-system/widgets/src/components/Select/src/ListBoxItem.tsx (1)

8-13: Effective use of HeadlessListBoxItem with conditional styling using clsx. The integration with typography utilities enhances consistency.

app/client/src/widgets/wds/WDSInlineButtonsWidget/component/types.ts (1)

8-9: The extension of InlineButtonsProps with additional functionalities like onButtonClick is well implemented. This enhances component interactivity.

app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/types.ts (1)

8-9: Proper extension of ToolbarButtonsProps with additional functionalities like onButtonClick. This setup allows for enhanced component interactivity and flexibility.

app/client/packages/design-system/widgets/src/components/Menu/src/types.ts (1)

8-27: The extension of HeadlessMenuProps and HeadlessMenuItemProps with additional properties to support submenus is well executed. This change aligns with the PR's objectives and enhances the Menu component's functionality.

app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButton.tsx (1)

1-26: The implementation of ToolbarButton is clean and follows best practices for React functional components with TypeScript. Good use of destructuring and forwarding refs.

app/client/packages/design-system/widgets/src/components/InlineButtons/src/InlineButton.tsx (1)

1-26: The InlineButton component is implemented consistently with the ToolbarButton, maintaining a clean and understandable codebase. Well done on ensuring consistency across components.

app/client/packages/design-system/widgets/src/index.ts (1)

20-21: The new exports for ToolbarButtons and InlineButtons are correctly added, ensuring these components are accessible throughout the project. Also, the export for Popover is correctly placed.

Also applies to: 25-25

app/client/packages/design-system/widgets/src/components/Select/src/types.ts (1)

Line range hint 1-32: The enhancements to the SelectProps and SelectItem interfaces are well-defined, improving the API's flexibility and clarity. Good use of TypeScript features to define precise and restrictive types.

app/client/packages/design-system/widgets/src/components/InlineButtons/src/types.ts (1)

Line range hint 1-39: The type definitions for InlineButtonsProps and InlineButtonsItem are well-crafted, providing clear and flexible APIs for the component. Excellent use of TypeScript's advanced types.

app/client/src/components/propertyControls/ToolbarButtonListControl.tsx (1)

27-28: The updates to the addOption method in ToolbarButtonListControl correctly implement the handling of icons and separators for toolbar buttons, aligning with the PR's objectives.

app/client/src/widgets/wds/WDSInlineButtonsWidget/config/defaultsConfig.ts (2)

18-19: Ensure consistency in button styling across the application.

Verification successful

The 'negative' color and 'outlined' variant are consistently used and supported across various components in the application.

  • Instances of 'negative' color found in multiple CSS files, indicating it is a well-supported theme color.
  • Instances of 'outlined' variant found in multiple CSS files, indicating it is a recognized variant.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the 'negative' color and 'outlined' variant are supported and consistently used across other components.

# Test: Search for the usage of 'negative' color and 'outlined' variant in other components.
rg --type css "negative" && rg --type css "outlined"

Length of output: 3463


37-38: Validate the use of color variants in the application's theme.

Also applies to: 47-48

Verification successful

The 'accent' color and 'outlined'/'filled' variants are defined in the application's theme settings, as evidenced by the search results in the CSS files.

  • accent color is defined in multiple places, such as styles.module.css, colors.module.css, and index.css.
  • outlined and filled variants are also defined in styles.module.css.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check if 'accent' color and 'outlined'/'filled' variants are defined in the application's theme settings.

# Test: Search for the 'accent' color and 'outlined'/'filled' variants in theme settings.
rg --type css "accent" && rg --type css "outlined|filled"

Length of output: 6094

app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/types.ts (3)

12-35: Ensure removed properties do not affect existing functionality.


37-42: Validate the use of icon, isLoading, and isDisabled properties in ToolbarButtonsItem.


7-10: Confirm the alignment options are sufficient for UI requirements.

Verification successful

The alignment options "Start" and "End" are indeed used across the application, confirming their necessity for UI requirements.

  • Instances of "End" alignment were found in various files, indicating its usage.
  • Numerous instances of "Start" alignment were also found, further validating its importance.

These findings confirm that the alignment options "Start" and "End" are sufficient and necessary for the application's UI requirements.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the alignment options 'Start' and 'End' meet the UI requirements across the application.

# Test: Check usage of alignment properties in ToolbarButtons across the application.
rg --type typescript "alignment:.*\(Start|End\)"

Length of output: 85



Script:

#!/bin/bash
# Description: Verify that the alignment options 'Start' and 'End' meet the UI requirements across the application.

# Test: Check usage of alignment properties in ToolbarButtons across the application.
rg --type ts "alignment:.*\(Start|End\)"

Length of output: 2608



Script:

#!/bin/bash
# Description: Verify that the alignment option 'Start' meets the UI requirements across the application.

# Test: Check usage of alignment properties in ToolbarButtons across the application.
rg --type ts "alignment:.*Start"

Length of output: 13407

app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/defaultsConfig.ts (2)

7-8: Ensure the 'ghost' variant and 'accent' color are supported and used consistently.

Verification successful

The 'ghost' variant and 'accent' color are defined in the application's theme settings and used consistently across various components.

  • ghost variant is defined in app/client/packages/design-system/widgets/src/components/Button/src/styles.module.css.
  • accent color is used in multiple files, including styles.module.css, colors.module.css, and token/src/styles.module.css.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the 'ghost' variant and 'accent' color are defined in the application's theme settings and used consistently across other components.

# Test: Search for the 'ghost' variant and 'accent' color in theme settings and other components.
rg --type css "ghost" && rg --type css "accent"

Length of output: 5811


22-23: Check for consistent icon usage and positioning across the application.

Also applies to: 32-33, 42-43, 62-63

app/client/packages/design-system/widgets/src/components/Menu/stories/menuData.ts (3)

3-13: Validate the completeness and correctness of the basic menu items.

The basic menu items are well-defined and appear to be correctly structured.


40-57: Check for consistent icon usage in submenu items with icons.

Verification successful

The search results indicate that the icon "galaxy" is used consistently across various components, including the submenu items in menuData.ts. Here are the relevant locations:

  • app/client/packages/design-system/widgets/src/components/Menu/stories/menuData.ts
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/toolbarButtonsData.ts
  • app/client/packages/design-system/widgets/src/components/InlineButtons/stories/inlineButtonsData.ts
  • app/client/packages/design-system/widgets/src/components/Select/stories/selectData.ts

The usage of the "galaxy" icon appears consistent in the submenu items as well as other components.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that icons are used consistently in submenu items across the application.

# Test: Search for the usage of icons in submenu items and their consistency.
rg --type typescript "icon:.*galaxy"

Length of output: 73



Script:

#!/bin/bash
# Description: Verify that icons are used consistently in submenu items across the application.

# Test: Search for the usage of icons in submenu items and their consistency.
rg --type ts "icon:.*galaxy"

Length of output: 1202


15-38: Ensure the hierarchical structure of submenu items is correctly implemented.

Verification successful

The search results indicate that the childItems property is used in multiple places within the codebase, including the menuData.ts file and the Menu.tsx file. This suggests that the hierarchical structure of submenu items is indeed implemented and utilized in the application.

  • menuData.ts: Contains the hierarchical data structure with childItems.
  • Menu.tsx: Processes and renders the childItems.

Based on this evidence, the hierarchical structure of submenu items appears to be correctly implemented.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the hierarchical structure of submenu items is correctly implemented and matches the UI specifications.

# Test: Check the rendering and functionality of submenu items in the application.
rg --type typescript "childItems"

Length of output: 68



Script:

#!/bin/bash
# Description: Verify that the hierarchical structure of submenu items is correctly implemented and matches the UI specifications.

# Test: Check the rendering and functionality of submenu items in the application.
rg --type ts "childItems"

Length of output: 816

app/client/src/widgets/wds/WDSInlineButtonsWidget/component/index.tsx (4)

3-3: Confirm the import and usage of InlineButtons from the design system.

The import and usage of InlineButtons from the design system are correctly implemented.


55-59: Check the rendering and functionality of the InlineButtons component.

The rendering and functionality of the InlineButtons component are correctly implemented and appear to be functioning as expected.


45-49: Verify the button action handling logic.

Verification successful

The button action handling logic appears to be correctly implemented. The onButtonClick function is defined in WDSInlineButtonsWidget/widget/index.tsx and is passed as a prop to InlineButtonsComponent in WDSInlineButtonsWidget/component/index.tsx. The function executes an action based on the onClick property and calls a callback upon completion.

  • WDSInlineButtonsWidget/widget/index.tsx:

    onButtonClick = (
      onClick: string | undefined,
      callback?: (result: ExecutionResult) => void,
    ) => {
      if (onClick) {
        super.executeAction({
          triggerPropertyName: "onClick",
          dynamicString: onClick,
          event: {
            type: EventType.ON_CLICK,
            callback: callback,
        });
      }
    };
  • WDSInlineButtonsWidget/component/index.tsx:

    const onAction = (key: Key) => {
      if (buttonsList[key].onClick) {
        setLoadingButtonIds([...loadingButtonIds, key as string]);
    
        onButtonClick(buttonsList[key].onClick, () =>
          onActionComplete(buttonsList[key]),
        );
      }
    };

The logic ensures that the button's onClick action is executed and the onActionComplete callback is called after the action completes.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the button action handling logic is correctly implemented and triggers the expected behaviors.

# Test: Check the button action handling in the application.
rg --type typescript "onButtonClick"

Length of output: 71



Script:

#!/bin/bash
# Description: Verify that the button action handling logic is correctly implemented and triggers the expected behaviors.

# Test: Check the button action handling in the application.
rg --type ts "onButtonClick"

Length of output: 4055



Script:

#!/bin/bash
# Description: Extract the implementation details of onButtonClick in the relevant files.

# Extract the implementation of onButtonClick in WDSInlineButtonsWidget/component/index.tsx
rg --type ts --context 10 "onButtonClick" app/client/src/widgets/wds/WDSInlineButtonsWidget/component/index.tsx

# Extract the implementation of onButtonClick in WDSInlineButtonsWidget/widget/index.tsx
rg --type ts --context 10 "onButtonClick" app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/index.tsx

Length of output: 1962


15-19: Ensure the sorting and filtering logic for buttons is correct and efficient.

Also applies to: 26-27

app/client/packages/design-system/widgets/src/components/Menu/stories/Menu.stories.tsx (2)

2-2: Confirm the import and usage of components from the design system in Menu stories.

The import and usage of components from the design system in Menu stories are correctly implemented.

Also applies to: 4-4


21-30: Check the rendering and functionality of different Menu configurations in stories.

The rendering and functionality of different Menu configurations in stories are correctly implemented and appear to be functioning as expected.

Also applies to: 34-37, 46-51, 56-59

app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/index.tsx (1)

Line range hint 17-64: Ensure asynchronous actions are correctly handled in onButtonClick.

app/client/packages/design-system/widgets/src/components/Select/src/styles.module.css (1)

72-80: CSS changes enhance UI consistency for select items with icons.

app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/index.tsx (1)

Line range hint 1-50: Proper use of inheritance in handling button click actions.

app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts (1)

Line range hint 10-35: Configuration enhances user experience and ensures data integrity for button styles.

app/client/src/widgets/wds/WDSToolbarButtonsWidget/widget/index.tsx (1)

Line range hint 1-82: Proper use of inheritance in handling button click actions.

app/client/packages/design-system/widgets/src/components/Menu/src/Menu.tsx (1)

13-69: Correct implementation of complex menu structures and enhanced accessibility.

app/client/packages/design-system/widgets/src/components/InlineButtons/src/useInlineButtons.tsx (1)

Line range hint 20-102: The implementation of useInlineButtons hook looks robust and well-structured.

app/client/packages/design-system/widgets/src/components/InlineButtons/src/InlineButtons.tsx (2)

16-73: The InlineButtonsInner component is implemented correctly and efficiently handles the rendering of inline buttons with appropriate styles and behaviors.


77-90: The InlineButtons component is well-implemented, correctly forwarding refs and handling props.

app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx (6)

30-32: The Main story provides a clear and straightforward example of how to use the InlineButtons component with basic items.


38-53: The Semantic story effectively demonstrates the visual styling capabilities of the InlineButtons component with various color and variant combinations.


59-61: The IndividualSemantic story is a good example of how to customize the color and variant for each button within the InlineButtons component.


66-76: The Sizes story clearly demonstrates how the InlineButtons component can be used with different sizes, providing a practical example of its adaptability.


81-87: The Responsive story effectively illustrates the adaptive layout behavior of the InlineButtons component in constrained spaces.


93-104: The Disabled and WithIcons stories are well-crafted to showcase the handling of disabled states and the inclusion of icons within the InlineButtons component.

app/client/packages/design-system/widgets/src/testing/ComplexForm.tsx (1)

11-11: Ensure that the ToolbarButtons component is properly integrated and used as intended.

Verification successful

The ToolbarButtons component is indeed integrated and used in various parts of the codebase, including multiple files related to widgets, components, and stories. This confirms that the component is properly integrated and utilized as intended.

  • Files where ToolbarButtons is used:
    • app/client/src/widgets/wds/WDSToolbarButtonsWidget/widget/types.ts
    • app/client/src/widgets/wds/WDSToolbarButtonsWidget/widget/index.tsx
    • app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/index.tsx
    • app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx
    • app/client/packages/design-system/widgets/src/components/Modal/stories/ModalExamples.tsx
    • And several other related files.

This extensive usage across different files indicates that the ToolbarButtons component is well-integrated within the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `ToolbarButtons` is properly integrated in other parts of the codebase.

# Test: Search for the usage of `ToolbarButtons`. Expect: Proper integration and usage.
rg --type typescript $'ToolbarButtons'

Length of output: 72



Script:

#!/bin/bash
# Description: Verify that `ToolbarButtons` is properly integrated in other parts of the codebase.

# Test: Search for the usage of `ToolbarButtons`. Expect: Proper integration and usage.
rg --type ts 'ToolbarButtons'

Length of output: 13564

app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx (3)

39-44: Verify the slicing logic for children and menuChildren.

Verification successful

The slicing logic for children and menuChildren in ToolbarButtons.tsx appears to be straightforward and correct. The code creates menuChildren by slicing props.items from visibleItems onward and limits children to the first visibleItems elements. This ensures that children contains only the visible items, while menuChildren contains the remaining items.

  • menuChildren is created by slicing props.items from visibleItems onward.
  • children is limited to the first visibleItems elements.

The slicing logic seems to handle the intended functionality correctly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the slicing logic for children in `ToolbarButtons.tsx`.

# Test: Check if the slicing logic correctly handles edge cases. Expect: Correct handling of edge cases.
rg --type typescript $'slice' ToolbarButtons.tsx

Length of output: 82



Script:

#!/bin/bash
# Description: Verify the slicing logic for children in `ToolbarButtons.tsx`.

# Test: Check if the slicing logic correctly handles edge cases. Expect: Correct handling of edge cases.
rg --type ts 'slice' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx

Length of output: 229



Script:

#!/bin/bash
# Description: Extract the relevant code around the `slice` operations in `ToolbarButtons.tsx`.

# Extract 5 lines before and after each `slice` usage for context.
rg --type ts 'slice' -A 5 -B 5 app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx

Length of output: 413


1-12: Ensure all imports are used and necessary.

Verification successful

The following imports were found in ToolbarButtons.tsx:

  1. Button from @design-system/widgets
  2. Menu from @design-system/widgets
  3. FocusScope from @react-aria/focus
  4. useDOMRef from @react-spectrum/utils
  5. useListState from @react-stately/list
  6. Item from @react-stately/collections
  7. MenuTrigger from react-aria-components
  8. ToolbarButton from ./ToolbarButton
  9. useToolbarButtons from ./useToolbarButtons

To ensure all these imports are used, I will generate a script to search for their usage within the file.


All imports in ToolbarButtons.tsx are used within the file. Here is the verification for each import:

  • Button from @design-system/widgets is used.
  • Menu from @design-system/widgets is used.
  • FocusScope from @react-aria/focus is used.
  • useDOMRef from @react-spectrum/utils is used.
  • useListState from @react-stately/list is used.
  • Item from @react-stately/collections is used.
  • MenuTrigger from react-aria-components is used.
  • ToolbarButton from ./ToolbarButton is used.
  • useToolbarButtons from ./useToolbarButtons is used.

No unused imports were found.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all imports in `ToolbarButtons.tsx` are used.

# Test: Check for unused imports. Expect: No unused imports.
rg --type typescript -U $'import {.*} from' ToolbarButtons.tsx | rg -v $'import type'

Length of output: 192



Script:

#!/bin/bash
# Description: Verify that all imports in `ToolbarButtons.tsx` are used.

# Test: Check for unused imports. Expect: No unused imports.
rg --type typescript -U $'import \\{.*\\} from' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx | rg -v $'import type'

Length of output: 198



Script:

#!/bin/bash
# Description: Verify that all imports in `ToolbarButtons.tsx` are used.

# Test: Check for unused imports. Expect: No unused imports.
rg --type ts -U $'import \\{.*\\} from' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx | rg -v $'import type'

Length of output: 571



Script:

#!/bin/bash
# Description: Verify the usage of each import in `ToolbarButtons.tsx`.

# List of imports to check
imports=("Button" "Menu" "FocusScope" "useDOMRef" "useListState" "Item" "MenuTrigger" "ToolbarButton" "useToolbarButtons")

# Check usage of each import
for import in "${imports[@]}"; do
  echo "Checking usage of $import:"
  rg "$import" app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx
  echo
done

Length of output: 5116


79-90: Ensure that the MenuTrigger and Menu components are used correctly within ToolbarButtons.

app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx (1)

1-16: Check for consistency in Storybook stories with the actual component properties.

Verification successful

The properties used in the Storybook stories for the ToolbarButtons component are consistent with the actual component properties defined in the _ToolbarButtons function. The properties include alignment, color, density, isDisabled, onAction, size, and variant, which are all present in the component definition.

  • alignment
  • color
  • density
  • isDisabled
  • onAction
  • size
  • variant

These properties match those used in the Storybook stories, confirming consistency.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify consistency between Storybook stories and actual component properties in `ToolbarButtons`.

# Test: Compare Storybook stories with component properties. Expect: Consistent properties.
rg --type typescript $'ToolbarButtons' ToolbarButtons.stories.tsx | rg $'props'

Length of output: 110



Script:

#!/bin/bash
# Description: Verify consistency between Storybook stories and actual component properties in `ToolbarButtons`.

# Test: Compare Storybook stories with component properties. Expect: Consistent properties.
rg 'ToolbarButtons' app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx

Length of output: 1501



Script:

#!/bin/bash
# Description: Verify the properties of the `ToolbarButtons` component.

# Test: Retrieve the `ToolbarButtons` component definition and its properties.
ast-grep --lang typescript --pattern $'export const ToolbarButtons = $_' 

Length of output: 73



Script:

#!/bin/bash
# Description: Verify the properties of the `ToolbarButtons` component.

# Test: Retrieve the `ToolbarButtons` component definition and its properties.
rg 'ToolbarButtons' --type ts

Length of output: 13564



Script:

#!/bin/bash
# Description: Verify the properties of the `ToolbarButtons` component.

# Test: Retrieve the `ToolbarButtons` component definition and its properties.
ast-grep --lang typescript --pattern $'export const ToolbarButtons = $_' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx

Length of output: 168



Script:

#!/bin/bash
# Description: Verify the properties of the `ToolbarButtons` component.

# Test: Retrieve the `ToolbarButtons` component definition and its properties.
rg 'export const ToolbarButtons' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx

Length of output: 188



Script:

#!/bin/bash
# Description: Verify the properties of the `_ToolbarButtons` function.

# Test: Retrieve the `_ToolbarButtons` function definition and its properties.
ast-grep --lang typescript --pattern $'const _ToolbarButtons = <T extends ToolbarButtonsItem>($_) => { $$$ }' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx

Length of output: 205



Script:

#!/bin/bash
# Description: Verify the properties of the `_ToolbarButtons` function.

# Test: Retrieve the `_ToolbarButtons` function definition and its properties.
rg 'const _ToolbarButtons' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx

Length of output: 240



Script:

#!/bin/bash
# Description: Verify the properties of the `_ToolbarButtons` function.

# Test: Retrieve the `_ToolbarButtons` function definition and its properties.
ast-grep --lang typescript --pattern $'const _ToolbarButtons = <T extends ToolbarButtonsItem>($props) => { $$$ }' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx

Length of output: 209



Script:

#!/bin/bash
# Description: Verify the properties of the `_ToolbarButtons` function.

# Test: Retrieve the `_ToolbarButtons` function definition and its properties.
rg 'const _ToolbarButtons' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/ToolbarButtons.tsx -A 20

Length of output: 1057

app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/useToolbarButtons.ts (2)

11-11: Confirm that the ToolbarButtonsProps type is correctly utilized in the useToolbarButtons hook.

Verification successful

The ToolbarButtonsProps type is correctly utilized in the useToolbarButtons hook.

  • import type { ToolbarButtonsProps } from "./types";
  • props: ToolbarButtonsProps<T>,
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct utilization of `ToolbarButtonsProps` in `useToolbarButtons`.

# Test: Check for correct type usage in the hook. Expect: Correct type usage.
rg --type typescript $'ToolbarButtonsProps' useToolbarButtons.ts

Length of output: 98



Script:

#!/bin/bash
# Description: Verify correct utilization of `ToolbarButtonsProps` in `useToolbarButtons`.

# Test: Check for correct type usage in the hook. Expect: Correct type usage.
rg --type ts 'ToolbarButtonsProps' useToolbarButtons.ts

Length of output: 116



Script:

#!/bin/bash
# Description: Locate the `useToolbarButtons.ts` file and verify correct utilization of `ToolbarButtonsProps`.

# Step 1: Locate the file
file_path=$(fd useToolbarButtons.ts)

# Step 2: Verify correct type usage in the located file
if [ -n "$file_path" ]; then
  rg 'ToolbarButtonsProps' "$file_path"
else
  echo "useToolbarButtons.ts file not found."
fi

Length of output: 452


145-155: Ensure that the resize observer and layout effect are correctly managing the overflow behavior.

Verification successful

The useResizeObserver and updateOverflow are both present and used in the useToolbarButtons file. The updateOverflow function is used in conjunction with useResizeObserver and useLayoutEffect, which suggests that the overflow behavior is being managed correctly.

  • useResizeObserver is used to observe resize events.
  • updateOverflow is defined and used within the useCallback, onResize, and useLayoutEffect.

This indicates that the resize observer and layout effect are correctly managing the overflow behavior.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct management of overflow in `useToolbarButtons`.

# Test: Check for correct handling of overflow with resize observer and layout effect. Expect: Correct overflow management.
rg --type typescript $'useResizeObserver' useToolbarButtons.ts | rg $'updateOverflow'

Length of output: 116



Script:

#!/bin/bash
# Description: Verify correct management of overflow in `useToolbarButtons`.

# Test: Check for correct handling of overflow with resize observer and layout effect. Expect: Correct overflow management.
rg --type ts 'useResizeObserver' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/useToolbarButtons.ts | rg 'updateOverflow'

Length of output: 149



Script:

#!/bin/bash
# Description: Verify presence of `useResizeObserver` in `useToolbarButtons`.

# Test: Check if `useResizeObserver` is used in the file.
rg --type ts 'useResizeObserver' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/useToolbarButtons.ts

Length of output: 172


Script:

#!/bin/bash
# Description: Verify presence of `updateOverflow` in `useToolbarButtons`.

# Test: Check if `updateOverflow` is used in the file.
rg --type ts 'updateOverflow' app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/useToolbarButtons.ts

Length of output: 272

app/client/src/widgets/wds/WDSMenuButtonWidget/widget/index.tsx (2)

15-15: Verify that the MenuTrigger and Menu components are correctly integrated into the WDSMenuButtonWidget.

Verification successful

The MenuTrigger and Menu components are correctly integrated into the WDSMenuButtonWidget as evidenced by their usage in the file app/client/src/widgets/wds/WDSMenuButtonWidget/widget/index.tsx.

  • MenuTrigger is used within the JSX structure.
  • Menu is used within the MenuTrigger component.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct integration of `MenuTrigger` and `Menu` in `WDSMenuButtonWidget`.

# Test: Search for other instances of `MenuTrigger` and `Menu` usage in the widget. Expect: Correct integration.
rg --type typescript $'MenuTrigger' WDSMenuButtonWidget/widget/index.tsx | rg $'Menu'

Length of output: 116



Script:

#!/bin/bash
# Description: Verify correct integration of `MenuTrigger` and `Menu` in `WDSMenuButtonWidget`.

# Test: Search for instances of `MenuTrigger` and `Menu` usage in the widget. Expect: Correct integration.
rg 'MenuTrigger' WDSMenuButtonWidget/widget/index.tsx
rg 'Menu' WDSMenuButtonWidget/widget/index.tsx

Length of output: 254



Script:

#!/bin/bash
# Description: Locate the correct path of the file and verify the integration of `MenuTrigger` and `Menu`.

# Step 1: Locate the file
file_path=$(fd WDSMenuButtonWidget/widget/index.tsx)

# Step 2: Verify correct integration of `MenuTrigger` and `Menu` if the file is found
if [ -n "$file_path" ]; then
  rg 'MenuTrigger' "$file_path"
  rg 'Menu' "$file_path"
else
  echo "File not found"
fi

Length of output: 110



Script:

#!/bin/bash
# Description: Locate the file by name and verify the integration of `MenuTrigger` and `Menu`.

# Step 1: Locate the file by name
file_path=$(fd index.tsx | grep 'WDSMenuButtonWidget/widget')

# Step 2: Verify correct integration of `MenuTrigger` and `Menu` if the file is found
if [ -n "$file_path" ]; then
  rg 'MenuTrigger' "$file_path"
  rg 'Menu' "$file_path"
else
  echo "File not found"
fi

Length of output: 1091


Line range hint 167-194: Ensure that the menu interaction logic correctly handles item clicks and state updates.

Verification successful

The verification confirms that the onAction event handler and state management are present in the WDSMenuButtonWidget component. The onAction handler is defined, and there is a reference to this.state in the file, indicating state management.

  • onAction is defined at line: onAction={(key) => {
  • state is referenced at line: this.state = {

These findings suggest that the menu interaction logic correctly handles item clicks and state updates.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct handling of menu item clicks and state updates in `WDSMenuButtonWidget`.

# Test: Check for correct event handling and state management on menu item click. Expect: Correct handling and updates.
rg --type typescript $'onAction' WDSMenuButtonWidget/widget/index.tsx | rg $'state'

Length of output: 114



Script:

#!/bin/bash
# Description: Verify correct handling of menu item clicks and state updates in `WDSMenuButtonWidget`.

# Test: Check for correct event handling and state management on menu item click. Expect: Correct handling and updates.
rg --type ts 'onAction' WDSMenuButtonWidget/widget/index.tsx | rg 'state'

Length of output: 148



Script:

#!/bin/bash
# Description: Locate the correct path for the `WDSMenuButtonWidget/widget/index.tsx` file and verify correct handling of menu item clicks and state updates.

# Step 1: Locate the file
file_path=$(fd WDSMenuButtonWidget/widget/index.tsx)

# Step 2: Check for correct event handling and state management on menu item click if the file is found
if [ -n "$file_path" ]; then
  rg --type ts 'onAction' "$file_path" | rg 'state'
else
  echo "File not found"
fi

Length of output: 110



Script:

#!/bin/bash
# Description: Locate the correct path for the `WDSMenuButtonWidget/widget/index.tsx` file and verify correct handling of menu item clicks and state updates.

# Step 1: Locate the file
file_path=$(fd -i 'index.tsx' | grep 'WDSMenuButtonWidget/widget')

# Step 2: Check for correct event handling and state management on menu item click if the file is found
if [ -n "$file_path" ]; then
  rg --type ts 'onAction' "$file_path" | rg 'state'
else
  echo "File not found"
fi

Length of output: 305



Script:

#!/bin/bash
# Description: Verify correct handling of menu item clicks and state updates in `WDSMenuButtonWidget`.

# Step 1: Locate the file
file_path="app/client/src/widgets/wds/WDSMenuButtonWidget/widget/index.tsx"

# Step 2: Check for `onAction` in the file
rg 'onAction' "$file_path"

# Step 3: Check for `state` in the file
rg 'state' "$file_path"

Length of output: 278

app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/contentConfig.ts (1)

Line range hint 97-112: Ensure that the new icon properties are correctly integrated and function as expected.

Verification successful

The new icon properties are correctly integrated in the WDSToolbarButtonsWidget configuration.

  • The script confirmed the presence of icon and iconPosition properties in app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/contentConfig.ts.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct integration and functionality of new icon properties in `WDSToolbarButtonsWidget`.

# Test: Check for correct property handling and functionality. Expect: Correct integration and functionality.
rg --type typescript $'icon' contentConfig.ts | rg $'iconPosition'

Length of output: 97



Script:

#!/bin/bash
# Description: Verify correct integration and functionality of new icon properties in `WDSToolbarButtonsWidget`.

# Test: Check for correct property handling and functionality. Expect: Correct integration and functionality.
rg --type ts 'icon' contentConfig.ts | rg 'iconPosition'

Length of output: 111



Script:

#!/bin/bash
# Description: Locate `contentConfig.ts` and verify correct integration and functionality of new icon properties in `WDSToolbarButtonsWidget`.

# Step 1: Locate the file
file_path=$(fd contentConfig.ts)

# Step 2: Verify correct property handling and functionality if the file is found
if [ -n "$file_path" ]; then
  rg --type ts 'icon' "$file_path" | rg 'iconPosition'
else
  echo "contentConfig.ts not found"
fi

Length of output: 8387



Script:

#!/bin/bash
# Description: Locate `contentConfig.ts` and verify correct integration and functionality of new icon properties in `WDSToolbarButtonsWidget`.

# Step 1: Locate the files
file_paths=$(fd contentConfig.ts)

# Step 2: Verify correct property handling and functionality for each file
for file_path in $file_paths; do
  echo "Processing $file_path"
  rg --type ts 'icon' "$file_path" | rg 'iconPosition'
done

Length of output: 10789

app/client/packages/design-system/widgets/src/components/Modal/stories/ModalExamples.tsx (1)

Line range hint 33-52: Usage of ToolbarButtons to control modal visibility is implemented correctly.

app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts (2)

Line range hint 99-121: The configuration for the variant property of buttons is robust, ensuring UI consistency and error prevention.


Line range hint 121-149: The configuration for the color property of buttons is well-defined, promoting consistent styling and configuration flexibility.

app/client/src/components/propertyControls/ButtonListControl.tsx (1)

196-196: The implementation of the addOption method in ButtonListControl is well-thought-out, handling different widget types and user preferences effectively.


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

SpectrumFieldProps,
"showErrorIcon" | "labelPosition" | "labelAlign" | keyof StyleProps
| "contextualHelp"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Types are broken due to package updates.

@@ -64,7 +64,7 @@ const _Icon = (props: IconProps, ref: Ref<SVGSVGElement>) => {
ref={ref}
{...rest}
>
<Icon {...props} />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fix for these errors
Снимок экрана 2024-05-16 в 16 40 19

@@ -32,4 +32,13 @@
a:not(.docs-story a) {
color: var(--color-fg-accent) !important;
}

.css-qa4clq :where(div:not(.sb-anchor, .sb-unstyled, .sb-unstyled div)),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixing the typography in Storybrook for menu items

@KelvinOm KelvinOm added the ok-to-test Required label for CI label May 23, 2024
@KelvinOm KelvinOm requested a review from ramsaptami May 23, 2024 14:59
@KelvinOm KelvinOm added skip-changelog Adding this label to a PR prevents it from being listed in the changelog skip-docs skip-testPlan labels May 23, 2024
@KelvinOm
Copy link
Collaborator Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9210338526.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33703.
recreate: .

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

Outside diff range and nitpick comments (3)
app/client/packages/design-system/widgets/src/components/Menu/stories/Menu.stories.tsx (1)

49-49: Consider providing visual feedback or logging instead of using alert for action feedback in production code.

app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/index.tsx (1)

[!TIP]
Codebase Verification

The WDSInlineButtonsWidget is a class-based component extending BaseWidget, but it does not implement componentDidMount or componentWillUnmount. Additionally, there are no useEffect hooks, indicating that side effects and lifecycle management might not be handled properly.

  • File: app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/index.tsx
  • Class: WDSInlineButtonsWidget
Analysis chain

Line range hint 1-1: Review the widget's lifecycle methods to ensure they are correctly implemented and do not introduce memory leaks or performance issues.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct implementation of lifecycle methods in WDSInlineButtonsWidget.

# Test: Check for correct implementation of lifecycle methods.
rg --type typescript --context 5 'componentDidMount|componentWillUnmount' app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/index.tsx

Length of output: 177



Script:

#!/bin/bash
# Description: Verify correct implementation of lifecycle methods in WDSInlineButtonsWidget.

# Test: Check for correct implementation of lifecycle methods.
rg --type ts --context 5 'componentDidMount|componentWillUnmount' app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/index.tsx

Length of output: 134



Script:

#!/bin/bash
# Description: Verify correct implementation of lifecycle methods or hooks in WDSInlineButtonsWidget.

# Test: Check for useEffect hook usage.
rg --type ts --context 5 'useEffect' app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/index.tsx

Length of output: 103



Script:

#!/bin/bash
# Description: Verify the structure and side effect management in WDSInlineButtonsWidget.

# Test: Check for the component definition and any hooks or methods used.
rg --type ts --context 5 'function|const' app/client/src/widgets/wds/WDSInlineButtonsWidget/widget/index.tsx

Length of output: 718

app/client/packages/design-system/headless/src/components/Field/src/Field.tsx (1)

7-29: Ensure new properties in FieldProps are well-documented.

Adding detailed comments for each property in FieldProps would improve maintainability and developer understanding, especially for properties like elementType and necessityIndicator.

Comment on lines +3 to +12
.inlineButtons {
display: flex;
width: 100%;
gap: var(--inner-spacing-2);

& :is([data-button]) {
min-inline-size: fit-content;
/*
We use !important here to be sure that button width and the logic of useInlineButtons hook will not be changed from the outside
*/
min-inline-size: fit-content !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider alternatives to using !important in CSS to allow easier style customization and maintenance. However, if it's necessary for ensuring consistency in UI behavior, the current approach may be justified.

Also applies to: 22-22

Comment on lines +93 to +95
necessityIndicator={
!Boolean(isReadOnly) ? necessityIndicator : undefined
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor to simplify necessity indicator logic.

The current implementation of the necessity indicator is a bit complex. Consider simplifying it as follows:

- !Boolean(isReadOnly) ? necessityIndicator : undefined
+ isReadOnly ? undefined : necessityIndicator

This change makes the condition more readable by directly checking the isReadOnly state.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
necessityIndicator={
!Boolean(isReadOnly) ? necessityIndicator : undefined
}
necessityIndicator={
isReadOnly ? undefined : necessityIndicator
}

Comment on lines +27 to +28
icon: "thumb-up",
isSeparator,
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider making the icon property configurable to enhance flexibility.

- icon: "thumb-up",
+ icon: isSeparator ? undefined : "thumb-up",  // or pass an icon parameter

Committable suggestion was skipped due low confidence.

Comment on lines +59 to +66
<ToolbarButtons
items={[
{ id: 1, label: "Fast food" },
{ id: 2, label: "Salads" },
{ id: 3, label: "Salads" },
{ id: 4, label: "Sauces" },
]}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure unique IDs for ToolbarButtons items.

The ToolbarButtons component is used with non-unique IDs for items (two items with ID 3). This could lead to unexpected behavior or accessibility issues. Consider ensuring unique IDs for each item:

- { id: 3, label: "Salads" },
+ { id: 3, label: "Desserts" },

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<ToolbarButtons
items={[
{ id: 1, label: "Fast food" },
{ id: 2, label: "Salads" },
{ id: 3, label: "Salads" },
{ id: 4, label: "Sauces" },
]}
/>
<ToolbarButtons
items={[
{ id: 1, label: "Fast food" },
{ id: 2, label: "Salads" },
{ id: 3, label: "Desserts" },
{ id: 4, label: "Sauces" },
]}
/>

Comment on lines +39 to +90
let children = [...state.collection];
const menuChildren = (props.items as ToolbarButtonsItem[]).slice(
visibleItems,
);
children = children.slice(0, visibleItems);

return (
<FocusScope>
<div
className={styles.toolbarButtons}
data-alignment={alignment}
data-density={Boolean(density) ? density : undefined}
ref={domRef}
{...toolbarButtonsProps}
>
{children.map((item) => {
if (Boolean(item.props.isSeparator)) {
return <div data-separator="" key={item.key} role="separator" />;
}

return (
<ToolbarButton
color={color}
icon={item.props.icon}
iconPosition={item.props.iconPosition}
isDisabled={
Boolean(state.disabledKeys.has(item.key)) ||
Boolean(item.props.isDisabled) ||
isDisabled
}
isLoading={item.props.isLoading}
item={item}
key={item.key}
onPress={() => onAction?.(item.key)}
size={Boolean(size) ? size : undefined}
state={state}
variant={variant}
/>
);
})}
{menuChildren?.length > 0 && (
<MenuTrigger>
<Button
color={color}
data-action-group-menu
icon="dots"
isDisabled={isDisabled}
variant={variant}
/>
<Menu {...props} items={menuChildren} />
</MenuTrigger>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize rendering logic in ToolbarButtons.

The rendering logic in ToolbarButtons can be optimized to avoid unnecessary re-renders and improve performance. Consider using React.memo or React.useMemo for parts of the component that depend on specific props:

+ const MemoizedToolbarButton = React.memo(ToolbarButton);
- <ToolbarButton ... />
+ <MemoizedToolbarButton ... />

This change helps prevent unnecessary re-renders when the props to ToolbarButton have not changed.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
let children = [...state.collection];
const menuChildren = (props.items as ToolbarButtonsItem[]).slice(
visibleItems,
);
children = children.slice(0, visibleItems);
return (
<FocusScope>
<div
className={styles.toolbarButtons}
data-alignment={alignment}
data-density={Boolean(density) ? density : undefined}
ref={domRef}
{...toolbarButtonsProps}
>
{children.map((item) => {
if (Boolean(item.props.isSeparator)) {
return <div data-separator="" key={item.key} role="separator" />;
}
return (
<ToolbarButton
color={color}
icon={item.props.icon}
iconPosition={item.props.iconPosition}
isDisabled={
Boolean(state.disabledKeys.has(item.key)) ||
Boolean(item.props.isDisabled) ||
isDisabled
}
isLoading={item.props.isLoading}
item={item}
key={item.key}
onPress={() => onAction?.(item.key)}
size={Boolean(size) ? size : undefined}
state={state}
variant={variant}
/>
);
})}
{menuChildren?.length > 0 && (
<MenuTrigger>
<Button
color={color}
data-action-group-menu
icon="dots"
isDisabled={isDisabled}
variant={variant}
/>
<Menu {...props} items={menuChildren} />
</MenuTrigger>
)}
let children = [...state.collection];
const menuChildren = (props.items as ToolbarButtonsItem[]).slice(
visibleItems,
);
children = children.slice(0, visibleItems);
+ const MemoizedToolbarButton = React.memo(ToolbarButton);
return (
<FocusScope>
<div
className={styles.toolbarButtons}
data-alignment={alignment}
data-density={Boolean(density) ? density : undefined}
ref={domRef}
{...toolbarButtonsProps}
>
{children.map((item) => {
if (Boolean(item.props.isSeparator)) {
return <div data-separator="" key={item.key} role="separator" />;
}
return (
<MemoizedToolbarButton
color={color}
icon={item.props.icon}
iconPosition={item.props.iconPosition}
isDisabled={
Boolean(state.disabledKeys.has(item.key)) ||
Boolean(item.props.isDisabled) ||
isDisabled
}
isLoading={item.props.isLoading}
item={item}
key={item.key}
onPress={() => onAction?.(item.key)}
size={Boolean(size) ? size : undefined}
state={state}
variant={variant}
/>
);
})}
{menuChildren?.length > 0 && (
<MenuTrigger>
<Button
color={color}
data-action-group-menu
icon="dots"
isDisabled={isDisabled}
variant={variant}
/>
<Menu {...props} items={menuChildren} />
</MenuTrigger>
)}

Comment on lines +45 to +49
if (buttonsList[key].onClick) {
setLoadingButtonIds([...loadingButtonIds, key as string]);

props.onButtonClick(props.buttonsList[key].onClick, () =>
onActionComplete(props.buttonsList[key]),
onButtonClick(buttonsList[key].onClick, () =>
onActionComplete(buttonsList[key]),
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The search did not find any explicit error handling mechanisms such as try-catch blocks or error callbacks in the specified file. This suggests that there might be a lack of error handling for the onClick action, which could indeed cause the UI to become unresponsive if an error occurs.

  • Ensure that the onClick action has proper error handling to prevent the UI from becoming unresponsive in case of failures.
Analysis chain

Review the error handling for the onClick action to ensure that failures in the action do not cause the UI to become unresponsive.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify error handling for onClick action.

# Test: Check for error handling in onClick action.
rg --type typescript --context 5 'onClick' app/client/src/widgets/wds/WDSInlineButtonsWidget/component/index.tsx

Length of output: 147



Script:

#!/bin/bash
# Description: Verify error handling for onClick action.

# Test: Check for error handling in onClick action.
rg --type ts --context 5 'onClick' app/client/src/widgets/wds/WDSInlineButtonsWidget/component/index.tsx

Length of output: 789



Script:

#!/bin/bash
# Description: Verify error handling for onClick action.

# Test: Check for error handling mechanisms such as try-catch blocks or error callbacks in the same file.
rg --type ts --context 5 'try' app/client/src/widgets/wds/WDSInlineButtonsWidget/component/index.tsx

# Test: Check for error handling mechanisms such as error callbacks in the same file.
rg --type ts --context 5 'catch' app/client/src/widgets/wds/WDSInlineButtonsWidget/component/index.tsx

# Test: Check for error handling mechanisms such as error callbacks in the same file.
rg --type ts --context 5 'error' app/client/src/widgets/wds/WDSInlineButtonsWidget/component/index.tsx

Length of output: 306

@@ -14,19 +14,21 @@ export const ToolbarButtonsComponent = (
Array<ToolbarButtonsItemComponentProps["id"]>
>([]);

const { alignment, buttonsList, color, onButtonClick, variant } = props;
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The code handles the sorting and disabling logic for buttonsList and loadingButtonIds. It filters visible buttons, sorts them, and manages disabled buttons and loading states. However, it does not explicitly handle edge cases like empty lists or all buttons being disabled.

  • Ensure that buttonsList is not empty before performing operations.
  • Handle cases where all buttons might be disabled.
Analysis chain

Ensure that the sorting and disabling logic correctly handles all edge cases, such as empty lists or all buttons being disabled.

Also applies to: 28-29

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that sorting and disabling logic handles edge cases.

# Test: Check for edge case handling in sorting and disabling logic.
rg --type typescript --context 5 'sortBy' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/index.tsx

Length of output: 147



Script:

#!/bin/bash
# Description: Verify that sorting and disabling logic handles edge cases.

# Test: Check for edge case handling in sorting and disabling logic.
rg --type ts --context 5 'sortBy' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/index.tsx

Length of output: 757



Script:

#!/bin/bash
# Description: Verify handling of edge cases for buttonsList and loadingButtonIds.

# Test: Check for edge case handling in buttonsList and loadingButtonIds.
rg --type ts --context 5 'buttonsList|loadingButtonIds' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/index.tsx

Length of output: 1407

Comment on lines +47 to +51
if (buttonsList[key].onClick) {
setLoadingButtonIds([...loadingButtonIds, key as string]);

props.onButtonClick(props.buttonsList[key].onClick, () =>
onActionComplete(props.buttonsList[key]),
onButtonClick(buttonsList[key].onClick, () =>
onActionComplete(buttonsList[key]),
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The implementation of onButtonClick in WDSToolbarButtonsWidget does not include explicit error handling. This could potentially cause the UI to become unresponsive if the action fails.

  • Consider adding error handling within the onButtonClick method to ensure that any failures in the action do not cause the UI to become unresponsive.
Analysis chain

Review the error handling for the onClick action to ensure that failures in the action do not cause the UI to become unresponsive.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify error handling for onClick action.

# Test: Check for error handling in onClick action.
rg --type typescript --context 5 'onClick' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/index.tsx

Length of output: 148



Script:

#!/bin/bash
# Description: Verify error handling for onClick action.

# Test: Check for error handling in onClick action.
rg --type ts --context 5 'onClick' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/index.tsx

Length of output: 745



Script:

#!/bin/bash
# Description: Verify error handling for onClick action.

# Test: Check for the definition and implementation of onButtonClick.
rg --type ts 'function onButtonClick' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/

# Test: Check for the definition and implementation of onActionComplete.
rg --type ts 'function onActionComplete' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/

Length of output: 206



Script:

#!/bin/bash
# Description: Verify error handling for onClick action.

# Test: Search for the usage and definition of onButtonClick.
rg --type ts 'onButtonClick' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/

# Test: Search for the usage and definition of onActionComplete.
rg --type ts 'onActionComplete' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/

Length of output: 803



Script:

#!/bin/bash
# Description: Verify error handling for onClick action.

# Test: Extract the full implementation of onActionComplete.
rg --type ts --context 10 'const onActionComplete' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/index.tsx

# Test: Extract the type definition of onButtonClick.
rg --type ts --context 10 'onButtonClick' app/client/src/widgets/wds/WDSToolbarButtonsWidget/component/types.ts

Length of output: 1380



Script:

#!/bin/bash
# Description: Verify error handling for onClick action.

# Test: Search for the implementation of onButtonClick.
rg --type ts 'onButtonClick' 

Length of output: 4055



Script:

#!/bin/bash
# Description: Verify error handling for onClick action.

# Test: Extract the implementation of onButtonClick in WDSToolbarButtonsWidget.
rg --type ts --context 10 'onButtonClick' app/client/src/widgets/wds/WDSToolbarButtonsWidget/widget/index.tsx

Length of output: 957

Copy link

Deploy-Preview-URL: https://ce-33703.dp.appsmith.com

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 (3)
app/client/src/widgets/wds/WDSInlineButtonsWidget/config/defaultsConfig.ts (1)

26-26: Properly document the use of isSeparator for clarity.

Consider adding a comment here explaining the purpose and usage of isSeparator to improve code readability.

app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/defaultsConfig.ts (1)

48-48: Document the purpose of isSeparator in the context of ToolbarButtons.

It would be beneficial to add a comment here explaining the use of isSeparator to enhance code readability and maintainability.

app/client/packages/design-system/widgets/src/testing/ComplexForm.tsx (1)

59-66: Check for potential duplication of 'Salads' in the ToolbarButtons items.

Consider whether having two 'Salads' items is intentional or an oversight. If it's not required, you might want to remove the duplicate to avoid confusion.

variant = "filled",
} = props;
const domRef = useDOMRef(ref);
const state = useListState({ ...props, suppressTextValueWarning: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

wont this create a new object everytime the widget renders?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It shouldn't, as far as I can see from the code of this hook.

domRef,
);

const children = [...state.collection];
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we want to create a new array by spreading?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because collection is not an array and we need it to iterate through items.

Copy link
Contributor

@marks0351 marks0351 left a comment

Choose a reason for hiding this comment

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

have left a few comments. overall LGTM.

@riodeuno riodeuno removed their request for review May 24, 2024 08:17
@riodeuno
Copy link
Contributor

@KelvinOm Looks like both @marks0351 and @jsartisan have review this. Is there anything you'd like for me to check out? If not, I've removed myself from the reviewers list for now.

@KelvinOm
Copy link
Collaborator Author

@KelvinOm Looks like both @marks0351 and @jsartisan have review this. Is there anything you'd like for me to check out? If not, I've removed myself from the reviewers list for now.

@riodeuno Two reviewers are enough. You can skip this. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog skip-docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants