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

View File

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

View File

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