43 lines
2.4 KiB
TypeScript
43 lines
2.4 KiB
TypeScript
import { ShieldQuestion } from "lucide-react";
|
|
import type { ApprovalView } from "@peppa/core";
|
|
import type { Translator } from "@peppa/shared/i18n";
|
|
import { decideApprovalAction } from "@/app/(app)/actions";
|
|
import { Hidden } from "@/components/cards";
|
|
import { ago } from "@/components/common";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Card } from "@/components/ui/card";
|
|
|
|
/**
|
|
* PEP-235: «Ждут подтверждения» on «Подключения» — agents' calls that run only after the owner's
|
|
* «Разрешить один раз». The card shows who, where and what (values that look like keys hidden).
|
|
*/
|
|
export function ApprovalList({ list, t }: { list: ApprovalView[]; t: Translator }) {
|
|
return (
|
|
<ul className="m-0 flex list-none flex-col gap-2 p-0">
|
|
{list.map((a) => (
|
|
<li key={a.id} id={`approval-${a.id}`}>
|
|
<Card className="flex flex-wrap items-center gap-x-3 gap-y-1 p-3 text-sm" data-approval={a.id}>
|
|
<ShieldQuestion className="size-4 text-primary" />
|
|
<span className="font-medium">{a.connectionName}</span>
|
|
<span className="text-muted-foreground">
|
|
· {a.agentName ? t("агент {name}", { name: a.agentName }) : t("агент")} · {a.taskKey ? `${a.taskKey}${a.taskTitle ? ` «${a.taskTitle}»` : ""}` : a.projectKey}
|
|
</span>
|
|
<span className="ml-auto text-xs text-muted-foreground">{ago(a.createdAt, t)}</span>
|
|
<pre className="m-0 basis-full overflow-x-auto whitespace-pre-wrap rounded-md bg-muted p-2 font-mono text-xs">{a.summary}</pre>
|
|
<span className="basis-full text-xs text-muted-foreground">{t("До вашего ответа действие не выполняется. Без ответа запрос отменится сам.")}</span>
|
|
<form action={decideApprovalAction} className="flex basis-full flex-wrap items-center gap-2 pt-1">
|
|
<Hidden fields={{ back: "/connections#approvals", approvalId: a.id }} />
|
|
<Button size="sm" name="decision" value="allow" data-approval-decision="allow">
|
|
{t("Разрешить один раз")}
|
|
</Button>
|
|
<Button size="sm" variant="secondary" name="decision" value="deny" data-approval-decision="deny">
|
|
{t("Отклонить")}
|
|
</Button>
|
|
</form>
|
|
</Card>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
);
|
|
}
|