@nivaro/react 0.3.45 → 0.3.46
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 +42 -7
- package/dist/shared/components/BaseMap.js +149 -103
- package/dist/shared/components/command-center/CommandCenterView.js +313 -69
- package/dist/shared/components/command-center/Customize.js +353 -0
- package/dist/shared/components/command-center/Header.js +279 -53
- package/dist/shared/components/command-center/KioskLinks.js +198 -0
- package/dist/shared/components/command-center/PeekPanel.js +143 -3
- package/dist/shared/components/command-center/announce.js +13 -0
- package/dist/shared/components/command-center/board-prefs.js +99 -0
- package/dist/shared/components/command-center/freshness.js +29 -0
- package/dist/shared/components/command-center/layout.js +56 -0
- package/dist/shared/components/command-center/panels/AttentionPanel.js +132 -3
- package/dist/shared/components/command-center/panels/Banner.js +75 -0
- package/dist/shared/components/command-center/panels/BoardSettings.js +223 -0
- package/dist/shared/components/command-center/panels/FeedPanel.js +145 -29
- package/dist/shared/components/command-center/panels/FlowPanel.js +154 -56
- package/dist/shared/components/command-center/panels/ForecastPanel.js +244 -3
- package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
- package/dist/shared/components/command-center/panels/MapPanel.js +216 -66
- package/dist/shared/components/command-center/panels/PartnersPanel.js +49 -3
- package/dist/shared/components/command-center/panels/PeoplePanel.js +257 -40
- package/dist/shared/components/command-center/panels/RegionPicker.js +88 -3
- package/dist/shared/components/command-center/panels/SystemPanel.js +158 -38
- package/dist/shared/components/command-center/panels/ThroughputPanel.js +307 -3
- package/dist/shared/components/command-center/panels/TimeBar.js +227 -6
- package/dist/shared/components/command-center/panels/TrafficPanel.js +12 -8
- package/dist/shared/components/command-center/panels/WorkloadPanel.js +82 -3
- package/dist/shared/components/command-center/panels/attention-actions.js +267 -0
- package/dist/shared/components/command-center/panels/map-shared.js +95 -0
- package/dist/shared/components/command-center/panels/registry.js +87 -19
- package/dist/shared/components/command-center/shell-hooks.js +118 -0
- package/dist/shared/components/command-center/shortcuts.js +37 -0
- package/dist/shared/components/command-center/theme.js +39 -21
- package/dist/shared/components/command-center/time.js +52 -0
- package/dist/shared/components/command-center/url-state.js +54 -0
- package/dist/shared/components/command-center/work-links.js +32 -0
- package/dist/shared/components/monitoring/TrafficMiniMap.js +111 -70
- package/package.json +1 -1
|
@@ -1,10 +1,231 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { jsx as t, jsxs as r, Fragment as N } from "react/jsx-runtime";
|
|
2
|
+
import { useMutation as E } from "@tanstack/react-query";
|
|
3
|
+
import { useState as p, useEffect as g, useMemo as I } from "react";
|
|
4
|
+
import { useNivaroClient as U } from "../../../context.js";
|
|
5
|
+
import { post as _ } from "../../../lib/commands.js";
|
|
6
|
+
import { useArmedFaults as W } from "../../chaos/DrillBanner.js";
|
|
7
|
+
import { Popover as A, PopoverTrigger as O, PopoverContent as B } from "../../ui/popover.js";
|
|
8
|
+
import { useCc as L } from "../state.js";
|
|
9
|
+
import { MUTED as w, FOCUS as u, BUTTON as v, FAINT as $ } from "../theme.js";
|
|
10
|
+
import { usePortalVars as F, localDayStart as m, whenLabel as h, clockLabel as y } from "../time.js";
|
|
11
|
+
const C = 5 * 6e4, Y = 7, j = "border-[var(--cc-border)] bg-[var(--cc-panel)] text-[var(--cc-text)]";
|
|
12
|
+
function ne({ label: e = "Live only" }) {
|
|
13
|
+
return /* @__PURE__ */ t(
|
|
14
|
+
"span",
|
|
15
|
+
{
|
|
16
|
+
className: `inline-flex items-center rounded-full border border-[var(--cc-border)] px-1.5 py-px text-[10.5px] font-medium ${w}`,
|
|
17
|
+
"data-tip": "This shows what is happening now, even while the board is rewound.",
|
|
18
|
+
"data-cc-live-only": "",
|
|
19
|
+
children: e
|
|
20
|
+
}
|
|
21
|
+
);
|
|
3
22
|
}
|
|
4
|
-
function
|
|
5
|
-
|
|
23
|
+
function q(e) {
|
|
24
|
+
const c = [];
|
|
25
|
+
let n = m(e);
|
|
26
|
+
for (let l = 0; l <= Y; l++)
|
|
27
|
+
c.push(n), n = m(n - 36e5);
|
|
28
|
+
return c;
|
|
29
|
+
}
|
|
30
|
+
function S(e, c, n) {
|
|
31
|
+
const l = Math.min(m(c + 936e5) - 1, n - 6e4), o = Math.floor(e / C) * C;
|
|
32
|
+
return Math.max(c, Math.min(l, o));
|
|
33
|
+
}
|
|
34
|
+
function K(e, c) {
|
|
35
|
+
const n = m(c);
|
|
36
|
+
return e === n ? "Today" : e === m(n - 36e5) ? "Yesterday" : new Date(e).toLocaleDateString([], { weekday: "short", month: "short", day: "numeric" });
|
|
37
|
+
}
|
|
38
|
+
function ae() {
|
|
39
|
+
const e = L(), c = F(), [n, l] = p(!1), [o, f] = p(() => Date.now());
|
|
40
|
+
g(() => {
|
|
41
|
+
if (!n) return;
|
|
42
|
+
f(Date.now());
|
|
43
|
+
const a = setInterval(() => f(Date.now()), 3e4);
|
|
44
|
+
return () => clearInterval(a);
|
|
45
|
+
}, [n]);
|
|
46
|
+
const s = I(() => q(o), [o]), [i, b] = p(() => m(e.at ?? Date.now())), [d, x] = p(() => e.at ?? Date.now() - 30 * 6e4), [D, T] = p(!1), k = (a) => {
|
|
47
|
+
T(!0), x(a);
|
|
48
|
+
}, { at: M, setAt: P } = e;
|
|
49
|
+
g(() => {
|
|
50
|
+
n || T(!1);
|
|
51
|
+
}, [n]), g(() => {
|
|
52
|
+
if (!n || !D) return;
|
|
53
|
+
const a = setTimeout(() => {
|
|
54
|
+
d !== M && P(d);
|
|
55
|
+
}, 400);
|
|
56
|
+
return () => clearTimeout(a);
|
|
57
|
+
}, [d, n, D, M, P]);
|
|
58
|
+
const R = Math.min(m(i + 26 * 36e5) - 1, o - 6e4);
|
|
59
|
+
return e.at != null && !n ? /* @__PURE__ */ r(
|
|
60
|
+
"span",
|
|
61
|
+
{
|
|
62
|
+
className: "inline-flex items-center gap-1 rounded-full bg-amber-500/15 py-0.5 pl-2.5 pr-1 text-[12px] text-[var(--cc-text)]",
|
|
63
|
+
"data-cc-rewound": "",
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ r(
|
|
66
|
+
"button",
|
|
67
|
+
{
|
|
68
|
+
type: "button",
|
|
69
|
+
className: `rounded-full font-medium ${u}`,
|
|
70
|
+
onClick: () => {
|
|
71
|
+
b(m(e.at)), x(e.at), l(!0);
|
|
72
|
+
},
|
|
73
|
+
"aria-label": `Rewound to ${h(e.at)} — change`,
|
|
74
|
+
children: [
|
|
75
|
+
"Rewound to ",
|
|
76
|
+
h(e.at)
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ t(
|
|
81
|
+
"button",
|
|
82
|
+
{
|
|
83
|
+
type: "button",
|
|
84
|
+
className: `rounded-full bg-[var(--cc-panel)] px-2 py-0.5 text-[11.5px] font-medium text-[var(--cc-strong)] hover:bg-[var(--cc-chip-hover)] ${u}`,
|
|
85
|
+
onClick: () => e.setAt(null),
|
|
86
|
+
children: "Back to live"
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
) : /* @__PURE__ */ r(A, { open: n, onOpenChange: l, children: [
|
|
92
|
+
/* @__PURE__ */ t(O, { asChild: !0, children: /* @__PURE__ */ t(
|
|
93
|
+
"button",
|
|
94
|
+
{
|
|
95
|
+
type: "button",
|
|
96
|
+
className: `${v} ${u} inline-flex items-center gap-1.5`,
|
|
97
|
+
"aria-label": e.at ? `Rewound to ${h(e.at)}` : "Live — rewind the board",
|
|
98
|
+
children: e.at == null ? /* @__PURE__ */ r(N, { children: [
|
|
99
|
+
/* @__PURE__ */ t("span", { className: "h-1.5 w-1.5 rounded-full bg-[var(--cc-people)]", "aria-hidden": !0 }),
|
|
100
|
+
"Live",
|
|
101
|
+
/* @__PURE__ */ t("span", { className: $, children: "· Rewind" })
|
|
102
|
+
] }) : /* @__PURE__ */ r(N, { children: [
|
|
103
|
+
"Rewound to ",
|
|
104
|
+
h(e.at)
|
|
105
|
+
] })
|
|
106
|
+
}
|
|
107
|
+
) }),
|
|
108
|
+
/* @__PURE__ */ r(B, { align: "end", className: `w-[340px] p-3 ${j}`, style: c, children: [
|
|
109
|
+
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-[var(--cc-strong)]", children: "Rewind the board" }),
|
|
110
|
+
/* @__PURE__ */ t("p", { className: `mt-0.5 text-[11.5px] ${w}`, children: "Panels show what they showed then; a few can only show now and say so." }),
|
|
111
|
+
/* @__PURE__ */ t("fieldset", { className: "mt-2.5 flex flex-wrap gap-1", "aria-label": "Day", children: s.map((a) => /* @__PURE__ */ t(
|
|
112
|
+
"button",
|
|
113
|
+
{
|
|
114
|
+
type: "button",
|
|
115
|
+
"aria-pressed": i === a,
|
|
116
|
+
onClick: () => {
|
|
117
|
+
b(a), k(S(a === s[0] ? o - 30 * 6e4 : a + 12 * 36e5, a, o));
|
|
118
|
+
},
|
|
119
|
+
className: `rounded-full px-2 py-0.5 text-[11.5px] ${u} ${i === a ? "bg-nvr-cyan/15 font-medium text-[var(--cc-strong)]" : "bg-[var(--cc-chip)] hover:bg-[var(--cc-chip-hover)]"}`,
|
|
120
|
+
children: K(a, o)
|
|
121
|
+
},
|
|
122
|
+
a
|
|
123
|
+
)) }),
|
|
124
|
+
/* @__PURE__ */ r("label", { className: "mt-3 block text-[11.5px]", htmlFor: "cc-rewind-scrubber", children: [
|
|
125
|
+
/* @__PURE__ */ t("span", { className: w, children: "Time" }),
|
|
126
|
+
" ",
|
|
127
|
+
/* @__PURE__ */ t("b", { className: "tabular-nums text-[var(--cc-strong)]", children: y(d) })
|
|
128
|
+
] }),
|
|
129
|
+
/* @__PURE__ */ t(
|
|
130
|
+
"input",
|
|
131
|
+
{
|
|
132
|
+
id: "cc-rewind-scrubber",
|
|
133
|
+
type: "range",
|
|
134
|
+
min: i,
|
|
135
|
+
max: R,
|
|
136
|
+
step: C,
|
|
137
|
+
value: Math.max(i, Math.min(R, d)),
|
|
138
|
+
onChange: (a) => k(S(Number(a.target.value), i, o)),
|
|
139
|
+
className: `mt-1 w-full accent-[#0891b2] ${u}`,
|
|
140
|
+
"aria-valuetext": h(d, o)
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
/* @__PURE__ */ r("div", { className: `flex justify-between text-[10.5px] tabular-nums ${$}`, children: [
|
|
144
|
+
/* @__PURE__ */ t("span", { children: "12 AM" }),
|
|
145
|
+
/* @__PURE__ */ t("span", { children: i === s[0] ? "Now" : "11:59 PM" })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ r("div", { className: "mt-3 flex items-center justify-between gap-2", children: [
|
|
148
|
+
/* @__PURE__ */ t(
|
|
149
|
+
"button",
|
|
150
|
+
{
|
|
151
|
+
type: "button",
|
|
152
|
+
className: `${v} ${u}`,
|
|
153
|
+
onClick: () => {
|
|
154
|
+
e.setAt(null), l(!1);
|
|
155
|
+
},
|
|
156
|
+
children: "Back to live"
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
/* @__PURE__ */ r(
|
|
160
|
+
"button",
|
|
161
|
+
{
|
|
162
|
+
type: "button",
|
|
163
|
+
className: `rounded-md bg-nvr-cyan px-2.5 py-1 text-[11.5px] font-medium text-white ${u}`,
|
|
164
|
+
onClick: () => {
|
|
165
|
+
e.setAt(d), l(!1);
|
|
166
|
+
},
|
|
167
|
+
children: [
|
|
168
|
+
"Show ",
|
|
169
|
+
y(d)
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
] })
|
|
174
|
+
] })
|
|
175
|
+
] });
|
|
176
|
+
}
|
|
177
|
+
function re() {
|
|
178
|
+
const e = L(), c = U(), n = F(), { armed: l } = W(), [o, f] = p(!1), s = E({
|
|
179
|
+
mutationFn: (d) => c.request(
|
|
180
|
+
_("/command-center/brief", {
|
|
181
|
+
...e.region ? { region: e.region } : {},
|
|
182
|
+
...e.at ? { at: new Date(e.at).toISOString() } : {},
|
|
183
|
+
drill: l.length > 0,
|
|
184
|
+
fresh: d
|
|
185
|
+
})
|
|
186
|
+
).then((x) => x.data)
|
|
187
|
+
}), { mutate: i, reset: b } = s;
|
|
188
|
+
return g(() => {
|
|
189
|
+
o ? i(!1) : b();
|
|
190
|
+
}, [o, e.region, e.at]), e.kiosk ? null : /* @__PURE__ */ r(A, { open: o, onOpenChange: f, children: [
|
|
191
|
+
/* @__PURE__ */ t(O, { asChild: !0, children: /* @__PURE__ */ t("button", { type: "button", className: `${v} ${u}`, children: "What changed?" }) }),
|
|
192
|
+
/* @__PURE__ */ r(B, { align: "end", className: `w-[360px] p-3 ${j}`, style: n, children: [
|
|
193
|
+
/* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-2", children: [
|
|
194
|
+
/* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-[var(--cc-strong)]", children: e.at ? `The hour before ${y(e.at)}` : "The last hour" }),
|
|
195
|
+
/* @__PURE__ */ t(
|
|
196
|
+
"button",
|
|
197
|
+
{
|
|
198
|
+
type: "button",
|
|
199
|
+
className: `${v} ${u}`,
|
|
200
|
+
disabled: s.isPending,
|
|
201
|
+
onClick: () => i(!0),
|
|
202
|
+
children: "Refresh"
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
] }),
|
|
206
|
+
/* @__PURE__ */ t(
|
|
207
|
+
"div",
|
|
208
|
+
{
|
|
209
|
+
className: "mt-2 text-[12.5px] leading-relaxed",
|
|
210
|
+
"aria-live": "polite",
|
|
211
|
+
"aria-busy": s.isPending,
|
|
212
|
+
children: s.isPending ? /* @__PURE__ */ t("p", { className: w, children: "Putting it together…" }) : s.isError ? /* @__PURE__ */ t("p", { className: "text-[var(--cc-bad-text)]", children: "Could not put the summary together. Try Refresh." }) : s.data ? /* @__PURE__ */ r(N, { children: [
|
|
213
|
+
/* @__PURE__ */ t("p", { className: "whitespace-pre-line", children: s.data.text }),
|
|
214
|
+
/* @__PURE__ */ r("p", { className: `mt-2 text-[11px] ${$}`, children: [
|
|
215
|
+
"Written ",
|
|
216
|
+
y(new Date(s.data.generated_at).getTime()),
|
|
217
|
+
" from the figures on this board."
|
|
218
|
+
] })
|
|
219
|
+
] }) : null
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
] })
|
|
223
|
+
] });
|
|
6
224
|
}
|
|
7
225
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
226
|
+
re as BriefButton,
|
|
227
|
+
ne as LiveOnlyBadge,
|
|
228
|
+
ae as TimeBar,
|
|
229
|
+
S as clampRewind,
|
|
230
|
+
q as rewindDays
|
|
10
231
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { TrafficMiniMap as
|
|
3
|
-
import { useCc as
|
|
4
|
-
import { useAppIsDark as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsxs as n, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { TrafficMiniMap as o } from "../../monitoring/TrafficMiniMap.js";
|
|
3
|
+
import { useCc as c } from "../state.js";
|
|
4
|
+
import { useAppIsDark as m } from "../theme.js";
|
|
5
|
+
import { LiveOnlyBadge as s } from "./TimeBar.js";
|
|
6
|
+
function v() {
|
|
7
|
+
const { snapshot: r, tv: a, at: i, setAt: l } = c(), t = m();
|
|
8
|
+
return r != null && r.health ? /* @__PURE__ */ n("div", { className: "flex flex-col gap-1", "data-cc-panel": "traffic", children: [
|
|
9
|
+
i != null && /* @__PURE__ */ e("span", { className: "flex justify-end", children: /* @__PURE__ */ e(s, { label: "Traffic: live only" }) }),
|
|
10
|
+
/* @__PURE__ */ e(o, { tone: t || a ? "dark" : "auto", onPickTime: (f) => l(f) })
|
|
11
|
+
] }) : null;
|
|
8
12
|
}
|
|
9
13
|
export {
|
|
10
|
-
|
|
14
|
+
v as TrafficPanel
|
|
11
15
|
};
|
|
@@ -1,6 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { jsxs as t, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useCcQuery as d } from "../api.js";
|
|
3
|
+
import { useCc as m } from "../state.js";
|
|
4
|
+
import { PANEL as h, PANEL_HEAD as p, TITLE as x, FAINT as u, FOCUS as v } from "../theme.js";
|
|
5
|
+
const b = {
|
|
6
|
+
over: { word: "Over usual", tone: "text-[var(--cc-warn-text)]", bar: "bg-amber-500" },
|
|
7
|
+
normal: { word: "", tone: "text-[var(--cc-muted)]", bar: "bg-nvr-cyan" },
|
|
8
|
+
idle: { word: "Idle", tone: "text-[var(--cc-muted)]", bar: "bg-nvr-cyan" }
|
|
9
|
+
};
|
|
10
|
+
function g() {
|
|
11
|
+
const i = m(), r = d("/workload", void 0, {
|
|
12
|
+
refetchInterval: 12e4,
|
|
13
|
+
retry: !1
|
|
14
|
+
});
|
|
15
|
+
if (r.isError) return null;
|
|
16
|
+
const n = r.data ?? [];
|
|
17
|
+
if (!r.isLoading && n.length === 0) return null;
|
|
18
|
+
const o = Math.max(1, ...n.map((e) => Math.max(e.open, e.usual))), c = n.filter((e) => e.status === "over").length;
|
|
19
|
+
return /* @__PURE__ */ t("section", { className: h, "data-cc-panel": "workload", "aria-busy": r.isLoading, children: [
|
|
20
|
+
/* @__PURE__ */ t("div", { className: p, children: [
|
|
21
|
+
/* @__PURE__ */ a("h2", { className: x, children: "Workload" }),
|
|
22
|
+
/* @__PURE__ */ a("span", { className: `text-[11px] ${u}`, children: c > 0 ? `${c} over usual` : "open now · tick = usual" })
|
|
23
|
+
] }),
|
|
24
|
+
/* @__PURE__ */ a("ul", { className: "max-h-[320px] space-y-1.5 overflow-y-auto p-3", children: n.map((e) => {
|
|
25
|
+
const s = b[e.status], l = e.out ? s.word ? `Out · ${s.word}` : "Out" : s.word;
|
|
26
|
+
return /* @__PURE__ */ t("li", { className: "text-[11.5px]", children: [
|
|
27
|
+
/* @__PURE__ */ t("div", { className: "flex items-baseline gap-2", children: [
|
|
28
|
+
/* @__PURE__ */ a(
|
|
29
|
+
"button",
|
|
30
|
+
{
|
|
31
|
+
type: "button",
|
|
32
|
+
onClick: () => i.navigate(`/users/${encodeURIComponent(e.user_id)}`),
|
|
33
|
+
className: `min-w-0 flex-1 truncate rounded text-left text-[var(--cc-text)] hover:underline ${v}`,
|
|
34
|
+
children: e.name
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
l && /* @__PURE__ */ a("span", { className: `shrink-0 ${e.out ? "text-[var(--cc-muted)]" : s.tone}`, children: l }),
|
|
38
|
+
/* @__PURE__ */ t(
|
|
39
|
+
"span",
|
|
40
|
+
{
|
|
41
|
+
className: "w-[64px] shrink-0 text-right tabular-nums text-[var(--cc-text)]",
|
|
42
|
+
"data-tip": e.usual_source === "team" ? "Usual = the median across these people until their own history builds up" : "Usual = their median over the last 28 days",
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ a("b", { children: e.open }),
|
|
45
|
+
" ",
|
|
46
|
+
/* @__PURE__ */ t("span", { className: u, children: [
|
|
47
|
+
"/ ",
|
|
48
|
+
Math.round(e.usual)
|
|
49
|
+
] })
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
] }),
|
|
54
|
+
/* @__PURE__ */ t(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
className: "relative mt-0.5 h-1.5 rounded-full bg-[var(--cc-chip)]",
|
|
58
|
+
role: "img",
|
|
59
|
+
"aria-label": `${e.name}: ${e.open} open, usually ${Math.round(e.usual)}${l ? `, ${l}` : ""}`,
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ a(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: `h-full rounded-full ${s.bar} ${e.out ? "opacity-50" : ""}`,
|
|
65
|
+
style: { width: `${e.open / o * 100}%` }
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ a(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
className: "absolute top-[-2px] h-[10px] w-[2px] rounded bg-[var(--cc-strong)]",
|
|
72
|
+
style: { left: `calc(${e.usual / o * 100}% - 1px)` },
|
|
73
|
+
"aria-hidden": !0
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
] }, e.user_id);
|
|
80
|
+
}) })
|
|
81
|
+
] });
|
|
3
82
|
}
|
|
4
83
|
export {
|
|
5
|
-
|
|
84
|
+
g as WorkloadPanel
|
|
6
85
|
};
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { jsxs as s, jsx as e, Fragment as Y } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as M, useQueryClient as _ } from "@tanstack/react-query";
|
|
3
|
+
import { useState as u } from "react";
|
|
4
|
+
import { useNivaroClient as w } from "../../../context.js";
|
|
5
|
+
import { get as P, post as R } from "../../../lib/commands.js";
|
|
6
|
+
import { userErrorMessage as q } from "../../../lib/safe-error.js";
|
|
7
|
+
import { BUTTON as r, FOCUS as c, MUTED as g, FAINT as F } from "../theme.js";
|
|
8
|
+
const S = "w-full rounded-md border border-[var(--cc-border)] bg-[var(--cc-panel)] px-2 py-1 text-[12px] text-[var(--cc-text)] placeholder:text-[var(--cc-faint)]", T = "rounded-md bg-nvr-cyan px-2.5 py-1 text-[11.5px] font-medium text-white hover:opacity-90 disabled:opacity-50";
|
|
9
|
+
function U() {
|
|
10
|
+
const t = _();
|
|
11
|
+
return () => void t.invalidateQueries({ queryKey: ["command-center"] });
|
|
12
|
+
}
|
|
13
|
+
function N({ ok: t, text: i }) {
|
|
14
|
+
return /* @__PURE__ */ e(
|
|
15
|
+
"p",
|
|
16
|
+
{
|
|
17
|
+
role: "status",
|
|
18
|
+
className: `text-[11.5px] ${t ? "text-[var(--cc-good-text)]" : "text-[var(--cc-bad-text)]"}`,
|
|
19
|
+
children: i
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
function z({
|
|
24
|
+
target: t,
|
|
25
|
+
onDone: i
|
|
26
|
+
}) {
|
|
27
|
+
const f = w(), y = U(), [a, x] = u(""), [n, p] = u(!1), [l, h] = u(null), $ = async () => {
|
|
28
|
+
p(!0);
|
|
29
|
+
try {
|
|
30
|
+
const m = await f.request(
|
|
31
|
+
R("/command-center/nudge", {
|
|
32
|
+
collection: t.collection,
|
|
33
|
+
item: t.id,
|
|
34
|
+
...a.trim() ? { message: a.trim() } : {}
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
h({ ok: !0, text: `Nudged ${m.data.names.join(", ")}.` }), y();
|
|
38
|
+
} catch (m) {
|
|
39
|
+
h({ ok: !1, text: q(m, "Could not send the nudge") });
|
|
40
|
+
} finally {
|
|
41
|
+
p(!1);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return l != null && l.ok ? /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
45
|
+
/* @__PURE__ */ e(N, { ...l }),
|
|
46
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: i, className: `${r} ${c}`, children: "Close" })
|
|
47
|
+
] }) : /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
|
|
48
|
+
/* @__PURE__ */ s("label", { className: `block text-[11px] ${g}`, children: [
|
|
49
|
+
"Message to the owners (optional)",
|
|
50
|
+
/* @__PURE__ */ e(
|
|
51
|
+
"input",
|
|
52
|
+
{
|
|
53
|
+
className: `${S} mt-0.5 ${c}`,
|
|
54
|
+
value: a,
|
|
55
|
+
maxLength: 500,
|
|
56
|
+
onChange: (m) => x(m.target.value),
|
|
57
|
+
placeholder: "Can you take a look today?"
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
62
|
+
/* @__PURE__ */ e("button", { type: "button", disabled: n, onClick: $, className: `${T} ${c}`, children: n ? "Sending…" : "Send nudge" }),
|
|
63
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: i, className: `${r} ${c}`, children: "Cancel" })
|
|
64
|
+
] }),
|
|
65
|
+
l && /* @__PURE__ */ e(N, { ...l })
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
function G({
|
|
69
|
+
target: t,
|
|
70
|
+
onDone: i
|
|
71
|
+
}) {
|
|
72
|
+
const f = w(), y = U(), [a, x] = u(null), [n, p] = u(!1), [l, h] = u(null), $ = M({
|
|
73
|
+
queryKey: ["command-center", "attention-transitions", t.collection, t.id],
|
|
74
|
+
queryFn: () => f.request(
|
|
75
|
+
P(
|
|
76
|
+
`/pipelines/instance/${encodeURIComponent(t.collection)}/${encodeURIComponent(t.id)}`
|
|
77
|
+
)
|
|
78
|
+
).then((d) => {
|
|
79
|
+
var C;
|
|
80
|
+
return ((C = d.data) == null ? void 0 : C.available_transitions) ?? [];
|
|
81
|
+
}),
|
|
82
|
+
staleTime: 15e3
|
|
83
|
+
}), m = (d) => d.label || d.name || "Move on", b = async () => {
|
|
84
|
+
if (a) {
|
|
85
|
+
p(!0);
|
|
86
|
+
try {
|
|
87
|
+
await f.request(
|
|
88
|
+
R(
|
|
89
|
+
`/pipelines/instance/${encodeURIComponent(t.collection)}/${encodeURIComponent(t.id)}/transition`,
|
|
90
|
+
{ transition_id: a.id }
|
|
91
|
+
)
|
|
92
|
+
), h({ ok: !0, text: `Done: ${m(a)}.` }), y();
|
|
93
|
+
} catch (d) {
|
|
94
|
+
h({
|
|
95
|
+
ok: !1,
|
|
96
|
+
text: q(d, "Could not move the record — open it to finish this step")
|
|
97
|
+
});
|
|
98
|
+
} finally {
|
|
99
|
+
p(!1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
if (l != null && l.ok)
|
|
104
|
+
return /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
105
|
+
/* @__PURE__ */ e(N, { ...l }),
|
|
106
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: i, className: `${r} ${c}`, children: "Close" })
|
|
107
|
+
] });
|
|
108
|
+
if ($.isLoading) return /* @__PURE__ */ e("p", { className: `text-[11.5px] ${F}`, children: "Loading the next steps…" });
|
|
109
|
+
const v = $.data ?? [];
|
|
110
|
+
return v.length === 0 ? /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
111
|
+
/* @__PURE__ */ e("p", { className: `text-[11.5px] ${g}`, children: "There is no step you can take on this record from here." }),
|
|
112
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: i, className: `${r} ${c}`, children: "Close" })
|
|
113
|
+
] }) : /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
|
|
114
|
+
a ? /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
115
|
+
/* @__PURE__ */ s("span", { className: "text-[12px] text-[var(--cc-text)]", children: [
|
|
116
|
+
"Run ",
|
|
117
|
+
/* @__PURE__ */ e("b", { children: m(a) }),
|
|
118
|
+
" on this record?"
|
|
119
|
+
] }),
|
|
120
|
+
/* @__PURE__ */ e("button", { type: "button", disabled: n, onClick: b, className: `${T} ${c}`, children: n ? "Working…" : "Yes, run it" }),
|
|
121
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: () => x(null), className: `${r} ${c}`, children: "Back" })
|
|
122
|
+
] }) : /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
123
|
+
v.map((d) => /* @__PURE__ */ e(
|
|
124
|
+
"button",
|
|
125
|
+
{
|
|
126
|
+
type: "button",
|
|
127
|
+
onClick: () => x(d),
|
|
128
|
+
className: `${r} ${c}`,
|
|
129
|
+
children: m(d)
|
|
130
|
+
},
|
|
131
|
+
d.id
|
|
132
|
+
)),
|
|
133
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: i, className: `${r} ${c}`, children: "Cancel" })
|
|
134
|
+
] }),
|
|
135
|
+
l && /* @__PURE__ */ e(N, { ...l })
|
|
136
|
+
] });
|
|
137
|
+
}
|
|
138
|
+
function J({ approvalId: t, onDone: i }) {
|
|
139
|
+
const f = w(), y = U(), [a, x] = u(!1), [n, p] = u(null), l = async () => {
|
|
140
|
+
x(!0);
|
|
141
|
+
try {
|
|
142
|
+
await f.request(
|
|
143
|
+
R(`/approvals/instances/${t}/decide`, { decision: "approved" })
|
|
144
|
+
), p({ ok: !0, text: "Approved." }), y();
|
|
145
|
+
} catch (h) {
|
|
146
|
+
p({ ok: !1, text: q(h, "Could not approve") });
|
|
147
|
+
} finally {
|
|
148
|
+
x(!1);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
return /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
|
|
152
|
+
!(n != null && n.ok) && /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
153
|
+
/* @__PURE__ */ e("span", { className: "text-[12px] text-[var(--cc-text)]", children: "Approve this step?" }),
|
|
154
|
+
/* @__PURE__ */ e("button", { type: "button", disabled: a, onClick: l, className: `${T} ${c}`, children: a ? "Approving…" : "Yes, approve" }),
|
|
155
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: i, className: `${r} ${c}`, children: "Cancel" })
|
|
156
|
+
] }),
|
|
157
|
+
n && /* @__PURE__ */ e(N, { ...n }),
|
|
158
|
+
(n == null ? void 0 : n.ok) && /* @__PURE__ */ e("button", { type: "button", onClick: i, className: `${r} ${c}`, children: "Close" })
|
|
159
|
+
] });
|
|
160
|
+
}
|
|
161
|
+
const k = (t) => [t.first_name, t.last_name].filter(Boolean).join(" ") || t.email;
|
|
162
|
+
function V({
|
|
163
|
+
targets: t,
|
|
164
|
+
onDone: i
|
|
165
|
+
}) {
|
|
166
|
+
var I;
|
|
167
|
+
const f = w(), y = U(), [a, x] = u(""), [n, p] = u(null), [l, h] = u(!1), [$, m] = u(!1), [b, v] = u(null), d = M({
|
|
168
|
+
queryKey: ["command-center", "reassign-people", a],
|
|
169
|
+
queryFn: () => f.request(P("/users", { search: a, limit: 8 })).then((o) => o.data ?? []),
|
|
170
|
+
enabled: !n && a.trim().length >= 2,
|
|
171
|
+
staleTime: 3e4
|
|
172
|
+
}), C = async () => {
|
|
173
|
+
if (!n) return;
|
|
174
|
+
m(!0);
|
|
175
|
+
let o = 0;
|
|
176
|
+
const A = [];
|
|
177
|
+
for (const B of t)
|
|
178
|
+
try {
|
|
179
|
+
await f.request(
|
|
180
|
+
R(
|
|
181
|
+
`/pipelines/instance/${encodeURIComponent(B.collection)}/${encodeURIComponent(B.id)}/owners`,
|
|
182
|
+
{ user: n.id }
|
|
183
|
+
)
|
|
184
|
+
), o++;
|
|
185
|
+
} catch (j) {
|
|
186
|
+
A.push({ id: B.id, error: q(j, "Refused") });
|
|
187
|
+
}
|
|
188
|
+
v({ moved: o, failed: A }), m(!1), y();
|
|
189
|
+
};
|
|
190
|
+
return b ? /* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
191
|
+
/* @__PURE__ */ e(
|
|
192
|
+
N,
|
|
193
|
+
{
|
|
194
|
+
ok: b.failed.length === 0,
|
|
195
|
+
text: `${b.moved} of ${t.length} handed to ${n ? k(n) : "them"}.${b.failed.length ? ` ${b.failed.length} refused:` : ""}`
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
b.failed.length > 0 && /* @__PURE__ */ e("ul", { className: `max-h-24 overflow-y-auto text-[11px] ${g}`, children: b.failed.slice(0, 20).map((o) => /* @__PURE__ */ s("li", { children: [
|
|
199
|
+
"#",
|
|
200
|
+
o.id,
|
|
201
|
+
": ",
|
|
202
|
+
o.error
|
|
203
|
+
] }, o.id)) }),
|
|
204
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: i, className: `${r} ${c}`, children: "Close" })
|
|
205
|
+
] }) : /* @__PURE__ */ e("div", { className: "space-y-1.5", children: n ? l ? /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
206
|
+
/* @__PURE__ */ s("span", { className: "text-[12px] text-[var(--cc-text)]", children: [
|
|
207
|
+
k(n),
|
|
208
|
+
" becomes an owner of the current step on each record. Sure?"
|
|
209
|
+
] }),
|
|
210
|
+
/* @__PURE__ */ e("button", { type: "button", disabled: $, onClick: C, className: `${T} ${c}`, children: $ ? "Handing on…" : `Yes, hand on ${t.length}` }),
|
|
211
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: () => h(!1), className: `${r} ${c}`, children: "Back" })
|
|
212
|
+
] }) : /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
213
|
+
/* @__PURE__ */ s("span", { className: "text-[12px] text-[var(--cc-text)]", children: [
|
|
214
|
+
"Hand ",
|
|
215
|
+
t.length,
|
|
216
|
+
" record",
|
|
217
|
+
t.length === 1 ? "" : "s",
|
|
218
|
+
" to",
|
|
219
|
+
" ",
|
|
220
|
+
/* @__PURE__ */ e("b", { children: k(n) }),
|
|
221
|
+
"?"
|
|
222
|
+
] }),
|
|
223
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: () => h(!0), className: `${r} ${c}`, children: "Continue" }),
|
|
224
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: () => p(null), className: `${r} ${c}`, children: "Pick someone else" })
|
|
225
|
+
] }) : /* @__PURE__ */ s(Y, { children: [
|
|
226
|
+
/* @__PURE__ */ s("label", { className: `block text-[11px] ${g}`, children: [
|
|
227
|
+
"Hand ",
|
|
228
|
+
t.length,
|
|
229
|
+
" record",
|
|
230
|
+
t.length === 1 ? "" : "s",
|
|
231
|
+
" to",
|
|
232
|
+
/* @__PURE__ */ e(
|
|
233
|
+
"input",
|
|
234
|
+
{
|
|
235
|
+
className: `${S} mt-0.5 ${c}`,
|
|
236
|
+
value: a,
|
|
237
|
+
onChange: (o) => x(o.target.value),
|
|
238
|
+
placeholder: "Type a name",
|
|
239
|
+
"aria-autocomplete": "list"
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
] }),
|
|
243
|
+
a.trim().length >= 2 && /* @__PURE__ */ s("ul", { className: "space-y-0.5", "aria-label": "People", children: [
|
|
244
|
+
(d.data ?? []).map((o) => /* @__PURE__ */ e("li", { children: /* @__PURE__ */ s(
|
|
245
|
+
"button",
|
|
246
|
+
{
|
|
247
|
+
type: "button",
|
|
248
|
+
onClick: () => p(o),
|
|
249
|
+
className: `w-full rounded px-1.5 py-0.5 text-left text-[12px] text-[var(--cc-text)] hover:bg-[var(--cc-chip)] ${c}`,
|
|
250
|
+
children: [
|
|
251
|
+
k(o),
|
|
252
|
+
" ",
|
|
253
|
+
/* @__PURE__ */ e("span", { className: F, children: o.email })
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
) }, o.id)),
|
|
257
|
+
((I = d.data) == null ? void 0 : I.length) === 0 && /* @__PURE__ */ e("li", { className: `text-[11.5px] ${F}`, children: "Nobody found." })
|
|
258
|
+
] }),
|
|
259
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: i, className: `${r} ${c}`, children: "Cancel" })
|
|
260
|
+
] }) });
|
|
261
|
+
}
|
|
262
|
+
export {
|
|
263
|
+
J as ApproveForm,
|
|
264
|
+
z as NudgeForm,
|
|
265
|
+
V as ReassignForm,
|
|
266
|
+
G as TransitionForm
|
|
267
|
+
};
|