@nivaro/react 0.2.49 → 0.2.50
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/shared/components/CollectionBrowserView.js +1576 -1555
- package/dist/shared/components/bulk/RowPushActions.js +37 -36
- package/dist/shared/components/panels/ItemActionButtons.js +100 -68
- package/dist/shared/components/panels/ItemActionChoices.js +60 -0
- package/package.json +1 -1
|
@@ -1,52 +1,53 @@
|
|
|
1
1
|
import { useQuery as m } from "@tanstack/react-query";
|
|
2
2
|
import { useNivaroClient as y } from "../../context.js";
|
|
3
|
-
import { get as
|
|
4
|
-
import { builtinListed as
|
|
5
|
-
function
|
|
6
|
-
const s = /* @__PURE__ */ new Set(),
|
|
7
|
-
for (const
|
|
8
|
-
const r = String(
|
|
9
|
-
s.has(r) || (s.add(r), (
|
|
3
|
+
import { get as d, post as f } from "../../lib/commands.js";
|
|
4
|
+
import { builtinListed as p } from "./PushBulkButtons.js";
|
|
5
|
+
function g(e) {
|
|
6
|
+
const s = /* @__PURE__ */ new Set(), n = [];
|
|
7
|
+
for (const t of e) {
|
|
8
|
+
const r = String(t.external_api ?? "");
|
|
9
|
+
s.has(r) || (s.add(r), (t.status === "failed" || t.status === "rejected") && n.push(t.external_api_name ?? `API ${t.external_api ?? "?"}`));
|
|
10
10
|
}
|
|
11
|
-
return
|
|
11
|
+
return n;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
collection:
|
|
13
|
+
function S({
|
|
14
|
+
collection: e,
|
|
15
15
|
id: s,
|
|
16
|
-
open:
|
|
17
|
-
bulkData:
|
|
16
|
+
open: n,
|
|
17
|
+
bulkData: t,
|
|
18
18
|
bulkEnabledKeys: r
|
|
19
19
|
}) {
|
|
20
|
-
const
|
|
21
|
-
queryKey: ["item-actions",
|
|
22
|
-
queryFn: () =>
|
|
23
|
-
|
|
24
|
-
).then((
|
|
25
|
-
enabled:
|
|
20
|
+
const i = y(), a = p(t, r, e, "push"), c = p(t, r, e, "retry-push"), { data: u = [] } = m({
|
|
21
|
+
queryKey: ["item-actions", e, String(s)],
|
|
22
|
+
queryFn: () => i.request(
|
|
23
|
+
d("/item-actions/registered", { collection: e, item: String(s) })
|
|
24
|
+
).then((h) => h.data ?? []).catch(() => []),
|
|
25
|
+
enabled: n && a,
|
|
26
26
|
staleTime: 5 * 6e4
|
|
27
|
-
}), { data:
|
|
28
|
-
queryKey: ["row-push-state",
|
|
29
|
-
queryFn: () =>
|
|
30
|
-
enabled:
|
|
27
|
+
}), { data: o = [] } = m({
|
|
28
|
+
queryKey: ["row-push-state", e, String(s)],
|
|
29
|
+
queryFn: () => i.request(d(`/erp-submissions/${e}/${s}`)).then((h) => g(h.data ?? [])).catch(() => []),
|
|
30
|
+
enabled: n && c,
|
|
31
31
|
staleTime: 15e3
|
|
32
32
|
});
|
|
33
|
-
return { pushActions:
|
|
33
|
+
return { pushActions: a ? u : [], failedPartners: c ? o : [] };
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
async function _(e, s, n, t, r, i) {
|
|
36
|
+
var u, o;
|
|
37
|
+
const a = {};
|
|
38
|
+
return r != null && r.trim() && (a.message = r.trim()), t.kind === "push" && t.action.choose && i != null && (a[t.action.choose.key] = i), ((o = (u = (t.kind === "push" ? await e.request(
|
|
39
|
+
f("/bulk-actions/push", {
|
|
39
40
|
collection: s,
|
|
40
|
-
action_id:
|
|
41
|
-
ids: [
|
|
42
|
-
...
|
|
41
|
+
action_id: t.action.id,
|
|
42
|
+
ids: [n],
|
|
43
|
+
...Object.keys(a).length > 0 ? { payload: a } : {}
|
|
43
44
|
})
|
|
44
|
-
) : await
|
|
45
|
-
|
|
46
|
-
)).data) == null ? void 0 :
|
|
45
|
+
) : await e.request(
|
|
46
|
+
f("/bulk-actions/retry-push", { collection: s, ids: [n] })
|
|
47
|
+
)).data) == null ? void 0 : u.outcomes) == null ? void 0 : o[0]) ?? null;
|
|
47
48
|
}
|
|
48
49
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
g as latestFailedPartners,
|
|
51
|
+
_ as runRowPush,
|
|
52
|
+
S as useRowPushActions
|
|
52
53
|
};
|
|
@@ -1,115 +1,147 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { toast as
|
|
7
|
-
import { useNivaroClient as
|
|
8
|
-
import { get as
|
|
9
|
-
import { PushReadinessChip as
|
|
10
|
-
import { Button as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { jsxs as d, Fragment as F, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as B, useQuery as L, useMutation as R } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as _, Play as E, X as M } from "lucide-react";
|
|
4
|
+
import { useState as m } from "react";
|
|
5
|
+
import { createPortal as O } from "react-dom";
|
|
6
|
+
import { toast as x } from "sonner";
|
|
7
|
+
import { useNivaroClient as T } from "../../context.js";
|
|
8
|
+
import { get as z, post as X } from "../../lib/commands.js";
|
|
9
|
+
import { PushReadinessChip as D } from "../integrations/RecordIntegrationPreview.js";
|
|
10
|
+
import { Button as g } from "../ui/button.js";
|
|
11
|
+
import { ItemActionChoiceList as G, itemActionChoiceStep as H } from "./ItemActionChoices.js";
|
|
12
|
+
function re({ collection: r, itemId: s }) {
|
|
13
|
+
var w, Q, K, S, j, A;
|
|
14
|
+
const f = T(), l = B(), [k, u] = m(null), { data: h } = L({
|
|
15
|
+
queryKey: ["item-actions", r, s],
|
|
16
|
+
queryFn: () => f.request(
|
|
17
|
+
z("/item-actions/registered", { collection: r, item: s })
|
|
17
18
|
).then((e) => e.data ?? []),
|
|
18
19
|
staleTime: 5 * 6e4
|
|
19
|
-
}), [t,
|
|
20
|
-
mutationFn: ({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
20
|
+
}), [t, p] = m(null), [b, N] = m(""), [y, P] = m(null), [v, q] = m(null), C = R({
|
|
21
|
+
mutationFn: ({
|
|
22
|
+
action: e,
|
|
23
|
+
message: i,
|
|
24
|
+
pick: a
|
|
25
|
+
}) => {
|
|
26
|
+
const o = {};
|
|
27
|
+
return i != null && i.trim() && (o.message = i.trim()), e.choose && a != null && (o[e.choose.key] = a), f.request(
|
|
28
|
+
X(`/item-actions/${e.id}/execute`, {
|
|
29
|
+
collection: r,
|
|
30
|
+
itemId: s,
|
|
31
|
+
...Object.keys(o).length > 0 ? { payload: o } : {}
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
},
|
|
27
35
|
onSuccess: (e) => {
|
|
28
|
-
var
|
|
29
|
-
|
|
36
|
+
var i;
|
|
37
|
+
x.success(((i = e == null ? void 0 : e.data) == null ? void 0 : i.message) ?? "Action completed"), l.invalidateQueries({ queryKey: ["item", r, String(s)] }), l.invalidateQueries({ queryKey: ["erp-submissions", r, String(s)] }), l.invalidateQueries({ queryKey: ["item-actions", r, s] }), l.invalidateQueries({ queryKey: ["addendums", r] }), l.invalidateQueries({ queryKey: ["pipeline-all-owners"] }), l.invalidateQueries({ queryKey: ["o2m-rows"] }), l.invalidateQueries({ queryKey: ["pipeline-instance", r, String(s)] });
|
|
30
38
|
},
|
|
31
|
-
onError: (e, { action:
|
|
32
|
-
const
|
|
33
|
-
|
|
39
|
+
onError: (e, { action: i }) => {
|
|
40
|
+
const a = e == null ? void 0 : e.response;
|
|
41
|
+
x.error((a == null ? void 0 : a.error) ?? `${i.label} failed`, { duration: 12e3 }), l.invalidateQueries({ queryKey: ["erp-submissions", r, String(s)] });
|
|
34
42
|
},
|
|
35
|
-
onSettled: () =>
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
onSettled: () => u(null)
|
|
44
|
+
}), $ = async (e) => {
|
|
45
|
+
let i = null, a = null;
|
|
46
|
+
if (e.choose) {
|
|
47
|
+
u(e.id);
|
|
48
|
+
try {
|
|
49
|
+
const o = await f.request(
|
|
50
|
+
z(`/item-actions/${e.id}/choices`, { collection: r, item: s })
|
|
51
|
+
), c = H(o.data ?? []);
|
|
52
|
+
c.ask ? a = o.data : i = c.value;
|
|
53
|
+
} catch (o) {
|
|
54
|
+
const c = o == null ? void 0 : o.response;
|
|
55
|
+
x.error((c == null ? void 0 : c.error) ?? `${e.label}: could not load the options`), u(null);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
u(null);
|
|
59
|
+
}
|
|
60
|
+
if (e.confirm || a) {
|
|
61
|
+
N(""), P(a), q(i), p(e);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
u(e.id), C.mutate({ action: e, pick: i });
|
|
65
|
+
};
|
|
66
|
+
return !h || h.length === 0 ? null : /* @__PURE__ */ d(F, { children: [
|
|
67
|
+
h.map((e) => /* @__PURE__ */ d("span", { className: "relative inline-flex", children: [
|
|
68
|
+
/* @__PURE__ */ d(
|
|
69
|
+
g,
|
|
41
70
|
{
|
|
42
71
|
type: "button",
|
|
43
72
|
size: "sm",
|
|
44
73
|
variant: e.variant ?? "outline",
|
|
45
74
|
className: "gap-1.5",
|
|
46
|
-
disabled:
|
|
47
|
-
onClick: () =>
|
|
48
|
-
if (e.confirm) {
|
|
49
|
-
h(""), l(e);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
d(e.id), x.mutate({ action: e });
|
|
53
|
-
},
|
|
75
|
+
disabled: k !== null,
|
|
76
|
+
onClick: () => void $(e),
|
|
54
77
|
children: [
|
|
55
|
-
|
|
78
|
+
k === e.id ? /* @__PURE__ */ n(_, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(E, { className: "h-3.5 w-3.5" }),
|
|
56
79
|
e.label
|
|
57
80
|
]
|
|
58
81
|
}
|
|
59
82
|
),
|
|
60
|
-
e.has_preflight && /* @__PURE__ */
|
|
61
|
-
|
|
83
|
+
e.has_preflight && /* @__PURE__ */ n(
|
|
84
|
+
D,
|
|
62
85
|
{
|
|
63
86
|
collection: r,
|
|
64
|
-
itemId: String(
|
|
87
|
+
itemId: String(s),
|
|
65
88
|
itemActionId: e.id,
|
|
66
89
|
label: e.label,
|
|
67
90
|
compact: !0
|
|
68
91
|
}
|
|
69
92
|
)
|
|
70
93
|
] }, e.id)),
|
|
71
|
-
t &&
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
94
|
+
t && O(
|
|
95
|
+
/* @__PURE__ */ n("div", { className: "fixed inset-0 z-[130] flex items-center justify-center bg-black/40 p-4", children: /* @__PURE__ */ d("div", { className: "w-full max-w-md rounded-lg border border-slate-200 bg-white p-5 shadow-xl dark:border-border dark:bg-card", children: [
|
|
96
|
+
/* @__PURE__ */ d("div", { className: "flex items-start justify-between gap-3", children: [
|
|
97
|
+
/* @__PURE__ */ n("h3", { className: "text-[14px] font-semibold text-slate-900 dark:text-foreground", children: ((w = t.confirm) == null ? void 0 : w.title) ?? t.label }),
|
|
98
|
+
/* @__PURE__ */ n(
|
|
76
99
|
"button",
|
|
77
100
|
{
|
|
78
101
|
type: "button",
|
|
79
|
-
onClick: () =>
|
|
102
|
+
onClick: () => p(null),
|
|
80
103
|
className: "rounded p-1 text-slate-400 hover:text-slate-600",
|
|
81
104
|
"aria-label": "Close",
|
|
82
|
-
children: /* @__PURE__ */
|
|
105
|
+
children: /* @__PURE__ */ n(M, { className: "h-4 w-4" })
|
|
83
106
|
}
|
|
84
107
|
)
|
|
85
108
|
] }),
|
|
86
|
-
((
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
109
|
+
((Q = t.confirm) == null ? void 0 : Q.body) && /* @__PURE__ */ n("p", { className: "mt-2 text-[12.5px] leading-relaxed text-slate-600 dark:text-muted-foreground", children: t.confirm.body }),
|
|
110
|
+
t.choose && y && /* @__PURE__ */ n(
|
|
111
|
+
G,
|
|
112
|
+
{
|
|
113
|
+
choose: t.choose,
|
|
114
|
+
options: y,
|
|
115
|
+
value: v,
|
|
116
|
+
onChange: q
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
((K = t.confirm) == null ? void 0 : K.input) && /* @__PURE__ */ d("div", { className: "mt-3", children: [
|
|
120
|
+
/* @__PURE__ */ n("p", { className: "mb-1 text-[11.5px] font-medium text-slate-500", children: t.confirm.input.label }),
|
|
121
|
+
/* @__PURE__ */ n(
|
|
90
122
|
"textarea",
|
|
91
123
|
{
|
|
92
|
-
value:
|
|
93
|
-
onChange: (e) =>
|
|
124
|
+
value: b,
|
|
125
|
+
onChange: (e) => N(e.target.value),
|
|
94
126
|
placeholder: t.confirm.input.placeholder,
|
|
95
127
|
rows: 3,
|
|
96
128
|
className: "w-full rounded-md border border-slate-200 bg-background px-2.5 py-1.5 text-[12.5px] dark:border-border"
|
|
97
129
|
}
|
|
98
130
|
)
|
|
99
131
|
] }),
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
|
|
132
|
+
/* @__PURE__ */ d("div", { className: "mt-4 flex justify-end gap-2", children: [
|
|
133
|
+
/* @__PURE__ */ n(g, { type: "button", size: "sm", variant: "ghost", onClick: () => p(null), children: "Cancel" }),
|
|
134
|
+
/* @__PURE__ */ n(
|
|
135
|
+
g,
|
|
104
136
|
{
|
|
105
137
|
type: "button",
|
|
106
138
|
size: "sm",
|
|
107
|
-
disabled: !!((
|
|
139
|
+
disabled: !!((j = (S = t.confirm) == null ? void 0 : S.input) != null && j.required) && !b.trim() || !!y && v == null,
|
|
108
140
|
onClick: () => {
|
|
109
141
|
const e = t;
|
|
110
|
-
|
|
142
|
+
p(null), u(e.id), C.mutate({ action: e, message: b, pick: v });
|
|
111
143
|
},
|
|
112
|
-
children: ((
|
|
144
|
+
children: ((A = t.confirm) == null ? void 0 : A.confirm_label) ?? t.label
|
|
113
145
|
}
|
|
114
146
|
)
|
|
115
147
|
] })
|
|
@@ -119,5 +151,5 @@ function U({ collection: r, itemId: n }) {
|
|
|
119
151
|
] });
|
|
120
152
|
}
|
|
121
153
|
export {
|
|
122
|
-
|
|
154
|
+
re as ItemActionButtons
|
|
123
155
|
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { Check as i } from "lucide-react";
|
|
3
|
+
import { cn as n } from "../../lib/utils.js";
|
|
4
|
+
function b(e) {
|
|
5
|
+
return e.length === 0 ? { ask: !1, value: null } : e.length === 1 ? { ask: !1, value: e[0].value } : { ask: !0 };
|
|
6
|
+
}
|
|
7
|
+
function x({
|
|
8
|
+
choose: e,
|
|
9
|
+
options: d,
|
|
10
|
+
value: s,
|
|
11
|
+
onChange: c
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ l("div", { className: "mt-3", "data-item-action-choices": e.key, children: [
|
|
14
|
+
/* @__PURE__ */ t("p", { className: "mb-1 text-[11.5px] font-medium text-slate-500 dark:text-muted-foreground", children: e.label }),
|
|
15
|
+
e.body && /* @__PURE__ */ t("p", { className: "mb-2 text-[12px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: e.body }),
|
|
16
|
+
/* @__PURE__ */ t(
|
|
17
|
+
"fieldset",
|
|
18
|
+
{
|
|
19
|
+
"aria-label": e.label,
|
|
20
|
+
className: "m-0 max-h-64 min-w-0 overflow-y-auto overscroll-contain rounded-md border border-slate-200 p-0 dark:border-border",
|
|
21
|
+
children: d.map((r) => {
|
|
22
|
+
const a = r.value === s;
|
|
23
|
+
return /* @__PURE__ */ l(
|
|
24
|
+
"button",
|
|
25
|
+
{
|
|
26
|
+
type: "button",
|
|
27
|
+
"aria-pressed": a,
|
|
28
|
+
onClick: () => c(r.value),
|
|
29
|
+
className: n(
|
|
30
|
+
"flex w-full items-start gap-2 border-b border-slate-100 px-2.5 py-2 text-left last:border-b-0 dark:border-border",
|
|
31
|
+
a ? "bg-accent" : "hover:bg-muted"
|
|
32
|
+
),
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ t(
|
|
35
|
+
"span",
|
|
36
|
+
{
|
|
37
|
+
className: n(
|
|
38
|
+
"mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border",
|
|
39
|
+
a ? "border-nvr-cyan bg-nvr-cyan text-white" : "border-slate-300 dark:border-border"
|
|
40
|
+
),
|
|
41
|
+
children: a && /* @__PURE__ */ t(i, { className: "h-2.5 w-2.5" })
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ l("span", { className: "min-w-0 flex-1", children: [
|
|
45
|
+
/* @__PURE__ */ t("span", { className: "block truncate text-[12.5px] text-slate-800 dark:text-foreground", children: r.label }),
|
|
46
|
+
r.hint && /* @__PURE__ */ t("span", { className: "block truncate text-[11px] text-slate-500 dark:text-muted-foreground", children: r.hint })
|
|
47
|
+
] })
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
r.value
|
|
51
|
+
);
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
x as ItemActionChoiceList,
|
|
59
|
+
b as itemActionChoiceStep
|
|
60
|
+
};
|