The Settings save flow tracked dirty fields but did not consult validity:
each page validated in a local computed the save bar could not see, so an
invalid draft could be saved and the server refused it a round-trip later.
The rules now live once in ui/src/settings/validation.ts, the store derives
invalidFields from the same draft diff as dirtyKinds, and the save bar lists
the invalid fields and refuses Save. The route-leave guard still reads the
one dirty model, so the two can never disagree.
Every edited field also shows its former value inline ("was 1m0s") from the
same per-kind diff, via a new DraftHint component.
The per-kind diff is now a cached computed, so the hint, the save bar and
the guard share one computation per change instead of one per consumer.
24 lines
785 B
Vue
24 lines
785 B
Vue
<script setup lang="ts">
|
|
import { computed } from "vue";
|
|
|
|
import { useControlPlaneStore } from "@/stores/control-plane";
|
|
import { formatValue } from "./changes";
|
|
|
|
/**
|
|
* The previous value of an edited field, inline at the control: "was 1m0s".
|
|
*
|
|
* It reads the same per-kind diff the save bar and the route guard read, so
|
|
* the hint, the review drawer and the dirty count can never disagree about
|
|
* whether a field changed.
|
|
*/
|
|
const props = defineProps<{ kind: string; path: string }>();
|
|
const store = useControlPlaneStore();
|
|
const change = computed(() => store.changeFor(props.kind, props.path));
|
|
</script>
|
|
|
|
<template>
|
|
<span v-if="change" class="text-xs whitespace-nowrap text-fg-subtle">
|
|
was <s class="font-mono">{{ formatValue(change.before) }}</s>
|
|
</span>
|
|
</template>
|