feat(webui): Settings > History, and a resizable Settings sidebar
History replaces the Audit card on every settings page: one change log for all settings, filterable by section, actor and time window, with the filters in the query so each page's History link opens it filtered to that page. Rows show the old and new value as a diff and expand to the full value; Restore still puts a resource back to the version before a change. The sidebar's edge drags (or takes arrow keys) between 180 and 420px, resets on double-click and remembers its width per browser.
This commit is contained in:
1 parent
5b06f0b42a
commit
9639e7041e
20 files changed
+416
-166
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted } from "vue";
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import { hidden } from "@/lib/capabilities";
|
||||
@@ -12,6 +12,45 @@ import SettingsSaveBar from "./SettingsSaveBar.vue";
|
||||
const route = useRoute();
|
||||
const items = computed(() => settingsNav(hidden.value));
|
||||
|
||||
// The sidebar's width, dragged or keyed on its edge, kept per browser.
|
||||
const MIN_WIDTH = 180;
|
||||
const MAX_WIDTH = 420;
|
||||
const DEFAULT_WIDTH = 240;
|
||||
const WIDTH_KEY = "archie.settingsSidebarWidth";
|
||||
const clampWidth = (w: number) => Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, Math.round(w)));
|
||||
const width = ref(clampWidth(Number(localStorage.getItem(WIDTH_KEY)) || DEFAULT_WIDTH));
|
||||
watch(width, (w) => localStorage.setItem(WIDTH_KEY, String(w)));
|
||||
|
||||
function startResize(event: PointerEvent) {
|
||||
event.preventDefault();
|
||||
const handle = event.currentTarget as HTMLElement;
|
||||
const startX = event.clientX;
|
||||
const startWidth = width.value;
|
||||
handle.setPointerCapture(event.pointerId);
|
||||
const move = (e: PointerEvent) => (width.value = clampWidth(startWidth + e.clientX - startX));
|
||||
const stop = () => {
|
||||
handle.removeEventListener("pointermove", move);
|
||||
handle.removeEventListener("pointerup", stop);
|
||||
handle.removeEventListener("pointercancel", stop);
|
||||
};
|
||||
handle.addEventListener("pointermove", move);
|
||||
handle.addEventListener("pointerup", stop);
|
||||
handle.addEventListener("pointercancel", stop);
|
||||
}
|
||||
|
||||
function keyResize(event: KeyboardEvent) {
|
||||
const step = event.shiftKey ? 48 : 16;
|
||||
const next: Record<string, number> = {
|
||||
ArrowLeft: width.value - step,
|
||||
ArrowRight: width.value + step,
|
||||
Home: MIN_WIDTH,
|
||||
End: MAX_WIDTH,
|
||||
};
|
||||
if (!(event.key in next)) return;
|
||||
event.preventDefault();
|
||||
width.value = clampWidth(next[event.key]!);
|
||||
}
|
||||
|
||||
// Drafts live in the store, so moving between Settings pages keeps them;
|
||||
// leaving Settings, or the page, with edits unsaved asks first.
|
||||
const store = useControlPlaneStore();
|
||||
@@ -31,15 +70,17 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex gap-10 max-lg:flex-col max-lg:gap-4">
|
||||
<div class="flex max-lg:flex-col max-lg:gap-4" :style="{ '--sidebar-w': `${width}px` }">
|
||||
<nav
|
||||
id="settings-sidebar"
|
||||
aria-label="Settings"
|
||||
class="w-60 shrink-0 max-lg:-mx-4 max-lg:w-auto max-lg:scroll-fade-x max-lg:overflow-x-auto max-lg:[scrollbar-width:none] max-lg:border-b max-lg:px-4"
|
||||
class="shrink-0 lg:w-[var(--sidebar-w)] max-lg:-mx-4 max-lg:w-auto max-lg:scroll-fade-x max-lg:overflow-x-auto max-lg:[scrollbar-width:none] max-lg:border-b max-lg:px-4"
|
||||
>
|
||||
<ul class="flex flex-col gap-0.5 lg:sticky lg:top-20 max-lg:flex-row max-lg:gap-1">
|
||||
<li v-for="(item, index) in items" :key="item.path" class="contents">
|
||||
<hr v-if="item.dividerBefore === ''" class="my-4 border-border max-lg:hidden" />
|
||||
<p
|
||||
v-if="item.dividerBefore"
|
||||
v-else-if="item.dividerBefore"
|
||||
:class="cn('mb-1.5 px-3 text-[11px] font-medium tracking-[0.06em] text-fg-subtle uppercase max-lg:hidden', index > 0 && 'mt-5')"
|
||||
>
|
||||
{{ item.dividerBefore }}
|
||||
@@ -60,7 +101,26 @@ onBeforeUnmount(() => {
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="min-w-0 max-w-[960px] flex-1">
|
||||
<div
|
||||
role="separator"
|
||||
aria-orientation="vertical"
|
||||
aria-label="Resize settings sidebar"
|
||||
aria-controls="settings-sidebar"
|
||||
:aria-valuenow="width"
|
||||
:aria-valuemin="MIN_WIDTH"
|
||||
:aria-valuemax="MAX_WIDTH"
|
||||
tabindex="0"
|
||||
class="group relative w-10 shrink-0 cursor-col-resize touch-none outline-none max-lg:hidden"
|
||||
@pointerdown="startResize"
|
||||
@keydown="keyResize"
|
||||
@dblclick="width = DEFAULT_WIDTH"
|
||||
>
|
||||
<span
|
||||
class="absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-transparent transition-colors group-hover:bg-border-strong group-focus-visible:bg-primary group-active:bg-primary"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
<div class="min-w-0 flex-1" :class="route.meta.wide ? '' : 'max-w-[960px]'">
|
||||
<RestartPendingBanner />
|
||||
<!-- Room below the last setting, so it can be scrolled up to eye level. -->
|
||||
<div class="pb-[40vh]">
|
||||
|
||||
Reference in new issue
Block a user