@nivaro/react 0.3.99 → 0.3.101
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/useFormSchema.js +82 -85
- package/dist/hooks/useSessionRecorder.js +206 -175
- package/dist/index.d.ts +84 -16
- package/dist/index.js +627 -622
- package/dist/lib/commands.js +15 -11
- package/dist/shared/components/ActivityEntry.js +5 -5
- package/dist/shared/components/CollectionBrowserView.js +516 -503
- package/dist/shared/components/ItemEditForm.js +3471 -3465
- package/dist/shared/components/JobsTray.js +76 -61
- package/dist/shared/components/MyWorkView.js +133 -126
- package/dist/shared/components/NotificationBell.js +322 -289
- package/dist/shared/components/RecordCompare.js +38 -40
- package/dist/shared/components/RecordReadView.js +119 -119
- package/dist/shared/components/TipLayer.js +56 -41
- package/dist/shared/components/cbv/FoundElsewhere.js +61 -0
- package/dist/shared/components/integrations/console/SignalCard.js +40 -40
- package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +95 -73
- package/dist/shared/components/integrations/console/drill/status.js +23 -18
- package/dist/shared/components/item-edit/InlineGridField.js +45 -45
- package/dist/shared/components/item-edit/InlineTableField.js +750 -749
- package/dist/shared/components/item-edit/QuickPickerDialog.js +44 -44
- package/dist/shared/components/item-edit/RawEditSheet.js +122 -114
- package/dist/shared/components/item-edit/RecordInsights.js +86 -86
- package/dist/shared/components/item-edit/RelationCombobox.js +454 -378
- package/dist/shared/components/item-edit/SummaryPanel.js +56 -48
- package/dist/shared/components/item-edit/header-path-preview.js +46 -34
- package/dist/shared/components/item-edit/related-missing.js +75 -19
- package/dist/shared/components/notifications/DeliveryChips.js +1 -2
- package/dist/shared/components/notifications/NotificationCenterView.js +249 -226
- package/dist/shared/components/panels/AccessDeniedPanel.js +31 -28
- package/dist/shared/components/panels/BackgroundMove.js +242 -0
- package/dist/shared/components/panels/MoveAdvisory.js +204 -0
- package/dist/shared/components/panels/PipelinePanel.js +1459 -1220
- package/dist/shared/components/panels/RecordIntegrityBanner.js +113 -112
- package/dist/shared/components/profile/ActivityFeedCard.js +322 -0
- package/dist/shared/components/profile/DayTimeline.js +145 -140
- package/dist/shared/components/profile/PersonAccess.js +679 -383
- package/dist/shared/components/profile/PersonActivity.js +404 -427
- package/dist/shared/components/profile/PersonDidPanel.js +248 -134
- package/dist/shared/components/profile/PersonProfile.js +33 -32
- package/dist/shared/components/profile/journey-view.js +166 -0
- package/dist/shared/lib/activity-sentence.js +319 -236
- package/dist/shared/lib/commands.js +18 -14
- package/dist/shared/lib/error-hints.js +1 -1
- package/dist/shared/lib/job-failure-text.js +12 -0
- package/dist/shared/lib/jobs-tray.js +60 -41
- package/dist/shared/lib/move-failure.js +19 -0
- package/dist/shared/lib/obligation-banner.js +22 -21
- package/dist/shared/lib/partner-failure.js +83 -0
- package/dist/shared/lib/prefetch.js +73 -73
- package/dist/shared/lib/replay-checkout.js +18 -13
- package/dist/shared/lib/replay-context.js +90 -77
- package/dist/shared/lib/replay-idle.js +21 -0
- package/dist/shared/lib/replay-socket.js +21 -17
- package/dist/shared/lib/rum.js +56 -51
- package/dist/shared/lib/safe-error.js +17 -13
- package/dist/shared/lib/stale-chunk.js +69 -26
- package/dist/shared/lib/system-collections.js +20 -0
- package/package.json +1 -1
|
@@ -5,32 +5,33 @@ import { useState as f } from "react";
|
|
|
5
5
|
import { toast as y } from "sonner";
|
|
6
6
|
import { useNivaroClient as F } from "../../context.js";
|
|
7
7
|
import { post as L, get as T } from "../../lib/commands.js";
|
|
8
|
-
|
|
8
|
+
import { hasRecordExtras as _ } from "../../lib/system-collections.js";
|
|
9
|
+
const E = {
|
|
9
10
|
access: !1,
|
|
10
11
|
reasons: [{ type: "not_found", message: "There is no record with this id." }]
|
|
11
12
|
};
|
|
12
|
-
function
|
|
13
|
-
var
|
|
14
|
-
const e =
|
|
15
|
-
return ((e == null ? void 0 : e.status) ?? ((
|
|
13
|
+
function R(s) {
|
|
14
|
+
var r;
|
|
15
|
+
const e = s;
|
|
16
|
+
return ((e == null ? void 0 : e.status) ?? ((r = e == null ? void 0 : e.response) == null ? void 0 : r.status)) === 404;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function j(s, e) {
|
|
18
19
|
const o = e == null ? void 0 : e.trim();
|
|
19
20
|
if (o) return o.toLowerCase();
|
|
20
|
-
const
|
|
21
|
-
return /ies$/i.test(
|
|
21
|
+
const r = s.replace(/_/g, " ").trim();
|
|
22
|
+
return /ies$/i.test(r) ? r.replace(/ies$/i, "y") : /[^su]s$/i.test(r) ? r.slice(0, -1) : r || "record";
|
|
22
23
|
}
|
|
23
24
|
const b = 300;
|
|
24
|
-
function
|
|
25
|
-
collection:
|
|
25
|
+
function I({
|
|
26
|
+
collection: s,
|
|
26
27
|
itemId: e,
|
|
27
28
|
noun: o,
|
|
28
|
-
onBack:
|
|
29
|
+
onBack: r
|
|
29
30
|
}) {
|
|
30
|
-
const d =
|
|
31
|
+
const d = j(s, o), g = F(), [i, k] = f(!1), [c, N] = f(""), u = w({
|
|
31
32
|
mutationFn: () => g.request(
|
|
32
33
|
L("/access-requests", {
|
|
33
|
-
collection:
|
|
34
|
+
collection: s,
|
|
34
35
|
item: String(e),
|
|
35
36
|
...c.trim() ? { note: c.trim().slice(0, b) } : {}
|
|
36
37
|
})
|
|
@@ -40,12 +41,14 @@ function z({
|
|
|
40
41
|
},
|
|
41
42
|
onError: () => y.error("Could not send the request")
|
|
42
43
|
}), { data: m, isLoading: x } = q({
|
|
43
|
-
queryKey: ["access-explain",
|
|
44
|
+
queryKey: ["access-explain", s, String(e)],
|
|
44
45
|
queryFn: () => g.request(
|
|
45
|
-
T(`/access-explain/${
|
|
46
|
-
).then((
|
|
46
|
+
T(`/access-explain/${s}/${encodeURIComponent(e)}`)
|
|
47
|
+
).then((a) => a.data ?? null).catch((a) => R(a) ? E : null),
|
|
48
|
+
// "Why can't I see this" is refused for system tables by name: the plain message stands.
|
|
49
|
+
enabled: _(s),
|
|
47
50
|
staleTime: 3e4
|
|
48
|
-
}), p = (m == null ? void 0 : m.reasons) ?? [], l = p.some((
|
|
51
|
+
}), p = (m == null ? void 0 : m.reasons) ?? [], l = p.some((a) => a.type === "not_found");
|
|
49
52
|
return /* @__PURE__ */ t("div", { className: "flex flex-1 items-start justify-center px-6 py-16", children: /* @__PURE__ */ n("div", { className: "w-full max-w-[560px] rounded-xl border border-slate-200 bg-white p-8 dark:border-border dark:bg-card", children: [
|
|
50
53
|
/* @__PURE__ */ n("div", { className: "flex items-center gap-3", children: [
|
|
51
54
|
/* @__PURE__ */ t("span", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ t($, { className: "h-[18px] w-[18px] text-slate-500 dark:text-slate-400" }) }),
|
|
@@ -60,20 +63,20 @@ function z({
|
|
|
60
63
|
] }) : l ? null : p.length > 0 ? (
|
|
61
64
|
// A missing record is said once, in the heading (army11 f3: the
|
|
62
65
|
// page gave two different reasons for the same thing).
|
|
63
|
-
p.map((
|
|
66
|
+
p.map((a, v) => /* @__PURE__ */ t(
|
|
64
67
|
"div",
|
|
65
68
|
{
|
|
66
69
|
className: "rounded-lg border border-slate-200 bg-slate-50 px-3.5 py-2.5 text-[13px] leading-relaxed text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-300",
|
|
67
|
-
children:
|
|
70
|
+
children: a.message
|
|
68
71
|
},
|
|
69
|
-
`${
|
|
72
|
+
`${a.type}-${a.dimension ?? v}`
|
|
70
73
|
))
|
|
71
74
|
) : /* @__PURE__ */ t("div", { className: "rounded-lg border border-slate-200 bg-slate-50 px-3.5 py-2.5 text-[13px] leading-relaxed text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-300", children: "This record could not be loaded. It may have been deleted, or an access rule may be hiding it." }) }),
|
|
72
75
|
!l && !x && !i && /* @__PURE__ */ n("div", { className: "mt-4", children: [
|
|
73
76
|
/* @__PURE__ */ n(
|
|
74
77
|
"label",
|
|
75
78
|
{
|
|
76
|
-
htmlFor: `access-note-${
|
|
79
|
+
htmlFor: `access-note-${s}-${e}`,
|
|
77
80
|
className: "block text-[12px] font-medium text-slate-700 dark:text-slate-300",
|
|
78
81
|
children: [
|
|
79
82
|
"Need it? Say what for ",
|
|
@@ -84,9 +87,9 @@ function z({
|
|
|
84
87
|
/* @__PURE__ */ t(
|
|
85
88
|
"textarea",
|
|
86
89
|
{
|
|
87
|
-
id: `access-note-${
|
|
90
|
+
id: `access-note-${s}-${e}`,
|
|
88
91
|
value: c,
|
|
89
|
-
onChange: (
|
|
92
|
+
onChange: (a) => N(a.target.value.slice(0, b)),
|
|
90
93
|
rows: 2,
|
|
91
94
|
maxLength: b,
|
|
92
95
|
placeholder: `e.g. I approve this ${d} for my team`,
|
|
@@ -117,11 +120,11 @@ function z({
|
|
|
117
120
|
] })
|
|
118
121
|
}
|
|
119
122
|
),
|
|
120
|
-
|
|
123
|
+
r && /* @__PURE__ */ n(
|
|
121
124
|
"button",
|
|
122
125
|
{
|
|
123
126
|
type: "button",
|
|
124
|
-
onClick:
|
|
127
|
+
onClick: r,
|
|
125
128
|
className: "mt-5 inline-flex items-center gap-1.5 rounded-md border border-slate-200 px-3 py-1.5 text-[12px] font-medium text-slate-600 hover:bg-slate-50 dark:border-border dark:text-slate-300 dark:hover:bg-white/[0.03]",
|
|
126
129
|
children: [
|
|
127
130
|
/* @__PURE__ */ t(S, { className: "h-3.5 w-3.5" }),
|
|
@@ -132,7 +135,7 @@ function z({
|
|
|
132
135
|
] }) });
|
|
133
136
|
}
|
|
134
137
|
export {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
I as AccessDeniedPanel,
|
|
139
|
+
R as explainMissing,
|
|
140
|
+
j as recordNoun
|
|
138
141
|
};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { jsxs as i, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { Loader2 as L, AlertTriangle as U, ArrowUpRight as A } from "lucide-react";
|
|
3
|
+
import { createContext as B, useRef as _, useEffect as P, useMemo as x, useContext as W } from "react";
|
|
4
|
+
import { useItemEditAuth as E } from "../../context.js";
|
|
5
|
+
import { describeError as j } from "../../lib/error-message.js";
|
|
6
|
+
import { partnerSaid as z, withoutMoveLabel as D } from "../../lib/partner-failure.js";
|
|
7
|
+
import { partnerOutcome as xe, partnerWords as ke } from "../../lib/partner-failure.js";
|
|
8
|
+
import { formatRelative as g, cn as k, formatDateTime as T } from "../../lib/utils.js";
|
|
9
|
+
import { ErrorDetails as G } from "../ErrorNotice.js";
|
|
10
|
+
import { useOverflowTip as H } from "../TipLayer.js";
|
|
11
|
+
import { Button as C } from "../ui/button.js";
|
|
12
|
+
const V = 4e3;
|
|
13
|
+
function ie(e) {
|
|
14
|
+
return e != null && e.running_move ? V : !1;
|
|
15
|
+
}
|
|
16
|
+
function oe(e, t) {
|
|
17
|
+
const r = _(!1), n = _(t);
|
|
18
|
+
n.current = t, P(() => {
|
|
19
|
+
r.current && !e && n.current(), r.current = e;
|
|
20
|
+
}, [e]);
|
|
21
|
+
}
|
|
22
|
+
function de(e, t) {
|
|
23
|
+
return (e ?? []).some((r) => r.id === t && r.background === !0) ? { accept_pending: !0 } : {};
|
|
24
|
+
}
|
|
25
|
+
function le(e) {
|
|
26
|
+
const t = e == null ? void 0 : e.data;
|
|
27
|
+
return (t == null ? void 0 : t.background) === !0 && t.run ? t.run : null;
|
|
28
|
+
}
|
|
29
|
+
function $(e, t) {
|
|
30
|
+
return !!e && !!t && e.toUpperCase() === t.toUpperCase();
|
|
31
|
+
}
|
|
32
|
+
function M(e, t) {
|
|
33
|
+
return e.mode === "auto" ? "Started automatically" : $(e.started_by, t) ? "You started it" : e.started_by_name ? `Started by ${e.started_by_name}` : "Started";
|
|
34
|
+
}
|
|
35
|
+
function Y(e) {
|
|
36
|
+
return D(e.reason, e.transition_label);
|
|
37
|
+
}
|
|
38
|
+
const R = "flex items-start gap-2.5", I = "is running. Other moves wait until it finishes.", O = (e) => {
|
|
39
|
+
var t;
|
|
40
|
+
return ((t = e.transition_label) == null ? void 0 : t.trim()) || "A move";
|
|
41
|
+
};
|
|
42
|
+
function ce(e) {
|
|
43
|
+
return `${O(e)} ${I}`;
|
|
44
|
+
}
|
|
45
|
+
const q = {
|
|
46
|
+
refused: "did not go through. The record was not moved.",
|
|
47
|
+
interrupted: "stopped before it finished.",
|
|
48
|
+
failed: "ran into a problem."
|
|
49
|
+
};
|
|
50
|
+
function me({
|
|
51
|
+
run: e,
|
|
52
|
+
floating: t,
|
|
53
|
+
className: r,
|
|
54
|
+
style: n
|
|
55
|
+
}) {
|
|
56
|
+
const { userId: o } = E(), m = O(e);
|
|
57
|
+
return /* @__PURE__ */ i(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
role: "status",
|
|
61
|
+
"data-running-move": e.transition_id ?? "",
|
|
62
|
+
className: k(
|
|
63
|
+
R,
|
|
64
|
+
t ? "rounded-lg border border-sky-200 bg-sky-50 p-3 shadow-lg dark:border-sky-500/30 dark:bg-sky-950" : "border-t border-sky-200/80 bg-sky-50/70 px-4 py-2.5 dark:border-sky-500/20 dark:bg-sky-500/[0.06]",
|
|
65
|
+
r
|
|
66
|
+
),
|
|
67
|
+
style: n,
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ s(
|
|
70
|
+
L,
|
|
71
|
+
{
|
|
72
|
+
"aria-hidden": !0,
|
|
73
|
+
className: "mt-[3px] h-3.5 w-3.5 shrink-0 animate-spin text-sky-600 motion-reduce:animate-none dark:text-sky-400"
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
/* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: [
|
|
77
|
+
/* @__PURE__ */ i("p", { className: "break-words text-[13px] leading-snug text-slate-800 dark:text-slate-100", children: [
|
|
78
|
+
/* @__PURE__ */ s("span", { className: "font-medium", children: m }),
|
|
79
|
+
" ",
|
|
80
|
+
I
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ i("p", { className: "mt-0.5 text-[11.5px] text-sky-800/80 dark:text-sky-300/80", children: [
|
|
83
|
+
M(e, o),
|
|
84
|
+
" · ",
|
|
85
|
+
g(e.started_at),
|
|
86
|
+
" · this page updates on its own"
|
|
87
|
+
] })
|
|
88
|
+
] })
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
const F = B(
|
|
94
|
+
null
|
|
95
|
+
);
|
|
96
|
+
function J(e, t) {
|
|
97
|
+
var o;
|
|
98
|
+
const r = ((o = e.api_name) == null ? void 0 : o.trim()) || "the other system", n = `The order may already be at ${r}.`;
|
|
99
|
+
return e.stale ? {
|
|
100
|
+
lead: n,
|
|
101
|
+
next: t ? `The send on ${T(e.started_at)} got no answer. Check first: look in ${r}, then mark that send received or not received.` : `The send on ${T(e.started_at)} got no answer. Check first: an administrator looks in ${r} and marks that send before it can go again.`
|
|
102
|
+
} : {
|
|
103
|
+
lead: n,
|
|
104
|
+
next: `The send started ${g(e.started_at)} and has not been answered yet. Wait for it to finish before you do anything else.`
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function ue(e, t) {
|
|
108
|
+
var o;
|
|
109
|
+
const r = e == null ? void 0 : e.unanswered;
|
|
110
|
+
if (!r || !$(e == null ? void 0 : e.transition_id, t)) return null;
|
|
111
|
+
const n = ((o = r.api_name) == null ? void 0 : o.trim()) || "the other system";
|
|
112
|
+
return r.stale ? `Waiting on a check: ${n} may already have this order. An administrator marks the last send received or not received first.` : `Still being sent to ${n}. Wait for it to finish.`;
|
|
113
|
+
}
|
|
114
|
+
function he({
|
|
115
|
+
problem: e,
|
|
116
|
+
onRetry: t,
|
|
117
|
+
retryDisabled: r,
|
|
118
|
+
className: n
|
|
119
|
+
}) {
|
|
120
|
+
var y, v, w;
|
|
121
|
+
const { userId: o } = E(), m = ((y = e.transition_label) == null ? void 0 : y.trim()) || "The move", d = Y(e), l = x(() => d ? j({ message: d }, "") : null, [d]), u = W(F), f = x(
|
|
122
|
+
() => {
|
|
123
|
+
var N;
|
|
124
|
+
return d && ((N = u == null ? void 0 : u(d)) == null ? void 0 : N.trim()) || null;
|
|
125
|
+
},
|
|
126
|
+
[d, u]
|
|
127
|
+
), p = x(
|
|
128
|
+
() => f ?? (d ? z(d) : null) ?? (l == null ? void 0 : l.title.trim()) ?? "",
|
|
129
|
+
[f, d, l]
|
|
130
|
+
), S = H(p), a = e.unanswered ?? null, c = ((v = a == null ? void 0 : a.review_url) == null ? void 0 : v.trim()) || null, h = a ? J(a, !!c) : null, b = !!c && typeof window < "u" && (() => {
|
|
131
|
+
try {
|
|
132
|
+
return new URL(c, window.location.href).origin !== window.location.origin;
|
|
133
|
+
} catch {
|
|
134
|
+
return !1;
|
|
135
|
+
}
|
|
136
|
+
})();
|
|
137
|
+
return /* @__PURE__ */ i(
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
role: "note",
|
|
141
|
+
"data-move-problem": e.result,
|
|
142
|
+
className: k(
|
|
143
|
+
R,
|
|
144
|
+
"border-t border-amber-200/80 bg-amber-50/70 px-4 py-2.5 dark:border-amber-500/20 dark:bg-amber-500/[0.06]",
|
|
145
|
+
n
|
|
146
|
+
),
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ s(
|
|
149
|
+
U,
|
|
150
|
+
{
|
|
151
|
+
"aria-hidden": !0,
|
|
152
|
+
className: "mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-400"
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
/* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: [
|
|
156
|
+
/* @__PURE__ */ i("p", { className: "break-words text-[13px] leading-snug text-slate-800 dark:text-slate-100", children: [
|
|
157
|
+
/* @__PURE__ */ s("span", { className: "font-medium", children: m }),
|
|
158
|
+
" ",
|
|
159
|
+
a && !a.stale ? `is still being sent to ${((w = a.api_name) == null ? void 0 : w.trim()) || "the other system"}.` : q[e.result]
|
|
160
|
+
] }),
|
|
161
|
+
p && !(h && e.result === "interrupted") && /* @__PURE__ */ s(
|
|
162
|
+
"p",
|
|
163
|
+
{
|
|
164
|
+
ref: S,
|
|
165
|
+
"data-move-problem-reason": !0,
|
|
166
|
+
className: k(
|
|
167
|
+
"mt-0.5 break-words text-[12px] leading-snug text-slate-700 dark:text-slate-300",
|
|
168
|
+
// A host's words are short and curated (one per line): shown whole. The other
|
|
169
|
+
// system's words can run long: three lines, the rest on hover.
|
|
170
|
+
f ? "whitespace-pre-line" : "line-clamp-3"
|
|
171
|
+
),
|
|
172
|
+
children: p
|
|
173
|
+
}
|
|
174
|
+
),
|
|
175
|
+
h && /* @__PURE__ */ i(
|
|
176
|
+
"p",
|
|
177
|
+
{
|
|
178
|
+
"data-move-problem-unanswered": !0,
|
|
179
|
+
className: "mt-1 break-words text-[12px] leading-snug text-slate-700 dark:text-slate-300",
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-amber-900 dark:text-amber-200", children: h.lead }),
|
|
182
|
+
" ",
|
|
183
|
+
h.next
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
/* @__PURE__ */ i("p", { className: "mt-0.5 text-[11.5px] text-amber-800/80 dark:text-amber-300/80", children: [
|
|
188
|
+
M(e, o),
|
|
189
|
+
" · ",
|
|
190
|
+
g(e.finished_at ?? e.started_at)
|
|
191
|
+
] }),
|
|
192
|
+
l && /* @__PURE__ */ s(G, { description: l, action: m, className: "mt-1" })
|
|
193
|
+
] }),
|
|
194
|
+
a ? (
|
|
195
|
+
// While the send may still answer there is nothing to mark yet.
|
|
196
|
+
c && a.stale && /* @__PURE__ */ s(C, { asChild: !0, size: "sm", variant: "outline", className: "h-7 shrink-0 gap-1 text-[12px]", children: /* @__PURE__ */ i(
|
|
197
|
+
"a",
|
|
198
|
+
{
|
|
199
|
+
href: c,
|
|
200
|
+
"data-move-problem-check": !0,
|
|
201
|
+
...b ? { target: "_blank", rel: "noreferrer" } : {},
|
|
202
|
+
children: [
|
|
203
|
+
"Check first",
|
|
204
|
+
b && /* @__PURE__ */ s(A, { "aria-hidden": !0, className: "h-3 w-3" })
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
) })
|
|
208
|
+
) : t && /* @__PURE__ */ s(
|
|
209
|
+
C,
|
|
210
|
+
{
|
|
211
|
+
type: "button",
|
|
212
|
+
size: "sm",
|
|
213
|
+
variant: "outline",
|
|
214
|
+
className: "h-7 shrink-0 text-[12px]",
|
|
215
|
+
disabled: r,
|
|
216
|
+
onClick: t,
|
|
217
|
+
"data-move-problem-retry": !0,
|
|
218
|
+
children: "Try again"
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
export {
|
|
226
|
+
he as MoveProblemNotice,
|
|
227
|
+
F as MoveProblemWordsContext,
|
|
228
|
+
V as RUNNING_MOVE_POLL_MS,
|
|
229
|
+
me as RunningMoveNotice,
|
|
230
|
+
xe as partnerOutcome,
|
|
231
|
+
ke as partnerWords,
|
|
232
|
+
de as pendingOptIn,
|
|
233
|
+
Y as problemReason,
|
|
234
|
+
ie as runningMovePoll,
|
|
235
|
+
ce as runningMoveTip,
|
|
236
|
+
$ as sameMoveId,
|
|
237
|
+
M as startedBy,
|
|
238
|
+
le as startedInBackground,
|
|
239
|
+
ue as unansweredHoldTip,
|
|
240
|
+
J as unansweredWords,
|
|
241
|
+
oe as useRunEnded
|
|
242
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { jsxs as c, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useMutation as z, useQueryClient as O, useQuery as P } from "@tanstack/react-query";
|
|
3
|
+
import { AlertTriangle as Q, Loader2 as D } from "lucide-react";
|
|
4
|
+
import { useState as S, useRef as T, useEffect as _ } from "react";
|
|
5
|
+
import { toast as F } from "sonner";
|
|
6
|
+
import { useNivaroClient as U } from "../../context.js";
|
|
7
|
+
import { get as B, post as j } from "../../lib/commands.js";
|
|
8
|
+
import { toastError as H } from "../../lib/error-toast.js";
|
|
9
|
+
import { cn as V } from "../../lib/utils.js";
|
|
10
|
+
import { invalidateRecordData as X } from "../item-edit/RecordInsights.js";
|
|
11
|
+
import { Button as y } from "../ui/button.js";
|
|
12
|
+
const Y = {
|
|
13
|
+
PRIORITY_REQUIRED: "priority",
|
|
14
|
+
// A held record does not move forward (efp-ops hold-gate, army 11): taking
|
|
15
|
+
// the hold off is one deliberate, noted step, then the move is tried again.
|
|
16
|
+
ON_HOLD: "remove-hold"
|
|
17
|
+
};
|
|
18
|
+
function G(n) {
|
|
19
|
+
var o, t;
|
|
20
|
+
return ((t = (o = n.fix) == null ? void 0 : o.action) == null ? void 0 : t.trim()) || Y[n.code] || null;
|
|
21
|
+
}
|
|
22
|
+
function ie(n) {
|
|
23
|
+
var t;
|
|
24
|
+
const o = /* @__PURE__ */ new Map();
|
|
25
|
+
for (const e of n) {
|
|
26
|
+
if (!((t = e.advisory) != null && t.message)) continue;
|
|
27
|
+
const i = `${e.advisory.code}\0${e.advisory.message}`, s = o.get(i);
|
|
28
|
+
s ? s.moves.push(e) : o.set(i, { advisory: e.advisory, moves: [e] });
|
|
29
|
+
}
|
|
30
|
+
return [...o.values()];
|
|
31
|
+
}
|
|
32
|
+
function J(n, o, t) {
|
|
33
|
+
const e = U(), i = O(), { data: s, isLoading: d } = P({
|
|
34
|
+
queryKey: ["bulk-actions-available-one", n, t],
|
|
35
|
+
enabled: !!t,
|
|
36
|
+
queryFn: async () => ((await e.request(
|
|
37
|
+
B("/bulk-actions/available", { collection: n })
|
|
38
|
+
)).data ?? []).find((u) => u.key === t) ?? null,
|
|
39
|
+
staleTime: 6e4
|
|
40
|
+
});
|
|
41
|
+
return { action: s ?? null, isLoading: !!t && d, run: async (p) => {
|
|
42
|
+
var h, x;
|
|
43
|
+
if (!s) throw new Error("This action is not available");
|
|
44
|
+
const u = { collection: n, ids: [o], reason: p.trim() || null }, m = (s.source === "extension" ? await e.request(j(`/bulk-actions/${s.key}/execute`, u)) : await e.request(j("/bulk-actions/run", { ...u, key: s.key }))).data ?? {};
|
|
45
|
+
if (s.source !== "extension" && !(m.succeeded && m.succeeded > 0))
|
|
46
|
+
throw new Error(((x = (h = m.errors) == null ? void 0 : h[0]) == null ? void 0 : x.error) || `${s.label} did not change the record`);
|
|
47
|
+
X(i, n, o);
|
|
48
|
+
} };
|
|
49
|
+
}
|
|
50
|
+
function le({
|
|
51
|
+
collection: n,
|
|
52
|
+
item: o,
|
|
53
|
+
advisory: t,
|
|
54
|
+
armedMove: e,
|
|
55
|
+
stops: i,
|
|
56
|
+
floating: s,
|
|
57
|
+
onFixed: d,
|
|
58
|
+
onDismiss: b,
|
|
59
|
+
className: p,
|
|
60
|
+
style: u
|
|
61
|
+
}) {
|
|
62
|
+
var A, I;
|
|
63
|
+
const { action: r, isLoading: m, run: h } = J(n, o, G(t)), [x, k] = S(!1), [N, v] = S(""), R = T(null), C = T(null), g = !!r && (x || !!e);
|
|
64
|
+
_(() => {
|
|
65
|
+
var a;
|
|
66
|
+
g && ((a = R.current) == null || a.focus());
|
|
67
|
+
}, [g]);
|
|
68
|
+
const $ = e == null ? void 0 : e.id;
|
|
69
|
+
_(() => {
|
|
70
|
+
var a, L;
|
|
71
|
+
$ && ((L = (a = C.current) == null ? void 0 : a.scrollIntoView) == null || L.call(a, { block: "nearest" }));
|
|
72
|
+
}, [$]);
|
|
73
|
+
const f = ((I = (A = t.fix) == null ? void 0 : A.label) == null ? void 0 : I.trim()) || (r == null ? void 0 : r.label) || "", w = z({
|
|
74
|
+
mutationFn: () => h(N),
|
|
75
|
+
onSuccess: () => {
|
|
76
|
+
F.success(
|
|
77
|
+
e != null && e.confirms ? `Done: ${f}. Confirm ${e.label} to finish.` : `Done: ${f}.`
|
|
78
|
+
), k(!1), v(""), d == null || d(e ?? null);
|
|
79
|
+
},
|
|
80
|
+
onError: (a) => H(a, `${(r == null ? void 0 : r.label) ?? "The action"} failed`)
|
|
81
|
+
}), q = !w.isPending && (!(r != null && r.require_reason) || N.trim().length > 0), E = () => {
|
|
82
|
+
k(!1), v(""), b == null || b();
|
|
83
|
+
};
|
|
84
|
+
return /* @__PURE__ */ c(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
ref: C,
|
|
88
|
+
role: e ? "status" : "note",
|
|
89
|
+
"data-move-advisory": t.code,
|
|
90
|
+
className: V(
|
|
91
|
+
"flex items-start gap-2.5",
|
|
92
|
+
s ? "rounded-lg border border-amber-200 bg-amber-50 p-3 shadow-lg dark:border-amber-500/30 dark:bg-amber-950" : "border-t border-amber-200/80 bg-amber-50/70 px-4 py-2.5 dark:border-amber-500/20 dark:bg-amber-500/[0.06]",
|
|
93
|
+
e && "ring-1 ring-inset ring-amber-400 dark:ring-amber-400/60",
|
|
94
|
+
p
|
|
95
|
+
),
|
|
96
|
+
style: u,
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ l(
|
|
99
|
+
Q,
|
|
100
|
+
{
|
|
101
|
+
"aria-hidden": !0,
|
|
102
|
+
className: "mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-400"
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ c("div", { className: "min-w-0 flex-1 space-y-2", children: [
|
|
106
|
+
/* @__PURE__ */ c("div", { children: [
|
|
107
|
+
/* @__PURE__ */ l("p", { className: "break-words text-[13px] leading-snug text-slate-800 dark:text-slate-100", children: t.message }),
|
|
108
|
+
!!(i != null && i.length) && /* @__PURE__ */ c(
|
|
109
|
+
"p",
|
|
110
|
+
{
|
|
111
|
+
className: "mt-0.5 text-[11.5px] text-amber-800/80 dark:text-amber-300/80",
|
|
112
|
+
"data-move-advisory-stops": !0,
|
|
113
|
+
children: [
|
|
114
|
+
"Stops: ",
|
|
115
|
+
i.join(", ")
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
] }),
|
|
120
|
+
g && r && /* @__PURE__ */ c(
|
|
121
|
+
"form",
|
|
122
|
+
{
|
|
123
|
+
className: "space-y-2",
|
|
124
|
+
onSubmit: (a) => {
|
|
125
|
+
a.preventDefault(), q && w.mutate();
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
r.require_reason && /* @__PURE__ */ l(
|
|
129
|
+
"input",
|
|
130
|
+
{
|
|
131
|
+
ref: R,
|
|
132
|
+
type: "text",
|
|
133
|
+
value: N,
|
|
134
|
+
onChange: (a) => v(a.target.value),
|
|
135
|
+
placeholder: "Reason (required)",
|
|
136
|
+
"aria-label": "Reason",
|
|
137
|
+
className: "w-full rounded-md border border-slate-200 bg-white px-3 py-1.5 text-[13px] text-slate-900 placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/30 dark:border-border dark:bg-card dark:text-slate-100 dark:placeholder-slate-400"
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ c("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [
|
|
141
|
+
/* @__PURE__ */ l(
|
|
142
|
+
y,
|
|
143
|
+
{
|
|
144
|
+
type: "button",
|
|
145
|
+
size: "sm",
|
|
146
|
+
variant: "ghost",
|
|
147
|
+
className: "h-7 text-[12px]",
|
|
148
|
+
onClick: E,
|
|
149
|
+
children: "Not now"
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ c(
|
|
153
|
+
y,
|
|
154
|
+
{
|
|
155
|
+
type: "submit",
|
|
156
|
+
size: "sm",
|
|
157
|
+
className: "h-7 gap-1.5 text-[12px]",
|
|
158
|
+
disabled: !q,
|
|
159
|
+
"data-move-advisory-run": !0,
|
|
160
|
+
children: [
|
|
161
|
+
w.isPending && /* @__PURE__ */ l(D, { className: "h-3 w-3 animate-spin" }),
|
|
162
|
+
e ? `${f}, then ${e.label}` : f
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
] })
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
e && !r && !m && s && /* @__PURE__ */ l("div", { className: "flex justify-end", children: /* @__PURE__ */ l(
|
|
171
|
+
y,
|
|
172
|
+
{
|
|
173
|
+
type: "button",
|
|
174
|
+
size: "sm",
|
|
175
|
+
variant: "ghost",
|
|
176
|
+
className: "h-7 text-[12px]",
|
|
177
|
+
onClick: E,
|
|
178
|
+
children: "Close"
|
|
179
|
+
}
|
|
180
|
+
) })
|
|
181
|
+
] }),
|
|
182
|
+
r && !g && /* @__PURE__ */ l(
|
|
183
|
+
y,
|
|
184
|
+
{
|
|
185
|
+
type: "button",
|
|
186
|
+
size: "sm",
|
|
187
|
+
variant: "outline",
|
|
188
|
+
className: "h-7 shrink-0 text-[12px]",
|
|
189
|
+
onClick: () => k(!0),
|
|
190
|
+
"data-move-advisory-fix": r.key,
|
|
191
|
+
children: f
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
le as MoveAdvisoryNotice,
|
|
200
|
+
Y as REFUSAL_FIX_ACTIONS,
|
|
201
|
+
G as advisoryFixKey,
|
|
202
|
+
ie as distinctAdvisories,
|
|
203
|
+
J as useRecordFixAction
|
|
204
|
+
};
|