@nivaro/react 0.3.13 → 0.3.14
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/components/slots/pipeline/OwnersSection.js +79 -75
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +33 -2
- package/dist/index.js +520 -516
- package/dist/shared/components/CollectionBrowserView.js +2373 -2298
- package/dist/shared/components/DataTable.js +347 -335
- package/dist/shared/components/ItemEditForm.js +5278 -5149
- package/dist/shared/components/ListLoadError.js +33 -0
- package/dist/shared/components/PageRenderer.js +562 -529
- package/dist/shared/components/ProfileView.js +53 -51
- package/dist/shared/components/RecordReadView.js +119 -117
- package/dist/shared/components/ReportView.js +1268 -1241
- package/dist/shared/components/cbv/export-rows.js +69 -0
- package/dist/shared/components/cbv/saved-view-risk.js +35 -0
- package/dist/shared/components/cbv/unknown-fields.js +18 -0
- package/dist/shared/components/integrations/console/AlertsView.js +27 -25
- package/dist/shared/components/integrations/console/EventsView.js +244 -209
- package/dist/shared/components/item-edit/CatalogPickerField.js +946 -878
- package/dist/shared/components/item-edit/DraftRecoveryBanner.js +84 -57
- package/dist/shared/components/item-edit/FieldAffordances.js +63 -61
- package/dist/shared/components/item-edit/FieldRow.js +195 -179
- package/dist/shared/components/item-edit/FilePickerField.js +257 -254
- package/dist/shared/components/item-edit/HeaderTools.js +139 -95
- package/dist/shared/components/item-edit/InlineTableField.js +2087 -2075
- package/dist/shared/components/item-edit/RowComments.js +1 -3
- package/dist/shared/components/item-edit/SummaryPanel.js +62 -62
- package/dist/shared/components/item-edit/UserChip.js +113 -113
- package/dist/shared/components/item-edit/file-download.js +18 -0
- package/dist/shared/components/item-edit/line-qty.js +67 -32
- package/dist/shared/components/item-edit/save-refusal.js +23 -0
- package/dist/shared/components/monitoring/TrafficMiniMap.js +9 -9
- package/dist/shared/components/panels/CommentPanel.js +30 -30
- package/dist/shared/components/panels/ItemLockBanner.js +207 -185
- package/dist/shared/components/panels/PipelinePanel.js +915 -786
- package/dist/shared/components/pipeline/PipelineEditorView.js +45 -25
- package/dist/shared/components/profile/DelegationCard.js +1 -1
- package/dist/shared/components/profile/session-actions.js +24 -24
- package/dist/shared/components/queue/QueueItemSheet.js +18 -18
- package/dist/shared/components/queue/QueueWorklist.js +517 -504
- package/dist/shared/components/ui/dropdown-menu.js +8 -7
- package/dist/shared/lib/draft-store.js +60 -33
- package/dist/shared/lib/leave-guard.js +38 -0
- package/dist/shared/lib/load-error.js +38 -17
- package/dist/shared/lib/summary-mode.js +25 -25
- package/dist/shared/lib/table-pins.js +23 -0
- package/dist/shared/lib/validation-rules.js +55 -51
- package/package.json +1 -1
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { jsxs as f, jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import { Lock as
|
|
3
|
-
import { useState as
|
|
2
|
+
import { Lock as V, LockOpen as ee } from "lucide-react";
|
|
3
|
+
import { useState as x, useRef as Y, useCallback as w, useEffect as S } from "react";
|
|
4
4
|
import { toast as u } from "sonner";
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { post as
|
|
7
|
-
import { idleState as
|
|
8
|
-
import { useOptionalRealtime as
|
|
9
|
-
import { announceRecordTabs as
|
|
10
|
-
import { Button as
|
|
11
|
-
import { Popover as
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
const [t, r] =
|
|
5
|
+
import { useNivaroClient as pe, useItemEditAuth as $e } from "../../context.js";
|
|
6
|
+
import { post as R, get as Ne, del as D } from "../../lib/commands.js";
|
|
7
|
+
import { idleState as Se } from "../../lib/idle.js";
|
|
8
|
+
import { useOptionalRealtime as te, updateTouches as qe } from "../../lib/realtime.js";
|
|
9
|
+
import { announceRecordTabs as re, useRecordTabsSignal as Le } from "../../lib/record-tabs.js";
|
|
10
|
+
import { Button as I } from "../ui/button.js";
|
|
11
|
+
import { Popover as ae, PopoverTrigger as ne, PopoverContent as se } from "../ui/popover.js";
|
|
12
|
+
const Re = 6e4, Ce = 2 * 6e4, Ee = 3e4;
|
|
13
|
+
function Ae() {
|
|
14
|
+
const [t, r] = x(
|
|
15
15
|
() => typeof document > "u" || document.visibilityState !== "hidden"
|
|
16
16
|
);
|
|
17
|
-
return
|
|
17
|
+
return S(() => {
|
|
18
18
|
const o = () => r(document.visibilityState !== "hidden");
|
|
19
19
|
return document.addEventListener("visibilitychange", o), () => document.removeEventListener("visibilitychange", o);
|
|
20
20
|
}, []), t;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const { lazy: q = !1, active: E = !0 } =
|
|
24
|
-
|
|
25
|
-
}, []), c =
|
|
26
|
-
var
|
|
27
|
-
if (!t || !r ||
|
|
28
|
-
|
|
22
|
+
function Ke(t, r, o, C = {}) {
|
|
23
|
+
const { lazy: q = !1, active: E = !0 } = C, s = pe(), { isAdmin: N, userId: b } = $e(), [_, g] = x(null), [p, $] = x(!1), [M, A] = x(!1), [oe, ie] = x([]), [le, O] = x(null), [ce, U] = x(!1), [ue, W] = x(""), [de, F] = x(!1), [me, J] = x(!1), z = Y(null), i = Y(!1), L = Y(!1), P = Y(!1), j = Y(!1), K = Y(null), h = w(() => {
|
|
24
|
+
z.current && (clearInterval(z.current), z.current = null);
|
|
25
|
+
}, []), c = w(async () => {
|
|
26
|
+
var n, a;
|
|
27
|
+
if (!t || !r || j.current) return !1;
|
|
28
|
+
K.current = null;
|
|
29
29
|
try {
|
|
30
|
-
return await
|
|
30
|
+
return await s.request(R(`/item-locks/${t}/${r}/lock`, {})), i.current = !0, $(!0), F(!1), g(null), h(), z.current = setInterval(() => {
|
|
31
31
|
const k = Math.max(
|
|
32
32
|
0,
|
|
33
|
-
Math.floor((Date.now() - new Date(
|
|
33
|
+
Math.floor((Date.now() - new Date(Se().last_active).getTime()) / 1e3)
|
|
34
34
|
);
|
|
35
|
-
|
|
35
|
+
s.request(R(`/item-locks/${t}/${r}/heartbeat`, { idle_seconds: k })).then((l) => {
|
|
36
36
|
if (!(l != null && l.idle_released)) return;
|
|
37
|
-
h(), i.current = !1,
|
|
37
|
+
h(), i.current = !1, $(!1), u.info(
|
|
38
38
|
"Your edit lock was released after inactivity — it re-locks when you resume."
|
|
39
39
|
);
|
|
40
40
|
const e = () => {
|
|
@@ -45,35 +45,40 @@ function Me(t, r, o, R = {}) {
|
|
|
45
45
|
var X, Z;
|
|
46
46
|
const e = l, d = e.status ?? ((X = e.response) == null ? void 0 : X.status);
|
|
47
47
|
if (d !== 404 && d !== 409) return;
|
|
48
|
-
const
|
|
49
|
-
if (d === 404 && !(
|
|
48
|
+
const v = ((Z = e.response) == null ? void 0 : Z.data) ?? e.response;
|
|
49
|
+
if (d === 404 && !(v != null && v.locked_by)) {
|
|
50
50
|
c();
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
h(), i.current = !1,
|
|
54
|
-
locked_by:
|
|
55
|
-
locked_by_name:
|
|
53
|
+
h(), i.current = !1, $(!1), v != null && v.locked_by && (g({
|
|
54
|
+
locked_by: v.locked_by,
|
|
55
|
+
locked_by_name: v.locked_by_name ?? null
|
|
56
56
|
}), u.warning(
|
|
57
|
-
`${
|
|
57
|
+
`${v.locked_by_name ?? "Another user"} took over editing — your changes are no longer being saved`
|
|
58
58
|
));
|
|
59
59
|
});
|
|
60
|
-
},
|
|
60
|
+
}, Re), !0;
|
|
61
61
|
} catch (k) {
|
|
62
|
-
const l = k, e = l.status ?? ((
|
|
63
|
-
return
|
|
62
|
+
const l = k, e = l.status ?? ((n = l.response) == null ? void 0 : n.status), d = ((a = l.response) == null ? void 0 : a.data) ?? l.response;
|
|
63
|
+
return K.current = e ?? null, e === 404 ? (j.current = !0, h(), i.current = !1, $(!1), !1) : (e === 409 && (d != null && d.locked_by) && (i.current = !1, $(!1), g({
|
|
64
64
|
locked_by: d.locked_by,
|
|
65
65
|
locked_by_name: d.locked_by_name ?? null,
|
|
66
66
|
...typeof d.may_take_over == "boolean" ? { may_take_over: d.may_take_over } : {}
|
|
67
67
|
})), !1);
|
|
68
68
|
}
|
|
69
|
-
}, [
|
|
69
|
+
}, [s, t, r, h]), y = w(async () => {
|
|
70
70
|
if (!(!t || !r))
|
|
71
71
|
try {
|
|
72
|
-
const
|
|
73
|
-
|
|
72
|
+
const n = await s.request(Ne(`/item-locks/${t}/${r}/lock`)), a = n == null ? void 0 : n.data;
|
|
73
|
+
ie(Array.isArray(a == null ? void 0 : a.queue) ? a.queue : []), O(typeof (a == null ? void 0 : a.my_position) == "number" ? a.my_position : null);
|
|
74
74
|
const k = (a == null ? void 0 : a.is_mine) === !0 || !!b && String((a == null ? void 0 : a.locked_by) ?? "").toLowerCase() === b.toLowerCase(), l = typeof (a == null ? void 0 : a.may_take_over) == "boolean" ? { may_take_over: a.may_take_over } : {};
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
if (i.current) return;
|
|
76
|
+
if (!(a != null && a.locked_by) || k) {
|
|
77
|
+
g(null);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
g(
|
|
81
|
+
(e) => e && e.locked_by === String(a.locked_by) ? {
|
|
77
82
|
...e,
|
|
78
83
|
note: a.note ?? e.note ?? null,
|
|
79
84
|
idle_minutes: a.locked_by_idle_minutes ?? e.idle_minutes ?? null,
|
|
@@ -82,51 +87,56 @@ function Me(t, r, o, R = {}) {
|
|
|
82
87
|
locked_by: String(a.locked_by),
|
|
83
88
|
locked_by_name: a.locked_by_name ?? null,
|
|
84
89
|
note: a.note ?? null,
|
|
90
|
+
idle_minutes: a.locked_by_idle_minutes ?? null,
|
|
85
91
|
...l
|
|
86
92
|
}
|
|
87
|
-
);
|
|
88
|
-
} catch (
|
|
89
|
-
(
|
|
93
|
+
), F(!1);
|
|
94
|
+
} catch (n) {
|
|
95
|
+
(n == null ? void 0 : n.status) === 404 && (j.current = !0);
|
|
90
96
|
}
|
|
91
|
-
}, [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}, [
|
|
97
|
+
}, [s, t, r, b]), B = (_ == null ? void 0 : _.locked_by) ?? null;
|
|
98
|
+
S(() => {
|
|
99
|
+
B && y();
|
|
100
|
+
}, [B, y]), S(() => {
|
|
101
|
+
if (!B) return;
|
|
102
|
+
const n = setInterval(() => void y(), Ee);
|
|
103
|
+
return () => clearInterval(n);
|
|
104
|
+
}, [B, y]), S(() => {
|
|
95
105
|
if (!(!o || !t || !r))
|
|
96
|
-
return
|
|
97
|
-
h(),
|
|
106
|
+
return L.current = !1, j.current = !1, q ? y() : c(), () => {
|
|
107
|
+
h(), L.current = !1, i.current && (i.current = !1, s.request(D(`/item-locks/${t}/${r}/lock`)).then(() => re(b, "lock-released", t, r)).catch(() => {
|
|
98
108
|
}));
|
|
99
109
|
};
|
|
100
|
-
}, [o, t, r, c,
|
|
101
|
-
const
|
|
102
|
-
if (!(!o || i.current ||
|
|
103
|
-
|
|
110
|
+
}, [o, t, r, c, s, h, b, q, y]);
|
|
111
|
+
const ke = w(async () => {
|
|
112
|
+
if (!(!o || i.current || P.current)) {
|
|
113
|
+
P.current = !0;
|
|
104
114
|
try {
|
|
105
|
-
!await c() &&
|
|
115
|
+
!await c() && K.current === 409 && u.warning("Someone else is editing this record — your change can’t be saved yet");
|
|
106
116
|
} finally {
|
|
107
|
-
|
|
117
|
+
P.current = !1;
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
|
-
}, [o, c]),
|
|
111
|
-
|
|
120
|
+
}, [o, c]), he = Ae(), G = E && he;
|
|
121
|
+
S(() => {
|
|
112
122
|
if (!o || !t || !r) return;
|
|
113
|
-
if (
|
|
114
|
-
|
|
123
|
+
if (G) {
|
|
124
|
+
L.current && (L.current = !1, c());
|
|
115
125
|
return;
|
|
116
126
|
}
|
|
117
|
-
const
|
|
118
|
-
i.current && (h(), i.current = !1,
|
|
127
|
+
const n = setTimeout(() => {
|
|
128
|
+
i.current && (h(), i.current = !1, $(!1), L.current = !0, s.request(D(`/item-locks/${t}/${r}/lock`)).then(() => re(b, "lock-released", t, r)).catch(() => {
|
|
119
129
|
}));
|
|
120
|
-
},
|
|
121
|
-
return () => clearTimeout(
|
|
122
|
-
}, [o,
|
|
130
|
+
}, Ce);
|
|
131
|
+
return () => clearTimeout(n);
|
|
132
|
+
}, [o, G, t, r, c, s, h, b]), S(() => {
|
|
123
133
|
if (!o || !t || !r) return;
|
|
124
|
-
const
|
|
134
|
+
const n = () => {
|
|
125
135
|
var k;
|
|
126
136
|
if (i.current) {
|
|
127
|
-
h(), i.current = !1,
|
|
137
|
+
h(), i.current = !1, L.current = !0;
|
|
128
138
|
try {
|
|
129
|
-
const l = (k =
|
|
139
|
+
const l = (k = s.getToken) == null ? void 0 : k.call(s), e = s.url ?? "";
|
|
130
140
|
fetch(
|
|
131
141
|
`${e}/api/item-locks/${encodeURIComponent(t)}/${encodeURIComponent(r)}/lock/release`,
|
|
132
142
|
{
|
|
@@ -141,29 +151,37 @@ function Me(t, r, o, R = {}) {
|
|
|
141
151
|
}
|
|
142
152
|
}
|
|
143
153
|
}, a = (k) => {
|
|
144
|
-
k.persisted &&
|
|
154
|
+
k.persisted && L.current && (L.current = !1, c());
|
|
145
155
|
};
|
|
146
|
-
return window.addEventListener("pagehide",
|
|
147
|
-
window.removeEventListener("pagehide",
|
|
156
|
+
return window.addEventListener("pagehide", n), window.addEventListener("pageshow", a), () => {
|
|
157
|
+
window.removeEventListener("pagehide", n), window.removeEventListener("pageshow", a);
|
|
148
158
|
};
|
|
149
|
-
}, [o, t, r,
|
|
159
|
+
}, [o, t, r, s, h, c]), Le(b, "lock-released", t, r, () => {
|
|
150
160
|
o && i.current && c();
|
|
151
161
|
});
|
|
152
|
-
const
|
|
162
|
+
const Q = te();
|
|
163
|
+
S(() => {
|
|
164
|
+
if (!(!o || !Q || !t || !r))
|
|
165
|
+
return Q.subscribeCollections([t], (n) => {
|
|
166
|
+
var a;
|
|
167
|
+
i.current || j.current || !((a = n.changed_fields) != null && a.includes("$lock")) || !qe(n, r) || y();
|
|
168
|
+
});
|
|
169
|
+
}, [o, Q, t, r, y]);
|
|
170
|
+
const T = te(), [fe, H] = x(!1), be = w(async () => {
|
|
153
171
|
if (!(!t || !r)) {
|
|
154
|
-
|
|
172
|
+
H(!0);
|
|
155
173
|
try {
|
|
156
|
-
await
|
|
174
|
+
await s.request(R(`/item-locks/${t}/${r}/lock/request`, {})), u.success("Asked the current editor to release the lock");
|
|
157
175
|
} catch {
|
|
158
176
|
u.error("Could not send the lock request");
|
|
159
177
|
} finally {
|
|
160
|
-
|
|
178
|
+
H(!1);
|
|
161
179
|
}
|
|
162
180
|
}
|
|
163
|
-
}, [
|
|
164
|
-
|
|
181
|
+
}, [s, t, r]);
|
|
182
|
+
S(() => {
|
|
165
183
|
if (!T || !t || !r) return;
|
|
166
|
-
const
|
|
184
|
+
const n = T.on("lock:requested", (e) => {
|
|
167
185
|
if ((e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || !i.current) return;
|
|
168
186
|
const d = (e == null ? void 0 : e.from) ?? {};
|
|
169
187
|
u(`${d.name ?? "Someone"} is asking you to release this record`, {
|
|
@@ -171,8 +189,8 @@ function Me(t, r, o, R = {}) {
|
|
|
171
189
|
action: {
|
|
172
190
|
label: "Release",
|
|
173
191
|
onClick: () => {
|
|
174
|
-
h(), i.current = !1,
|
|
175
|
-
|
|
192
|
+
h(), i.current = !1, $(!1), s.request(
|
|
193
|
+
R(`/item-locks/${t}/${r}/lock/respond`, {
|
|
176
194
|
to: d.id,
|
|
177
195
|
action: "release"
|
|
178
196
|
})
|
|
@@ -182,8 +200,8 @@ function Me(t, r, o, R = {}) {
|
|
|
182
200
|
cancel: {
|
|
183
201
|
label: "Keep editing",
|
|
184
202
|
onClick: () => {
|
|
185
|
-
|
|
186
|
-
|
|
203
|
+
s.request(
|
|
204
|
+
R(`/item-locks/${t}/${r}/lock/respond`, {
|
|
187
205
|
to: d.id,
|
|
188
206
|
action: "decline"
|
|
189
207
|
})
|
|
@@ -193,120 +211,124 @@ function Me(t, r, o, R = {}) {
|
|
|
193
211
|
}
|
|
194
212
|
});
|
|
195
213
|
}), a = T.on("lock:response", (e) => {
|
|
196
|
-
var d,
|
|
214
|
+
var d, v;
|
|
197
215
|
(e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || i.current || ((e == null ? void 0 : e.action) === "release" ? (u.success(`${((d = e == null ? void 0 : e.from) == null ? void 0 : d.name) ?? "The editor"} released the lock — it's yours`), c()) : u.warning(
|
|
198
|
-
`${((
|
|
216
|
+
`${((v = e == null ? void 0 : e.from) == null ? void 0 : v.name) ?? "The editor"} is keeping the lock${e != null && e.note ? `: "${e.note}"` : ""}`
|
|
199
217
|
));
|
|
200
218
|
}), k = T.on("lock:available", (e) => {
|
|
201
|
-
(e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || i.current || (u.success("Your turn — the edit lock is yours"),
|
|
219
|
+
(e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || i.current || (u.success("Your turn — the edit lock is yours"), O(null), c());
|
|
202
220
|
}), l = T.on("lock:queued", (e) => {
|
|
203
|
-
(e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || (i.current && u(`${(e == null ? void 0 : e.user_name) ?? "Someone"} is waiting to edit this record`, { duration: 8e3 }),
|
|
221
|
+
(e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || (i.current && u(`${(e == null ? void 0 : e.user_name) ?? "Someone"} is waiting to edit this record`, { duration: 8e3 }), y());
|
|
204
222
|
});
|
|
205
223
|
return () => {
|
|
206
|
-
|
|
224
|
+
n(), a(), k(), l();
|
|
207
225
|
};
|
|
208
|
-
}, [T, t, r,
|
|
209
|
-
const
|
|
210
|
-
var s;
|
|
226
|
+
}, [T, t, r, s, c, h, y]);
|
|
227
|
+
const ye = w(async () => {
|
|
211
228
|
if (!(!t || !r)) {
|
|
212
|
-
|
|
229
|
+
U(!0);
|
|
213
230
|
try {
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
),
|
|
217
|
-
|
|
231
|
+
const n = await s.request(
|
|
232
|
+
R(`/item-locks/${t}/${r}/lock/queue`, {})
|
|
233
|
+
), a = n == null ? void 0 : n.data;
|
|
234
|
+
if (a != null && a.free) {
|
|
235
|
+
O(null), g(null), u.success("Nobody is editing this record now — go ahead");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
const k = a == null ? void 0 : a.position;
|
|
239
|
+
O(typeof k == "number" ? k : 1), u.success("You are in line — the lock comes to you automatically when it frees up"), y();
|
|
218
240
|
} catch {
|
|
219
241
|
u.error("Could not join the queue");
|
|
220
242
|
} finally {
|
|
221
|
-
|
|
243
|
+
U(!1);
|
|
222
244
|
}
|
|
223
245
|
}
|
|
224
|
-
}, [
|
|
246
|
+
}, [s, t, r, y]), ge = w(async () => {
|
|
225
247
|
if (!(!t || !r))
|
|
226
248
|
try {
|
|
227
|
-
await
|
|
249
|
+
await s.request(D(`/item-locks/${t}/${r}/lock/queue`)), O(null), y();
|
|
228
250
|
} catch {
|
|
229
251
|
}
|
|
230
|
-
}, [
|
|
231
|
-
async (
|
|
252
|
+
}, [s, t, r, y]), ve = w(
|
|
253
|
+
async (n) => {
|
|
232
254
|
if (!(!t || !r || !i.current)) {
|
|
233
|
-
|
|
255
|
+
W(n);
|
|
234
256
|
try {
|
|
235
|
-
await
|
|
257
|
+
await s.request(R(`/item-locks/${t}/${r}/lock/note`, { note: n }));
|
|
236
258
|
} catch {
|
|
237
259
|
}
|
|
238
260
|
}
|
|
239
261
|
},
|
|
240
|
-
[
|
|
241
|
-
),
|
|
262
|
+
[s, t, r]
|
|
263
|
+
), xe = w(async () => {
|
|
242
264
|
if (!(!t || !r || !i.current)) {
|
|
243
|
-
|
|
265
|
+
J(!0), h(), i.current = !1, $(!1);
|
|
244
266
|
try {
|
|
245
|
-
await
|
|
267
|
+
await s.request(D(`/item-locks/${t}/${r}/lock`)), F(!0), W(""), u.success("Lock released — anyone can edit this record now");
|
|
246
268
|
} catch {
|
|
247
269
|
u.error("Failed to release the lock"), c();
|
|
248
270
|
} finally {
|
|
249
|
-
|
|
271
|
+
J(!1);
|
|
250
272
|
}
|
|
251
273
|
}
|
|
252
|
-
}, [
|
|
274
|
+
}, [s, t, r, h, c]), we = w(async () => {
|
|
253
275
|
if (i.current) return !0;
|
|
254
|
-
const
|
|
255
|
-
return
|
|
256
|
-
}, [c]),
|
|
257
|
-
var
|
|
276
|
+
const n = await c();
|
|
277
|
+
return n && u.success("You hold the edit lock again"), n;
|
|
278
|
+
}, [c]), _e = w(async () => {
|
|
279
|
+
var n;
|
|
258
280
|
if (!(!t || !r)) {
|
|
259
281
|
A(!0);
|
|
260
282
|
try {
|
|
261
|
-
await
|
|
283
|
+
await s.request(R(`/item-locks/${t}/${r}/lock/force`, {})), u.success("You now hold the edit lock"), await c();
|
|
262
284
|
} catch (a) {
|
|
263
|
-
const k = ((
|
|
264
|
-
u.error(k), (a == null ? void 0 : a.status) === 403 &&
|
|
285
|
+
const k = ((n = a == null ? void 0 : a.response) == null ? void 0 : n.error) ?? "Failed to take over the lock";
|
|
286
|
+
u.error(k), (a == null ? void 0 : a.status) === 403 && g((l) => l && { ...l, may_take_over: !1 });
|
|
265
287
|
} finally {
|
|
266
288
|
A(!1);
|
|
267
289
|
}
|
|
268
290
|
}
|
|
269
|
-
}, [
|
|
291
|
+
}, [s, t, r, c]);
|
|
270
292
|
return {
|
|
271
|
-
lockHolder:
|
|
272
|
-
acquired:
|
|
273
|
-
isReadOnly: !!
|
|
274
|
-
takeOver:
|
|
275
|
-
takingOver:
|
|
293
|
+
lockHolder: _,
|
|
294
|
+
acquired: p,
|
|
295
|
+
isReadOnly: !!_,
|
|
296
|
+
takeOver: _e,
|
|
297
|
+
takingOver: M,
|
|
276
298
|
isAdmin: N,
|
|
277
|
-
requestLock:
|
|
278
|
-
requesting:
|
|
279
|
-
queue:
|
|
280
|
-
myPosition:
|
|
281
|
-
joinQueue:
|
|
282
|
-
leaveQueue:
|
|
283
|
-
joining:
|
|
284
|
-
myNote:
|
|
285
|
-
saveNote:
|
|
286
|
-
release:
|
|
287
|
-
releasing:
|
|
288
|
-
released:
|
|
289
|
-
relock:
|
|
290
|
-
claim:
|
|
299
|
+
requestLock: be,
|
|
300
|
+
requesting: fe,
|
|
301
|
+
queue: oe,
|
|
302
|
+
myPosition: le,
|
|
303
|
+
joinQueue: ye,
|
|
304
|
+
leaveQueue: ge,
|
|
305
|
+
joining: ce,
|
|
306
|
+
myNote: ue,
|
|
307
|
+
saveNote: ve,
|
|
308
|
+
release: xe,
|
|
309
|
+
releasing: me,
|
|
310
|
+
released: de,
|
|
311
|
+
relock: we,
|
|
312
|
+
claim: ke
|
|
291
313
|
};
|
|
292
314
|
}
|
|
293
|
-
function
|
|
315
|
+
function Qe({
|
|
294
316
|
note: t,
|
|
295
317
|
onSave: r,
|
|
296
318
|
waiting: o,
|
|
297
|
-
onRelease:
|
|
319
|
+
onRelease: C,
|
|
298
320
|
releasing: q,
|
|
299
321
|
released: E,
|
|
300
|
-
onRelock:
|
|
322
|
+
onRelock: s
|
|
301
323
|
}) {
|
|
302
|
-
var
|
|
303
|
-
const [N, b] =
|
|
304
|
-
|
|
305
|
-
const
|
|
324
|
+
var g;
|
|
325
|
+
const [N, b] = x(t);
|
|
326
|
+
S(() => b(t), [t]);
|
|
327
|
+
const _ = () => {
|
|
306
328
|
N.trim() !== t && r(N.trim());
|
|
307
329
|
};
|
|
308
|
-
return E ? /* @__PURE__ */ f(
|
|
309
|
-
/* @__PURE__ */ m(
|
|
330
|
+
return E ? /* @__PURE__ */ f(ae, { children: [
|
|
331
|
+
/* @__PURE__ */ m(ne, { asChild: !0, children: /* @__PURE__ */ m(
|
|
310
332
|
"button",
|
|
311
333
|
{
|
|
312
334
|
type: "button",
|
|
@@ -314,29 +336,29 @@ function Pe({
|
|
|
314
336
|
title: "Lock released — anyone can edit this record",
|
|
315
337
|
"data-lock-released": !0,
|
|
316
338
|
className: "relative inline-flex h-8 w-8 items-center justify-center text-slate-400 transition-colors hover:bg-accent hover:text-accent-foreground dark:text-slate-500",
|
|
317
|
-
children: /* @__PURE__ */ m(
|
|
339
|
+
children: /* @__PURE__ */ m(ee, { className: "h-4 w-4", strokeWidth: 2 })
|
|
318
340
|
}
|
|
319
341
|
) }),
|
|
320
|
-
/* @__PURE__ */ f(
|
|
342
|
+
/* @__PURE__ */ f(se, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
|
|
321
343
|
/* @__PURE__ */ m("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "You released the edit lock" }),
|
|
322
344
|
/* @__PURE__ */ m("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: "Anyone can edit this record now. Your next edit locks it again — or lock it now." }),
|
|
323
345
|
/* @__PURE__ */ f(
|
|
324
|
-
|
|
346
|
+
I,
|
|
325
347
|
{
|
|
326
348
|
type: "button",
|
|
327
349
|
size: "sm",
|
|
328
350
|
className: "mt-2 h-7 w-full text-[12px]",
|
|
329
|
-
onClick:
|
|
351
|
+
onClick: s,
|
|
330
352
|
"data-lock-relock": !0,
|
|
331
353
|
children: [
|
|
332
|
-
/* @__PURE__ */ m(
|
|
354
|
+
/* @__PURE__ */ m(V, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
333
355
|
" Lock again"
|
|
334
356
|
]
|
|
335
357
|
}
|
|
336
358
|
)
|
|
337
359
|
] })
|
|
338
|
-
] }) : /* @__PURE__ */ f(
|
|
339
|
-
/* @__PURE__ */ m(
|
|
360
|
+
] }) : /* @__PURE__ */ f(ae, { children: [
|
|
361
|
+
/* @__PURE__ */ m(ne, { asChild: !0, children: /* @__PURE__ */ f(
|
|
340
362
|
"button",
|
|
341
363
|
{
|
|
342
364
|
type: "button",
|
|
@@ -345,22 +367,22 @@ function Pe({
|
|
|
345
367
|
"data-lock-holder": !0,
|
|
346
368
|
className: "relative inline-flex h-8 w-8 items-center justify-center text-[#0e7490] transition-colors hover:bg-accent hover:text-accent-foreground dark:text-nvr-cyan",
|
|
347
369
|
children: [
|
|
348
|
-
/* @__PURE__ */ m(
|
|
370
|
+
/* @__PURE__ */ m(V, { className: "h-4 w-4", strokeWidth: 2 }),
|
|
349
371
|
o.length > 0 && /* @__PURE__ */ m("span", { className: "absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-amber-500 ring-2 ring-background" })
|
|
350
372
|
]
|
|
351
373
|
}
|
|
352
374
|
) }),
|
|
353
|
-
/* @__PURE__ */ f(
|
|
375
|
+
/* @__PURE__ */ f(se, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
|
|
354
376
|
/* @__PURE__ */ m("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "You hold the edit lock" }),
|
|
355
377
|
/* @__PURE__ */ m("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: "Others see this record read-only. A note tells them what you’re doing." }),
|
|
356
378
|
/* @__PURE__ */ m(
|
|
357
379
|
"input",
|
|
358
380
|
{
|
|
359
381
|
value: N,
|
|
360
|
-
onChange: (
|
|
361
|
-
onBlur:
|
|
362
|
-
onKeyDown: (
|
|
363
|
-
|
|
382
|
+
onChange: (p) => b(p.target.value.slice(0, 300)),
|
|
383
|
+
onBlur: _,
|
|
384
|
+
onKeyDown: (p) => {
|
|
385
|
+
p.key === "Enter" && (p.preventDefault(), _());
|
|
364
386
|
},
|
|
365
387
|
placeholder: "“editing lines, ~15 min”",
|
|
366
388
|
"aria-label": "Lock note",
|
|
@@ -373,57 +395,57 @@ function Pe({
|
|
|
373
395
|
" waiting for the lock:"
|
|
374
396
|
] }),
|
|
375
397
|
" ",
|
|
376
|
-
o.map((
|
|
398
|
+
o.map((p) => p.name ?? "someone").join(", ")
|
|
377
399
|
] }),
|
|
378
|
-
|
|
379
|
-
|
|
400
|
+
C && /* @__PURE__ */ f(
|
|
401
|
+
I,
|
|
380
402
|
{
|
|
381
403
|
type: "button",
|
|
382
404
|
variant: "outline",
|
|
383
405
|
size: "sm",
|
|
384
406
|
className: "mt-2 h-7 w-full text-[12px]",
|
|
385
|
-
onClick:
|
|
407
|
+
onClick: C,
|
|
386
408
|
disabled: q,
|
|
387
409
|
"data-lock-release": !0,
|
|
388
410
|
children: [
|
|
389
|
-
/* @__PURE__ */ m(
|
|
390
|
-
q ? "Releasing…" : o.length > 0 ? `Release lock to ${((
|
|
411
|
+
/* @__PURE__ */ m(ee, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
412
|
+
q ? "Releasing…" : o.length > 0 ? `Release lock to ${((g = o[0]) == null ? void 0 : g.name) ?? "the next person"}` : "Release lock"
|
|
391
413
|
]
|
|
392
414
|
}
|
|
393
415
|
)
|
|
394
416
|
] })
|
|
395
417
|
] });
|
|
396
418
|
}
|
|
397
|
-
function
|
|
419
|
+
function Ve({
|
|
398
420
|
lockHolder: t,
|
|
399
421
|
onTakeOver: r,
|
|
400
422
|
takingOver: o,
|
|
401
|
-
isAdmin:
|
|
423
|
+
isAdmin: C,
|
|
402
424
|
onRequestLock: q,
|
|
403
425
|
requesting: E,
|
|
404
|
-
queue:
|
|
426
|
+
queue: s,
|
|
405
427
|
myPosition: N,
|
|
406
428
|
onJoinQueue: b,
|
|
407
|
-
onLeaveQueue:
|
|
408
|
-
joining:
|
|
409
|
-
noun:
|
|
410
|
-
readOnlyText:
|
|
429
|
+
onLeaveQueue: _,
|
|
430
|
+
joining: g,
|
|
431
|
+
noun: p = "this item",
|
|
432
|
+
readOnlyText: $ = "fields are read-only"
|
|
411
433
|
}) {
|
|
412
434
|
if (!t) return null;
|
|
413
|
-
const
|
|
435
|
+
const M = t.locked_by_name || "Another user", A = (s == null ? void 0 : s.length) ?? 0;
|
|
414
436
|
return /* @__PURE__ */ f(
|
|
415
437
|
"div",
|
|
416
438
|
{
|
|
417
439
|
className: "mb-4 flex flex-wrap items-center gap-3 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-100",
|
|
418
440
|
"data-lock-banner": !0,
|
|
419
441
|
children: [
|
|
420
|
-
/* @__PURE__ */ m(
|
|
442
|
+
/* @__PURE__ */ m(V, { className: "h-4 w-4 shrink-0 text-amber-500" }),
|
|
421
443
|
/* @__PURE__ */ f("span", { className: "min-w-0 flex-1", children: [
|
|
422
|
-
/* @__PURE__ */ m("span", { className: "font-medium", children:
|
|
444
|
+
/* @__PURE__ */ m("span", { className: "font-medium", children: M }),
|
|
423
445
|
" is editing ",
|
|
424
|
-
_,
|
|
425
|
-
" — ",
|
|
426
446
|
p,
|
|
447
|
+
" — ",
|
|
448
|
+
$,
|
|
427
449
|
t.idle_minutes != null && t.idle_minutes >= 2 && /* @__PURE__ */ f(
|
|
428
450
|
"span",
|
|
429
451
|
{
|
|
@@ -452,12 +474,12 @@ function Fe({
|
|
|
452
474
|
] })
|
|
453
475
|
] }),
|
|
454
476
|
b && (N != null ? /* @__PURE__ */ f(
|
|
455
|
-
|
|
477
|
+
I,
|
|
456
478
|
{
|
|
457
479
|
size: "sm",
|
|
458
480
|
variant: "outline",
|
|
459
481
|
className: "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15",
|
|
460
|
-
onClick:
|
|
482
|
+
onClick: _,
|
|
461
483
|
"data-lock-queue-leave": !0,
|
|
462
484
|
children: [
|
|
463
485
|
"You’re #",
|
|
@@ -466,19 +488,19 @@ function Fe({
|
|
|
466
488
|
]
|
|
467
489
|
}
|
|
468
490
|
) : /* @__PURE__ */ m(
|
|
469
|
-
|
|
491
|
+
I,
|
|
470
492
|
{
|
|
471
493
|
size: "sm",
|
|
472
494
|
variant: "outline",
|
|
473
495
|
className: "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15",
|
|
474
496
|
onClick: b,
|
|
475
|
-
disabled:
|
|
497
|
+
disabled: g,
|
|
476
498
|
"data-lock-queue-join": !0,
|
|
477
|
-
children:
|
|
499
|
+
children: g ? "Joining…" : "Ask to be next"
|
|
478
500
|
}
|
|
479
501
|
)),
|
|
480
502
|
q && /* @__PURE__ */ m(
|
|
481
|
-
|
|
503
|
+
I,
|
|
482
504
|
{
|
|
483
505
|
size: "sm",
|
|
484
506
|
variant: "outline",
|
|
@@ -491,12 +513,12 @@ function Fe({
|
|
|
491
513
|
// Admins always; other roles only when the server says they may (the
|
|
492
514
|
// takeover-role allowlist, #256) — unknown = offered, and a 403 then
|
|
493
515
|
// hides it. A Take over that can only fail was a dead end.
|
|
494
|
-
(
|
|
495
|
-
|
|
516
|
+
(C || t.may_take_over !== !1) && /* @__PURE__ */ m(
|
|
517
|
+
I,
|
|
496
518
|
{
|
|
497
519
|
size: "sm",
|
|
498
520
|
variant: "outline",
|
|
499
|
-
className:
|
|
521
|
+
className: C ? "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15" : "h-7 shrink-0 border-amber-200 bg-white/60 text-[12px] text-amber-700/80 hover:bg-amber-100 dark:border-amber-500/30 dark:bg-transparent dark:text-amber-200/80 dark:hover:bg-amber-500/15",
|
|
500
522
|
onClick: r,
|
|
501
523
|
disabled: o,
|
|
502
524
|
children: o ? "Taking over…" : "Take over"
|
|
@@ -507,7 +529,7 @@ function Fe({
|
|
|
507
529
|
);
|
|
508
530
|
}
|
|
509
531
|
export {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
532
|
+
Ve as ItemLockBanner,
|
|
533
|
+
Qe as LockHolderButton,
|
|
534
|
+
Ke as useItemLock
|
|
513
535
|
};
|