New settings/KindGate renders the store's per-kind loading/error state where the form would be: a skeleton while loading, ReadError with Retry on a failed read. Wired into Tools, SystemModels, SystemRepos, SchedulingPolicy, ContainerRuntime, OrgAlerts, Instructions, Plugins, SystemTasks, UpdateSettings, IdentityGrants, OrgModels, Channels and Authentication pages, which no longer render blank until the draft exists.
71 lines
2.9 KiB
Vue
71 lines
2.9 KiB
Vue
<script setup lang="ts">
|
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
import { computed, onMounted } from "vue";
|
|
|
|
import { Field, FieldContent, FieldGroup, FieldLabel } from "@/components/ui/field";
|
|
import { Section } from "@/components/ui/section";
|
|
import { Input } from "@/components/ui/input";
|
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
|
import { useSettingsStore } from "@/stores/settings";
|
|
import { fieldInvalid } from "./settings-form";
|
|
import KindGate from "./KindGate.vue";
|
|
|
|
const KIND = "update-settings";
|
|
type UpdateSettings = { channel: string; pin: string };
|
|
|
|
const store = useSettingsStore();
|
|
onMounted(store.load);
|
|
|
|
const form = computed(() => store.formFor(KIND));
|
|
const channel = computed(() => (store.draftValue(KIND) as UpdateSettings | undefined)?.channel || "stable");
|
|
const error = computed(() => store.pageErrorFor(KIND));
|
|
|
|
const channels = [
|
|
{ value: "stable", label: "Stable" },
|
|
{ value: "next", label: "Prereleases" },
|
|
{ value: "exact-pin", label: "Pinned" },
|
|
];
|
|
</script>
|
|
|
|
<template>
|
|
<KindGate v-if="!form" :kind="KIND" />
|
|
<Section v-if="form" title="Updates">
|
|
<Alert v-if="error" variant="destructive" class="mb-2"><AlertDescription>{{ error }}</AlertDescription></Alert>
|
|
<FieldGroup class="@container/field-group">
|
|
<form.Field v-slot="{ field }" name="channel">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel>Release channel</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<ToggleGroup
|
|
type="single"
|
|
variant="outline"
|
|
size="sm"
|
|
:model-value="channel"
|
|
aria-label="Release channel"
|
|
@update:model-value="(value) => { if (value) field.handleChange(value); }"
|
|
>
|
|
<ToggleGroupItem v-for="option in channels" :key="option.value" :value="option.value">{{ option.label }}</ToggleGroupItem>
|
|
</ToggleGroup>
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
<form.Field v-if="channel === 'exact-pin'" v-slot="{ field }" name="pin">
|
|
<Field orientation="responsive" :data-invalid="fieldInvalid(field)">
|
|
<FieldContent><FieldLabel for="update-pin">Version</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
id="update-pin"
|
|
:model-value="field.state.value"
|
|
class="max-w-40 font-mono"
|
|
placeholder="1.48.0"
|
|
:aria-invalid="fieldInvalid(field)"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
</FieldGroup>
|
|
</Section>
|
|
</template>
|