@lumerahq/ui 0.13.0-dev.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import React__default, { useContext, createContext, forwardRef, createElement, memo, useId as useId$1, useTransition, useMemo, useRef, useEffect, useState, cloneElement, isValidElement, useCallback, Suspense, lazy, Fragment as Fragment$1, useLayoutEffect } from "react";
4
- import { u as useAgentChat, a as useAgentChatSessions, b as useAuditLog, c as useAutomationRun } from "./use-automation-run-Vo2NXx-h.js";
4
+ import { u as useAgentChat, a as useAgentChatSessions, g as getRecordAuditLogSnapshot, d as auditLogSummaryWithCollectionLabel, e as auditLogDetailValue, f as auditLogActorLabel, n as normalizeRecordAuditCollections, h as normalizeAuditLogFilterState, A as AUDIT_LOG_MAX_COLLECTIONS, b as useAuditLog, i as fetchRecordAuditLogCsv, j as normalizeAuditLogExportLimit, c as useAutomationRun } from "./use-automation-run-D6DIaHy3.js";
5
5
  import { t as twMerge, p as clsx, o as cn$2, a as formatCellValue$2 } from "./formatters-D4T821Dv.js";
6
- import { f as getDownloadUrl, t as pbSql, p as parentApiRequest, d as parentApiStream, B as BridgeError, a0 as getRecordAuditLogSnapshot, a4 as auditLogSummaryWithCollectionLabel, Z as auditLogActorLabel, a5 as auditLogDetailValue, a2 as normalizeRecordAuditCollections, a6 as normalizeAuditLogFilterState, Y as AUDIT_LOG_MAX_COLLECTIONS, _ as auditLogRequestedCollectionName, $ as fetchRecordAuditLogCsv, a7 as normalizeAuditLogExportLimit, z as automationStatuses, L as getAutomationRunFileDownloadUrl, R as listAutomationRunFiles } from "./automations-DOek1EjJ.js";
6
+ import { f as getDownloadUrl, v as pbSql, p as parentApiRequest, d as parentApiStream, B as BridgeError, C as automationStatuses, N as getAutomationRunFileDownloadUrl, T as listAutomationRunFiles } from "./automations-DGUEnAYR.js";
7
7
  import * as ReactDOM from "react-dom";
8
8
  import { createPortal } from "react-dom";
9
9
  import { useQuery } from "@tanstack/react-query";
@@ -24050,7 +24050,7 @@ var lr = (e) => {
24050
24050
  for (; t > 0 && e[t - 1] === `
24051
24051
  `; ) t--;
24052
24052
  return e.slice(0, t);
24053
- }, cr = lazy(() => import("./highlighted-body-OFNGDK62-CkZgLnjq.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), st = ({ code: e, language: t, className: o, children: n, isIncomplete: r = false, startLine: s2, lineNumbers: a, ...l }) => {
24053
+ }, cr = lazy(() => import("./highlighted-body-OFNGDK62-V6FEuBTg.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), st = ({ code: e, language: t, className: o, children: n, isIncomplete: r = false, startLine: s2, lineNumbers: a, ...l }) => {
24054
24054
  let i = y2(), d2 = useMemo(() => lr(e), [e]), c2 = useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: d2.split(`
24055
24055
  `).map((p2) => [{ content: p2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [d2]);
24056
24056
  return jsx(nt.Provider, { value: { code: e }, children: jsxs(ot, { isIncomplete: r, language: t, children: [jsx(rt, { language: t }), n ? jsx("div", { className: i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"), children: jsx("div", { className: i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"), "data-streamdown": "code-block-actions", children: n }) }) : null, jsx(Suspense, { fallback: jsx(At, { className: o, language: t, lineNumbers: a, result: c2, startLine: s2, ...l }), children: jsx(cr, { className: o, code: d2, language: t, lineNumbers: a, raw: c2, startLine: s2, ...l }) })] }) });
@@ -24412,7 +24412,7 @@ var vo = ({ children: e, className: t, showControls: o, showCopy: n = true, show
24412
24412
  let l = y2(), i = o && n, d2 = o && r, c2 = o && s2, p2 = i || d2 || c2;
24413
24413
  return jsxs("div", { className: l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"), "data-streamdown": "table-wrapper", children: [p2 ? jsxs("div", { className: l("flex items-center justify-end gap-1"), children: [i ? jsx(Te, {}) : null, d2 ? jsx(Pe, {}) : null, c2 ? jsx(Co, { showCopy: i, showDownload: d2, children: e }) : null] }) : null, jsx("div", { className: l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"), children: jsx("table", { className: l("w-full divide-y divide-border", t), "data-streamdown": "table", ...a, children: e }) })] });
24414
24414
  };
24415
- var es = /startLine=(\d+)/, ts = /\bnoLineNumbers\b/, os = lazy(() => import("./mermaid-GHXKKRXX-DXYmvmZa.js").then((e) => ({ default: e.Mermaid }))), ns = /language-([^\s]+)/;
24415
+ var es = /startLine=(\d+)/, ts = /\bnoLineNumbers\b/, os = lazy(() => import("./mermaid-GHXKKRXX-AvjGDhsO.js").then((e) => ({ default: e.Mermaid }))), ns = /language-([^\s]+)/;
24416
24416
  function qe(e, t) {
24417
24417
  if (!(e != null && e.position || t != null && t.position)) return true;
24418
24418
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -29592,11 +29592,10 @@ function FieldValue({ field }) {
29592
29592
  ] }) : null
29593
29593
  ] });
29594
29594
  }
