mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-19 14:33:38 +00:00
* feat: Edit Projects in a Dialog and Match the Landing Background * fix: No Fill on the Edit Project Description Field * feat: Choose Project Files in the Your Files Dialog * fix: Filtered Empty State and a Page Retry in the Project File Picker * test: Scenarios for Project Dialogs and the File Picker * fix: Retry the Failed Page or the Listed Files, Whichever Failed * fix: Forget a Picker Page Failure Once the Query Recovers * fix: Show the Picker Loading While a Further Page Loads * test: Follow the Picker's Your Files Markup and Its Focus Return * fix: Apply a Picker Page Result Only to the Query That Requested It * fix: Hold the Edit Project Dialog Through a Save and Keep Page Failures per Search * test: Match the Visible Rename Failure Toast * fix: Refuse to Dismiss Edit Project From the Moment a Save Is Submitted * fix: Announce the File Grid Result Count to Screen Readers
68 lines
2.1 KiB
TypeScript
68 lines
2.1 KiB
TypeScript
import { useRef } from 'react';
|
|
import { OGDialog, OGDialogTitle, OGDialogHeader, OGDialogContent } from '@librechat/client';
|
|
import type { TChatProject } from 'librechat-data-provider';
|
|
import type { ComponentProps } from 'react';
|
|
import { useUpdateProjectMutation } from '~/data-provider';
|
|
import ProjectEditor from './ProjectEditor';
|
|
import { useLocalize } from '~/hooks';
|
|
|
|
type ProjectEditDialogProps = {
|
|
open: boolean;
|
|
onOpenChange: (open: boolean) => void;
|
|
project: TChatProject;
|
|
triggerRef?: ComponentProps<typeof OGDialog>['triggerRef'];
|
|
};
|
|
|
|
export default function ProjectEditDialog({
|
|
open,
|
|
onOpenChange,
|
|
project,
|
|
triggerRef,
|
|
}: ProjectEditDialogProps) {
|
|
const localize = useLocalize();
|
|
/** Owned here, so a save in flight settles with its toast; the dialog stays open meanwhile. */
|
|
const updateProject = useUpdateProjectMutation();
|
|
const savingRef = useRef(false);
|
|
/** Read at event time: the submit marks the ref before the loading state renders. */
|
|
const isBusy = () => savingRef.current || updateProject.isLoading;
|
|
return (
|
|
<OGDialog
|
|
open={open}
|
|
onOpenChange={(next) => {
|
|
if (next || !isBusy()) {
|
|
onOpenChange(next);
|
|
}
|
|
}}
|
|
triggerRef={triggerRef}
|
|
>
|
|
<OGDialogContent
|
|
className="w-11/12 max-w-md"
|
|
showCloseButton={false}
|
|
onEscapeKeyDown={(event) => {
|
|
if (isBusy()) {
|
|
event.preventDefault();
|
|
}
|
|
}}
|
|
onInteractOutside={(event) => {
|
|
if (isBusy()) {
|
|
event.preventDefault();
|
|
}
|
|
}}
|
|
>
|
|
<OGDialogHeader>
|
|
<OGDialogTitle>{localize('com_ui_edit_project')}</OGDialogTitle>
|
|
</OGDialogHeader>
|
|
{/* Mounted per opening so the form starts from the saved project. */}
|
|
{open ? (
|
|
<ProjectEditor
|
|
project={project}
|
|
layout="dialog"
|
|
updateProject={updateProject}
|
|
savingRef={savingRef}
|
|
onDone={() => onOpenChange(false)}
|
|
/>
|
|
) : null}
|
|
</OGDialogContent>
|
|
</OGDialog>
|
|
);
|
|
}
|