feat(ui): choose a connection's permitted identities from the identity list
This commit is contained in:
1 parent
8dc7b8635e
commit
afbc7b57a3
3 files changed
+89
-85
No files matched your search
@@ -8,6 +8,7 @@ import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectVa
|
||||
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 {
|
||||
@@ -27,6 +28,10 @@ const props = defineProps<{ connection: Connection; index: number }>();
|
||||
const extensions = useExtensionsStore();
|
||||
onMounted(() => void extensions.loadInstalled());
|
||||
const forges = computed(() => extensions.extensions.filter((e) => e.enabled && e.surfaces.includes("forge")));
|
||||
const org = useOrgStore();
|
||||
// An identity already permitted on another row is not offered again.
|
||||
const choosable = (current: string) =>
|
||||
org.identities.filter((a) => a.lifecycle === "active" && (a.id === current || !(a.id in (props.connection.permits ?? {}))));
|
||||
const unavailable = computed(() => !!props.connection.type && !forges.value.some((e) => e.name === props.connection.type));
|
||||
</script>
|
||||
|
||||
@@ -98,14 +103,18 @@ const unavailable = computed(() => !!props.connection.type && !forges.value.some
|
||||
: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="Identity"
|
||||
:aria-label="`Permitted identity for ${props.connection.id}`"
|
||||
@change="renamePermit(props.connection, identity, ($event.target as HTMLInputElement).value.trim())"
|
||||
/>
|
||||
<Select
|
||||
:model-value="identity || undefined"
|
||||
@update:model-value="(to) => renamePermit(props.connection, identity, String(to))"
|
||||
>
|
||||
<SelectTrigger class="max-w-72" :aria-label="`Permitted identity for ${props.connection.id}`">
|
||||
<SelectValue placeholder="Choose identity" />
|
||||
</SelectTrigger>
|
||||
<SelectContent><SelectGroup>
|
||||
<SelectItem v-for="actor in choosable(identity)" :key="actor.id" :value="actor.id">{{ actor.display_name || actor.id }}</SelectItem>
|
||||
<SelectItem v-if="identity && !choosable(identity).some((a) => a.id === identity)" :value="identity">{{ org.identityName(identity) }} · unavailable</SelectItem>
|
||||
</SelectGroup></SelectContent>
|
||||
</Select>
|
||||
<label
|
||||
v-for="operation in OPERATIONS"
|
||||
:key="operation"
|
||||
|
||||
@@ -93,11 +93,6 @@ function addConnection() {
|
||||
</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>
|
||||
Reference in new issue
Block a user