29595
- function FieldList({ fields, snapshotSide }) {
29595
+ function FieldList({ fields }) {
29596
29596
  return /* @__PURE__ */ jsx("dl", { className: "divide-y divide-border/70", children: fields.map((field, index2) => /* @__PURE__ */ jsxs(
29597
29597
  "div",
29598
29598
  {
29599
- "data-audit-log-snapshot-field": snapshotSide ? fieldKey(field) : void 0,
29600
29599
  className: "grid gap-1 py-2.5 sm:grid-cols-[9rem_1fr] sm:gap-4",
29601
29600
  children: [
29602
29601
  /* @__PURE__ */ jsx("dt", { className: "text-xs font-medium text-muted-foreground", children: field.label }),
@@ -29625,14 +29624,10 @@ function FieldGroups({ fields }) {
29625
29624
  /* @__PURE__ */ jsx(FieldList, { fields: group.fields })
29626
29625
  ] }, group.title)) });
29627
29626
  }
29628
- function SnapshotSide({
29629
- side,
29630
- label,
29631
- fields
29632
- }) {
29633
- return /* @__PURE__ */ jsxs("div", { "data-audit-log-snapshot": side, className: "min-w-0 rounded-xl border bg-background p-3", children: [
29627
+ function SnapshotSide({ label, fields }) {
29628
+ return /* @__PURE__ */ jsxs("div", { className: "min-w-0 rounded-xl border bg-background p-3", children: [
29634
29629
  /* @__PURE__ */ jsx("p", { className: "mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: label }),
29635
- fields?.length ? /* @__PURE__ */ jsx(FieldList, { fields, snapshotSide: side }) : /* @__PURE__ */ jsx("p", { className: "py-3 text-sm text-muted-foreground", children: "No values" })
29630
+ fields?.length ? /* @__PURE__ */ jsx(FieldList, { fields }) : /* @__PURE__ */ jsx("p", { className: "py-3 text-sm text-muted-foreground", children: "No values" })
29636
29631
  ] });
29637
29632
  }
29638
29633
  function AuditLogEntry({
@@ -29662,8 +29657,6 @@ function AuditLogEntry({
29662
29657
  const recordHref = getRecordHref?.(entry)?.trim();
29663
29658
  const rowPadding = density === "comfortable" ? "py-4" : void 0;
29664
29659
  const summary = activityCollectionLabel ? auditLogSummaryWithCollectionLabel(entry, activityCollectionLabel) : entry.summary;
29665
- const actorLabel = auditLogActorLabel(entry.actor);
29666
- const actorTitle = [actorLabel, entry.actor.type_label, entry.actor.id ? `ID: ${entry.actor.id}` : ""].filter((value, index2, values) => value && values.indexOf(value) === index2).join("; ");
29667
29660
  const recordAction = recordHref ? /* @__PURE__ */ jsxs(
29668
29661
  "a",
29669
29662
  {
@@ -29681,7 +29674,7 @@ function AuditLogEntry({
29681
29674
  "Open record"
29682
29675
  ] }) : null;
29683
29676
  return /* @__PURE__ */ jsxs(Fragment, { children: [
29684
- /* @__PURE__ */ jsxs(TableRow, { "data-audit-log-entry": entry.id, "aria-expanded": expanded, children: [
29677
+ /* @__PURE__ */ jsxs(TableRow, { "aria-expanded": expanded, children: [
29685
29678
  /* @__PURE__ */ jsx(TableCell, { className: cn$2("text-xs text-muted-foreground", rowPadding), children: /* @__PURE__ */ jsx("time", { dateTime: entry.occurred_at, title: new Date(entry.occurred_at).toLocaleString(), children: relativeTime(entry.occurred_at) }) }),
29686
29679
  showCollectionColumn ? /* @__PURE__ */ jsx(
29687
29680
  TableCell,
@@ -29698,13 +29691,12 @@ function AuditLogEntry({
29698
29691
  /* @__PURE__ */ jsx("span", { className: segment.emphasis === "strong" ? "font-semibold" : void 0, children: segment.text })
29699
29692
  ] }, `${segment.text}-${index2}`)) })
29700
29693
  ] }) }),
29701
- showActorColumn ? /* @__PURE__ */ jsx(TableCell, { className: cn$2("max-w-48 truncate text-xs", rowPadding), title: actorTitle, children: actorLabel }) : null,
29694
+ showActorColumn ? /* @__PURE__ */ jsx(TableCell, { className: cn$2("max-w-48 truncate text-xs", rowPadding), title: auditLogActorLabel(entry.actor), children: auditLogActorLabel(entry.actor) }) : null,
29702
29695
  /* @__PURE__ */ jsx(TableCell, { className: cn$2("text-right", rowPadding), children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-0.5", children: [
29703
29696
  recordAction,
29704
29697
  /* @__PURE__ */ jsx(
29705
29698
  Button2,
29706
29699
  {
29707
- "data-audit-log-control": "details",
29708
29700
  type: "button",
29709
29701
  variant: "ghost",
29710
29702
  size: "icon-sm",
@@ -29717,7 +29709,7 @@ function AuditLogEntry({
29717
29709
  )
29718
29710
  ] }) })
29719
29711
  ] }),
29720
- expanded ? /* @__PURE__ */ jsx(TableRow, { "data-audit-log-details": entry.id, className: "hover:bg-transparent", children: /* @__PURE__ */ jsxs(
29712
+ expanded ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsxs(
29721
29713
  TableCell,
29722
29714
  {
29723
29715
  id: detailsID,
@@ -29725,7 +29717,7 @@ function AuditLogEntry({
29725
29717
  className: cn$2("bg-muted/20 whitespace-normal", density === "comfortable" ? "p-5" : "p-4"),
29726
29718
  children: [
29727
29719
  detailFields.length > 0 ? /* @__PURE__ */ jsx(FieldGroups, { fields: detailFields }) : null,
29728
- entry.has_snapshot ? /* @__PURE__ */ jsxs("div", { "data-audit-log-state": "snapshot", className: cn$2(detailFields.length > 0 && "mt-4 border-t pt-4"), children: [
29720
+ entry.has_snapshot ? /* @__PURE__ */ jsxs("div", { className: cn$2(detailFields.length > 0 && "mt-4 border-t pt-4"), children: [
29729
29721
  /* @__PURE__ */ jsx("p", { className: "mb-3 text-sm font-medium", children: "Before and after" }),
29730
29722
  snapshotQuery.isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 py-4 text-sm text-muted-foreground", children: [
29731
29723
  /* @__PURE__ */ jsx(LoaderCircle, { className: "size-4 animate-spin" }),
@@ -29734,7 +29726,6 @@ function AuditLogEntry({
29734
29726
  /* @__PURE__ */ jsx(
29735
29727
  SnapshotSide,
29736
29728
  {
29737
- side: "before",
29738
29729
  label: "Before",
29739
29730
  fields: displayFields(snapshotQuery.data.snapshot.before, fieldLabels, showSystemFields)
29740
29731
  }
@@ -29742,7 +29733,6 @@ function AuditLogEntry({
29742
29733
  /* @__PURE__ */ jsx(
29743
29734
  SnapshotSide,
29744
29735
  {
29745
- side: "after",
29746
29736
  label: "After",
29747
29737
  fields: displayFields(snapshotQuery.data.snapshot.after, fieldLabels, showSystemFields)
29748
29738
  }
@@ -42317,16 +42307,9 @@ function AuditLog({
42317
42307
  const configurationError = availableCollections.length === 0 ? "Add at least one collection to the component." : availableCollections.length > AUDIT_LOG_MAX_COLLECTIONS ? `Choose no more than ${AUDIT_LOG_MAX_COLLECTIONS} collections.` : "";
42318
42308
  const auditLog = useAuditLog(selectedCollections, requestFilters, { pageSize, enabled: !configurationError });
42319
42309
  const columnCount = 3 + Number(showCollectionColumn) + Number(showActorColumn);
42320
- const configuredNameForCollection = (collection) => auditLogRequestedCollectionName(collection, auditLog.collectionStatus);
42321
- const labelForCollection = (collection) => {
42322
- const configuredName = configuredNameForCollection(collection);
42323
- return collectionLabels?.[collection]?.trim() || collectionLabels?.[configuredName]?.trim() || configuredName;
42324
- };
42325
- const activityLabelForCollection = (collection) => {
42326
- const configuredName = configuredNameForCollection(collection);
42327
- return activityNouns?.[collection]?.trim() || activityNouns?.[configuredName]?.trim() || collectionLabels?.[collection]?.trim() || collectionLabels?.[configuredName]?.trim();
42328
- };
42329
- const currentActorOptions = useMemo(() => {
42310
+ const labelForCollection = (collection) => collectionLabels?.[collection]?.trim() || collection;
42311
+ const activityLabelForCollection = (collection) => activityNouns?.[collection]?.trim() || collectionLabels?.[collection]?.trim();
42312
+ const actorOptions = useMemo(() => {
42330
42313
  const actors = /* @__PURE__ */ new Map();
42331
42314
  for (const entry of auditLog.entries) {
42332
42315
  const actorID2 = entry.actor.id?.trim();
@@ -42336,21 +42319,12 @@ function AuditLog({
42336
42319
  ([, left], [, right]) => auditLogActorLabel(left).localeCompare(auditLogActorLabel(right))
42337
42320
  );
42338
42321
  }, [auditLog.entries]);
42339
- const selectedActorCache = useRef(null);
42340
- const currentSelectedActor = currentActorOptions.find(([actorID2]) => actorID2 === actor)?.[1];
42341
- useEffect(() => {
42342
- if (actor === "all") selectedActorCache.current = null;
42343
- else if (currentSelectedActor) selectedActorCache.current = { id: actor, actor: currentSelectedActor };
42344
- }, [actor, currentSelectedActor]);
42345
- const selectedActor = currentSelectedActor ?? (selectedActorCache.current?.id === actor ? selectedActorCache.current.actor : void 0);
42346
- const actorOptions = actor !== "all" && selectedActor && !currentSelectedActor ? [...currentActorOptions, [actor, selectedActor]].sort(
42347
- ([, left], [, right]) => auditLogActorLabel(left).localeCompare(auditLogActorLabel(right))
42348
- ) : currentActorOptions;
42349
42322
  const hasFilters = selectedCollections.length !== availableCollections.length || Boolean(filterState.event || filterState.actor || filterState.since || filterState.until);
42350
42323
  const hasDateFilter = Boolean(filterState.since || filterState.until);
42351
42324
  const status = auditLog.error?.status;
42352
42325
  const errorCopy = errorCopyFor(status);
42353
42326
  const exportStatusForFilters = exportStatus.key === filterKey && exportStatus.message ? exportStatus : null;
42327
+ const selectedActor = actorOptions.find(([actorID2]) => actorID2 === actor)?.[1];
42354
42328
  const selectedActorLabel = actor === "all" ? "All actors" : selectedActor ? auditLogActorLabel(selectedActor) : "Selected actor";
42355
42329
  const disabledCollections = auditLog.collectionStatus.filter((collection) => !collection.audit_enabled).map((collection) => labelForCollection(collection.name));
42356
42330
  const collectionSelectionLabel = selectedCollections.length === availableCollections.length ? "All collections" : selectedCollections.length === 1 ? labelForCollection(selectedCollections[0]) : `${selectedCollections.length} collections`;
@@ -42359,16 +42333,6 @@ function AuditLog({
42359
42333
  if (controlledFilters === void 0) setLocalFilters({ key: availableKey, value: normalized });
42360
42334
  onFiltersChange?.(normalized);
42361
42335
  };
42362
- const selectActor = (value) => {
42363
- if (!value) return;
42364
- if (value === "all") {
42365
- selectedActorCache.current = null;
42366
- } else {
42367
- const selected = currentActorOptions.find(([actorID2]) => actorID2 === value)?.[1];
42368
- if (selected) selectedActorCache.current = { id: value, actor: selected };
42369
- }
42370
- setFilters({ ...filterState, actor: value === "all" ? void 0 : value });
42371
- };
42372
42336
  const toggleCollection = (collection, checked) => {
42373
42337
  const next2 = new Set(selectedCollections);
42374
42338
  if (checked) next2.add(collection);
@@ -42460,353 +42424,309 @@ function AuditLog({
42460
42424
  setIsExporting(false);
42461
42425
  }
42462
42426
  };
42463
- return /* @__PURE__ */ jsxs(
42464
- "section",
42465
- {
42466
- "data-audit-log": "root",
42467
- className: cn$2("overflow-hidden rounded-2xl border bg-card text-card-foreground", className),
42468
- children: [
42469
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3 border-b px-5 py-4", children: [
42470
- /* @__PURE__ */ jsxs("div", { children: [
42471
- /* @__PURE__ */ jsx("h2", { className: "font-semibold", children: title }),
42472
- /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: "Record changes across your selected collections" })
42473
- ] }),
42474
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
42475
- /* @__PURE__ */ jsx(
42476
- Button2,
42477
- {
42478
- "data-audit-log-control": "refresh",
42479
- type: "button",
42480
- variant: "ghost",
42481
- size: "icon-sm",
42482
- "aria-label": "Refresh activity",
42483
- title: "Refresh activity",
42484
- disabled: auditLog.isFetching || Boolean(configurationError),
42485
- onClick: () => void auditLog.refresh(),
42486
- children: /* @__PURE__ */ jsx(RefreshCw, { className: cn$2(auditLog.isFetching && "animate-spin") })
42487
- }
42488
- ),
42489
- /* @__PURE__ */ jsxs(
42490
- Button2,
42491
- {
42492
- "data-audit-log-control": "export",
42493
- "data-audit-log-state": isExporting ? "exporting" : void 0,
42494
- type: "button",
42495
- variant: "outline",
42496
- size: "sm",
42497
- disabled: isExporting || auditLog.entries.length === 0,
42498
- onClick: () => void handleExport(),
42499
- children: [
42500
- isExporting ? /* @__PURE__ */ jsx(LoaderCircle, { className: "animate-spin" }) : /* @__PURE__ */ jsx(Download, {}),
42501
- isExporting ? "Exporting…" : "Export CSV"
42502
- ]
42503
- }
42504
- )
42505
- ] })
42506
- ] }),
42507
- exportStatusForFilters ? /* @__PURE__ */ jsxs(
42508
- "div",
42427
+ return /* @__PURE__ */ jsxs("section", { className: cn$2("overflow-hidden rounded-2xl border bg-card text-card-foreground", className), children: [
42428
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3 border-b px-5 py-4", children: [
42429
+ /* @__PURE__ */ jsxs("div", { children: [
42430
+ /* @__PURE__ */ jsx("h2", { className: "font-semibold", children: title }),
42431
+ /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: "Record changes across your selected collections" })
42432
+ ] }),
42433
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
42434
+ /* @__PURE__ */ jsx(
42435
+ Button2,
42509
42436
  {
42510
- "data-audit-log-state": exportStatusForFilters.tone === "success" ? "exported" : "export-error",
42511
- className: cn$2(
42512
- "flex gap-2 border-b px-5 py-2.5 text-xs",
42513
- exportStatusForFilters.tone === "success" ? "bg-emerald-50 text-emerald-950" : "bg-rose-50 text-rose-950"
42514
- ),
42515
- role: "status",
42516
- "aria-live": "polite",
42437
+ type: "button",
42438
+ variant: "ghost",
42439
+ size: "icon-sm",
42440
+ "aria-label": "Refresh activity",
42441
+ title: "Refresh activity",
42442
+ disabled: auditLog.isFetching || Boolean(configurationError),
42443
+ onClick: () => void auditLog.refresh(),
42444
+ children: /* @__PURE__ */ jsx(RefreshCw, { className: cn$2(auditLog.isFetching && "animate-spin") })
42445
+ }
42446
+ ),
42447
+ /* @__PURE__ */ jsxs(
42448
+ Button2,
42449
+ {
42450
+ type: "button",
42451
+ variant: "outline",
42452
+ size: "sm",
42453
+ disabled: isExporting || auditLog.entries.length === 0,
42454
+ onClick: () => void handleExport(),
42517
42455
  children: [
42518
- exportStatusForFilters.tone === "success" ? /* @__PURE__ */ jsx(CircleCheck, { className: "mt-0.5 size-4 shrink-0" }) : /* @__PURE__ */ jsx(CircleAlert, { className: "mt-0.5 size-4 shrink-0" }),
42519
- /* @__PURE__ */ jsx("p", { children: exportStatusForFilters.message })
42456
+ isExporting ? /* @__PURE__ */ jsx(LoaderCircle, { className: "animate-spin" }) : /* @__PURE__ */ jsx(Download, {}),
42457
+ "Export CSV"
42520
42458
  ]
42521
42459
  }
42522
- ) : null,
42523
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-end gap-2 border-b bg-muted/20 px-5 py-3", children: [
42524
- availableCollections.length > 1 ? /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42525
- /* @__PURE__ */ jsx(Label, { className: "text-xs text-muted-foreground", children: "Collections" }),
42526
- /* @__PURE__ */ jsxs(DropdownMenu, { children: [
42527
- /* @__PURE__ */ jsxs(
42528
- DropdownMenuTrigger,
42529
- {
42530
- "data-audit-log-control": "collections",
42531
- render: /* @__PURE__ */ jsx(Button2, { type: "button", variant: "outline", size: "sm", className: "w-[11rem] justify-start" }),
42532
- children: [
42533
- /* @__PURE__ */ jsx(ListFilter, {}),
42534
- /* @__PURE__ */ jsx("span", { className: "truncate", children: collectionSelectionLabel })
42535
- ]
42536
- }
42537
- ),
42538
- /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", className: "w-64", children: [
42539
- /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
42540
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Select collections" }),
42541
- availableCollections.map((collection) => {
42542
- const checked = selectedCollections.includes(collection);
42543
- return /* @__PURE__ */ jsx(
42544
- DropdownMenuCheckboxItem,
42545
- {
42546
- checked,
42547
- disabled: checked && selectedCollections.length === 1,
42548
- onCheckedChange: (value) => toggleCollection(collection, value === true),
42549
- children: /* @__PURE__ */ jsx("span", { className: "truncate", title: collection, children: labelForCollection(collection) })
42550
- },
42551
- collection
42552
- );
42553
- })
42554
- ] }),
42555
- hasFilters ? /* @__PURE__ */ jsxs(Fragment, { children: [
42556
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
42557
- /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: resetFilters, children: [
42558
- /* @__PURE__ */ jsx(FunnelX, {}),
42559
- "Reset filters"
42560
- ] })
42561
- ] }) : null
42562
- ] })
42563
- ] })
42564
- ] }) : null,
42565
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42566
- /* @__PURE__ */ jsx(Label, { htmlFor: fromID, className: "text-xs text-muted-foreground", children: "From" }),
42567
- /* @__PURE__ */ jsx(
42568
- Input2,
42569
- {
42570
- "data-audit-log-control": "from",
42571
- id: fromID,
42572
- "aria-label": "From date and time in your local timezone",
42573
- type: "datetime-local",
42574
- step: "60",
42575
- value: fromDateTime,
42576
- max: untilDateTime || void 0,
42577
- className: "h-8 w-[12rem] text-xs",
42578
- onChange: (inputEvent) => setFilters({ ...filterState, since: dateTimeBoundary(inputEvent.target.value) })
42579
- }
42580
- )
42581
- ] }),
42582
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42583
- /* @__PURE__ */ jsx(Label, { htmlFor: untilID, className: "text-xs text-muted-foreground", children: "Until" }),
42584
- /* @__PURE__ */ jsx(
42585
- Input2,
42586
- {
42587
- "data-audit-log-control": "until",
42588
- id: untilID,
42589
- "aria-label": "Until date and time in your local timezone",
42590
- type: "datetime-local",
42591
- step: "60",
42592
- value: untilDateTime,
42593
- min: fromDateTime || void 0,
42594
- className: "h-8 w-[12rem] text-xs",
42595
- onChange: (inputEvent) => setFilters({ ...filterState, until: dateTimeBoundary(inputEvent.target.value) })
42596
- }
42597
- )
42598
- ] }),
42599
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42600
- /* @__PURE__ */ jsx(Label, { className: "text-xs text-muted-foreground", children: "Date presets" }),
42601
- /* @__PURE__ */ jsxs(DropdownMenu, { children: [
42602
- /* @__PURE__ */ jsxs(
42603
- DropdownMenuTrigger,
42604
- {
42605
- "data-audit-log-control": "date-presets",
42606
- render: /* @__PURE__ */ jsx(Button2, { type: "button", variant: "outline", size: "sm", className: "w-[10rem] justify-start" }),
42607
- children: [
42608
- /* @__PURE__ */ jsx(CalendarClock, {}),
42609
- "Quick range"
42610
- ]
42611
- }
42612
- ),
42613
- /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", children: [
42614
- /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => applyDatePreset("last-24-hours"), children: "Last 24 hours" }),
42615
- /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => applyDatePreset("last-7-days"), children: "Last 7 days" }),
42616
- /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => applyDatePreset("today"), children: "Today" }),
42617
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
42618
- /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => applyDatePreset("clear"), children: "Clear date range" })
42619
- ] })
42620
- ] })
42621
- ] }),
42622
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42623
- /* @__PURE__ */ jsx(Label, { htmlFor: eventID, className: "text-xs text-muted-foreground", children: "Event" }),
42624
- /* @__PURE__ */ jsxs(
42625
- Select,
42626
- {
42627
- value: event,
42628
- onValueChange: (value) => value && setFilters({ ...filterState, event: value === "all" ? void 0 : value }),
42629
- children: [
42630
- /* @__PURE__ */ jsx(
42631
- SelectTrigger2,
42632
- {
42633
- id: eventID,
42634
- "data-audit-log-control": "event",
42635
- size: "sm",
42636
- className: "w-[8.5rem] rounded-lg border-border bg-background",
42637
- children: /* @__PURE__ */ jsx(SelectValue2, { children: event === "all" ? "All events" : `${event[0].toUpperCase()}${event.slice(1)}` })
42638
- }
42639
- ),
42640
- /* @__PURE__ */ jsxs(SelectContent, { children: [
42641
- /* @__PURE__ */ jsx(SelectItem2, { value: "all", children: "All events" }),
42642
- /* @__PURE__ */ jsx(SelectItem2, { value: "created", children: "Created" }),
42643
- /* @__PURE__ */ jsx(SelectItem2, { value: "updated", children: "Updated" }),
42644
- /* @__PURE__ */ jsx(SelectItem2, { value: "deleted", children: "Deleted" })
42645
- ] })
42646
- ]
42647
- }
42648
- )
42649
- ] }),
42650
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42651
- /* @__PURE__ */ jsx(Label, { htmlFor: actorID, className: "text-xs text-muted-foreground", children: "Actor" }),
42652
- /* @__PURE__ */ jsxs(Select, { value: actor, onValueChange: selectActor, children: [
42653
- /* @__PURE__ */ jsx(
42654
- SelectTrigger2,
42655
- {
42656
- id: actorID,
42657
- "data-audit-log-control": "actor",
42658
- size: "sm",
42659
- className: "w-[11rem] rounded-lg border-border bg-background",
42660
- children: /* @__PURE__ */ jsx(SelectValue2, { children: selectedActorLabel })
42661
- }
42662
- ),
42663
- /* @__PURE__ */ jsxs(SelectContent, { children: [
42664
- /* @__PURE__ */ jsx(SelectItem2, { value: "all", children: "All actors" }),
42665
- actorOptions.map(([actorID2, option]) => /* @__PURE__ */ jsx(SelectItem2, { value: actorID2, children: auditLogActorLabel(option) }, actorID2))
42666
- ] })
42667
- ] })
42668
- ] }),
42669
- /* @__PURE__ */ jsx("span", { className: "mb-2 text-[11px] text-muted-foreground", children: "Dates use local time" }),
42670
- hasFilters ? /* @__PURE__ */ jsxs(
42671
- Button2,
42460
+ )
42461
+ ] })
42462
+ ] }),
42463
+ exportStatusForFilters ? /* @__PURE__ */ jsxs(
42464
+ "div",
42465
+ {
42466
+ className: cn$2(
42467
+ "flex gap-2 border-b px-5 py-2.5 text-xs",
42468
+ exportStatusForFilters.tone === "success" ? "bg-emerald-50 text-emerald-950" : "bg-rose-50 text-rose-950"
42469
+ ),
42470
+ role: "status",
42471
+ "aria-live": "polite",
42472
+ children: [
42473
+ exportStatusForFilters.tone === "success" ? /* @__PURE__ */ jsx(CircleCheck, { className: "mt-0.5 size-4 shrink-0" }) : /* @__PURE__ */ jsx(CircleAlert, { className: "mt-0.5 size-4 shrink-0" }),
42474
+ /* @__PURE__ */ jsx("p", { children: exportStatusForFilters.message })
42475
+ ]
42476
+ }
42477
+ ) : null,
42478
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-end gap-2 border-b bg-muted/20 px-5 py-3", children: [
42479
+ availableCollections.length > 1 ? /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42480
+ /* @__PURE__ */ jsx(Label, { className: "text-xs text-muted-foreground", children: "Collections" }),
42481
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [
42482
+ /* @__PURE__ */ jsxs(
42483
+ DropdownMenuTrigger,
42672
42484
  {
42673
- "data-audit-log-control": "reset",
42674
- type: "button",
42675
- variant: "ghost",
42676
- size: "sm",
42677
- className: "mb-px",
42678
- onPointerDown: resetFiltersFromPointer,
42679
- onClick: resetFilters,
42485
+ render: /* @__PURE__ */ jsx(Button2, { type: "button", variant: "outline", size: "sm", className: "w-[11rem] justify-start" }),
42680
42486
  children: [
42487
+ /* @__PURE__ */ jsx(ListFilter, {}),
42488
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: collectionSelectionLabel })
42489
+ ]
42490
+ }
42491
+ ),
42492
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", className: "w-64", children: [
42493
+ /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
42494
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Select collections" }),
42495
+ availableCollections.map((collection) => {
42496
+ const checked = selectedCollections.includes(collection);
42497
+ return /* @__PURE__ */ jsx(
42498
+ DropdownMenuCheckboxItem,
42499
+ {
42500
+ checked,
42501
+ disabled: checked && selectedCollections.length === 1,
42502
+ onCheckedChange: (value) => toggleCollection(collection, value === true),
42503
+ children: /* @__PURE__ */ jsx("span", { className: "truncate", title: collection, children: labelForCollection(collection) })
42504
+ },
42505
+ collection
42506
+ );
42507
+ })
42508
+ ] }),
42509
+ hasFilters ? /* @__PURE__ */ jsxs(Fragment, { children: [
42510
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
42511
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: resetFilters, children: [
42681
42512
  /* @__PURE__ */ jsx(FunnelX, {}),
42682
- " Reset filters"
42513
+ "Reset filters"
42514
+ ] })
42515
+ ] }) : null
42516
+ ] })
42517
+ ] })
42518
+ ] }) : null,
42519
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42520
+ /* @__PURE__ */ jsx(Label, { htmlFor: fromID, className: "text-xs text-muted-foreground", children: "From" }),
42521
+ /* @__PURE__ */ jsx(
42522
+ Input2,
42523
+ {
42524
+ id: fromID,
42525
+ "aria-label": "From date and time in your local timezone",
42526
+ type: "datetime-local",
42527
+ step: "60",
42528
+ value: fromDateTime,
42529
+ max: untilDateTime || void 0,
42530
+ className: "h-8 w-[12rem] text-xs",
42531
+ onChange: (inputEvent) => setFilters({ ...filterState, since: dateTimeBoundary(inputEvent.target.value) })
42532
+ }
42533
+ )
42534
+ ] }),
42535
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42536
+ /* @__PURE__ */ jsx(Label, { htmlFor: untilID, className: "text-xs text-muted-foreground", children: "Until" }),
42537
+ /* @__PURE__ */ jsx(
42538
+ Input2,
42539
+ {
42540
+ id: untilID,
42541
+ "aria-label": "Until date and time in your local timezone",
42542
+ type: "datetime-local",
42543
+ step: "60",
42544
+ value: untilDateTime,
42545
+ min: fromDateTime || void 0,
42546
+ className: "h-8 w-[12rem] text-xs",
42547
+ onChange: (inputEvent) => setFilters({ ...filterState, until: dateTimeBoundary(inputEvent.target.value) })
42548
+ }
42549
+ )
42550
+ ] }),
42551
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42552
+ /* @__PURE__ */ jsx(Label, { className: "text-xs text-muted-foreground", children: "Date presets" }),
42553
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [
42554
+ /* @__PURE__ */ jsxs(
42555
+ DropdownMenuTrigger,
42556
+ {
42557
+ render: /* @__PURE__ */ jsx(Button2, { type: "button", variant: "outline", size: "sm", className: "w-[10rem] justify-start" }),
42558
+ children: [
42559
+ /* @__PURE__ */ jsx(CalendarClock, {}),
42560
+ "Quick range"
42683
42561
  ]
42684
42562
  }
42685
- ) : null
42686
- ] }),
42687
- filterChips.length > 0 ? /* @__PURE__ */ jsxs(
42688
- "div",
42563
+ ),
42564
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", children: [
42565
+ /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => applyDatePreset("last-24-hours"), children: "Last 24 hours" }),
42566
+ /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => applyDatePreset("last-7-days"), children: "Last 7 days" }),
42567
+ /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => applyDatePreset("today"), children: "Today" }),
42568
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
42569
+ /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => applyDatePreset("clear"), children: "Clear date range" })
42570
+ ] })
42571
+ ] })
42572
+ ] }),
42573
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42574
+ /* @__PURE__ */ jsx(Label, { htmlFor: eventID, className: "text-xs text-muted-foreground", children: "Event" }),
42575
+ /* @__PURE__ */ jsxs(
42576
+ Select,
42689
42577
  {
42690
- "data-audit-log-state": "active-filters",
42691
- className: "flex flex-wrap items-center gap-2 border-b bg-muted/10 px-5 py-2 text-xs",
42578
+ value: event,
42579
+ onValueChange: (value) => value && setFilters({ ...filterState, event: value === "all" ? void 0 : value }),
42692
42580
  children: [
42693
- /* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground", children: "Active filters" }),
42694
- filterChips.map((chip) => /* @__PURE__ */ jsxs(
42695
- "span",
42696
- {
42697
- "data-audit-log-filter": chip.key,
42698
- className: "inline-flex h-6 max-w-full items-center gap-1 rounded-full border bg-background px-2 text-foreground",
42699
- children: [
42700
- /* @__PURE__ */ jsx("span", { className: "truncate", children: chip.label }),
42701
- /* @__PURE__ */ jsx(
42702
- "button",
42703
- {
42704
- type: "button",
42705
- className: "rounded-full text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:outline-none",
42706
- "aria-label": `Clear ${chip.label}`,
42707
- onClick: chip.onClear,
42708
- children: /* @__PURE__ */ jsx(X$2, { className: "size-3" })
42709
- }
42710
- )
42711
- ]
42712
- },
42713
- chip.key
42714
- ))
42581
+ /* @__PURE__ */ jsx(SelectTrigger2, { id: eventID, size: "sm", className: "w-[8.5rem] rounded-lg border-border bg-background", children: /* @__PURE__ */ jsx(SelectValue2, { children: event === "all" ? "All events" : `${event[0].toUpperCase()}${event.slice(1)}` }) }),
42582
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
42583
+ /* @__PURE__ */ jsx(SelectItem2, { value: "all", children: "All events" }),
42584
+ /* @__PURE__ */ jsx(SelectItem2, { value: "created", children: "Created" }),
42585
+ /* @__PURE__ */ jsx(SelectItem2, { value: "updated", children: "Updated" }),
42586
+ /* @__PURE__ */ jsx(SelectItem2, { value: "deleted", children: "Deleted" })
42587
+ ] })
42715
42588
  ]
