@nivaro/react 0.3.95 → 0.3.97
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/chat/ChatMessageToast.js +248 -0
- package/dist/shared/components/chat/chat-core.js +415 -381
- package/dist/shared/components/item-edit/M2MCombobox.js +106 -102
- package/dist/shared/components/item-edit/RawEditSheet.js +116 -99
- package/dist/shared/components/ops-report/SettingsPanel.js +44 -41
- package/dist/shared/components/ops-report/drill.js +263 -177
- package/dist/shared/components/panels/PipelinePanel.js +391 -425
- package/package.json +1 -1
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
import { jsx as l, jsxs as f } from "react/jsx-runtime";
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Wrench as
|
|
4
|
-
import { useState as w, useMemo as
|
|
5
|
-
import { toast as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as
|
|
8
|
-
import { titleCase as
|
|
9
|
-
import { Button as
|
|
10
|
-
import { Sheet as
|
|
11
|
-
import { ChangeReasonDialog as
|
|
12
|
-
import { FieldRenderer as
|
|
13
|
-
import { M2MCombobox as
|
|
14
|
-
import { M2MStagingContext as
|
|
15
|
-
import { invalidateM2MFor as
|
|
16
|
-
function
|
|
2
|
+
import { useQueryClient as X, useQuery as R } from "@tanstack/react-query";
|
|
3
|
+
import { Wrench as Y, ShieldAlert as Z, Loader2 as U } from "lucide-react";
|
|
4
|
+
import { useState as w, useMemo as A } from "react";
|
|
5
|
+
import { toast as F } from "sonner";
|
|
6
|
+
import { useNivaroClient as I } from "../../context.js";
|
|
7
|
+
import { get as $, patch as ee, del as te, post as ne } from "../../lib/commands.js";
|
|
8
|
+
import { titleCase as Q } from "../../lib/utils.js";
|
|
9
|
+
import { Button as T } from "../ui/button.js";
|
|
10
|
+
import { Sheet as ae, SheetContent as re, SheetHeader as se, SheetTitle as ie } from "../ui/sheet.js";
|
|
11
|
+
import { ChangeReasonDialog as le, changeReasonChallenge as oe } from "./ChangeReasonDialog.js";
|
|
12
|
+
import { FieldRenderer as ce } from "./FieldRenderer.js";
|
|
13
|
+
import { M2MCombobox as de, m2aAllowedCount as me, m2aWriteMeta as fe } from "./M2MCombobox.js";
|
|
14
|
+
import { M2MStagingContext as ue } from "./M2MStagingContext.js";
|
|
15
|
+
import { invalidateM2MFor as pe } from "./m2m-invalidate.js";
|
|
16
|
+
function W(s, i) {
|
|
17
17
|
const u = (p) => p == null || p === "";
|
|
18
|
-
return u(
|
|
18
|
+
return u(s) && u(i) ? !0 : typeof s == "number" || typeof i == "number" ? Number(s) === Number(i) : typeof s == "boolean" || typeof i == "boolean" ? String(s) === String(i) : typeof s == "object" || typeof i == "object" ? JSON.stringify(s) === JSON.stringify(i) : String(s) === String(i);
|
|
19
19
|
}
|
|
20
|
-
function E(
|
|
21
|
-
if (
|
|
22
|
-
const i = typeof
|
|
20
|
+
function E(s) {
|
|
21
|
+
if (s == null || s === "") return "∅";
|
|
22
|
+
const i = typeof s == "object" ? JSON.stringify(s) : String(s);
|
|
23
23
|
return i.length > 60 ? `${i.slice(0, 57)}…` : i;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
collection:
|
|
25
|
+
function $e({
|
|
26
|
+
collection: s,
|
|
27
27
|
itemId: i,
|
|
28
28
|
open: u,
|
|
29
29
|
onClose: p,
|
|
30
30
|
onSaved: S
|
|
31
31
|
}) {
|
|
32
|
-
const h =
|
|
33
|
-
queryKey: ["raw-edit-config",
|
|
32
|
+
const h = I(), M = X(), [m, j] = w({}), [g, v] = w(/* @__PURE__ */ new Map()), [x, k] = w(/* @__PURE__ */ new Map()), [N, L] = w(!1), [J, q] = w(null), { data: c } = R({
|
|
33
|
+
queryKey: ["raw-edit-config", s],
|
|
34
34
|
queryFn: async () => {
|
|
35
|
-
const [e,
|
|
36
|
-
h.request(
|
|
37
|
-
h.request(
|
|
35
|
+
const [e, n] = await Promise.all([
|
|
36
|
+
h.request($(`/field-config/${s}`)).then((r) => r.data ?? []),
|
|
37
|
+
h.request($(`/collections/${s}`)).then((r) => r.data)
|
|
38
38
|
]);
|
|
39
|
-
return { fields: e, relations:
|
|
39
|
+
return { fields: e, relations: n.relations ?? [] };
|
|
40
40
|
},
|
|
41
41
|
enabled: u,
|
|
42
42
|
staleTime: 6e4
|
|
43
|
-
}), { data: o, isLoading: P } =
|
|
44
|
-
queryKey: ["raw-edit-record",
|
|
45
|
-
queryFn: () => h.request(
|
|
43
|
+
}), { data: o, isLoading: P } = R({
|
|
44
|
+
queryKey: ["raw-edit-record", s, i],
|
|
45
|
+
queryFn: () => h.request($(`/items/${s}/${i}`)).then((e) => e.data),
|
|
46
46
|
enabled: u,
|
|
47
47
|
staleTime: 0
|
|
48
|
-
}), D =
|
|
49
|
-
const e = (c == null ? void 0 : c.fields) ?? [],
|
|
48
|
+
}), D = A(() => {
|
|
49
|
+
const e = (c == null ? void 0 : c.fields) ?? [], n = (c == null ? void 0 : c.relations) ?? [], r = (t) => n.some((a) => a.one_collection === s && a.one_field === t.field);
|
|
50
50
|
return e.filter((t) => !t.field.startsWith("__")).map((t) => ({
|
|
51
51
|
// Strip every conditional/curation config — raw mode ignores them all
|
|
52
52
|
field: {
|
|
@@ -57,127 +57,132 @@ function qe({
|
|
|
57
57
|
lock_condition: null,
|
|
58
58
|
dependency_config: null
|
|
59
59
|
},
|
|
60
|
-
alias:
|
|
61
|
-
m2mRel:
|
|
62
|
-
(
|
|
60
|
+
alias: r(t),
|
|
61
|
+
m2mRel: n.find(
|
|
62
|
+
(a) => a.one_collection === s && a.one_field === t.field && a.junction_field != null
|
|
63
63
|
)
|
|
64
|
-
})).sort((t,
|
|
65
|
-
}, [c,
|
|
66
|
-
(
|
|
67
|
-
), B =
|
|
64
|
+
})).sort((t, a) => (t.field.sort ?? 0) - (a.field.sort ?? 0));
|
|
65
|
+
}, [c, s]), _ = (c == null ? void 0 : c.relations) ?? [], O = (e) => _.find(
|
|
66
|
+
(n) => n.one_collection === s && n.one_field === e && n.junction_field != null
|
|
67
|
+
), B = (e) => {
|
|
68
|
+
const n = _.find(
|
|
69
|
+
(r) => r.many_collection === e.many_collection && r.many_field === e.junction_field && r.id !== e.id
|
|
70
|
+
);
|
|
71
|
+
return !n || n.one_collection ? !1 : me(n) > 1;
|
|
72
|
+
}, H = A(
|
|
68
73
|
() => ({
|
|
69
74
|
getStagedLinks: (e) => g.get(e) ?? [],
|
|
70
75
|
getStagedUnlinks: (e) => x.get(e) ?? /* @__PURE__ */ new Set(),
|
|
71
|
-
stageLink: (e,
|
|
72
|
-
const t = new Map(
|
|
73
|
-
return t.set(e, [...t.get(e) ?? [],
|
|
76
|
+
stageLink: (e, n) => v((r) => {
|
|
77
|
+
const t = new Map(r);
|
|
78
|
+
return t.set(e, [...t.get(e) ?? [], n]), t;
|
|
74
79
|
}),
|
|
75
|
-
unstageLink: (e,
|
|
76
|
-
const t = new Map(
|
|
80
|
+
unstageLink: (e, n) => v((r) => {
|
|
81
|
+
const t = new Map(r);
|
|
77
82
|
return t.set(
|
|
78
83
|
e,
|
|
79
|
-
(t.get(e) ?? []).filter((
|
|
84
|
+
(t.get(e) ?? []).filter((a) => String(a) !== String(n))
|
|
80
85
|
), t;
|
|
81
86
|
}),
|
|
82
|
-
stageUnlink: (e,
|
|
83
|
-
const t = new Map(
|
|
84
|
-
return
|
|
87
|
+
stageUnlink: (e, n) => k((r) => {
|
|
88
|
+
const t = new Map(r), a = new Set(t.get(e) ?? []);
|
|
89
|
+
return a.add(n), t.set(e, a), t;
|
|
85
90
|
}),
|
|
86
|
-
unstageUnlink: (e,
|
|
87
|
-
const t = new Map(
|
|
88
|
-
return
|
|
91
|
+
unstageUnlink: (e, n) => k((r) => {
|
|
92
|
+
const t = new Map(r), a = new Set(t.get(e) ?? []);
|
|
93
|
+
return a.delete(n), t.set(e, a), t;
|
|
89
94
|
})
|
|
90
95
|
}),
|
|
91
96
|
[g, x]
|
|
92
|
-
),
|
|
93
|
-
var
|
|
97
|
+
), G = [...g.values()].some((e) => e.length > 0) || [...x.values()].some((e) => e.size > 0), z = Object.keys(m).length > 0 || G, K = async (e) => {
|
|
98
|
+
var n;
|
|
94
99
|
L(!0);
|
|
95
100
|
try {
|
|
96
101
|
if (Object.keys(m).length > 0) {
|
|
97
102
|
const t = { ...m };
|
|
98
|
-
e && (t._change_reason = e), await h.request(
|
|
103
|
+
e && (t._change_reason = e), await h.request(ee(`/items/${s}/${i}`, t));
|
|
99
104
|
}
|
|
100
|
-
const
|
|
101
|
-
for (const [t,
|
|
102
|
-
if (!
|
|
105
|
+
const r = [];
|
|
106
|
+
for (const [t, a] of x.entries()) {
|
|
107
|
+
if (!a.size) continue;
|
|
103
108
|
const d = O(t);
|
|
104
109
|
if (d)
|
|
105
|
-
for (const y of
|
|
106
|
-
|
|
110
|
+
for (const y of a)
|
|
111
|
+
r.push(h.request(te(`/items/${d.many_collection}/${y}`)).catch(() => {
|
|
107
112
|
}));
|
|
108
113
|
}
|
|
109
|
-
for (const [t,
|
|
110
|
-
if (!
|
|
114
|
+
for (const [t, a] of g.entries()) {
|
|
115
|
+
if (!a.length) continue;
|
|
111
116
|
const d = O(t);
|
|
112
117
|
if (!d) continue;
|
|
113
|
-
const y =
|
|
118
|
+
const y = _.find(
|
|
114
119
|
(b) => b.many_collection === d.many_collection && b.many_field === d.junction_field && b.id !== d.id
|
|
115
|
-
),
|
|
116
|
-
for (const b of
|
|
117
|
-
|
|
120
|
+
), C = fe(y), V = C ? { [C.field]: C.value } : {};
|
|
121
|
+
for (const b of a)
|
|
122
|
+
r.push(
|
|
118
123
|
h.request(
|
|
119
|
-
|
|
124
|
+
ne(`/items/${d.many_collection}`, {
|
|
120
125
|
[d.many_field ?? ""]: i,
|
|
121
126
|
[d.junction_field ?? ""]: b,
|
|
122
|
-
...
|
|
127
|
+
...V
|
|
123
128
|
})
|
|
124
129
|
).catch(() => {
|
|
125
130
|
})
|
|
126
131
|
);
|
|
127
132
|
}
|
|
128
|
-
await Promise.all(
|
|
129
|
-
} catch (
|
|
130
|
-
const t =
|
|
133
|
+
await Promise.all(r), F.success("Raw changes saved"), j({}), v(/* @__PURE__ */ new Map()), k(/* @__PURE__ */ new Map()), M.invalidateQueries({ queryKey: ["item", s, String(i)] }), M.invalidateQueries({ queryKey: ["raw-edit-record", s, i] }), pe(M, [i]), S == null || S(), p();
|
|
134
|
+
} catch (r) {
|
|
135
|
+
const t = oe(r);
|
|
131
136
|
if (t) {
|
|
132
|
-
|
|
137
|
+
q(t);
|
|
133
138
|
return;
|
|
134
139
|
}
|
|
135
|
-
const
|
|
136
|
-
|
|
140
|
+
const a = r == null ? void 0 : r.response;
|
|
141
|
+
F.error(((n = a == null ? void 0 : a.data) == null ? void 0 : n.error) ?? (a == null ? void 0 : a.error) ?? "Save failed");
|
|
137
142
|
} finally {
|
|
138
143
|
L(!1);
|
|
139
144
|
}
|
|
140
145
|
};
|
|
141
146
|
return /* @__PURE__ */ l(
|
|
142
|
-
|
|
147
|
+
ae,
|
|
143
148
|
{
|
|
144
149
|
open: u,
|
|
145
150
|
onOpenChange: (e) => {
|
|
146
|
-
e ||
|
|
151
|
+
e || N || (j({}), v(/* @__PURE__ */ new Map()), k(/* @__PURE__ */ new Map()), p());
|
|
147
152
|
},
|
|
148
153
|
children: /* @__PURE__ */ f(
|
|
149
|
-
|
|
154
|
+
re,
|
|
150
155
|
{
|
|
151
156
|
side: "right",
|
|
152
157
|
className: "flex w-[1040px] max-w-[94vw] flex-col p-0 sm:max-w-[94vw]",
|
|
153
158
|
children: [
|
|
154
|
-
/* @__PURE__ */ l(
|
|
155
|
-
/* @__PURE__ */ l(
|
|
159
|
+
/* @__PURE__ */ l(se, { className: "shrink-0 border-b border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ f(ie, { className: "flex items-center gap-2 text-[14px]", children: [
|
|
160
|
+
/* @__PURE__ */ l(Y, { className: "h-4 w-4 text-nvr-cyan" }),
|
|
156
161
|
"Raw edit — ",
|
|
157
|
-
|
|
162
|
+
Q(s),
|
|
158
163
|
" #",
|
|
159
164
|
i
|
|
160
165
|
] }) }),
|
|
161
166
|
/* @__PURE__ */ f("p", { className: "flex shrink-0 items-center gap-2 border-b border-amber-200 bg-amber-50 px-5 py-2 text-[12px] text-amber-800 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-300", children: [
|
|
162
|
-
/* @__PURE__ */ l(
|
|
167
|
+
/* @__PURE__ */ l(Z, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
163
168
|
"Admin raw mode — visibility rules, locks, cascades and layout restrictions are bypassed. Server-side validation still applies. Every change is recorded in the revision history."
|
|
164
169
|
] }),
|
|
165
|
-
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: P || !c ? /* @__PURE__ */ l("div", { className: "flex justify-center py-10", children: /* @__PURE__ */ l(
|
|
166
|
-
const t = e.field in m ? m[e.field] : o == null ? void 0 : o[e.field],
|
|
170
|
+
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: P || !c ? /* @__PURE__ */ l("div", { className: "flex justify-center py-10", children: /* @__PURE__ */ l(U, { className: "h-5 w-5 animate-spin text-slate-400" }) }) : /* @__PURE__ */ l("div", { className: "space-y-3", children: D.map(({ field: e, alias: n, m2mRel: r }) => {
|
|
171
|
+
const t = e.field in m ? m[e.field] : o == null ? void 0 : o[e.field], a = e.field in m && !W(m[e.field], o == null ? void 0 : o[e.field]);
|
|
167
172
|
return /* @__PURE__ */ f(
|
|
168
173
|
"div",
|
|
169
174
|
{
|
|
170
|
-
className: `grid grid-cols-[220px_1fr] items-start gap-3 rounded-md ${
|
|
171
|
-
"data-raw-changed":
|
|
175
|
+
className: `grid grid-cols-[220px_1fr] items-start gap-3 rounded-md ${a ? "-mx-2 bg-amber-50 px-2 py-1 ring-1 ring-amber-200 dark:bg-amber-400/10 dark:ring-amber-500/30" : ""}`,
|
|
176
|
+
"data-raw-changed": a ? e.field : void 0,
|
|
172
177
|
"data-raw-field": e.field,
|
|
173
178
|
children: [
|
|
174
179
|
/* @__PURE__ */ f("div", { className: "pt-1.5", children: [
|
|
175
180
|
/* @__PURE__ */ f("p", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: [
|
|
176
|
-
e.label ||
|
|
177
|
-
|
|
181
|
+
e.label || Q(e.field),
|
|
182
|
+
a && /* @__PURE__ */ l("span", { className: "ml-1.5 rounded bg-amber-200/70 px-1 text-[9px] font-semibold uppercase tracking-wide text-amber-900 dark:bg-amber-500/20 dark:text-amber-200", children: "changed" })
|
|
178
183
|
] }),
|
|
179
184
|
/* @__PURE__ */ l("p", { className: "font-mono text-[10.5px] text-slate-400", children: e.field }),
|
|
180
|
-
|
|
185
|
+
a && /* @__PURE__ */ f(
|
|
181
186
|
"p",
|
|
182
187
|
{
|
|
183
188
|
className: "mt-0.5 truncate text-[10.5px] text-slate-400",
|
|
@@ -189,14 +194,26 @@ function qe({
|
|
|
189
194
|
}
|
|
190
195
|
)
|
|
191
196
|
] }),
|
|
192
|
-
e.field === "id" ? /* @__PURE__ */ l("p", { className: "pt-1.5 font-mono text-[12px] text-slate-500", children: String(t ?? "") }) :
|
|
193
|
-
|
|
197
|
+
e.field === "id" ? /* @__PURE__ */ l("p", { className: "pt-1.5 font-mono text-[12px] text-slate-500", children: String(t ?? "") }) : n && r && B(r) ? (
|
|
198
|
+
// A ship-to contact is a person OR an external email: the
|
|
199
|
+
// picker here reads every link as a person, so an external
|
|
200
|
+
// email showed "Record not found". The normal form edits it.
|
|
201
|
+
/* @__PURE__ */ l(
|
|
202
|
+
"p",
|
|
203
|
+
{
|
|
204
|
+
className: "pt-1.5 text-[11.5px] italic text-slate-400",
|
|
205
|
+
"data-raw-m2a": e.field,
|
|
206
|
+
children: "Links to more than one kind of record — edit through the normal form"
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
) : n && r ? /* @__PURE__ */ l(ue.Provider, { value: H, children: /* @__PURE__ */ l(de, { relation: r, parentId: i, allRelations: _ }) }) : n ? /* @__PURE__ */ l("p", { className: "pt-1.5 text-[11.5px] italic text-slate-400", children: "Child rows (one-to-many) — edit through the normal form" }) : /* @__PURE__ */ l(
|
|
210
|
+
ce,
|
|
194
211
|
{
|
|
195
212
|
field: e,
|
|
196
213
|
value: t,
|
|
197
|
-
onChange: (d) =>
|
|
214
|
+
onChange: (d) => j((y) => ({ ...y, [e.field]: d })),
|
|
198
215
|
relations: c.relations,
|
|
199
|
-
collection:
|
|
216
|
+
collection: s,
|
|
200
217
|
itemId: i
|
|
201
218
|
}
|
|
202
219
|
)
|
|
@@ -207,22 +224,22 @@ function qe({
|
|
|
207
224
|
}) }) }),
|
|
208
225
|
/* @__PURE__ */ f("div", { className: "flex shrink-0 items-center justify-between gap-3 border-t border-slate-200 px-5 py-3 dark:border-border", children: [
|
|
209
226
|
/* @__PURE__ */ l("span", { className: "text-[11.5px] text-slate-400", children: (() => {
|
|
210
|
-
if (!
|
|
211
|
-
const e = Object.keys(m).filter((
|
|
227
|
+
if (!z) return "No changes yet";
|
|
228
|
+
const e = Object.keys(m).filter((n) => !W(m[n], o == null ? void 0 : o[n])).length + [...g.values()].filter((n) => n.length > 0).length + [...x.values()].filter((n) => n.size > 0).length;
|
|
212
229
|
return e === 0 ? "No changes yet" : `${e} field${e !== 1 ? "s" : ""} changed`;
|
|
213
230
|
})() }),
|
|
214
231
|
/* @__PURE__ */ f("div", { className: "flex gap-2", children: [
|
|
215
|
-
/* @__PURE__ */ l(
|
|
216
|
-
/* @__PURE__ */ l(
|
|
232
|
+
/* @__PURE__ */ l(T, { variant: "outline", size: "sm", onClick: p, disabled: N, children: "Cancel" }),
|
|
233
|
+
/* @__PURE__ */ l(T, { size: "sm", onClick: () => void K(), disabled: !z || N, children: N ? /* @__PURE__ */ l(U, { className: "h-3.5 w-3.5 animate-spin" }) : "Save raw changes" })
|
|
217
234
|
] })
|
|
218
235
|
] }),
|
|
219
236
|
/* @__PURE__ */ l(
|
|
220
|
-
|
|
237
|
+
le,
|
|
221
238
|
{
|
|
222
239
|
challenge: J,
|
|
223
|
-
onCancel: () =>
|
|
240
|
+
onCancel: () => q(null),
|
|
224
241
|
onSubmit: (e) => {
|
|
225
|
-
|
|
242
|
+
q(null), K(e);
|
|
226
243
|
}
|
|
227
244
|
}
|
|
228
245
|
)
|
|
@@ -233,5 +250,5 @@ function qe({
|
|
|
233
250
|
);
|
|
234
251
|
}
|
|
235
252
|
export {
|
|
236
|
-
|
|
253
|
+
$e as RawEditSheet
|
|
237
254
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as h, jsx as t, Fragment as E } from "react/jsx-runtime";
|
|
2
2
|
import { useQueryClient as T, useQuery as j, useMutation as O } from "@tanstack/react-query";
|
|
3
3
|
import { Settings2 as W } from "lucide-react";
|
|
4
4
|
import { useState as w, useEffect as q } from "react";
|
|
@@ -20,18 +20,18 @@ const S = [
|
|
|
20
20
|
"model",
|
|
21
21
|
"token_cap"
|
|
22
22
|
];
|
|
23
|
-
function Q(
|
|
24
|
-
var x,
|
|
25
|
-
const r =
|
|
26
|
-
if (
|
|
23
|
+
function Q(c) {
|
|
24
|
+
var x, b, o, g, y, p;
|
|
25
|
+
const r = c, d = ((x = r == null ? void 0 : r.response) == null ? void 0 : x.fields) ?? ((b = r == null ? void 0 : r.body) == null ? void 0 : b.fields);
|
|
26
|
+
if (d && typeof d == "object") {
|
|
27
27
|
const a = {}, n = [];
|
|
28
|
-
for (const [e,
|
|
29
|
-
S.includes(e) ? a[e] = String(
|
|
28
|
+
for (const [e, l] of Object.entries(d))
|
|
29
|
+
S.includes(e) ? a[e] = String(l) : n.push(String(l));
|
|
30
30
|
return { byField: a, rest: n };
|
|
31
31
|
}
|
|
32
32
|
const i = [
|
|
33
33
|
(o = r == null ? void 0 : r.response) == null ? void 0 : o.message,
|
|
34
|
-
(
|
|
34
|
+
(g = r == null ? void 0 : r.body) == null ? void 0 : g.message,
|
|
35
35
|
(y = r == null ? void 0 : r.response) == null ? void 0 : y.error,
|
|
36
36
|
(p = r == null ? void 0 : r.body) == null ? void 0 : p.error,
|
|
37
37
|
r == null ? void 0 : r.message
|
|
@@ -42,7 +42,7 @@ function Q(d) {
|
|
|
42
42
|
}
|
|
43
43
|
return { byField: s, rest: f };
|
|
44
44
|
}
|
|
45
|
-
function R(
|
|
45
|
+
function R(c) {
|
|
46
46
|
return {
|
|
47
47
|
enabled: "The nightly report",
|
|
48
48
|
window_start_hour: "Window start",
|
|
@@ -51,46 +51,46 @@ function R(d) {
|
|
|
51
51
|
notify: "Notification",
|
|
52
52
|
model: "Model",
|
|
53
53
|
token_cap: "Token cap"
|
|
54
|
-
}[
|
|
54
|
+
}[c];
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
label:
|
|
56
|
+
function m({
|
|
57
|
+
label: c,
|
|
58
58
|
hint: r,
|
|
59
|
-
error:
|
|
59
|
+
error: d,
|
|
60
60
|
children: u
|
|
61
61
|
}) {
|
|
62
|
-
return /* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
/* @__PURE__ */ t("div", { className: "text-[12.5px] font-medium text-slate-800 dark:text-foreground", children:
|
|
62
|
+
return /* @__PURE__ */ h("div", { className: "space-y-1", children: [
|
|
63
|
+
/* @__PURE__ */ h("div", { className: "flex items-center justify-between gap-3", children: [
|
|
64
|
+
/* @__PURE__ */ h("div", { className: "min-w-0", children: [
|
|
65
|
+
/* @__PURE__ */ t("div", { className: "text-[12.5px] font-medium text-slate-800 dark:text-foreground", children: c }),
|
|
66
66
|
r && /* @__PURE__ */ t("div", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: r })
|
|
67
67
|
] }),
|
|
68
68
|
u
|
|
69
69
|
] }),
|
|
70
|
-
|
|
70
|
+
d && /* @__PURE__ */ t("p", { role: "alert", className: "text-[11.5px] text-red-600 dark:text-red-400", children: d })
|
|
71
71
|
] });
|
|
72
72
|
}
|
|
73
73
|
function re() {
|
|
74
|
-
const
|
|
74
|
+
const c = P(), r = T(), [d, u] = w(!1), i = j({
|
|
75
75
|
queryKey: ["ops-report-settings"],
|
|
76
|
-
enabled:
|
|
77
|
-
queryFn: () =>
|
|
78
|
-
}), [s, f] = w(null), [x,
|
|
76
|
+
enabled: d,
|
|
77
|
+
queryFn: () => c.request(M("/ops-reports/settings")).then((e) => e.data)
|
|
78
|
+
}), [s, f] = w(null), [x, b] = w(""), [o, g] = w({ byField: {}, rest: [] }), [y, p] = w(null);
|
|
79
79
|
q(() => {
|
|
80
|
-
i.data && (f(i.data),
|
|
80
|
+
i.data && (f(i.data), b(String(i.data.token_cap)));
|
|
81
81
|
}, [i.data]);
|
|
82
82
|
const a = O({
|
|
83
|
-
mutationFn: (e) =>
|
|
83
|
+
mutationFn: (e) => c.request(B("/ops-reports/settings", e)),
|
|
84
84
|
onSuccess: (e) => {
|
|
85
|
-
|
|
85
|
+
g({ byField: {}, rest: [] }), p(null), r.setQueryData(["ops-report-settings"], e.data), u(!1);
|
|
86
86
|
},
|
|
87
87
|
onError: (e) => {
|
|
88
|
-
const
|
|
89
|
-
|
|
88
|
+
const l = Q(e);
|
|
89
|
+
g(l), e.status === 400 && (Object.keys(l.byField).length || l.rest.length) ? p(null) : (p(e), z(e, "Could not save the settings"));
|
|
90
90
|
}
|
|
91
|
-
}), n = (e,
|
|
92
|
-
return /* @__PURE__ */
|
|
93
|
-
/* @__PURE__ */ t(I, { asChild: !0, children: /* @__PURE__ */
|
|
91
|
+
}), n = (e, l) => f((_) => _ && { ..._, [e]: l });
|
|
92
|
+
return /* @__PURE__ */ h(D, { open: d, onOpenChange: u, children: [
|
|
93
|
+
/* @__PURE__ */ t(I, { asChild: !0, children: /* @__PURE__ */ h(
|
|
94
94
|
k,
|
|
95
95
|
{
|
|
96
96
|
variant: "outline",
|
|
@@ -104,8 +104,8 @@ function re() {
|
|
|
104
104
|
]
|
|
105
105
|
}
|
|
106
106
|
) }),
|
|
107
|
-
/* @__PURE__ */ t(L, { align: "end", className: "w-[340px] space-y-3 p-4", children: i.isLoading || !s ? i.error ? /* @__PURE__ */ t(C, { error: i.error, what: "the settings", onRetry: () => void i.refetch() }) : /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-500", children: "Loading…" }) : /* @__PURE__ */
|
|
108
|
-
/* @__PURE__ */ t(
|
|
107
|
+
/* @__PURE__ */ t(L, { align: "end", className: "w-[340px] space-y-3 p-4", children: i.isLoading || !s ? i.error ? /* @__PURE__ */ t(C, { error: i.error, what: "the settings", onRetry: () => void i.refetch() }) : /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-500", children: "Loading…" }) : /* @__PURE__ */ h(E, { children: [
|
|
108
|
+
/* @__PURE__ */ t(m, { label: "Nightly report", hint: "Run now always works.", error: o.byField.enabled, children: /* @__PURE__ */ t(
|
|
109
109
|
F,
|
|
110
110
|
{
|
|
111
111
|
checked: s.enabled,
|
|
@@ -114,7 +114,7 @@ function re() {
|
|
|
114
114
|
}
|
|
115
115
|
) }),
|
|
116
116
|
/* @__PURE__ */ t(
|
|
117
|
-
|
|
117
|
+
m,
|
|
118
118
|
{
|
|
119
119
|
label: "Window starts (hour)",
|
|
120
120
|
hint: "0 to 23, instance time",
|
|
@@ -137,7 +137,7 @@ function re() {
|
|
|
137
137
|
}
|
|
138
138
|
),
|
|
139
139
|
/* @__PURE__ */ t(
|
|
140
|
-
|
|
140
|
+
m,
|
|
141
141
|
{
|
|
142
142
|
label: "Window ends (hour)",
|
|
143
143
|
hint: "1 to 24, after the start",
|
|
@@ -159,7 +159,7 @@ function re() {
|
|
|
159
159
|
)
|
|
160
160
|
}
|
|
161
161
|
),
|
|
162
|
-
/* @__PURE__ */ t(
|
|
162
|
+
/* @__PURE__ */ t(m, { label: "Email administrators", error: o.byField.email, children: /* @__PURE__ */ t(
|
|
163
163
|
F,
|
|
164
164
|
{
|
|
165
165
|
checked: s.email,
|
|
@@ -168,7 +168,7 @@ function re() {
|
|
|
168
168
|
}
|
|
169
169
|
) }),
|
|
170
170
|
/* @__PURE__ */ t(
|
|
171
|
-
|
|
171
|
+
m,
|
|
172
172
|
{
|
|
173
173
|
label: "Notify administrators",
|
|
174
174
|
hint: "Off = this page only",
|
|
@@ -184,7 +184,7 @@ function re() {
|
|
|
184
184
|
}
|
|
185
185
|
),
|
|
186
186
|
/* @__PURE__ */ t(
|
|
187
|
-
|
|
187
|
+
m,
|
|
188
188
|
{
|
|
189
189
|
label: "Model",
|
|
190
190
|
hint: "Blank = the AI settings’ chat model",
|
|
@@ -202,7 +202,7 @@ function re() {
|
|
|
202
202
|
}
|
|
203
203
|
),
|
|
204
204
|
/* @__PURE__ */ t(
|
|
205
|
-
|
|
205
|
+
m,
|
|
206
206
|
{
|
|
207
207
|
label: "Token cap",
|
|
208
208
|
hint: "20,000 to 5,000,000 per run",
|
|
@@ -213,7 +213,7 @@ function re() {
|
|
|
213
213
|
inputMode: "numeric",
|
|
214
214
|
value: x,
|
|
215
215
|
onChange: (e) => {
|
|
216
|
-
|
|
216
|
+
b(e.target.value), n("token_cap", Number(e.target.value.replace(/[^\d]/g, "")));
|
|
217
217
|
},
|
|
218
218
|
"aria-label": "Token cap",
|
|
219
219
|
className: v(
|
|
@@ -226,7 +226,7 @@ function re() {
|
|
|
226
226
|
),
|
|
227
227
|
o.rest.length > 0 && /* @__PURE__ */ t("ul", { role: "alert", className: "space-y-0.5 text-[11.5px] text-red-600 dark:text-red-400", children: o.rest.map((e) => /* @__PURE__ */ t("li", { children: e }, e)) }),
|
|
228
228
|
y != null && /* @__PURE__ */ t(C, { error: y, fallback: "Could not save" }),
|
|
229
|
-
/* @__PURE__ */
|
|
229
|
+
/* @__PURE__ */ h("div", { className: "flex justify-end gap-2 pt-1", children: [
|
|
230
230
|
/* @__PURE__ */ t(k, { variant: "ghost", size: "sm", className: "h-8", onClick: () => u(!1), children: "Cancel" }),
|
|
231
231
|
/* @__PURE__ */ t(
|
|
232
232
|
k,
|
|
@@ -234,7 +234,10 @@ function re() {
|
|
|
234
234
|
size: "sm",
|
|
235
235
|
className: "h-8",
|
|
236
236
|
disabled: a.isPending,
|
|
237
|
-
onClick: () =>
|
|
237
|
+
onClick: () => {
|
|
238
|
+
const { email_me: e, ...l } = s;
|
|
239
|
+
a.mutate(l);
|
|
240
|
+
},
|
|
238
241
|
children: a.isPending ? "Saving…" : "Save"
|
|
239
242
|
}
|
|
240
243
|
)
|