From a54654b0c8eb1771e614807c69111ab143c9455c Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 22 Nov 2026 02:32:12 +1100 Subject: [PATCH 1/7] fix(ui/data-table): lay out columns at fixed widths with middle-aligned rows (#2023) Columns take a width from their definition, the first one takes the rest, and a column can hide below a breakpoint. Rows may carry a right-click menu. --- ui/src/audit/AuditPage.vue | 6 +- ui/src/audit/DenialsPage.vue | 14 +- ui/src/base/LogTable.vue | 12 +- ui/src/components/ui/data-table/DataTable.vue | 34 +++-- ui/src/components/ui/data-table/types.ts | 6 + ui/src/org/OrgUsagePage.vue | 30 ++-- ui/src/schedules/SchedulesPage.vue | 4 +- ui/src/tasks/TaskTable.vue | 6 +- ui/src/workflows/WorkflowDocumentPage.vue | 129 ------------------ ...orkflowPage.vue => WorkflowEditorPage.vue} | 0 ui/src/workflows/WorkflowListPage.vue | 126 ----------------- ui/src/workflows/WorkflowRuns.vue | 6 +- 12 files changed, 71 insertions(+), 302 deletions(-) delete mode 100644 ui/src/workflows/WorkflowDocumentPage.vue rename ui/src/workflows/{WorkflowPage.vue => WorkflowEditorPage.vue} (100%) delete mode 100644 ui/src/workflows/WorkflowListPage.vue diff --git a/ui/src/audit/AuditPage.vue b/ui/src/audit/AuditPage.vue index 2446e9f4e..61fa2d7c7 100644 --- a/ui/src/audit/AuditPage.vue +++ b/ui/src/audit/AuditPage.vue @@ -82,9 +82,9 @@ const queryKey = computed(() => JSON.stringify(query.value)); const columns: DataTableColumn[] = [ { id: "event", label: "Event", fixed: true, class: "whitespace-normal" }, - { id: "target", label: "Target", fixed: true, class: "hidden sm:table-cell" }, - { id: "actor", label: "Actor", fixed: true, class: "hidden sm:table-cell" }, - { id: "when", label: "When", fixed: true, class: "hidden sm:table-cell" }, + { id: "target", label: "Target", fixed: true, hide: "sm", width: "14rem" }, + { id: "actor", label: "Actor", fixed: true, hide: "sm", width: "12rem" }, + { id: "when", label: "When", fixed: true, hide: "sm", width: "9rem" }, ]; const status = ref(""); diff --git a/ui/src/audit/DenialsPage.vue b/ui/src/audit/DenialsPage.vue index 8e3e96cb0..4a0fd888e 100644 --- a/ui/src/audit/DenialsPage.vue +++ b/ui/src/audit/DenialsPage.vue @@ -18,13 +18,13 @@ const store = useDenialsStore(); const { denials, loading, error } = storeToRefs(store); const columns: DataTableColumn[] = [ - { id: "at", label: "When", fixed: true, sort: (d) => d.at }, - { id: "principal", label: "Principal", fixed: true, class: "whitespace-normal" }, - { id: "action", label: "Action" }, - { id: "resource", label: "Resource", class: "whitespace-normal" }, - { id: "level", label: "Level" }, - { id: "policies", label: "Deciding policies", class: "hidden md:table-cell whitespace-normal" }, - { id: "count", label: "Count", sort: (d) => d.count }, + { id: "at", label: "When", fixed: true, width: "9rem", sort: (d) => d.at }, + { id: "principal", label: "Principal", fixed: true, width: "auto", class: "whitespace-normal" }, + { id: "action", label: "Action", width: "12rem" }, + { id: "resource", label: "Resource", width: "14rem", class: "whitespace-normal" }, + { id: "level", label: "Level", width: "6rem" }, + { id: "policies", label: "Deciding policies", hide: "md", width: "14rem", class: "whitespace-normal" }, + { id: "count", label: "Count", width: "6rem", sort: (d) => d.count }, ]; onMounted(() => void store.load()); diff --git a/ui/src/base/LogTable.vue b/ui/src/base/LogTable.vue index d39bffedf..1100a7c8d 100644 --- a/ui/src/base/LogTable.vue +++ b/ui/src/base/LogTable.vue @@ -35,12 +35,12 @@ const props = withDefaults( const position = computed(() => new Map(props.entries.map((entry, i) => [entry, i]))); const columns: DataTableColumn[] = [ - { id: "time", label: "Time", fixed: true, class: "w-0 whitespace-nowrap", sort: (e) => position.value.get(e) ?? 0 }, - { id: "level", label: "Level", fixed: true, class: "w-0" }, - { id: "service", label: "Service", hidden: !props.services, class: "w-0 whitespace-nowrap" }, - { id: "component", label: "Component", hidden: !props.services, class: "w-0 whitespace-nowrap" }, - { id: "stage", label: "Stage", hidden: props.services, class: "w-0 whitespace-nowrap" }, - { id: "message", label: "Message", fixed: true, class: "whitespace-normal" }, + { id: "time", label: "Time", fixed: true, width: "9rem", sort: (e) => position.value.get(e) ?? 0 }, + { id: "level", label: "Level", fixed: true, width: "6rem" }, + { id: "service", label: "Service", hidden: !props.services, width: "8rem" }, + { id: "component", label: "Component", hidden: !props.services, width: "9rem" }, + { id: "stage", label: "Stage", hidden: props.services, width: "9rem" }, + { id: "message", label: "Message", fixed: true, width: "auto", class: "whitespace-normal" }, ]; // received_at restates the time; the rest have columns. const shown = new Set(["received_at", "stage", "service", "component", ...props.omit]); diff --git a/ui/src/components/ui/data-table/DataTable.vue b/ui/src/components/ui/data-table/DataTable.vue index d516b1bdf..1c52cf568 100644 --- a/ui/src/components/ui/data-table/DataTable.vue +++ b/ui/src/components/ui/data-table/DataTable.vue @@ -11,13 +11,16 @@ import { DropdownMenuContent, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; +import { cn } from "@/lib/utils"; +import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from "@/components/ui/context-menu"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import type { DataTableColumn } from "./types"; /** * A table whose optional columns the operator chooses, remembered per browser * under `storageKey`. Cells render through `#cell-` slots, given the row; - * `#actions` fills a trailing cell and `#empty` replaces the body when there + * `#menu` fills a right-click menu with ContextMenuItems, `#actions` fills a + * trailing cell and `#empty` replaces the body when there * are no rows. With `rowLink`, the whole row opens that route, so controls * inside a cell must stop their click and keydown events. With a `#detail` * slot and no `rowLink`, a row opens in place to show its detail beneath it. @@ -35,7 +38,7 @@ const props = defineProps<{ /** The sort the table opens with, on a column that has one. */ initialSort?: { id: string; desc: boolean }; }>(); -const slots = defineSlots unknown> & { empty?: () => unknown; actions?: (props: { row: Row }) => unknown; detail?: (props: { row: Row }) => unknown }>(); +const slots = defineSlots unknown> & { empty?: () => unknown; actions?: (props: { row: Row }) => unknown; detail?: (props: { row: Row }) => unknown; menu?: (props: { row: Row }) => unknown }>(); const router = useRouter(); const chosen = useLocalStorage( @@ -72,6 +75,12 @@ const sorted = computed(() => { const ariaSort = (id: string) => (sortBy.value?.id !== id ? "none" : sortBy.value.desc ? "descending" : "ascending"); const sortIcon = (id: string) => (sortBy.value?.id !== id ? ArrowUpDown : sortBy.value.desc ? ArrowDown : ArrowUp); +// A fixed layout: the first column takes what the others leave. +const grows = computed(() => (props.columns.some((c) => c.width === "auto") ? "auto" : props.columns[0]?.id)); +const width = (column: DataTableColumn) => + column.width === "auto" || (!column.width && grows.value === column.id) ? undefined : { width: column.width ?? "10rem" }; +const hidden = (column: DataTableColumn) => (column.hide ? (column.hide === "sm" ? "max-sm:hidden" : "max-md:hidden") : undefined); + const expandable = computed(() => !props.rowLink && !!slots.detail); const expanded = ref(new Set()); function open(row: Row): void { @@ -90,13 +99,17 @@ function open(row: Row): void {