@nivaro/react 0.3.111 → 0.3.113
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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +207 -3
- package/dist/index.js +745 -728
- package/dist/shared/components/CollectionBrowserView.js +3133 -2954
- package/dist/shared/components/CollectionImportBanner.js +135 -0
- package/dist/shared/components/ItemEditForm.js +2235 -2218
- package/dist/shared/components/JobsTray.js +54 -47
- package/dist/shared/components/ViewAsPersonButton.js +109 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +228 -150
- package/dist/shared/components/bulk/BulkFieldUpdateButton.js +35 -41
- package/dist/shared/components/bulk/BulkLinksValue.js +91 -0
- package/dist/shared/components/bulk/bulk-field-options.js +20 -19
- package/dist/shared/components/bulk/bulk-update-preview.js +39 -0
- package/dist/shared/components/cbv/ColumnHeaderMenu.js +130 -0
- package/dist/shared/components/cbv/column-totals.js +163 -0
- package/dist/shared/components/collections-directory/CollectionHoverCard.js +108 -81
- package/dist/shared/components/collections-directory/CollectionRow.js +164 -148
- package/dist/shared/components/collections-directory/CollectionsDirectory.js +167 -166
- package/dist/shared/components/collections-directory/directory-data.js +70 -58
- package/dist/shared/components/imports/CollectionImportPanel.js +120 -118
- package/dist/shared/components/imports/DefinitionsPanel.js +24 -24
- package/dist/shared/components/imports/ImportDuplicatesNotice.js +65 -0
- package/dist/shared/components/item-edit/CatalogPickerField.js +631 -639
- package/dist/shared/components/item-edit/DuplicateNotice.js +168 -0
- package/dist/shared/components/item-edit/FieldRow.js +248 -246
- package/dist/shared/components/item-edit/InlineGridField.js +34 -33
- package/dist/shared/components/item-edit/InlineTableField.js +3002 -2825
- package/dist/shared/components/item-edit/MembershipSetField.js +165 -169
- package/dist/shared/components/item-edit/NestedRelationEditor.js +184 -189
- package/dist/shared/components/item-edit/PlanGrid.js +2 -1
- package/dist/shared/components/item-edit/QuickPickerDialog.js +35 -34
- package/dist/shared/components/item-edit/RecordLiveSync.js +32 -30
- package/dist/shared/components/item-edit/RelationCombobox.js +101 -100
- package/dist/shared/components/item-edit/RowHistorySheet.js +28 -27
- package/dist/shared/components/item-edit/SummaryPanel.js +133 -135
- package/dist/shared/components/item-edit/UserChip.js +262 -239
- package/dist/shared/components/item-edit/ViewAsRole.js +129 -52
- package/dist/shared/components/item-edit/grid-search.js +375 -0
- package/dist/shared/components/item-edit/render-stability.js +61 -54
- package/dist/shared/components/notifications/NotificationRulesEditor.js +25 -20
- package/dist/shared/components/ops-report/DigestSections.js +163 -144
- package/dist/shared/components/ops-report/drill.js +97 -97
- package/dist/shared/components/panels/AddendumLinesDiff.js +52 -51
- package/dist/shared/components/panels/AddendumPanel.js +92 -91
- package/dist/shared/components/panels/AsyncUserPicker.js +108 -0
- package/dist/shared/components/panels/CommentPanel.js +265 -252
- package/dist/shared/components/panels/OwnersSlot.js +47 -35
- package/dist/shared/components/panels/PipelineInsight.js +186 -0
- package/dist/shared/components/panels/PipelinePanel.js +1440 -1397
- package/dist/shared/components/panels/RecordIntegrityBanner.js +39 -38
- package/dist/shared/components/panels/RevisionsPanel.js +261 -260
- package/dist/shared/components/panels/StandInReason.js +69 -0
- package/dist/shared/components/pipeline/FieldPicker.js +41 -40
- package/dist/shared/components/pipeline/OwnerMatrix.js +829 -700
- package/dist/shared/components/pipeline/OwnerRecordTrial.js +362 -0
- package/dist/shared/components/pipeline/PipelineEditorView.js +483 -467
- package/dist/shared/components/pipeline/PipelineStateOwners.js +65 -64
- package/dist/shared/components/pipeline/owner-matrix-draft.js +178 -0
- package/dist/shared/components/profile/MyDefaultsCard.js +36 -35
- package/dist/shared/components/profile/PersonHeader.js +29 -29
- package/dist/shared/components/profile/PersonProfile.js +30 -28
- package/dist/shared/components/profile/SlowScreensCard.js +286 -0
- package/dist/shared/components/queue/QueueWorklist.js +1090 -1071
- package/dist/shared/components/quick-filters/useQuickFilterEditing.js +45 -44
- package/dist/shared/components/support/TicketDetailSheet.js +25 -16
- package/dist/shared/components/support/TicketSlowScreens.js +32 -0
- package/dist/shared/lib/activity-sentence.js +224 -178
- package/dist/shared/lib/collection-import-banner.js +27 -0
- package/dist/shared/lib/crash-report.js +112 -0
- package/dist/shared/lib/export-runs.js +99 -0
- package/dist/shared/lib/jobs-tray.js +89 -67
- package/dist/shared/lib/list-link.js +76 -69
- package/dist/shared/lib/nav-trail.js +180 -76
- package/dist/shared/lib/query-keys.js +26 -0
- package/dist/shared/lib/view-as.js +16 -11
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsxs as l, jsx as t, Fragment as $ } from "react/jsx-runtime";
|
|
2
2
|
import { useQuery as I, useQueryClient as te, useMutation as Y } from "@tanstack/react-query";
|
|
3
3
|
import { Clock as G, Search as Te, X as Re, CalendarClock as je, GitCompareArrows as Ae, ChevronDown as $e, ChevronRight as Oe, MessageSquare as qe, RotateCcw as me, ArrowRight as Fe } from "lucide-react";
|
|
4
|
-
import { useState as w, useRef as Le, useMemo as
|
|
4
|
+
import { useState as w, useRef as Le, useMemo as j, createContext as De, useEffect as Ee, useContext as pe } from "react";
|
|
5
5
|
import { toast as A } from "sonner";
|
|
6
6
|
import { useNivaroClient as D } from "../../context.js";
|
|
7
7
|
import { o2mSentence as Be, activityPredicate as Pe, activityWhy as Ie, actorName as Ke } from "../../lib/activity-sentence.js";
|
|
8
8
|
import { get as L, post as M } from "../../lib/commands.js";
|
|
9
9
|
import { useLiveRecordQueries as Me } from "../../lib/live.js";
|
|
10
10
|
import { restoreSkippedNote as le } from "../../lib/restore-skipped.js";
|
|
11
|
-
import { formatDateTime as E, cn as
|
|
11
|
+
import { formatDateTime as E, cn as R, titleCase as ue, toLocalDateString as ae } from "../../lib/utils.js";
|
|
12
12
|
import { useActivityLabels as Ue } from "../ActivityEntry.js";
|
|
13
13
|
import { AgentBadge as We } from "../AgentBadge.js";
|
|
14
14
|
import { RelatedItemLabel as Ve } from "../item-edit/RelationCombobox.js";
|
|
@@ -18,8 +18,8 @@ import { Sheet as ze, SheetTrigger as He, SheetContent as Je, SheetHeader as Qe,
|
|
|
18
18
|
import { Skeleton as Ge } from "../ui/skeleton.js";
|
|
19
19
|
import { IntegrationActivitySection as Xe } from "./IntegrationActivitySection.js";
|
|
20
20
|
const X = (e) => e.id != null && (e.action === "create" || e.action === "update" || e.action === "delete" || e.action === "restore"), Ze = (e) => !X(e), q = (e) => {
|
|
21
|
-
var
|
|
22
|
-
return e.id != null ? `r${e.id}` : `e${((
|
|
21
|
+
var r;
|
|
22
|
+
return e.id != null ? `r${e.id}` : `e${((r = e.event) == null ? void 0 : r.history_id) ?? ""}-${e.activity ?? ""}-${e.timestamp ?? ""}`;
|
|
23
23
|
}, et = /* @__PURE__ */ new Set([
|
|
24
24
|
"id",
|
|
25
25
|
"created",
|
|
@@ -32,10 +32,10 @@ const X = (e) => e.id != null && (e.action === "create" || e.action === "update"
|
|
|
32
32
|
"updated_at",
|
|
33
33
|
"sort"
|
|
34
34
|
]);
|
|
35
|
-
function xe(e,
|
|
35
|
+
function xe(e, r) {
|
|
36
36
|
const d = D(), { data: a } = I({
|
|
37
37
|
queryKey: ["revisions-field-meta", e],
|
|
38
|
-
enabled:
|
|
38
|
+
enabled: r,
|
|
39
39
|
staleTime: 3e5,
|
|
40
40
|
queryFn: async () => {
|
|
41
41
|
const [i, o] = await Promise.all([
|
|
@@ -43,19 +43,19 @@ function xe(e, s) {
|
|
|
43
43
|
d.request(
|
|
44
44
|
L(`/collections/${e}`)
|
|
45
45
|
).then((n) => {
|
|
46
|
-
var
|
|
47
|
-
return ((
|
|
46
|
+
var s;
|
|
47
|
+
return ((s = n.data) == null ? void 0 : s.relations) ?? [];
|
|
48
48
|
}).catch(() => [])
|
|
49
49
|
]);
|
|
50
50
|
return { fields: i, relations: o };
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
|
-
return
|
|
53
|
+
return j(() => {
|
|
54
54
|
const i = /* @__PURE__ */ new Map(), o = (n) => {
|
|
55
|
-
const
|
|
55
|
+
const s = ((a == null ? void 0 : a.relations) ?? []).find(
|
|
56
56
|
(m) => m.many_collection === e && m.many_field === n && m.junction_field == null
|
|
57
57
|
);
|
|
58
|
-
return
|
|
58
|
+
return s != null && s.one_collection ? s.one_collection === "directus_users" ? "nivaro_users" : s.one_collection : null;
|
|
59
59
|
};
|
|
60
60
|
for (const n of (a == null ? void 0 : a.fields) ?? [])
|
|
61
61
|
n.field.startsWith("__") || i.set(n.field, {
|
|
@@ -73,31 +73,31 @@ function xe(e, s) {
|
|
|
73
73
|
return i;
|
|
74
74
|
}, [a, e]);
|
|
75
75
|
}
|
|
76
|
-
function k(e,
|
|
77
|
-
return e.get(
|
|
76
|
+
function k(e, r) {
|
|
77
|
+
return e.get(r) ?? {
|
|
78
78
|
// Unknown to the form = machine column. Still labeled, still reachable.
|
|
79
|
-
label: ue(
|
|
79
|
+
label: ue(r.replace(/[_-]/g, " ")),
|
|
80
80
|
system: !0,
|
|
81
81
|
onLayout: !1
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
function tt({ map: e, field:
|
|
85
|
-
const d = k(e,
|
|
84
|
+
function tt({ map: e, field: r }) {
|
|
85
|
+
const d = k(e, r);
|
|
86
86
|
return /* @__PURE__ */ t(
|
|
87
87
|
"span",
|
|
88
88
|
{
|
|
89
89
|
className: "text-[12px] font-medium text-slate-700 dark:text-slate-200",
|
|
90
|
-
"data-tip":
|
|
91
|
-
title:
|
|
90
|
+
"data-tip": r,
|
|
91
|
+
title: r,
|
|
92
92
|
children: d.label
|
|
93
93
|
}
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
const de = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/, at = /^\d{4}-\d{2}-\d{2}(?:T00:00:00(?:\.0+)?Z)?$/;
|
|
97
|
-
function rt(e,
|
|
97
|
+
function rt(e, r = !1) {
|
|
98
98
|
if (e == null || e === "") return "";
|
|
99
99
|
if (typeof e == "boolean") return e ? "Yes" : "No";
|
|
100
|
-
if (typeof e == "string" && (at.test(e) ||
|
|
100
|
+
if (typeof e == "string" && (at.test(e) || r && de.test(e)))
|
|
101
101
|
return ae(e);
|
|
102
102
|
if (typeof e == "string" && de.test(e)) {
|
|
103
103
|
const d = new Date(e);
|
|
@@ -108,18 +108,18 @@ function rt(e, s = !1) {
|
|
|
108
108
|
function W(e) {
|
|
109
109
|
return e == null ? "" : typeof e == "object" ? JSON.stringify(e) : String(e);
|
|
110
110
|
}
|
|
111
|
-
function st({ collection: e, id:
|
|
111
|
+
function st({ collection: e, id: r }) {
|
|
112
112
|
const d = D(), { data: a } = I({
|
|
113
113
|
queryKey: ["col-meta", e],
|
|
114
114
|
queryFn: () => d.request(L(`/collections/${e}`)).then((i) => i.data),
|
|
115
115
|
staleTime: 3e5,
|
|
116
116
|
retry: !1
|
|
117
117
|
});
|
|
118
|
-
return /* @__PURE__ */ t("span", { title: `${e} #${String(
|
|
118
|
+
return /* @__PURE__ */ t("span", { title: `${e} #${String(r)}`, children: /* @__PURE__ */ t(
|
|
119
119
|
Ve,
|
|
120
120
|
{
|
|
121
121
|
collection: e,
|
|
122
|
-
id:
|
|
122
|
+
id: r,
|
|
123
123
|
displayTemplate: a == null ? void 0 : a.display_template
|
|
124
124
|
}
|
|
125
125
|
) });
|
|
@@ -130,23 +130,23 @@ function nt(e) {
|
|
|
130
130
|
const ie = 160;
|
|
131
131
|
function oe({
|
|
132
132
|
value: e,
|
|
133
|
-
tone:
|
|
133
|
+
tone: r,
|
|
134
134
|
dateOnly: d
|
|
135
135
|
}) {
|
|
136
136
|
const [a, i] = w(!1), o = rt(e, d);
|
|
137
137
|
if (o === "")
|
|
138
138
|
return /* @__PURE__ */ t("span", { className: "text-[11.5px] italic text-slate-300 dark:text-slate-600", children: "empty" });
|
|
139
|
-
const n = o.length > ie,
|
|
139
|
+
const n = o.length > ie, s = a || !n ? o : `${o.slice(0, ie)}…`;
|
|
140
140
|
return /* @__PURE__ */ l("span", { className: "break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: [
|
|
141
|
-
typeof e == "object" ? /* @__PURE__ */ t("span", { className: "font-mono text-[11px]", children:
|
|
141
|
+
typeof e == "object" ? /* @__PURE__ */ t("span", { className: "font-mono text-[11px]", children: s }) : s,
|
|
142
142
|
n && /* @__PURE__ */ t(
|
|
143
143
|
"button",
|
|
144
144
|
{
|
|
145
145
|
type: "button",
|
|
146
146
|
onClick: () => i((m) => !m),
|
|
147
|
-
className:
|
|
147
|
+
className: R(
|
|
148
148
|
"ml-1 text-[10.5px] font-medium hover:underline",
|
|
149
|
-
|
|
149
|
+
r === "before" ? "text-rose-500" : "text-emerald-600"
|
|
150
150
|
),
|
|
151
151
|
children: a ? "less" : "more"
|
|
152
152
|
}
|
|
@@ -157,8 +157,8 @@ function K(e) {
|
|
|
157
157
|
if (e && typeof e == "object" && !Array.isArray(e)) return e;
|
|
158
158
|
if (typeof e == "string" && e.trim().startsWith("{"))
|
|
159
159
|
try {
|
|
160
|
-
const
|
|
161
|
-
return
|
|
160
|
+
const r = JSON.parse(e);
|
|
161
|
+
return r && typeof r == "object" && !Array.isArray(r) ? r : null;
|
|
162
162
|
} catch {
|
|
163
163
|
return null;
|
|
164
164
|
}
|
|
@@ -166,33 +166,33 @@ function K(e) {
|
|
|
166
166
|
}
|
|
167
167
|
function lt({
|
|
168
168
|
before: e,
|
|
169
|
-
after:
|
|
169
|
+
after: r
|
|
170
170
|
}) {
|
|
171
|
-
const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(
|
|
172
|
-
const n = o in e ? JSON.stringify(e[o]) : void 0,
|
|
173
|
-
return n ===
|
|
171
|
+
const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(r)])).sort().map((o) => {
|
|
172
|
+
const n = o in e ? JSON.stringify(e[o]) : void 0, s = o in r ? JSON.stringify(r[o]) : void 0;
|
|
173
|
+
return n === s ? null : { k: o, b: n, a: s };
|
|
174
174
|
}).filter(Boolean);
|
|
175
175
|
if (a.length === 0)
|
|
176
176
|
return /* @__PURE__ */ t("span", { className: "text-[11px] italic text-slate-400", children: "keys reordered only" });
|
|
177
177
|
const i = (o) => o == null ? void 0 : o.length > 80 ? `${o.slice(0, 80)}…` : o;
|
|
178
|
-
return /* @__PURE__ */ t("div", { className: "space-y-0.5", "data-json-diff": !0, children: a.map(({ k: o, b: n, a:
|
|
178
|
+
return /* @__PURE__ */ t("div", { className: "space-y-0.5", "data-json-diff": !0, children: a.map(({ k: o, b: n, a: s }) => /* @__PURE__ */ l("p", { className: "text-[11.5px]", children: [
|
|
179
179
|
/* @__PURE__ */ t("span", { className: "font-mono text-[10.5px] text-slate-500", children: o }),
|
|
180
180
|
":",
|
|
181
181
|
" ",
|
|
182
182
|
n !== void 0 && /* @__PURE__ */ t("span", { className: "text-rose-600 line-through dark:text-rose-400", children: i(n) }),
|
|
183
|
-
n !== void 0 &&
|
|
184
|
-
|
|
183
|
+
n !== void 0 && s !== void 0 && " → ",
|
|
184
|
+
s !== void 0 ? /* @__PURE__ */ t("span", { className: "text-emerald-700 dark:text-emerald-400", children: i(s) }) : /* @__PURE__ */ t("span", { className: "italic text-slate-400", children: " (removed)" })
|
|
185
185
|
] }, o)) });
|
|
186
186
|
}
|
|
187
|
-
function dt({ field: e, ctl:
|
|
188
|
-
return
|
|
187
|
+
function dt({ field: e, ctl: r }) {
|
|
188
|
+
return r.confirmField === e ? /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1", "data-revert-field-confirm": e, children: [
|
|
189
189
|
/* @__PURE__ */ t("span", { className: "text-[10.5px] text-slate-500", children: "Revert?" }),
|
|
190
190
|
/* @__PURE__ */ t(
|
|
191
191
|
"button",
|
|
192
192
|
{
|
|
193
193
|
type: "button",
|
|
194
|
-
disabled:
|
|
195
|
-
onClick: () =>
|
|
194
|
+
disabled: r.pending,
|
|
195
|
+
onClick: () => r.revert(e),
|
|
196
196
|
className: "rounded bg-nvr-cyan px-1.5 py-px text-[10.5px] font-semibold text-white disabled:opacity-50",
|
|
197
197
|
children: "Yes"
|
|
198
198
|
}
|
|
@@ -201,7 +201,7 @@ function dt({ field: e, ctl: s }) {
|
|
|
201
201
|
"button",
|
|
202
202
|
{
|
|
203
203
|
type: "button",
|
|
204
|
-
onClick: () =>
|
|
204
|
+
onClick: () => r.setConfirmField(null),
|
|
205
205
|
className: "rounded border border-slate-200 px-1.5 py-px text-[10.5px] text-slate-500 dark:border-border",
|
|
206
206
|
children: "Cancel"
|
|
207
207
|
}
|
|
@@ -210,7 +210,7 @@ function dt({ field: e, ctl: s }) {
|
|
|
210
210
|
"button",
|
|
211
211
|
{
|
|
212
212
|
type: "button",
|
|
213
|
-
onClick: () =>
|
|
213
|
+
onClick: () => r.setConfirmField(e),
|
|
214
214
|
className: "inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10.5px] font-medium text-slate-400 opacity-0 transition-opacity hover:bg-nvr-cyan/10 hover:text-nvr-navy group-hover/frow:opacity-100 dark:hover:text-nvr-cyan",
|
|
215
215
|
title: "Set the field back to this revision’s value",
|
|
216
216
|
"data-revert-field": e,
|
|
@@ -227,24 +227,24 @@ function Z(e) {
|
|
|
227
227
|
function ee(e) {
|
|
228
228
|
return String(e ?? "").replace(/<[^>]*>/g, " ").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").split(/\s+/).filter(Boolean);
|
|
229
229
|
}
|
|
230
|
-
function it(e,
|
|
231
|
-
const a = ee(e).slice(0, 600), i = ee(
|
|
232
|
-
for (let
|
|
230
|
+
function it(e, r) {
|
|
231
|
+
const a = ee(e).slice(0, 600), i = ee(r).slice(0, 600), o = a.length, n = i.length, s = Array.from({ length: o + 1 }, () => new Array(n + 1).fill(0));
|
|
232
|
+
for (let b = o - 1; b >= 0; b--)
|
|
233
233
|
for (let c = n - 1; c >= 0; c--)
|
|
234
|
-
|
|
235
|
-
const m = [],
|
|
234
|
+
s[b][c] = a[b] === i[c] ? s[b + 1][c + 1] + 1 : Math.max(s[b + 1][c], s[b][c + 1]);
|
|
235
|
+
const m = [], u = (b, c) => {
|
|
236
236
|
const y = m[m.length - 1];
|
|
237
|
-
y && y.type ===
|
|
237
|
+
y && y.type === b ? y.text += ` ${c}` : m.push({ text: c, type: b });
|
|
238
238
|
};
|
|
239
|
-
let p = 0,
|
|
240
|
-
for (; p < o &&
|
|
241
|
-
a[p] === i[
|
|
242
|
-
for (; p < o; )
|
|
243
|
-
for (;
|
|
239
|
+
let p = 0, h = 0;
|
|
240
|
+
for (; p < o && h < n; )
|
|
241
|
+
a[p] === i[h] ? (u("same", a[p]), p++, h++) : s[p + 1][h] >= s[p][h + 1] ? (u("del", a[p]), p++) : (u("ins", i[h]), h++);
|
|
242
|
+
for (; p < o; ) u("del", a[p++]);
|
|
243
|
+
for (; h < n; ) u("ins", i[h++]);
|
|
244
244
|
return m;
|
|
245
245
|
}
|
|
246
|
-
function ot({ before: e, after:
|
|
247
|
-
const d = it(e,
|
|
246
|
+
function ot({ before: e, after: r }) {
|
|
247
|
+
const d = it(e, r);
|
|
248
248
|
return /* @__PURE__ */ t("p", { className: "whitespace-pre-wrap break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: d.map(
|
|
249
249
|
(a, i) => a.type === "same" ? (
|
|
250
250
|
// biome-ignore lint/suspicious/noArrayIndexKey: static segment list
|
|
@@ -286,57 +286,57 @@ const ct = {
|
|
|
286
286
|
removed: "bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400",
|
|
287
287
|
changed: "bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400"
|
|
288
288
|
};
|
|
289
|
-
function mt(e,
|
|
290
|
-
const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(
|
|
291
|
-
const m = !(
|
|
292
|
-
if (m &&
|
|
293
|
-
const p = m ? "added" :
|
|
289
|
+
function mt(e, r, d) {
|
|
290
|
+
const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(r)])), i = (s) => s == null || s === "", o = a.map((s) => {
|
|
291
|
+
const m = !(s in e) || i(e[s]), u = !(s in r) || i(r[s]);
|
|
292
|
+
if (m && u) return null;
|
|
293
|
+
const p = m ? "added" : u ? "removed" : W(e[s]) !== W(r[s]) ? "changed" : "unchanged";
|
|
294
294
|
return {
|
|
295
|
-
field:
|
|
295
|
+
field: s,
|
|
296
296
|
status: p,
|
|
297
|
-
before: e[
|
|
298
|
-
after: s
|
|
299
|
-
system: k(d,
|
|
297
|
+
before: e[s],
|
|
298
|
+
after: r[s],
|
|
299
|
+
system: k(d, s).system
|
|
300
300
|
};
|
|
301
|
-
}).filter(Boolean), n = (
|
|
302
|
-
const m = k(d,
|
|
303
|
-
return (m.system ? 8 : m.onLayout ? 0 : 4) + (
|
|
301
|
+
}).filter(Boolean), n = (s) => {
|
|
302
|
+
const m = k(d, s.field);
|
|
303
|
+
return (m.system ? 8 : m.onLayout ? 0 : 4) + (s.status === "unchanged" ? 2 : 0);
|
|
304
304
|
};
|
|
305
305
|
return o.sort(
|
|
306
|
-
(
|
|
306
|
+
(s, m) => n(s) - n(m) || k(d, s.field).label.localeCompare(k(d, m.field).label)
|
|
307
307
|
);
|
|
308
308
|
}
|
|
309
309
|
function F({
|
|
310
310
|
value: e,
|
|
311
|
-
meta:
|
|
311
|
+
meta: r,
|
|
312
312
|
tone: d
|
|
313
313
|
}) {
|
|
314
|
-
return e == null || e === "" ? /* @__PURE__ */ t("span", { className: "text-[11.5px] italic text-slate-300 dark:text-slate-600", children: "empty" }) :
|
|
314
|
+
return e == null || e === "" ? /* @__PURE__ */ t("span", { className: "text-[11.5px] italic text-slate-300 dark:text-slate-600", children: "empty" }) : r.relatedCollection && (typeof e == "string" || typeof e == "number") ? /* @__PURE__ */ t("span", { className: "break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: /* @__PURE__ */ t(st, { collection: r.relatedCollection, id: e }) }) : Z(e) ? /* @__PURE__ */ t(oe, { value: nt(e), tone: d }) : /* @__PURE__ */ t(oe, { value: e, tone: d, dateOnly: r.dateOnly });
|
|
315
315
|
}
|
|
316
316
|
function pt({
|
|
317
317
|
row: e,
|
|
318
|
-
meta:
|
|
318
|
+
meta: r,
|
|
319
319
|
fieldRevert: d,
|
|
320
320
|
mode: a,
|
|
321
321
|
hideStatusChips: i,
|
|
322
322
|
between: o
|
|
323
323
|
}) {
|
|
324
|
-
const n = e.status === "changed" && (Z(e.before) || Z(e.after)),
|
|
324
|
+
const n = e.status === "changed" && (Z(e.before) || Z(e.after)), s = e.status === "changed" && K(e.before) && K(e.after);
|
|
325
325
|
return /* @__PURE__ */ l(
|
|
326
326
|
"div",
|
|
327
327
|
{
|
|
328
|
-
className:
|
|
328
|
+
className: R(
|
|
329
329
|
"group/frow border-b border-slate-100 px-3 py-2 last:border-0 dark:border-border/60",
|
|
330
330
|
e.system && "bg-slate-50/60 dark:bg-muted/20"
|
|
331
331
|
),
|
|
332
332
|
"data-field-row": e.field,
|
|
333
333
|
children: [
|
|
334
334
|
/* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
|
|
335
|
-
/* @__PURE__ */ t(tt, { map:
|
|
335
|
+
/* @__PURE__ */ t(tt, { map: r, field: e.field }),
|
|
336
336
|
e.status !== "unchanged" && !i && /* @__PURE__ */ t(
|
|
337
337
|
"span",
|
|
338
338
|
{
|
|
339
|
-
className:
|
|
339
|
+
className: R(
|
|
340
340
|
"rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide",
|
|
341
341
|
ct[e.status]
|
|
342
342
|
),
|
|
@@ -347,41 +347,41 @@ function pt({
|
|
|
347
347
|
// not something to put back by hand (army11 f1 design review).
|
|
348
348
|
!o && /* @__PURE__ */ t("span", { className: "ml-auto shrink-0", children: /* @__PURE__ */ t(dt, { field: e.field, ctl: d }) })
|
|
349
349
|
] }),
|
|
350
|
-
/* @__PURE__ */ t("div", { className: "mt-1", children: n ? /* @__PURE__ */ t("div", { "data-richtext-diff": !0, children: /* @__PURE__ */ t(ot, { before: e.before, after: e.after }) }) :
|
|
350
|
+
/* @__PURE__ */ t("div", { className: "mt-1", children: n ? /* @__PURE__ */ t("div", { "data-richtext-diff": !0, children: /* @__PURE__ */ t(ot, { before: e.before, after: e.after }) }) : s ? /* @__PURE__ */ t(
|
|
351
351
|
lt,
|
|
352
352
|
{
|
|
353
353
|
before: K(e.before),
|
|
354
354
|
after: K(e.after)
|
|
355
355
|
}
|
|
356
356
|
) : e.status === "changed" || e.status === "removed" ? /* @__PURE__ */ l("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-0.5", children: [
|
|
357
|
-
/* @__PURE__ */ t("span", { className: "max-w-full break-words text-[12px] text-rose-600 line-through decoration-rose-300 dark:text-rose-400", children: /* @__PURE__ */ t(F, { value: e.before, meta: k(
|
|
357
|
+
/* @__PURE__ */ t("span", { className: "max-w-full break-words text-[12px] text-rose-600 line-through decoration-rose-300 dark:text-rose-400", children: /* @__PURE__ */ t(F, { value: e.before, meta: k(r, e.field), tone: "before" }) }),
|
|
358
358
|
/* @__PURE__ */ t(Fe, { className: "h-3 w-3 shrink-0 self-center text-slate-300 dark:text-slate-600" }),
|
|
359
|
-
/* @__PURE__ */ t(F, { value: e.after, meta: k(
|
|
360
|
-
] }) : /* @__PURE__ */ t(F, { value: e.after ?? e.before, meta: k(
|
|
359
|
+
/* @__PURE__ */ t(F, { value: e.after, meta: k(r, e.field), tone: "after" })
|
|
360
|
+
] }) : /* @__PURE__ */ t(F, { value: e.after ?? e.before, meta: k(r, e.field), tone: "after" }) })
|
|
361
361
|
]
|
|
362
362
|
}
|
|
363
363
|
);
|
|
364
364
|
}
|
|
365
365
|
function ut({
|
|
366
366
|
before: e,
|
|
367
|
-
after:
|
|
367
|
+
after: r,
|
|
368
368
|
meta: d,
|
|
369
369
|
fieldRevert: a,
|
|
370
370
|
mode: i,
|
|
371
371
|
hideStatusChips: o,
|
|
372
372
|
ownFields: n
|
|
373
373
|
}) {
|
|
374
|
-
const [
|
|
374
|
+
const [s, m] = w(!1), u = j(() => mt(e, r, d), [e, r, d]), p = i === "changes" ? u.filter((x) => x.status !== "unchanged") : u, h = s ? p : p.filter((x) => !x.system), b = (x) => !!n && i === "changes" && !x.system && !n.has(x.field), c = h.filter(b), y = [...h.filter((x) => !b(x)), ...c], S = c.length ? y.length - c.length : -1, f = p.length - y.length;
|
|
375
375
|
if (p.length === 0)
|
|
376
376
|
return /* @__PURE__ */ t("p", { className: "px-3 py-3 text-[12px] text-slate-400", children: i === "changes" ? "No field changes recorded." : "No snapshot data available." });
|
|
377
377
|
const N = y.findIndex(
|
|
378
|
-
(
|
|
378
|
+
(x) => !b(x) && !k(d, x.field).onLayout && !k(d, x.field).system
|
|
379
379
|
), C = y.some(
|
|
380
|
-
(
|
|
380
|
+
(x) => !b(x) && k(d, x.field).onLayout && !k(d, x.field).system
|
|
381
381
|
);
|
|
382
382
|
return /* @__PURE__ */ l("div", { className: "overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [
|
|
383
|
-
y.map((
|
|
384
|
-
|
|
383
|
+
y.map((x, _) => /* @__PURE__ */ l("div", { children: [
|
|
384
|
+
_ === S && /* @__PURE__ */ l(
|
|
385
385
|
"div",
|
|
386
386
|
{
|
|
387
387
|
"data-recalculated-between": !0,
|
|
@@ -392,22 +392,22 @@ function ut({
|
|
|
392
392
|
]
|
|
393
393
|
}
|
|
394
394
|
),
|
|
395
|
-
|
|
395
|
+
_ === N && C && /* @__PURE__ */ l("div", { className: "border-b border-t border-slate-100 bg-slate-50/70 px-3 py-1.5 dark:border-border/60 dark:bg-muted/30", children: [
|
|
396
396
|
/* @__PURE__ */ t("p", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: "Behind the scenes" }),
|
|
397
397
|
/* @__PURE__ */ t("p", { className: "text-[10.5px] text-slate-400", children: "Not on the form — written automatically by rules, computed fields or integrations." })
|
|
398
398
|
] }),
|
|
399
399
|
/* @__PURE__ */ t(
|
|
400
400
|
pt,
|
|
401
401
|
{
|
|
402
|
-
row:
|
|
402
|
+
row: x,
|
|
403
403
|
meta: d,
|
|
404
404
|
fieldRevert: a,
|
|
405
405
|
mode: i,
|
|
406
406
|
hideStatusChips: o,
|
|
407
|
-
between:
|
|
407
|
+
between: b(x)
|
|
408
408
|
}
|
|
409
409
|
)
|
|
410
|
-
] },
|
|
410
|
+
] }, x.field)),
|
|
411
411
|
f > 0 && /* @__PURE__ */ l(
|
|
412
412
|
"button",
|
|
413
413
|
{
|
|
@@ -424,7 +424,7 @@ function ut({
|
|
|
424
424
|
]
|
|
425
425
|
}
|
|
426
426
|
),
|
|
427
|
-
f === 0 &&
|
|
427
|
+
f === 0 && s && p.some((x) => x.system) && /* @__PURE__ */ t(
|
|
428
428
|
"button",
|
|
429
429
|
{
|
|
430
430
|
type: "button",
|
|
@@ -441,18 +441,18 @@ const ht = {
|
|
|
441
441
|
update: "bg-nvr-cyan",
|
|
442
442
|
delete: "bg-red-500"
|
|
443
443
|
}, re = De(void 0);
|
|
444
|
-
function P(e,
|
|
444
|
+
function P(e, r) {
|
|
445
445
|
var d;
|
|
446
|
-
return e.actor && e.actor.kind !== "person" ? Ke(e,
|
|
446
|
+
return e.actor && e.actor.kind !== "person" ? Ke(e, r) : e.first_name || e.last_name ? [e.first_name, e.last_name].filter(Boolean).join(" ") : e.user_email ?? ((d = e.user_id) == null ? void 0 : d.slice(0, 8)) ?? "System";
|
|
447
447
|
}
|
|
448
|
-
function xt(e,
|
|
449
|
-
return e.action === "create" ? "created this record" : e.action === "restore" ? "restored this record from trash" : e.action === "delete" ? "deleted this record" :
|
|
448
|
+
function xt(e, r, d) {
|
|
449
|
+
return e.action === "create" ? "created this record" : e.action === "restore" ? "restored this record from trash" : e.action === "delete" ? "deleted this record" : r > 0 ? `changed ${r} field${r === 1 ? "" : "s"}` : d > 0 ? "updated system fields" : "saved this record";
|
|
450
450
|
}
|
|
451
|
-
function ft({ revision: e, isLast:
|
|
452
|
-
var
|
|
453
|
-
const d = pe(re), a = e.event, i = (a == null ? void 0 : a.source) === "auto" || !e.user_id && (a == null ? void 0 : a.kind) === "transition", o = !i && ((
|
|
454
|
-
let
|
|
455
|
-
(a == null ? void 0 : a.kind) === "transition" && a.addendum ?
|
|
451
|
+
function ft({ revision: e, isLast: r }) {
|
|
452
|
+
var h, b, c, y, S;
|
|
453
|
+
const d = pe(re), a = e.event, i = (a == null ? void 0 : a.source) === "auto" || !e.user_id && (a == null ? void 0 : a.kind) === "transition", o = !i && ((h = a == null ? void 0 : a.on_behalf_of) != null && h.name) ? a.on_behalf_of.name : null, n = !i && ((b = a == null ? void 0 : a.acting_admin) != null && b.name) ? a.acting_admin.name : null, s = n ? `${n} as ${P(e, d)}` : P(e, d), m = i ? "Automatic rule" : o ? `${s}, for ${o}` : s;
|
|
454
|
+
let u;
|
|
455
|
+
(a == null ? void 0 : a.kind) === "transition" && a.addendum ? u = /* @__PURE__ */ l($, { children: [
|
|
456
456
|
"moved",
|
|
457
457
|
" ",
|
|
458
458
|
/* @__PURE__ */ l("span", { className: "font-medium text-slate-700 dark:text-slate-200", "data-revision-addendum": !0, children: [
|
|
@@ -473,7 +473,7 @@ function ft({ revision: e, isLast: s }) {
|
|
|
473
473
|
" · ",
|
|
474
474
|
a.transition_label
|
|
475
475
|
] })
|
|
476
|
-
] }) : (a == null ? void 0 : a.kind) === "transition" ?
|
|
476
|
+
] }) : (a == null ? void 0 : a.kind) === "transition" ? u = /* @__PURE__ */ l($, { children: [
|
|
477
477
|
"moved it",
|
|
478
478
|
" ",
|
|
479
479
|
a.from_label && /* @__PURE__ */ l($, { children: [
|
|
@@ -489,36 +489,37 @@ function ft({ revision: e, isLast: s }) {
|
|
|
489
489
|
" · ",
|
|
490
490
|
a.transition_label
|
|
491
491
|
] })
|
|
492
|
-
] }) : (a == null ? void 0 : a.kind) === "start" && a.to_label ?
|
|
492
|
+
] }) : (a == null ? void 0 : a.kind) === "start" && a.to_label ? u = /* @__PURE__ */ l($, { children: [
|
|
493
493
|
"started it in",
|
|
494
494
|
" ",
|
|
495
495
|
/* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: a.to_label })
|
|
496
|
-
] }) : (a == null ? void 0 : a.kind) === "start" ?
|
|
496
|
+
] }) : (a == null ? void 0 : a.kind) === "start" ? u = /* @__PURE__ */ l($, { children: [
|
|
497
497
|
"started the pipeline",
|
|
498
498
|
e.comment ? ` — ${e.comment.replace(/^Started pipeline\s*[—-]?\s*/i, "")}` : ""
|
|
499
|
-
] }) : (
|
|
499
|
+
] }) : (c = e.action) != null && c.startsWith("o2m-") ? u = /* @__PURE__ */ t("span", { "data-revision-o2m": !0, children: e.o2m ? Be(e.o2m) : `${e.action === "o2m-create" ? "added" : e.action === "o2m-delete" ? "removed" : "changed"} related rows` }) : u = /* @__PURE__ */ l($, { children: [
|
|
500
500
|
Pe({ ...e, item: null }, d),
|
|
501
501
|
e.comment ? ` — ${e.comment}` : ""
|
|
502
502
|
] });
|
|
503
|
-
const
|
|
503
|
+
const p = e.timestamp ? new Date(e.timestamp).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "—";
|
|
504
504
|
return /* @__PURE__ */ l(
|
|
505
505
|
"div",
|
|
506
506
|
{
|
|
507
507
|
className: "relative pl-9",
|
|
508
508
|
"data-revision-event": (a == null ? void 0 : a.kind) ?? e.action ?? "",
|
|
509
|
-
"data-revision-on-behalf": o ? (
|
|
509
|
+
"data-revision-on-behalf": o ? (y = a == null ? void 0 : a.on_behalf_of) == null ? void 0 : y.id : void 0,
|
|
510
|
+
"data-revision-acting-admin": n ? (S = a == null ? void 0 : a.acting_admin) == null ? void 0 : S.id : void 0,
|
|
510
511
|
children: [
|
|
511
512
|
/* @__PURE__ */ t(
|
|
512
513
|
"span",
|
|
513
514
|
{
|
|
514
|
-
className:
|
|
515
|
+
className: R(
|
|
515
516
|
"absolute left-[11px] top-[18px] h-2.5 w-2.5 rounded-full ring-4 ring-white dark:ring-card",
|
|
516
517
|
(a == null ? void 0 : a.kind) === "transition" && a.addendum ? "bg-amber-500" : (a == null ? void 0 : a.kind) === "transition" ? "bg-violet-500" : (a == null ? void 0 : a.kind) === "start" ? "bg-violet-300" : "bg-slate-300"
|
|
517
518
|
),
|
|
518
519
|
"aria-hidden": !0
|
|
519
520
|
}
|
|
520
521
|
),
|
|
521
|
-
!
|
|
522
|
+
!r && /* @__PURE__ */ t(
|
|
522
523
|
"span",
|
|
523
524
|
{
|
|
524
525
|
className: "absolute bottom-0 left-[15.5px] top-[30px] w-px bg-slate-200 dark:bg-border",
|
|
@@ -531,13 +532,13 @@ function ft({ revision: e, isLast: s }) {
|
|
|
531
532
|
{
|
|
532
533
|
userId: e.user_id,
|
|
533
534
|
className: "h-6 w-6",
|
|
534
|
-
fallback: /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children:
|
|
535
|
+
fallback: /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: m.split(" ").map((f) => f[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() })
|
|
535
536
|
}
|
|
536
537
|
),
|
|
537
538
|
/* @__PURE__ */ l("span", { className: "min-w-0 flex-1 text-[12.5px] text-slate-700 dark:text-slate-200", children: [
|
|
538
|
-
/* @__PURE__ */ t("span", { className: "font-medium", children:
|
|
539
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: m }),
|
|
539
540
|
" ",
|
|
540
|
-
/* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children:
|
|
541
|
+
/* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: u }),
|
|
541
542
|
(a == null ? void 0 : a.kind) === "transition" && e.comment && /* @__PURE__ */ l(
|
|
542
543
|
"span",
|
|
543
544
|
{
|
|
@@ -556,7 +557,7 @@ function ft({ revision: e, isLast: s }) {
|
|
|
556
557
|
{
|
|
557
558
|
className: "shrink-0 text-[11px] tabular-nums text-slate-400",
|
|
558
559
|
title: e.timestamp ? E(e.timestamp) : void 0,
|
|
559
|
-
children:
|
|
560
|
+
children: p
|
|
560
561
|
}
|
|
561
562
|
)
|
|
562
563
|
] })
|
|
@@ -566,57 +567,57 @@ function ft({ revision: e, isLast: s }) {
|
|
|
566
567
|
}
|
|
567
568
|
function bt({
|
|
568
569
|
revision: e,
|
|
569
|
-
previousData:
|
|
570
|
+
previousData: r,
|
|
570
571
|
meta: d,
|
|
571
572
|
onRollback: a,
|
|
572
573
|
inlineTableFields: i,
|
|
573
574
|
isLast: o
|
|
574
575
|
}) {
|
|
575
|
-
const n = D(),
|
|
576
|
-
const
|
|
577
|
-
let
|
|
578
|
-
for (const Q of Object.keys(
|
|
579
|
-
const
|
|
580
|
-
|
|
576
|
+
const n = D(), s = pe(re), m = Ie(e).reason, [u, p] = w(!1), [h, b] = w(!1), [c, y] = w("changes"), [S, f] = w(!1), [N, C] = w(null), x = e.action === "update", _ = e.action === "create" || e.action === "restore", V = e.action === "delete", v = V ? e.data ?? {} : _ ? {} : r ?? {}, O = V ? {} : e.data ?? {}, { humanDelta: z, systemDelta: fe } = j(() => {
|
|
577
|
+
const g = e.delta ?? {};
|
|
578
|
+
let T = 0, B = 0;
|
|
579
|
+
for (const Q of Object.keys(g)) {
|
|
580
|
+
const _e = r == null ? void 0 : r[Q], Se = (e.data ?? {})[Q];
|
|
581
|
+
x && r && W(_e) === W(Se) || (k(d, Q).system ? B++ : T++);
|
|
581
582
|
}
|
|
582
|
-
return { humanDelta:
|
|
583
|
-
}, [e,
|
|
584
|
-
mutationFn: (
|
|
585
|
-
onSuccess: (
|
|
586
|
-
se(null), A.success(`Reverted ${k(d,
|
|
583
|
+
return { humanDelta: T, systemDelta: B };
|
|
584
|
+
}, [e, r, d, x]), be = j(() => new Set(Object.keys(e.delta ?? {})), [e]), ge = x || _, [H, ye] = w(null), Ne = te(), [ke, se] = w(null), ne = Y({
|
|
585
|
+
mutationFn: (g) => n.request(M(`/revisions/${e.id}/revert-field`, { field: g })),
|
|
586
|
+
onSuccess: (g, T) => {
|
|
587
|
+
se(null), A.success(`Reverted ${k(d, T).label} to this revision's value`), Ne.invalidateQueries({ queryKey: ["revisions", e.collection, e.item] }), a == null || a();
|
|
587
588
|
},
|
|
588
589
|
onError: () => A.error("Failed to revert field")
|
|
589
|
-
}), ve =
|
|
590
|
+
}), ve = x || _ ? {
|
|
590
591
|
confirmField: ke,
|
|
591
592
|
setConfirmField: se,
|
|
592
|
-
revert: (
|
|
593
|
+
revert: (g) => ne.mutate(g),
|
|
593
594
|
pending: ne.isPending
|
|
594
595
|
} : void 0, J = Y({
|
|
595
596
|
mutationFn: () => n.request(M(`/revisions/${e.id}/rollback`, {})),
|
|
596
|
-
onSuccess: (
|
|
597
|
-
|
|
598
|
-
const
|
|
599
|
-
|
|
597
|
+
onSuccess: (g) => {
|
|
598
|
+
b(!1), A.success("Rolled back to this revision");
|
|
599
|
+
const T = le(g);
|
|
600
|
+
T && A.warning(T, { duration: 1e4 }), i != null && i.length && e.timestamp && ye(e.timestamp), a == null || a();
|
|
600
601
|
},
|
|
601
602
|
onError: () => A.error("Failed to rollback")
|
|
602
603
|
});
|
|
603
|
-
async function we(
|
|
604
|
+
async function we(g) {
|
|
604
605
|
if (H) {
|
|
605
|
-
C(
|
|
606
|
+
C(g.field);
|
|
606
607
|
try {
|
|
607
|
-
const
|
|
608
|
+
const T = await n.request(
|
|
608
609
|
M("/revisions/o2m-restore", {
|
|
609
|
-
collection:
|
|
610
|
-
many_field:
|
|
611
|
-
parent_id:
|
|
610
|
+
collection: g.relatedCollection,
|
|
611
|
+
many_field: g.manyField,
|
|
612
|
+
parent_id: g.parentId,
|
|
612
613
|
target_timestamp: H
|
|
613
614
|
})
|
|
614
615
|
);
|
|
615
|
-
A.success(`Restored ${
|
|
616
|
-
const B = le(
|
|
616
|
+
A.success(`Restored ${g.label}`);
|
|
617
|
+
const B = le(T);
|
|
617
618
|
B && A.warning(B, { duration: 1e4 });
|
|
618
619
|
} catch {
|
|
619
|
-
A.error(`Failed to restore ${
|
|
620
|
+
A.error(`Failed to restore ${g.label}`);
|
|
620
621
|
} finally {
|
|
621
622
|
C(null);
|
|
622
623
|
}
|
|
@@ -627,7 +628,7 @@ function bt({
|
|
|
627
628
|
/* @__PURE__ */ t(
|
|
628
629
|
"span",
|
|
629
630
|
{
|
|
630
|
-
className:
|
|
631
|
+
className: R(
|
|
631
632
|
"absolute left-[11px] top-[18px] h-2.5 w-2.5 rounded-full ring-4 ring-white dark:ring-card",
|
|
632
633
|
ht[e.action ?? ""] ?? "bg-slate-300"
|
|
633
634
|
),
|
|
@@ -645,7 +646,7 @@ function bt({
|
|
|
645
646
|
"button",
|
|
646
647
|
{
|
|
647
648
|
type: "button",
|
|
648
|
-
onClick: () => p((
|
|
649
|
+
onClick: () => p((g) => !g),
|
|
649
650
|
className: "flex w-full items-center gap-2.5 rounded-md px-2 py-2.5 text-left transition-colors hover:bg-slate-50 dark:hover:bg-muted/40",
|
|
650
651
|
children: [
|
|
651
652
|
/* @__PURE__ */ t(
|
|
@@ -653,11 +654,11 @@ function bt({
|
|
|
653
654
|
{
|
|
654
655
|
userId: e.user_id,
|
|
655
656
|
className: "h-6 w-6",
|
|
656
|
-
fallback: /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: P(e,
|
|
657
|
+
fallback: /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: P(e, s).split(" ").map((g) => g[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() })
|
|
657
658
|
}
|
|
658
659
|
),
|
|
659
660
|
/* @__PURE__ */ l("span", { className: "min-w-0 flex-1 truncate text-[12.5px] text-slate-700 dark:text-slate-200", children: [
|
|
660
|
-
/* @__PURE__ */ t("span", { className: "font-medium", children: P(e,
|
|
661
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: P(e, s) }),
|
|
661
662
|
" ",
|
|
662
663
|
/* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: xt(e, z, fe) }),
|
|
663
664
|
m && /* @__PURE__ */ l(
|
|
@@ -682,37 +683,37 @@ function bt({
|
|
|
682
683
|
children: Ce
|
|
683
684
|
}
|
|
684
685
|
),
|
|
685
|
-
|
|
686
|
+
u ? /* @__PURE__ */ t($e, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }) : /* @__PURE__ */ t(Oe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
686
687
|
]
|
|
687
688
|
}
|
|
688
689
|
),
|
|
689
|
-
|
|
690
|
+
u && /* @__PURE__ */ l("div", { className: "space-y-2.5 px-2 pb-4 pt-1", children: [
|
|
690
691
|
/* @__PURE__ */ l("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [
|
|
691
692
|
/* @__PURE__ */ t("div", { className: "flex items-center overflow-hidden rounded-md border border-slate-200 dark:border-border", children: [
|
|
692
693
|
["changes", "What changed"],
|
|
693
694
|
["all", "Full record"]
|
|
694
|
-
].map(([
|
|
695
|
+
].map(([g, T]) => /* @__PURE__ */ t(
|
|
695
696
|
"button",
|
|
696
697
|
{
|
|
697
698
|
type: "button",
|
|
698
|
-
onClick: () => y(
|
|
699
|
-
className:
|
|
699
|
+
onClick: () => y(g),
|
|
700
|
+
className: R(
|
|
700
701
|
"px-2.5 py-1 text-[11.5px] transition-colors",
|
|
701
|
-
c ===
|
|
702
|
+
c === g ? "bg-nvr-cyan/10 font-medium text-nvr-navy dark:text-nvr-cyan" : "text-slate-400 hover:text-slate-600 dark:hover:text-slate-300"
|
|
702
703
|
),
|
|
703
|
-
children:
|
|
704
|
+
children: T
|
|
704
705
|
},
|
|
705
|
-
|
|
706
|
+
g
|
|
706
707
|
)) }),
|
|
707
708
|
/* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
|
|
708
709
|
/* @__PURE__ */ l(
|
|
709
710
|
"button",
|
|
710
711
|
{
|
|
711
712
|
type: "button",
|
|
712
|
-
onClick: () => f((
|
|
713
|
-
className:
|
|
713
|
+
onClick: () => f((g) => !g),
|
|
714
|
+
className: R(
|
|
714
715
|
"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11.5px] transition-colors",
|
|
715
|
-
|
|
716
|
+
S ? "border-nvr-cyan/40 text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-400 hover:text-slate-600 dark:border-border dark:hover:text-slate-300"
|
|
716
717
|
),
|
|
717
718
|
children: [
|
|
718
719
|
/* @__PURE__ */ t(qe, { className: "h-3 w-3" }),
|
|
@@ -720,7 +721,7 @@ function bt({
|
|
|
720
721
|
]
|
|
721
722
|
}
|
|
722
723
|
),
|
|
723
|
-
ge && (
|
|
724
|
+
ge && (h ? /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
724
725
|
/* @__PURE__ */ t("span", { className: "text-[11px] text-slate-500", children: "Restore this version?" }),
|
|
725
726
|
/* @__PURE__ */ t(
|
|
726
727
|
U,
|
|
@@ -739,7 +740,7 @@ function bt({
|
|
|
739
740
|
size: "sm",
|
|
740
741
|
variant: "outline",
|
|
741
742
|
className: "h-6 text-[11px]",
|
|
742
|
-
onClick: () =>
|
|
743
|
+
onClick: () => b(!1),
|
|
743
744
|
children: "Cancel"
|
|
744
745
|
}
|
|
745
746
|
)
|
|
@@ -750,7 +751,7 @@ function bt({
|
|
|
750
751
|
variant: "outline",
|
|
751
752
|
className: "h-6 gap-1 text-[11px]",
|
|
752
753
|
disabled: J.isPending,
|
|
753
|
-
onClick: () =>
|
|
754
|
+
onClick: () => b(!0),
|
|
754
755
|
title: "Set the whole record back to how it looked after this save",
|
|
755
756
|
children: [
|
|
756
757
|
/* @__PURE__ */ t(me, { className: "h-3 w-3" }),
|
|
@@ -760,7 +761,7 @@ function bt({
|
|
|
760
761
|
))
|
|
761
762
|
] })
|
|
762
763
|
] }),
|
|
763
|
-
|
|
764
|
+
S && /* @__PURE__ */ t(vt, { revisionId: e.id ?? "" }),
|
|
764
765
|
/* @__PURE__ */ t(
|
|
765
766
|
ut,
|
|
766
767
|
{
|
|
@@ -769,49 +770,49 @@ function bt({
|
|
|
769
770
|
meta: d,
|
|
770
771
|
fieldRevert: ve,
|
|
771
772
|
mode: c,
|
|
772
|
-
hideStatusChips:
|
|
773
|
-
ownFields:
|
|
773
|
+
hideStatusChips: _,
|
|
774
|
+
ownFields: x && e.delta ? be : null
|
|
774
775
|
}
|
|
775
776
|
),
|
|
776
777
|
H && i && i.length > 0 && /* @__PURE__ */ l("div", { className: "space-y-1.5 rounded-md border border-slate-100 bg-slate-50 p-2 dark:border-border dark:bg-muted/30", children: [
|
|
777
778
|
/* @__PURE__ */ t("p", { className: "text-[10.5px] font-medium text-slate-500", children: "Also restore related rows?" }),
|
|
778
|
-
i.map((
|
|
779
|
-
/* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children:
|
|
779
|
+
i.map((g) => /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-2", children: [
|
|
780
|
+
/* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children: g.label }),
|
|
780
781
|
/* @__PURE__ */ t(
|
|
781
782
|
"button",
|
|
782
783
|
{
|
|
783
784
|
type: "button",
|
|
784
|
-
disabled: N ===
|
|
785
|
-
onClick: () => we(
|
|
785
|
+
disabled: N === g.field,
|
|
786
|
+
onClick: () => we(g),
|
|
786
787
|
className: "rounded border border-nvr-cyan/40 px-2 py-0.5 text-[10.5px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 disabled:opacity-40",
|
|
787
|
-
children: N ===
|
|
788
|
+
children: N === g.field ? "Restoring…" : "Restore"
|
|
788
789
|
}
|
|
789
790
|
)
|
|
790
|
-
] },
|
|
791
|
+
] }, g.field))
|
|
791
792
|
] })
|
|
792
793
|
] })
|
|
793
794
|
] });
|
|
794
795
|
}
|
|
795
|
-
function gt({ data: e, meta:
|
|
796
|
-
const [d, a] = w(null), [i, o] = w(""), [n,
|
|
796
|
+
function gt({ data: e, meta: r }) {
|
|
797
|
+
const [d, a] = w(null), [i, o] = w(""), [n, s] = w(""), [m, u] = w(""), p = j(() => {
|
|
797
798
|
if (!i || !e) return null;
|
|
798
799
|
const c = (/* @__PURE__ */ new Date(`${i}T23:59:59`)).getTime();
|
|
799
800
|
return e.find((y) => y.timestamp && new Date(y.timestamp).getTime() <= c) ?? null;
|
|
800
|
-
}, [i, e]),
|
|
801
|
+
}, [i, e]), h = j(() => {
|
|
801
802
|
if (!n || !m || !e) return null;
|
|
802
803
|
const c = (/* @__PURE__ */ new Date(`${n}T23:59:59`)).getTime(), y = (/* @__PURE__ */ new Date(`${m}T23:59:59`)).getTime();
|
|
803
804
|
if (y <= c) return { error: "The second date must be after the first" };
|
|
804
|
-
const
|
|
805
|
+
const S = (v) => e.find((O) => O.timestamp && new Date(O.timestamp).getTime() <= v) ?? null, f = S(c), N = S(y);
|
|
805
806
|
if (!N) return { error: "No snapshot exists at or before the second date" };
|
|
806
|
-
const C = (f == null ? void 0 : f.data) ?? {},
|
|
807
|
+
const C = (f == null ? void 0 : f.data) ?? {}, x = N.data ?? {}, _ = /* @__PURE__ */ new Map();
|
|
807
808
|
for (const v of [...e].reverse()) {
|
|
808
809
|
const O = v.timestamp ? new Date(v.timestamp).getTime() : 0;
|
|
809
810
|
if (!(O <= c || O > y || !v.delta))
|
|
810
811
|
for (const z of Object.keys(v.delta))
|
|
811
|
-
|
|
812
|
+
_.set(z, { name: P(v), when: v.timestamp });
|
|
812
813
|
}
|
|
813
|
-
return { fields: [.../* @__PURE__ */ new Set([...Object.keys(C), ...Object.keys(
|
|
814
|
-
}, [n, m, e]),
|
|
814
|
+
return { fields: [.../* @__PURE__ */ new Set([...Object.keys(C), ...Object.keys(x)])].filter((v) => String(C[v] ?? "") !== String(x[v] ?? "")).map((v) => ({ field: v, from: C[v], to: x[v], by: _.get(v) ?? null })) };
|
|
815
|
+
}, [n, m, e]), b = "h-7 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card";
|
|
815
816
|
return /* @__PURE__ */ l("div", { className: "space-y-2", children: [
|
|
816
817
|
/* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
|
|
817
818
|
/* @__PURE__ */ l(
|
|
@@ -819,7 +820,7 @@ function gt({ data: e, meta: s }) {
|
|
|
819
820
|
{
|
|
820
821
|
type: "button",
|
|
821
822
|
onClick: () => a(d === "asof" ? null : "asof"),
|
|
822
|
-
className:
|
|
823
|
+
className: R(
|
|
823
824
|
"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-[11.5px] transition-colors",
|
|
824
825
|
d === "asof" || i ? "border-nvr-cyan/40 bg-nvr-cyan/5 font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400 dark:hover:text-slate-200"
|
|
825
826
|
),
|
|
@@ -834,7 +835,7 @@ function gt({ data: e, meta: s }) {
|
|
|
834
835
|
{
|
|
835
836
|
type: "button",
|
|
836
837
|
onClick: () => a(d === "compare" ? null : "compare"),
|
|
837
|
-
className:
|
|
838
|
+
className: R(
|
|
838
839
|
"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-[11.5px] transition-colors",
|
|
839
840
|
d === "compare" || n && m ? "border-nvr-cyan/40 bg-nvr-cyan/5 font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400 dark:hover:text-slate-200"
|
|
840
841
|
),
|
|
@@ -854,7 +855,7 @@ function gt({ data: e, meta: s }) {
|
|
|
854
855
|
type: "date",
|
|
855
856
|
value: i,
|
|
856
857
|
onChange: (c) => o(c.target.value),
|
|
857
|
-
className:
|
|
858
|
+
className: b,
|
|
858
859
|
"aria-label": "View record as of date",
|
|
859
860
|
"data-as-of": !0
|
|
860
861
|
}
|
|
@@ -876,7 +877,7 @@ function gt({ data: e, meta: s }) {
|
|
|
876
877
|
" ",
|
|
877
878
|
p.timestamp ? E(p.timestamp) : i
|
|
878
879
|
] }) }),
|
|
879
|
-
/* @__PURE__ */ t("div", { className: "max-h-80 overflow-y-auto", children: Object.entries(p.data ?? {}).filter(([, c]) => c != null && c !== "").sort(([c], [y]) => k(
|
|
880
|
+
/* @__PURE__ */ t("div", { className: "max-h-80 overflow-y-auto", children: Object.entries(p.data ?? {}).filter(([, c]) => c != null && c !== "").sort(([c], [y]) => k(r, c).label.localeCompare(k(r, y).label)).map(([c, y]) => /* @__PURE__ */ l(
|
|
880
881
|
"div",
|
|
881
882
|
{
|
|
882
883
|
className: "flex items-start gap-3 border-b border-slate-100 px-2.5 py-1.5 last:border-0 dark:border-border/60",
|
|
@@ -886,10 +887,10 @@ function gt({ data: e, meta: s }) {
|
|
|
886
887
|
{
|
|
887
888
|
className: "w-[200px] shrink-0 text-[11.5px] font-medium text-slate-600 dark:text-slate-300",
|
|
888
889
|
title: c,
|
|
889
|
-
children: k(
|
|
890
|
+
children: k(r, c).label
|
|
890
891
|
}
|
|
891
892
|
),
|
|
892
|
-
/* @__PURE__ */ t("span", { className: "break-words text-[11.5px] text-slate-700 dark:text-slate-300", children: /* @__PURE__ */ t(F, { value: y, meta: k(
|
|
893
|
+
/* @__PURE__ */ t("span", { className: "break-words text-[11.5px] text-slate-700 dark:text-slate-300", children: /* @__PURE__ */ t(F, { value: y, meta: k(r, c), tone: "after" }) })
|
|
893
894
|
]
|
|
894
895
|
},
|
|
895
896
|
c
|
|
@@ -904,8 +905,8 @@ function gt({ data: e, meta: s }) {
|
|
|
904
905
|
{
|
|
905
906
|
type: "date",
|
|
906
907
|
value: n,
|
|
907
|
-
onChange: (c) =>
|
|
908
|
-
className:
|
|
908
|
+
onChange: (c) => s(c.target.value),
|
|
909
|
+
className: b,
|
|
909
910
|
"aria-label": "Compare from date",
|
|
910
911
|
"data-diff-from": !0
|
|
911
912
|
}
|
|
@@ -916,8 +917,8 @@ function gt({ data: e, meta: s }) {
|
|
|
916
917
|
{
|
|
917
918
|
type: "date",
|
|
918
919
|
value: m,
|
|
919
|
-
onChange: (c) =>
|
|
920
|
-
className:
|
|
920
|
+
onChange: (c) => u(c.target.value),
|
|
921
|
+
className: b,
|
|
921
922
|
"aria-label": "Compare to date",
|
|
922
923
|
"data-diff-to": !0
|
|
923
924
|
}
|
|
@@ -927,31 +928,31 @@ function gt({ data: e, meta: s }) {
|
|
|
927
928
|
{
|
|
928
929
|
type: "button",
|
|
929
930
|
onClick: () => {
|
|
930
|
-
|
|
931
|
+
s(""), u("");
|
|
931
932
|
},
|
|
932
933
|
className: "text-[11px] text-slate-400 hover:text-slate-600 dark:hover:text-slate-300",
|
|
933
934
|
children: "Clear"
|
|
934
935
|
}
|
|
935
936
|
)
|
|
936
937
|
] }),
|
|
937
|
-
(
|
|
938
|
-
(
|
|
938
|
+
(h == null ? void 0 : h.error) != null && /* @__PURE__ */ t("p", { className: "mt-2 text-[12px] text-amber-600 dark:text-amber-400", children: h == null ? void 0 : h.error }),
|
|
939
|
+
(h == null ? void 0 : h.fields) != null && /* @__PURE__ */ l(
|
|
939
940
|
"div",
|
|
940
941
|
{
|
|
941
942
|
className: "mt-2 overflow-hidden rounded-lg border border-nvr-cyan/40 bg-white dark:bg-card",
|
|
942
943
|
"data-between-diff": !0,
|
|
943
944
|
children: [
|
|
944
945
|
/* @__PURE__ */ t("div", { className: "border-b border-slate-200 bg-[#f0fbff] px-2.5 py-1.5 dark:border-border dark:bg-nvr-cyan/10", children: /* @__PURE__ */ l("span", { className: "text-[11.5px] font-semibold text-slate-700 dark:text-slate-200", children: [
|
|
945
|
-
|
|
946
|
+
h.fields.length,
|
|
946
947
|
" field",
|
|
947
|
-
|
|
948
|
+
h.fields.length === 1 ? "" : "s",
|
|
948
949
|
" changed between ",
|
|
949
950
|
n,
|
|
950
951
|
" and",
|
|
951
952
|
" ",
|
|
952
953
|
m
|
|
953
954
|
] }) }),
|
|
954
|
-
|
|
955
|
+
h.fields.length === 0 ? /* @__PURE__ */ t("p", { className: "px-2.5 py-3 text-[12px] text-slate-400", children: "Nothing changed in that window." }) : /* @__PURE__ */ t("div", { className: "max-h-80 overflow-y-auto", children: h.fields.map((c) => /* @__PURE__ */ l(
|
|
955
956
|
"div",
|
|
956
957
|
{
|
|
957
958
|
className: "border-b border-slate-100 px-2.5 py-1.5 last:border-0 dark:border-border/60",
|
|
@@ -962,7 +963,7 @@ function gt({ data: e, meta: s }) {
|
|
|
962
963
|
{
|
|
963
964
|
className: "text-[11.5px] font-medium text-slate-600 dark:text-slate-300",
|
|
964
965
|
title: c.field,
|
|
965
|
-
children: k(
|
|
966
|
+
children: k(r, c.field).label
|
|
966
967
|
}
|
|
967
968
|
),
|
|
968
969
|
c.by && /* @__PURE__ */ l("span", { className: "shrink-0 text-[10.5px] text-slate-400", children: [
|
|
@@ -971,8 +972,8 @@ function gt({ data: e, meta: s }) {
|
|
|
971
972
|
] })
|
|
972
973
|
] }),
|
|
973
974
|
/* @__PURE__ */ l("p", { className: "mt-0.5 flex flex-wrap items-baseline gap-x-2 break-words text-[11.5px]", children: [
|
|
974
|
-
/* @__PURE__ */ t("span", { className: "text-red-500 line-through dark:text-red-400", children: /* @__PURE__ */ t(F, { value: c.from, meta: k(
|
|
975
|
-
/* @__PURE__ */ t("span", { className: "text-emerald-600 dark:text-emerald-400", children: /* @__PURE__ */ t(F, { value: c.to, meta: k(
|
|
975
|
+
/* @__PURE__ */ t("span", { className: "text-red-500 line-through dark:text-red-400", children: /* @__PURE__ */ t(F, { value: c.from, meta: k(r, c.field), tone: "before" }) }),
|
|
976
|
+
/* @__PURE__ */ t("span", { className: "text-emerald-600 dark:text-emerald-400", children: /* @__PURE__ */ t(F, { value: c.to, meta: k(r, c.field), tone: "after" }) })
|
|
976
977
|
] })
|
|
977
978
|
]
|
|
978
979
|
},
|
|
@@ -994,65 +995,65 @@ function yt(e) {
|
|
|
994
995
|
}
|
|
995
996
|
function Nt({
|
|
996
997
|
collection: e,
|
|
997
|
-
item:
|
|
998
|
+
item: r,
|
|
998
999
|
onRollback: d,
|
|
999
1000
|
inlineTableFields: a
|
|
1000
1001
|
}) {
|
|
1001
|
-
const i = D(), o = xe(e, !0), { data: n, isLoading:
|
|
1002
|
-
queryKey: ["revisions", e,
|
|
1003
|
-
queryFn: () => i.request(L("/revisions", { collection: e, item:
|
|
1002
|
+
const i = D(), o = xe(e, !0), { data: n, isLoading: s } = I({
|
|
1003
|
+
queryKey: ["revisions", e, r],
|
|
1004
|
+
queryFn: () => i.request(L("/revisions", { collection: e, item: r })).then((f) => f.data ?? []),
|
|
1004
1005
|
staleTime: 3e4
|
|
1005
1006
|
}), m = te();
|
|
1006
|
-
Me(e,
|
|
1007
|
-
const
|
|
1007
|
+
Me(e, r, [["revisions", e, r]], { client: m });
|
|
1008
|
+
const u = Le(null), p = j(() => {
|
|
1008
1009
|
if (!n) return /* @__PURE__ */ new Set();
|
|
1009
1010
|
const f = n.map(q);
|
|
1010
|
-
if (!
|
|
1011
|
-
return
|
|
1012
|
-
const N =
|
|
1011
|
+
if (!u.current)
|
|
1012
|
+
return u.current = new Set(f), /* @__PURE__ */ new Set();
|
|
1013
|
+
const N = u.current;
|
|
1013
1014
|
return new Set(f.filter((C) => !N.has(C)));
|
|
1014
|
-
}, [n]),
|
|
1015
|
+
}, [n]), h = (n == null ? void 0 : n.length) ?? 0, b = j(() => (n ?? []).filter(X), [n]), c = j(
|
|
1015
1016
|
() => (n ?? []).filter((f) => f.actor && f.actor.kind !== "person").map((f) => ({ action: f.action, user: f.user_id, actor: f.actor })),
|
|
1016
1017
|
[n]
|
|
1017
|
-
), y = Ue(c, { enabled: c.length > 0 }),
|
|
1018
|
+
), y = Ue(c, { enabled: c.length > 0 }), S = j(() => {
|
|
1018
1019
|
const f = [];
|
|
1019
1020
|
for (const N of n ?? []) {
|
|
1020
|
-
const C = yt(N.timestamp),
|
|
1021
|
-
|
|
1021
|
+
const C = yt(N.timestamp), x = f[f.length - 1];
|
|
1022
|
+
x && x.day === C ? x.revisions.push(N) : f.push({ day: C, revisions: [N] });
|
|
1022
1023
|
}
|
|
1023
1024
|
return f;
|
|
1024
1025
|
}, [n]);
|
|
1025
|
-
return
|
|
1026
|
+
return s ? /* @__PURE__ */ t("div", { className: "space-y-2 pt-3", children: [1, 2, 3, 4].map((f) => /* @__PURE__ */ t(Ge, { className: "h-11 rounded-md" }, f)) }) : h === 0 ? /* @__PURE__ */ l("div", { className: "flex flex-col items-center py-16 text-center", children: [
|
|
1026
1027
|
/* @__PURE__ */ t(G, { className: "mb-2 h-8 w-8 text-slate-300 dark:text-slate-600" }),
|
|
1027
1028
|
/* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: "No history yet" }),
|
|
1028
1029
|
/* @__PURE__ */ t("p", { className: "mt-1 max-w-[38ch] text-[12px] text-slate-400", children: "Every save records who changed what — the trail will appear here." })
|
|
1029
1030
|
] }) : /* @__PURE__ */ t(re.Provider, { value: y, children: /* @__PURE__ */ l("div", { className: "space-y-3 pt-3", children: [
|
|
1030
|
-
/* @__PURE__ */ t(gt, { data:
|
|
1031
|
-
|
|
1032
|
-
/* @__PURE__ */ t("div", { children:
|
|
1031
|
+
/* @__PURE__ */ t(gt, { data: b, meta: o }),
|
|
1032
|
+
b.length >= 3 && /* @__PURE__ */ t(wt, { revisions: b, meta: o }),
|
|
1033
|
+
/* @__PURE__ */ t("div", { children: S.map((f) => /* @__PURE__ */ l("div", { children: [
|
|
1033
1034
|
/* @__PURE__ */ t("div", { className: "sticky top-0 z-10 -mx-6 border-b border-slate-100 bg-white px-6 py-1.5 dark:border-border/60 dark:bg-card", children: /* @__PURE__ */ t("span", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: f.day }) }),
|
|
1034
1035
|
f.revisions.map((N) => {
|
|
1035
|
-
const C = (n ?? []).indexOf(N),
|
|
1036
|
+
const C = (n ?? []).indexOf(N), x = C === ((n == null ? void 0 : n.length) ?? 1) - 1;
|
|
1036
1037
|
if (Ze(N))
|
|
1037
1038
|
return /* @__PURE__ */ l(
|
|
1038
1039
|
"div",
|
|
1039
1040
|
{
|
|
1040
|
-
className:
|
|
1041
|
+
className: R(
|
|
1041
1042
|
"nvr-fade-in relative",
|
|
1042
1043
|
p.has(q(N)) && "rounded-md bg-nvr-cyan/[0.06]"
|
|
1043
1044
|
),
|
|
1044
1045
|
children: [
|
|
1045
1046
|
p.has(q(N)) && /* @__PURE__ */ t(ce, {}),
|
|
1046
|
-
/* @__PURE__ */ t(ft, { revision: N, isLast:
|
|
1047
|
+
/* @__PURE__ */ t(ft, { revision: N, isLast: x })
|
|
1047
1048
|
]
|
|
1048
1049
|
},
|
|
1049
1050
|
q(N)
|
|
1050
1051
|
);
|
|
1051
|
-
const
|
|
1052
|
+
const _ = (n ?? []).slice(C + 1).find(X);
|
|
1052
1053
|
return /* @__PURE__ */ l(
|
|
1053
1054
|
"div",
|
|
1054
1055
|
{
|
|
1055
|
-
className:
|
|
1056
|
+
className: R(
|
|
1056
1057
|
"nvr-fade-in relative",
|
|
1057
1058
|
p.has(q(N)) && "rounded-md bg-nvr-cyan/[0.06]"
|
|
1058
1059
|
),
|
|
@@ -1062,11 +1063,11 @@ function Nt({
|
|
|
1062
1063
|
bt,
|
|
1063
1064
|
{
|
|
1064
1065
|
revision: N,
|
|
1065
|
-
previousData: (
|
|
1066
|
+
previousData: (_ == null ? void 0 : _.data) ?? null,
|
|
1066
1067
|
meta: o,
|
|
1067
1068
|
onRollback: d,
|
|
1068
1069
|
inlineTableFields: a,
|
|
1069
|
-
isLast:
|
|
1070
|
+
isLast: x
|
|
1070
1071
|
}
|
|
1071
1072
|
)
|
|
1072
1073
|
]
|
|
@@ -1092,26 +1093,26 @@ function ce() {
|
|
|
1092
1093
|
}
|
|
1093
1094
|
function Ut({
|
|
1094
1095
|
collection: e,
|
|
1095
|
-
item:
|
|
1096
|
+
item: r,
|
|
1096
1097
|
onRollback: d,
|
|
1097
1098
|
triggerClassName: a,
|
|
1098
1099
|
inlineTableFields: i,
|
|
1099
1100
|
open: o,
|
|
1100
1101
|
onOpenChange: n,
|
|
1101
|
-
compact:
|
|
1102
|
+
compact: s
|
|
1102
1103
|
}) {
|
|
1103
1104
|
return /* @__PURE__ */ l(ze, { open: o, onOpenChange: n, children: [
|
|
1104
1105
|
!(o !== void 0) && /* @__PURE__ */ t(He, { asChild: !0, children: /* @__PURE__ */ l(
|
|
1105
1106
|
U,
|
|
1106
1107
|
{
|
|
1107
|
-
variant:
|
|
1108
|
+
variant: s ? "ghost" : "outline",
|
|
1108
1109
|
size: "sm",
|
|
1109
|
-
title:
|
|
1110
|
+
title: s ? "History — revisions of this record" : void 0,
|
|
1110
1111
|
"aria-label": "History",
|
|
1111
|
-
className: a ?? (
|
|
1112
|
+
className: a ?? (s ? "h-8 w-8 rounded-none p-0" : "gap-1.5"),
|
|
1112
1113
|
children: [
|
|
1113
|
-
/* @__PURE__ */ t(G, { className:
|
|
1114
|
-
!
|
|
1114
|
+
/* @__PURE__ */ t(G, { className: s ? "h-4 w-4" : "h-3.5 w-3.5" }),
|
|
1115
|
+
!s && "History"
|
|
1115
1116
|
]
|
|
1116
1117
|
}
|
|
1117
1118
|
) }),
|
|
@@ -1123,13 +1124,13 @@ function Ut({
|
|
|
1123
1124
|
] }),
|
|
1124
1125
|
/* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "Who changed what, when — expand any entry to see the exact values, revert a single field, or restore the whole version." })
|
|
1125
1126
|
] }),
|
|
1126
|
-
/* @__PURE__ */ t(kt, { collection: e, item:
|
|
1127
|
-
/* @__PURE__ */ t(Xe, { collection: e, item: String(
|
|
1127
|
+
/* @__PURE__ */ t(kt, { collection: e, item: r }),
|
|
1128
|
+
/* @__PURE__ */ t(Xe, { collection: e, item: String(r) }),
|
|
1128
1129
|
/* @__PURE__ */ t(
|
|
1129
1130
|
Nt,
|
|
1130
1131
|
{
|
|
1131
1132
|
collection: e,
|
|
1132
|
-
item:
|
|
1133
|
+
item: r,
|
|
1133
1134
|
onRollback: d,
|
|
1134
1135
|
inlineTableFields: i
|
|
1135
1136
|
}
|
|
@@ -1137,10 +1138,10 @@ function Ut({
|
|
|
1137
1138
|
] }) })
|
|
1138
1139
|
] });
|
|
1139
1140
|
}
|
|
1140
|
-
function kt({ collection: e, item:
|
|
1141
|
-
const d = D(), a = xe(e, !0), [i, o] = w(""), [n,
|
|
1142
|
-
queryKey: ["rev-value-search", e,
|
|
1143
|
-
queryFn: () => d.request(L("/revisions/value-search", { collection: e, item:
|
|
1141
|
+
function kt({ collection: e, item: r }) {
|
|
1142
|
+
const d = D(), a = xe(e, !0), [i, o] = w(""), [n, s] = w(""), { data: m, isFetching: u } = I({
|
|
1143
|
+
queryKey: ["rev-value-search", e, r, n],
|
|
1144
|
+
queryFn: () => d.request(L("/revisions/value-search", { collection: e, item: r, q: n })).then((p) => p.data),
|
|
1144
1145
|
enabled: n.length >= 2
|
|
1145
1146
|
});
|
|
1146
1147
|
return /* @__PURE__ */ l("div", { className: "mt-3", children: [
|
|
@@ -1152,7 +1153,7 @@ function kt({ collection: e, item: s }) {
|
|
|
1152
1153
|
value: i,
|
|
1153
1154
|
onChange: (p) => o(p.target.value),
|
|
1154
1155
|
onKeyDown: (p) => {
|
|
1155
|
-
p.key === "Enter" &&
|
|
1156
|
+
p.key === "Enter" && s(i.trim());
|
|
1156
1157
|
},
|
|
1157
1158
|
placeholder: "Search this record’s history for a value — who wrote it, and when",
|
|
1158
1159
|
className: "h-8 w-full rounded-md border border-slate-200 bg-background pl-8 pr-8 text-[12.5px] outline-none focus:border-nvr-cyan dark:border-border"
|
|
@@ -1163,7 +1164,7 @@ function kt({ collection: e, item: s }) {
|
|
|
1163
1164
|
{
|
|
1164
1165
|
type: "button",
|
|
1165
1166
|
onClick: () => {
|
|
1166
|
-
o(""),
|
|
1167
|
+
o(""), s("");
|
|
1167
1168
|
},
|
|
1168
1169
|
className: "absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",
|
|
1169
1170
|
"aria-label": "Clear search",
|
|
@@ -1171,20 +1172,20 @@ function kt({ collection: e, item: s }) {
|
|
|
1171
1172
|
}
|
|
1172
1173
|
)
|
|
1173
1174
|
] }),
|
|
1174
|
-
n && /* @__PURE__ */ t("div", { className: "mt-2 space-y-1.5 rounded-lg border border-slate-200 p-2.5 dark:border-border", children:
|
|
1175
|
+
n && /* @__PURE__ */ t("div", { className: "mt-2 space-y-1.5 rounded-lg border border-slate-200 p-2.5 dark:border-border", children: u ? /* @__PURE__ */ t("p", { className: "text-[11.5px] text-slate-400", children: "Searching…" }) : ((m == null ? void 0 : m.matches) ?? []).length === 0 ? /* @__PURE__ */ l("p", { className: "text-[11.5px] text-slate-400", children: [
|
|
1175
1176
|
"“",
|
|
1176
1177
|
n,
|
|
1177
1178
|
"” never appears in this record’s recorded changes."
|
|
1178
1179
|
] }) : /* @__PURE__ */ l($, { children: [
|
|
1179
1180
|
m == null ? void 0 : m.matches.map((p) => /* @__PURE__ */ l("div", { className: "text-[11.5px]", children: [
|
|
1180
|
-
/* @__PURE__ */ t("p", { className: "text-slate-600 dark:text-slate-300", children: p.fields.map((
|
|
1181
|
-
/* @__PURE__ */ t("span", { className: "font-medium", title:
|
|
1181
|
+
/* @__PURE__ */ t("p", { className: "text-slate-600 dark:text-slate-300", children: p.fields.map((h) => /* @__PURE__ */ l("span", { children: [
|
|
1182
|
+
/* @__PURE__ */ t("span", { className: "font-medium", title: h.field, children: k(a, h.field).label }),
|
|
1182
1183
|
" ",
|
|
1183
1184
|
"→ “",
|
|
1184
|
-
|
|
1185
|
+
h.value.length > 60 ? `${h.value.slice(0, 60)}…` : h.value,
|
|
1185
1186
|
"”",
|
|
1186
1187
|
" "
|
|
1187
|
-
] },
|
|
1188
|
+
] }, h.field)) }),
|
|
1188
1189
|
/* @__PURE__ */ l("p", { className: "text-[10.5px] text-slate-400", children: [
|
|
1189
1190
|
p.user_name ?? "System",
|
|
1190
1191
|
" · ",
|
|
@@ -1199,12 +1200,12 @@ function kt({ collection: e, item: s }) {
|
|
|
1199
1200
|
] });
|
|
1200
1201
|
}
|
|
1201
1202
|
function vt({ revisionId: e }) {
|
|
1202
|
-
const
|
|
1203
|
+
const r = D(), d = te(), [a, i] = w(""), { data: o = [] } = I({
|
|
1203
1204
|
queryKey: ["revision-notes", String(e)],
|
|
1204
|
-
queryFn: () =>
|
|
1205
|
+
queryFn: () => r.request(L("/comments", { collection: "nivaro_revisions", item: String(e) })).then((s) => s.data ?? []).catch(() => []),
|
|
1205
1206
|
staleTime: 3e4
|
|
1206
1207
|
}), n = Y({
|
|
1207
|
-
mutationFn: () =>
|
|
1208
|
+
mutationFn: () => r.request(
|
|
1208
1209
|
M("/comments", { collection: "nivaro_revisions", item: String(e), text: a })
|
|
1209
1210
|
),
|
|
1210
1211
|
onSuccess: () => {
|
|
@@ -1213,21 +1214,21 @@ function vt({ revisionId: e }) {
|
|
|
1213
1214
|
onError: () => A.error("Note failed")
|
|
1214
1215
|
});
|
|
1215
1216
|
return /* @__PURE__ */ l("div", { className: "rounded-md border border-slate-100 bg-slate-50/60 p-2 dark:border-border/60 dark:bg-muted/30", children: [
|
|
1216
|
-
o.map((
|
|
1217
|
-
|
|
1217
|
+
o.map((s) => /* @__PURE__ */ l("p", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children: [
|
|
1218
|
+
s.text,
|
|
1218
1219
|
" ",
|
|
1219
1220
|
/* @__PURE__ */ l("span", { className: "text-[10px] text-slate-400", children: [
|
|
1220
1221
|
"— ",
|
|
1221
|
-
|
|
1222
|
+
s.user_name ?? "someone",
|
|
1222
1223
|
" · ",
|
|
1223
|
-
ae(
|
|
1224
|
+
ae(s.created_at)
|
|
1224
1225
|
] })
|
|
1225
|
-
] },
|
|
1226
|
+
] }, s.id)),
|
|
1226
1227
|
/* @__PURE__ */ l(
|
|
1227
1228
|
"form",
|
|
1228
1229
|
{
|
|
1229
|
-
onSubmit: (
|
|
1230
|
-
|
|
1230
|
+
onSubmit: (s) => {
|
|
1231
|
+
s.preventDefault(), a.trim() && n.mutate();
|
|
1231
1232
|
},
|
|
1232
1233
|
className: "mt-1 flex gap-1.5",
|
|
1233
1234
|
children: [
|
|
@@ -1235,7 +1236,7 @@ function vt({ revisionId: e }) {
|
|
|
1235
1236
|
"input",
|
|
1236
1237
|
{
|
|
1237
1238
|
value: a,
|
|
1238
|
-
onChange: (
|
|
1239
|
+
onChange: (s) => i(s.target.value),
|
|
1239
1240
|
placeholder: "Annotate this revision…",
|
|
1240
1241
|
className: "h-6 flex-1 rounded border border-slate-200 bg-transparent px-1.5 text-[11.5px] outline-none dark:border-border"
|
|
1241
1242
|
}
|
|
@@ -1256,7 +1257,7 @@ function vt({ revisionId: e }) {
|
|
|
1256
1257
|
}
|
|
1257
1258
|
function wt({
|
|
1258
1259
|
revisions: e,
|
|
1259
|
-
meta:
|
|
1260
|
+
meta: r
|
|
1260
1261
|
}) {
|
|
1261
1262
|
const d = [...e].reverse(), [a, i] = w(!1), [o, n] = w(0);
|
|
1262
1263
|
Ee(() => {
|
|
@@ -1265,10 +1266,10 @@ function wt({
|
|
|
1265
1266
|
i(!1);
|
|
1266
1267
|
return;
|
|
1267
1268
|
}
|
|
1268
|
-
const
|
|
1269
|
-
return () => clearTimeout(
|
|
1269
|
+
const u = setTimeout(() => n((p) => p + 1), 1600);
|
|
1270
|
+
return () => clearTimeout(u);
|
|
1270
1271
|
}, [a, o, d.length]);
|
|
1271
|
-
const
|
|
1272
|
+
const s = d[o], m = s != null && s.delta ? Object.keys(s.delta).slice(0, 5).map((u) => k(r, u).label) : [];
|
|
1272
1273
|
return /* @__PURE__ */ l("div", { className: "rounded-md border border-slate-200 bg-slate-50/70 p-2 dark:border-border dark:bg-muted/30", children: [
|
|
1273
1274
|
/* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
|
|
1274
1275
|
/* @__PURE__ */ t(
|
|
@@ -1276,7 +1277,7 @@ function wt({
|
|
|
1276
1277
|
{
|
|
1277
1278
|
type: "button",
|
|
1278
1279
|
onClick: () => {
|
|
1279
|
-
!a && o >= d.length - 1 && n(0), i((
|
|
1280
|
+
!a && o >= d.length - 1 && n(0), i((u) => !u);
|
|
1280
1281
|
},
|
|
1281
1282
|
className: "rounded-md bg-nvr-cyan px-2.5 py-1 text-[11.5px] font-semibold text-white",
|
|
1282
1283
|
children: a ? "Pause" : "▶ Time-lapse"
|
|
@@ -1289,8 +1290,8 @@ function wt({
|
|
|
1289
1290
|
min: 0,
|
|
1290
1291
|
max: Math.max(0, d.length - 1),
|
|
1291
1292
|
value: o,
|
|
1292
|
-
onChange: (
|
|
1293
|
-
i(!1), n(Number(
|
|
1293
|
+
onChange: (u) => {
|
|
1294
|
+
i(!1), n(Number(u.target.value));
|
|
1294
1295
|
},
|
|
1295
1296
|
className: "flex-1 accent-nvr-cyan",
|
|
1296
1297
|
"aria-label": "History position"
|
|
@@ -1302,10 +1303,10 @@ function wt({
|
|
|
1302
1303
|
d.length
|
|
1303
1304
|
] })
|
|
1304
1305
|
] }),
|
|
1305
|
-
|
|
1306
|
-
/* @__PURE__ */ t("span", { className: "font-medium capitalize", children:
|
|
1307
|
-
|
|
1308
|
-
|
|
1306
|
+
s && /* @__PURE__ */ l("p", { className: "mt-1 text-[11.5px] text-slate-600 dark:text-slate-300", children: [
|
|
1307
|
+
/* @__PURE__ */ t("span", { className: "font-medium capitalize", children: s.action ?? "change" }),
|
|
1308
|
+
s.timestamp ? ` · ${E(s.timestamp)}` : "",
|
|
1309
|
+
s.user_name ? ` · ${s.user_name}` : "",
|
|
1309
1310
|
m.length > 0 && /* @__PURE__ */ l("span", { className: "ml-1 text-[10.5px] text-slate-400", children: [
|
|
1310
1311
|
"changed: ",
|
|
1311
1312
|
m.join(", ")
|