@nivaro/react 0.3.89 → 0.3.90
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/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/CollectionBrowserView.js +151 -150
- package/dist/shared/components/ItemEditForm.js +2108 -2058
- package/dist/shared/components/panels/AddendumPanel.js +691 -691
- package/dist/shared/components/panels/MoveToStatePanel.js +78 -64
- package/dist/shared/components/panels/PipelinePanel.js +1149 -1132
- package/dist/shared/lib/move-state.js +10 -0
- package/package.json +1 -1
|
@@ -1,105 +1,119 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMutation as
|
|
3
|
-
import { MoveRight as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { toast as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { post as
|
|
8
|
-
import { toastError as
|
|
9
|
-
import { Button as
|
|
10
|
-
import { SimpleSelect as
|
|
11
|
-
import { Textarea as
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
collection:
|
|
15
|
-
item:
|
|
16
|
-
states:
|
|
17
|
-
currentStateId:
|
|
18
|
-
onMoved:
|
|
1
|
+
import { jsxs as o, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as F, useMutation as L } from "@tanstack/react-query";
|
|
3
|
+
import { MoveRight as O, Loader2 as T } from "lucide-react";
|
|
4
|
+
import { useState as h, useEffect as U, useMemo as j } from "react";
|
|
5
|
+
import { toast as z } from "sonner";
|
|
6
|
+
import { useNivaroClient as W } from "../../context.js";
|
|
7
|
+
import { get as B, post as K } from "../../lib/commands.js";
|
|
8
|
+
import { toastError as Q } from "../../lib/error-toast.js";
|
|
9
|
+
import { Button as C } from "../ui/button.js";
|
|
10
|
+
import { SimpleSelect as V } from "../ui/SimpleSelect.js";
|
|
11
|
+
import { Textarea as G } from "../ui/textarea.js";
|
|
12
|
+
const $ = 5;
|
|
13
|
+
function re({
|
|
14
|
+
collection: m,
|
|
15
|
+
item: d,
|
|
16
|
+
states: n,
|
|
17
|
+
currentStateId: R,
|
|
18
|
+
onMoved: E,
|
|
19
|
+
openSignal: x = 0,
|
|
20
|
+
standalone: c = !1,
|
|
21
|
+
onCancel: p
|
|
19
22
|
}) {
|
|
20
|
-
|
|
23
|
+
var M, w, S, P;
|
|
24
|
+
const f = W(), [I, i] = h(c), [u, g] = h(""), [l, v] = h("");
|
|
25
|
+
U(() => {
|
|
26
|
+
x > 0 && i(!0);
|
|
27
|
+
}, [x]);
|
|
28
|
+
const { data: t, isLoading: b } = F({
|
|
29
|
+
queryKey: ["move-state-instance", m, String(d)],
|
|
30
|
+
queryFn: () => f.request(
|
|
31
|
+
B(`/pipelines/instance/${m}/${encodeURIComponent(String(d))}`)
|
|
32
|
+
),
|
|
33
|
+
enabled: !n
|
|
34
|
+
}), N = n ?? ((M = t == null ? void 0 : t.data) == null ? void 0 : M.states) ?? [], y = n ? R ?? null : ((S = (w = t == null ? void 0 : t.data) == null ? void 0 : w.instance) == null ? void 0 : S.current_state) ?? null, _ = !n && !b && !((P = t == null ? void 0 : t.data) != null && P.instance), q = j(
|
|
21
35
|
() => [
|
|
22
36
|
{ value: "", label: "Pick a state" },
|
|
23
|
-
...
|
|
37
|
+
...N.filter((e) => String(e.id).toUpperCase() !== String(y ?? "").toUpperCase()).map((e) => ({ value: String(e.id), label: e.label }))
|
|
24
38
|
],
|
|
25
|
-
[
|
|
26
|
-
),
|
|
39
|
+
[N, y]
|
|
40
|
+
), r = L({
|
|
27
41
|
mutationFn: () => f.request(
|
|
28
|
-
|
|
29
|
-
to_state:
|
|
30
|
-
reason:
|
|
42
|
+
K(`/pipelines/instance/${m}/${encodeURIComponent(String(d))}/move-state`, {
|
|
43
|
+
to_state: u,
|
|
44
|
+
reason: l.trim()
|
|
31
45
|
})
|
|
32
46
|
),
|
|
33
47
|
onSuccess: (e) => {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
),
|
|
48
|
+
const a = e == null ? void 0 : e.data;
|
|
49
|
+
z.success(
|
|
50
|
+
a != null && a.ended ? `Moved to ${a.to.label}, then an automatic rule took it to ${a.ended.label}` : `Moved to ${(a == null ? void 0 : a.to.label) ?? "the new state"}`
|
|
51
|
+
), c || i(!1), g(""), v(""), E();
|
|
38
52
|
},
|
|
39
|
-
onError: (e) =>
|
|
40
|
-
}),
|
|
41
|
-
return
|
|
53
|
+
onError: (e) => Q(e, "Could not move it")
|
|
54
|
+
}), k = l.trim().length >= $, A = !!u && k && !r.isPending;
|
|
55
|
+
return I ? _ ? /* @__PURE__ */ s("p", { className: "text-[12px] text-slate-500", "data-move-to-state-none": !0, children: "This record has no pipeline to move." }) : /* @__PURE__ */ o(
|
|
42
56
|
"div",
|
|
43
57
|
{
|
|
44
58
|
className: "space-y-3 rounded-lg border border-amber-200 bg-amber-50/60 p-3 dark:border-amber-500/25 dark:bg-amber-500/[0.06]",
|
|
45
59
|
"data-move-to-state-form": !0,
|
|
46
60
|
children: [
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
/* @__PURE__ */
|
|
61
|
+
/* @__PURE__ */ o("div", { className: "space-y-1", children: [
|
|
62
|
+
/* @__PURE__ */ s("p", { className: "text-[12px] font-medium text-slate-800 dark:text-slate-200", children: "Move to state" }),
|
|
63
|
+
/* @__PURE__ */ s("p", { className: "text-[11px] leading-relaxed text-slate-600 dark:text-slate-400", children: "Administrators only. Puts this record straight into the state you pick. No transition steps run: no Fusion or MWF pushes, emails or flows. Automatic rules are checked again afterwards, so it may move on by itself." })
|
|
50
64
|
] }),
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
|
|
65
|
+
/* @__PURE__ */ o("div", { className: "grid gap-2 sm:grid-cols-[minmax(0,220px)_1fr]", children: [
|
|
66
|
+
/* @__PURE__ */ s(
|
|
67
|
+
V,
|
|
54
68
|
{
|
|
55
|
-
value:
|
|
56
|
-
onChange:
|
|
57
|
-
options:
|
|
69
|
+
value: u,
|
|
70
|
+
onChange: g,
|
|
71
|
+
options: q,
|
|
58
72
|
ariaLabel: "New state",
|
|
59
|
-
disabled:
|
|
73
|
+
disabled: r.isPending || !n && b
|
|
60
74
|
}
|
|
61
75
|
),
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
|
|
76
|
+
/* @__PURE__ */ s(
|
|
77
|
+
G,
|
|
64
78
|
{
|
|
65
|
-
value:
|
|
66
|
-
onChange: (e) =>
|
|
79
|
+
value: l,
|
|
80
|
+
onChange: (e) => v(e.target.value),
|
|
67
81
|
placeholder: "Why? Saved in the history.",
|
|
68
82
|
rows: 2,
|
|
69
83
|
maxLength: 500,
|
|
70
|
-
disabled:
|
|
84
|
+
disabled: r.isPending,
|
|
71
85
|
className: "min-h-[38px] text-[12px]",
|
|
72
86
|
"aria-label": "Reason"
|
|
73
87
|
}
|
|
74
88
|
)
|
|
75
89
|
] }),
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
!
|
|
90
|
+
/* @__PURE__ */ o("div", { className: "flex items-center justify-end gap-2", children: [
|
|
91
|
+
!k && l.length > 0 && /* @__PURE__ */ o("span", { className: "mr-auto text-[11px] text-slate-500", children: [
|
|
78
92
|
"A few more words, please (",
|
|
79
|
-
|
|
93
|
+
$,
|
|
80
94
|
" characters or more)."
|
|
81
95
|
] }),
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
|
|
96
|
+
/* @__PURE__ */ s(
|
|
97
|
+
C,
|
|
84
98
|
{
|
|
85
99
|
size: "sm",
|
|
86
100
|
variant: "ghost",
|
|
87
101
|
className: "h-7 text-[12px]",
|
|
88
|
-
onClick: () =>
|
|
89
|
-
disabled:
|
|
102
|
+
onClick: () => c ? p == null ? void 0 : p() : i(!1),
|
|
103
|
+
disabled: r.isPending,
|
|
90
104
|
children: "Cancel"
|
|
91
105
|
}
|
|
92
106
|
),
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
|
|
107
|
+
/* @__PURE__ */ o(
|
|
108
|
+
C,
|
|
95
109
|
{
|
|
96
110
|
size: "sm",
|
|
97
111
|
className: "h-7 gap-1.5 bg-nvr-cyan text-[12px] text-white hover:bg-nvr-cyan/90",
|
|
98
|
-
onClick: () =>
|
|
99
|
-
disabled: !
|
|
112
|
+
onClick: () => r.mutate(),
|
|
113
|
+
disabled: !A,
|
|
100
114
|
"data-move-to-state-submit": !0,
|
|
101
115
|
children: [
|
|
102
|
-
|
|
116
|
+
r.isPending && /* @__PURE__ */ s(T, { className: "h-3 w-3 animate-spin" }),
|
|
103
117
|
"Move"
|
|
104
118
|
]
|
|
105
119
|
}
|
|
@@ -107,21 +121,21 @@ function V({
|
|
|
107
121
|
] })
|
|
108
122
|
]
|
|
109
123
|
}
|
|
110
|
-
) : /* @__PURE__ */
|
|
124
|
+
) : /* @__PURE__ */ o(
|
|
111
125
|
"button",
|
|
112
126
|
{
|
|
113
127
|
type: "button",
|
|
114
128
|
className: "flex items-center gap-1.5 text-[12px] text-slate-400 transition-colors hover:text-slate-600 dark:hover:text-slate-300",
|
|
115
|
-
onClick: () =>
|
|
129
|
+
onClick: () => i(!0),
|
|
116
130
|
"data-move-to-state-open": !0,
|
|
117
131
|
children: [
|
|
118
|
-
/* @__PURE__ */
|
|
132
|
+
/* @__PURE__ */ s(O, { className: "h-3.5 w-3.5" }),
|
|
119
133
|
"Move to state…"
|
|
120
134
|
]
|
|
121
135
|
}
|
|
122
136
|
);
|
|
123
137
|
}
|
|
124
138
|
export {
|
|
125
|
-
|
|
126
|
-
|
|
139
|
+
$ as MOVE_REASON_MIN,
|
|
140
|
+
re as MoveToStatePanel
|
|
127
141
|
};
|