diff --git a/apps/web-tss/src/api/buster_rest/dashboards/dashboardVersionNumber.ts b/apps/web-tss/src/api/buster_rest/dashboards/dashboardVersionNumber.ts index 5b1c61d6c..8c426a8a7 100644 --- a/apps/web-tss/src/api/buster_rest/dashboards/dashboardVersionNumber.ts +++ b/apps/web-tss/src/api/buster_rest/dashboards/dashboardVersionNumber.ts @@ -20,7 +20,7 @@ export const useGetDashboardVersionNumber = ( // Get the dashboard_version_number query param from the route const paramVersionNumber = useSearch({ - from: '/app/_app/_asset/dashboards/$dashboardId', + from: '/app/_app/_asset/dashboards/$dashboardId/', shouldThrow: false, select: stableVersionSearchSelector, }); diff --git a/apps/web-tss/src/components/features/sidebars/SidebarPrimary/getFavoriteRoute.ts b/apps/web-tss/src/components/features/sidebars/SidebarPrimary/getFavoriteRoute.ts index e8ecf3353..1abcabea4 100644 --- a/apps/web-tss/src/components/features/sidebars/SidebarPrimary/getFavoriteRoute.ts +++ b/apps/web-tss/src/components/features/sidebars/SidebarPrimary/getFavoriteRoute.ts @@ -3,25 +3,43 @@ import type { OptionsTo } from '@/types/routes'; export const getFavoriteRoute = (favorite: Pick): OptionsTo => { if (favorite.asset_type === 'chat') { - return { to: '/app/chats/$chatId', params: { chatId: favorite.id } }; + return { + to: '/app/chats/$chatId', + params: { chatId: favorite.id }, + } as const satisfies OptionsTo; } if (favorite.asset_type === 'metric') { - return { to: '/app/metrics/$metricId', params: { metricId: favorite.id } }; + return { + to: '/app/metrics/$metricId', + params: { metricId: favorite.id }, + } as const satisfies OptionsTo; } if (favorite.asset_type === 'dashboard') { - return { to: '/app/dashboards/$dashboardId', params: { dashboardId: favorite.id } }; + return { + to: '/app/dashboards/$dashboardId', + params: { dashboardId: favorite.id }, + } as const satisfies OptionsTo; } if (favorite.asset_type === 'collection') { - return { to: '/app/collections/$collectionId', params: { collectionId: favorite.id } }; + return { + to: '/app/collections/$collectionId', + params: { collectionId: favorite.id }, + } as const satisfies OptionsTo; } if (favorite.asset_type === 'report') { - return { to: '/app/reports/$reportId', params: { reportId: favorite.id } }; + return { + to: '/app/reports/$reportId', + params: { reportId: favorite.id }, + } as const satisfies OptionsTo; } const _exhaustiveCheck: never = favorite.asset_type; - return { to: '/app/chats/$chatId', params: { chatId: favorite.id } }; + return { + to: '/app/chats/$chatId', + params: { chatId: favorite.id }, + } as const satisfies OptionsTo; }; diff --git a/apps/web-tss/src/components/ui/sidebar/interfaces.ts b/apps/web-tss/src/components/ui/sidebar/interfaces.ts index 4c49426cc..e54d04cf9 100644 --- a/apps/web-tss/src/components/ui/sidebar/interfaces.ts +++ b/apps/web-tss/src/components/ui/sidebar/interfaces.ts @@ -1,9 +1,4 @@ -import type { - ActiveOptions, - LinkProps, - RegisteredRouter, - ValidateLinkOptions, -} from '@tanstack/react-router'; +import type { LinkProps, RegisteredRouter } from '@tanstack/react-router'; import type React from 'react'; import type { LinkOptionsTo, OptionsTo } from '@/types/routes'; diff --git a/apps/web-tss/src/context/BusterAssets/metric-server/metricIndexServerAssetContext.ts b/apps/web-tss/src/context/BusterAssets/metric-server/metricIndexServerAssetContext.ts index ce61a147d..324f52190 100644 --- a/apps/web-tss/src/context/BusterAssets/metric-server/metricIndexServerAssetContext.ts +++ b/apps/web-tss/src/context/BusterAssets/metric-server/metricIndexServerAssetContext.ts @@ -1,12 +1,6 @@ import type { AssetType } from '@buster/server-shared/assets'; import type { QueryClient } from '@tanstack/react-query'; -import { - type AnyRoute, - type BeforeLoadContextOptions, - type BeforeLoadContextParameter, - type BeforeLoadFn, - redirect, -} from '@tanstack/react-router'; +import { MatchRoute, redirect } from '@tanstack/react-router'; import { z } from 'zod'; import { prefetchGetMetric } from '@/api/buster_rest/metrics'; import type { AppRouterContext } from '@/router'; @@ -26,7 +20,7 @@ export const beforeLoad: any = async ({ params, search, }: { - matches: { routeId: FileRouteTypes['id'] }[]; + matches: { routeId: FileRouteTypes['id']; fullPath: FileRouteTypes['fullPaths'] }[]; params: { metricId: string; }; @@ -40,7 +34,8 @@ export const beforeLoad: any = async ({ if (isIndexRoute) { throw redirect({ //relative path required the use of as... - to: './chart' as '/app/metrics/$metricId/chart', + from: lastMatch.fullPath, + to: './chart', params, search, }); diff --git a/apps/web-tss/src/routes/app/_app/_asset/dashboards.$dashboardId.metrics.$metricId.tsx b/apps/web-tss/src/routes/app/_app/_asset/dashboards.$dashboardId.metrics.$metricId.tsx index e466ca998..e83017622 100644 --- a/apps/web-tss/src/routes/app/_app/_asset/dashboards.$dashboardId.metrics.$metricId.tsx +++ b/apps/web-tss/src/routes/app/_app/_asset/dashboards.$dashboardId.metrics.$metricId.tsx @@ -1,14 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/react-router'; -import { z } from 'zod'; -import { Route as MetricRoute } from './metrics.$metricId'; +import { createFileRoute } from '@tanstack/react-router'; +import * as metricServerContext from '@/context/BusterAssets/metric-server/metricIndexServerAssetContext'; export const Route = createFileRoute('/app/_app/_asset/dashboards/$dashboardId/metrics/$metricId')({ - staticData: { - assetType: 'metric', - }, - component: RouteComponent, + ...metricServerContext, }); - -function RouteComponent() { - return
Hello "/app/_app/dashboards/$dashboardId/metrics/$metricId"!
; -} diff --git a/apps/web-tss/src/routes/app/_app/_asset/metrics.$metricId.tsx b/apps/web-tss/src/routes/app/_app/_asset/metrics.$metricId.tsx index 01e15cc12..c5811aae8 100644 --- a/apps/web-tss/src/routes/app/_app/_asset/metrics.$metricId.tsx +++ b/apps/web-tss/src/routes/app/_app/_asset/metrics.$metricId.tsx @@ -3,4 +3,5 @@ import * as metricServerContext from '@/context/BusterAssets/metric-server/metri export const Route = createFileRoute('/app/_app/_asset/metrics/$metricId')({ ...metricServerContext, + component: Outlet, }); diff --git a/apps/web-tss/src/routes/auth.logout.tsx b/apps/web-tss/src/routes/auth.logout.tsx index 1a08698e7..e599aed8e 100644 --- a/apps/web-tss/src/routes/auth.logout.tsx +++ b/apps/web-tss/src/routes/auth.logout.tsx @@ -13,6 +13,6 @@ export const Route = createFileRoute('/auth/logout')({ preload: false, loader: async () => { await signOut(); - redirect({ to: '/auth/login' }); + throw redirect({ to: '/auth/login' }); }, });