mirror of https://github.com/buster-so/buster.git
update some layout stuff
This commit is contained in:
parent
4974176187
commit
e1ccaec8e8
|
@ -1,7 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { FileIndeterminateLoader } from '@/components/features/FileIndeterminateLoader';
|
||||
import { StatusCard } from '@/components/ui/card/StatusCard';
|
||||
import { ReasoningController } from '@/controllers/ReasoningController';
|
||||
import { useChatIndividualContextSelector } from '@/layouts/ChatLayout/ChatContext';
|
||||
|
||||
|
@ -15,12 +14,8 @@ export default function Page(params: { params: { chatId: string } }) {
|
|||
|
||||
return (
|
||||
<>
|
||||
<FileIndeterminateLoader />
|
||||
<div className="p-5">
|
||||
<StatusCard
|
||||
title="Error"
|
||||
message="If you are seeing this, tell Nate and screenshot this whole page including the URL and logs..."
|
||||
/>
|
||||
<div className="animate-in fade-in hidden delay-300 duration-500">
|
||||
<FileIndeterminateLoader />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -13,7 +13,7 @@ const inputTextAreaButtonVariants = cva(
|
|||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
'has-[textarea:hover]:border-foreground shadow has-[textarea:focus]:border-foreground has-[textarea:disabled]:border-border'
|
||||
'has-[textarea:hover]:border-foreground shadow bg-background has-[textarea:focus]:border-foreground has-[textarea:disabled]:border-border'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,9 +44,7 @@ export const useChatLayout = ({ appSplitterRef }: UseChatSplitterProps) => {
|
|||
renderViewLayoutKey
|
||||
} = useSelectedFileAndLayout({ animateOpenSplitter });
|
||||
|
||||
const { onCollapseFileClick } = useLayoutCollapse({
|
||||
animateOpenSplitter
|
||||
});
|
||||
const onCollapseFileClick = useLayoutCollapse({ onSetSelectedFile });
|
||||
|
||||
const fileLayoutContext = useChatFileLayout({
|
||||
selectedFileId: selectedFile?.id,
|
||||
|
|
|
@ -1,30 +1,16 @@
|
|||
'use client';
|
||||
|
||||
import { useMemoizedFn } from '@/hooks';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { SelectedFileParams } from './useSelectedFileAndLayout';
|
||||
import { ChatLayoutView } from '../interfaces';
|
||||
import { useSelectedFileAndLayout } from './useSelectedFileAndLayout';
|
||||
|
||||
export const useLayoutCollapse = ({
|
||||
animateOpenSplitter
|
||||
onSetSelectedFile
|
||||
}: {
|
||||
animateOpenSplitter: (side: 'left' | 'right' | 'both') => void;
|
||||
onSetSelectedFile: ReturnType<typeof useSelectedFileAndLayout>['onSetSelectedFile'];
|
||||
}) => {
|
||||
const onCollapseFileClick = useMemoizedFn((close?: boolean) => {
|
||||
// if (selectedFile && selectedFile.type === 'reasoning') {
|
||||
// animateOpenSplitter(!isCloseAction ? 'both' : 'left');
|
||||
// } else if (isFileLayout) {
|
||||
// // For file layout, toggle between 'both' and 'right'
|
||||
// animateOpenSplitter(!isCloseAction && selectedFile ? 'both' : 'right');
|
||||
// } else {
|
||||
// // For other layouts, toggle between 'right' and 'both'
|
||||
// animateOpenSplitter(isCloseAction ? 'left' : 'both');
|
||||
// }
|
||||
|
||||
animateOpenSplitter('left');
|
||||
onSetSelectedFile(null);
|
||||
});
|
||||
|
||||
return {
|
||||
onCollapseFileClick
|
||||
};
|
||||
return onCollapseFileClick;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { SelectedFile } from '../../interfaces';
|
||||
import type { ChatURLParsed } from './parsePathnameSegments';
|
||||
|
||||
export const initializeSelectedFile = (params: ChatURLParsed): SelectedFile | undefined => {
|
||||
export const initializeSelectedFile = (params: ChatURLParsed): SelectedFile | null => {
|
||||
const { metricId, collectionId, datasetId, dashboardId, chatId, messageId } = params;
|
||||
|
||||
if (metricId) {
|
||||
|
@ -25,5 +25,5 @@ export const initializeSelectedFile = (params: ChatURLParsed): SelectedFile | un
|
|||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return null;
|
||||
};
|
||||
|
|
|
@ -5,11 +5,7 @@ import type { ChatLayoutView, SelectedFile } from '../../interfaces';
|
|||
import { usePathname } from 'next/navigation';
|
||||
import { parsePathnameSegments } from './parsePathnameSegments';
|
||||
import { useMemoizedFn } from '@/hooks';
|
||||
import {
|
||||
createChatAssetRoute,
|
||||
createChatRoute,
|
||||
createFileRoute
|
||||
} from '../../ChatLayoutContext/helpers';
|
||||
import { createChatAssetRoute, createChatRoute } from '../../ChatLayoutContext/helpers';
|
||||
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
|
||||
import { initializeSelectedFile } from './initializeSelectedFile';
|
||||
import { BusterRoutes, createBusterRoute } from '@/routes';
|
||||
|
@ -26,7 +22,7 @@ export const useSelectedFileAndLayout = ({
|
|||
|
||||
const { chatId } = params;
|
||||
|
||||
const [selectedFile, setSelectedFile] = useState<SelectedFile | undefined>(() =>
|
||||
const [selectedFile, setSelectedFile] = useState<SelectedFile | null>(() =>
|
||||
initializeSelectedFile(params)
|
||||
);
|
||||
|
||||
|
@ -51,6 +47,7 @@ export const useSelectedFileAndLayout = ({
|
|||
if (!file || !fileType || !fileId || !chatId) {
|
||||
if (chatId) {
|
||||
await onChangePage(createChatRoute(chatId));
|
||||
setSelectedFile(null);
|
||||
animateOpenSplitter('left');
|
||||
} else {
|
||||
await onChangePage(createBusterRoute({ route: BusterRoutes.APP_HOME }));
|
||||
|
@ -62,7 +59,7 @@ export const useSelectedFileAndLayout = ({
|
|||
? createChatRoute(chatId)
|
||||
: createChatAssetRoute({ chatId, assetId: fileId, type: fileType });
|
||||
setRenderViewLayoutKey('both');
|
||||
setSelectedFile(isSameAsCurrentFile ? undefined : file);
|
||||
setSelectedFile(isSameAsCurrentFile ? null : file);
|
||||
await onChangePage(route);
|
||||
startTransition(() => {
|
||||
onChangePage(route); //this is hack for now...
|
||||
|
|
Loading…
Reference in New Issue