@nivaro/react 0.3.78 → 0.3.79
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.
|
@@ -9,7 +9,7 @@ import { noteReplayEvent as _e, createReplayCheckoutState as De } from "../share
|
|
|
9
9
|
import { emitReplayTap as Te, setReplayRecorderMode as N, registerReplayCapture as qe, clipEndOffset as Le, withClipKind as Pe } from "../shared/lib/replay-capture.js";
|
|
10
10
|
import { instrumentConsole as Ne, instrumentRequests as Fe, redactSecrets as Me } from "../shared/lib/replay-context.js";
|
|
11
11
|
import { instrumentSocket as Oe } from "../shared/lib/replay-socket.js";
|
|
12
|
-
const Ue = "nivaro-react@0.3.
|
|
12
|
+
const Ue = "nivaro-react@0.3.79", j = 1e4, We = 150, He = 3e3, Ke = 600, $e = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
|
|
13
13
|
function Be(n) {
|
|
14
14
|
return typeof n.url != "string" || typeof fetch != "function" ? null : (f, a) => {
|
|
15
15
|
const u = typeof n.getToken == "function" ? n.getToken() : void 0, d = { "Content-Type": "application/json" };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { jsxs as m, jsx as l, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as N } from "@tanstack/react-query";
|
|
3
|
+
import { ArrowRight as U } from "lucide-react";
|
|
4
|
+
import { useState as f, useMemo as D } from "react";
|
|
5
|
+
import { toast as q } from "sonner";
|
|
6
|
+
import { useNivaroClient as E } from "../../context.js";
|
|
7
|
+
import { get as _, post as B } from "../../lib/commands.js";
|
|
8
|
+
import { userErrorMessage as Y } from "../../lib/safe-error.js";
|
|
9
|
+
import { Popover as z, PopoverTrigger as G, PopoverContent as H } from "../ui/popover.js";
|
|
10
|
+
import { SimpleSelect as K } from "../ui/SimpleSelect.js";
|
|
11
|
+
function J(o) {
|
|
12
|
+
var h;
|
|
13
|
+
const s = /* @__PURE__ */ new Map();
|
|
14
|
+
for (const c of o) {
|
|
15
|
+
const i = ((h = c.label) == null ? void 0 : h.trim()) || "Move", n = s.get(i) ?? {
|
|
16
|
+
label: i,
|
|
17
|
+
ids: [],
|
|
18
|
+
noteRequired: !1,
|
|
19
|
+
targets: /* @__PURE__ */ new Map()
|
|
20
|
+
};
|
|
21
|
+
n.ids.push(c.id), c.comment_mode === "required" && (n.noteRequired = !0);
|
|
22
|
+
const p = String(c.to_state ?? "");
|
|
23
|
+
n.targets.set(p, [...n.targets.get(p) ?? [], c.id]), s.set(i, n);
|
|
24
|
+
}
|
|
25
|
+
return [...s.values()];
|
|
26
|
+
}
|
|
27
|
+
function ne({
|
|
28
|
+
collection: o,
|
|
29
|
+
ids: s,
|
|
30
|
+
disabled: h,
|
|
31
|
+
onDone: c
|
|
32
|
+
}) {
|
|
33
|
+
const i = E(), [n, p] = f(!1), [w, C] = f(""), [v, x] = f(""), [g, M] = f(""), [S, j] = f(!1), O = s.slice(0, 50).map(String).join(","), { data: y } = N({
|
|
34
|
+
queryKey: ["queue-bulk-move-binding", o],
|
|
35
|
+
queryFn: () => i.request(
|
|
36
|
+
_(`/pipelines/instances/${o}`, { ids: O })
|
|
37
|
+
).then((e) => {
|
|
38
|
+
var a, b;
|
|
39
|
+
return ((b = (a = e.data) == null ? void 0 : a.binding) == null ? void 0 : b.template) ?? null;
|
|
40
|
+
}),
|
|
41
|
+
enabled: n && !!o && s.length > 0,
|
|
42
|
+
staleTime: 5 * 6e4,
|
|
43
|
+
retry: !1
|
|
44
|
+
}), { data: d } = N({
|
|
45
|
+
queryKey: ["queue-bulk-move-outline", y],
|
|
46
|
+
queryFn: () => i.request(
|
|
47
|
+
_(`/pipelines/${y}/outline`)
|
|
48
|
+
).then((e) => e.data),
|
|
49
|
+
enabled: n && !!y,
|
|
50
|
+
staleTime: 5 * 6e4,
|
|
51
|
+
retry: !1
|
|
52
|
+
}), k = D(() => J((d == null ? void 0 : d.transitions) ?? []), [d]), I = (d == null ? void 0 : d.states) ?? [], $ = (e) => I.find((a) => String(a.id).toUpperCase() === e.toUpperCase()), t = k.find((e) => e.label === w) ?? null, R = t ? [...t.targets.keys()].filter(Boolean).sort((e, a) => {
|
|
53
|
+
var b, F;
|
|
54
|
+
return Number(((b = $(e)) == null ? void 0 : b.sort) ?? 0) - Number(((F = $(a)) == null ? void 0 : F.sort) ?? 0);
|
|
55
|
+
}) : [], L = R.length > 1, u = t ? L ? v ? t.targets.get(v) ?? [] : [] : t.ids : [], P = u.length ? `${u.join(",")}|${s.join(",")}` : "", { data: r, isFetching: T } = N({
|
|
56
|
+
queryKey: ["bulk-transition-preview", o, P],
|
|
57
|
+
queryFn: () => i.request(
|
|
58
|
+
B(`/items/${o}/bulk-transition?dry_run=1`, {
|
|
59
|
+
ids: s,
|
|
60
|
+
transition_ids: u,
|
|
61
|
+
comment: "(preview)"
|
|
62
|
+
})
|
|
63
|
+
),
|
|
64
|
+
enabled: n && !!o && u.length > 0,
|
|
65
|
+
staleTime: 15e3,
|
|
66
|
+
retry: !1
|
|
67
|
+
}), A = async () => {
|
|
68
|
+
if (!(!o || !t || u.length === 0) && !(t.noteRequired && !g.trim())) {
|
|
69
|
+
j(!0);
|
|
70
|
+
try {
|
|
71
|
+
const e = await i.request(
|
|
72
|
+
B(`/items/${o}/bulk-transition`, {
|
|
73
|
+
ids: s,
|
|
74
|
+
transition_ids: u,
|
|
75
|
+
...g.trim() ? { comment: g.trim() } : {}
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
e.failed > 0 ? q.warning(
|
|
79
|
+
`${t.label}: ${e.succeeded} done, ${e.failed} not moved — ${(e.errors ?? []).slice(0, 3).map((a) => `${a.label ?? `#${a.item}`}: ${a.error}`).join("; ")}`
|
|
80
|
+
) : q.success(`${t.label}: ${e.succeeded} done`), p(!1), C(""), x(""), M(""), c();
|
|
81
|
+
} catch (e) {
|
|
82
|
+
q.error(Y(e, `Could not ${t.label.toLowerCase()}`));
|
|
83
|
+
} finally {
|
|
84
|
+
j(!1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return /* @__PURE__ */ m(z, { open: n, onOpenChange: p, children: [
|
|
89
|
+
/* @__PURE__ */ l(G, { asChild: !0, children: /* @__PURE__ */ m(
|
|
90
|
+
"button",
|
|
91
|
+
{
|
|
92
|
+
type: "button",
|
|
93
|
+
disabled: h || !o,
|
|
94
|
+
"data-tip": o ? void 0 : "Select records of one kind to move them together",
|
|
95
|
+
"data-queue-bulk-move": !0,
|
|
96
|
+
className: "flex items-center gap-1 rounded-md px-2.5 py-1 text-[12px] font-medium text-slate-600 hover:bg-slate-100 disabled:opacity-50 dark:text-slate-300 dark:hover:bg-muted",
|
|
97
|
+
children: [
|
|
98
|
+
"Move / Send Back ",
|
|
99
|
+
/* @__PURE__ */ l(U, { className: "h-3 w-3" })
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
) }),
|
|
103
|
+
/* @__PURE__ */ m(H, { side: "top", align: "center", className: "w-[360px] space-y-2 p-3", children: [
|
|
104
|
+
/* @__PURE__ */ m("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-foreground", children: [
|
|
105
|
+
"Move ",
|
|
106
|
+
s.length,
|
|
107
|
+
" record",
|
|
108
|
+
s.length === 1 ? "" : "s"
|
|
109
|
+
] }),
|
|
110
|
+
d ? k.length === 0 ? /* @__PURE__ */ l("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: "You can’t move these records from here." }) : /* @__PURE__ */ m(
|
|
111
|
+
"form",
|
|
112
|
+
{
|
|
113
|
+
className: "space-y-2",
|
|
114
|
+
onSubmit: (e) => {
|
|
115
|
+
e.preventDefault(), A();
|
|
116
|
+
},
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ l(
|
|
119
|
+
K,
|
|
120
|
+
{
|
|
121
|
+
value: w,
|
|
122
|
+
onChange: (e) => {
|
|
123
|
+
C(e), x("");
|
|
124
|
+
},
|
|
125
|
+
options: [
|
|
126
|
+
{ value: "", label: "Choose a move…" },
|
|
127
|
+
...k.map((e) => ({ value: e.label, label: e.label }))
|
|
128
|
+
],
|
|
129
|
+
ariaLabel: "Choose a move",
|
|
130
|
+
className: "h-8 w-full text-[12.5px]"
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
t && L && /* @__PURE__ */ l(
|
|
134
|
+
K,
|
|
135
|
+
{
|
|
136
|
+
value: v,
|
|
137
|
+
onChange: x,
|
|
138
|
+
options: [
|
|
139
|
+
{ value: "", label: `${t.label} to…` },
|
|
140
|
+
...R.map((e) => {
|
|
141
|
+
var a;
|
|
142
|
+
return {
|
|
143
|
+
value: e,
|
|
144
|
+
label: ((a = $(e)) == null ? void 0 : a.label) ?? "another step"
|
|
145
|
+
};
|
|
146
|
+
})
|
|
147
|
+
],
|
|
148
|
+
ariaLabel: `${t.label} to which step`,
|
|
149
|
+
className: "h-8 w-full text-[12.5px]"
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
t && /* @__PURE__ */ l(
|
|
153
|
+
"textarea",
|
|
154
|
+
{
|
|
155
|
+
value: g,
|
|
156
|
+
onChange: (e) => M(e.target.value),
|
|
157
|
+
placeholder: t.noteRequired ? "Note for every record (required)" : "Note for every record (optional)",
|
|
158
|
+
"aria-label": "Note for every selected record",
|
|
159
|
+
maxLength: 2e3,
|
|
160
|
+
rows: 2,
|
|
161
|
+
className: "w-full rounded-md border border-slate-200 bg-background px-2 py-1 text-[12.5px] outline-none focus:border-nvr-cyan dark:border-border"
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
u.length > 0 && /* @__PURE__ */ l(
|
|
165
|
+
"p",
|
|
166
|
+
{
|
|
167
|
+
role: "status",
|
|
168
|
+
className: "text-[12px] text-slate-600 dark:text-muted-foreground",
|
|
169
|
+
"data-bulk-transition-preview": !0,
|
|
170
|
+
children: T || !r ? "Checking the selected records…" : r.failed === 0 ? `All ${r.succeeded} can move.` : /* @__PURE__ */ m(Q, { children: [
|
|
171
|
+
/* @__PURE__ */ m("span", { className: "font-medium text-amber-700 dark:text-amber-400", children: [
|
|
172
|
+
r.succeeded,
|
|
173
|
+
" of ",
|
|
174
|
+
r.succeeded + r.failed,
|
|
175
|
+
" can move.",
|
|
176
|
+
" ",
|
|
177
|
+
r.failed,
|
|
178
|
+
" can’t:"
|
|
179
|
+
] }),
|
|
180
|
+
" ",
|
|
181
|
+
r.errors.slice(0, 4).map((e) => `${e.label ?? `#${e.item}`} — ${e.error}`).join("; "),
|
|
182
|
+
r.errors.length > 4 ? `; and ${r.errors.length - 4} more` : ""
|
|
183
|
+
] })
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
/* @__PURE__ */ m("div", { className: "flex justify-end gap-2", children: [
|
|
187
|
+
/* @__PURE__ */ l(
|
|
188
|
+
"button",
|
|
189
|
+
{
|
|
190
|
+
type: "button",
|
|
191
|
+
onClick: () => p(!1),
|
|
192
|
+
className: "h-8 px-2 text-[12.5px] text-slate-500 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
|
|
193
|
+
children: "Cancel"
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
/* @__PURE__ */ l(
|
|
197
|
+
"button",
|
|
198
|
+
{
|
|
199
|
+
type: "submit",
|
|
200
|
+
disabled: S || !t || u.length === 0 || r != null && r.succeeded === 0 || t.noteRequired && !g.trim(),
|
|
201
|
+
className: "h-8 rounded-md bg-nvr-cyan px-3 text-[12.5px] font-semibold text-white disabled:opacity-50",
|
|
202
|
+
children: S ? "Moving…" : r && !T ? `Run (${r.succeeded})` : "Run"
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
] })
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
) : /* @__PURE__ */ l("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: "Loading the moves…" })
|
|
209
|
+
] })
|
|
210
|
+
] });
|
|
211
|
+
}
|
|
212
|
+
export {
|
|
213
|
+
ne as QueueBulkMove,
|
|
214
|
+
J as groupTransitions
|
|
215
|
+
};
|