diff --git a/web/src/api/buster_rest/dashboards/queryRequests.ts b/web/src/api/buster_rest/dashboards/queryRequests.ts index bfd4fff3c..fe146bb13 100644 --- a/web/src/api/buster_rest/dashboards/queryRequests.ts +++ b/web/src/api/buster_rest/dashboards/queryRequests.ts @@ -72,8 +72,8 @@ const useGetDashboardAndInitializeMetrics = () => { export const useGetDashboard = ( { id, - version_number: version_number_prop - }: { id: string | undefined; version_number?: number | null }, + versionNumber: versionNumberProp + }: { id: string | undefined; versionNumber?: number | null }, params?: Omit< UseQueryOptions, 'queryKey' | 'queryFn' @@ -85,12 +85,14 @@ export const useGetDashboard = ( }; const versionNumberQueryParam = useSearchParams().get('versionNumber'); - const versionNumber = versionNumberQueryParam || verionNumberPathParam; + const versionNumberFromParams = versionNumberQueryParam || verionNumberPathParam; const version_number = useMemo(() => { - if (version_number_prop === null) return undefined; - return version_number_prop || versionNumber ? parseInt(versionNumber!) : undefined; - }, [version_number_prop, versionNumber]); + if (versionNumberProp === null) return undefined; + return versionNumberProp || versionNumberFromParams + ? parseInt(versionNumberFromParams!) + : undefined; + }, [versionNumberProp, versionNumberFromParams]); return useQuery({ ...dashboardQueryKeys.dashboardGetDashboard(id!, version_number), diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx index bc1260c8e..8dc4f8195 100644 --- a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx +++ b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx @@ -5,12 +5,12 @@ export default async function MetricLayout({ params }: { children: React.ReactNode; - params: Promise<{ metricId: string }>; + params: Promise<{ metricId: string; versionNumber?: number }>; }) { - const { metricId } = await params; + const { metricId, versionNumber } = await params; return ( - + {children} ); diff --git a/web/src/layouts/AppAssetCheckLayout/AppAssetCheckLayout.tsx b/web/src/layouts/AppAssetCheckLayout/AppAssetCheckLayout.tsx index 4e235109f..d0de46626 100644 --- a/web/src/layouts/AppAssetCheckLayout/AppAssetCheckLayout.tsx +++ b/web/src/layouts/AppAssetCheckLayout/AppAssetCheckLayout.tsx @@ -15,14 +15,15 @@ import { HydrationBoundaryAssetStore } from '@/context/Assets/HydrationBoundaryA export type AppAssetCheckLayoutProps = { assetId: string; type: 'metric' | 'dashboard'; + versionNumber?: number; }; export const AppAssetCheckLayout: React.FC< { children: React.ReactNode; } & AppAssetCheckLayoutProps -> = async ({ children, type, assetId }) => { - const queryClient = await prefetchAsset(assetId, type); +> = async ({ children, type, assetId, versionNumber }) => { + const queryClient = await prefetchAsset(assetId, type, versionNumber); const { has_access, @@ -55,7 +56,7 @@ export const AppAssetCheckLayout: React.FC< return ( - + {Component} @@ -63,15 +64,25 @@ export const AppAssetCheckLayout: React.FC< ); }; -const prefetchAsset = async (assetId: string, type: 'metric' | 'dashboard') => { +const prefetchAsset = async ( + assetId: string, + type: 'metric' | 'dashboard', + versionNumber?: number +) => { let queryClient = new QueryClient(); switch (type) { case 'metric': - queryClient = await prefetchGetMetric({ id: assetId }, queryClient); + queryClient = await prefetchGetMetric( + { id: assetId, version_number: versionNumber }, + queryClient + ); break; case 'dashboard': - queryClient = await prefetchGetDashboard({ id: assetId }, queryClient); + queryClient = await prefetchGetDashboard( + { id: assetId, version_number: versionNumber }, + queryClient + ); break; default: const _exhaustiveCheck: never = type; diff --git a/web/src/layouts/AppAssetCheckLayout/AppAssetLoadingContainer.tsx b/web/src/layouts/AppAssetCheckLayout/AppAssetLoadingContainer.tsx index 98a327be8..166dfdbb8 100644 --- a/web/src/layouts/AppAssetCheckLayout/AppAssetLoadingContainer.tsx +++ b/web/src/layouts/AppAssetCheckLayout/AppAssetLoadingContainer.tsx @@ -2,24 +2,23 @@ import { useGetDashboard } from '@/api/buster_rest/dashboards'; import { useGetMetric, useGetMetricData } from '@/api/buster_rest/metrics'; -import { metricsQueryKeys } from '@/api/query_keys/metric'; import { FileIndeterminateLoader } from '@/components/features/FileIndeterminateLoader'; -import { useMount } from '@/hooks'; -import { useQuery, useQueryClient } from '@tanstack/react-query'; -import React, { useEffect, useMemo, useState } from 'react'; +import React, { useMemo } from 'react'; export const AppAssetLoadingContainer: React.FC<{ assetId: string; type: 'metric' | 'dashboard'; children: React.ReactNode; -}> = React.memo(({ assetId, type, children }) => { + versionNumber: number | undefined; +}> = React.memo(({ assetId, type, children, versionNumber }) => { const { isFetchedConfig: isFetchedMetricConfig, isFetchedData: isFetchedMetricData, error: metricError } = useGetMetricAssetData({ assetId, - enabled: type === 'metric' + enabled: type === 'metric', + versionNumber }); const { isFetchedConfig: isFetchedDashboardConfig, @@ -27,7 +26,8 @@ export const AppAssetLoadingContainer: React.FC<{ error: dashboardError } = useGetDashboardAssetData({ assetId, - enabled: type === 'dashboard' + enabled: type === 'dashboard', + versionNumber }); const showLoader = useMemo(() => { @@ -60,12 +60,22 @@ export const AppAssetLoadingContainer: React.FC<{ AppAssetLoadingContainer.displayName = 'AppAssetLoadingContainer'; -const useGetMetricAssetData = ({ assetId, enabled }: { assetId: string; enabled: boolean }) => { +const useGetMetricAssetData = ({ + assetId, + enabled, + versionNumber +}: { + assetId: string; + enabled: boolean; + versionNumber: number | undefined; +}) => { const { isFetched: isMetricFetched, ...rest } = useGetMetric({ - id: enabled ? assetId : undefined + id: enabled ? assetId : undefined, + versionNumber }); const { isFetched: isMetricDataFetched } = useGetMetricData({ - id: enabled ? assetId : undefined + id: enabled ? assetId : undefined, + versionNumber }); return { @@ -75,9 +85,18 @@ const useGetMetricAssetData = ({ assetId, enabled }: { assetId: string; enabled: }; }; -const useGetDashboardAssetData = ({ assetId, enabled }: { assetId: string; enabled: boolean }) => { +const useGetDashboardAssetData = ({ + assetId, + enabled, + versionNumber +}: { + assetId: string; + enabled: boolean; + versionNumber: number | undefined; +}) => { const { isFetched: isDashboardFetched, error: dashboardError } = useGetDashboard({ - id: enabled ? assetId : undefined + id: enabled ? assetId : undefined, + versionNumber }); return { diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx index de7f993b3..954d3a06e 100644 --- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx +++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx @@ -65,7 +65,7 @@ const FileContainerHeaderStandard: React.FC<{ /> )} -
+
diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeaderVersionHistory/useCloseVersionHistory.ts b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeaderVersionHistory/useCloseVersionHistory.ts index 10b210ce7..5e5a57558 100644 --- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeaderVersionHistory/useCloseVersionHistory.ts +++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeaderVersionHistory/useCloseVersionHistory.ts @@ -21,14 +21,13 @@ export const useCloseVersionHistory = () => { chatId: string | undefined; }) => { closeSecondaryView(); - await timeout(chatId ? 250 : 0); + await timeout(chatId ? 250 : 0); //wait for the secondary view to close startTransition(() => { const link = getFileLink({ fileId: assetId, fileType: type, chatId }); - alert(link); if (link) onChangePage(link); }); } diff --git a/web/src/layouts/DashboardLayout/DashboardLayoutContainer.tsx b/web/src/layouts/DashboardLayout/DashboardLayoutContainer.tsx index 72e61709a..55f149de0 100644 --- a/web/src/layouts/DashboardLayout/DashboardLayoutContainer.tsx +++ b/web/src/layouts/DashboardLayout/DashboardLayoutContainer.tsx @@ -13,7 +13,7 @@ export const DashboardLayoutContainer: React.FC<{ return ( <> {children} - + {/* */} ); };