Files
nanobot/webui/src/components/RenameChatDialog.tsx
T
Xubin RenandGitHub 3a420136bb feat(webui): add project workspaces and access controls (#4007)
* feat(webui): add project workspaces and access controls

* feat(webui): add project workspaces and access controls

* refactor(tools): centralize workspace access resolution

* refactor(webui): remove unused workspace host state

* fix(webui): hide estimated file edit label

* fix(webui): clarify file edit deletion feedback

* fix(webui): label deleted file activity

* fix(webui): flatten file edit activity rows

* fix(core): remove path-only patch deletion

* fix(core): keep apply patch non-destructive

* refactor(webui): trim workspace host plumbing

* fix(tools): register exec with tools config
2026-05-29 03:42:53 +08:00

82 lines
2.1 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;
dialogTitle?: string;
description?: string;
placeholder?: string;
onCancel: () => void;
onConfirm: (title: string) => void;
}
export function RenameChatDialog({
open,
title,
dialogTitle,
description,
placeholder,
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>{dialogTitle ?? t("chat.renameTitle")}</DialogTitle>
<DialogDescription>
{description ?? t("chat.renameDescription")}
</DialogDescription>
</DialogHeader>
<Input
value={value}
onChange={(event) => setValue(event.target.value)}
placeholder={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>
);
}