feat(webui): repositories list is an accordion; adding opens the new one and waits for save

This commit is contained in:
sam committed 2026-10-13 19:04:14 +11:00
1 parent 60307b31fd
commit 45a97c2385
5 files changed
+86 -74

No files matched your search

@@ -19,7 +19,7 @@ defineEmits<{ change: [] }>();
<template>
<div class="flex flex-col gap-1.5">
<div class="flex h-9 items-center gap-2 rounded-md border border-input bg-background px-3 font-mono text-[13px]">
<div class="flex h-8 items-center gap-2 rounded-lg border border-input bg-card px-2.5 font-mono text-[13px]">
<Lock class="size-3.5 shrink-0 text-muted-foreground" aria-hidden="true" />
<span class="text-muted-foreground">{{ engine }}</span>
<span class="text-muted-foreground" aria-hidden="true">/</span>
@@ -16,7 +16,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
<template>
<TagsInputRoot
v-slot="slotProps" v-bind="forwarded" :class="cn(
'flex flex-wrap gap-2 items-center rounded-md border border-input bg-background px-2 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none',
'flex flex-wrap gap-2 items-center rounded-lg border border-input bg-card px-2.5 py-1 text-sm transition-[color,box-shadow] outline-none',
'focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-3',
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
props.class)"
+20 -8
View File
@@ -4,6 +4,8 @@ import { computed, onMounted, ref } from "vue";
import { storeToRefs } from "pinia";
import { Plus, Trash2 } from "@lucide/vue";
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion";
import PageHeader from "@/base/PageHeader.vue";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -62,7 +64,10 @@ const error = computed(() => store.pageErrorFor(KIND));
const ecosystems = ["go", "python", "node", "rust", "custom"];
const newRepo = ref("");
const open = ref("0");
const unsaved = computed(() => store.changesFor(KIND).length > 0);
function addRepo() {
if (unsaved.value) return;
const [owner, name] = newRepo.value.trim().split("/");
if (!draft.value || !owner || !name) return;
draft.value.value ??= [];
@@ -71,6 +76,7 @@ function addRepo() {
test_glob: "", persistent_storage: false, max_retries: 0, allow_concurrent: false,
});
newRepo.value = "";
open.value = String((draft.value.value as Repo[]).length - 1);
}
const protectOf = (repo: Repo) => repo.protect ?? [];
</script>
@@ -85,16 +91,20 @@ const protectOf = (repo: Repo) => repo.protect ?? [];
<p v-if="catalogError || error" class="mb-4 text-sm text-danger" role="alert">{{ catalogError || error }}</p>
<template v-if="draft">
<section
<Accordion v-model="open" type="single" collapsible class="mb-4 gap-4">
<AccordionItem
v-for="(repo, i) in repos"
:key="i"
class="mb-4 rounded-lg border border-border bg-card px-5 pt-4 pb-2"
:aria-label="`${repo.owner}/${repo.name}`"
:value="String(i)"
class="rounded-lg border border-border bg-card px-5 not-last:border-b"
>
<header class="flex items-center gap-2">
<h2 class="min-w-0 flex-1 truncate font-mono text-[15px] font-medium">{{ repo.owner }}/{{ repo.name }}</h2>
<header class="flex items-center gap-2 [&>h3]:min-w-0 [&>h3]:flex-1">
<AccordionTrigger class="min-w-0 flex-1 items-center font-mono text-[15px] hover:no-underline">
<span class="truncate">{{ repo.owner }}/{{ repo.name }}</span>
</AccordionTrigger>
<Button variant="ghost" size="icon" :aria-label="`Remove ${repo.owner}/${repo.name}`" @click="repos.splice(i, 1)"><Trash2 /></Button>
</header>
<AccordionContent>
<SettingRow label="Base branch" :for="`repo-${i}-base`">
<div class="flex flex-wrap items-center gap-3">
<Input :id="`repo-${i}-base`" v-model="repo.base" class="max-w-56 font-mono" />
@@ -171,11 +181,13 @@ const protectOf = (repo: Repo) => repo.protect ?? [];
<DraftHint :kind="KIND" :path="`${i}.allow_concurrent`" />
</div>
</SettingRow>
</section>
</AccordionContent>
</AccordionItem>
</Accordion>
<div class="flex gap-2">
<Input v-model="newRepo" class="max-w-72 font-mono" placeholder="owner/repository" aria-label="New repository" @keydown.enter="addRepo" />
<Button variant="outline" size="sm" :disabled="!/^[^/\s]+\/[^/\s]+$/.test(newRepo.trim())" @click="addRepo">
<Input v-model="newRepo" class="max-w-72 font-mono" placeholder="owner/repository" aria-label="New repository" :disabled="unsaved" @keydown.enter="addRepo" />
<Button variant="outline" size="sm" :disabled="unsaved || !/^[^/\s]+\/[^/\s]+$/.test(newRepo.trim())" @click="addRepo">
<Plus data-icon="inline-start" /> Add repository</Button>
</div>
</template>