diff --git a/web/src/api/asset_interfaces/chat/chatInterfaces.ts b/web/src/api/asset_interfaces/chat/chatInterfaces.ts index 85c5e9557..c61143608 100644 --- a/web/src/api/asset_interfaces/chat/chatInterfaces.ts +++ b/web/src/api/asset_interfaces/chat/chatInterfaces.ts @@ -27,4 +27,6 @@ export interface BusterChatListItem { created_by_name: string; created_by_avatar: string | null; last_edited: string; + latest_file_id: string | null; + latest_file_type: 'metric' | 'dashboard'; } diff --git a/web/src/components/features/sidebars/SidebarPrimary.tsx b/web/src/components/features/sidebars/SidebarPrimary.tsx index 704bb461d..02cd7c092 100644 --- a/web/src/components/features/sidebars/SidebarPrimary.tsx +++ b/web/src/components/features/sidebars/SidebarPrimary.tsx @@ -160,6 +160,8 @@ export const SidebarPrimary = React.memo(() => { ); const FooterMemoized = useMemo(() => , []); + console.log(currentRoute); + return ( <> { + if (chat.latest_file_id) { + switch (chat.latest_file_type) { + case 'metric': + return createBusterRoute({ + route: BusterRoutes.APP_CHAT_ID_METRIC_ID, + chatId: chat.id, + metricId: chat.latest_file_id + }); + case 'dashboard': + return createBusterRoute({ + route: BusterRoutes.APP_CHAT_ID_DASHBOARD_ID, + chatId: chat.id, + dashboardId: chat.latest_file_id + }); + default: + const _exhaustiveCheck: never = chat.latest_file_type; + } + } + + return createBusterRoute({ + route: BusterRoutes.APP_CHAT_ID, + chatId: chat.id + }); + }); + const chatsByDate: BusterListRow[] = useMemo(() => { return Object.entries(logsRecord).flatMap(([key, chats]) => { const records = chats.map((chat) => ({ id: chat.id, data: chat, - link: createBusterRoute({ - route: BusterRoutes.APP_CHAT_ID, - chatId: chat.id - }) + link: getLink(chat) })); const hasRecords = records.length > 0; diff --git a/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/MetricTitle.tsx b/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/MetricTitle.tsx index 8ee132a35..4ef6fb797 100644 --- a/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/MetricTitle.tsx +++ b/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/MetricTitle.tsx @@ -35,7 +35,6 @@ export const MetricTitle: React.FC<{ const { attributes, listeners } = useContext(SortableItemContext); useMount(() => { - console.log('I want to test if we really need this here?'); if (metricLink) router.prefetch(metricLink); }); diff --git a/web/src/routes/helpers.tsx b/web/src/routes/helpers.tsx index e2633bc97..f1045bc7d 100644 --- a/web/src/routes/helpers.tsx +++ b/web/src/routes/helpers.tsx @@ -20,7 +20,11 @@ export const pathNameToRoute = (pathName: string, params: any): BusterRoutes => [BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: BusterRoutes.APP_DATASETS, [BusterRoutes.APP_DATASETS_ID_OVERVIEW]: BusterRoutes.APP_DATASETS, [BusterRoutes.APP_DATASETS_ID_EDITOR]: BusterRoutes.APP_DATASETS, - [BusterRoutes.APP_TERMS_ID]: BusterRoutes.APP_TERMS + [BusterRoutes.APP_TERMS_ID]: BusterRoutes.APP_TERMS, + [BusterRoutes.APP_CHAT_ID_METRIC_ID_CHART]: BusterRoutes.APP_CHAT, + [BusterRoutes.APP_CHAT_ID_METRIC_ID_FILE]: BusterRoutes.APP_CHAT, + [BusterRoutes.APP_CHAT_ID_METRIC_ID_RESULTS]: BusterRoutes.APP_CHAT, + [BusterRoutes.APP_CHAT_ID_DASHBOARD_ID_FILE]: BusterRoutes.APP_CHAT }; if (route && paramRoutesToParent[route as string]) {