42716
42589
  }
42717
- ) : null,
42718
- disabledCollections.length > 0 && !auditLog.error ? /* @__PURE__ */ jsxs(
42719
- "div",
42590
+ )
42591
+ ] }),
42592
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42593
+ /* @__PURE__ */ jsx(Label, { htmlFor: actorID, className: "text-xs text-muted-foreground", children: "Actor" }),
42594
+ /* @__PURE__ */ jsxs(
42595
+ Select,
42720
42596
  {
42721
- "data-audit-log-state": "audit-disabled",
42722
- className: "flex gap-2 border-b bg-amber-50 px-5 py-2.5 text-xs text-amber-950",
42723
- role: "status",
42597
+ value: actor,
42598
+ onValueChange: (value) => value && setFilters({ ...filterState, actor: value === "all" ? void 0 : value }),
42724
42599
  children: [
42725
- /* @__PURE__ */ jsx(CircleAlert, { className: "mt-0.5 size-4 shrink-0" }),
42726
- /* @__PURE__ */ jsxs("p", { children: [
42727
- "Auditing is off for ",
42728
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: disabledCollections.join(", ") }),
42729
- ". Existing history is still visible, but new changes will not be recorded."
42600
+ /* @__PURE__ */ jsx(SelectTrigger2, { id: actorID, size: "sm", className: "w-[11rem] rounded-lg border-border bg-background", children: /* @__PURE__ */ jsx(SelectValue2, { children: selectedActorLabel }) }),
42601
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
42602
+ /* @__PURE__ */ jsx(SelectItem2, { value: "all", children: "All actors" }),
42603
+ actorOptions.map(([actorID2, option]) => /* @__PURE__ */ jsx(SelectItem2, { value: actorID2, children: auditLogActorLabel(option) }, actorID2))
42730
42604
  ] })
42731
42605
  ]
