From 7fd5d346ff97d1948db6e77696162a5da0fe3011 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Sat, 22 Mar 2025 16:05:12 -0600 Subject: [PATCH] favorites on list endpoint --- web/src/components/ui/dropdown/Dropdown.tsx | 2 +- web/src/components/ui/tooltip/TooltipBase.tsx | 26 +++++++------ .../CollectionsListContent.tsx | 37 +++++++++++-------- .../DashboardListContent.tsx | 20 ++++++++-- .../MetricItemsContainer.tsx | 18 ++++----- .../DashboardThreeDotMenu.tsx | 8 +++- 6 files changed, 68 insertions(+), 43 deletions(-) diff --git a/web/src/components/ui/dropdown/Dropdown.tsx b/web/src/components/ui/dropdown/Dropdown.tsx index e795aba98..fdce8058f 100644 --- a/web/src/components/ui/dropdown/Dropdown.tsx +++ b/web/src/components/ui/dropdown/Dropdown.tsx @@ -110,7 +110,7 @@ export const DropdownBase = ({ {children} diff --git a/web/src/components/ui/tooltip/TooltipBase.tsx b/web/src/components/ui/tooltip/TooltipBase.tsx index dfb5e3228..e8a7b2f5a 100644 --- a/web/src/components/ui/tooltip/TooltipBase.tsx +++ b/web/src/components/ui/tooltip/TooltipBase.tsx @@ -14,18 +14,20 @@ const TooltipContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, sideOffset = 4, ...props }, ref) => ( - + + + )); TooltipContent.displayName = TooltipPrimitive.Content.displayName; diff --git a/web/src/controllers/CollectionListController/CollectionsListContent.tsx b/web/src/controllers/CollectionListController/CollectionsListContent.tsx index 38b3ddf8d..dd891d76d 100644 --- a/web/src/controllers/CollectionListController/CollectionsListContent.tsx +++ b/web/src/controllers/CollectionListController/CollectionsListContent.tsx @@ -13,8 +13,10 @@ import { } from '@/components/ui/list'; import { useMemoizedFn } from '@/hooks'; import { NewCollectionModal } from '@/components/features/modal/NewCollectionModal'; -import { BusterCollectionListItem } from '@/api/asset_interfaces'; +import { BusterCollectionListItem, ShareAssetType } from '@/api/asset_interfaces'; import { CollectionListSelectedPopup } from './CollectionListSelectedPopup'; +import { Text } from '@/components/ui/typography'; +import { FavoriteStar } from '@/components/features/list'; export const CollectionsListContent: React.FC<{ openNewCollectionModal: boolean; @@ -54,17 +56,28 @@ export const CollectionsListContent: React.FC<{ CollectionsListContent.displayName = 'CollectionsListContent'; const columns: BusterListColumn[] = [ - { dataIndex: 'title', title: 'Title' }, { - dataIndex: 'createdAt', - title: 'Created at', - width: 145, - render: (v) => formatDate({ date: v, format: 'lll' }) + dataIndex: 'name', + title: 'Title', + render: (v, { id, ...rest }: BusterCollectionListItem) => { + return ( +
+ {v} + +
+ ); + } }, { - dataIndex: 'lastEdited', + dataIndex: 'last_edited', title: 'Last edited', - width: 145, + width: 150, render: (v) => formatDate({ date: v, format: 'lll' }) }, { @@ -98,13 +111,7 @@ const CollectionList: React.FC<{ route: BusterRoutes.APP_COLLECTIONS_ID, collectionId: collection.id }), - data: { - title: collection.name, - lastEdited: collection.last_edited, - createdAt: collection.created_at, - owner: collection.owner, - sharing: collection.sharing - } + data: collection }; }); }, [collectionsList]); diff --git a/web/src/controllers/DashboardListController/DashboardListContent.tsx b/web/src/controllers/DashboardListController/DashboardListContent.tsx index cbf3b5783..241058f0c 100644 --- a/web/src/controllers/DashboardListController/DashboardListContent.tsx +++ b/web/src/controllers/DashboardListController/DashboardListContent.tsx @@ -16,14 +16,28 @@ import type { BusterDashboardListItem } from '@/api/asset_interfaces'; import { getShareStatus } from '@/components/features/metrics/StatusBadgeIndicator/helpers'; import { useCreateDashboard } from '@/api/buster_rest/dashboards'; import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; +import { FavoriteStar } from '@/components/features/list'; +import { ShareAssetType } from '@/api/asset_interfaces'; +import { Text } from '@/components/ui/typography'; const columns: BusterListColumn[] = [ { dataIndex: 'name', title: 'Title', - render: (data) => { - if (data) return data; - return 'New Dashboard'; + render: (data, { id }) => { + const name = data || 'New Dashboard'; + return ( +
+ {name} + +
+ ); } }, { diff --git a/web/src/controllers/MetricListContainer/MetricItemsContainer.tsx b/web/src/controllers/MetricListContainer/MetricItemsContainer.tsx index c0cb8a065..45ccff4e8 100644 --- a/web/src/controllers/MetricListContainer/MetricItemsContainer.tsx +++ b/web/src/controllers/MetricListContainer/MetricItemsContainer.tsx @@ -158,20 +158,18 @@ const TitleCell = React.memo<{ title: string; status: VerificationStatus; metric }); return ( -
+
{title} -
- -
+
); } diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardThreeDotMenu.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardThreeDotMenu.tsx index 60bee2864..3011c99d3 100644 --- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardThreeDotMenu.tsx +++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardThreeDotMenu.tsx @@ -33,6 +33,7 @@ import { ShareMenuContent } from '@/components/features/ShareMenu/ShareMenuConte import { DASHBOARD_TITLE_INPUT_ID } from '@/controllers/DashboardController/DashboardViewDashboardController/DashboardEditTitle'; import { canEdit, canFilter, getIsEffectiveOwner } from '@/lib/share'; import { getShareAssetConfig } from '@/components/features/ShareMenu/helpers'; +import { useDashboardContentStore } from '@/context/Dashboards'; export const DashboardThreeDotMenu = React.memo(({ dashboardId }: { dashboardId: string }) => { const versionHistoryItems = useVersionHistorySelectMenu({ dashboardId }); @@ -245,13 +246,16 @@ export const useShareMenuSelectMenu = ({ dashboardId }: { dashboardId: string }) }; const useAddContentToDashboardSelectMenu = () => { + const onOpenAddContentModal = useDashboardContentStore((x) => x.onOpenAddContentModal); + return useMemo( () => ({ label: 'Add content', value: 'add-content', - icon: + icon: , + onClick: onOpenAddContentModal }), - [] + [onOpenAddContentModal] ); };