@nivaro/react 0.3.118 → 0.3.120
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/CopyValueButton.js +61 -0
- package/dist/shared/components/GridPresenceLine.js +46 -36
- package/dist/shared/components/ItemEditForm.js +2435 -2395
- package/dist/shared/components/ProfileView.js +181 -175
- package/dist/shared/components/RecordReadView.js +590 -557
- package/dist/shared/components/UserAvatar.js +11 -11
- package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +6 -4
- package/dist/shared/components/item-edit/FieldComments.js +45 -43
- package/dist/shared/components/item-edit/HeaderBand.js +50 -50
- package/dist/shared/components/item-edit/HeaderTools.js +237 -142
- package/dist/shared/components/item-edit/RecordHelpChip.js +10 -10
- package/dist/shared/components/item-edit/UserChip.js +52 -47
- package/dist/shared/components/item-edit/addendum-view.js +6 -0
- package/dist/shared/components/layout-editor/pickers/field-picker.js +118 -105
- package/dist/shared/components/profile/PersonAccess.js +84 -94
- package/dist/shared/components/profile/primitives.js +2 -1
- package/dist/shared/components/support/SupportEmailSwitch.js +63 -0
- package/dist/shared/components/support/SupportView.js +51 -45
- package/dist/shared/lib/header-strip.js +125 -120
- package/package.json +1 -1
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { jsxs as n, jsx as t, Fragment as
|
|
1
|
+
import { jsxs as n, jsx as t, Fragment as I } from "react/jsx-runtime";
|
|
2
2
|
import { useQuery as E, useMutation as j, useQueryClient as oe } from "@tanstack/react-query";
|
|
3
|
-
import { Undo2 as _e, Loader2 as le, Check as ye, ShieldCheck as qe, ShieldAlert as ve, SlidersHorizontal as Re, RefreshCw as ae, BookUser as Ae, LogOut as ke, MonitorSmartphone as Le, EyeOff as Te, Eye as De,
|
|
3
|
+
import { Undo2 as _e, Loader2 as le, Check as ye, ShieldCheck as qe, ShieldAlert as ve, SlidersHorizontal as Re, RefreshCw as ae, BookUser as Ae, LogOut as ke, MonitorSmartphone as Le, EyeOff as Te, Eye as De, Trash2 as Fe, KeyRound as Ke, Smartphone as Pe, Monitor as Ee } from "lucide-react";
|
|
4
4
|
import { useMemo as de, useState as P, useRef as X, useEffect as pe } from "react";
|
|
5
|
-
import { toast as
|
|
5
|
+
import { toast as K } from "sonner";
|
|
6
6
|
import { useNivaroClient as Q } from "../../context.js";
|
|
7
|
-
import { get as O, patch as
|
|
7
|
+
import { get as O, patch as Oe, put as Qe, post as G, del as Ne } from "../../lib/commands.js";
|
|
8
8
|
import { toastError as se } from "../../lib/error-toast.js";
|
|
9
|
-
import { useLiveOps as
|
|
10
|
-
import { useLivePreference as
|
|
11
|
-
import { formatRelative as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
9
|
+
import { useLiveOps as Me, useFreshIds as Ue } from "../../lib/live-ops.js";
|
|
10
|
+
import { useLivePreference as je } from "../../lib/live-preference.js";
|
|
11
|
+
import { formatRelative as Be, cn as T, formatNumber as M, formatDateTime as Ie } from "../../lib/utils.js";
|
|
12
|
+
import { CopyValueButton as ze } from "../CopyValueButton.js";
|
|
13
|
+
import { ErrorNotice as Ge } from "../ErrorNotice.js";
|
|
14
|
+
import { useOverflowTip as He } from "../TipLayer.js";
|
|
14
15
|
import { SimpleSelect as re } from "../ui/SimpleSelect.js";
|
|
15
16
|
import { Skeleton as he } from "../ui/skeleton.js";
|
|
16
|
-
import { SectionCard as
|
|
17
|
+
import { SectionCard as V, EmptyLine as we, ConfirmButton as H } from "./primitives.js";
|
|
17
18
|
import { useInvalidatePerson as ce, errorText as J } from "./types.js";
|
|
18
19
|
const Je = [
|
|
19
20
|
{ value: "", label: "Person" },
|
|
@@ -22,7 +23,7 @@ const Je = [
|
|
|
22
23
|
{ value: "bot", label: "Bot" },
|
|
23
24
|
{ value: "placeholder", label: "Placeholder — kept so old references resolve" }
|
|
24
25
|
];
|
|
25
|
-
function
|
|
26
|
+
function St({ profile: e }) {
|
|
26
27
|
const r = Q(), s = ce(e.id), { data: i = [] } = E({
|
|
27
28
|
queryKey: ["nvr-roles"],
|
|
28
29
|
queryFn: () => r.request(
|
|
@@ -41,22 +42,22 @@ function wt({ profile: e }) {
|
|
|
41
42
|
[e]
|
|
42
43
|
), [h, b] = P(null), d = h ?? l, $ = JSON.stringify(d) !== JSON.stringify(l), c = j({
|
|
43
44
|
mutationFn: () => r.request(
|
|
44
|
-
|
|
45
|
+
Oe(`/users/${e.id}`, {
|
|
45
46
|
role: d.role || null,
|
|
46
47
|
status: d.status,
|
|
47
48
|
account_kind: d.account_kind || null
|
|
48
49
|
})
|
|
49
50
|
),
|
|
50
51
|
onSuccess: () => {
|
|
51
|
-
b(null), s(),
|
|
52
|
+
b(null), s(), K.success("Access saved");
|
|
52
53
|
},
|
|
53
|
-
onError: (u) =>
|
|
54
|
+
onError: (u) => K.error(J(u, "Could not save access"))
|
|
54
55
|
}), f = [
|
|
55
56
|
{ value: "", label: "No role" },
|
|
56
57
|
...i.map((u) => ({ value: u.id, label: u.admin_access ? `${u.name} · admin` : u.name }))
|
|
57
58
|
];
|
|
58
59
|
return /* @__PURE__ */ t(
|
|
59
|
-
|
|
60
|
+
V,
|
|
60
61
|
{
|
|
61
62
|
icon: /* @__PURE__ */ t(qe, { className: "h-4 w-4" }),
|
|
62
63
|
title: "Access",
|
|
@@ -140,7 +141,7 @@ function wt({ profile: e }) {
|
|
|
140
141
|
}
|
|
141
142
|
);
|
|
142
143
|
}
|
|
143
|
-
const
|
|
144
|
+
const Ve = {
|
|
144
145
|
directory: "Directory sync",
|
|
145
146
|
retention: "Retention policy",
|
|
146
147
|
offboarding: "Offboarding",
|
|
@@ -149,7 +150,7 @@ const Ye = {
|
|
|
149
150
|
"legacy-redaction": "Legacy redaction job",
|
|
150
151
|
unknown: "Unknown"
|
|
151
152
|
};
|
|
152
|
-
function
|
|
153
|
+
function $t({ profile: e }) {
|
|
153
154
|
var l;
|
|
154
155
|
const r = Q(), s = e.status === "suspended" || !!((l = e.admin) != null && l.is_redacted), { data: i } = E({
|
|
155
156
|
queryKey: ["nvr-user-suspension", e.id],
|
|
@@ -165,7 +166,7 @@ function St({ profile: e }) {
|
|
|
165
166
|
children: [
|
|
166
167
|
/* @__PURE__ */ n("p", { className: "font-medium", children: [
|
|
167
168
|
"Cannot sign in — ",
|
|
168
|
-
|
|
169
|
+
Ve[i.source] ?? i.source,
|
|
169
170
|
i.at ? ` · ${new Date(i.at).toLocaleString()}` : "",
|
|
170
171
|
i.by ? ` · by ${i.by.name}` : ""
|
|
171
172
|
] }),
|
|
@@ -314,11 +315,11 @@ const Z = (e, r) => {
|
|
|
314
315
|
if (e.length !== r.length) return !1;
|
|
315
316
|
const s = new Set(e.map(String));
|
|
316
317
|
return r.every((i) => s.has(String(i)));
|
|
317
|
-
},
|
|
318
|
+
}, Ye = (e, r) => `${e}:${r.map(String).sort().join(",")}`, ie = (e) => e.replace(/_/g, " ").replace(/^\w/, (r) => r.toUpperCase()), ge = (e) => /s$/i.test(e) ? e : `${e}s`;
|
|
318
319
|
function ne(e) {
|
|
319
320
|
return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e.at(-1)}`;
|
|
320
321
|
}
|
|
321
|
-
function
|
|
322
|
+
function Ct({
|
|
322
323
|
userId: e,
|
|
323
324
|
previewDelayMs: r = 400
|
|
324
325
|
}) {
|
|
@@ -344,17 +345,17 @@ function $t({
|
|
|
344
345
|
}), y = j({
|
|
345
346
|
// One person's scope saves go out one after another, in click order.
|
|
346
347
|
scope: { id: `nvr-user-scopes:${e}` },
|
|
347
|
-
mutationFn: (a) => s.request(
|
|
348
|
+
mutationFn: (a) => s.request(Qe(`/user-scopes/${e}`, a)),
|
|
348
349
|
onMutate: (a) => {
|
|
349
|
-
var q,
|
|
350
|
-
const p = `${a.dimension}:${a.mode}`, S = a.mode === "restrict" ? "restricted" : "defaults", k = ((
|
|
350
|
+
var q, z;
|
|
351
|
+
const p = `${a.dimension}:${a.mode}`, S = a.mode === "restrict" ? "restricted" : "defaults", k = ((z = (q = i.getQueryData(l)) == null ? void 0 : q[S]) == null ? void 0 : z[a.dimension]) ?? [];
|
|
351
352
|
return u.current[p] = (u.current[p] ?? 0) + 1, delete f.current[p], d((B) => ({ ...B, [p]: a.values })), _(p, "saving"), i.cancelQueries({ queryKey: l }), R(a), { before: k };
|
|
352
353
|
},
|
|
353
354
|
onSuccess: (a, p) => R(p),
|
|
354
355
|
onError: (a, p, S) => {
|
|
355
356
|
var B, ue;
|
|
356
|
-
const k = `${p.dimension}:${p.mode}`, q = p.mode === "restrict" ? "restricted" : "defaults",
|
|
357
|
-
S && Z(
|
|
357
|
+
const k = `${p.dimension}:${p.mode}`, q = p.mode === "restrict" ? "restricted" : "defaults", z = ((ue = (B = i.getQueryData(l)) == null ? void 0 : B[q]) == null ? void 0 : ue[p.dimension]) ?? [];
|
|
358
|
+
S && Z(z, p.values) && R({ ...p, values: S.before }), d((W) => {
|
|
358
359
|
if (!W[k] || !Z(W[k], p.values)) return W;
|
|
359
360
|
const { [k]: st, ...Ce } = W;
|
|
360
361
|
return Ce;
|
|
@@ -368,16 +369,16 @@ function $t({
|
|
|
368
369
|
const k = `${S.dimension}:${S.mode}`;
|
|
369
370
|
u.current[k] = Math.max(0, (u.current[k] ?? 1) - 1), p || d((q) => {
|
|
370
371
|
if (!q[k] || !Z(q[k], S.values)) return q;
|
|
371
|
-
const { [k]:
|
|
372
|
+
const { [k]: z, ...B } = q;
|
|
372
373
|
return B;
|
|
373
374
|
}), u.current[k] === 0 && _(k, p ? "failed" : "saved"), i.invalidateQueries({ queryKey: l }), i.invalidateQueries({ queryKey: ["nvr-person-profile", e] }), i.invalidateQueries({ queryKey: ["nvr-my-scopes"] }), i.invalidateQueries({ queryKey: ["nvr-profile-scopes"] });
|
|
374
375
|
}
|
|
375
|
-
}), v = (a, p) => b[`${a}:${p}`] ?? (p === "restrict" ? h == null ? void 0 : h.restricted[a] : h == null ? void 0 : h.defaults[a]) ?? [], [o, N] = P(null), [w, C] = P(null), [g, L] = P(0), m = X(0), A = o ?
|
|
376
|
+
}), v = (a, p) => b[`${a}:${p}`] ?? (p === "restrict" ? h == null ? void 0 : h.restricted[a] : h == null ? void 0 : h.defaults[a]) ?? [], [o, N] = P(null), [w, C] = P(null), [g, L] = P(0), m = X(0), A = o ? Ye(o.dimension, o.values) : null;
|
|
376
377
|
pe(() => {
|
|
377
378
|
if (!o || !A) return;
|
|
378
379
|
const a = ++m.current, p = setTimeout(() => {
|
|
379
380
|
s.request(
|
|
380
|
-
|
|
381
|
+
G(`/user-scopes/${e}/impact`, {
|
|
381
382
|
dimension: o.dimension,
|
|
382
383
|
values: o.values
|
|
383
384
|
})
|
|
@@ -392,7 +393,7 @@ function $t({
|
|
|
392
393
|
}, r);
|
|
393
394
|
return () => clearTimeout(p);
|
|
394
395
|
}, [A, g, s, e, r]);
|
|
395
|
-
const
|
|
396
|
+
const F = (a, p) => {
|
|
396
397
|
if (Z(p, v(a, "restrict"))) {
|
|
397
398
|
m.current++, N(null), C(null);
|
|
398
399
|
return;
|
|
@@ -400,14 +401,14 @@ function $t({
|
|
|
400
401
|
o && o.dimension !== a && C(null), N({ dimension: a, values: p });
|
|
401
402
|
}, U = () => {
|
|
402
403
|
m.current++, N(null), C(null);
|
|
403
|
-
},
|
|
404
|
+
}, Y = () => {
|
|
404
405
|
o && (y.mutate({ dimension: o.dimension, mode: "restrict", values: o.values }), U());
|
|
405
406
|
}, x = (a) => {
|
|
406
407
|
const p = f.current[a];
|
|
407
408
|
p && y.mutate(p);
|
|
408
409
|
};
|
|
409
410
|
return !h || h.dimensions.length === 0 ? null : /* @__PURE__ */ t(
|
|
410
|
-
|
|
411
|
+
V,
|
|
411
412
|
{
|
|
412
413
|
icon: /* @__PURE__ */ t(Re, { className: "h-4 w-4" }),
|
|
413
414
|
title: "Scopes",
|
|
@@ -471,7 +472,7 @@ function $t({
|
|
|
471
472
|
removing: S && o ? v(a.name, "restrict").filter(
|
|
472
473
|
(k) => !o.values.some((q) => String(q) === String(k))
|
|
473
474
|
) : void 0,
|
|
474
|
-
onToggle: (k) =>
|
|
475
|
+
onToggle: (k) => F(a.name, k)
|
|
475
476
|
}
|
|
476
477
|
),
|
|
477
478
|
S && o && /* @__PURE__ */ t(
|
|
@@ -482,7 +483,7 @@ function $t({
|
|
|
482
483
|
values: o.values,
|
|
483
484
|
result: (w == null ? void 0 : w.key) === A ? w : null,
|
|
484
485
|
stale: w && w.key !== A ? w.answer : null,
|
|
485
|
-
onApply:
|
|
486
|
+
onApply: Y,
|
|
486
487
|
onCancel: U,
|
|
487
488
|
onRetry: () => L((k) => k + 1)
|
|
488
489
|
}
|
|
@@ -511,15 +512,15 @@ function fe({
|
|
|
511
512
|
r === "saving" && "text-slate-600 dark:text-slate-300"
|
|
512
513
|
),
|
|
513
514
|
children: [
|
|
514
|
-
r === "saving" && /* @__PURE__ */ n(
|
|
515
|
+
r === "saving" && /* @__PURE__ */ n(I, { children: [
|
|
515
516
|
/* @__PURE__ */ t(le, { className: "h-3 w-3 animate-spin motion-reduce:animate-none", "aria-hidden": !0 }),
|
|
516
517
|
"Saving…"
|
|
517
518
|
] }),
|
|
518
|
-
r === "saved" && /* @__PURE__ */ n(
|
|
519
|
+
r === "saved" && /* @__PURE__ */ n(I, { children: [
|
|
519
520
|
/* @__PURE__ */ t(ye, { className: "h-3 w-3", "aria-hidden": !0 }),
|
|
520
521
|
"Saved"
|
|
521
522
|
] }),
|
|
522
|
-
r === "failed" && /* @__PURE__ */ n(
|
|
523
|
+
r === "failed" && /* @__PURE__ */ n(I, { children: [
|
|
523
524
|
"Not saved",
|
|
524
525
|
/* @__PURE__ */ t(
|
|
525
526
|
"button",
|
|
@@ -545,11 +546,11 @@ function We({
|
|
|
545
546
|
onCancel: b,
|
|
546
547
|
onRetry: d
|
|
547
548
|
}) {
|
|
548
|
-
var U,
|
|
549
|
+
var U, Y;
|
|
549
550
|
const $ = $e(e, [...r, ...s]), c = (x) => $.get(String(x)) ?? `#${x}`, f = e.label.toLowerCase(), u = new Set(r.map(String)), D = new Set(s.map(String)), _ = s.filter((x) => !u.has(String(x))).map(c), R = r.filter((x) => !D.has(String(x))).map(c), y = (i == null ? void 0 : i.answer) ?? l, v = i ? i.error ? "error" : "ready" : l ? "updating" : "loading", o = (y == null ? void 0 : y.impact) ?? [], N = o.filter((x) => x.proposed === 0 && x.total > 0), w = s.length === 0, C = (x, a = 5) => x.length <= a ? ne(x) : `${x.slice(0, a - 1).join(", ")} and ${x.length - (a - 1)} more`, g = w ? `Remove the ${f} restriction` : r.length === 0 ? `Limit them to ${C(s.map(c))}` : [
|
|
550
551
|
_.length > 0 ? `Also let them see ${C(_)}` : null,
|
|
551
552
|
R.length > 0 ? `${_.length > 0 ? "stop" : "Stop"} them seeing ${C(R)}` : null
|
|
552
|
-
].filter(Boolean).join("; "), L = w ? `They will see records in every ${f}.` : `After this they only see records in ${C(s.map(c))}.`, m = v === "updating" ? "opacity-40" : "", A = N.map((x) => x.label ?? ie(x.collection)),
|
|
553
|
+
].filter(Boolean).join("; "), L = w ? `They will see records in every ${f}.` : `After this they only see records in ${C(s.map(c))}.`, m = v === "updating" ? "opacity-40" : "", A = N.map((x) => x.label ?? ie(x.collection)), F = A.length <= 2 ? `they lose all ${ne(A)}` : `they lose ${A.length} record types`;
|
|
553
554
|
return /* @__PURE__ */ n(
|
|
554
555
|
"div",
|
|
555
556
|
{
|
|
@@ -603,11 +604,11 @@ function We({
|
|
|
603
604
|
] }),
|
|
604
605
|
(((U = y == null ? void 0 : y.partial) == null ? void 0 : U.length) ?? 0) > 0 && /* @__PURE__ */ n("p", { className: "mx-3 mt-1.5 text-[11px] text-amber-900 dark:text-amber-200", children: [
|
|
605
606
|
"Not counted in time: ",
|
|
606
|
-
(
|
|
607
|
+
(Y = y == null ? void 0 : y.partial) == null ? void 0 : Y.map((x) => x.label).join(", "),
|
|
607
608
|
"."
|
|
608
609
|
] }),
|
|
609
610
|
/* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2 px-3 pb-2.5 pt-2.5", children: [
|
|
610
|
-
v === "error" ? /* @__PURE__ */ n(
|
|
611
|
+
v === "error" ? /* @__PURE__ */ n(I, { children: [
|
|
611
612
|
/* @__PURE__ */ t(
|
|
612
613
|
"button",
|
|
613
614
|
{
|
|
@@ -628,15 +629,15 @@ function We({
|
|
|
628
629
|
}
|
|
629
630
|
)
|
|
630
631
|
] }) : N.length > 0 && v === "ready" ? /* @__PURE__ */ t("span", { "data-scope-apply-danger": !0, children: /* @__PURE__ */ n(
|
|
631
|
-
|
|
632
|
+
H,
|
|
632
633
|
{
|
|
633
634
|
onConfirm: h,
|
|
634
|
-
confirmLabel: `Press again — ${
|
|
635
|
+
confirmLabel: `Press again — ${F}`,
|
|
635
636
|
className: "inline-flex h-7 items-center rounded-md bg-red-600 px-3 text-[11.5px] font-medium text-white hover:bg-red-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-500/50 focus-visible:ring-offset-1 dark:bg-red-700 dark:hover:bg-red-600",
|
|
636
637
|
armedClassName: "bg-red-700 dark:bg-red-800",
|
|
637
638
|
children: [
|
|
638
639
|
"Apply — ",
|
|
639
|
-
|
|
640
|
+
F
|
|
640
641
|
]
|
|
641
642
|
}
|
|
642
643
|
) }) : /* @__PURE__ */ t(
|
|
@@ -666,7 +667,7 @@ function We({
|
|
|
666
667
|
);
|
|
667
668
|
}
|
|
668
669
|
function xe({ items: e }) {
|
|
669
|
-
return /* @__PURE__ */ t(
|
|
670
|
+
return /* @__PURE__ */ t(I, { children: e.map((r, s) => /* @__PURE__ */ n("span", { children: [
|
|
670
671
|
s > 0 && ", ",
|
|
671
672
|
/^\d+$/.test(r.label) ? /* @__PURE__ */ n("span", { className: "font-mono text-[10.5px]", children: [
|
|
672
673
|
"#",
|
|
@@ -743,7 +744,7 @@ const Ze = [
|
|
|
743
744
|
{ key: "employee_id", label: "Employee id" },
|
|
744
745
|
{ key: "preferred_language", label: "Language" }
|
|
745
746
|
];
|
|
746
|
-
function
|
|
747
|
+
function _t({ profile: e }) {
|
|
747
748
|
var _, R, y, v;
|
|
748
749
|
const r = Q(), s = oe(), i = ce(e.id), l = E({
|
|
749
750
|
queryKey: ["nvr-directory-status"],
|
|
@@ -758,13 +759,13 @@ function Ct({ profile: e }) {
|
|
|
758
759
|
enabled: !!((_ = l.data) != null && _.granted && e.email),
|
|
759
760
|
staleTime: 6e4
|
|
760
761
|
}), b = j({
|
|
761
|
-
mutationFn: () => r.request(
|
|
762
|
+
mutationFn: () => r.request(G(`/directory/sync/${e.id}`)).then((o) => o.data),
|
|
762
763
|
onSuccess: ({ summary: o }) => {
|
|
763
|
-
i(), s.invalidateQueries({ queryKey: ["nvr-directory-entry", e.email] }), o.active > 0 ?
|
|
764
|
+
i(), s.invalidateQueries({ queryKey: ["nvr-directory-entry", e.email] }), o.active > 0 ? K.success("Still with the company — profile synced from the directory") : K.warning(
|
|
764
765
|
`${o.missing > 0 ? "Not in the directory" : "Disabled in Azure"}${o.suspended > 0 ? " — suspended" : ""}`
|
|
765
766
|
);
|
|
766
767
|
},
|
|
767
|
-
onError: (o) =>
|
|
768
|
+
onError: (o) => K.error(J(o, "Directory sync failed"))
|
|
768
769
|
});
|
|
769
770
|
if (l.isLoading || !((R = l.data) != null && R.configured)) return null;
|
|
770
771
|
const d = e, $ = (o) => {
|
|
@@ -772,7 +773,7 @@ function Ct({ profile: e }) {
|
|
|
772
773
|
return d[o] ?? ((N = e.admin) == null ? void 0 : N[o]) ?? null;
|
|
773
774
|
}, c = h.data, f = ((y = e.admin) == null ? void 0 : y.directory_status) ?? null, u = f === "active" ? "border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-400/30 dark:bg-emerald-400/10 dark:text-emerald-200" : f === "disabled" || f === "missing" ? "border-red-200 bg-red-50 text-red-800 dark:border-red-400/30 dark:bg-red-400/10 dark:text-red-200" : "border-slate-200 bg-slate-50 text-slate-600 dark:border-border dark:bg-muted dark:text-muted-foreground", D = f === "active" ? "Still with the company" : f === "disabled" ? "Account disabled in Azure — no longer with the company" : f === "missing" ? "Not in the Microsoft directory — no longer with the company" : "Not checked against the directory yet";
|
|
774
775
|
return /* @__PURE__ */ n(
|
|
775
|
-
|
|
776
|
+
V,
|
|
776
777
|
{
|
|
777
778
|
icon: /* @__PURE__ */ t(Ae, { className: "h-4 w-4" }),
|
|
778
779
|
title: "Microsoft directory",
|
|
@@ -801,7 +802,7 @@ function Ct({ profile: e }) {
|
|
|
801
802
|
/* @__PURE__ */ t("span", { className: "font-medium", children: D }),
|
|
802
803
|
((v = e.admin) == null ? void 0 : v.directory_checked_at) && /* @__PURE__ */ n("span", { className: "ml-2 text-[11px] opacity-70", children: [
|
|
803
804
|
"checked ",
|
|
804
|
-
|
|
805
|
+
Be(e.admin.directory_checked_at)
|
|
805
806
|
] }),
|
|
806
807
|
(f === "disabled" || f === "missing") && /* @__PURE__ */ t("p", { className: "mt-0.5 text-[11.5px] opacity-80", children: "Hand off what they still own under Admin tools. Redaction stays a separate step." })
|
|
807
808
|
]
|
|
@@ -854,25 +855,25 @@ function Ct({ profile: e }) {
|
|
|
854
855
|
}
|
|
855
856
|
);
|
|
856
857
|
}
|
|
857
|
-
function
|
|
858
|
+
function qt({ profile: e }) {
|
|
858
859
|
var f;
|
|
859
860
|
const r = Q(), s = ce(e.id), [i, l] = P(null), [h, b] = P(!1), d = j({
|
|
860
|
-
mutationFn: () => r.request(
|
|
861
|
+
mutationFn: () => r.request(G(`/users/${e.id}/token`)).then((u) => u.data.token),
|
|
861
862
|
onSuccess: (u) => {
|
|
862
|
-
l(u), b(!0), s(),
|
|
863
|
+
l(u), b(!0), s(), K.success("Token generated — copy it now, it is shown once");
|
|
863
864
|
},
|
|
864
|
-
onError: (u) =>
|
|
865
|
+
onError: (u) => K.error(J(u, "Could not generate a token"))
|
|
865
866
|
}), $ = j({
|
|
866
867
|
mutationFn: () => r.request(Ne(`/users/${e.id}/token`)),
|
|
867
868
|
onSuccess: () => {
|
|
868
|
-
l(null), b(!1), s(),
|
|
869
|
+
l(null), b(!1), s(), K.success("Token revoked");
|
|
869
870
|
},
|
|
870
|
-
onError: (u) =>
|
|
871
|
+
onError: (u) => K.error(J(u, "Could not revoke the token"))
|
|
871
872
|
}), c = !!((f = e.admin) != null && f.has_static_token) || !!i;
|
|
872
873
|
return /* @__PURE__ */ t(
|
|
873
|
-
|
|
874
|
+
V,
|
|
874
875
|
{
|
|
875
|
-
icon: /* @__PURE__ */ t(
|
|
876
|
+
icon: /* @__PURE__ */ t(Ke, { className: "h-4 w-4" }),
|
|
876
877
|
title: "API token",
|
|
877
878
|
hint: "Static bearer token for scripts and the SDK",
|
|
878
879
|
testId: "api-token",
|
|
@@ -889,22 +890,11 @@ function _t({ profile: e }) {
|
|
|
889
890
|
children: h ? /* @__PURE__ */ t(Te, { className: "h-4 w-4" }) : /* @__PURE__ */ t(De, { className: "h-4 w-4" })
|
|
890
891
|
}
|
|
891
892
|
),
|
|
892
|
-
/* @__PURE__ */ t(
|
|
893
|
-
"button",
|
|
894
|
-
{
|
|
895
|
-
type: "button",
|
|
896
|
-
onClick: () => {
|
|
897
|
-
navigator.clipboard.writeText(i), F.success("Copied");
|
|
898
|
-
},
|
|
899
|
-
"aria-label": "Copy token",
|
|
900
|
-
className: "rounded-md border border-slate-200 p-2 text-slate-500 hover:bg-slate-50 dark:border-border dark:hover:bg-muted",
|
|
901
|
-
children: /* @__PURE__ */ t(Fe, { className: "h-4 w-4" })
|
|
902
|
-
}
|
|
903
|
-
)
|
|
893
|
+
/* @__PURE__ */ t(ze, { value: i, label: "Copy token", testId: "copy-api-token" })
|
|
904
894
|
] }) : /* @__PURE__ */ t("p", { className: "text-[12.5px] text-slate-600 dark:text-slate-300", children: "A token is set. The value is never shown again — regenerate to issue a new one." }),
|
|
905
895
|
/* @__PURE__ */ n("div", { className: "flex gap-2", children: [
|
|
906
896
|
/* @__PURE__ */ n(
|
|
907
|
-
|
|
897
|
+
H,
|
|
908
898
|
{
|
|
909
899
|
onConfirm: () => d.mutate(),
|
|
910
900
|
disabled: d.isPending,
|
|
@@ -918,7 +908,7 @@ function _t({ profile: e }) {
|
|
|
918
908
|
}
|
|
919
909
|
),
|
|
920
910
|
/* @__PURE__ */ n(
|
|
921
|
-
|
|
911
|
+
H,
|
|
922
912
|
{
|
|
923
913
|
onConfirm: () => $.mutate(),
|
|
924
914
|
disabled: $.isPending,
|
|
@@ -926,7 +916,7 @@ function _t({ profile: e }) {
|
|
|
926
916
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-red-600 transition-colors hover:bg-red-50 disabled:opacity-50 dark:border-border dark:text-red-400 dark:hover:bg-red-500/10",
|
|
927
917
|
armedClassName: "border-red-300",
|
|
928
918
|
children: [
|
|
929
|
-
/* @__PURE__ */ t(
|
|
919
|
+
/* @__PURE__ */ t(Fe, { className: "h-3 w-3" }),
|
|
930
920
|
" Revoke"
|
|
931
921
|
]
|
|
932
922
|
}
|
|
@@ -957,7 +947,7 @@ function et(e, r, s) {
|
|
|
957
947
|
}
|
|
958
948
|
function tt(e) {
|
|
959
949
|
const r = new Date(e);
|
|
960
|
-
if (Number.isNaN(r.getTime())) return
|
|
950
|
+
if (Number.isNaN(r.getTime())) return Ie(e);
|
|
961
951
|
const s = r.getFullYear() === (/* @__PURE__ */ new Date()).getFullYear();
|
|
962
952
|
return r.toLocaleString(void 0, {
|
|
963
953
|
month: "short",
|
|
@@ -980,13 +970,13 @@ function nt(e) {
|
|
|
980
970
|
const r = Math.round(e / 3600);
|
|
981
971
|
return r >= 48 ? `Ends in ${Math.round(r / 24)} days` : `Ends in ${r}h`;
|
|
982
972
|
}
|
|
983
|
-
function
|
|
973
|
+
function Rt({ userId: e }) {
|
|
984
974
|
const r = Q(), s = oe(), i = ["nvr-user-sessions", e], l = E({
|
|
985
975
|
queryKey: i,
|
|
986
976
|
queryFn: () => r.request(O("/security/sessions", { user_id: e })).then((m) => m.data ?? []),
|
|
987
977
|
staleTime: 3e4
|
|
988
978
|
}), h = e.toUpperCase();
|
|
989
|
-
|
|
979
|
+
Me(
|
|
990
980
|
"sessions",
|
|
991
981
|
() => {
|
|
992
982
|
s.invalidateQueries({ queryKey: ["nvr-user-sessions", e] }), s.invalidateQueries({ queryKey: ["nvr-signed-in-devices", e] });
|
|
@@ -999,18 +989,18 @@ function qt({ userId: e }) {
|
|
|
999
989
|
const b = j({
|
|
1000
990
|
mutationFn: (m) => r.request(Ne(`/security/sessions/${m}`)),
|
|
1001
991
|
onSuccess: (m, A) => {
|
|
1002
|
-
s.setQueryData(i, (
|
|
992
|
+
s.setQueryData(i, (F) => F == null ? void 0 : F.filter((U) => U.sid_prefix !== A)), K.success("That browser is signed out");
|
|
1003
993
|
},
|
|
1004
994
|
onError: (m) => se(m, "Could not sign that browser out")
|
|
1005
|
-
}), d = de(() => rt(l.data ?? []), [l.data]), $ =
|
|
995
|
+
}), d = de(() => rt(l.data ?? []), [l.data]), $ = Ue(d.map((m) => m.sid_prefix)), { quiet: c } = je(), [f, u] = P(!1), D = d.filter((m) => !m.current && !te(m)), _ = D.length >= 3 ? d.filter((m) => m.current || te(m)) : d, R = f ? d : _.slice(0, ee), y = d.length - R.length, v = y > 0 && y === D.length && _.length <= ee, o = d.some((m) => m.current), N = d.filter((m) => !m.current), w = j({
|
|
1006
996
|
mutationFn: () => r.request(
|
|
1007
|
-
o ?
|
|
997
|
+
o ? G("/security/my/sessions/sign-out-others", {}) : G(`/security/users/${encodeURIComponent(e)}/sign-out`, {})
|
|
1008
998
|
),
|
|
1009
999
|
onSuccess: (m) => {
|
|
1010
|
-
var
|
|
1000
|
+
var F;
|
|
1011
1001
|
s.invalidateQueries({ queryKey: i }), s.invalidateQueries({ queryKey: ["nvr-signed-in-devices", e] });
|
|
1012
|
-
const A = ((
|
|
1013
|
-
|
|
1002
|
+
const A = ((F = m == null ? void 0 : m.data) == null ? void 0 : F.revoked) ?? 0;
|
|
1003
|
+
K.success(A === 1 ? "1 sign-in ended" : `${M(A)} sign-ins ended`);
|
|
1014
1004
|
},
|
|
1015
1005
|
onError: (m) => se(m, "Could not sign those out")
|
|
1016
1006
|
}), C = o ? "Sign out everywhere else" : "Sign out everywhere", L = (E({
|
|
@@ -1019,7 +1009,7 @@ function qt({ userId: e }) {
|
|
|
1019
1009
|
staleTime: 3e4
|
|
1020
1010
|
}).data ?? []).filter((m) => !(o && m.current)).length;
|
|
1021
1011
|
return /* @__PURE__ */ t(
|
|
1022
|
-
|
|
1012
|
+
V,
|
|
1023
1013
|
{
|
|
1024
1014
|
icon: /* @__PURE__ */ t(Le, { className: "h-4 w-4" }),
|
|
1025
1015
|
title: l.isSuccess ? `Signed-in browsers · ${d.length}` : "Signed-in browsers",
|
|
@@ -1028,7 +1018,7 @@ function qt({ userId: e }) {
|
|
|
1028
1018
|
children: l.isLoading ? /* @__PURE__ */ n("div", { className: "space-y-3", "aria-hidden": !0, children: [
|
|
1029
1019
|
/* @__PURE__ */ t(he, { className: "h-9 w-full" }),
|
|
1030
1020
|
/* @__PURE__ */ t(he, { className: "h-9 w-2/3" })
|
|
1031
|
-
] }) : l.isError ? /* @__PURE__ */ t(
|
|
1021
|
+
] }) : l.isError ? /* @__PURE__ */ t(Ge, { error: l.error, what: "signed-in browsers", onRetry: () => l.refetch() }) : d.length === 0 ? /* @__PURE__ */ t(we, { children: "Not signed in on any browser." }) : /* @__PURE__ */ n(I, { children: [
|
|
1032
1022
|
/* @__PURE__ */ t(
|
|
1033
1023
|
"ul",
|
|
1034
1024
|
{
|
|
@@ -1075,7 +1065,7 @@ function qt({ userId: e }) {
|
|
|
1075
1065
|
}
|
|
1076
1066
|
) : null,
|
|
1077
1067
|
N.length > 1 && /* @__PURE__ */ t("span", { className: "ml-auto", children: /* @__PURE__ */ n(
|
|
1078
|
-
|
|
1068
|
+
H,
|
|
1079
1069
|
{
|
|
1080
1070
|
title: C,
|
|
1081
1071
|
onConfirm: () => w.mutate(),
|
|
@@ -1106,7 +1096,7 @@ function at({
|
|
|
1106
1096
|
e.ip,
|
|
1107
1097
|
e.signed_in_at ? `Signed in ${tt(e.signed_in_at)}` : "Signed in before this was recorded",
|
|
1108
1098
|
nt(e.ttl_seconds)
|
|
1109
|
-
].filter((d) => !!d), b =
|
|
1099
|
+
].filter((d) => !!d), b = He(l);
|
|
1110
1100
|
return /* @__PURE__ */ n(
|
|
1111
1101
|
"li",
|
|
1112
1102
|
{
|
|
@@ -1117,7 +1107,7 @@ function at({
|
|
|
1117
1107
|
r && "bg-nvr-cyan/10"
|
|
1118
1108
|
),
|
|
1119
1109
|
children: [
|
|
1120
|
-
/* @__PURE__ */ t("span", { className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-300", children: / on (iOS|Android)$/.test(l) ? /* @__PURE__ */ t(
|
|
1110
|
+
/* @__PURE__ */ t("span", { className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-300", children: / on (iOS|Android)$/.test(l) ? /* @__PURE__ */ t(Pe, { className: "h-4 w-4", "aria-hidden": !0 }) : /* @__PURE__ */ t(Ee, { className: "h-4 w-4", "aria-hidden": !0 }) }),
|
|
1121
1111
|
/* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
|
|
1122
1112
|
/* @__PURE__ */ n("p", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5", children: [
|
|
1123
1113
|
/* @__PURE__ */ t(
|
|
@@ -1148,7 +1138,7 @@ function at({
|
|
|
1148
1138
|
)) }) })
|
|
1149
1139
|
] }),
|
|
1150
1140
|
/* @__PURE__ */ t("span", { "data-session-sign-out": !0, className: "contents", children: /* @__PURE__ */ n(
|
|
1151
|
-
|
|
1141
|
+
H,
|
|
1152
1142
|
{
|
|
1153
1143
|
title: e.current ? "Sign out of this browser" : `Sign out ${l}`,
|
|
1154
1144
|
onConfirm: i,
|
|
@@ -1167,12 +1157,12 @@ function at({
|
|
|
1167
1157
|
);
|
|
1168
1158
|
}
|
|
1169
1159
|
export {
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1160
|
+
St as AccessCard,
|
|
1161
|
+
qt as ApiTokenCard,
|
|
1162
|
+
Rt as SessionsCard,
|
|
1163
|
+
$t as SuspensionBanner,
|
|
1164
|
+
_t as UserDirectoryCard,
|
|
1165
|
+
Ct as UserScopesCard,
|
|
1176
1166
|
rt as orderSessions,
|
|
1177
1167
|
nt as sessionEndsIn,
|
|
1178
1168
|
et as signOutAllQuestion
|
|
@@ -98,7 +98,8 @@ function A({
|
|
|
98
98
|
onClick: t,
|
|
99
99
|
className: o(
|
|
100
100
|
"relative h-[18px] w-8 shrink-0 rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40",
|
|
101
|
-
|
|
101
|
+
// Off in dark: slate-600, not bg-muted (it all but vanished on a dark card).
|
|
102
|
+
e ? n === "amber" ? "bg-amber-400" : "bg-nvr-cyan" : "bg-slate-200 dark:bg-slate-600"
|
|
102
103
|
),
|
|
103
104
|
children: /* @__PURE__ */ a(
|
|
104
105
|
"span",
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsxs as m, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as d, useQuery as f, useMutation as x } from "@tanstack/react-query";
|
|
3
|
+
import { useNivaroClient as h } from "../../context.js";
|
|
4
|
+
import { get as g, patch as y } from "../../lib/commands.js";
|
|
5
|
+
import { announceLocalPrefs as w } from "../../lib/user-sync.js";
|
|
6
|
+
import { cn as _ } from "../../lib/utils.js";
|
|
7
|
+
import { Toggle as v } from "../profile/primitives.js";
|
|
8
|
+
const o = ["nvr-profile-prefs"];
|
|
9
|
+
function F({ compact: c }) {
|
|
10
|
+
const n = h(), i = d(), { data: r, isSuccess: l } = f({
|
|
11
|
+
queryKey: o,
|
|
12
|
+
queryFn: () => n.request(g("/users/me")).then((e) => {
|
|
13
|
+
var s;
|
|
14
|
+
return ((s = e.data) == null ? void 0 : s.preferences) ?? {};
|
|
15
|
+
})
|
|
16
|
+
}), t = (r == null ? void 0 : r.support_email_updates) === !0, u = x({
|
|
17
|
+
mutationFn: (e) => n.request(y("/users/me/preferences", { support_email_updates: e ? !0 : null })),
|
|
18
|
+
onMutate: (e) => {
|
|
19
|
+
i.setQueryData(o, (s) => ({
|
|
20
|
+
...s ?? {},
|
|
21
|
+
support_email_updates: e ? !0 : null
|
|
22
|
+
}));
|
|
23
|
+
},
|
|
24
|
+
onSettled: () => {
|
|
25
|
+
i.invalidateQueries({ queryKey: o }), w(["support_email_updates"]);
|
|
26
|
+
}
|
|
27
|
+
}), p = "Email me when my requests get a reply or change";
|
|
28
|
+
return /* @__PURE__ */ m(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
"data-support-email-switch": l ? t ? "on" : "off" : "loading",
|
|
32
|
+
className: "flex items-start gap-2 text-[12.5px] text-slate-600 dark:text-muted-foreground",
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ a("span", { className: "pt-px", children: /* @__PURE__ */ a(
|
|
35
|
+
v,
|
|
36
|
+
{
|
|
37
|
+
on: t,
|
|
38
|
+
onChange: () => {
|
|
39
|
+
l && !u.isPending && u.mutate(!t);
|
|
40
|
+
},
|
|
41
|
+
label: p
|
|
42
|
+
}
|
|
43
|
+
) }),
|
|
44
|
+
/* @__PURE__ */ m("div", { className: "min-w-0", children: [
|
|
45
|
+
/* @__PURE__ */ a("p", { className: "text-[12.5px] font-medium text-slate-700 dark:text-slate-200", children: p }),
|
|
46
|
+
/* @__PURE__ */ a(
|
|
47
|
+
"p",
|
|
48
|
+
{
|
|
49
|
+
className: _(
|
|
50
|
+
"max-w-[68ch] leading-snug text-slate-500 dark:text-slate-400",
|
|
51
|
+
c ? "text-[11px]" : "text-[11.5px]"
|
|
52
|
+
),
|
|
53
|
+
children: t ? "You get an email when someone replies, picks one up or changes its status, following your email setting for Workflow & approvals." : "Off: replies and changes reach you in the app (and as push, if you allow it), not by email."
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
] })
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
F as SupportEmailSwitch
|
|
63
|
+
};
|