49 lines
1.8 KiB
Vue
49 lines
1.8 KiB
Vue
<script setup lang="ts">
|
|
import { computed, onMounted } from "vue";
|
|
|
|
import { Section } from "@/components/ui/section";
|
|
import { Input } from "@/components/ui/input";
|
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
|
import { SettingRow } from "@/components/ui/setting-row";
|
|
import { useSettingsStore } from "@/stores/settings";
|
|
|
|
const KIND = "update-settings";
|
|
type UpdateSettings = { channel: string; pin: string };
|
|
|
|
const store = useSettingsStore();
|
|
onMounted(store.load);
|
|
|
|
const draft = computed(() => store.drafts[KIND]?.value as UpdateSettings | undefined);
|
|
const error = computed(() => store.pageErrorFor(KIND));
|
|
|
|
const channels = [
|
|
{ value: "stable", label: "Stable" },
|
|
{ value: "next", label: "Prereleases" },
|
|
{ value: "exact-pin", label: "Pinned" },
|
|
];
|
|
const channel = computed({
|
|
get: () => draft.value?.channel || "stable",
|
|
set: (value: string) => {
|
|
if (draft.value) draft.value.channel = value;
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<Section v-if="draft" title="Updates">
|
|
<p v-if="error" class="mb-2 text-sm text-danger" role="alert">{{ error }}</p>
|
|
<SettingRow label="Release channel">
|
|
<div class="flex justify-end">
|
|
<ToggleGroup type="single" variant="outline" size="sm" :model-value="channel" aria-label="Release channel" @update:model-value="(value) => { if (value) channel = value as typeof channel; }">
|
|
<ToggleGroupItem v-for="option in channels" :key="option.value" :value="option.value">{{ option.label }}</ToggleGroupItem>
|
|
</ToggleGroup>
|
|
</div>
|
|
</SettingRow>
|
|
<SettingRow v-if="channel === 'exact-pin'" label="Version" for="update-pin">
|
|
<div class="flex justify-end">
|
|
<Input id="update-pin" v-model="draft.pin" class="max-w-40 font-mono" placeholder="1.48.0" />
|
|
</div>
|
|
</SettingRow>
|
|
</Section>
|
|
</template>
|