@nivaro/react 0.3.20 → 0.3.22
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 +11 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/shared/components/CollectionBrowserView.js +2668 -2613
- package/dist/shared/components/ItemEditForm.js +1501 -1480
- package/dist/shared/components/QueryTable.js +268 -239
- package/dist/shared/components/bulk/PushBulkButtons.js +17 -17
- package/dist/shared/components/bulk/RowPushActions.js +45 -35
- package/dist/shared/components/chat/ChatPanel.js +258 -251
- package/dist/shared/components/help-videos/viewer/HelpVideoButton.js +106 -99
- package/dist/shared/components/item-edit/RecordHeaderActions.js +140 -0
- package/dist/shared/components/item-edit/UserChip.js +1 -1
- package/dist/shared/components/queue/QueueWorklist.js +1026 -1006
- package/package.json +1 -1
- package/styles.css +10 -0
|
@@ -10,14 +10,14 @@ import { cn as G } from "../../lib/utils.js";
|
|
|
10
10
|
import { Popover as be, PopoverTrigger as ke, PopoverContent as xe } from "../ui/popover.js";
|
|
11
11
|
import { useAvailableBulkActions as ge, bulkActionEnabled as ye } from "./BulkActionButtons.js";
|
|
12
12
|
function H(i, r, t, d) {
|
|
13
|
-
return ((i == null ? void 0 : i[t]) ?? []).some((
|
|
13
|
+
return ((i == null ? void 0 : i[t]) ?? []).some((m) => m.source === "builtin" && m.key === d) && ye(r, t, d);
|
|
14
14
|
}
|
|
15
15
|
function ve(i) {
|
|
16
16
|
const r = { succeeded: 0, failed: 0, skipped: 0, errors: [], outcomes: [] };
|
|
17
17
|
for (const { collection: t, data: d } of i) {
|
|
18
18
|
r.succeeded += d.succeeded ?? 0, r.failed += d.failed ?? 0, r.skipped += d.skipped ?? 0, r.errors.push(...d.errors ?? []);
|
|
19
|
-
for (const
|
|
20
|
-
r.outcomes.push({ ...
|
|
19
|
+
for (const m of d.outcomes ?? [])
|
|
20
|
+
r.outcomes.push({ ...m, item: `${t}:${m.item}` });
|
|
21
21
|
}
|
|
22
22
|
return r;
|
|
23
23
|
}
|
|
@@ -30,7 +30,7 @@ function Qe({
|
|
|
30
30
|
enabledKeys: r,
|
|
31
31
|
tone: t = "light",
|
|
32
32
|
disabled: d,
|
|
33
|
-
onDone:
|
|
33
|
+
onDone: m
|
|
34
34
|
}) {
|
|
35
35
|
const v = pe(), J = oe(), w = K(() => [...new Set(i.map((e) => e.collection))], [i]), { data: j } = ge(w), N = w.filter((e) => H(j, r, e, "push")), O = w.filter(
|
|
36
36
|
(e) => H(j, r, e, "retry-push")
|
|
@@ -44,29 +44,29 @@ function Qe({
|
|
|
44
44
|
const e = /* @__PURE__ */ new Map();
|
|
45
45
|
return N.forEach((s, a) => {
|
|
46
46
|
var o;
|
|
47
|
-
for (const n of ((o = P[a]) == null ? void 0 : o.data) ?? []) {
|
|
48
|
-
const
|
|
49
|
-
|
|
47
|
+
for (const n of (((o = P[a]) == null ? void 0 : o.data) ?? []).filter((u) => u.bulk !== !1)) {
|
|
48
|
+
const u = e.get(n.id);
|
|
49
|
+
u ? u.collections.push(s) : e.set(n.id, { ...n, collections: [s] });
|
|
50
50
|
}
|
|
51
51
|
}), [...e.values()];
|
|
52
52
|
}, [V, N.join(",")]), [X, S] = x(null), [g, A] = x(""), [M, _] = x(null), [Y, $] = x({}), [Z, E] = x({}), D = (e) => {
|
|
53
|
-
const [s, ...a] = e.split(":"), o = a.join(":"), n = i.find((
|
|
53
|
+
const [s, ...a] = e.split(":"), o = a.join(":"), n = i.find((u) => u.collection === s && String(u.id) === o);
|
|
54
54
|
return n != null && n.label ? String(n.label) : `#${o}`;
|
|
55
55
|
}, Q = async (e, s) => {
|
|
56
56
|
const a = e.kind === "push" ? e.action.collections : e.collections, o = [];
|
|
57
57
|
for (const n of a) {
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
58
|
+
const u = i.filter((p) => p.collection === n).map((p) => p.id);
|
|
59
|
+
if (u.length === 0) continue;
|
|
60
60
|
const k = e.kind === "push" ? await v.request(
|
|
61
61
|
U("/bulk-actions/push", {
|
|
62
62
|
collection: n,
|
|
63
63
|
action_id: e.action.id,
|
|
64
|
-
ids:
|
|
64
|
+
ids: u,
|
|
65
65
|
dry_run: s,
|
|
66
66
|
...g.trim() ? { payload: { message: g.trim() } } : {}
|
|
67
67
|
})
|
|
68
68
|
) : await v.request(
|
|
69
|
-
U("/bulk-actions/retry-push", { collection: n, ids:
|
|
69
|
+
U("/bulk-actions/retry-push", { collection: n, ids: u, dry_run: s })
|
|
70
70
|
);
|
|
71
71
|
o.push({ collection: n, data: k.data });
|
|
72
72
|
}
|
|
@@ -117,13 +117,13 @@ function Qe({
|
|
|
117
117
|
);
|
|
118
118
|
return /* @__PURE__ */ l(ie, { children: B.map((e) => {
|
|
119
119
|
var F, L, z, T;
|
|
120
|
-
const s = C(e), a = R(e), o = e.kind === "push" ? e.action.collections : e.collections, n = i.filter((b) => o.includes(b.collection)).length,
|
|
120
|
+
const s = C(e), a = R(e), o = e.kind === "push" ? e.action.collections : e.collections, n = i.filter((b) => o.includes(b.collection)).length, u = X === s, k = M === s, p = e.kind === "push" ? (F = e.action.confirm) == null ? void 0 : F.input : void 0, h = Y[s], f = Z[s] ?? null, y = h && h !== "loading" ? h.succeeded : null, ne = n > 0 && !k && y !== 0 && (!(p != null && p.required) || g.trim().length > 0), re = e.kind === "push" ? ((L = e.action.confirm) == null ? void 0 : L.body) ?? `Runs "${e.action.label}" on each selected record, one at a time. Every record is a real request to the partner.` : "Re-sends the latest failed push of each selected record, partner by partner — the same stored request the record’s own Retry button sends.";
|
|
121
121
|
return /* @__PURE__ */ c(
|
|
122
122
|
be,
|
|
123
123
|
{
|
|
124
|
-
open:
|
|
124
|
+
open: u,
|
|
125
125
|
onOpenChange: (b) => {
|
|
126
|
-
S(b ? s : null), b ? (A(""), E((ae) => ({ ...ae, [s]: null })), ee(e)) : f && (
|
|
126
|
+
S(b ? s : null), b ? (A(""), E((ae) => ({ ...ae, [s]: null })), ee(e)) : f && (m == null || m(f));
|
|
127
127
|
},
|
|
128
128
|
children: [
|
|
129
129
|
/* @__PURE__ */ l(ke, { asChild: !0, children: /* @__PURE__ */ c(
|
|
@@ -134,7 +134,7 @@ function Qe({
|
|
|
134
134
|
"data-bulk-push-action": e.kind === "push" ? e.action.id : void 0,
|
|
135
135
|
"data-bulk-retry-push": e.kind === "retry" ? "" : void 0,
|
|
136
136
|
title: e.kind === "push" ? `Run ${e.action.label} on the selected records` : "Re-send each selected record’s latest failed push",
|
|
137
|
-
className: se(
|
|
137
|
+
className: se(u),
|
|
138
138
|
children: [
|
|
139
139
|
k ? /* @__PURE__ */ l(I, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ l(ce, { className: "h-3.5 w-3.5" }),
|
|
140
140
|
a
|
|
@@ -201,7 +201,7 @@ function Qe({
|
|
|
201
201
|
{
|
|
202
202
|
type: "button",
|
|
203
203
|
onClick: () => {
|
|
204
|
-
S(null), f && (
|
|
204
|
+
S(null), f && (m == null || m(f));
|
|
205
205
|
},
|
|
206
206
|
className: "h-8 rounded-md px-2.5 text-[12.5px] font-medium text-slate-600 hover:bg-muted dark:text-slate-300",
|
|
207
207
|
children: f ? "Done" : "Close"
|
|
@@ -1,53 +1,63 @@
|
|
|
1
|
-
import { useQuery as
|
|
2
|
-
import { useNivaroClient as
|
|
3
|
-
import { get as
|
|
1
|
+
import { useQuery as h } from "@tanstack/react-query";
|
|
2
|
+
import { useNivaroClient as g } from "../../context.js";
|
|
3
|
+
import { get as m, post as y } from "../../lib/commands.js";
|
|
4
4
|
import { builtinListed as p } from "./PushBulkButtons.js";
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
for (const
|
|
8
|
-
const r = String(
|
|
9
|
-
|
|
5
|
+
function w(s) {
|
|
6
|
+
const a = /* @__PURE__ */ new Set(), n = [];
|
|
7
|
+
for (const e of s) {
|
|
8
|
+
const r = String(e.external_api ?? "");
|
|
9
|
+
a.has(r) || (a.add(r), (e.status === "failed" || e.status === "rejected") && n.push(e.external_api_name ?? `API ${e.external_api ?? "?"}`));
|
|
10
10
|
}
|
|
11
11
|
return n;
|
|
12
12
|
}
|
|
13
13
|
function S({
|
|
14
|
-
collection:
|
|
15
|
-
id:
|
|
14
|
+
collection: s,
|
|
15
|
+
id: a,
|
|
16
16
|
open: n,
|
|
17
|
-
bulkData:
|
|
17
|
+
bulkData: e,
|
|
18
18
|
bulkEnabledKeys: r
|
|
19
19
|
}) {
|
|
20
|
-
const
|
|
21
|
-
queryKey: ["
|
|
22
|
-
queryFn: () =>
|
|
23
|
-
|
|
24
|
-
).then((h) => h.data ?? []).catch(() => []),
|
|
25
|
-
enabled: n && a,
|
|
20
|
+
const u = g(), i = p(e, r, s, "push"), c = p(e, r, s, "retry-push"), { data: o = [] } = h({
|
|
21
|
+
queryKey: ["bulk-push-actions", s],
|
|
22
|
+
queryFn: () => u.request(m("/item-actions/registered", { collection: s })).then((t) => t.data ?? []).catch(() => []),
|
|
23
|
+
enabled: n && i,
|
|
26
24
|
staleTime: 5 * 6e4
|
|
27
|
-
}), { data:
|
|
28
|
-
queryKey: ["
|
|
29
|
-
queryFn: () =>
|
|
25
|
+
}), { data: d = [] } = h({
|
|
26
|
+
queryKey: ["item-actions", s, String(a)],
|
|
27
|
+
queryFn: () => u.request(
|
|
28
|
+
m("/item-actions/registered", { collection: s, item: String(a) })
|
|
29
|
+
).then((t) => t.data ?? []).catch(() => []),
|
|
30
|
+
enabled: n && i,
|
|
31
|
+
staleTime: 5 * 6e4
|
|
32
|
+
}), { data: f = [] } = h({
|
|
33
|
+
queryKey: ["row-push-state", s, String(a)],
|
|
34
|
+
queryFn: () => u.request(m(`/erp-submissions/${s}/${a}`)).then((t) => w(t.data ?? [])).catch(() => []),
|
|
30
35
|
enabled: n && c,
|
|
31
36
|
staleTime: 15e3
|
|
32
|
-
})
|
|
33
|
-
|
|
37
|
+
}), q = new Set(d.map((t) => t.id)), l = [
|
|
38
|
+
...d.map((t) => ({ ...t, ready: !0 })),
|
|
39
|
+
// Not ready here: listed, disabled — unless it is withheld from this person
|
|
40
|
+
// (an addendum they could not create), which stays hidden.
|
|
41
|
+
...o.filter((t) => !q.has(t.id) && !t.requires_addendum_create).map((t) => ({ ...t, ready: !1 }))
|
|
42
|
+
];
|
|
43
|
+
return { pushActions: i ? l : [], failedPartners: c ? f : [] };
|
|
34
44
|
}
|
|
35
|
-
async function
|
|
36
|
-
var
|
|
37
|
-
const
|
|
38
|
-
return r != null && r.trim() && (
|
|
39
|
-
|
|
40
|
-
collection:
|
|
41
|
-
action_id:
|
|
45
|
+
async function k(s, a, n, e, r, u) {
|
|
46
|
+
var o, d;
|
|
47
|
+
const i = {};
|
|
48
|
+
return r != null && r.trim() && (i.message = r.trim()), e.kind === "push" && e.action.choose && u != null && (i[e.action.choose.key] = u), ((d = (o = (e.kind === "push" ? await s.request(
|
|
49
|
+
y("/bulk-actions/push", {
|
|
50
|
+
collection: a,
|
|
51
|
+
action_id: e.action.id,
|
|
42
52
|
ids: [n],
|
|
43
|
-
...Object.keys(
|
|
53
|
+
...Object.keys(i).length > 0 ? { payload: i } : {}
|
|
44
54
|
})
|
|
45
|
-
) : await
|
|
46
|
-
|
|
47
|
-
)).data) == null ? void 0 :
|
|
55
|
+
) : await s.request(
|
|
56
|
+
y("/bulk-actions/retry-push", { collection: a, ids: [n] })
|
|
57
|
+
)).data) == null ? void 0 : o.outcomes) == null ? void 0 : d[0]) ?? null;
|
|
48
58
|
}
|
|
49
59
|
export {
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
w as latestFailedPartners,
|
|
61
|
+
k as runRowPush,
|
|
52
62
|
S as useRowPushActions
|
|
53
63
|
};
|