42732
42606
  }
42733
- ) : null,
42734
- /* @__PURE__ */ jsxs(Table, { children: [
42735
- /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-transparent", children: [
42736
- /* @__PURE__ */ jsx(TableHead, { className: "w-32 text-xs text-muted-foreground", children: "Time" }),
42737
- showCollectionColumn ? /* @__PURE__ */ jsx(TableHead, { className: "w-48 text-xs text-muted-foreground", children: "Collection" }) : null,
42738
- /* @__PURE__ */ jsx(TableHead, { className: "text-xs text-muted-foreground", children: "Activity" }),
42739
- showActorColumn ? /* @__PURE__ */ jsx(TableHead, { className: "w-48 text-xs text-muted-foreground", children: "Actor" }) : null,
42740
- /* @__PURE__ */ jsx(TableHead, { className: getRecordHref || onRecordClick ? "w-36" : "w-12", children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Actions" }) })
42741
- ] }) }),
42742
- /* @__PURE__ */ jsx(TableBody, { children: auditLog.isLoading ? loadingState !== void 0 ? /* @__PURE__ */ jsx(TableRow, { "data-audit-log-state": "loading", className: "hover:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, className: "h-48 whitespace-normal text-center", children: loadingState }) }) : [0, 1, 2].map((item) => /* @__PURE__ */ jsxs(TableRow, { children: [
42743
- /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-20" }) }),
42744
- showCollectionColumn ? /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-28" }) }) : null,
42745
- /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-2/3" }) }),
42746
- showActorColumn ? /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" }) }) : null,
42747
- /* @__PURE__ */ jsx(TableCell, {})
42748
- ] }, item)) : configurationError || auditLog.error ? /* @__PURE__ */ jsx(TableRow, { "data-audit-log-state": "error", className: "hover:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, className: "h-48 whitespace-normal text-center", children: auditLog.error && errorState ? errorState(auditLog.error) : defaultState(
42749
- /* @__PURE__ */ jsx(History, { className: "mx-auto mb-3 size-8 text-muted-foreground/60" }),
42750
- configurationError ? "Audit log is not configured" : errorCopy.title,
42751
- configurationError || `${errorCopy.description} Filters: ${filterSummary}.`,
42752
- configurationError ? void 0 : /* @__PURE__ */ jsxs(Fragment, { children: [
42753
- hasFilters ? /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "outline", size: "sm", onClick: resetFilters, children: [
42754
- /* @__PURE__ */ jsx(FunnelX, {}),
42755
- " Reset filters"
42756
- ] }) : null,
42757
- /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "ghost", size: "sm", onClick: () => void auditLog.refresh(), children: [
42758
- /* @__PURE__ */ jsx(RefreshCw, {}),
42759
- " Refresh"
42760
- ] })
42761
- ] })
42762
- ) }) }) : auditLog.entries.length === 0 ? /* @__PURE__ */ jsx(TableRow, { "data-audit-log-state": "empty", className: "hover:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, className: "h-48 whitespace-normal text-center", children: emptyState ?? defaultState(
42763
- /* @__PURE__ */ jsx(History, { className: "mx-auto mb-3 size-8 text-muted-foreground/60" }),
42764
- hasDateFilter ? "No activity in this date range" : hasFilters ? "No activity matches these filters" : "No activity to show",
42765
- hasDateFilter ? "Try expanding the date range or reset filters." : disabledCollections.length > 0 ? "Auditing is off, and no existing changes match the current filters." : hasFilters ? "Try removing a filter or reset filters." : "No record changes have been logged yet.",
42766
- hasFilters ? /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "outline", size: "sm", onClick: resetFilters, children: [
42767
- /* @__PURE__ */ jsx(FunnelX, {}),
42768
- " Reset filters"
42769
- ] }) : void 0
42770
- ) }) }) : auditLog.entries.map((entry) => {
42771
- const collectionApiName = entry.collection;
42772
- return /* @__PURE__ */ jsx(
42773
- AuditLogEntry,
42607
+ )
42608
+ ] }),
42609
+ /* @__PURE__ */ jsx("span", { className: "mb-2 text-[11px] text-muted-foreground", children: "Dates use local time" }),
42610
+ hasFilters ? /* @__PURE__ */ jsxs(
42611
+ Button2,
42612
+ {
42613
+ type: "button",
42614
+ variant: "ghost",
42615
+ size: "sm",
42616
+ className: "mb-px",
42617
+ onPointerDown: resetFiltersFromPointer,
42618
+ onClick: resetFilters,
42619
+ children: [
42620
+ /* @__PURE__ */ jsx(FunnelX, {}),
42621
+ " Reset filters"
42622
+ ]
42623
+ }
42624
+ ) : null
42625
+ ] }),
42626
+ filterChips.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 border-b bg-muted/10 px-5 py-2 text-xs", children: [
42627
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground", children: "Active filters" }),
42628
+ filterChips.map((chip) => /* @__PURE__ */ jsxs(
42629
+ "span",
42630
+ {
42631
+ className: "inline-flex h-6 max-w-full items-center gap-1 rounded-full border bg-background px-2 text-foreground",
42632
+ children: [
42633
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: chip.label }),
42634
+ /* @__PURE__ */ jsx(
42635
+ "button",
42774
42636
  {
42775
- entry,
42776
- collectionApiName,
42777
- collectionLabel: labelForCollection(collectionApiName),
42778
- activityCollectionLabel: activityLabelForCollection(collectionApiName),
42779
- density,
42780
- showCollectionColumn,
42781
- showActorColumn,
42782
- showSystemFields,
42783
- fieldLabels,
42784
- columnCount,
42785
- getRecordHref,
42786
- onRecordClick
42787
- },
42788
- entry.id
42789
- );
42790
- }) })
42791
- ] }),
42792
- auditLog.hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center border-t p-4", children: /* @__PURE__ */ jsxs(
42793
- Button2,
42637
+ type: "button",
42638
+ className: "rounded-full text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:outline-none",
42639
+ "aria-label": `Clear ${chip.label}`,
42640
+ onClick: chip.onClear,
42641
+ children: /* @__PURE__ */ jsx(X$2, { className: "size-3" })
42642
+ }
42643
+ )
42644
+ ]
42645
+ },
42646
+ chip.key
42647
+ ))
42648
+ ] }) : null,
42649
+ disabledCollections.length > 0 && !auditLog.error ? /* @__PURE__ */ jsxs("div", { className: "flex gap-2 border-b bg-amber-50 px-5 py-2.5 text-xs text-amber-950", role: "status", children: [
42650
+ /* @__PURE__ */ jsx(CircleAlert, { className: "mt-0.5 size-4 shrink-0" }),
42651
+ /* @__PURE__ */ jsxs("p", { children: [
42652
+ "Auditing is off for ",
42653
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: disabledCollections.join(", ") }),
42654
+ ". Existing history is still visible, but new changes will not be recorded."
42655
+ ] })
42656
+ ] }) : null,
42657
+ /* @__PURE__ */ jsxs(Table, { children: [
42658
+ /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-transparent", children: [
42659
+ /* @__PURE__ */ jsx(TableHead, { className: "w-32 text-xs text-muted-foreground", children: "Time" }),
42660
+ showCollectionColumn ? /* @__PURE__ */ jsx(TableHead, { className: "w-48 text-xs text-muted-foreground", children: "Collection" }) : null,
42661
+ /* @__PURE__ */ jsx(TableHead, { className: "text-xs text-muted-foreground", children: "Activity" }),
42662
+ showActorColumn ? /* @__PURE__ */ jsx(TableHead, { className: "w-48 text-xs text-muted-foreground", children: "Actor" }) : null,
42663
+ /* @__PURE__ */ jsx(TableHead, { className: getRecordHref || onRecordClick ? "w-36" : "w-12", children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Actions" }) })
42664
+ ] }) }),
42665
+ /* @__PURE__ */ jsx(TableBody, { children: auditLog.isLoading ? loadingState !== void 0 ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, className: "h-48 whitespace-normal text-center", children: loadingState }) }) : [0, 1, 2].map((item) => /* @__PURE__ */ jsxs(TableRow, { children: [
42666
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-20" }) }),
42667
+ showCollectionColumn ? /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-28" }) }) : null,
42668
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-2/3" }) }),
42669
+ showActorColumn ? /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" }) }) : null,
42670
+ /* @__PURE__ */ jsx(TableCell, {})
42671
+ ] }, item)) : configurationError || auditLog.error ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, className: "h-48 whitespace-normal text-center", children: auditLog.error && errorState ? errorState(auditLog.error) : defaultState(
42672
+ /* @__PURE__ */ jsx(History, { className: "mx-auto mb-3 size-8 text-muted-foreground/60" }),
42673
+ configurationError ? "Audit log is not configured" : errorCopy.title,
42674
+ configurationError || `${errorCopy.description} Filters: ${filterSummary}.`,
42675
+ configurationError ? void 0 : /* @__PURE__ */ jsxs(Fragment, { children: [
42676
+ hasFilters ? /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "outline", size: "sm", onClick: resetFilters, children: [
42677
+ /* @__PURE__ */ jsx(FunnelX, {}),
42678
+ " Reset filters"
42679
+ ] }) : null,
42680
+ /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "ghost", size: "sm", onClick: () => void auditLog.refresh(), children: [
42681
+ /* @__PURE__ */ jsx(RefreshCw, {}),
42682
+ " Refresh"
42683
+ ] })
42684
+ ] })
42685
+ ) }) }) : auditLog.entries.length === 0 ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, className: "h-48 whitespace-normal text-center", children: emptyState ?? defaultState(
42686
+ /* @__PURE__ */ jsx(History, { className: "mx-auto mb-3 size-8 text-muted-foreground/60" }),
42687
+ hasDateFilter ? "No activity in this date range" : hasFilters ? "No activity matches these filters" : "No activity to show",
42688
+ hasDateFilter ? "Try expanding the date range or reset filters." : disabledCollections.length > 0 ? "Auditing is off, and no existing changes match the current filters." : hasFilters ? "Try removing a filter or reset filters." : "No record changes have been logged yet.",
42689
+ hasFilters ? /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "outline", size: "sm", onClick: resetFilters, children: [
42690
+ /* @__PURE__ */ jsx(FunnelX, {}),
42691
+ " Reset filters"
42692
+ ] }) : void 0
42693
+ ) }) }) : auditLog.entries.map((entry) => {
42694
+ const collectionApiName = auditLogDetailValue(entry, "Collection");
42695
+ return /* @__PURE__ */ jsx(
42696
+ AuditLogEntry,
42794
42697
  {
42795
- "data-audit-log-control": "load-more",
42796
- type: "button",
42797
- variant: "outline",
42798
- size: "sm",
42799
- disabled: auditLog.isLoadingMore,
42800
- onClick: () => void auditLog.loadMore(),
42801
- children: [
42802
- auditLog.isLoadingMore ? /* @__PURE__ */ jsx(LoaderCircle, { className: "animate-spin" }) : null,
42803
- "Load more"
42804
- ]
42805
- }
42806
- ) }) : null
42807
- ]
42808
- }
42809
- );
42698
+ entry,
42699
+ collectionApiName,
42700
+ collectionLabel: labelForCollection(collectionApiName),
42701
+ activityCollectionLabel: activityLabelForCollection(collectionApiName),
42702
+ density,
42703
+ showCollectionColumn,
42704
+ showActorColumn,
42705
+ showSystemFields,
42706
+ fieldLabels,
42707
+ columnCount,
42708
+ getRecordHref,
42709
+ onRecordClick
42710
+ },
42711
+ entry.id
42712
+ );
42713
+ }) })
42714
+ ] }),
42715
+ auditLog.hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center border-t p-4", children: /* @__PURE__ */ jsxs(
42716
+ Button2,
42717
+ {
42718
+ type: "button",
42719
+ variant: "outline",
42720
+ size: "sm",
42721
+ disabled: auditLog.isLoadingMore,
42722
+ onClick: () => void auditLog.loadMore(),
42723
+ children: [
42724
+ auditLog.isLoadingMore ? /* @__PURE__ */ jsx(LoaderCircle, { className: "animate-spin" }) : null,
42725
+ "Load more"
42726
+ ]
42727
+ }
42728
+ ) }) : null
42729
+ ] });
42810
42730
  }
42811
42731
  function RunDownloadAction({ run }) {
42812
42732
  const [isDownloading, setIsDownloading] = useState(false);