mirror of https://github.com/buster-so/buster.git
fixed broken exit button
This commit is contained in:
parent
090f7877b7
commit
5c9a45977d
|
@ -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'
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]);
|
||||
|
||||
|
|
|
@ -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]: {
|
||||
|
|
Loading…
Reference in New Issue