@nivaro/react 0.3.146 → 0.3.148
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 +28 -0
- package/dist/index.js +767 -764
- package/dist/shared/components/AnnouncementBanner.js +91 -42
- package/dist/shared/components/hub-switcher/HubSwitcher.js +101 -0
- package/dist/shared/components/item-edit/PlanGrid.js +989 -953
- package/dist/shared/components/ops-report/DigestSections.js +119 -112
- package/dist/shared/components/panels/PipelinePanel.js +71 -71
- package/dist/shared/lib/error-hints.js +8 -1
- package/dist/shared/lib/error-message.js +73 -66
- package/package.json +1 -1
|
@@ -1,90 +1,139 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useOptionalNivaroClient as
|
|
5
|
-
import { get as
|
|
6
|
-
import { useLiveAvailable as
|
|
7
|
-
function
|
|
8
|
-
const t =
|
|
1
|
+
import { jsxs as u, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as y, useQuery as w } from "@tanstack/react-query";
|
|
3
|
+
import { useState as N, useRef as q, useEffect as S } from "react";
|
|
4
|
+
import { useOptionalNivaroClient as Q, useNavigation as D } from "../context.js";
|
|
5
|
+
import { get as K, post as A } from "../lib/commands.js";
|
|
6
|
+
import { useLiveAvailable as j, useLiveEvent as C } from "../lib/live.js";
|
|
7
|
+
function b(n) {
|
|
8
|
+
const t = n.help_video;
|
|
9
9
|
return t && typeof t.path == "string" ? { path: t.path, title: String(t.title ?? "") } : null;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
11
|
+
function k(n) {
|
|
12
|
+
const t = n.maintenance;
|
|
13
|
+
return t && t.strict === !0 ? t : null;
|
|
14
|
+
}
|
|
15
|
+
function M(n) {
|
|
16
|
+
if (!n) return null;
|
|
17
|
+
const t = new Date(n);
|
|
18
|
+
return Number.isNaN(t.getTime()) ? null : `Expected back around ${t.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" })}.`;
|
|
19
|
+
}
|
|
20
|
+
function O({ row: n, fallback: t }) {
|
|
21
|
+
var o;
|
|
22
|
+
const m = M(n.until), d = q(null);
|
|
23
|
+
return S(() => {
|
|
24
|
+
var a;
|
|
25
|
+
(a = d.current) == null || a.focus({ preventScroll: !0 });
|
|
26
|
+
}, []), /* @__PURE__ */ r(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
role: "alertdialog",
|
|
30
|
+
"aria-modal": "true",
|
|
31
|
+
"aria-labelledby": "nvr-strict-maintenance-title",
|
|
32
|
+
"data-strict-maintenance": !0,
|
|
33
|
+
onKeyDown: (a) => {
|
|
34
|
+
var c;
|
|
35
|
+
a.key === "Tab" && (a.preventDefault(), (c = d.current) == null || c.focus({ preventScroll: !0 }));
|
|
36
|
+
},
|
|
37
|
+
className: "fixed inset-0 z-[150] flex items-center justify-center bg-slate-50 p-6 dark:bg-background",
|
|
38
|
+
children: /* @__PURE__ */ u("div", { className: "w-full max-w-[520px] rounded-xl border border-slate-200 bg-white p-6 shadow-sm dark:border-border dark:bg-card", children: [
|
|
39
|
+
/* @__PURE__ */ r("p", { className: "text-[11px] font-semibold uppercase tracking-wide text-amber-600 dark:text-amber-400", children: "Maintenance" }),
|
|
40
|
+
/* @__PURE__ */ r(
|
|
41
|
+
"h1",
|
|
42
|
+
{
|
|
43
|
+
ref: d,
|
|
44
|
+
id: "nvr-strict-maintenance-title",
|
|
45
|
+
tabIndex: -1,
|
|
46
|
+
className: "mt-2 rounded text-[16px] font-semibold text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:text-foreground",
|
|
47
|
+
children: ((o = n.headline) == null ? void 0 : o.trim()) || t
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
n.explainer && /* @__PURE__ */ r("p", { className: "mt-2 text-[13px] leading-relaxed text-slate-600 dark:text-muted-foreground", children: n.explainer }),
|
|
51
|
+
m && /* @__PURE__ */ r("p", { className: "mt-2 text-[12.5px] text-slate-500 dark:text-muted-foreground", children: m }),
|
|
52
|
+
/* @__PURE__ */ r("p", { className: "mt-4 text-[12px] text-slate-400 dark:text-muted-foreground", children: "This page goes away by itself when the app is back." })
|
|
53
|
+
] })
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
function P() {
|
|
58
|
+
const n = Q(), t = y(), m = D().helpVideosPath ?? "/help-videos", d = j(), [o, a] = N(() => /* @__PURE__ */ new Set()), { data: c = [] } = w(
|
|
13
59
|
{
|
|
14
60
|
queryKey: ["announcements-active"],
|
|
15
|
-
queryFn: () =>
|
|
16
|
-
|
|
61
|
+
queryFn: () => n.request(
|
|
62
|
+
K("/announcements/active")
|
|
17
63
|
).then((e) => e.data ?? []).catch(() => []),
|
|
18
|
-
enabled: !!
|
|
64
|
+
enabled: !!n,
|
|
19
65
|
// The socket says when something changed; the poll still catches a window that simply
|
|
20
66
|
// elapsed (ends_at passing sends nothing) and a socket that is down.
|
|
21
|
-
refetchInterval:
|
|
67
|
+
refetchInterval: d ? 3e5 : 6e4
|
|
22
68
|
}
|
|
23
69
|
);
|
|
24
|
-
|
|
70
|
+
C(
|
|
25
71
|
"announcements:changed",
|
|
26
72
|
() => void t.invalidateQueries({ queryKey: ["announcements-active"] }),
|
|
27
|
-
{ debounceMs: 300, includeOwn: !0, enabled: !!
|
|
73
|
+
{ debounceMs: 300, includeOwn: !0, enabled: !!n }
|
|
28
74
|
);
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
75
|
+
const x = o.size > 0 ? c.filter((e) => !o.has(e.id)) : c;
|
|
76
|
+
if (x.length === 0) return null;
|
|
77
|
+
const s = x.filter((e) => e.require_ack), l = x.find((e) => k(e)), f = l ? k(l) : null, v = x.filter(
|
|
78
|
+
(e) => !e.require_ack && e !== l
|
|
79
|
+
), h = (e) => {
|
|
80
|
+
a((i) => new Set(i).add(e));
|
|
81
|
+
const g = () => t.setQueryData(
|
|
34
82
|
["announcements-active"],
|
|
35
|
-
(
|
|
83
|
+
(i) => i == null ? void 0 : i.filter((p) => p.id !== e)
|
|
36
84
|
);
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
return
|
|
85
|
+
g(), t.cancelQueries({ queryKey: ["announcements-active"] }).then(g), n == null || n.request(A(`/announcements/${e}/ack`, {})).then(() => t.invalidateQueries({ queryKey: ["announcements-active"] })).catch(() => (a((i) => {
|
|
86
|
+
const p = new Set(i);
|
|
87
|
+
return p.delete(e), p;
|
|
40
88
|
}), t.invalidateQueries({ queryKey: ["announcements-active"] })));
|
|
41
89
|
};
|
|
42
|
-
return /* @__PURE__ */
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/* @__PURE__ */
|
|
46
|
-
|
|
47
|
-
|
|
90
|
+
return /* @__PURE__ */ u("div", { "data-announcements": !0, "data-nvr-recording-hide": !0, className: "shrink-0", children: [
|
|
91
|
+
f && l && /* @__PURE__ */ r(O, { row: f, fallback: l.message }),
|
|
92
|
+
s.length > 0 && /* @__PURE__ */ r("div", { className: "fixed inset-0 z-[140] flex items-center justify-center bg-black/50 p-6", children: /* @__PURE__ */ u("div", { className: "w-full max-w-[520px] rounded-xl border border-slate-200 bg-white p-6 shadow-2xl dark:border-border dark:bg-card", children: [
|
|
93
|
+
/* @__PURE__ */ r("p", { className: "text-[11px] font-semibold uppercase tracking-wide text-amber-600 dark:text-amber-400", children: "Acknowledgement required" }),
|
|
94
|
+
/* @__PURE__ */ r("p", { className: "mt-2 whitespace-pre-wrap text-[14px] leading-relaxed text-slate-800 dark:text-foreground", children: s[0].message }),
|
|
95
|
+
s.length > 1 && /* @__PURE__ */ u("p", { className: "mt-2 text-[11.5px] text-slate-400", children: [
|
|
96
|
+
s.length - 1,
|
|
48
97
|
" more notice",
|
|
49
|
-
|
|
98
|
+
s.length > 2 ? "s" : "",
|
|
50
99
|
" after this one."
|
|
51
100
|
] }),
|
|
52
|
-
/* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ r(
|
|
53
102
|
"button",
|
|
54
103
|
{
|
|
55
104
|
type: "button",
|
|
56
|
-
onClick: () =>
|
|
105
|
+
onClick: () => h(s[0].id),
|
|
57
106
|
className: "mt-4 h-9 w-full rounded-md bg-nvr-cyan text-[13px] font-semibold text-white",
|
|
58
107
|
children: "I acknowledge"
|
|
59
108
|
}
|
|
60
109
|
)
|
|
61
110
|
] }) }),
|
|
62
|
-
|
|
111
|
+
v.map((e) => /* @__PURE__ */ u(
|
|
63
112
|
"div",
|
|
64
113
|
{
|
|
65
114
|
className: e.severity === "critical" ? "flex items-center gap-3 border-b border-red-200 bg-red-50 px-4 py-2 dark:border-red-500/30 dark:bg-red-500/10" : e.severity === "warn" ? "flex items-center gap-3 border-b border-amber-200 bg-amber-50 px-4 py-2 dark:border-amber-500/30 dark:bg-amber-400/10" : "flex items-center gap-3 border-b border-sky-200 bg-sky-50 px-4 py-2 dark:border-sky-500/30 dark:bg-sky-500/10",
|
|
66
115
|
children: [
|
|
67
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ r(
|
|
68
117
|
"span",
|
|
69
118
|
{
|
|
70
119
|
className: e.severity === "critical" ? "min-w-0 flex-1 text-[12.5px] text-red-800 dark:text-red-300" : e.severity === "warn" ? "min-w-0 flex-1 text-[12.5px] text-amber-800 dark:text-amber-300" : "min-w-0 flex-1 text-[12.5px] text-sky-800 dark:text-sky-300",
|
|
71
120
|
children: e.message
|
|
72
121
|
}
|
|
73
122
|
),
|
|
74
|
-
|
|
123
|
+
b(e) && /* @__PURE__ */ r(
|
|
75
124
|
"a",
|
|
76
125
|
{
|
|
77
|
-
href: `${
|
|
126
|
+
href: `${m}${b(e).path.replace(/^\/help-videos/, "")}`,
|
|
78
127
|
className: "shrink-0 text-[11.5px] font-medium text-slate-700 underline decoration-dotted underline-offset-2 hover:text-slate-900 dark:text-foreground",
|
|
79
|
-
"data-announcement-video":
|
|
128
|
+
"data-announcement-video": b(e).path,
|
|
80
129
|
children: "Watch the video"
|
|
81
130
|
}
|
|
82
131
|
),
|
|
83
|
-
e.dismissable !== !1 && /* @__PURE__ */
|
|
132
|
+
e.dismissable !== !1 && /* @__PURE__ */ r(
|
|
84
133
|
"button",
|
|
85
134
|
{
|
|
86
135
|
type: "button",
|
|
87
|
-
onClick: () =>
|
|
136
|
+
onClick: () => h(e.id),
|
|
88
137
|
className: "shrink-0 text-[11.5px] font-medium text-slate-500 underline decoration-dotted underline-offset-2 hover:text-slate-700 dark:text-muted-foreground",
|
|
89
138
|
children: "Dismiss"
|
|
90
139
|
}
|
|
@@ -96,5 +145,5 @@ function _() {
|
|
|
96
145
|
] });
|
|
97
146
|
}
|
|
98
147
|
export {
|
|
99
|
-
|
|
148
|
+
P as AnnouncementBanner
|
|
100
149
|
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as t, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as b } from "@tanstack/react-query";
|
|
3
|
+
import { LayoutGrid as g } from "lucide-react";
|
|
4
|
+
import { useApiFetchConfig as k } from "../../context.js";
|
|
5
|
+
import { cn as o } from "../../lib/utils.js";
|
|
6
|
+
import { useOverflowTip as v } from "../TipLayer.js";
|
|
7
|
+
import { Popover as y, PopoverTrigger as N, PopoverContent as _ } from "../ui/popover.js";
|
|
8
|
+
function f({ name: a, className: r }) {
|
|
9
|
+
const s = v(a);
|
|
10
|
+
return /* @__PURE__ */ t("span", { ref: s, className: o("truncate", r), children: a });
|
|
11
|
+
}
|
|
12
|
+
function x(a) {
|
|
13
|
+
try {
|
|
14
|
+
const r = new URL(a);
|
|
15
|
+
return r.protocol === "https:" ? !0 : r.protocol === "http:" && (r.hostname === "localhost" || r.hostname === "127.0.0.1" || r.hostname === "[::1]");
|
|
16
|
+
} catch {
|
|
17
|
+
return !1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const w = { apps: [], unavailable: !1 };
|
|
21
|
+
function T({
|
|
22
|
+
apps: a,
|
|
23
|
+
unavailable: r,
|
|
24
|
+
variant: s = "header",
|
|
25
|
+
defaultOpen: l,
|
|
26
|
+
className: c
|
|
27
|
+
}) {
|
|
28
|
+
return !a.some((e) => !e.current && x(e.signin_url)) && !r ? null : /* @__PURE__ */ i(y, { defaultOpen: l, children: [
|
|
29
|
+
/* @__PURE__ */ t(N, { asChild: !0, children: /* @__PURE__ */ t(
|
|
30
|
+
"button",
|
|
31
|
+
{
|
|
32
|
+
type: "button",
|
|
33
|
+
"aria-label": "Your apps",
|
|
34
|
+
"data-tip": "Your apps",
|
|
35
|
+
className: o(
|
|
36
|
+
"inline-flex shrink-0 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
|
|
37
|
+
s === "rail" ? "h-8 w-8 text-slate-400 hover:bg-white/[0.05] hover:text-white" : "h-9 w-9 border border-slate-200 bg-white text-slate-500 shadow-sm hover:bg-slate-50 hover:text-slate-800 dark:border-border dark:bg-card dark:text-slate-300 dark:hover:bg-muted dark:hover:text-foreground",
|
|
38
|
+
c
|
|
39
|
+
),
|
|
40
|
+
children: /* @__PURE__ */ t(g, { className: "h-4 w-4" })
|
|
41
|
+
}
|
|
42
|
+
) }),
|
|
43
|
+
/* @__PURE__ */ i(
|
|
44
|
+
_,
|
|
45
|
+
{
|
|
46
|
+
side: s === "rail" ? "right" : "bottom",
|
|
47
|
+
align: "end",
|
|
48
|
+
className: "w-[min(18rem,calc(100vw-2rem))] p-1.5",
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ t("div", { className: "px-2 pb-1 pt-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Your apps" }),
|
|
51
|
+
r && /* @__PURE__ */ t("p", { className: "px-2 py-2 text-[13px] text-slate-600 dark:text-slate-300", children: "The app list is not available right now. Try again in a few minutes." }),
|
|
52
|
+
/* @__PURE__ */ t("ul", { className: "m-0 list-none p-0", children: a.map((e) => {
|
|
53
|
+
const n = e.environment_key && e.environment_key !== "production" ? /* @__PURE__ */ t("span", { className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-600 dark:bg-white/[0.08] dark:text-slate-300", children: e.environment_key }) : null, p = "flex items-center justify-between gap-2 rounded-md px-2 py-2 text-[13px] text-slate-800 dark:text-slate-100";
|
|
54
|
+
return e.current ? /* @__PURE__ */ t("li", { children: /* @__PURE__ */ i("div", { className: o(p, "bg-slate-50 dark:bg-white/[0.06]"), "aria-current": "true", children: [
|
|
55
|
+
/* @__PURE__ */ t(f, { name: e.app_name, className: "font-medium" }),
|
|
56
|
+
/* @__PURE__ */ i("span", { className: "flex shrink-0 items-center gap-2", children: [
|
|
57
|
+
/* @__PURE__ */ t("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "You are here" }),
|
|
58
|
+
n
|
|
59
|
+
] })
|
|
60
|
+
] }) }, `${e.app_key}:${e.environment_key}`) : x(e.signin_url) ? /* @__PURE__ */ t("li", { children: /* @__PURE__ */ i(
|
|
61
|
+
"a",
|
|
62
|
+
{
|
|
63
|
+
href: e.signin_url,
|
|
64
|
+
target: "_blank",
|
|
65
|
+
rel: "noopener noreferrer",
|
|
66
|
+
className: o(p, "hover:bg-slate-100 dark:hover:bg-white/[0.06]"),
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ t(f, { name: e.app_name }),
|
|
69
|
+
n
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
) }, `${e.app_key}:${e.environment_key}`) : null;
|
|
73
|
+
}) })
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
function L({
|
|
80
|
+
variant: a = "header",
|
|
81
|
+
className: r
|
|
82
|
+
}) {
|
|
83
|
+
const { apiBase: s, authHeaders: l, credentials: c } = k(), { data: u } = b({
|
|
84
|
+
queryKey: ["hub-switcher"],
|
|
85
|
+
staleTime: 5 * 6e4,
|
|
86
|
+
retry: !1,
|
|
87
|
+
queryFn: async () => {
|
|
88
|
+
var h, d, m;
|
|
89
|
+
const e = await fetch(`${s}/hub-switcher`, { credentials: c, headers: l });
|
|
90
|
+
if (!e.ok) return w;
|
|
91
|
+
const n = await e.json().catch(() => null);
|
|
92
|
+
return { apps: Array.isArray((h = n == null ? void 0 : n.data) == null ? void 0 : h.apps) ? (d = n == null ? void 0 : n.data) == null ? void 0 : d.apps : [], unavailable: ((m = n == null ? void 0 : n.data) == null ? void 0 : m.unavailable) === !0 };
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return /* @__PURE__ */ t(T, { ...u ?? w, variant: a, className: r });
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
L as HubSwitcher,
|
|
99
|
+
T as HubSwitcherView,
|
|
100
|
+
x as isSafeSwitcherLink
|
|
101
|
+
};
|