Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Show deployment credentials read-only in credential settings

Josh France1cb4ba8cff8b
diff --git a/plugins/admin/test/default-view.test.ts b/plugins/admin/test/default-view.test.ts
index 9d7da5217..fd1c05403 100644
--- a/plugins/admin/test/default-view.test.ts
+++ b/plugins/admin/test/default-view.test.ts
@@ -1,3 +1,4 @@
+import { readFileSync } from "node:fs";
import { SettingsState, load as loadSettings, states as settingsStates } from "../ui/settings.ts";
import { CredentialState } from "../ui/settings-credentials.ts";
import { GovernanceState, load, states } from "../ui/governance-state.ts";
@@ -373,6 +374,9 @@ test("governance credential editor previews effective capability and uses an in-
assert.match(html, new RegExp(`id="${id}"`));
}
assert.match(html, /function renderServiceCredentialCapability\(\)/);
+ const credentialsSource = readFileSync(new URL("../ui/settings-credentials.ts", import.meta.url), "utf8");
+ assert.match(credentialsSource, /deployment\s*\?\s*html`<div class="credential-actions hint">Read-only<\/div>`/);
+ assert.match(credentialsSource, /badge\("Supplied by deployment", "info"\)/);
assert.match(html, /expectedUpdatedAt: c\.updatedAt/);
assert.match(html, /function refreshServiceCredentialConflict\(\)/);
assert.match(html, /credentialState.version = scEditVersion/);
diff --git a/plugins/admin/ui/settings-credentials.ts b/plugins/admin/ui/settings-credentials.ts
index e4a62e6f7..d5348c46f 100644
--- a/plugins/admin/ui/settings-credentials.ts
+++ b/plugins/admin/ui/settings-credentials.ts
@@ -254,11 +254,15 @@ function credentialRows() {
credentialState.rows,
(c) => c.slug,
(c) => {
- const org = (c.grantees || []).some((g: string) => g.startsWith("org:"));
+ const deployment = c.source === "deployment";
+ const org = deployment || (c.grantees || []).some((g: string) => g.startsWith("org:"));
const target =
c.delivery === "env"
? "sandbox env $" + (c.envKey || "?")
- : c.host + " · " + (c.allowedMethods?.length ? c.allowedMethods.join("/") : "GET");
+ : c.host +
+ " · " +
+ (c.allowedMethods?.length ? c.allowedMethods.join("/") : "GET") +
+ (c.maxRequestsPerDay ? " · " + plural(c.maxRequestsPerDay, "request") + " per UTC day" : "");
return html`<div
class=${classMap({ "credential-row": true, "is-editing": c.slug === credentialState.editing })}
>
@@ -268,21 +272,25 @@ function credentialRows() {
</div>
<div class="hint">${target + " · " + credentialUsage(c)}</div>
<div class="credential-badges">
- ${badge(c.delivery === "env" ? "Env" : "Broker", "info")}${badge(c.enabled === false ? "Disabled" : "Enabled", c.enabled === false ? "warn" : "ok")}${badge(c.hasSecret ? "Secret set" : "Secret missing", c.hasSecret ? "ok" : "err")}${badge(org ? "Organization-wide" : plural((c.grantees || []).length, "principal"), org ? "info" : "muted")}${c.delivery !== "env" && c.deployments === false ? badge("No apps", "muted") : null}
+ ${badge(c.delivery === "env" ? "Env" : "Broker", "info")}${badge(c.enabled === false ? "Disabled" : "Enabled", c.enabled === false ? "warn" : "ok")}${badge(c.hasSecret ? "Secret set" : "Secret missing", c.hasSecret ? "ok" : "err")}${badge(org ? "Organization-wide" : plural((c.grantees || []).length, "principal"), org ? "info" : "muted")}${c.delivery !== "env" && c.deployments === false ? badge("No apps", "muted") : null}${deployment ? badge("Supplied by deployment", "info") : null}
</div>
</div>
- <div class="credential-actions">
- <button type="button" @click=${() => config.edit(c)}>Edit</button
- ><button
- type="button"
- class="rowbtn danger"
- title="Delete credential"
- aria-label=${"Delete " + (c.name || c.slug)}
- @click=${() => config.remove(c)}
- >
- Delete
- </button>
- </div>
+ ${
+ deployment
+ ? html`<div class="credential-actions hint">Read-only</div>`
+ : html`<div class="credential-actions">
+ <button type="button" @click=${() => config.edit(c)}>Edit</button
+ ><button
+ type="button"
+ class="rowbtn danger"
+ title="Delete credential"
+ aria-label=${"Delete " + (c.name || c.slug)}
+ @click=${() => config.remove(c)}
+ >
+ Delete
+ </button>
+ </div>`
+ }
</div>`;
},
)