chore(ui/settings): delete the unused forge connection card (#2063)

This commit is contained in:
sam committed 2026-11-22 15:44:17 +11:00
1 parent 787a213db6
commit 7f89b03507
3 files changed
+1 -229

No files matched your search

-162
View File
@@ -1,162 +0,0 @@
<script setup lang="ts">
import { Label } from "@/components/ui/label";
import { Plus } from "@lucide/vue";
import { computed, onMounted } from "vue";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { SettingRow } from "@/components/ui/setting-row";
import { Switch } from "@/components/ui/switch";
import { useExtensionsStore } from "@/stores/extensions";
import { useOrgStore } from "@/stores/org";
import SecretRefField from "./SecretRefField.vue";
import DraftHint from "./DraftHint.vue";
import {
OPERATIONS,
addPermit,
choosableIdentities,
permits,
removePermit,
renamePermit,
toggleOperation,
type Connection,
} from "./connection";
// The card mutates the draft object it is given, the way every settings page
// edits its draft in place; it never reassigns the prop.
const props = defineProps<{ index: number }>();
const connection = defineModel<Connection>({ required: true });
// The bound connection belongs to a settings form, so an edit emits a new one.
function patch(change: Partial<Connection>): void {
connection.value = { ...connection.value, ...change };
}
const extensions = useExtensionsStore();
onMounted(() => void extensions.loadInstalled());
const org = useOrgStore();
const unavailable = computed(() => !!connection.value.type && !extensions.forges.some((e) => e.name === connection.value.type));
</script>
<template>
<SettingRow label="ID" :for="`connection-${props.index}-id`">
<div class="flex flex-wrap items-center gap-3">
<Input
:id="`connection-${props.index}-id`"
:model-value="connection.id"
@update:model-value="(value: string | number) => patch({ id: String(value) })"
class="max-w-56 font-mono"
aria-label="Connection ID"
/>
<DraftHint kind="forge-connections" :path="`${props.index}.id`" />
</div>
</SettingRow>
<SettingRow label="Name" :for="`connection-${props.index}-name`">
<div class="flex flex-wrap items-center gap-3">
<Input
:id="`connection-${props.index}-name`"
:model-value="connection.name"
@update:model-value="(value: string | number) => patch({ name: String(value) })"
class="max-w-72"
placeholder="GitHub (platform team)"
/>
<DraftHint kind="forge-connections" :path="`${props.index}.name`" />
</div>
</SettingRow>
<SettingRow label="Forge" :for="`connection-${props.index}-type`">
<div class="flex flex-wrap items-center gap-3">
<Select :model-value="connection.type" @update:model-value="(type) => patch({ type: String(type ?? '') })">
<SelectTrigger :id="`connection-${props.index}-type`" class="max-w-56"><SelectValue>{{ connection.type ? extensions.forgeName(connection.type) : "Choose" }}</SelectValue></SelectTrigger>
<SelectContent><SelectGroup>
<SelectItem v-for="forge in extensions.forges" :key="forge.name" :value="forge.name">{{ forge.display_name || forge.name }}</SelectItem>
<SelectItem v-if="unavailable" :value="connection.type">{{ connection.type }} · not enabled</SelectItem>
</SelectGroup></SelectContent>
</Select>
</div>
</SettingRow>
<SettingRow label="Host" :for="`connection-${props.index}-host`">
<div class="flex flex-wrap items-center gap-3">
<Input
:id="`connection-${props.index}-host`"
:model-value="connection.host"
@update:model-value="(value: string | number) => patch({ host: String(value) })"
class="max-w-72 font-mono"
placeholder="https://github.com"
/>
<DraftHint kind="forge-connections" :path="`${props.index}.host`" />
</div>
</SettingRow>
<SettingRow label="External account">
<Input
:model-value="connection.account"
@update:model-value="(value: string | number) => patch({ account: String(value) })"
class="max-w-56 font-mono"
placeholder="acme-bot"
aria-label="External account"
/>
</SettingRow>
<SettingRow label="Credential">
<div role="group" aria-label="Credential"><SecretRefField :model-value="connection.token" @update:model-value="(token) => patch({ token })" :id-prefix="`connection-${props.index}-token`" /></div>
</SettingRow>
<SettingRow label="Commit author" :for="`connection-${props.index}-commit-name`">
<div class="flex flex-wrap items-center gap-3">
<Input
:id="`connection-${props.index}-commit-name`"
:model-value="connection.commit_name ?? ''"
@update:model-value="(value: string | number) => patch({ commit_name: String(value) || undefined })"
class="max-w-56"
:placeholder="connection.account || 'archie'"
aria-label="Commit author name"
/>
<Input
:model-value="connection.commit_email ?? ''"
@update:model-value="(value: string | number) => patch({ commit_email: String(value) || undefined })"
class="max-w-72 font-mono"
type="email"
placeholder="archie@example.com"
aria-label="Commit author email"
/>
</div>
</SettingRow>
<SettingRow label="Signing key">
<div role="group" aria-label="Signing key"><SecretRefField :model-value="connection.signing_key ?? { engine: '', key: '' }" @update:model-value="(ref) => patch({ signing_key: ref.engine || ref.key ? ref : undefined })" :id-prefix="`connection-${props.index}-signing-key`" /></div>
</SettingRow>
<SettingRow label="Permitted operations">
<div class="w-full space-y-2" role="group" aria-label="Permitted operations">
<div
v-for="[identity, operations] in permits(connection)"
:key="`${props.index}-${identity}`"
class="flex flex-wrap items-center gap-3"
>
<Select
:model-value="identity || undefined"
@update:model-value="(to) => (connection = renamePermit(connection, identity, String(to)))"
>
<SelectTrigger class="max-w-72" :aria-label="`Permitted identity for ${connection.id}`">
<SelectValue>{{ identity ? org.identityName(identity) : "Choose" }}</SelectValue>
</SelectTrigger>
<SelectContent><SelectGroup>
<SelectItem v-for="actor in choosableIdentities(connection, org.activeIdentities, identity)" :key="actor.id" :value="actor.id">{{ actor.display_name || actor.id }}</SelectItem>
<SelectItem v-if="identity && !choosableIdentities(connection, org.activeIdentities, identity).some((a) => a.id === identity)" :value="identity">{{ org.identityName(identity) }} · unavailable</SelectItem>
</SelectGroup></SelectContent>
</Select>
<Label
v-for="operation in OPERATIONS"
:key="operation"
class="flex items-center gap-2 text-label"
>
<Switch
:model-value="operations.includes(operation)"
:aria-label="`${operation} for ${identity || 'the identity'}`"
@update:model-value="(on: boolean) => (connection = toggleOperation(connection, identity, operation, on))"
/>
<span class="font-mono text-caption">{{ operation }}</span>
</Label>
<Button variant="ghost" size="sm" @click="connection = removePermit(connection, identity)">Remove</Button>
</div>
<Button variant="outline" size="sm" @click="connection = addPermit(connection)">
<Plus data-icon="inline-start" />Add identity
</Button>
</div>
</SettingRow>
</template>
-57
View File
@@ -1,57 +0,0 @@
/** The operations the runtime can perform through a connection. */
export const OPERATIONS = ["clone", "push", "pr"] as const;
/** One organisation-owned forge connection, as the document writes it. */
export interface Connection {
id: string;
name: string;
type: string;
host: string;
account: string;
token: { engine: string; key: string };
commit_name?: string;
commit_email?: string;
/** OpenSSH private key that signs commits made through the connection. */
signing_key?: { engine: string; key: string };
/** Permitted operations per execution identity ID. */
permits?: Record<string, string[]>;
}
/** permits renders the document's map as rows the page can edit. */
export const permits = (c: Connection): [string, string[]][] =>
Object.entries(c.permits ?? {});
// Each edit returns a new connection: the one passed in belongs to a settings
// form, and a write in place never reaches it.
export function addPermit(c: Connection): Connection {
return { ...c, permits: { ...c.permits, "": ["clone"] } };
}
export function removePermit(c: Connection, id: string): Connection {
const { [id]: _, ...rest } = c.permits ?? {};
return { ...c, permits: rest };
}
// Renaming rebuilds the entry: the identity reference is the map key.
export function renamePermit(c: Connection, from: string, to: string): Connection {
if (!c.permits || from === to) return c;
const { [from]: operations = [], ...rest } = c.permits;
return { ...c, permits: to ? { ...rest, [to]: operations } : rest };
}
export function toggleOperation(
c: Connection,
id: string,
operation: string,
on: boolean,
): Connection {
const current = new Set(c.permits?.[id] ?? []);
if (on) current.add(operation);
else current.delete(operation);
return { ...c, permits: { ...c.permits, [id]: OPERATIONS.filter((o) => current.has(o)) } };
}
/** Identities a permit row may pick: any not already permitted on another row. */
export const choosableIdentities = <T extends { id: string }>(c: Connection, identities: T[], current: string): T[] =>
identities.filter((a) => a.id === current || !(a.id in (c.permits ?? {})));
+1 -10
View File
@@ -1,5 +1,5 @@
import { defineStore } from "pinia";
import { computed, ref } from "vue";
import { ref } from "vue";
import { errors } from "@/copy/errors";
import { api, describeError, type CatalogueEntry, type CatalogueSourceView, type Extension, type ExtensionGrantsInput, type Grants, type SettingField } from "@/lib/api";
@@ -35,13 +35,6 @@ export const useExtensionsStore = defineStore("extensions", () => {
const catalogueLoaded = ref(false);
const error = ref("");
const busy = ref("");
// The binary carries no per-extension surface, so a connection cannot yet
// name an installed forge.
const forges = computed<Extension[]>(() => []);
function forgeName(type: string): string {
return `${type} · not enabled`;
}
async function loadInstalled(): Promise<void> {
try {
extensions.value = await api.allExtensions();
@@ -87,8 +80,6 @@ export const useExtensionsStore = defineStore("extensions", () => {
}
return {
forges,
forgeName,
extensions,
catalogue,
source,