-
Notifications
You must be signed in to change notification settings - Fork 213
feat: right click actions across the console #2787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HarshMN2345
wants to merge
5
commits into
main
Choose a base branch
from
feat-SER-655-right-click-shortcuts-console
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
...ject-[region]-[project]/databases/database-[database]/table-[table]/rowContextMenu.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| <script lang="ts"> | ||
| import { createContextMenu, melt } from '@melt-ui/svelte'; | ||
| import { Card, ActionMenu, Divider } from '@appwrite.io/pink-svelte'; | ||
| import type { ComponentType } from 'svelte'; | ||
| import { | ||
| IconPencil, | ||
| IconDuplicate, | ||
| IconKey, | ||
| IconChartBar, | ||
| IconLink, | ||
| IconTrash, | ||
| IconClipboardCopy, | ||
| IconCode, | ||
| IconChevronRight | ||
| } from '@appwrite.io/pink-icons-svelte'; | ||
| import type { RowCellAction } from './sheetOptions.svelte'; | ||
| import { trackEvent, Click } from '$lib/actions/analytics'; | ||
|
|
||
| export let onSelect: (action: RowCellAction) => void; | ||
|
|
||
| const { | ||
| elements: { menu, trigger, item }, | ||
| builders: { createSubmenu } | ||
| } = createContextMenu({ | ||
| positioning: { | ||
| placement: 'right-start', | ||
| gutter: 2, | ||
| sameWidth: false | ||
| }, | ||
| onOpenChange: ({ next }) => { | ||
| if (next) { | ||
| trackEvent(Click.RowContextMenuOpen); | ||
| } | ||
| return next; | ||
| } | ||
| }); | ||
|
|
||
| const { | ||
| elements: { subMenu: copySubMenu, subTrigger: copySubTrigger } | ||
| } = createSubmenu({ | ||
| positioning: { | ||
| placement: 'right-start', | ||
| gutter: 8 | ||
| }, | ||
| arrowSize: 0 | ||
| }); | ||
|
|
||
| const menuItems: { | ||
| label?: string; | ||
| icon?: ComponentType; | ||
| action?: RowCellAction; | ||
| subMenu?: string; | ||
| divider?: boolean; | ||
| danger?: boolean; | ||
| }[] = [ | ||
| { label: 'Update row', icon: IconPencil, action: 'update' }, | ||
| { label: 'Duplicate row', icon: IconDuplicate, action: 'duplicate-row' }, | ||
| { divider: true }, | ||
| { label: 'Manage permissions', icon: IconKey, action: 'permissions' }, | ||
| { label: 'View activity', icon: IconChartBar, action: 'activity' }, | ||
| { divider: true }, | ||
| { label: 'Copy', icon: IconDuplicate, subMenu: 'copy' }, | ||
| { divider: true }, | ||
| { label: 'Delete', icon: IconTrash, action: 'delete', danger: true } | ||
| ]; | ||
|
|
||
| const copyMenuItems: { label: string; icon: ComponentType; action: RowCellAction }[] = [ | ||
| { label: 'URL', icon: IconLink, action: 'copy-url' }, | ||
| { label: 'JSON', icon: IconClipboardCopy, action: 'copy-json' }, | ||
| { label: 'Code snippet', icon: IconCode, action: 'copy-snippet' } | ||
| ]; | ||
| </script> | ||
|
|
||
| <div use:melt={$trigger} style="display: contents;"> | ||
| <slot /> | ||
| </div> | ||
|
|
||
| <div class="menu" use:melt={$menu}> | ||
| <Card.Base padding="none"> | ||
| <div class="action-menu-root"> | ||
| <ActionMenu.Root> | ||
| {#each menuItems as menuItem} | ||
| {#if menuItem.divider} | ||
| <div style:padding-block="0.25rem"> | ||
| <Divider /> | ||
| </div> | ||
| {:else if menuItem.subMenu === 'copy'} | ||
| <!-- Copy Submenu Trigger --> | ||
| <div use:melt={$copySubTrigger} class="sub-trigger"> | ||
| <ActionMenu.Root> | ||
| <ActionMenu.Item.Button | ||
| leadingIcon={menuItem.icon} | ||
| trailingIcon={IconChevronRight}> | ||
| {menuItem.label} | ||
| </ActionMenu.Item.Button> | ||
| </ActionMenu.Root> | ||
| </div> | ||
| {:else} | ||
| <div | ||
| use:melt={$item} | ||
| style:display="contents" | ||
| on:m-click={() => onSelect(menuItem.action as RowCellAction)}> | ||
| <ActionMenu.Item.Button | ||
| leadingIcon={menuItem.icon} | ||
| status={menuItem.danger ? 'danger' : undefined}> | ||
| {menuItem.label} | ||
| </ActionMenu.Item.Button> | ||
| </div> | ||
| {/if} | ||
| {/each} | ||
| </ActionMenu.Root> | ||
| </div> | ||
|
|
||
| <!-- Copy Submenu (outside ActionMenu.Root, inside Card.Base) --> | ||
| <div class="menu submenu" use:melt={$copySubMenu}> | ||
| <Card.Base padding="none"> | ||
| <div class="action-menu-root"> | ||
| {#each copyMenuItems as copyItem} | ||
| <div use:melt={$item} on:m-click={() => onSelect(copyItem.action)}> | ||
| <ActionMenu.Root> | ||
| <ActionMenu.Item.Button leadingIcon={copyItem.icon}> | ||
| {copyItem.label} | ||
| </ActionMenu.Item.Button> | ||
| </ActionMenu.Root> | ||
| </div> | ||
| {/each} | ||
| </div> | ||
| </Card.Base> | ||
| </div> | ||
| </Card.Base> | ||
| </div> | ||
|
|
||
| <style> | ||
| .menu { | ||
| z-index: 50; | ||
| min-width: 220px; | ||
| outline: none; | ||
| border-radius: var(--border-radius-m); | ||
| box-shadow: var(--shadow-large); | ||
| } | ||
|
|
||
| .submenu { | ||
| margin-inline: -4px; | ||
| margin-block: -4px; | ||
| } | ||
|
|
||
| .action-menu-root { | ||
| margin-inline-start: calc(var(--space-2) * -1); | ||
|
|
||
| & :global(:first-child) { | ||
| overflow: visible; | ||
| } | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |
| | 'activity' | ||
| | 'copy-url' | ||
| | 'copy-json' | ||
| // | 'copy-snippet' | ||
| | 'copy-snippet' | ||
| | 'delete'; | ||
| </script> | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: appwrite/console
Length of output: 90
🏁 Script executed:
Repository: appwrite/console
Length of output: 18237
🏁 Script executed:
Repository: appwrite/console
Length of output: 3576
Simplify
ActionMenu.Rootwrapping in copy submenu items (lines 120-124).Each item in the
copyMenuItemsloop has its ownActionMenu.Root, which is atypical. The standard pattern across the codebase is oneActionMenu.Rootwrapping multiple items. Move theActionMenu.Rootoutside the loop:Current structure (incorrect)
Recommended: One
ActionMenu.Rootshould wrap all items in the loop, consistent with how the main menu items are structured (lines 81-111).🤖 Prompt for AI Agents