-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat: added an ads entity context menu template component #39358
Conversation
WalkthroughThis pull request introduces the new Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant ECM as EntityContextMenu
participant M as Menu
participant T as Tooltip
U->>ECM: Click on MenuTrigger button
ECM->>ECM: Toggle menu open state (useToggle)
ECM->>T: Disable tooltip when menu is open
ECM->>M: Render Menu with MenuContent (children)
M-->>U: Display menu options ("Rename", "Copy", "Delete")
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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 (5)
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/constants.ts (1)
1-4
: LGTM! Consider adding JSDoc comments.The enum values follow a consistent naming pattern and are descriptive.
Add JSDoc comments to document the purpose of each class name:
export enum EntityClassNames { + /** Class name for the context menu container */ CONTEXT_MENU = "entity-context-menu", + /** Class name for the context menu content wrapper */ CONTEXT_MENU_CONTENT = "entity-context-menu-content", }app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.styles.ts (1)
5-8
: Consider making the width more flexible.A fixed width of 220px might be too restrictive for different content lengths. Consider using min-width or max-width instead.
export const MenuContent = styled(ADSMenuContent)` - width: 220px; + min-width: 220px; + max-width: 300px; max-height: unset; `;app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.stories.tsx (1)
22-24
: Replace console.log with action handlers.While console.log is fine for stories, consider using Storybook's action handlers for better debugging.
+import { action } from '@storybook/addon-actions'; + export const Basic: Story = { args: { tooltipContent: "More actions", children: ( <> - <MenuItem onClick={console.log} startIcon="edit-line"> + <MenuItem onClick={action('rename-clicked')} startIcon="edit-line"> Rename </MenuItem> - <MenuItem onClick={console.log} startIcon="copy-control"> + <MenuItem onClick={action('copy-clicked')} startIcon="copy-control"> Copy </MenuItem> - <MenuItem onClick={console.log} startIcon="delete"> + <MenuItem onClick={action('delete-clicked')} startIcon="delete"> Delete </MenuItem> </> ), }, };Also applies to: 25-27, 28-30
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.tsx (2)
11-14
: Add JSDoc documentation and improve type specificity.Consider adding documentation for the props and being more specific about the children type if possible.
+/** + * Props for the EntityContextMenu component + * @param children - Menu items to be rendered inside the context menu + * @param tooltipContent - Content to be displayed in the tooltip + */ interface Props { - children?: React.ReactNode[] | React.ReactNode; + children?: React.ReactElement | React.ReactElement[]; tooltipContent: React.ReactNode; }
16-49
: Consider adding error boundary and loading states.The component implementation is solid with good accessibility features and test coverage. Consider adding error boundaries and loading states for better user experience.
export const EntityContextMenu = (props: Props) => { const { children, tooltipContent } = props; const [isMenuOpen, toggleMenuOpen] = useToggle(); + const [isLoading, setIsLoading] = React.useState(false); return ( <Menu onOpenChange={toggleMenuOpen} open={isMenuOpen}> <MenuTrigger className="t--context-menu"> <Styled.ButtonContainer> <Tooltip content={tooltipContent} isDisabled={isMenuOpen} mouseLeaveDelay={0} placement="right" > <Button className={EntityClassNames.CONTEXT_MENU} data-testid="t--more-action-trigger" isIconButton kind="tertiary" startIcon="more-2-fill" + isLoading={isLoading} /> </Tooltip> </Styled.ButtonContainer> </MenuTrigger> <Styled.MenuContent align="start" className={`t--entity-context-menu ${EntityClassNames.CONTEXT_MENU_CONTENT}`} side="right" > + <React.Suspense fallback={<div>Loading...</div>}> {children} + </React.Suspense> </Styled.MenuContent> </Menu> ); };
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.stories.tsx
(1 hunks)app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.styles.ts
(1 hunks)app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.tsx
(1 hunks)app/client/packages/design-system/ads/src/Templates/EntityContextMenu/constants.ts
(1 hunks)app/client/packages/design-system/ads/src/Templates/EntityContextMenu/index.ts
(1 hunks)app/client/packages/design-system/ads/src/Templates/index.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- app/client/packages/design-system/ads/src/Templates/EntityContextMenu/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (10)
- GitHub Check: perform-test / client-build / client-build
- GitHub Check: perform-test / rts-build / build
- GitHub Check: perform-test / server-build / server-unit-tests
- GitHub Check: client-unit-tests / client-unit-tests
- GitHub Check: client-lint / client-lint
- GitHub Check: client-build / client-build
- GitHub Check: client-prettier / prettier-check
- GitHub Check: storybook-tests
- GitHub Check: chromatic-deployment
- GitHub Check: chromatic-deployment
🔇 Additional comments (4)
app/client/packages/design-system/ads/src/Templates/index.ts (1)
7-7
: LGTM!The export follows the established pattern and maintains alphabetical ordering.
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.styles.ts (1)
10-12
: LGTM!The ButtonContainer styling is appropriate for positioning the context menu trigger.
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.stories.tsx (1)
8-11
: LGTM! Story setup is well-structured.The story metadata is properly configured with appropriate title and component reference.
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.tsx (1)
1-9
: LGTM! Well-organized imports.Imports are properly organized with external dependencies first, followed by internal components and local imports.
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 (1)
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.tsx (1)
31-59
: Consider adding keyboard navigation support.The menu implementation looks good, but could benefit from explicit keyboard navigation support for accessibility.
Consider adding:
<Menu onOpenChange={toggleMenuOpen} open={isMenuOpen}> + <MenuTrigger className="t--context-menu" aria-label={tooltipContent}> - <MenuTrigger className="t--context-menu">
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.tsx
(1 hunks)app/client/packages/design-system/ads/src/Templates/EntityContextMenu/constants.ts
(1 hunks)app/client/src/pages/AppIDE/components/JSEntityItem/JSEntityItem.tsx
(1 hunks)app/client/src/pages/AppIDE/components/QueryEntityItem/QueryEntityItem.tsx
(1 hunks)app/client/src/pages/Editor/JSEditor/AppJSEditorContextMenu.tsx
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- app/client/src/pages/Editor/JSEditor/AppJSEditorContextMenu.tsx
- app/client/src/pages/AppIDE/components/JSEntityItem/JSEntityItem.tsx
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: perform-test / client-build / client-build
- GitHub Check: perform-test / server-build / server-unit-tests
- GitHub Check: perform-test / rts-build / build
- GitHub Check: client-unit-tests / client-unit-tests
- GitHub Check: client-build / client-build
- GitHub Check: client-lint / client-lint
- GitHub Check: client-prettier / prettier-check
- GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
- GitHub Check: chromatic-deployment
- GitHub Check: storybook-tests
- GitHub Check: chromatic-deployment
🔇 Additional comments (4)
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/constants.ts (2)
1-4
: LGTM! Well-structured enum for class names.The enum provides clear, consistent naming for CSS classes.
6-7
: Consider making test ID configurable per usage context.Based on past review comments, the hardcoded test ID caused issues with multiple elements in fullscreen mode.
Consider making this more specific or allowing override per context:
-export const DEFAULT_DATA_TEST_ID = "t--more-action-trigger"; +export const DEFAULT_DATA_TEST_ID = "t--entity-more-action-trigger";app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.tsx (1)
16-20
: LGTM! Well-structured props interface.Props are clearly defined with appropriate types.
app/client/src/pages/AppIDE/components/QueryEntityItem/QueryEntityItem.tsx (1)
51-58
: LGTM! Proper memoization of context menu.The context menu is correctly memoized with appropriate dependencies.
Description
Extracted EntityContextMenu, used in EntityItems, into ADS templates.
Fixes #39355
Automation
/ok-to-test tags="@tag.IDE"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13416528173
Commit: dd82e81
Cypress dashboard.
Tags:
@tag.IDE
Spec:
Wed, 19 Feb 2025 16:15:34 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
Summary by CodeRabbit
EntityContextMenu
by integrating it into various components within the application.