From a70b7c0ca6d0c9a0da7836ee871f1108da106de0 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 19 Mar 2025 17:21:43 -0600 Subject: [PATCH] update owner items --- .../dashboards/interfaces.ts | 4 --- .../features/ShareMenu/AccessDropdown.tsx | 27 +++++++++++++------ .../ShareMenu/ShareMenuContentBody.tsx | 2 +- web/src/components/ui/dropdown/Dropdown.tsx | 6 +++-- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/web/src/api/request_interfaces/dashboards/interfaces.ts b/web/src/api/request_interfaces/dashboards/interfaces.ts index 05097d4f5..2740c890e 100644 --- a/web/src/api/request_interfaces/dashboards/interfaces.ts +++ b/web/src/api/request_interfaces/dashboards/interfaces.ts @@ -61,10 +61,6 @@ export type DashboardUpdateRequest = { add_to_collections?: string[]; /** Collection IDs to remove the dashboard from */ remove_from_collections?: string[]; - /** User IDs to remove access from */ - remove_users?: string[]; - /** Array of metric IDs associated with the dashboard */ - metrics?: string[]; /** The file content of the dashboard */ file?: string; }; diff --git a/web/src/components/features/ShareMenu/AccessDropdown.tsx b/web/src/components/features/ShareMenu/AccessDropdown.tsx index c486748d5..ff80b807b 100644 --- a/web/src/components/features/ShareMenu/AccessDropdown.tsx +++ b/web/src/components/features/ShareMenu/AccessDropdown.tsx @@ -6,6 +6,7 @@ import { useMemoizedFn } from '@/hooks'; import { Dropdown } from '@/components/ui/dropdown'; import { ChevronDown } from '@/components/ui/icons/NucleoIconFilled'; import { canEdit } from '@/lib/share'; +import { cn } from '@/lib/classMerge'; type DropdownValue = ShareRole | 'remove' | 'notShared'; @@ -25,7 +26,7 @@ export const AccessDropdown: React.FC<{ const disabled = useMemo(() => canEdit(shareLevel), [shareLevel]); const items = useMemo(() => { - const baseItems: DropdownItem[] = [...standardItems]; + const baseItems: DropdownItem[] = standardItems; if (groupShare) { baseItems.push({ @@ -46,11 +47,12 @@ export const AccessDropdown: React.FC<{ }, [groupShare, showRemove, shareLevel]); const selectedLabel = useMemo(() => { - const selectedItem = items.find((item) => item.selected); - if (!selectedItem) return 'No shared'; + const selectedItem = items.find((item) => item.selected) || OWNER_ITEM; const { value } = selectedItem; + console.log(selectedItem, shareLevel); + // Using a type-safe switch to handle all ShareRole values switch (value) { case ShareRole.FULL_ACCESS: @@ -62,13 +64,11 @@ export const AccessDropdown: React.FC<{ case ShareRole.CAN_VIEW: return 'Can view'; case ShareRole.OWNER: - return 'Full access'; + return 'Owner'; case 'remove': return 'Remove'; case 'notShared': return 'Not shared'; - default: - return typeof selectedItem.label === 'string' ? selectedItem.label : 'Selected'; } }, [items]); @@ -83,6 +83,7 @@ export const AccessDropdown: React.FC<{ return ( } footerClassName="p-0!" onSelect={onSelectMenuItem} @@ -93,9 +94,13 @@ export const AccessDropdown: React.FC<{ + className={cn('flex! items-center! space-x-1', !disabled && 'cursor-pointer', className)}> {selectedLabel} - {!disabled && } + {!disabled && ( + + + + )} ); @@ -124,6 +129,12 @@ const standardItems: DropdownItem[] = [ } ]; +const OWNER_ITEM: DropdownItem = { + value: ShareRole.OWNER, + label: 'Owner', + secondaryLabel: 'Owner of the asset.' +}; + const FooterContent = React.memo(() => { return (
diff --git a/web/src/components/features/ShareMenu/ShareMenuContentBody.tsx b/web/src/components/features/ShareMenu/ShareMenuContentBody.tsx index dfe0ed25b..a5137e837 100644 --- a/web/src/components/features/ShareMenu/ShareMenuContentBody.tsx +++ b/web/src/components/features/ShareMenu/ShareMenuContentBody.tsx @@ -192,7 +192,7 @@ const ShareMenuContentShare: React.FC = React.memo( )} {hasIndividualPermissions && ( -
+
{individual_permissions?.map((permission) => ( extends DropdownMenuProps { contentClassName?: string; footerClassName?: string; sideOffset?: number; + disabled?: boolean; } export interface DropdownContentProps @@ -95,7 +96,8 @@ export const DropdownBase = ({ modal, sideOffset, footerClassName = '', - showIndex = false + showIndex = false, + disabled = false }: DropdownProps) => { return ( ({ onOpenChange={onOpenChange} dir={dir} modal={modal}> - + {children}