feat(ui): configure forge connections in the dashboard
A Connections page under Settings lists the organisation's forge connections: host, forge type, the reference to the credential (never its value), the external account it belongs to, and the operations each execution identity may perform through it. The chat agent's page registry names the page too.
This commit is contained in:
10 files changed
+377
-80
No files matched your search
@@ -63,6 +63,7 @@ const settings: NavSpec = {
|
||||
label: "Integrations",
|
||||
paths: [
|
||||
"/settings/channels",
|
||||
"/settings/connections",
|
||||
"/settings/repositories",
|
||||
"/settings/tools",
|
||||
"/settings/extensions",
|
||||
|
||||
@@ -21,6 +21,7 @@ import ExtensionsPage from "@/settings/ExtensionsPage.vue";
|
||||
import PluginsPage from "@/settings/PluginsPage.vue";
|
||||
import SecretEnginesPage from "@/settings/SecretEnginesPage.vue";
|
||||
import ContainerRuntimePage from "@/settings/ContainerRuntimePage.vue";
|
||||
import ConnectionsPage from "@/settings/ConnectionsPage.vue";
|
||||
import SystemAppearancePage from "@/settings/SystemAppearancePage.vue";
|
||||
import SystemModelsPage from "@/settings/SystemModelsPage.vue";
|
||||
import SystemReposPage from "@/settings/SystemReposPage.vue";
|
||||
@@ -181,6 +182,18 @@ const routes = [
|
||||
section: "settings",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/connections",
|
||||
name: "settings-connections",
|
||||
component: ConnectionsPage,
|
||||
meta: {
|
||||
navPath: "/settings",
|
||||
settings: true,
|
||||
label: "Connections",
|
||||
description: "Forge hosts, credentials and permitted operations.",
|
||||
section: "settings",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/repositories",
|
||||
name: "system-repos",
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<script setup lang="ts">
|
||||
import { Plus } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SettingRow } from "@/components/ui/setting-row";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import SecretRefField from "./SecretRefField.vue";
|
||||
import DraftHint from "./DraftHint.vue";
|
||||
import {
|
||||
OPERATIONS,
|
||||
addPermit,
|
||||
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<{ connection: Connection; index: number }>();
|
||||
</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`"
|
||||
v-model="props.connection.id"
|
||||
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`"
|
||||
v-model="props.connection.name"
|
||||
class="max-w-72"
|
||||
placeholder="GitHub (platform team)"
|
||||
/>
|
||||
<DraftHint kind="forge-connections" :path="`${props.index}.name`" />
|
||||
</div>
|
||||
</SettingRow>
|
||||
<SettingRow label="Forge type" :for="`connection-${props.index}-type`">
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<Input
|
||||
:id="`connection-${props.index}-type`"
|
||||
v-model="props.connection.type"
|
||||
class="max-w-56 font-mono"
|
||||
/>
|
||||
<span class="text-xs text-fg-subtle">An installed forge extension of this name.</span>
|
||||
</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`"
|
||||
v-model="props.connection.host"
|
||||
class="max-w-72 font-mono"
|
||||
placeholder="https://github.com"
|
||||
/>
|
||||
<DraftHint kind="forge-connections" :path="`${props.index}.host`" />
|
||||
</div>
|
||||
</SettingRow>
|
||||
<SettingRow label="External account">
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<Input
|
||||
v-model="props.connection.account"
|
||||
class="max-w-56 font-mono"
|
||||
placeholder="acme-bot"
|
||||
aria-label="External account"
|
||||
/>
|
||||
<span class="text-xs text-fg-subtle">
|
||||
The account the credential belongs to. Commits may be authored as someone else.
|
||||
</span>
|
||||
</div>
|
||||
</SettingRow>
|
||||
<SettingRow label="Credential">
|
||||
<SecretRefField v-model="props.connection.token" :id-prefix="`connection-${props.index}-token`" />
|
||||
</SettingRow>
|
||||
<SettingRow label="Permitted operations">
|
||||
<div class="w-full space-y-2">
|
||||
<p class="text-xs text-fg-subtle">
|
||||
An identity with no entry performs nothing through this connection. A connection is not a
|
||||
grant.
|
||||
</p>
|
||||
<div
|
||||
v-for="[identity, operations] in permits(props.connection)"
|
||||
:key="`${props.index}-${identity}`"
|
||||
class="flex flex-wrap items-center gap-3"
|
||||
>
|
||||
<Input
|
||||
:model-value="identity"
|
||||
class="max-w-72 font-mono"
|
||||
list="connection-identities"
|
||||
placeholder="execution identity"
|
||||
:aria-label="`Permitted identity for ${props.connection.id}`"
|
||||
@change="renamePermit(props.connection, identity, ($event.target as HTMLInputElement).value.trim())"
|
||||
/>
|
||||
<label
|
||||
v-for="operation in OPERATIONS"
|
||||
:key="operation"
|
||||
class="flex items-center gap-2 text-sm"
|
||||
>
|
||||
<Switch
|
||||
:model-value="operations.includes(operation)"
|
||||
:aria-label="`${operation} for ${identity || 'the identity'}`"
|
||||
@update:model-value="(on: boolean) => toggleOperation(props.connection, identity, operation, on)"
|
||||
/>
|
||||
<span class="font-mono text-xs">{{ operation }}</span>
|
||||
</label>
|
||||
<Button variant="ghost" size="sm" @click="removePermit(props.connection, identity)">
|
||||
Remove
|
||||
</Button>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" @click="addPermit(props.connection)">
|
||||
<Plus data-icon="inline-start" />Permit an identity
|
||||
</Button>
|
||||
</div>
|
||||
</SettingRow>
|
||||
</template>
|
||||
@@ -0,0 +1,107 @@
|
||||
<script setup lang="ts">
|
||||
import ApplyStatusRows from "./ApplyStatusRows.vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { Plus } from "@lucide/vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
|
||||
import { useOrgStore } from "@/stores/org";
|
||||
import CardAccordion from "./CardAccordion.vue";
|
||||
import ConnectionCard from "./ConnectionCard.vue";
|
||||
import HistoryLink from "./HistoryLink.vue";
|
||||
import type { Connection } from "./connection";
|
||||
|
||||
const KIND = "forge-connections";
|
||||
|
||||
const store = useSettingsStore();
|
||||
const orgStore = useOrgStore();
|
||||
const { catalog, catalogError } = storeToRefs(store);
|
||||
onMounted(() => {
|
||||
void store.load();
|
||||
orgStore.watchIdentities();
|
||||
});
|
||||
|
||||
const resources = computed(() => resourcesForPage(catalog.value, "connections"));
|
||||
const draft = computed(() => store.drafts[KIND]);
|
||||
const connections = computed(() => (draft.value?.value ?? []) as Connection[]);
|
||||
const error = computed(() => store.pageErrorFor(KIND));
|
||||
const open = ref("0");
|
||||
const unsaved = computed(() => store.changesFor(KIND).length > 0);
|
||||
|
||||
function addConnection() {
|
||||
if (unsaved.value) return;
|
||||
draft.value.value ??= [];
|
||||
const used = new Set(connections.value.map((c) => c.id));
|
||||
let id = "connection";
|
||||
for (let n = 2; used.has(id); n++) id = `connection-${n}`;
|
||||
connections.value.push({
|
||||
id,
|
||||
name: "",
|
||||
type: "github",
|
||||
host: "",
|
||||
account: "",
|
||||
token: { engine: "", key: "" },
|
||||
permits: {},
|
||||
});
|
||||
open.value = String(connections.value.length - 1);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Connections">
|
||||
<HistoryLink :kinds="resources.map((r) => r.kind)" />
|
||||
</PageHeader>
|
||||
<ApplyStatusRows
|
||||
v-for="resource in resources"
|
||||
:key="resource.kind"
|
||||
:kind="resource.kind"
|
||||
class="mb-4"
|
||||
/>
|
||||
|
||||
<p class="mb-4 max-w-prose text-sm text-muted-foreground">
|
||||
A connection is how this organisation reaches a forge: where it is, which credential
|
||||
authenticates, and which execution identities may do what through it. A repository binding
|
||||
names one of these by its ID. The credential is stored as a reference; its value is never
|
||||
shown here.
|
||||
</p>
|
||||
|
||||
<p v-if="catalogError || error" class="mb-4 text-sm text-danger" role="alert">
|
||||
{{ catalogError || error }}
|
||||
</p>
|
||||
|
||||
<template v-if="draft">
|
||||
<div class="mb-4 flex flex-wrap items-center gap-2">
|
||||
<Button size="sm" :disabled="unsaved" @click="addConnection">
|
||||
<Plus data-icon="inline-start" />Add connection
|
||||
</Button>
|
||||
<span v-if="unsaved" class="text-xs text-muted-foreground">Save the current changes first.</span>
|
||||
</div>
|
||||
|
||||
<p v-if="!connections.length" class="text-sm text-fg-subtle">
|
||||
No connections yet. Add one to clone a private repository.
|
||||
</p>
|
||||
|
||||
<CardAccordion
|
||||
v-model:open="open"
|
||||
:items="connections"
|
||||
:title="(item) => item.name || item.id"
|
||||
remove-label="Remove"
|
||||
mono
|
||||
@remove="connections.splice($event, 1)"
|
||||
>
|
||||
<template #default="slot">
|
||||
<ConnectionCard :connection="slot.item" :index="slot.index" />
|
||||
</template>
|
||||
</CardAccordion>
|
||||
|
||||
<datalist id="connection-identities">
|
||||
<option v-for="identity in orgStore.identities" :key="identity.id" :value="identity.id">
|
||||
{{ identity.display_name }}
|
||||
</option>
|
||||
</datalist>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,48 @@
|
||||
/** 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 };
|
||||
/** 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 ?? {});
|
||||
|
||||
export function addPermit(c: Connection): void {
|
||||
c.permits ??= {};
|
||||
c.permits[""] = ["clone"];
|
||||
}
|
||||
|
||||
export function removePermit(c: Connection, id: string): void {
|
||||
if (c.permits) delete c.permits[id];
|
||||
}
|
||||
|
||||
// Renaming rebuilds the entry: the identity reference is the map key.
|
||||
export function renamePermit(c: Connection, from: string, to: string): void {
|
||||
if (!c.permits || from === to) return;
|
||||
const operations = c.permits[from];
|
||||
delete c.permits[from];
|
||||
if (to) c.permits[to] = operations;
|
||||
}
|
||||
|
||||
export function toggleOperation(
|
||||
c: Connection,
|
||||
id: string,
|
||||
operation: string,
|
||||
on: boolean,
|
||||
): void {
|
||||
const current = new Set(c.permits?.[id] ?? []);
|
||||
if (on) current.add(operation);
|
||||
else current.delete(operation);
|
||||
c.permits ??= {};
|
||||
c.permits[id] = OPERATIONS.filter((o) => current.has(o));
|
||||
}
|
||||
@@ -180,6 +180,7 @@ export type ControlPlanePage =
|
||||
| "tasks"
|
||||
| "models"
|
||||
| "repositories"
|
||||
| "connections"
|
||||
| "channels"
|
||||
| "scheduling"
|
||||
| "tools"
|
||||
@@ -193,6 +194,7 @@ const PAGE_RESOURCES: Record<ControlPlanePage, string[]> = {
|
||||
tasks: ["workflow-execution-settings","task-policy"],
|
||||
models: ["provider-settings", "model-aliases", "org-model-policy"],
|
||||
repositories: ["repository-policies"],
|
||||
connections: ["forge-connections"],
|
||||
channels: ["channel-settings"],
|
||||
scheduling: ["scheduling-policy"],
|
||||
tools: ["tool-settings"],
|
||||
|
||||
Reference in new issue
Block a user