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.
62 lines
2.2 KiB
Vue
62 lines
2.2 KiB
Vue
<script setup lang="ts">
|
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
import ApplyStatusRows from "./ApplyStatusRows.vue";
|
|
import { computed, onMounted } from "vue";
|
|
import { storeToRefs } from "pinia";
|
|
|
|
import PageHeader from "@/base/PageHeader.vue";
|
|
import { Textarea } from "@/components/ui/textarea";
|
|
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
|
|
import { Section } from "@/components/ui/section";
|
|
import DraftHint from "./DraftHint.vue";
|
|
import HistoryLink from "./HistoryLink.vue";
|
|
import KindGate from "./KindGate.vue";
|
|
import { fieldInvalid } from "./settings-form";
|
|
|
|
const KIND = "soul";
|
|
|
|
const store = useSettingsStore();
|
|
const { catalog, catalogError } = storeToRefs(store);
|
|
onMounted(store.load);
|
|
|
|
const resources = computed(() => resourcesForPage(catalog.value, "soul"));
|
|
const form = computed(() => store.formFor(KIND));
|
|
const soul = computed(() => store.draftValue(KIND) as { text: string } | undefined);
|
|
const error = computed(() => store.pageErrorFor(KIND));
|
|
const chars = computed(() => soul.value?.text.length ?? 0);
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<PageHeader title="Instructions">
|
|
<HistoryLink :kinds="resources.map((r) => r.kind)" />
|
|
</PageHeader>
|
|
<ApplyStatusRows v-for="resource in resources" :key="resource.kind" :kind="resource.kind" class="mb-4" />
|
|
|
|
<Alert v-if="catalogError || error" variant="destructive" class="mb-4"><AlertDescription>
|
|
{{ catalogError || error }}
|
|
</AlertDescription></Alert>
|
|
|
|
<KindGate v-if="!form" :kind="KIND" />
|
|
<Section v-if="form && soul">
|
|
<form.Field v-slot="{ field }" name="text">
|
|
<div class="flex justify-end">
|
|
<DraftHint :kind="KIND" path="text" />
|
|
</div>
|
|
<Textarea
|
|
id="soul-text"
|
|
:model-value="field.state.value"
|
|
:rows="18"
|
|
class="mt-1 font-mono text-label"
|
|
aria-label="Instructions"
|
|
:aria-invalid="fieldInvalid(field)"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
</form.Field>
|
|
<p class="mt-1.5 text-caption text-fg-subtle">
|
|
{{ chars.toLocaleString() }} chars · ~{{ Math.round(chars / 4).toLocaleString() }} tokens</p>
|
|
</Section>
|
|
</div>
|
|
</template>
|