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.
126 lines
4.4 KiB
Vue
126 lines
4.4 KiB
Vue
<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>
|