@nivaro/react 0.3.44 → 0.3.45
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/index.d.ts +38 -5
- package/dist/shared/components/CollectionBrowserView.js +1390 -1358
- package/dist/shared/components/DataTable.js +356 -334
- package/dist/shared/components/ProfileView.js +16 -21
- package/dist/shared/components/command-center/CommandCenterView.js +90 -355
- package/dist/shared/components/command-center/Header.js +70 -0
- package/dist/shared/components/command-center/PeekPanel.js +6 -0
- package/dist/shared/components/command-center/api.js +26 -0
- package/dist/shared/components/command-center/panels/AttentionPanel.js +6 -0
- package/dist/shared/components/command-center/panels/FeedPanel.js +33 -0
- package/dist/shared/components/command-center/panels/FlowPanel.js +61 -0
- package/dist/shared/components/command-center/panels/ForecastPanel.js +6 -0
- package/dist/shared/components/command-center/panels/MapPanel.js +74 -0
- package/dist/shared/components/command-center/panels/PartnersPanel.js +6 -0
- package/dist/shared/components/command-center/panels/PeoplePanel.js +47 -0
- package/dist/shared/components/command-center/panels/RegionPicker.js +6 -0
- package/dist/shared/components/command-center/panels/SystemPanel.js +53 -0
- package/dist/shared/components/command-center/panels/ThroughputPanel.js +6 -0
- package/dist/shared/components/command-center/panels/TimeBar.js +10 -0
- package/dist/shared/components/command-center/panels/TrafficPanel.js +11 -0
- package/dist/shared/components/command-center/panels/WorkloadPanel.js +6 -0
- package/dist/shared/components/command-center/panels/registry.js +28 -0
- package/dist/shared/components/command-center/state.js +12 -0
- package/dist/shared/components/command-center/theme.js +66 -0
- package/dist/shared/components/imports/ImportConsole.js +48 -47
- package/dist/shared/components/notifications/TestMyRules.js +39 -38
- package/dist/shared/components/profile/TeamsConnect.js +2 -2
- package/dist/shared/components/queue/QueueQuickFilters.js +81 -63
- package/dist/shared/components/queue/QueueWorklist.js +598 -586
- package/dist/shared/lib/quick-filter-cascade.js +29 -0
- package/package.json +1 -1
|
@@ -6,9 +6,9 @@ import { useNivaroClient as $e, useItemEditAuth as je, useNavigation as He, useI
|
|
|
6
6
|
import { useDebounced as We } from "../../hooks/useDebounced.js";
|
|
7
7
|
import { get as M, post as xe } from "../../lib/commands.js";
|
|
8
8
|
import { useLiveEvent as Ge } from "../../lib/live.js";
|
|
9
|
-
import { formatNumber as
|
|
9
|
+
import { formatNumber as N, cn as D, formatRelative as Ye, formatDateTime as Ze } from "../../lib/utils.js";
|
|
10
10
|
import { DataTable as Xe } from "../DataTable.js";
|
|
11
|
-
import { Button as
|
|
11
|
+
import { Button as k } from "../ui/button.js";
|
|
12
12
|
import { DropdownMenu as Je, DropdownMenuTrigger as et, DropdownMenuContent as tt, DropdownMenuItem as O } from "../ui/dropdown-menu.js";
|
|
13
13
|
import { CollectionImportPanel as rt } from "./CollectionImportPanel.js";
|
|
14
14
|
import { DefinitionHealthPanel as at } from "./DefinitionHealthPanel.js";
|
|
@@ -44,13 +44,13 @@ function ve({
|
|
|
44
44
|
count: i,
|
|
45
45
|
status: l,
|
|
46
46
|
active: m,
|
|
47
|
-
onClick:
|
|
47
|
+
onClick: w
|
|
48
48
|
}) {
|
|
49
49
|
return /* @__PURE__ */ a(
|
|
50
50
|
"button",
|
|
51
51
|
{
|
|
52
52
|
type: "button",
|
|
53
|
-
onClick:
|
|
53
|
+
onClick: w,
|
|
54
54
|
"aria-pressed": m,
|
|
55
55
|
className: D(
|
|
56
56
|
"flex items-center gap-1.5 px-3 py-2 text-left transition-colors hover:bg-slate-50 dark:hover:bg-muted/40",
|
|
@@ -59,7 +59,7 @@ function ve({
|
|
|
59
59
|
),
|
|
60
60
|
children: [
|
|
61
61
|
l && /* @__PURE__ */ t("span", { className: D("h-1.5 w-1.5 shrink-0 rounded-full", ke[l].dot) }),
|
|
62
|
-
/* @__PURE__ */ t("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: i == null ? "—" :
|
|
62
|
+
/* @__PURE__ */ t("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: i == null ? "—" : N(i) }),
|
|
63
63
|
/* @__PURE__ */ t("span", { className: "text-[11px] font-medium leading-none text-slate-400 dark:text-muted-foreground", children: o })
|
|
64
64
|
]
|
|
65
65
|
}
|
|
@@ -70,8 +70,8 @@ function xt({
|
|
|
70
70
|
queuedCount: i,
|
|
71
71
|
stage: l,
|
|
72
72
|
standing: m,
|
|
73
|
-
canManage:
|
|
74
|
-
onOpen:
|
|
73
|
+
canManage: w,
|
|
74
|
+
onOpen: _,
|
|
75
75
|
onCancel: I
|
|
76
76
|
}) {
|
|
77
77
|
const d = o.status === "running", p = lt(o.started_at ?? o.created_at, d);
|
|
@@ -81,7 +81,7 @@ function xt({
|
|
|
81
81
|
"button",
|
|
82
82
|
{
|
|
83
83
|
type: "button",
|
|
84
|
-
onClick:
|
|
84
|
+
onClick: _,
|
|
85
85
|
className: "font-mono text-[12px] font-medium text-slate-900 underline-offset-2 hover:underline dark:text-foreground",
|
|
86
86
|
children: o.import_key
|
|
87
87
|
}
|
|
@@ -93,7 +93,7 @@ function xt({
|
|
|
93
93
|
l && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: l }),
|
|
94
94
|
!d && m && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: m }),
|
|
95
95
|
o.row_count != null && /* @__PURE__ */ a("span", { className: "text-[12px] tabular-nums text-slate-500 dark:text-muted-foreground", children: [
|
|
96
|
-
|
|
96
|
+
N(o.row_count),
|
|
97
97
|
" rows"
|
|
98
98
|
] }),
|
|
99
99
|
i > 0 && /* @__PURE__ */ a("span", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
|
|
@@ -101,7 +101,7 @@ function xt({
|
|
|
101
101
|
i,
|
|
102
102
|
" more queued"
|
|
103
103
|
] }),
|
|
104
|
-
|
|
104
|
+
w && /* @__PURE__ */ a(k, { variant: "ghost", size: "sm", className: "ml-auto h-7 px-2", onClick: I, children: [
|
|
105
105
|
/* @__PURE__ */ t(ye, { className: "h-3.5 w-3.5" }),
|
|
106
106
|
"Stop"
|
|
107
107
|
] })
|
|
@@ -112,15 +112,15 @@ function Qt({
|
|
|
112
112
|
defaultTab: i = "runs",
|
|
113
113
|
initialJobId: l,
|
|
114
114
|
onJobOpen: m,
|
|
115
|
-
initialRunId:
|
|
116
|
-
onRunOpen:
|
|
115
|
+
initialRunId: w = null,
|
|
116
|
+
onRunOpen: _,
|
|
117
117
|
initialDefinitionKey: I = null
|
|
118
118
|
}) {
|
|
119
119
|
var ie, le, de, ce;
|
|
120
|
-
const d = $e(), p = Pe(), { isAdmin: s } = je(), j = He(), { open: we } = Ve(), _e = !!j.itemUrl || !!j.openItem, [b, H] = c(() => l ? "collection" : I && s ? "definitions" : i !== "runs" && !s ? "runs" : i), [h, R] = c("all"), [x, K] = c(""), [V, W] = c(""), [P, G] = c(1), [g, Y] = c("30"), [
|
|
121
|
-
Ce(e),
|
|
122
|
-
}, [Se, Q] = c(!1), [Z, A] = c(null), [X, qe] = c({}),
|
|
123
|
-
pe(() => G(1), [h, x,
|
|
120
|
+
const d = $e(), p = Pe(), { isAdmin: s } = je(), j = He(), { open: we } = Ve(), _e = !!j.itemUrl || !!j.openItem, [b, H] = c(() => l ? "collection" : I && s ? "definitions" : i !== "runs" && !s ? "runs" : i), [h, R] = c("all"), [x, K] = c(""), [V, W] = c(""), [P, G] = c(1), [g, Y] = c("30"), [C, Ce] = c(w), S = (e) => {
|
|
121
|
+
Ce(e), _ == null || _(e);
|
|
122
|
+
}, [Se, Q] = c(!1), [Z, A] = c(null), [X, qe] = c({}), q = We(V, 300);
|
|
123
|
+
pe(() => G(1), [h, x, q, g]);
|
|
124
124
|
const T = L({
|
|
125
125
|
queryKey: ["staged-import-definitions"],
|
|
126
126
|
queryFn: () => d.request(
|
|
@@ -135,8 +135,8 @@ function Qt({
|
|
|
135
135
|
), J = L({
|
|
136
136
|
queryKey: ["staged-import-stats", g],
|
|
137
137
|
queryFn: () => d.request(M("/staged-imports/stats", { days: g }))
|
|
138
|
-
}), r = (le = J.data) == null ? void 0 : le.data, De = ((r == null ? void 0 : r.active.length) ?? 0) > 0 ? ge : mt,
|
|
139
|
-
queryKey: ["staged-import-runs", h, x,
|
|
138
|
+
}), r = (le = J.data) == null ? void 0 : le.data, De = ((r == null ? void 0 : r.active.length) ?? 0) > 0 ? ge : mt, v = L({
|
|
139
|
+
queryKey: ["staged-import-runs", h, x, q, P, g],
|
|
140
140
|
queryFn: () => d.request(
|
|
141
141
|
M("/staged-imports", {
|
|
142
142
|
page: P,
|
|
@@ -144,23 +144,23 @@ function Qt({
|
|
|
144
144
|
days: g,
|
|
145
145
|
...h === "all" ? {} : { status: h },
|
|
146
146
|
...x ? { key: x } : {},
|
|
147
|
-
...
|
|
147
|
+
...q.trim() ? { search: q.trim() } : {}
|
|
148
148
|
})
|
|
149
149
|
),
|
|
150
150
|
refetchInterval: De,
|
|
151
151
|
// Refetching must not blank the table out from under someone reading it.
|
|
152
152
|
placeholderData: (e) => e
|
|
153
|
-
}), ee = ((de =
|
|
154
|
-
function
|
|
153
|
+
}), ee = ((de = v.data) == null ? void 0 : de.data) ?? [];
|
|
154
|
+
function y() {
|
|
155
155
|
p.invalidateQueries({ queryKey: ["staged-import-runs"] }), p.invalidateQueries({ queryKey: ["staged-import-stats"] }), p.invalidateQueries({ queryKey: ["collection-import-jobs"] });
|
|
156
156
|
}
|
|
157
|
-
const te = Ue(
|
|
158
|
-
te.current =
|
|
157
|
+
const te = Ue(y);
|
|
158
|
+
te.current = y, pe(() => {
|
|
159
159
|
if (o)
|
|
160
160
|
return o.subscribe((e) => {
|
|
161
161
|
qe((n) => ({
|
|
162
162
|
...n,
|
|
163
|
-
[e.id]: e.stage === "row_count" ? `${
|
|
163
|
+
[e.id]: e.stage === "row_count" ? `${N(e.row_count ?? 0)} rows read` : e.stage === "preparing" ? "Preparing the staging table" : e.stage === "importing" ? "Importing the rows" : e.stage === "completed" ? "Completed" : typeof e.error == "string" && e.error ? e.error : "Failed"
|
|
164
164
|
})), te.current();
|
|
165
165
|
});
|
|
166
166
|
}, [o]);
|
|
@@ -184,13 +184,13 @@ function Qt({
|
|
|
184
184
|
const oe = ue({
|
|
185
185
|
mutationFn: (e) => d.request(xe(`/staged-imports/${e}/requeue`)),
|
|
186
186
|
onSuccess: () => {
|
|
187
|
-
A(null),
|
|
187
|
+
A(null), y();
|
|
188
188
|
},
|
|
189
189
|
onError: (e) => A(e.message)
|
|
190
190
|
}), B = ue({
|
|
191
191
|
mutationFn: (e) => d.request(xe(`/staged-imports/${e}/cancel`)),
|
|
192
192
|
onSuccess: () => {
|
|
193
|
-
A(null),
|
|
193
|
+
A(null), y();
|
|
194
194
|
},
|
|
195
195
|
onError: (e) => A(e.message)
|
|
196
196
|
}), Ee = [
|
|
@@ -232,7 +232,7 @@ function Qt({
|
|
|
232
232
|
header: "Rows",
|
|
233
233
|
className: "w-[90px] text-right",
|
|
234
234
|
headerClassName: "text-right",
|
|
235
|
-
render: (e) => /* @__PURE__ */ t("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-700 dark:text-foreground", children: e.row_count == null ? "—" :
|
|
235
|
+
render: (e) => /* @__PURE__ */ t("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-700 dark:text-foreground", children: e.row_count == null ? "—" : N(e.row_count) })
|
|
236
236
|
},
|
|
237
237
|
{
|
|
238
238
|
key: "duration",
|
|
@@ -288,7 +288,7 @@ function Qt({
|
|
|
288
288
|
}
|
|
289
289
|
) }),
|
|
290
290
|
/* @__PURE__ */ a(tt, { align: "end", className: "text-[12.5px]", children: [
|
|
291
|
-
/* @__PURE__ */ a(O, { onSelect: () =>
|
|
291
|
+
/* @__PURE__ */ a(O, { onSelect: () => S(e.id), children: [
|
|
292
292
|
/* @__PURE__ */ t(ze, { className: "h-3.5 w-3.5" }),
|
|
293
293
|
" View details"
|
|
294
294
|
] }),
|
|
@@ -317,7 +317,7 @@ function Qt({
|
|
|
317
317
|
] })
|
|
318
318
|
] }) })
|
|
319
319
|
}
|
|
320
|
-
], z = h !== "all" || !!x || !!
|
|
320
|
+
], z = h !== "all" || !!x || !!q.trim(), se = ((r == null ? void 0 : r.all_time_total) ?? 0) === 0 && !J.isLoading, Le = !z && !se && ((r == null ? void 0 : r.total) ?? 0) === 0 && g !== "0", Me = C != null ? ee.find((e) => e.id === C) : void 0;
|
|
321
321
|
return /* @__PURE__ */ a("div", { className: "flex min-h-0 flex-1 flex-col gap-3", children: [
|
|
322
322
|
/* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
323
323
|
/* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: ["runs", "collection", "definitions"].filter((e) => e === "runs" || s).map((e) => /* @__PURE__ */ t(
|
|
@@ -335,26 +335,26 @@ function Qt({
|
|
|
335
335
|
)) }),
|
|
336
336
|
/* @__PURE__ */ a("div", { className: "ml-auto flex items-center gap-2", children: [
|
|
337
337
|
/* @__PURE__ */ t(
|
|
338
|
-
|
|
338
|
+
k,
|
|
339
339
|
{
|
|
340
340
|
variant: "ghost",
|
|
341
341
|
size: "sm",
|
|
342
342
|
className: "h-7 px-2",
|
|
343
|
-
onClick:
|
|
343
|
+
onClick: y,
|
|
344
344
|
"aria-label": "Refresh",
|
|
345
345
|
children: /* @__PURE__ */ t(
|
|
346
346
|
Qe,
|
|
347
347
|
{
|
|
348
348
|
className: D(
|
|
349
349
|
"h-3.5 w-3.5",
|
|
350
|
-
b === "runs" &&
|
|
350
|
+
b === "runs" && v.isFetching && "motion-safe:animate-spin"
|
|
351
351
|
)
|
|
352
352
|
}
|
|
353
353
|
)
|
|
354
354
|
}
|
|
355
355
|
),
|
|
356
356
|
s && b === "runs" && /* @__PURE__ */ t(ot, { definitions: f.filter((e) => e.is_active) }),
|
|
357
|
-
s && b === "runs" && /* @__PURE__ */ a(
|
|
357
|
+
s && b === "runs" && /* @__PURE__ */ a(k, { size: "sm", className: "h-7", onClick: () => Q(!0), children: [
|
|
358
358
|
/* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" }),
|
|
359
359
|
"New import"
|
|
360
360
|
] })
|
|
@@ -381,7 +381,7 @@ function Qt({
|
|
|
381
381
|
stage: X[u.id] ?? null,
|
|
382
382
|
standing: fe(F.get(u.id)),
|
|
383
383
|
canManage: s,
|
|
384
|
-
onOpen: () =>
|
|
384
|
+
onOpen: () => S(u.id),
|
|
385
385
|
onCancel: () => B.mutate(u.id)
|
|
386
386
|
}
|
|
387
387
|
),
|
|
@@ -427,7 +427,7 @@ function Qt({
|
|
|
427
427
|
U,
|
|
428
428
|
{
|
|
429
429
|
label: "Rows imported",
|
|
430
|
-
value: r ?
|
|
430
|
+
value: r ? N(r.rows_imported) : "—"
|
|
431
431
|
}
|
|
432
432
|
),
|
|
433
433
|
/* @__PURE__ */ t(
|
|
@@ -458,16 +458,16 @@ function Qt({
|
|
|
458
458
|
/* @__PURE__ */ t("h3", { className: "mt-3 text-[15px] font-semibold text-slate-900 dark:text-foreground", children: "No imports have run yet" }),
|
|
459
459
|
/* @__PURE__ */ t("p", { className: "mt-1.5 text-[12.5px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: "An import reads a file and brings its rows into the records it is defined for. Runs are queued here and picked up by the worker within a few seconds. Runs that share a staging table go one at a time; others run side by side." }),
|
|
460
460
|
s && /* @__PURE__ */ a("div", { className: "mt-4 flex items-center gap-2", children: [
|
|
461
|
-
/* @__PURE__ */ a(
|
|
461
|
+
/* @__PURE__ */ a(k, { size: "sm", onClick: () => Q(!0), children: [
|
|
462
462
|
/* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" }),
|
|
463
463
|
" Queue an import"
|
|
464
464
|
] }),
|
|
465
|
-
f.length === 0 && /* @__PURE__ */ t(
|
|
465
|
+
f.length === 0 && /* @__PURE__ */ t(k, { variant: "ghost", size: "sm", onClick: () => H("definitions"), children: "Define one first" })
|
|
466
466
|
] })
|
|
467
467
|
] }) }) : /* @__PURE__ */ a("div", { className: "flex min-h-0 flex-1 flex-col gap-2", children: [
|
|
468
468
|
Le && /* @__PURE__ */ a("p", { className: "flex flex-wrap items-center gap-2 rounded-md border border-slate-200 bg-white px-3 py-2 text-[12px] text-slate-600 dark:border-border dark:bg-card dark:text-muted-foreground", children: [
|
|
469
469
|
"Nothing ran in this window. All ",
|
|
470
|
-
|
|
470
|
+
N((r == null ? void 0 : r.all_time_total) ?? 0),
|
|
471
471
|
" runs on record are older than it.",
|
|
472
472
|
/* @__PURE__ */ t(
|
|
473
473
|
"button",
|
|
@@ -485,13 +485,14 @@ function Qt({
|
|
|
485
485
|
columns: Ee,
|
|
486
486
|
rows: ee,
|
|
487
487
|
rowKey: (e) => String(e.id),
|
|
488
|
-
total: ((ce =
|
|
488
|
+
total: ((ce = v.data) == null ? void 0 : ce.total) ?? 0,
|
|
489
489
|
page: P,
|
|
490
490
|
limit: be,
|
|
491
491
|
onPageChange: G,
|
|
492
|
-
isLoading:
|
|
493
|
-
isError:
|
|
492
|
+
isLoading: v.isLoading,
|
|
493
|
+
isError: v.isError,
|
|
494
494
|
errorMessage: "Those runs could not be loaded.",
|
|
495
|
+
onRetry: () => void v.refetch(),
|
|
495
496
|
searchValue: V,
|
|
496
497
|
onSearchChange: W,
|
|
497
498
|
searchPlaceholder: "Search imports, files, run ids…",
|
|
@@ -507,13 +508,13 @@ function Qt({
|
|
|
507
508
|
],
|
|
508
509
|
filterValues: { key: x },
|
|
509
510
|
onFilterChange: (e, n) => K(Array.isArray(n) ? n[0] ?? "" : n),
|
|
510
|
-
onRowClick: (e) =>
|
|
511
|
+
onRowClick: (e) => S(e.id),
|
|
511
512
|
nowrapCells: !0,
|
|
512
513
|
minBodyHeight: 280,
|
|
513
514
|
emptyMessage: z ? "No runs match these filters." : "No runs in this window — widen it above.",
|
|
514
515
|
rowClassName: (e) => e.status === "running" ? "bg-nvr-cyan/5 dark:bg-nvr-cyan/10" : void 0,
|
|
515
516
|
toolbarRight: z ? /* @__PURE__ */ t(
|
|
516
|
-
|
|
517
|
+
k,
|
|
517
518
|
{
|
|
518
519
|
variant: "ghost",
|
|
519
520
|
size: "sm",
|
|
@@ -532,10 +533,10 @@ function Qt({
|
|
|
532
533
|
it,
|
|
533
534
|
{
|
|
534
535
|
run: Me,
|
|
535
|
-
runId:
|
|
536
|
-
stage:
|
|
536
|
+
runId: C,
|
|
537
|
+
stage: C != null ? X[C] ?? null : null,
|
|
537
538
|
isAdmin: s,
|
|
538
|
-
onClose: () =>
|
|
539
|
+
onClose: () => S(null),
|
|
539
540
|
onRequeue: (e) => oe.mutate(e),
|
|
540
541
|
onCancel: (e) => B.mutate(e)
|
|
541
542
|
}
|
|
@@ -548,7 +549,7 @@ function Qt({
|
|
|
548
549
|
definitions: f.filter((e) => e.is_active),
|
|
549
550
|
runCounts: re,
|
|
550
551
|
onQueued: (e) => {
|
|
551
|
-
|
|
552
|
+
y(), S(e);
|
|
552
553
|
}
|
|
553
554
|
}
|
|
554
555
|
)
|
|
@@ -1,60 +1,61 @@
|
|
|
1
1
|
import { jsxs as r, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { useMutation as
|
|
2
|
+
import { useMutation as w } from "@tanstack/react-query";
|
|
3
3
|
import { FlaskConical as N } from "lucide-react";
|
|
4
4
|
import { useState as x } from "react";
|
|
5
5
|
import { useNivaroClient as v } from "../../context.js";
|
|
6
|
-
import { post as
|
|
7
|
-
import { cn as
|
|
8
|
-
import { Popover as
|
|
6
|
+
import { post as T } from "../../lib/commands.js";
|
|
7
|
+
import { cn as C } from "../../lib/utils.js";
|
|
8
|
+
import { Popover as S, PopoverTrigger as _, PopoverContent as E } from "../ui/popover.js";
|
|
9
9
|
import { SimpleSelectXs as f } from "../ui/SimpleSelect.js";
|
|
10
|
-
import { NOTIFY_RULE_CATS as
|
|
11
|
-
import { WHY_LAYER_LABELS as
|
|
12
|
-
const
|
|
10
|
+
import { NOTIFY_RULE_CATS as A } from "./NotificationRulesEditor.js";
|
|
11
|
+
import { WHY_LAYER_LABELS as L } from "./why-lines.js";
|
|
12
|
+
const P = [
|
|
13
13
|
{ value: "now", label: "Right now" },
|
|
14
14
|
{ value: "night", label: "Tonight at 11 PM" }
|
|
15
15
|
];
|
|
16
|
-
function
|
|
17
|
-
const
|
|
16
|
+
function D(d = /* @__PURE__ */ new Date()) {
|
|
17
|
+
const m = new Intl.DateTimeFormat("en-CA", {
|
|
18
18
|
timeZone: "America/New_York",
|
|
19
19
|
year: "numeric",
|
|
20
20
|
month: "2-digit",
|
|
21
21
|
day: "2-digit"
|
|
22
22
|
}).format(d);
|
|
23
|
-
for (const
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
23
|
+
for (const l of [4, 5]) {
|
|
24
|
+
const n = /* @__PURE__ */ new Date(`${m}T23:00:00Z`);
|
|
25
|
+
if (n.setUTCHours(n.getUTCHours() + l), new Intl.DateTimeFormat("en-US", {
|
|
26
26
|
timeZone: "America/New_York",
|
|
27
27
|
hour: "2-digit",
|
|
28
28
|
hour12: !1
|
|
29
|
-
}).format(
|
|
29
|
+
}).format(n) === "23") return n.toISOString();
|
|
30
30
|
}
|
|
31
31
|
return d.toISOString();
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function $({ category: d = "workflow" }) {
|
|
34
34
|
var c;
|
|
35
|
-
const
|
|
36
|
-
mutationFn: () =>
|
|
37
|
-
|
|
35
|
+
const m = v(), [l, n] = x(d), [u, g] = x("now"), i = w({
|
|
36
|
+
mutationFn: () => m.request(
|
|
37
|
+
T("/notifications/test-my-rules", {
|
|
38
38
|
category: l,
|
|
39
39
|
email: !0,
|
|
40
|
-
...
|
|
40
|
+
...u === "night" ? { at: D() } : {}
|
|
41
41
|
})
|
|
42
42
|
).then((t) => t.data)
|
|
43
|
-
}), e = i.data,
|
|
44
|
-
return /* @__PURE__ */ r(
|
|
43
|
+
}), e = i.data, b = (t) => e ? t === "email" ? e.decision.email === "send" ? "Emailed now" : e.decision.email === "deferred" ? "Daily summary" : e.decision.email === "no_address" ? "No address on file" : "No email" : t === "push" && e.decision.push && e.push_subscriptions === 0 ? "Allowed, but no device registered" : e.decision[t] ? "Yes" : "No" : null, y = (t) => (e == null ? void 0 : e.decision.reasons.find((o) => o.channel === t)) ?? (e == null ? void 0 : e.decision.reasons.find((o) => o.channel === "all")), k = !!(e != null && e.decision.reasons.some((t) => t.channel === "teams"));
|
|
44
|
+
return /* @__PURE__ */ r(S, { children: [
|
|
45
45
|
/* @__PURE__ */ a(_, { asChild: !0, children: /* @__PURE__ */ r(
|
|
46
46
|
"button",
|
|
47
47
|
{
|
|
48
48
|
type: "button",
|
|
49
49
|
"data-test-my-rules": !0,
|
|
50
|
-
|
|
50
|
+
"data-tip": "See what would happen to a notification for you right now, and which rule decides it",
|
|
51
|
+
className: "inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md border border-slate-200 px-2 text-[11.5px] font-medium text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:border-border dark:text-muted-foreground dark:hover:text-foreground",
|
|
51
52
|
children: [
|
|
52
53
|
/* @__PURE__ */ a(N, { className: "h-3.5 w-3.5" }),
|
|
53
54
|
"Test my rules"
|
|
54
55
|
]
|
|
55
56
|
}
|
|
56
57
|
) }),
|
|
57
|
-
/* @__PURE__ */ r(
|
|
58
|
+
/* @__PURE__ */ r(E, { align: "start", className: "w-[380px] p-3 text-[12px]", children: [
|
|
58
59
|
/* @__PURE__ */ a("p", { className: "font-semibold text-slate-800 dark:text-slate-100", children: "Test my rules" }),
|
|
59
60
|
/* @__PURE__ */ a("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-muted-foreground", children: "What would happen to a notification for you, and which rule decides each channel. Nothing is sent." }),
|
|
60
61
|
/* @__PURE__ */ r("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: [
|
|
@@ -63,17 +64,17 @@ function Z() {
|
|
|
63
64
|
{
|
|
64
65
|
ariaLabel: "Category to test",
|
|
65
66
|
value: l,
|
|
66
|
-
options:
|
|
67
|
-
onChange: (t) =>
|
|
67
|
+
options: A.map((t) => ({ value: t.key, label: t.label })),
|
|
68
|
+
onChange: (t) => n(t)
|
|
68
69
|
}
|
|
69
70
|
),
|
|
70
71
|
/* @__PURE__ */ a(
|
|
71
72
|
f,
|
|
72
73
|
{
|
|
73
74
|
ariaLabel: "When",
|
|
74
|
-
value:
|
|
75
|
-
options:
|
|
76
|
-
onChange: (t) =>
|
|
75
|
+
value: u,
|
|
76
|
+
options: P,
|
|
77
|
+
onChange: (t) => g(t)
|
|
77
78
|
}
|
|
78
79
|
),
|
|
79
80
|
/* @__PURE__ */ a(
|
|
@@ -92,29 +93,29 @@ function Z() {
|
|
|
92
93
|
e.decision.dropped ? /* @__PURE__ */ r("p", { className: "rounded border border-red-200 bg-red-50 px-2 py-1 text-red-800 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300", children: [
|
|
93
94
|
"Nothing would be delivered — ",
|
|
94
95
|
(c = e.decision.reasons[0]) == null ? void 0 : c.text
|
|
95
|
-
] }) : /* @__PURE__ */ a("ul", { className: "divide-y divide-slate-100 rounded border border-slate-100 dark:divide-border/60 dark:border-border/60", children: ["inapp", "push", "email", ...
|
|
96
|
+
] }) : /* @__PURE__ */ a("ul", { className: "divide-y divide-slate-100 rounded border border-slate-100 dark:divide-border/60 dark:border-border/60", children: ["inapp", "push", "email", ...k ? ["teams"] : []].map(
|
|
96
97
|
(t) => {
|
|
97
98
|
var p, h;
|
|
98
|
-
const o =
|
|
99
|
+
const o = y(t), s = (o == null ? void 0 : o.layer) ?? ((p = e.layers) == null ? void 0 : p[t]);
|
|
99
100
|
return /* @__PURE__ */ r("li", { className: "px-2 py-1", "data-test-channel": t, children: [
|
|
100
101
|
/* @__PURE__ */ r("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: [
|
|
101
102
|
t === "inapp" ? "In-app" : t === "push" ? "Push" : t === "email" ? "Email" : "Teams",
|
|
102
103
|
":"
|
|
103
104
|
] }),
|
|
104
105
|
" ",
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
b(t),
|
|
107
|
+
s && /* @__PURE__ */ r(
|
|
107
108
|
"span",
|
|
108
109
|
{
|
|
109
|
-
className:
|
|
110
|
+
className: C(
|
|
110
111
|
"ml-1 rounded px-1 text-[10px]",
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
s === "person" && "bg-sky-50 text-sky-700 dark:bg-sky-500/15 dark:text-sky-300",
|
|
113
|
+
s === "role" && "bg-violet-50 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300",
|
|
114
|
+
s === "system" && "bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-400"
|
|
114
115
|
),
|
|
115
116
|
children: [
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
L[s],
|
|
118
|
+
s === "role" && ((h = e.role) != null && h.name) ? ` · ${e.role.name}` : ""
|
|
118
119
|
]
|
|
119
120
|
}
|
|
120
121
|
),
|
|
@@ -133,5 +134,5 @@ function Z() {
|
|
|
133
134
|
] });
|
|
134
135
|
}
|
|
135
136
|
export {
|
|
136
|
-
|
|
137
|
+
$ as TestMyRules
|
|
137
138
|
};
|
|
@@ -17,7 +17,7 @@ function P({ linked: a, linkedAt: r }) {
|
|
|
17
17
|
/* @__PURE__ */ t(
|
|
18
18
|
"span",
|
|
19
19
|
{
|
|
20
|
-
className: "inline-flex
|
|
20
|
+
className: "inline-flex items-center justify-center gap-1 whitespace-nowrap text-[10.5px] font-normal normal-case tracking-normal text-emerald-700 dark:text-emerald-400",
|
|
21
21
|
"data-teams-connected": "",
|
|
22
22
|
title: r ? `Connected ${new Date(r).toLocaleString()}` : void 0,
|
|
23
23
|
children: [
|
|
@@ -52,7 +52,7 @@ function P({ linked: a, linkedAt: r }) {
|
|
|
52
52
|
{
|
|
53
53
|
type: "button",
|
|
54
54
|
"data-teams-connect": "",
|
|
55
|
-
className: "rounded border border-slate-200 px-1.5 py-0.5 text-[10.5px] font-medium normal-case tracking-normal text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:border-border dark:text-muted-foreground dark:hover:text-foreground",
|
|
55
|
+
className: "whitespace-nowrap rounded border border-slate-200 px-1.5 py-0.5 text-[10.5px] font-medium normal-case tracking-normal text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:border-border dark:text-muted-foreground dark:hover:text-foreground",
|
|
56
56
|
children: "Connect Teams"
|
|
57
57
|
}
|
|
58
58
|
) }),
|