From 7e98b6d853c6e6b89b231dc52a4072fd0f6e0377 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 10 Apr 2023 16:02:29 -0700 Subject: [PATCH] Dropdown keys and pointer events --- src-web/components/RecentRequestsDropdown.tsx | 4 +++- src-web/components/RequestActionsDropdown.tsx | 3 +++ src-web/components/ResponsePane.tsx | 3 +++ src-web/components/WorkspaceActionsDropdown.tsx | 4 ++++ src-web/components/WorkspaceHeader.tsx | 2 +- src-web/components/core/Button.tsx | 6 ++++-- src-web/components/core/Dropdown.tsx | 3 ++- src-web/components/core/RadioDropdown.tsx | 1 + 8 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src-web/components/RecentRequestsDropdown.tsx b/src-web/components/RecentRequestsDropdown.tsx index 46c4bf8f..82fd0666 100644 --- a/src-web/components/RecentRequestsDropdown.tsx +++ b/src-web/components/RecentRequestsDropdown.tsx @@ -49,6 +49,7 @@ export function RecentRequestsDropdown() { if (request === undefined) continue; recentRequestItems.push({ + key: request.id, label: request.name, leftSlot: , onSelect: () => { @@ -71,8 +72,9 @@ export function RecentRequestsDropdown() { return ( diff --git a/src-web/components/RequestActionsDropdown.tsx b/src-web/components/RequestActionsDropdown.tsx index bf051efa..9a85034c 100644 --- a/src-web/components/RequestActionsDropdown.tsx +++ b/src-web/components/RequestActionsDropdown.tsx @@ -34,12 +34,14 @@ export function RequestActionsDropdown({ requestId, children }: Props) { ref={dropdownRef} items={[ { + key: 'duplicate', label: 'Duplicate', onSelect: duplicateRequest.mutate, leftSlot: , rightSlot: , }, { + key: 'delete', label: 'Delete', onSelect: deleteRequest.mutate, variant: 'danger', @@ -47,6 +49,7 @@ export function RequestActionsDropdown({ requestId, children }: Props) { }, { type: 'separator', label: 'Yaak Settings' }, { + key: 'appearance', label: appearance === 'dark' ? 'Light Theme' : 'Dark Theme', onSelect: toggleAppearance, leftSlot: , diff --git a/src-web/components/ResponsePane.tsx b/src-web/components/ResponsePane.tsx index 662fdb88..09bd61ab 100644 --- a/src-web/components/ResponsePane.tsx +++ b/src-web/components/ResponsePane.tsx @@ -131,11 +131,13 @@ export const ResponsePane = memo(function ResponsePane({ style, className }: Pro ({ + key: r.id, label: ( diff --git a/src-web/components/WorkspaceActionsDropdown.tsx b/src-web/components/WorkspaceActionsDropdown.tsx index 88d28148..883ea4d6 100644 --- a/src-web/components/WorkspaceActionsDropdown.tsx +++ b/src-web/components/WorkspaceActionsDropdown.tsx @@ -29,6 +29,7 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceDropdown({ classN const items: DropdownItem[] = useMemo(() => { const workspaceItems = workspaces.map((w) => ({ + key: w.id, label: w.name, leftSlot: activeWorkspaceId === w.id ? : , onSelect: () => { @@ -51,6 +52,7 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceDropdown({ classN return [ ...activeWorkspaceItems, { + key: 'rename', label: 'Rename', leftSlot: , onSelect: async () => { @@ -69,6 +71,7 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceDropdown({ classN }, }, { + key: 'delete', label: 'Delete', leftSlot: , onSelect: deleteWorkspace.mutate, @@ -76,6 +79,7 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceDropdown({ classN }, { type: 'separator' }, { + key: 'create-workspace', label: 'Create Workspace', leftSlot: , onSelect: async () => { diff --git a/src-web/components/WorkspaceHeader.tsx b/src-web/components/WorkspaceHeader.tsx index 742d3619..079e768e 100644 --- a/src-web/components/WorkspaceHeader.tsx +++ b/src-web/components/WorkspaceHeader.tsx @@ -25,7 +25,7 @@ export const WorkspaceHeader = memo(function WorkspaceHeader({ className }: Prop -
+
diff --git a/src-web/components/core/Button.tsx b/src-web/components/core/Button.tsx index 03e1f5a9..734cc4f0 100644 --- a/src-web/components/core/Button.tsx +++ b/src-web/components/core/Button.tsx @@ -39,6 +39,7 @@ const _Button = forwardRef(function Button( type = 'button', justify = 'center', size = 'md', + disabled, ...props }: ButtonProps, ref, @@ -50,6 +51,7 @@ const _Button = forwardRef(function Button( 'outline-none whitespace-nowrap', 'focus-visible-or-class:ring', 'rounded-md flex items-center', + disabled ? 'pointer-events-none' : 'pointer-events-auto', colorStyles[color || 'default'], justify === 'start' && 'justify-start', justify === 'center' && 'justify-center', @@ -57,7 +59,7 @@ const _Button = forwardRef(function Button( size === 'sm' && 'h-sm px-2.5 text-sm', size === 'xs' && 'h-xs px-2 text-sm', ), - [color, size, justify, className], + [className, disabled, color, justify, size], ); if (typeof to === 'string') { @@ -69,7 +71,7 @@ const _Button = forwardRef(function Button( ); } else { return ( -