fixed broken exit button

This commit is contained in:
Nate Kelley 2025-04-15 22:46:59 -06:00
parent 090f7877b7
commit 5c9a45977d
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
4 changed files with 46 additions and 7 deletions

View File

@ -467,4 +467,24 @@ describe('assetParamsToRoute', () => {
}) })
); );
}); });
test('no chat id, metric with version number', () => {
const test = {
assetId: '06d9d8b7-eb96-59af-9a03-0436205b60a9',
type: 'metric',
versionNumber: 1,
chatId: undefined,
secondaryView: 'version-history'
} as const;
const result = assetParamsToRoute(test);
expect(result).toBe(
createBusterRoute({
route: BusterRoutes.APP_METRIC_ID_VERSION_NUMBER,
metricId: test.assetId,
versionNumber: test.versionNumber,
secondaryView: 'version-history'
})
);
});
}); });

View File

@ -27,7 +27,7 @@ const createMetricRoute = ({
secondaryView, secondaryView,
versionNumber versionNumber
}: MetricRouteParams) => { }: MetricRouteParams) => {
const baseParams = { metricId, secondaryView }; const baseParams = { versionNumber, metricId, secondaryView };
if (chatId) { if (chatId) {
if (versionNumber) { if (versionNumber) {
@ -69,6 +69,14 @@ const createMetricRoute = ({
} }
// Non-chat metric routes // Non-chat metric routes
if (versionNumber) {
return createBusterRoute({
route: BusterRoutes.APP_METRIC_ID_VERSION_NUMBER,
...baseParams
});
}
switch (secondaryView) { switch (secondaryView) {
case 'chart-edit': case 'chart-edit':
return createBusterRoute({ return createBusterRoute({
@ -81,9 +89,8 @@ const createMetricRoute = ({
...baseParams ...baseParams
}); });
case 'version-history': case 'version-history':
//
default: default:
const test: never | undefined =
secondaryView === 'version-history' ? undefined : secondaryView;
return createBusterRoute({ return createBusterRoute({
route: BusterRoutes.APP_METRIC_ID_CHART, route: BusterRoutes.APP_METRIC_ID_CHART,
metricId metricId

View File

@ -1,7 +1,10 @@
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
import { useMemoizedFn } from '@/hooks'; import { useMemoizedFn } from '@/hooks';
import { useGetInitialChatFile } from '@/layouts/ChatLayout/ChatContext/useGetInitialChatFile'; import { useGetInitialChatFile } from '@/layouts/ChatLayout/ChatContext/useGetInitialChatFile';
import { useChatLayoutContextSelector } from '@/layouts/ChatLayout/ChatLayoutContext'; import {
assetParamsToRoute,
useChatLayoutContextSelector
} from '@/layouts/ChatLayout/ChatLayoutContext';
import { useMemo } from 'react'; import { useMemo } from 'react';
export const useCloseVersionHistory = () => { export const useCloseVersionHistory = () => {
@ -13,16 +16,24 @@ export const useCloseVersionHistory = () => {
const getInitialChatFileHref = useGetInitialChatFile(); const getInitialChatFileHref = useGetInitialChatFile();
const href = useMemo(() => { const href = useMemo(() => {
if (!chatId) {
return assetParamsToRoute({
assetId: metricId!,
type: 'metric',
chatId
});
}
return ( return (
getInitialChatFileHref({ getInitialChatFileHref({
metricId, metricId,
dashboardId, dashboardId,
chatId: chatId!, chatId,
secondaryView: null, secondaryView: null,
dashboardVersionNumber: undefined, dashboardVersionNumber: undefined,
metricVersionNumber: undefined, metricVersionNumber: undefined,
messageId messageId
}) || '' }) || 'error'
); );
}, [chatId, messageId, metricId, dashboardId]); }, [chatId, messageId, metricId, dashboardId]);

View File

@ -57,12 +57,13 @@ export type BusterAppRoutesWithArgs = {
[BusterAppRoutes.APP_METRIC_ID_CHART]: { [BusterAppRoutes.APP_METRIC_ID_CHART]: {
route: BusterAppRoutes.APP_METRIC_ID_CHART; route: BusterAppRoutes.APP_METRIC_ID_CHART;
metricId: string; metricId: string;
versionNumber?: number;
secondaryView?: MetricFileViewSecondary; secondaryView?: MetricFileViewSecondary;
}; };
[BusterAppRoutes.APP_METRIC_ID_VERSION_NUMBER]: { [BusterAppRoutes.APP_METRIC_ID_VERSION_NUMBER]: {
route: BusterAppRoutes.APP_METRIC_ID_VERSION_NUMBER; route: BusterAppRoutes.APP_METRIC_ID_VERSION_NUMBER;
metricId: string; metricId: string;
versionNumber: number; versionNumber?: number;
secondaryView?: MetricFileViewSecondary; secondaryView?: MetricFileViewSecondary;
}; };
[BusterAppRoutes.APP_METRIC_ID_FILE]: { [BusterAppRoutes.APP_METRIC_ID_FILE]: {