Files
codecraft/web/src/components/ProjectPermissions.tsx
T
Richard ZinkandClaude Sonnet 5.5 6b1a1742b2 Web UI on Ant Design, scrollable factory columns, fix empty page after deleting the open chat
Buttons, fields, drop-downs, check boxes, tabs, dialogs and notices are Ant Design components;
their tokens come from the theme variables (web/src/ui). Every factory board column has its own
vertical scrollbar. ChatView rendered fewer hooks once its chat was deleted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 12:32:57 +01:00

56 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { Button } from "antd";
import { Modal } from "../ui/Modal";
import { useEffect, useState } from "react";
import { api, get } from "../api";
import { useT } from "../i18n";
import { toast } from "../dialogs";
import { Icon } from "./Icon";
/** "bash:git status" → "git status"; tool names stay. */
const label = (key: string) => (key.startsWith("bash:") ? `$ ${key.slice(5)}` : key);
/** What the user allowed "for this project" (all chats of the folder) – with a way to revoke it. */
export function ProjectPermissions({ sessionId, cwd, onClose }: { sessionId: string; cwd: string; onClose: () => void }) {
const t = useT();
const [keys, setKeys] = useState<string[]>();
useEffect(() => {
get<string[]>(`/sessions/${sessionId}/approvals`).then(setKeys, (e) => (toast(e.message), setKeys([])));
}, [sessionId]);
const revoke = async (key: string) => {
try {
await api(`/sessions/${sessionId}/approvals`, { method: "DELETE", json: { key } });
setKeys((k) => k?.filter((x) => x !== key));
} catch (e: any) {
toast(e.message);
}
};
return (
<Modal onClose={onClose} role="dialog" aria-label={t("permProject.title")}>
<h3>
<Icon name="lock" /> {t("permProject.title")}
</h3>
<p style={{ fontSize: 13, color: "var(--fg3)", marginBottom: 4 }}>{t("permProject.intro")}</p>
<div className="path mono" style={{ marginBottom: 8 }}>{cwd}</div>
{keys === undefined ? (
<div className="empty">…</div>
) : keys.length === 0 ? (
<p style={{ fontSize: 13 }}>{t("permProject.empty")}</p>
) : (
<ul className="rewind-files">
{keys.map((k) => (
<li key={k} className="row" style={{ justifyContent: "space-between" }}>
<code>{label(k)}</code>
<Button danger size="small" onClick={() => void revoke(k)}>
{t("permProject.revoke")}
</Button>
</li>
))}
</ul>
)}
<div className="row" style={{ justifyContent: "flex-end", marginTop: 10 }}>
<Button onClick={onClose}>{t("common.close")}</Button>
</div>
</Modal>
);
}