mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-12 13:38:51 +01:00
* fix: focus returns to manage files button on modal close * refactor: remove atoms and re-use components instead * refactor: FilesView to MyFilesModal * chore: import styling * chore: delete file that was meant to be renamed * feat: add trigger ref for settings button as well
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { FileSources, FileContext } from 'librechat-data-provider';
|
|
import type { TFile } from 'librechat-data-provider';
|
|
import { OGDialog, OGDialogContent, OGDialogHeader, OGDialogTitle } from '@librechat/client';
|
|
import { useGetFiles } from '~/data-provider';
|
|
import { DataTable, columns } from './Table';
|
|
import { useLocalize } from '~/hooks';
|
|
|
|
export function MyFilesModal({
|
|
open,
|
|
onOpenChange,
|
|
triggerRef,
|
|
}: {
|
|
open: boolean;
|
|
onOpenChange: (open: boolean) => void;
|
|
triggerRef?: React.RefObject<HTMLButtonElement | HTMLDivElement | null>;
|
|
}) {
|
|
const localize = useLocalize();
|
|
|
|
const { data: files = [] } = useGetFiles<TFile[]>({
|
|
select: (files) =>
|
|
files.map((file) => {
|
|
file.context = file.context ?? FileContext.unknown;
|
|
file.filterSource = file.source === FileSources.firebase ? FileSources.local : file.source;
|
|
return file;
|
|
}),
|
|
});
|
|
|
|
return (
|
|
<OGDialog open={open} onOpenChange={onOpenChange} triggerRef={triggerRef}>
|
|
<OGDialogContent
|
|
title={localize('com_nav_my_files')}
|
|
className="w-11/12 bg-background text-text-primary shadow-2xl"
|
|
>
|
|
<OGDialogHeader>
|
|
<OGDialogTitle>{localize('com_nav_my_files')}</OGDialogTitle>
|
|
</OGDialogHeader>
|
|
<DataTable columns={columns} data={files} />
|
|
</OGDialogContent>
|
|
</OGDialog>
|
|
);
|
|
}
|