fix(settings): name the act on the token revoke confirmation

The confirm button in the API-token and MCP-token revoke dialogs read
"Revoked", the status word the admin overview shows for a token that is
already gone, and the phone layout's trigger carried the dialog title,
question mark included. Both now say "Revoke token".
This commit is contained in:
Marc-André Bombeck committed 2026-10-21 12:02:20 +02:00
1 parent 9a8b95cfd0
commit 2e653b7aa0
3 files changed
+57 -5

No files matched your search

@@ -0,0 +1,52 @@
/**
* The token revoke confirmation names the act.
*
* Both token lists (API tokens and MCP connections) labelled the dialog's
* confirm button with `settings.tokenRevoked` — "Revoked", the status word the
* admin overview shows for a token that is already gone — so the button that
* performs the revoke read as if it had happened. The phone layout's trigger
* carried the dialog title instead, question mark included.
*
* Read from the source because the dialog content only mounts while open, and
* an SSR render never sees it. What is pinned: every `AlertDialogAction` that
* calls `handleRevoke` is labelled with the action key, and no trigger or
* action on these two surfaces uses the status word.
*/
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
const FILES = [
"src/components/settings/api-section.tsx",
"src/components/settings/mcp-section.tsx",
];
function read(rel: string): string {
return readFileSync(join(process.cwd(), rel), "utf8");
}
/** The body of every `<AlertDialogAction …>…</AlertDialogAction>` block. */
function actions(source: string): string[] {
return [
...source.matchAll(/<AlertDialogAction\b[\s\S]*?<\/AlertDialogAction>/g),
].map((m) => m[0]);
}
describe("token revoke labels", () => {
for (const rel of FILES) {
it(`${rel}: the revoke confirm says "Revoke token"`, () => {
const revokes = actions(read(rel)).filter((a) =>
a.includes("handleRevoke(tok.id)"),
);
expect(revokes.length).toBeGreaterThan(0);
for (const action of revokes) {
expect(action).toContain('t("settings.tokenRevokeAction")');
}
});
it(`${rel}: never labels a control with the status word`, () => {
expect(read(rel)).not.toContain('t("settings.tokenRevoked")');
});
}
});
+3 -3
View File
@@ -619,7 +619,7 @@ function ApiTokensCard() {
variant="destructive"
onClick={() => handleRevoke(tok.id)}
>
{t("settings.tokenRevoked")}
{t("settings.tokenRevokeAction")}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
@@ -698,7 +698,7 @@ function ApiTokensCard() {
className="min-h-11 w-full"
>
<Trash2 className="h-3.5 w-3.5" />
{t("settings.tokenRevoke")}
{t("settings.tokenRevokeAction")}
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
@@ -718,7 +718,7 @@ function ApiTokensCard() {
variant="destructive"
onClick={() => handleRevoke(tok.id)}
>
{t("settings.tokenRevoked")}
{t("settings.tokenRevokeAction")}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
+2 -2
View File
@@ -516,7 +516,7 @@ function McpTokensCard() {
className="min-h-11 w-full"
>
<Trash2 className="h-3.5 w-3.5" />
{t("settings.tokenRevoke")}
{t("settings.tokenRevokeAction")}
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
@@ -536,7 +536,7 @@ function McpTokensCard() {
variant="destructive"
onClick={() => handleRevoke(tok.id)}
>
{t("settings.tokenRevoked")}
{t("settings.tokenRevokeAction")}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>