mirror of https://github.com/buster-so/buster.git
update imports
This commit is contained in:
parent
7cf9789680
commit
430ae8d35a
|
@ -149,27 +149,22 @@ const useShareMenuSelectMenu = ({ metricId }: { metricId: string }): IDropdownIt
|
|||
};
|
||||
|
||||
const useEditWithAI = ({ metricId }: { metricId: string }): IDropdownItem => {
|
||||
const { mutateAsync: startChatFromAsset, isPending } = useStartChatFromAsset();
|
||||
const navigate = useNavigate();
|
||||
const { onCreateFileClick, loading } = useStartChatFromAsset({
|
||||
assetId: metricId,
|
||||
assetType: 'metric',
|
||||
});
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
label: 'Edit with AI',
|
||||
value: 'edit-with-ai',
|
||||
icon: <PenSparkle />,
|
||||
loading: isPending,
|
||||
loading: loading,
|
||||
onClick: async () => {
|
||||
const result = await startChatFromAsset({ asset_id: metricId, asset_type: 'metric' });
|
||||
navigate({
|
||||
to: '/app/chats/$chatId/metrics/$metricId',
|
||||
params: {
|
||||
metricId,
|
||||
chatId: result.id,
|
||||
},
|
||||
});
|
||||
await onCreateFileClick();
|
||||
},
|
||||
}),
|
||||
[metricId, startChatFromAsset, isPending]
|
||||
[metricId, onCreateFileClick, loading]
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import type { GetReportResponse } from '@buster/server-shared/reports';
|
||||
import type { VerificationStatus } from '@buster/server-shared/share';
|
||||
import { useNavigate } from '@tanstack/react-router';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import {
|
||||
useAddReportToCollection,
|
||||
|
@ -44,7 +43,6 @@ import { canEdit, getIsEffectiveOwner } from '@/lib/share';
|
|||
export const ReportThreeDotMenu = React.memo(
|
||||
({
|
||||
reportId,
|
||||
reportVersionNumber,
|
||||
isViewingOldVersion,
|
||||
}: {
|
||||
reportId: string;
|
||||
|
|
|
@ -112,7 +112,7 @@ const MemoizedAddMetricModal = React.memo(
|
|||
return;
|
||||
}
|
||||
|
||||
plugin.api.metric.updateMetric(selectedMetricId, { at });
|
||||
plugin.api.metric.updateMetric(selectedMetricId, undefined, { at });
|
||||
|
||||
// Close the modal after successful selection
|
||||
onCloseAddMetricModal();
|
||||
|
|
|
@ -3,8 +3,13 @@ import type React from 'react';
|
|||
import { useMemo } from 'react';
|
||||
import { useDeleteChat, useDuplicateChat, useGetChat } from '@/api/buster_rest/chats';
|
||||
import { useFavoriteStar } from '@/components/features/favorites';
|
||||
import { createDropdownItems, Dropdown, type IDropdownItems } from '@/components/ui/dropdown';
|
||||
import { DuplicatePlus, Pencil, Star, Trash } from '@/components/ui/icons';
|
||||
import {
|
||||
createDropdownItem,
|
||||
createDropdownItems,
|
||||
Dropdown,
|
||||
type IDropdownItems,
|
||||
} from '@/components/ui/dropdown';
|
||||
import { ArrowRight, DuplicatePlus, Pencil, Star, Trash } from '@/components/ui/icons';
|
||||
import { Star as StarFilled } from '@/components/ui/icons/NucleoIconFilled';
|
||||
import { useBusterNotifications } from '@/context/BusterNotifications';
|
||||
import { useGetChatId } from '@/context/Chats/useGetChatId';
|
||||
|
@ -32,40 +37,9 @@ export const ChatContainerHeaderDropdown: React.FC<{
|
|||
});
|
||||
|
||||
const menuItem: IDropdownItems = useMemo(() => {
|
||||
return createDropdownItems([
|
||||
return [
|
||||
{
|
||||
label: 'Delete chat',
|
||||
value: 'delete',
|
||||
icon: <Trash />,
|
||||
loading: isDeleting,
|
||||
onClick: () =>
|
||||
chatId &&
|
||||
deleteChat(
|
||||
{ data: [chatId] },
|
||||
{
|
||||
onSuccess: () => {
|
||||
navigate({ to: '/app/chats' });
|
||||
openSuccessMessage('Chat deleted');
|
||||
},
|
||||
}
|
||||
),
|
||||
},
|
||||
{
|
||||
label: 'Duplicate chat',
|
||||
value: 'duplicate',
|
||||
icon: <DuplicatePlus />,
|
||||
loading: isDuplicating,
|
||||
onClick: async () => {
|
||||
if (chatId) {
|
||||
const res = await duplicateChat({ id: chatId });
|
||||
await timeout(100);
|
||||
await navigate({ to: '/app/chats/$chatId', params: { chatId: res.id } });
|
||||
openSuccessMessage('Chat duplicated');
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Edit chat title',
|
||||
label: 'Rename',
|
||||
value: 'edit-chat-title',
|
||||
icon: <Pencil />,
|
||||
onClick: async () => {
|
||||
|
@ -83,7 +57,50 @@ export const ChatContainerHeaderDropdown: React.FC<{
|
|||
icon: isFavorited ? <StarFilled /> : <Star />,
|
||||
onClick: () => onFavoriteClick(),
|
||||
},
|
||||
]);
|
||||
createDropdownItem({
|
||||
label: 'Open in new tab',
|
||||
value: 'open-in-new-tab',
|
||||
icon: <ArrowRight />,
|
||||
link: {
|
||||
to: '/app/chats/$chatId',
|
||||
params: { chatId: chatId || '' },
|
||||
},
|
||||
}),
|
||||
{
|
||||
type: 'divider',
|
||||
},
|
||||
{
|
||||
label: 'Duplicate chat',
|
||||
value: 'duplicate',
|
||||
icon: <DuplicatePlus />,
|
||||
loading: isDuplicating,
|
||||
onClick: async () => {
|
||||
if (chatId) {
|
||||
const res = await duplicateChat({ id: chatId });
|
||||
await timeout(100);
|
||||
await navigate({ to: '/app/chats/$chatId', params: { chatId: res.id } });
|
||||
openSuccessMessage('Chat duplicated');
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Delete chat',
|
||||
value: 'delete',
|
||||
icon: <Trash />,
|
||||
loading: isDeleting,
|
||||
onClick: () =>
|
||||
chatId &&
|
||||
deleteChat(
|
||||
{ data: [chatId] },
|
||||
{
|
||||
onSuccess: () => {
|
||||
navigate({ to: '/app/chats' });
|
||||
openSuccessMessage('Chat deleted');
|
||||
},
|
||||
}
|
||||
),
|
||||
},
|
||||
];
|
||||
}, [
|
||||
chatId,
|
||||
isDeleting,
|
||||
|
|
|
@ -15,7 +15,9 @@ export const Route = createFileRoute('/app')({
|
|||
context: ({ context }) => ({ ...context, getAppLayout }),
|
||||
ssr: true,
|
||||
beforeLoad: async () => {
|
||||
console.log('beforeLoad app route');
|
||||
const { isExpired, accessToken = '' } = await getSupabaseSession();
|
||||
console.log('beforeLoad app route done');
|
||||
|
||||
if (isExpired || !accessToken) {
|
||||
console.error('Access token is expired or not found');
|
||||
|
@ -29,6 +31,7 @@ export const Route = createFileRoute('/app')({
|
|||
loader: async ({ context }) => {
|
||||
const { queryClient, accessToken } = context;
|
||||
try {
|
||||
console.log('loading app route');
|
||||
const [initialLayout, user] = await Promise.all([
|
||||
getAppLayout({ id: PRIMARY_APP_LAYOUT_ID }),
|
||||
getSupabaseUser(),
|
||||
|
@ -37,6 +40,7 @@ export const Route = createFileRoute('/app')({
|
|||
prefetchListDatasources(queryClient),
|
||||
prefetchGetDatasets(queryClient),
|
||||
]);
|
||||
console.log('app route loaded', user);
|
||||
|
||||
if (!user) {
|
||||
throw redirect({ to: '/auth/login', replace: true });
|
||||
|
|
|
@ -2,6 +2,7 @@ import { createFileRoute, redirect } from '@tanstack/react-router';
|
|||
|
||||
export const Route = createFileRoute('/')({
|
||||
beforeLoad: async () => {
|
||||
console.log('redirecting to /app/home');
|
||||
throw redirect({ to: '/app/home', replace: true });
|
||||
},
|
||||
component: () => null,
|
||||
|
|
Loading…
Reference in New Issue