From 1d272b36ec44198a317012bf4d40e5ee791b0a01 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Tue, 8 Apr 2025 11:15:24 -0600 Subject: [PATCH] dashboard versions --- web/src/api/buster_rest/dashboards/queryRequests.ts | 2 +- .../DashboardViewDashboardController.tsx | 4 +++- .../ChatResponseMessage_File/useGetFileHref.tsx | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/src/api/buster_rest/dashboards/queryRequests.ts b/web/src/api/buster_rest/dashboards/queryRequests.ts index 71ee76774..4c691308a 100644 --- a/web/src/api/buster_rest/dashboards/queryRequests.ts +++ b/web/src/api/buster_rest/dashboards/queryRequests.ts @@ -91,7 +91,7 @@ export const useGetDashboard = ( return useQuery({ ...dashboardQueryKeys.dashboardGetDashboard(id!, version_number), queryFn: () => queryFn(id!, version_number), - enabled: false, //it is false because we fetch the dashboard server side + enabled: !!id, //it is false because we fetch the dashboard server side select: params?.select, ...params }); diff --git a/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardViewDashboardController.tsx b/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardViewDashboardController.tsx index e5c3b76a4..bce697bd6 100644 --- a/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardViewDashboardController.tsx +++ b/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardViewDashboardController.tsx @@ -11,12 +11,14 @@ import { import { useDashboardContentStore } from '@/context/Dashboards'; import { ScrollArea } from '@/components/ui/scroll-area'; import { canEdit } from '@/lib/share'; +import { useChatLayoutContextSelector } from '@/layouts/ChatLayout'; export const DashboardViewDashboardController: React.FC<{ dashboardId: string; chatId: string | undefined; readOnly?: boolean; }> = ({ dashboardId, chatId, readOnly: readOnlyProp = false }) => { + const isVersionHistoryMode = useChatLayoutContextSelector((x) => x.isVersionHistoryMode); const { data: dashboardResponse } = useGetDashboard({ id: dashboardId }); const { mutateAsync: onUpdateDashboard } = useUpdateDashboard(); const { mutateAsync: onUpdateDashboardConfig } = useUpdateDashboardConfig(); @@ -24,7 +26,7 @@ export const DashboardViewDashboardController: React.FC<{ const metrics = dashboardResponse?.metrics; const dashboard = dashboardResponse?.dashboard; - const readOnly = readOnlyProp || !canEdit(dashboardResponse?.permission); + const readOnly = readOnlyProp || !canEdit(dashboardResponse?.permission) || isVersionHistoryMode; return ( diff --git a/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessage_File/useGetFileHref.tsx b/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessage_File/useGetFileHref.tsx index 1442b82db..d1d7107af 100644 --- a/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessage_File/useGetFileHref.tsx +++ b/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessage_File/useGetFileHref.tsx @@ -45,7 +45,6 @@ export const useGetFileHref = ({ } if (file_type === 'dashboard') { - console.log('dashboard', { isLatestVersion, id, version_number }); if (isLatestVersion) { return createBusterRoute({ route: BusterRoutes.APP_CHAT_ID_DASHBOARD_ID,