From 0091f308c356bc153420fc113de6ead5337789a2 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Tue, 1 Apr 2025 12:48:30 -0600 Subject: [PATCH] much faster loads --- .../versionHistory/VersionHistoryPanel.tsx | 2 +- web/src/components/ui/dropdown/Dropdown.tsx | 2 -- .../DashboardThreeDotMenu.tsx | 21 +++++++++-- .../MetricThreeDotMenu.tsx | 36 +++++++++++++++---- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/web/src/components/features/versionHistory/VersionHistoryPanel.tsx b/web/src/components/features/versionHistory/VersionHistoryPanel.tsx index 996e2749e..56aadc872 100644 --- a/web/src/components/features/versionHistory/VersionHistoryPanel.tsx +++ b/web/src/components/features/versionHistory/VersionHistoryPanel.tsx @@ -46,7 +46,7 @@ export const VersionHistoryPanel = React.memo( )} scrollable headerBorderVariant="ghost"> -
+
{listItems?.map((item) => ( ({ debounceTime: 50 }); - console.log(filteredItems, searchText); - const hasShownItem = useMemo(() => { return filteredItems.length > 0 && filteredItems.some((item) => (item as DropdownItem).value); }, [filteredItems]); diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardThreeDotMenu.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardThreeDotMenu.tsx index 021fd1425..f7ad7dc1e 100644 --- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardThreeDotMenu.tsx +++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardThreeDotMenu.tsx @@ -36,6 +36,7 @@ import { getShareAssetConfig } from '@/components/features/ShareMenu/helpers'; import { useDashboardContentStore } from '@/context/Dashboards'; import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; import { BusterRoutes } from '@/routes/busterRoutes'; +import { assetParamsToRoute } from '@/layouts/ChatLayout/ChatLayoutContext/helpers'; export const DashboardThreeDotMenu = React.memo(({ dashboardId }: { dashboardId: string }) => { const versionHistoryItems = useVersionHistorySelectMenu({ dashboardId }); @@ -90,15 +91,31 @@ const useVersionHistorySelectMenu = ({ dashboardId }: { dashboardId: string }) = version_number: x?.dashboard?.version_number })); const { versions, version_number } = data || {}; + const chatId = useChatLayoutContextSelector((x) => x.chatId); + const onChangePage = useAppLayoutContextSelector((s) => s.onChangePage); + + const createRouteWithQueryParams = useMemoizedFn((versionNumber: number) => { + const baseRoute = assetParamsToRoute({ + chatId, + assetId: dashboardId, + type: 'dashboard', + secondaryView: 'version-history' + }); + + return `${baseRoute}?${new URLSearchParams({ + dashboard_version_number: versionNumber.toString() + }).toString()}`; + }); const versionHistoryItems: DropdownItems = useMemo(() => { return [...(versions || [])].reverse().map((x) => ({ label: `Version ${x.version_number}`, secondaryLabel: timeFromNow(x.updated_at, false), value: x.version_number.toString(), - selected: x.version_number === version_number + selected: x.version_number === version_number, + onClick: () => onChangePage(createRouteWithQueryParams(x.version_number)) })); - }, [versions, version_number]); + }, [versions, version_number, createRouteWithQueryParams, onChangePage]); return useMemo( () => ({ diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx index 2410831eb..edce73033 100644 --- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx +++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx @@ -50,6 +50,8 @@ import { ShareMenuContent } from '@/components/features/ShareMenu/ShareMenuConte import { canEdit, getIsEffectiveOwner, getIsOwner } from '@/lib/share'; import { getShareAssetConfig } from '@/components/features/ShareMenu/helpers'; import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; +import { BusterRoutes, createBusterRoute } from '@/routes'; +import { assetParamsToRoute } from '@/layouts/ChatLayout/ChatLayoutContext/helpers'; export const ThreeDotMenuButton = React.memo(({ metricId }: { metricId: string }) => { const { openSuccessMessage } = useBusterNotifications(); @@ -118,7 +120,13 @@ export const ThreeDotMenuButton = React.memo(({ metricId }: { metricId: string } ); return ( - +