mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-26 11:32:25 +00:00
* feat(settings): expand settings api payload * feat(webui): build app-style settings center * feat(webui): add centered chat search dialog * fix(webui): shorten chat search label * fix(webui): center dialog entrance animation * fix(webui): simplify chat search results * fix(webui): tighten mobile settings navigation * feat(webui): persist sidebar state * feat(webui): add sidebar organization controls * refactor(webui): organize backend helpers * refactor(webui): remove utils compatibility shims * refactor(session): move shared webui helpers out of webui package * feat(webui): add image generation settings * style(webui): refine settings overview layout * fix(webui): localize settings zh-CN copy * style(webui): add settings status indicators * feat(webui): show sidebar run indicators * fix(webui): persist sidebar run indicators * fix(webui): highlight settings pending status * fix(webui): align settings test with provider update * fix(utils): preserve legacy webui helper imports
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import { useEffect, useState } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from "@/components/ui/dialog";
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
interface RenameChatDialogProps {
|
|
open: boolean;
|
|
title: string;
|
|
onCancel: () => void;
|
|
onConfirm: (title: string) => void;
|
|
}
|
|
|
|
export function RenameChatDialog({
|
|
open,
|
|
title,
|
|
onCancel,
|
|
onConfirm,
|
|
}: RenameChatDialogProps) {
|
|
const { t } = useTranslation();
|
|
const [value, setValue] = useState(title);
|
|
|
|
useEffect(() => {
|
|
if (open) setValue(title);
|
|
}, [open, title]);
|
|
|
|
const trimmed = value.trim();
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={(next) => {
|
|
if (!next) onCancel();
|
|
}}>
|
|
<DialogContent className="max-w-sm rounded-[22px] border-border/70 bg-popover p-5 shadow-2xl">
|
|
<form
|
|
className="grid gap-4"
|
|
onSubmit={(event) => {
|
|
event.preventDefault();
|
|
if (!trimmed) return;
|
|
onConfirm(trimmed);
|
|
}}
|
|
>
|
|
<DialogHeader className="text-left">
|
|
<DialogTitle>{t("chat.renameTitle")}</DialogTitle>
|
|
<DialogDescription>
|
|
{t("chat.renameDescription")}
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<Input
|
|
value={value}
|
|
onChange={(event) => setValue(event.target.value)}
|
|
placeholder={t("chat.renamePlaceholder")}
|
|
autoFocus
|
|
maxLength={160}
|
|
/>
|
|
<DialogFooter className="gap-2 sm:space-x-0">
|
|
<Button type="button" variant="outline" onClick={onCancel}>
|
|
{t("deleteConfirm.cancel")}
|
|
</Button>
|
|
<Button type="submit" disabled={!trimmed}>
|
|
{t("chat.renameSave")}
|
|
</Button>
|
|
</DialogFooter>
|
|
</form>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|