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.
110 lines
4.7 KiB
Vue
110 lines
4.7 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 { Button } from "@/components/ui/button";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
|
import PageHeader from "@/base/PageHeader.vue";
|
|
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
|
|
import { useSessionStore } from "@/stores/session";
|
|
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
|
|
import DraftHint from "./DraftHint.vue";
|
|
import HistoryLink from "./HistoryLink.vue";
|
|
import KindGate from "./KindGate.vue";
|
|
import SecretRefField from "./SecretRefField.vue";
|
|
|
|
const POLICY = "task-policy";
|
|
|
|
const store = useSettingsStore();
|
|
const { catalog, catalogError } = storeToRefs(store);
|
|
onMounted(store.load);
|
|
|
|
// A secret reference resolves against the instance's engines, so only the
|
|
// system org names one; another org signs with its credential binding.
|
|
const instance = computed(() => useSessionStore().sections?.settings !== false);
|
|
const resources = computed(() => resourcesForPage(catalog.value, "alerts"));
|
|
const form = computed(() => store.formFor(POLICY));
|
|
const policy = computed(() => store.draftValue(POLICY));
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<PageHeader title="Alert webhook">
|
|
<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 || store.pageErrorFor(POLICY)" variant="destructive" class="mb-4"><AlertDescription>
|
|
{{ catalogError || store.pageErrorFor(POLICY) }}
|
|
</AlertDescription></Alert>
|
|
|
|
<KindGate v-if="!form" :kind="POLICY" />
|
|
<FieldGroup v-if="form && policy" class="@container/field-group">
|
|
<form.Field v-slot="{ field }" name="notify_webhook">
|
|
<Field orientation="responsive">
|
|
<FieldContent>
|
|
<FieldLabel for="task-notify">Alert webhook</FieldLabel>
|
|
<FieldDescription>Receives each raised and resolved alert. Empty disables.</FieldDescription>
|
|
</FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
id="task-notify"
|
|
:model-value="field.state.value"
|
|
type="url"
|
|
class="max-w-md"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="POLICY" path="notify_webhook" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="notify_min_severity">
|
|
<Field orientation="responsive">
|
|
<FieldContent>
|
|
<FieldLabel>Webhook severity</FieldLabel>
|
|
<FieldDescription>Minimum severity.</FieldDescription>
|
|
</FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Select
|
|
:model-value="field.state.value || 'warning'"
|
|
@update:model-value="field.handleChange(String($event))"
|
|
>
|
|
<SelectTrigger class="w-40" aria-label="Webhook severity"><SelectValue /></SelectTrigger>
|
|
<SelectContent>
|
|
<SelectItem value="info">Info</SelectItem>
|
|
<SelectItem value="warning">Warning</SelectItem>
|
|
<SelectItem value="action">Needs attention</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
<DraftHint :kind="POLICY" path="notify_min_severity" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-if="instance" v-slot="{ field }" name="notify_secret">
|
|
<Field orientation="responsive">
|
|
<FieldContent>
|
|
<FieldLabel>Webhook signing secret</FieldLabel>
|
|
<FieldDescription>Signs each payload in X-Archie-Signature. Not set sends unsigned.</FieldDescription>
|
|
</FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<SecretRefField
|
|
v-if="field.state.value"
|
|
:model-value="field.state.value"
|
|
id-prefix="task-notify-secret"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<Button v-else variant="outline" size="sm" @click="field.handleChange({ engine: '', key: '' })">Set reference</Button>
|
|
<DraftHint :kind="POLICY" path="notify_secret" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
</FieldGroup>
|
|
</div>
|
|
</template>
|