mirror of https://github.com/buster-so/buster.git
chat history link updates
This commit is contained in:
parent
07e7d05867
commit
292ac4ff16
|
@ -27,4 +27,6 @@ export interface BusterChatListItem {
|
||||||
created_by_name: string;
|
created_by_name: string;
|
||||||
created_by_avatar: string | null;
|
created_by_avatar: string | null;
|
||||||
last_edited: string;
|
last_edited: string;
|
||||||
|
latest_file_id: string | null;
|
||||||
|
latest_file_type: 'metric' | 'dashboard';
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,8 @@ export const SidebarPrimary = React.memo(() => {
|
||||||
);
|
);
|
||||||
const FooterMemoized = useMemo(() => <SidebarUserFooter />, []);
|
const FooterMemoized = useMemo(() => <SidebarUserFooter />, []);
|
||||||
|
|
||||||
|
console.log(currentRoute);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Sidebar
|
<Sidebar
|
||||||
|
|
|
@ -35,15 +35,38 @@ export const ChatItemsContainer: React.FC<{
|
||||||
|
|
||||||
const logsRecord = useCreateListByDate({ data: chats });
|
const logsRecord = useCreateListByDate({ data: chats });
|
||||||
|
|
||||||
|
const getLink = useMemoizedFn((chat: BusterChatListItem) => {
|
||||||
|
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(() => {
|
const chatsByDate: BusterListRow[] = useMemo(() => {
|
||||||
return Object.entries(logsRecord).flatMap(([key, chats]) => {
|
return Object.entries(logsRecord).flatMap(([key, chats]) => {
|
||||||
const records = chats.map((chat) => ({
|
const records = chats.map((chat) => ({
|
||||||
id: chat.id,
|
id: chat.id,
|
||||||
data: chat,
|
data: chat,
|
||||||
link: createBusterRoute({
|
link: getLink(chat)
|
||||||
route: BusterRoutes.APP_CHAT_ID,
|
|
||||||
chatId: chat.id
|
|
||||||
})
|
|
||||||
}));
|
}));
|
||||||
const hasRecords = records.length > 0;
|
const hasRecords = records.length > 0;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ export const MetricTitle: React.FC<{
|
||||||
const { attributes, listeners } = useContext(SortableItemContext);
|
const { attributes, listeners } = useContext(SortableItemContext);
|
||||||
|
|
||||||
useMount(() => {
|
useMount(() => {
|
||||||
console.log('I want to test if we really need this here?');
|
|
||||||
if (metricLink) router.prefetch(metricLink);
|
if (metricLink) router.prefetch(metricLink);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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_PERMISSIONS_OVERVIEW]: BusterRoutes.APP_DATASETS,
|
||||||
[BusterRoutes.APP_DATASETS_ID_OVERVIEW]: BusterRoutes.APP_DATASETS,
|
[BusterRoutes.APP_DATASETS_ID_OVERVIEW]: BusterRoutes.APP_DATASETS,
|
||||||
[BusterRoutes.APP_DATASETS_ID_EDITOR]: 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]) {
|
if (route && paramRoutesToParent[route as string]) {
|
||||||
|
|
Loading…
Reference in New Issue