DRY pass #3: SyncView's update choices are one fieldset, twice (#5373)

The source and channel fieldsets were the same markup over different options.
updateChoices holds each set with its legend, radio name and when it is
offered, and one v-for draws them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 15:14:10 -04:00
co-authored by Claude Opus 5.5
parent 31d8b1e65b
commit 0e21b8e7f1
+13 -20
View File
@@ -147,6 +147,13 @@ const channelOptions = computed<UpdateOption[]>(() => [
}, },
]); ]);
// Each set of choices, and when it is offered. A server holds one build, so a
// channel only means something on the forge.
const updateChoices = computed(() => [
{ legend: "Updates from", name: "update-source", shown: !!offeredServer.value, options: sourceOptions.value },
{ legend: "Channel", name: "update-channel", shown: source.value === null, options: channelOptions.value },
]);
// --- Quick capture ----------------------------------------------------------- // --- Quick capture -----------------------------------------------------------
// A desktop-local preference, so it lives here beside the update channel rather // A desktop-local preference, so it lives here beside the update channel rather
// than in admin Settings: that screen is the SERVER's, and this is a property of // than in admin Settings: that screen is the SERVER's, and this is a property of
@@ -650,29 +657,14 @@ onBeforeUnmount(() => stopSyncListener?.());
This is version {{ update?.current_version ?? "—" }}. This is version {{ update?.current_version ?? "—" }}.
</p> </p>
<fieldset v-if="offeredServer" class="mt-4"> <template v-for="group in updateChoices" :key="group.name">
<fieldset v-if="group.shown" class="mt-4">
<legend class="section-label"> <legend class="section-label">
Updates from {{ group.legend }}
</legend> </legend>
<div class="mt-2 flex flex-col gap-2"> <div class="mt-2 flex flex-col gap-2">
<label v-for="o in sourceOptions" :key="o.title" class="flex items-start gap-2 text-sm"> <label v-for="o in group.options" :key="o.title" class="flex items-start gap-2 text-sm">
<input type="radio" class="mt-1" name="update-source" :checked="o.checked" @change="o.pick()" /> <input type="radio" class="mt-1" :name="group.name" :checked="o.checked" @change="o.pick()" />
<span>
<span class="font-medium">{{ o.title }}</span>
<span class="block text-neutral-500 dark:text-neutral-400">{{ o.detail }}</span>
</span>
</label>
</div>
</fieldset>
<!-- A server holds one build, so a channel only means something on the forge. -->
<fieldset v-if="source === null" class="mt-4">
<legend class="section-label">
Channel
</legend>
<div class="mt-2 flex flex-col gap-2">
<label v-for="o in channelOptions" :key="o.title" class="flex items-start gap-2 text-sm">
<input type="radio" class="mt-1" name="update-channel" :checked="o.checked" @change="o.pick()" />
<span> <span>
<span class="font-medium">{{ o.title }}</span> <span class="font-medium">{{ o.title }}</span>
<span class="block text-neutral-500 dark:text-neutral-400">{{ o.detail }}</span> <span class="block text-neutral-500 dark:text-neutral-400">{{ o.detail }}</span>
@@ -680,6 +672,7 @@ onBeforeUnmount(() => stopSyncListener?.());
</label> </label>
</div> </div>
</fieldset> </fieldset>
</template>
<p <p
v-if="update?.blocked_reason" v-if="update?.blocked_reason"