@nivaro/react 0.3.117 → 0.3.118
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 +136 -14
- package/dist/index.js +488 -485
- package/dist/shared/components/ActivityEntry.js +130 -125
- package/dist/shared/components/AgentPresenceChip.js +36 -26
- package/dist/shared/components/CellCopyLayer.js +50 -45
- package/dist/shared/components/CollectionBrowserView.js +3757 -3695
- package/dist/shared/components/FilePreviewLightbox.js +96 -58
- package/dist/shared/components/InStep.js +18 -17
- package/dist/shared/components/ItemEditForm.js +4220 -4175
- package/dist/shared/components/JobsTray.js +8 -8
- package/dist/shared/components/LiveNewMatchesPill.js +21 -14
- package/dist/shared/components/LiveOffNote.js +3 -2
- package/dist/shared/components/LiveRowMark.js +53 -23
- package/dist/shared/components/LiveTraceView.js +162 -123
- package/dist/shared/components/MyWorkView.js +320 -299
- package/dist/shared/components/NotificationBell.js +14 -14
- package/dist/shared/components/OverflowRail.js +1 -1
- package/dist/shared/components/PageRenderer.js +120 -116
- package/dist/shared/components/ProfileView.js +203 -202
- package/dist/shared/components/RealtimeStatusBanner.js +31 -29
- package/dist/shared/components/RecordDrilldownSheet.js +7 -7
- package/dist/shared/components/RecordHoverCard.js +102 -84
- package/dist/shared/components/RecordReadView.js +146 -146
- package/dist/shared/components/ScreenRefreshButton.js +34 -32
- package/dist/shared/components/TipLayer.js +65 -58
- package/dist/shared/components/WidgetImageMenu.js +83 -43
- package/dist/shared/components/activity/RecordActivityStream.js +175 -173
- package/dist/shared/components/bulk/BulkSelectionNotices.js +142 -119
- package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +158 -143
- package/dist/shared/components/change-proposals/ProposeChangeButton.js +17 -11
- package/dist/shared/components/change-proposals/ProposeChangeDialog.js +201 -173
- package/dist/shared/components/chat/ChatAnalyticsView.js +27 -27
- package/dist/shared/components/chat/HuddleAnalyticsTab.js +17 -17
- package/dist/shared/components/collections-directory/CollectionsToolbar.js +39 -41
- package/dist/shared/components/collections-directory/page-model.js +72 -67
- package/dist/shared/components/integrations/RecordIntegrationPreview.js +48 -56
- package/dist/shared/components/integrations/SendStatus.js +65 -59
- package/dist/shared/components/integrations/console/ReadyToSendView.js +275 -209
- package/dist/shared/components/integrations/console/SignalCard.js +237 -230
- package/dist/shared/components/item-edit/CatalogPickerField.js +227 -205
- package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +131 -92
- package/dist/shared/components/item-edit/CloneDialog.js +191 -161
- package/dist/shared/components/item-edit/DerivedCauseNote.js +44 -30
- package/dist/shared/components/item-edit/DraftRecoveryBanner.js +153 -134
- package/dist/shared/components/item-edit/FieldComments.js +54 -53
- package/dist/shared/components/item-edit/FieldPointer.js +82 -67
- package/dist/shared/components/item-edit/FieldRow.js +106 -100
- package/dist/shared/components/item-edit/FieldSourceBadge.js +58 -56
- package/dist/shared/components/item-edit/FilePickerField.js +452 -387
- package/dist/shared/components/item-edit/HeaderSummaryChip.js +78 -56
- package/dist/shared/components/item-edit/HeaderTools.js +94 -85
- package/dist/shared/components/item-edit/InlineTableField.js +1242 -1218
- package/dist/shared/components/item-edit/ListNeighborNav.js +47 -50
- package/dist/shared/components/item-edit/LiveTraceSheet.js +15 -10
- package/dist/shared/components/item-edit/MembershipSetField.js +285 -254
- package/dist/shared/components/item-edit/OutboxReviewTray.js +155 -144
- package/dist/shared/components/item-edit/QueueReturnChip.js +15 -36
- package/dist/shared/components/item-edit/RecalcValue.js +57 -32
- package/dist/shared/components/item-edit/RecordHelpChip.js +21 -22
- package/dist/shared/components/item-edit/RecordLiveSync.js +283 -231
- package/dist/shared/components/item-edit/RelationCombobox.js +439 -393
- package/dist/shared/components/item-edit/RemoteChangeUi.js +292 -224
- package/dist/shared/components/item-edit/RemoteUploads.js +26 -20
- package/dist/shared/components/item-edit/RemovedLineNote.js +77 -67
- package/dist/shared/components/item-edit/RichTextEditorImpl.js +184 -179
- package/dist/shared/components/item-edit/ScheduledChangeChip.js +168 -134
- package/dist/shared/components/item-edit/SectionPresence.js +18 -10
- package/dist/shared/components/item-edit/SplitLinesButton.js +163 -139
- package/dist/shared/components/item-edit/UserChip.js +1 -1
- package/dist/shared/components/item-edit/file-live.js +69 -54
- package/dist/shared/components/item-edit/layout-switch.js +98 -89
- package/dist/shared/components/item-edit/partner-needs.js +12 -12
- package/dist/shared/components/item-edit/removed-line.js +31 -25
- package/dist/shared/components/layout-editor/pickers/field-picker.js +112 -104
- package/dist/shared/components/list/ListViewers.js +46 -35
- package/dist/shared/components/notifications/NotificationCenterView.js +479 -437
- package/dist/shared/components/panels/AccessDeniedPanel.js +176 -101
- package/dist/shared/components/panels/AlertBanners.js +82 -72
- package/dist/shared/components/panels/BranchLanes.js +22 -22
- package/dist/shared/components/panels/CommentImages.js +123 -102
- package/dist/shared/components/panels/CommentPanel.js +186 -185
- package/dist/shared/components/panels/ExternalRequestsChip.js +111 -119
- package/dist/shared/components/panels/OwnerOpenedLine.js +31 -24
- package/dist/shared/components/panels/PipelinePanel.js +2037 -1885
- package/dist/shared/components/panels/ResubmissionDiff.js +163 -142
- package/dist/shared/components/pipeline/OwnerMatrixSheet.js +400 -288
- package/dist/shared/components/pipeline/PipelineEditorView.js +7 -2
- package/dist/shared/components/profile/AgentNameField.js +107 -81
- package/dist/shared/components/profile/AgentsPanel.js +184 -184
- package/dist/shared/components/profile/PersonAccess.js +599 -495
- package/dist/shared/components/profile/SignInTroubleshooter.js +160 -127
- package/dist/shared/components/profile/SignedInDevices.js +17 -17
- package/dist/shared/components/profile/primitives.js +1 -1
- package/dist/shared/components/queue/OwnerAvatars.js +91 -54
- package/dist/shared/components/queue/QueueTeamStrip.js +56 -46
- package/dist/shared/components/queue/QueueWorklist.js +1002 -983
- package/dist/shared/components/support/AssignRules.js +1733 -0
- package/dist/shared/components/support/PersonPick.js +88 -0
- package/dist/shared/components/support/RequestList.js +790 -0
- package/dist/shared/components/support/ScreenShare.js +158 -152
- package/dist/shared/components/support/SupportRequestDialog.js +50 -48
- package/dist/shared/components/support/SupportView.js +140 -246
- package/dist/shared/components/support/TicketDetailSheet.js +82 -75
- package/dist/shared/components/support/TicketSlowScreens.js +9 -9
- package/dist/shared/components/support/assign-rules-text.js +171 -0
- package/dist/shared/components/support/support-list.js +125 -0
- package/dist/shared/components/ui/SimpleSelect.js +28 -20
- package/dist/shared/components/ui/checkbox.js +6 -6
- package/dist/shared/components/ui/select.js +43 -39
- package/dist/shared/components/ui/sheet.js +9 -9
- package/dist/shared/components/ui/switch.js +12 -11
- package/dist/shared/components/watch-list/WatchDock.js +532 -459
- package/dist/shared/components/watch-list/WatchExtras.js +332 -286
- package/dist/shared/components/watch-list/WatchRows.js +164 -140
- package/dist/shared/lib/activity-sentence.js +103 -91
- package/dist/shared/lib/agent-presence.js +27 -21
- package/dist/shared/lib/approval-progress.js +2 -2
- package/dist/shared/lib/copy-rules.js +31 -24
- package/dist/shared/lib/derived-causes.js +113 -78
- package/dist/shared/lib/grid-cursors.js +26 -26
- package/dist/shared/lib/label-flash.js +27 -0
- package/dist/shared/lib/list-return.js +137 -125
- package/dist/shared/lib/live-deltas.js +40 -34
- package/dist/shared/lib/live-groups.js +56 -52
- package/dist/shared/lib/live-preference.js +64 -59
- package/dist/shared/lib/live-screen.js +223 -192
- package/dist/shared/lib/partner-failure.js +11 -11
- package/dist/shared/lib/rollup-recalc.js +68 -64
- package/dist/shared/lib/screen-refresh.js +74 -68
- package/dist/shared/lib/screen-share.js +108 -104
- package/dist/shared/lib/send-status.js +77 -61
- package/dist/shared/lib/text-diff-window.js +29 -0
- package/dist/shared/lib/watch-list.js +210 -209
- package/dist/shared/lib/widget-image-render.js +72 -49
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { Undo2 as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import { toast as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as
|
|
8
|
-
import { toastError as
|
|
9
|
-
import { useLiveOps as
|
|
10
|
-
import { useLivePreference as
|
|
11
|
-
import { formatRelative as
|
|
12
|
-
import { ErrorNotice as
|
|
13
|
-
import { useOverflowTip as
|
|
14
|
-
import { SimpleSelect as
|
|
15
|
-
import { Skeleton as
|
|
16
|
-
import { SectionCard as
|
|
17
|
-
import { useInvalidatePerson as
|
|
1
|
+
import { jsxs as n, jsx as t, Fragment as z } from "react/jsx-runtime";
|
|
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, Copy as Fe, Trash2 as Ke, KeyRound as Pe, Smartphone as Ee, Monitor as Oe } from "lucide-react";
|
|
4
|
+
import { useMemo as de, useState as P, useRef as X, useEffect as pe } from "react";
|
|
5
|
+
import { toast as F } from "sonner";
|
|
6
|
+
import { useNivaroClient as Q } from "../../context.js";
|
|
7
|
+
import { get as O, patch as Qe, put as Me, post as H, del as Ne } from "../../lib/commands.js";
|
|
8
|
+
import { toastError as se } from "../../lib/error-toast.js";
|
|
9
|
+
import { useLiveOps as Ue, useFreshIds as je } from "../../lib/live-ops.js";
|
|
10
|
+
import { useLivePreference as Be } from "../../lib/live-preference.js";
|
|
11
|
+
import { formatRelative as ze, cn as T, formatNumber as M, formatDateTime as Ge } from "../../lib/utils.js";
|
|
12
|
+
import { ErrorNotice as He } from "../ErrorNotice.js";
|
|
13
|
+
import { useOverflowTip as Ie } from "../TipLayer.js";
|
|
14
|
+
import { SimpleSelect as re } from "../ui/SimpleSelect.js";
|
|
15
|
+
import { Skeleton as he } from "../ui/skeleton.js";
|
|
16
|
+
import { SectionCard as Y, EmptyLine as we, ConfirmButton as I } from "./primitives.js";
|
|
17
|
+
import { useInvalidatePerson as ce, errorText as J } from "./types.js";
|
|
18
18
|
const Je = [
|
|
19
19
|
{ value: "", label: "Person" },
|
|
20
20
|
{ value: "integration", label: "Integration — an external system writes as it" },
|
|
@@ -22,97 +22,97 @@ const Je = [
|
|
|
22
22
|
{ value: "bot", label: "Bot" },
|
|
23
23
|
{ value: "placeholder", label: "Placeholder — kept so old references resolve" }
|
|
24
24
|
];
|
|
25
|
-
function
|
|
26
|
-
const
|
|
25
|
+
function wt({ profile: e }) {
|
|
26
|
+
const r = Q(), s = ce(e.id), { data: i = [] } = E({
|
|
27
27
|
queryKey: ["nvr-roles"],
|
|
28
|
-
queryFn: () =>
|
|
29
|
-
|
|
30
|
-
).then((
|
|
28
|
+
queryFn: () => r.request(
|
|
29
|
+
O("/roles")
|
|
30
|
+
).then((u) => u.data),
|
|
31
31
|
staleTime: 5 * 6e4
|
|
32
|
-
}),
|
|
32
|
+
}), l = de(
|
|
33
33
|
() => {
|
|
34
|
-
var
|
|
34
|
+
var u;
|
|
35
35
|
return {
|
|
36
36
|
role: e.role_id ?? "",
|
|
37
37
|
status: e.status,
|
|
38
|
-
account_kind: ((
|
|
38
|
+
account_kind: ((u = e.admin) == null ? void 0 : u.account_kind) ?? ""
|
|
39
39
|
};
|
|
40
40
|
},
|
|
41
41
|
[e]
|
|
42
|
-
), [
|
|
43
|
-
mutationFn: () =>
|
|
44
|
-
|
|
45
|
-
role:
|
|
46
|
-
status:
|
|
47
|
-
account_kind:
|
|
42
|
+
), [h, b] = P(null), d = h ?? l, $ = JSON.stringify(d) !== JSON.stringify(l), c = j({
|
|
43
|
+
mutationFn: () => r.request(
|
|
44
|
+
Qe(`/users/${e.id}`, {
|
|
45
|
+
role: d.role || null,
|
|
46
|
+
status: d.status,
|
|
47
|
+
account_kind: d.account_kind || null
|
|
48
48
|
})
|
|
49
49
|
),
|
|
50
50
|
onSuccess: () => {
|
|
51
|
-
|
|
51
|
+
b(null), s(), F.success("Access saved");
|
|
52
52
|
},
|
|
53
|
-
onError: (
|
|
54
|
-
}),
|
|
53
|
+
onError: (u) => F.error(J(u, "Could not save access"))
|
|
54
|
+
}), f = [
|
|
55
55
|
{ value: "", label: "No role" },
|
|
56
|
-
...i.map((
|
|
56
|
+
...i.map((u) => ({ value: u.id, label: u.admin_access ? `${u.name} · admin` : u.name }))
|
|
57
57
|
];
|
|
58
58
|
return /* @__PURE__ */ t(
|
|
59
|
-
|
|
59
|
+
Y,
|
|
60
60
|
{
|
|
61
|
-
icon: /* @__PURE__ */ t(
|
|
61
|
+
icon: /* @__PURE__ */ t(qe, { className: "h-4 w-4" }),
|
|
62
62
|
title: "Access",
|
|
63
63
|
hint: "Role decides what they can do; status decides whether they can sign in",
|
|
64
64
|
testId: "access",
|
|
65
|
-
actions:
|
|
66
|
-
/* @__PURE__ */
|
|
65
|
+
actions: $ && /* @__PURE__ */ n("span", { className: "flex items-center gap-1.5", children: [
|
|
66
|
+
/* @__PURE__ */ n(
|
|
67
67
|
"button",
|
|
68
68
|
{
|
|
69
69
|
type: "button",
|
|
70
|
-
onClick: () =>
|
|
70
|
+
onClick: () => b(null),
|
|
71
71
|
className: "inline-flex h-7 items-center gap-1 rounded-md px-2 text-[11.5px] font-medium text-slate-400 transition-colors hover:text-slate-600 dark:hover:text-slate-200",
|
|
72
72
|
children: [
|
|
73
|
-
/* @__PURE__ */ t(
|
|
73
|
+
/* @__PURE__ */ t(_e, { className: "h-3 w-3" }),
|
|
74
74
|
" Reset"
|
|
75
75
|
]
|
|
76
76
|
}
|
|
77
77
|
),
|
|
78
|
-
/* @__PURE__ */
|
|
78
|
+
/* @__PURE__ */ n(
|
|
79
79
|
"button",
|
|
80
80
|
{
|
|
81
81
|
type: "button",
|
|
82
|
-
disabled:
|
|
83
|
-
onClick: () =>
|
|
82
|
+
disabled: c.isPending,
|
|
83
|
+
onClick: () => c.mutate(),
|
|
84
84
|
"data-person-access-save": !0,
|
|
85
85
|
className: "inline-flex h-7 items-center gap-1 rounded-md bg-nvr-cyan px-2.5 text-[11.5px] font-semibold text-white transition-opacity disabled:opacity-50",
|
|
86
86
|
children: [
|
|
87
|
-
|
|
87
|
+
c.isPending ? /* @__PURE__ */ t(le, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(ye, { className: "h-3 w-3" }),
|
|
88
88
|
" ",
|
|
89
89
|
"Save"
|
|
90
90
|
]
|
|
91
91
|
}
|
|
92
92
|
)
|
|
93
93
|
] }),
|
|
94
|
-
children: /* @__PURE__ */
|
|
95
|
-
/* @__PURE__ */
|
|
94
|
+
children: /* @__PURE__ */ n("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
95
|
+
/* @__PURE__ */ n("div", { className: "block", children: [
|
|
96
96
|
/* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Role" }),
|
|
97
97
|
/* @__PURE__ */ t(
|
|
98
|
-
|
|
98
|
+
re,
|
|
99
99
|
{
|
|
100
100
|
ariaLabel: "Role",
|
|
101
|
-
value:
|
|
102
|
-
onChange: (
|
|
103
|
-
options:
|
|
101
|
+
value: d.role,
|
|
102
|
+
onChange: (u) => b({ ...d, role: u }),
|
|
103
|
+
options: f,
|
|
104
104
|
className: "h-8 text-[12.5px]"
|
|
105
105
|
}
|
|
106
106
|
)
|
|
107
107
|
] }),
|
|
108
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ n("div", { className: "block", children: [
|
|
109
109
|
/* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Status" }),
|
|
110
110
|
/* @__PURE__ */ t(
|
|
111
|
-
|
|
111
|
+
re,
|
|
112
112
|
{
|
|
113
113
|
ariaLabel: "Status",
|
|
114
|
-
value:
|
|
115
|
-
onChange: (
|
|
114
|
+
value: d.status,
|
|
115
|
+
onChange: (u) => b({ ...d, status: u }),
|
|
116
116
|
options: [
|
|
117
117
|
{ value: "active", label: "Active" },
|
|
118
118
|
{ value: "inactive", label: "Inactive" },
|
|
@@ -122,14 +122,14 @@ function ft({ profile: e }) {
|
|
|
122
122
|
}
|
|
123
123
|
)
|
|
124
124
|
] }),
|
|
125
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ n("div", { className: "block sm:col-span-2", children: [
|
|
126
126
|
/* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Account type" }),
|
|
127
127
|
/* @__PURE__ */ t(
|
|
128
|
-
|
|
128
|
+
re,
|
|
129
129
|
{
|
|
130
130
|
ariaLabel: "Account type",
|
|
131
|
-
value:
|
|
132
|
-
onChange: (
|
|
131
|
+
value: d.account_kind,
|
|
132
|
+
onChange: (u) => b({ ...d, account_kind: u }),
|
|
133
133
|
options: Je,
|
|
134
134
|
className: "h-8 text-[12.5px]"
|
|
135
135
|
}
|
|
@@ -140,7 +140,7 @@ function ft({ profile: e }) {
|
|
|
140
140
|
}
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
|
-
const
|
|
143
|
+
const Ye = {
|
|
144
144
|
directory: "Directory sync",
|
|
145
145
|
retention: "Retention policy",
|
|
146
146
|
offboarding: "Offboarding",
|
|
@@ -149,23 +149,23 @@ const Ge = {
|
|
|
149
149
|
"legacy-redaction": "Legacy redaction job",
|
|
150
150
|
unknown: "Unknown"
|
|
151
151
|
};
|
|
152
|
-
function
|
|
153
|
-
var
|
|
154
|
-
const
|
|
152
|
+
function St({ profile: e }) {
|
|
153
|
+
var l;
|
|
154
|
+
const r = Q(), s = e.status === "suspended" || !!((l = e.admin) != null && l.is_redacted), { data: i } = E({
|
|
155
155
|
queryKey: ["nvr-user-suspension", e.id],
|
|
156
|
-
queryFn: () =>
|
|
157
|
-
enabled:
|
|
156
|
+
queryFn: () => r.request(O(`/users/${e.id}/suspension`)).then((h) => h.data).catch(() => null),
|
|
157
|
+
enabled: s,
|
|
158
158
|
staleTime: 6e4
|
|
159
159
|
});
|
|
160
|
-
return !
|
|
160
|
+
return !s || !i ? null : /* @__PURE__ */ n(
|
|
161
161
|
"div",
|
|
162
162
|
{
|
|
163
163
|
className: "rounded-lg border border-[#e9c46a] bg-[#fbefd9] px-4 py-3 text-[12.5px] text-[#6b4300] dark:border-[#7a5a14] dark:bg-[#3a2a0d] dark:text-[#f1b95c]",
|
|
164
164
|
"data-suspension-reason": i.source,
|
|
165
165
|
children: [
|
|
166
|
-
/* @__PURE__ */
|
|
166
|
+
/* @__PURE__ */ n("p", { className: "font-medium", children: [
|
|
167
167
|
"Cannot sign in — ",
|
|
168
|
-
|
|
168
|
+
Ye[i.source] ?? i.source,
|
|
169
169
|
i.at ? ` · ${new Date(i.at).toLocaleString()}` : "",
|
|
170
170
|
i.by ? ` · by ${i.by.name}` : ""
|
|
171
171
|
] }),
|
|
@@ -175,79 +175,79 @@ function yt({ profile: e }) {
|
|
|
175
175
|
}
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
|
-
const
|
|
179
|
-
function
|
|
180
|
-
const
|
|
178
|
+
const me = (e, r) => e.map((s) => ({ id: s.id, label: String(s[r] ?? s.id) }));
|
|
179
|
+
function Se(e) {
|
|
180
|
+
const r = Q(), s = e.display_field ?? "name", { data: i = [] } = E({
|
|
181
181
|
queryKey: ["nvr-scope-options", e.name],
|
|
182
|
-
queryFn: () =>
|
|
183
|
-
|
|
184
|
-
fields: `id,${
|
|
182
|
+
queryFn: () => r.request(
|
|
183
|
+
O(`/items/${e.target_collection}`, {
|
|
184
|
+
fields: `id,${s}`,
|
|
185
185
|
limit: 200,
|
|
186
186
|
...e.options_sort ? { sort: e.options_sort } : {}
|
|
187
187
|
})
|
|
188
|
-
).then((
|
|
188
|
+
).then((l) => me(l.data ?? [], s))
|
|
189
189
|
});
|
|
190
190
|
return i;
|
|
191
191
|
}
|
|
192
|
-
function
|
|
193
|
-
const i =
|
|
194
|
-
for (const
|
|
195
|
-
const
|
|
196
|
-
queryKey: ["nvr-scope-selected-labels", e.name,
|
|
192
|
+
function $e(e, r, s = []) {
|
|
193
|
+
const i = Q(), l = e.display_field ?? "name", h = Se(e), b = new Map(h.map((c) => [String(c.id), c.label]));
|
|
194
|
+
for (const c of s) b.set(String(c.id), c.label);
|
|
195
|
+
const d = r.filter((c) => !b.has(String(c))), { data: $ = [] } = E({
|
|
196
|
+
queryKey: ["nvr-scope-selected-labels", e.name, d.map(String).sort().join(",")],
|
|
197
197
|
queryFn: () => i.request(
|
|
198
|
-
|
|
199
|
-
fields: `id,${
|
|
198
|
+
O(`/items/${e.target_collection}`, {
|
|
199
|
+
fields: `id,${l}`,
|
|
200
200
|
limit: 100,
|
|
201
|
-
filter: JSON.stringify({ id: { _in:
|
|
201
|
+
filter: JSON.stringify({ id: { _in: d } })
|
|
202
202
|
})
|
|
203
|
-
).then((
|
|
204
|
-
enabled:
|
|
203
|
+
).then((c) => me(c.data ?? [], l)),
|
|
204
|
+
enabled: d.length > 0
|
|
205
205
|
});
|
|
206
|
-
for (const
|
|
207
|
-
return
|
|
206
|
+
for (const c of $) b.set(String(c.id), c.label);
|
|
207
|
+
return b;
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function be({
|
|
210
210
|
dimension: e,
|
|
211
|
-
selected:
|
|
212
|
-
accent:
|
|
211
|
+
selected: r,
|
|
212
|
+
accent: s,
|
|
213
213
|
disabled: i,
|
|
214
|
-
staged:
|
|
215
|
-
removing:
|
|
216
|
-
onToggle:
|
|
214
|
+
staged: l,
|
|
215
|
+
removing: h,
|
|
216
|
+
onToggle: b
|
|
217
217
|
}) {
|
|
218
|
-
const
|
|
219
|
-
queryKey: ["nvr-scope-search", e.name,
|
|
220
|
-
queryFn: () =>
|
|
221
|
-
|
|
222
|
-
fields: `id,${
|
|
218
|
+
const d = Q(), $ = e.display_field ?? "name", [c, f] = P(""), u = new Set((l ?? []).map(String)), D = new Set((h ?? []).map(String)), _ = Se(e), R = _.length > 24, { data: y = [], isFetching: v } = E({
|
|
219
|
+
queryKey: ["nvr-scope-search", e.name, c],
|
|
220
|
+
queryFn: () => d.request(
|
|
221
|
+
O(`/items/${e.target_collection}`, {
|
|
222
|
+
fields: `id,${$}`,
|
|
223
223
|
limit: 30,
|
|
224
|
-
filter: JSON.stringify({ [
|
|
224
|
+
filter: JSON.stringify({ [$]: { _contains: c } }),
|
|
225
225
|
...e.options_sort ? { sort: e.options_sort } : {}
|
|
226
226
|
})
|
|
227
|
-
).then((g) =>
|
|
228
|
-
enabled: R &&
|
|
227
|
+
).then((g) => me(g.data ?? [], $)),
|
|
228
|
+
enabled: R && c.trim().length > 0,
|
|
229
229
|
placeholderData: (g) => g
|
|
230
|
-
}),
|
|
231
|
-
|
|
232
|
-
), C =
|
|
233
|
-
return R ? /* @__PURE__ */
|
|
234
|
-
|
|
230
|
+
}), o = $e(e, r, y), N = new Set(r.map(String)), w = (g) => b(
|
|
231
|
+
N.has(String(g)) ? r.filter((L) => String(L) !== String(g)) : [...r, g]
|
|
232
|
+
), C = s === "amber" ? "border-amber-400 bg-amber-50 font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400" : "border-nvr-cyan bg-accent font-medium text-nvr-navy dark:text-nvr-cyan";
|
|
233
|
+
return R ? /* @__PURE__ */ n("div", { className: "max-w-xl", children: [
|
|
234
|
+
r.length > 0 && /* @__PURE__ */ t("div", { className: "mb-1.5 flex flex-wrap gap-1", children: r.map((g) => /* @__PURE__ */ n(
|
|
235
235
|
"span",
|
|
236
236
|
{
|
|
237
237
|
className: T(
|
|
238
238
|
"inline-flex items-center gap-1 rounded-full border py-0.5 pl-2.5 pr-1 text-[11.5px]",
|
|
239
239
|
C,
|
|
240
|
-
|
|
240
|
+
u.has(String(g)) && "border-dashed"
|
|
241
241
|
),
|
|
242
242
|
children: [
|
|
243
|
-
|
|
243
|
+
o.get(String(g)) ?? String(g),
|
|
244
244
|
/* @__PURE__ */ t(
|
|
245
245
|
"button",
|
|
246
246
|
{
|
|
247
247
|
type: "button",
|
|
248
248
|
disabled: i,
|
|
249
|
-
onClick: () =>
|
|
250
|
-
"aria-label": `Remove ${
|
|
249
|
+
onClick: () => w(g),
|
|
250
|
+
"aria-label": `Remove ${o.get(String(g)) ?? g}`,
|
|
251
251
|
className: "rounded-full px-1 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",
|
|
252
252
|
children: "×"
|
|
253
253
|
}
|
|
@@ -259,22 +259,22 @@ function ue({
|
|
|
259
259
|
/* @__PURE__ */ t(
|
|
260
260
|
"input",
|
|
261
261
|
{
|
|
262
|
-
value:
|
|
263
|
-
onChange: (g) =>
|
|
262
|
+
value: c,
|
|
263
|
+
onChange: (g) => f(g.target.value),
|
|
264
264
|
disabled: i,
|
|
265
265
|
placeholder: `Search ${e.label.toLowerCase()} to add…`,
|
|
266
266
|
className: "h-8 w-full rounded-md border border-slate-200 bg-white px-2.5 text-[12px] outline-none focus:border-nvr-cyan dark:border-border dark:bg-card"
|
|
267
267
|
}
|
|
268
268
|
),
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const L =
|
|
272
|
-
return /* @__PURE__ */
|
|
269
|
+
c.trim().length > 0 && /* @__PURE__ */ n("div", { className: "mt-1 max-h-44 overflow-y-auto rounded-md border border-slate-200 dark:border-border", children: [
|
|
270
|
+
y.map((g) => {
|
|
271
|
+
const L = N.has(String(g.id));
|
|
272
|
+
return /* @__PURE__ */ n(
|
|
273
273
|
"button",
|
|
274
274
|
{
|
|
275
275
|
type: "button",
|
|
276
276
|
disabled: i,
|
|
277
|
-
onClick: () =>
|
|
277
|
+
onClick: () => w(g.id),
|
|
278
278
|
className: T(
|
|
279
279
|
"flex w-full items-center justify-between px-2.5 py-1.5 text-left text-[12px] hover:bg-muted",
|
|
280
280
|
L ? "font-medium text-nvr-navy dark:text-nvr-cyan" : "text-slate-600 dark:text-slate-300"
|
|
@@ -287,22 +287,22 @@ function ue({
|
|
|
287
287
|
String(g.id)
|
|
288
288
|
);
|
|
289
289
|
}),
|
|
290
|
-
|
|
290
|
+
y.length === 0 && /* @__PURE__ */ t("p", { className: "px-2.5 py-2 text-[11.5px] text-slate-400", children: v ? "Searching…" : "No matches." })
|
|
291
291
|
] })
|
|
292
|
-
] }) : /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children:
|
|
293
|
-
const L =
|
|
292
|
+
] }) : /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: _.map((g) => {
|
|
293
|
+
const L = N.has(String(g.id));
|
|
294
294
|
return /* @__PURE__ */ t(
|
|
295
295
|
"button",
|
|
296
296
|
{
|
|
297
297
|
type: "button",
|
|
298
298
|
"aria-pressed": L,
|
|
299
299
|
disabled: i,
|
|
300
|
-
onClick: () =>
|
|
300
|
+
onClick: () => w(g.id),
|
|
301
301
|
className: T(
|
|
302
302
|
// No colour transition: a press shows its new state at once.
|
|
303
303
|
"rounded-full border px-2.5 py-0.5 text-[11.5px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:cursor-wait",
|
|
304
|
-
L ? C :
|
|
305
|
-
L &&
|
|
304
|
+
L ? C : D.has(String(g.id)) ? "border-dashed border-amber-400 text-amber-800 line-through decoration-amber-500/70 dark:border-amber-500/60 dark:text-amber-300" : "border-slate-200 text-slate-600 hover:border-slate-300 dark:border-border dark:text-slate-400 dark:hover:border-slate-500",
|
|
305
|
+
L && u.has(String(g.id)) && "border-dashed"
|
|
306
306
|
),
|
|
307
307
|
children: g.label
|
|
308
308
|
},
|
|
@@ -310,222 +310,222 @@ function ue({
|
|
|
310
310
|
);
|
|
311
311
|
}) });
|
|
312
312
|
}
|
|
313
|
-
const
|
|
314
|
-
if (e.length !==
|
|
315
|
-
const
|
|
316
|
-
return
|
|
317
|
-
},
|
|
318
|
-
function
|
|
313
|
+
const Z = (e, r) => {
|
|
314
|
+
if (e.length !== r.length) return !1;
|
|
315
|
+
const s = new Set(e.map(String));
|
|
316
|
+
return r.every((i) => s.has(String(i)));
|
|
317
|
+
}, Ve = (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
|
+
function ne(e) {
|
|
319
319
|
return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e.at(-1)}`;
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function $t({
|
|
322
322
|
userId: e,
|
|
323
|
-
previewDelayMs:
|
|
323
|
+
previewDelayMs: r = 400
|
|
324
324
|
}) {
|
|
325
|
-
const
|
|
326
|
-
queryKey:
|
|
327
|
-
queryFn: () =>
|
|
328
|
-
}), [
|
|
329
|
-
|
|
330
|
-
const
|
|
325
|
+
const s = Q(), i = oe(), l = de(() => ["nvr-user-scopes", e], [e]), { data: h } = E({
|
|
326
|
+
queryKey: l,
|
|
327
|
+
queryFn: () => s.request(O(`/user-scopes/${e}`)).then((a) => a.data)
|
|
328
|
+
}), [b, d] = P({}), [$, c] = P({}), f = X({}), u = X({}), D = X({});
|
|
329
|
+
pe(() => {
|
|
330
|
+
const a = D.current;
|
|
331
331
|
return () => {
|
|
332
|
-
for (const
|
|
332
|
+
for (const p of Object.values(a)) clearTimeout(p);
|
|
333
333
|
};
|
|
334
334
|
}, []);
|
|
335
|
-
const
|
|
336
|
-
clearTimeout(
|
|
337
|
-
const { [
|
|
338
|
-
return
|
|
339
|
-
}),
|
|
340
|
-
}, R = (
|
|
341
|
-
if (!
|
|
342
|
-
const
|
|
343
|
-
return { ...
|
|
344
|
-
}),
|
|
335
|
+
const _ = (a, p) => {
|
|
336
|
+
clearTimeout(D.current[a]), c((S) => {
|
|
337
|
+
const { [a]: k, ...q } = S;
|
|
338
|
+
return p ? { ...q, [a]: p } : q;
|
|
339
|
+
}), p === "saved" && (D.current[a] = setTimeout(() => _(a, null), 2400));
|
|
340
|
+
}, R = (a) => i.setQueryData(l, (p) => {
|
|
341
|
+
if (!p) return p;
|
|
342
|
+
const S = a.mode === "restrict" ? "restricted" : "defaults";
|
|
343
|
+
return { ...p, [S]: { ...p[S], [a.dimension]: a.values } };
|
|
344
|
+
}), y = j({
|
|
345
345
|
// One person's scope saves go out one after another, in click order.
|
|
346
346
|
scope: { id: `nvr-user-scopes:${e}` },
|
|
347
|
-
mutationFn: (
|
|
348
|
-
onMutate: (
|
|
349
|
-
var
|
|
350
|
-
const
|
|
351
|
-
return
|
|
347
|
+
mutationFn: (a) => s.request(Me(`/user-scopes/${e}`, a)),
|
|
348
|
+
onMutate: (a) => {
|
|
349
|
+
var q, G;
|
|
350
|
+
const p = `${a.dimension}:${a.mode}`, S = a.mode === "restrict" ? "restricted" : "defaults", k = ((G = (q = i.getQueryData(l)) == null ? void 0 : q[S]) == null ? void 0 : G[a.dimension]) ?? [];
|
|
351
|
+
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
352
|
},
|
|
353
|
-
onSuccess: (
|
|
354
|
-
onError: (
|
|
355
|
-
var
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
if (!
|
|
359
|
-
const { [
|
|
360
|
-
return
|
|
361
|
-
}),
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
{ retry: () =>
|
|
353
|
+
onSuccess: (a, p) => R(p),
|
|
354
|
+
onError: (a, p, S) => {
|
|
355
|
+
var B, ue;
|
|
356
|
+
const k = `${p.dimension}:${p.mode}`, q = p.mode === "restrict" ? "restricted" : "defaults", G = ((ue = (B = i.getQueryData(l)) == null ? void 0 : B[q]) == null ? void 0 : ue[p.dimension]) ?? [];
|
|
357
|
+
S && Z(G, p.values) && R({ ...p, values: S.before }), d((W) => {
|
|
358
|
+
if (!W[k] || !Z(W[k], p.values)) return W;
|
|
359
|
+
const { [k]: st, ...Ce } = W;
|
|
360
|
+
return Ce;
|
|
361
|
+
}), f.current[k] = p, se(
|
|
362
|
+
a,
|
|
363
|
+
p.mode === "restrict" ? "Could not apply the restriction" : "Could not save the default",
|
|
364
|
+
{ retry: () => y.mutate(p) }
|
|
365
365
|
);
|
|
366
366
|
},
|
|
367
|
-
onSettled: (
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
if (!
|
|
371
|
-
const { [
|
|
372
|
-
return
|
|
373
|
-
}),
|
|
367
|
+
onSettled: (a, p, S) => {
|
|
368
|
+
const k = `${S.dimension}:${S.mode}`;
|
|
369
|
+
u.current[k] = Math.max(0, (u.current[k] ?? 1) - 1), p || d((q) => {
|
|
370
|
+
if (!q[k] || !Z(q[k], S.values)) return q;
|
|
371
|
+
const { [k]: G, ...B } = q;
|
|
372
|
+
return B;
|
|
373
|
+
}), 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
374
|
}
|
|
375
|
-
}),
|
|
376
|
-
|
|
377
|
-
if (!
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
dimension:
|
|
382
|
-
values:
|
|
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 ? Ve(o.dimension, o.values) : null;
|
|
376
|
+
pe(() => {
|
|
377
|
+
if (!o || !A) return;
|
|
378
|
+
const a = ++m.current, p = setTimeout(() => {
|
|
379
|
+
s.request(
|
|
380
|
+
H(`/user-scopes/${e}/impact`, {
|
|
381
|
+
dimension: o.dimension,
|
|
382
|
+
values: o.values
|
|
383
383
|
})
|
|
384
384
|
).then(
|
|
385
|
-
(
|
|
386
|
-
|
|
385
|
+
(S) => {
|
|
386
|
+
a === m.current && C({ key: A, answer: S.data, error: null });
|
|
387
387
|
},
|
|
388
|
-
(
|
|
389
|
-
|
|
388
|
+
(S) => {
|
|
389
|
+
a === m.current && C({ key: A, answer: null, error: S });
|
|
390
390
|
}
|
|
391
391
|
);
|
|
392
|
-
},
|
|
393
|
-
return () => clearTimeout(
|
|
394
|
-
}, [
|
|
395
|
-
const
|
|
396
|
-
if (
|
|
397
|
-
|
|
392
|
+
}, r);
|
|
393
|
+
return () => clearTimeout(p);
|
|
394
|
+
}, [A, g, s, e, r]);
|
|
395
|
+
const K = (a, p) => {
|
|
396
|
+
if (Z(p, v(a, "restrict"))) {
|
|
397
|
+
m.current++, N(null), C(null);
|
|
398
398
|
return;
|
|
399
399
|
}
|
|
400
|
-
|
|
401
|
-
},
|
|
402
|
-
|
|
403
|
-
},
|
|
404
|
-
|
|
405
|
-
}, x = (
|
|
406
|
-
const
|
|
407
|
-
|
|
400
|
+
o && o.dimension !== a && C(null), N({ dimension: a, values: p });
|
|
401
|
+
}, U = () => {
|
|
402
|
+
m.current++, N(null), C(null);
|
|
403
|
+
}, V = () => {
|
|
404
|
+
o && (y.mutate({ dimension: o.dimension, mode: "restrict", values: o.values }), U());
|
|
405
|
+
}, x = (a) => {
|
|
406
|
+
const p = f.current[a];
|
|
407
|
+
p && y.mutate(p);
|
|
408
408
|
};
|
|
409
|
-
return !
|
|
410
|
-
|
|
409
|
+
return !h || h.dimensions.length === 0 ? null : /* @__PURE__ */ t(
|
|
410
|
+
Y,
|
|
411
411
|
{
|
|
412
|
-
icon: /* @__PURE__ */ t(
|
|
412
|
+
icon: /* @__PURE__ */ t(Re, { className: "h-4 w-4" }),
|
|
413
413
|
title: "Scopes",
|
|
414
414
|
hint: "Defaults pre-fill their filters; restrictions limit what they can see",
|
|
415
415
|
testId: "scopes",
|
|
416
|
-
children: /* @__PURE__ */ t("div", { className: "space-y-5", children:
|
|
417
|
-
const
|
|
418
|
-
return /* @__PURE__ */
|
|
419
|
-
/* @__PURE__ */ t("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children:
|
|
420
|
-
/* @__PURE__ */
|
|
421
|
-
/* @__PURE__ */
|
|
422
|
-
/* @__PURE__ */
|
|
416
|
+
children: /* @__PURE__ */ t("div", { className: "space-y-5", children: h.dimensions.map((a) => {
|
|
417
|
+
const p = b[`${a.name}:restrict`] != null, S = (o == null ? void 0 : o.dimension) === a.name;
|
|
418
|
+
return /* @__PURE__ */ n("div", { children: [
|
|
419
|
+
/* @__PURE__ */ t("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: a.label }),
|
|
420
|
+
/* @__PURE__ */ n("div", { className: "mt-1.5 space-y-2.5", children: [
|
|
421
|
+
/* @__PURE__ */ n("div", { "data-scope-defaults": a.name, children: [
|
|
422
|
+
/* @__PURE__ */ n("p", { className: "mb-1 flex min-h-4 items-center gap-1.5 text-[11px] font-medium text-slate-600 dark:text-slate-300", children: [
|
|
423
423
|
"Defaults",
|
|
424
424
|
/* @__PURE__ */ t("span", { className: "font-normal text-slate-500 dark:text-slate-400", children: "pre-filled in their filters" }),
|
|
425
425
|
/* @__PURE__ */ t(
|
|
426
|
-
|
|
426
|
+
fe,
|
|
427
427
|
{
|
|
428
|
-
slot: `${
|
|
429
|
-
status:
|
|
428
|
+
slot: `${a.name}:default`,
|
|
429
|
+
status: $[`${a.name}:default`],
|
|
430
430
|
onRetry: x
|
|
431
431
|
}
|
|
432
432
|
)
|
|
433
433
|
] }),
|
|
434
434
|
/* @__PURE__ */ t(
|
|
435
|
-
|
|
435
|
+
be,
|
|
436
436
|
{
|
|
437
|
-
dimension:
|
|
438
|
-
selected:
|
|
437
|
+
dimension: a,
|
|
438
|
+
selected: v(a.name, "default"),
|
|
439
439
|
accent: "cyan",
|
|
440
|
-
onToggle: (
|
|
440
|
+
onToggle: (k) => y.mutate({ dimension: a.name, mode: "default", values: k })
|
|
441
441
|
}
|
|
442
442
|
)
|
|
443
443
|
] }),
|
|
444
|
-
/* @__PURE__ */
|
|
445
|
-
/* @__PURE__ */
|
|
446
|
-
/* @__PURE__ */ t(
|
|
444
|
+
/* @__PURE__ */ n("div", { "data-scope-restrict": a.name, children: [
|
|
445
|
+
/* @__PURE__ */ n("p", { className: "mb-1 flex min-h-4 items-center gap-1.5 text-[11px] font-medium text-slate-600 dark:text-slate-300", children: [
|
|
446
|
+
/* @__PURE__ */ t(ve, { className: "h-3 w-3 text-amber-500", "aria-hidden": !0 }),
|
|
447
447
|
"Restricted to",
|
|
448
|
-
|
|
448
|
+
v(a.name, "restrict").length === 0 && !S ? /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: [
|
|
449
449
|
"none — sees every ",
|
|
450
|
-
|
|
450
|
+
a.label.toLowerCase()
|
|
451
451
|
] }) : /* @__PURE__ */ t("span", { className: "font-normal text-slate-500 dark:text-slate-400", children: "enforced on every read" }),
|
|
452
452
|
/* @__PURE__ */ t(
|
|
453
|
-
|
|
453
|
+
fe,
|
|
454
454
|
{
|
|
455
|
-
slot: `${
|
|
456
|
-
status:
|
|
455
|
+
slot: `${a.name}:restrict`,
|
|
456
|
+
status: $[`${a.name}:restrict`],
|
|
457
457
|
onRetry: x
|
|
458
458
|
}
|
|
459
459
|
)
|
|
460
460
|
] }),
|
|
461
461
|
/* @__PURE__ */ t(
|
|
462
|
-
|
|
462
|
+
be,
|
|
463
463
|
{
|
|
464
|
-
dimension:
|
|
465
|
-
selected:
|
|
464
|
+
dimension: a,
|
|
465
|
+
selected: S && o ? o.values : v(a.name, "restrict"),
|
|
466
466
|
accent: "amber",
|
|
467
|
-
disabled:
|
|
468
|
-
staged:
|
|
469
|
-
(
|
|
467
|
+
disabled: p,
|
|
468
|
+
staged: S && o ? o.values.filter(
|
|
469
|
+
(k) => !v(a.name, "restrict").some((q) => String(q) === String(k))
|
|
470
470
|
) : void 0,
|
|
471
|
-
removing:
|
|
472
|
-
(
|
|
471
|
+
removing: S && o ? v(a.name, "restrict").filter(
|
|
472
|
+
(k) => !o.values.some((q) => String(q) === String(k))
|
|
473
473
|
) : void 0,
|
|
474
|
-
onToggle: (
|
|
474
|
+
onToggle: (k) => K(a.name, k)
|
|
475
475
|
}
|
|
476
476
|
),
|
|
477
|
-
|
|
478
|
-
|
|
477
|
+
S && o && /* @__PURE__ */ t(
|
|
478
|
+
We,
|
|
479
479
|
{
|
|
480
|
-
dimension:
|
|
481
|
-
saved:
|
|
482
|
-
values:
|
|
483
|
-
result: (
|
|
484
|
-
stale:
|
|
485
|
-
onApply:
|
|
486
|
-
onCancel:
|
|
487
|
-
onRetry: () => L((
|
|
480
|
+
dimension: a,
|
|
481
|
+
saved: v(a.name, "restrict"),
|
|
482
|
+
values: o.values,
|
|
483
|
+
result: (w == null ? void 0 : w.key) === A ? w : null,
|
|
484
|
+
stale: w && w.key !== A ? w.answer : null,
|
|
485
|
+
onApply: V,
|
|
486
|
+
onCancel: U,
|
|
487
|
+
onRetry: () => L((k) => k + 1)
|
|
488
488
|
}
|
|
489
489
|
)
|
|
490
490
|
] })
|
|
491
491
|
] })
|
|
492
|
-
] },
|
|
492
|
+
] }, a.name);
|
|
493
493
|
}) })
|
|
494
494
|
}
|
|
495
495
|
);
|
|
496
496
|
}
|
|
497
|
-
function
|
|
497
|
+
function fe({
|
|
498
498
|
slot: e,
|
|
499
|
-
status:
|
|
500
|
-
onRetry:
|
|
499
|
+
status: r,
|
|
500
|
+
onRetry: s
|
|
501
501
|
}) {
|
|
502
|
-
return /* @__PURE__ */
|
|
502
|
+
return /* @__PURE__ */ n(
|
|
503
503
|
"span",
|
|
504
504
|
{
|
|
505
505
|
"data-scope-status": e,
|
|
506
506
|
"aria-live": "polite",
|
|
507
507
|
className: T(
|
|
508
508
|
"inline-flex items-center gap-1 font-normal",
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
509
|
+
r === "saved" && "text-emerald-700 dark:text-emerald-400",
|
|
510
|
+
r === "failed" && "font-medium text-red-700 dark:text-red-400",
|
|
511
|
+
r === "saving" && "text-slate-600 dark:text-slate-300"
|
|
512
512
|
),
|
|
513
513
|
children: [
|
|
514
|
-
|
|
515
|
-
/* @__PURE__ */ t(
|
|
514
|
+
r === "saving" && /* @__PURE__ */ n(z, { children: [
|
|
515
|
+
/* @__PURE__ */ t(le, { className: "h-3 w-3 animate-spin motion-reduce:animate-none", "aria-hidden": !0 }),
|
|
516
516
|
"Saving…"
|
|
517
517
|
] }),
|
|
518
|
-
|
|
519
|
-
/* @__PURE__ */ t(
|
|
518
|
+
r === "saved" && /* @__PURE__ */ n(z, { children: [
|
|
519
|
+
/* @__PURE__ */ t(ye, { className: "h-3 w-3", "aria-hidden": !0 }),
|
|
520
520
|
"Saved"
|
|
521
521
|
] }),
|
|
522
|
-
|
|
522
|
+
r === "failed" && /* @__PURE__ */ n(z, { children: [
|
|
523
523
|
"Not saved",
|
|
524
524
|
/* @__PURE__ */ t(
|
|
525
525
|
"button",
|
|
526
526
|
{
|
|
527
527
|
type: "button",
|
|
528
|
-
onClick: () =>
|
|
528
|
+
onClick: () => s(e),
|
|
529
529
|
className: "rounded font-medium underline decoration-dotted underline-offset-2 hover:decoration-solid focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-500/40",
|
|
530
530
|
children: "Retry"
|
|
531
531
|
}
|
|
@@ -535,84 +535,84 @@ function be({
|
|
|
535
535
|
}
|
|
536
536
|
);
|
|
537
537
|
}
|
|
538
|
-
function
|
|
538
|
+
function We({
|
|
539
539
|
dimension: e,
|
|
540
|
-
saved:
|
|
541
|
-
values:
|
|
540
|
+
saved: r,
|
|
541
|
+
values: s,
|
|
542
542
|
result: i,
|
|
543
|
-
stale:
|
|
544
|
-
onApply:
|
|
545
|
-
onCancel:
|
|
546
|
-
onRetry:
|
|
543
|
+
stale: l,
|
|
544
|
+
onApply: h,
|
|
545
|
+
onCancel: b,
|
|
546
|
+
onRetry: d
|
|
547
547
|
}) {
|
|
548
|
-
var
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
R.length > 0 ? `${
|
|
552
|
-
].filter(Boolean).join("; "), L =
|
|
553
|
-
return /* @__PURE__ */
|
|
548
|
+
var U, V;
|
|
549
|
+
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
|
+
_.length > 0 ? `Also let them see ${C(_)}` : null,
|
|
551
|
+
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)), K = A.length <= 2 ? `they lose all ${ne(A)}` : `they lose ${A.length} record types`;
|
|
553
|
+
return /* @__PURE__ */ n(
|
|
554
554
|
"div",
|
|
555
555
|
{
|
|
556
|
-
"data-scope-preview":
|
|
556
|
+
"data-scope-preview": v,
|
|
557
557
|
className: "mt-2 rounded-md border border-amber-300 bg-amber-50 text-[12px] text-amber-950 dark:border-amber-500/30 dark:bg-amber-400/[0.07] dark:text-amber-50",
|
|
558
558
|
children: [
|
|
559
|
-
/* @__PURE__ */
|
|
560
|
-
/* @__PURE__ */
|
|
559
|
+
/* @__PURE__ */ n("div", { className: "flex items-start gap-3 px-3 pt-2.5", children: [
|
|
560
|
+
/* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
|
|
561
561
|
/* @__PURE__ */ t("p", { className: "font-semibold", children: g }),
|
|
562
562
|
/* @__PURE__ */ t("p", { className: "mt-0.5 text-amber-900 dark:text-amber-200", children: L })
|
|
563
563
|
] }),
|
|
564
|
-
(
|
|
565
|
-
/* @__PURE__ */ t(
|
|
566
|
-
|
|
564
|
+
(v === "loading" || v === "updating") && /* @__PURE__ */ n("span", { className: "mt-0.5 inline-flex shrink-0 items-center gap-1 text-[11px] text-amber-900 dark:text-amber-200", children: [
|
|
565
|
+
/* @__PURE__ */ t(le, { className: "h-3 w-3 animate-spin motion-reduce:animate-none", "aria-hidden": !0 }),
|
|
566
|
+
v === "loading" ? "Counting records…" : "Recounting — showing the last count"
|
|
567
567
|
] })
|
|
568
568
|
] }),
|
|
569
|
-
|
|
569
|
+
N.length > 0 && /* @__PURE__ */ n(
|
|
570
570
|
"p",
|
|
571
571
|
{
|
|
572
572
|
className: T(
|
|
573
573
|
"mx-3 mt-2 flex items-start gap-1.5 font-semibold text-red-700 dark:text-red-300",
|
|
574
|
-
|
|
574
|
+
m
|
|
575
575
|
),
|
|
576
576
|
"data-scope-blind": !0,
|
|
577
577
|
children: [
|
|
578
|
-
/* @__PURE__ */ t(
|
|
578
|
+
/* @__PURE__ */ t(ve, { className: "mt-px h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
|
|
579
579
|
"They would see nothing in ",
|
|
580
|
-
|
|
580
|
+
ne(N.map((x) => x.label ?? ie(x.collection))),
|
|
581
581
|
"."
|
|
582
582
|
]
|
|
583
583
|
}
|
|
584
584
|
),
|
|
585
|
-
|
|
585
|
+
v === "error" ? /* @__PURE__ */ t("div", { className: "mx-3 mt-2 text-amber-900 dark:text-amber-200", children: /* @__PURE__ */ n("p", { children: [
|
|
586
586
|
"Couldn’t count what changes. Count again, or check the ",
|
|
587
|
-
|
|
587
|
+
ge(f),
|
|
588
588
|
" above before applying."
|
|
589
|
-
] }) }) :
|
|
589
|
+
] }) }) : o.length > 0 ? /* @__PURE__ */ t(
|
|
590
590
|
"ul",
|
|
591
591
|
{
|
|
592
592
|
className: T(
|
|
593
593
|
"mx-3 mt-2 w-fit max-w-[calc(100%-1.5rem)] border-t border-amber-200 dark:border-amber-500/20",
|
|
594
|
-
|
|
594
|
+
m
|
|
595
595
|
),
|
|
596
|
-
"aria-busy":
|
|
597
|
-
children:
|
|
596
|
+
"aria-busy": v === "updating",
|
|
597
|
+
children: o.map((x) => /* @__PURE__ */ t(Xe, { row: x }, x.collection))
|
|
598
598
|
}
|
|
599
|
-
) :
|
|
599
|
+
) : v === "loading" ? /* @__PURE__ */ t("div", { className: "mx-3 mt-2 space-y-1.5", "aria-hidden": !0, children: [0, 1, 2].map((x) => /* @__PURE__ */ t("div", { className: "h-4 max-w-md rounded bg-amber-200/60 dark:bg-amber-400/10" }, x)) }) : /* @__PURE__ */ n("p", { className: "mx-3 mt-2", children: [
|
|
600
600
|
"No records route to ",
|
|
601
|
-
|
|
601
|
+
ge(f),
|
|
602
602
|
", so nothing they see changes."
|
|
603
603
|
] }),
|
|
604
|
-
(((
|
|
604
|
+
(((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
605
|
"Not counted in time: ",
|
|
606
|
-
(
|
|
606
|
+
(V = y == null ? void 0 : y.partial) == null ? void 0 : V.map((x) => x.label).join(", "),
|
|
607
607
|
"."
|
|
608
608
|
] }),
|
|
609
|
-
/* @__PURE__ */
|
|
610
|
-
|
|
609
|
+
/* @__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(z, { children: [
|
|
611
611
|
/* @__PURE__ */ t(
|
|
612
612
|
"button",
|
|
613
613
|
{
|
|
614
614
|
type: "button",
|
|
615
|
-
onClick:
|
|
615
|
+
onClick: d,
|
|
616
616
|
className: "inline-flex h-7 items-center rounded-md bg-amber-700 px-3 text-[11.5px] font-medium text-[#fff] hover:bg-amber-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50 focus-visible:ring-offset-1 dark:bg-amber-400 dark:text-[#1c1003] dark:hover:bg-amber-300",
|
|
617
617
|
children: "Count again"
|
|
618
618
|
}
|
|
@@ -622,21 +622,21 @@ function Ve({
|
|
|
622
622
|
{
|
|
623
623
|
type: "button",
|
|
624
624
|
"data-scope-apply": !0,
|
|
625
|
-
onClick:
|
|
625
|
+
onClick: h,
|
|
626
626
|
className: "inline-flex h-7 items-center rounded-md border border-amber-400 px-3 text-[11.5px] font-medium text-amber-900 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40 dark:border-amber-500/50 dark:text-amber-200 dark:hover:bg-amber-400/10",
|
|
627
627
|
children: "Apply without counts"
|
|
628
628
|
}
|
|
629
629
|
)
|
|
630
|
-
] }) :
|
|
631
|
-
|
|
630
|
+
] }) : N.length > 0 && v === "ready" ? /* @__PURE__ */ t("span", { "data-scope-apply-danger": !0, children: /* @__PURE__ */ n(
|
|
631
|
+
I,
|
|
632
632
|
{
|
|
633
|
-
onConfirm:
|
|
634
|
-
confirmLabel: `Press again — ${
|
|
633
|
+
onConfirm: h,
|
|
634
|
+
confirmLabel: `Press again — ${K}`,
|
|
635
635
|
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
636
|
armedClassName: "bg-red-700 dark:bg-red-800",
|
|
637
637
|
children: [
|
|
638
638
|
"Apply — ",
|
|
639
|
-
|
|
639
|
+
K
|
|
640
640
|
]
|
|
641
641
|
}
|
|
642
642
|
) }) : /* @__PURE__ */ t(
|
|
@@ -645,16 +645,16 @@ function Ve({
|
|
|
645
645
|
type: "button",
|
|
646
646
|
"data-scope-apply": !0,
|
|
647
647
|
disabled: !i,
|
|
648
|
-
onClick:
|
|
648
|
+
onClick: h,
|
|
649
649
|
className: "inline-flex h-7 items-center rounded-md bg-amber-700 px-3 text-[11.5px] font-medium text-[#fff] hover:bg-amber-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:bg-amber-700/45 dark:bg-amber-400 dark:text-[#1c1003] dark:hover:bg-amber-300 dark:disabled:bg-amber-400/40",
|
|
650
|
-
children:
|
|
650
|
+
children: w ? "Remove restriction" : "Apply restriction"
|
|
651
651
|
}
|
|
652
652
|
),
|
|
653
653
|
/* @__PURE__ */ t(
|
|
654
654
|
"button",
|
|
655
655
|
{
|
|
656
656
|
type: "button",
|
|
657
|
-
onClick:
|
|
657
|
+
onClick: b,
|
|
658
658
|
className: "inline-flex h-7 items-center rounded-md px-2 text-[11.5px] text-amber-900 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40 dark:text-amber-200 dark:hover:bg-amber-400/10",
|
|
659
659
|
children: "Cancel"
|
|
660
660
|
}
|
|
@@ -665,30 +665,30 @@ function Ve({
|
|
|
665
665
|
}
|
|
666
666
|
);
|
|
667
667
|
}
|
|
668
|
-
function
|
|
669
|
-
return /* @__PURE__ */ t(
|
|
670
|
-
|
|
671
|
-
/^\d+$/.test(
|
|
668
|
+
function xe({ items: e }) {
|
|
669
|
+
return /* @__PURE__ */ t(z, { children: e.map((r, s) => /* @__PURE__ */ n("span", { children: [
|
|
670
|
+
s > 0 && ", ",
|
|
671
|
+
/^\d+$/.test(r.label) ? /* @__PURE__ */ n("span", { className: "font-mono text-[10.5px]", children: [
|
|
672
672
|
"#",
|
|
673
|
-
|
|
674
|
-
] }) :
|
|
675
|
-
] },
|
|
673
|
+
r.label
|
|
674
|
+
] }) : r.label
|
|
675
|
+
] }, r.id)) });
|
|
676
676
|
}
|
|
677
|
-
function
|
|
678
|
-
var
|
|
679
|
-
const
|
|
680
|
-
return /* @__PURE__ */
|
|
677
|
+
function Xe({ row: e }) {
|
|
678
|
+
var b, d, $, c;
|
|
679
|
+
const r = e.label ?? ie(e.collection), s = e.gained ?? 0, i = e.lost ?? 0, l = e.proposed - e.current, h = (f, u) => f > u ? ` and ${M(f - u)} more` : "";
|
|
680
|
+
return /* @__PURE__ */ n(
|
|
681
681
|
"li",
|
|
682
682
|
{
|
|
683
683
|
className: "grid grid-cols-[minmax(9rem,16rem)_9.5rem_5.5rem] items-baseline justify-start gap-x-4 border-b border-amber-200 py-1.5 dark:border-amber-500/20",
|
|
684
684
|
"data-scope-impact-row": e.collection,
|
|
685
685
|
children: [
|
|
686
|
-
/* @__PURE__ */ t("span", { className: "min-w-0 truncate font-medium", children:
|
|
687
|
-
/* @__PURE__ */
|
|
688
|
-
e.proposed === 0 && e.total > 0 ? /* @__PURE__ */ t("span", { className: "font-semibold text-red-700 dark:text-red-300", children: "none" }) :
|
|
689
|
-
/* @__PURE__ */
|
|
686
|
+
/* @__PURE__ */ t("span", { className: "min-w-0 truncate font-medium", children: r }),
|
|
687
|
+
/* @__PURE__ */ n("span", { className: "text-right tabular-nums", children: [
|
|
688
|
+
e.proposed === 0 && e.total > 0 ? /* @__PURE__ */ t("span", { className: "font-semibold text-red-700 dark:text-red-300", children: "none" }) : M(e.proposed),
|
|
689
|
+
/* @__PURE__ */ n("span", { className: "text-amber-900 dark:text-amber-200", children: [
|
|
690
690
|
" of ",
|
|
691
|
-
|
|
691
|
+
M(e.total)
|
|
692
692
|
] })
|
|
693
693
|
] }),
|
|
694
694
|
/* @__PURE__ */ t(
|
|
@@ -696,32 +696,32 @@ function We({ row: e }) {
|
|
|
696
696
|
{
|
|
697
697
|
className: T(
|
|
698
698
|
"text-right text-[11.5px] tabular-nums",
|
|
699
|
-
|
|
699
|
+
l > 0 ? "font-semibold text-emerald-700 dark:text-emerald-400" : l < 0 ? "font-semibold text-red-700 dark:text-red-400" : "text-amber-900 dark:text-amber-200"
|
|
700
700
|
),
|
|
701
|
-
children:
|
|
701
|
+
children: l > 0 ? `+${M(l)}` : l < 0 ? `−${M(-l)}` : "no change"
|
|
702
702
|
}
|
|
703
703
|
),
|
|
704
|
-
|
|
704
|
+
s > 0 && (((b = e.gained_sample) == null ? void 0 : b.length) ?? 0) > 0 && /* @__PURE__ */ n(
|
|
705
705
|
"p",
|
|
706
706
|
{
|
|
707
707
|
className: "col-span-3 mt-0.5 truncate text-[11px] text-amber-900 dark:text-amber-200",
|
|
708
|
-
"data-scope-impact-gained":
|
|
708
|
+
"data-scope-impact-gained": s,
|
|
709
709
|
children: [
|
|
710
710
|
"Newly visible: ",
|
|
711
|
-
/* @__PURE__ */ t(
|
|
712
|
-
|
|
711
|
+
/* @__PURE__ */ t(xe, { items: e.gained_sample ?? [] }),
|
|
712
|
+
h(s, ((d = e.gained_sample) == null ? void 0 : d.length) ?? 0)
|
|
713
713
|
]
|
|
714
714
|
}
|
|
715
715
|
),
|
|
716
|
-
i > 0 && (((
|
|
716
|
+
i > 0 && ((($ = e.lost_sample) == null ? void 0 : $.length) ?? 0) > 0 && /* @__PURE__ */ n(
|
|
717
717
|
"p",
|
|
718
718
|
{
|
|
719
719
|
className: "col-span-3 mt-0.5 truncate text-[11px] text-amber-900 dark:text-amber-200",
|
|
720
720
|
"data-scope-impact-lost": i,
|
|
721
721
|
children: [
|
|
722
722
|
"No longer visible: ",
|
|
723
|
-
/* @__PURE__ */ t(
|
|
724
|
-
|
|
723
|
+
/* @__PURE__ */ t(xe, { items: e.lost_sample ?? [] }),
|
|
724
|
+
h(i, ((c = e.lost_sample) == null ? void 0 : c.length) ?? 0)
|
|
725
725
|
]
|
|
726
726
|
}
|
|
727
727
|
)
|
|
@@ -729,7 +729,7 @@ function We({ row: e }) {
|
|
|
729
729
|
}
|
|
730
730
|
);
|
|
731
731
|
}
|
|
732
|
-
const
|
|
732
|
+
const Ze = [
|
|
733
733
|
{ key: "first_name", label: "First name" },
|
|
734
734
|
{ key: "last_name", label: "Last name" },
|
|
735
735
|
{ key: "title", label: "Title" },
|
|
@@ -743,87 +743,87 @@ const Xe = [
|
|
|
743
743
|
{ key: "employee_id", label: "Employee id" },
|
|
744
744
|
{ key: "preferred_language", label: "Language" }
|
|
745
745
|
];
|
|
746
|
-
function
|
|
747
|
-
var
|
|
748
|
-
const
|
|
746
|
+
function Ct({ profile: e }) {
|
|
747
|
+
var _, R, y, v;
|
|
748
|
+
const r = Q(), s = oe(), i = ce(e.id), l = E({
|
|
749
749
|
queryKey: ["nvr-directory-status"],
|
|
750
|
-
queryFn: () =>
|
|
750
|
+
queryFn: () => r.request(O("/directory/status")).then((o) => o.data),
|
|
751
751
|
staleTime: 5 * 6e4
|
|
752
|
-
}),
|
|
752
|
+
}), h = E({
|
|
753
753
|
queryKey: ["nvr-directory-entry", e.email],
|
|
754
|
-
queryFn: () =>
|
|
755
|
-
if ((
|
|
756
|
-
throw
|
|
754
|
+
queryFn: () => r.request(O(`/directory/users/${encodeURIComponent(e.email)}`)).then((o) => o.data).catch((o) => {
|
|
755
|
+
if ((o == null ? void 0 : o.status) === 404) return null;
|
|
756
|
+
throw o;
|
|
757
757
|
}),
|
|
758
|
-
enabled: !!((
|
|
758
|
+
enabled: !!((_ = l.data) != null && _.granted && e.email),
|
|
759
759
|
staleTime: 6e4
|
|
760
|
-
}),
|
|
761
|
-
mutationFn: () =>
|
|
762
|
-
onSuccess: ({ summary:
|
|
763
|
-
i(),
|
|
764
|
-
`${
|
|
760
|
+
}), b = j({
|
|
761
|
+
mutationFn: () => r.request(H(`/directory/sync/${e.id}`)).then((o) => o.data),
|
|
762
|
+
onSuccess: ({ summary: o }) => {
|
|
763
|
+
i(), s.invalidateQueries({ queryKey: ["nvr-directory-entry", e.email] }), o.active > 0 ? F.success("Still with the company — profile synced from the directory") : F.warning(
|
|
764
|
+
`${o.missing > 0 ? "Not in the directory" : "Disabled in Azure"}${o.suspended > 0 ? " — suspended" : ""}`
|
|
765
765
|
);
|
|
766
766
|
},
|
|
767
|
-
onError: (
|
|
767
|
+
onError: (o) => F.error(J(o, "Directory sync failed"))
|
|
768
768
|
});
|
|
769
|
-
if (
|
|
770
|
-
const
|
|
771
|
-
var
|
|
772
|
-
return
|
|
773
|
-
},
|
|
774
|
-
return /* @__PURE__ */
|
|
775
|
-
|
|
769
|
+
if (l.isLoading || !((R = l.data) != null && R.configured)) return null;
|
|
770
|
+
const d = e, $ = (o) => {
|
|
771
|
+
var N;
|
|
772
|
+
return d[o] ?? ((N = e.admin) == null ? void 0 : N[o]) ?? null;
|
|
773
|
+
}, 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
|
+
return /* @__PURE__ */ n(
|
|
775
|
+
Y,
|
|
776
776
|
{
|
|
777
|
-
icon: /* @__PURE__ */ t(
|
|
777
|
+
icon: /* @__PURE__ */ t(Ae, { className: "h-4 w-4" }),
|
|
778
778
|
title: "Microsoft directory",
|
|
779
779
|
hint: "Pulling writes every field the directory has a value for; blanks never clear",
|
|
780
780
|
testId: "directory",
|
|
781
|
-
actions:
|
|
781
|
+
actions: l.data.granted && /* @__PURE__ */ n(
|
|
782
782
|
"button",
|
|
783
783
|
{
|
|
784
784
|
type: "button",
|
|
785
|
-
onClick: () =>
|
|
786
|
-
disabled:
|
|
785
|
+
onClick: () => b.mutate(),
|
|
786
|
+
disabled: b.isPending,
|
|
787
787
|
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-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
|
|
788
788
|
children: [
|
|
789
|
-
/* @__PURE__ */ t(
|
|
790
|
-
|
|
789
|
+
/* @__PURE__ */ t(ae, { className: T("h-3 w-3", b.isPending && "animate-spin") }),
|
|
790
|
+
b.isPending ? "Checking…" : "Sync from directory"
|
|
791
791
|
]
|
|
792
792
|
}
|
|
793
793
|
),
|
|
794
794
|
children: [
|
|
795
|
-
/* @__PURE__ */
|
|
795
|
+
/* @__PURE__ */ n(
|
|
796
796
|
"div",
|
|
797
797
|
{
|
|
798
|
-
className: T("rounded-md border px-3 py-2 text-[12.5px]",
|
|
799
|
-
"data-directory-verdict":
|
|
798
|
+
className: T("rounded-md border px-3 py-2 text-[12.5px]", u),
|
|
799
|
+
"data-directory-verdict": f ?? "unchecked",
|
|
800
800
|
children: [
|
|
801
|
-
/* @__PURE__ */ t("span", { className: "font-medium", children:
|
|
802
|
-
((
|
|
801
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: D }),
|
|
802
|
+
((v = e.admin) == null ? void 0 : v.directory_checked_at) && /* @__PURE__ */ n("span", { className: "ml-2 text-[11px] opacity-70", children: [
|
|
803
803
|
"checked ",
|
|
804
|
-
|
|
804
|
+
ze(e.admin.directory_checked_at)
|
|
805
805
|
] }),
|
|
806
|
-
(
|
|
806
|
+
(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
807
|
]
|
|
808
808
|
}
|
|
809
809
|
),
|
|
810
|
-
|
|
811
|
-
/* @__PURE__ */
|
|
812
|
-
/* @__PURE__ */ t("span", { className: "font-medium text-slate-800 dark:text-foreground", children:
|
|
813
|
-
|
|
810
|
+
l.data.granted ? h.isLoading ? /* @__PURE__ */ t("p", { className: "mt-3 text-[12px] text-slate-400", children: "Looking up the directory…" }) : h.isError ? /* @__PURE__ */ t("p", { className: "mt-3 text-[12px] text-red-600 dark:text-red-400", children: J(h.error, "The directory lookup failed.") }) : c ? /* @__PURE__ */ n("div", { className: "mt-3 space-y-3", children: [
|
|
811
|
+
/* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2 text-[12px]", children: [
|
|
812
|
+
/* @__PURE__ */ t("span", { className: "font-medium text-slate-800 dark:text-foreground", children: c.display_name ?? `${c.first_name ?? ""} ${c.last_name ?? ""}`.trim() }),
|
|
813
|
+
c.upn && c.upn.toLowerCase() !== e.email.toLowerCase() && /* @__PURE__ */ n("span", { className: "text-slate-400", children: [
|
|
814
814
|
"UPN ",
|
|
815
|
-
|
|
815
|
+
c.upn
|
|
816
816
|
] }),
|
|
817
|
-
|
|
818
|
-
|
|
817
|
+
c.account_enabled === !1 && /* @__PURE__ */ t("span", { className: "rounded-full bg-red-50 px-2 py-0.5 text-[11px] font-medium text-red-700 dark:bg-red-400/10 dark:text-red-300", children: "Disabled in Azure" }),
|
|
818
|
+
c.manager && /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: [
|
|
819
819
|
"Reports to",
|
|
820
820
|
" ",
|
|
821
|
-
/* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-foreground", children:
|
|
821
|
+
/* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-foreground", children: c.manager.display_name ?? c.manager.email })
|
|
822
822
|
] })
|
|
823
823
|
] }),
|
|
824
|
-
/* @__PURE__ */ t("dl", { className: "grid gap-px overflow-hidden rounded-lg border border-slate-200 bg-slate-200 dark:border-border dark:bg-border sm:grid-cols-2 lg:grid-cols-3", children:
|
|
825
|
-
const
|
|
826
|
-
return /* @__PURE__ */
|
|
824
|
+
/* @__PURE__ */ t("dl", { className: "grid gap-px overflow-hidden rounded-lg border border-slate-200 bg-slate-200 dark:border-border dark:bg-border sm:grid-cols-2 lg:grid-cols-3", children: Ze.filter((o) => o.key in c).map((o) => {
|
|
825
|
+
const N = c[o.key] ?? null, w = $(o.key), C = !!N && N !== w;
|
|
826
|
+
return /* @__PURE__ */ n(
|
|
827
827
|
"div",
|
|
828
828
|
{
|
|
829
829
|
className: T(
|
|
@@ -831,62 +831,62 @@ function kt({ profile: e }) {
|
|
|
831
831
|
C && "bg-amber-50/60 dark:bg-amber-400/10"
|
|
832
832
|
),
|
|
833
833
|
children: [
|
|
834
|
-
/* @__PURE__ */ t("dt", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children:
|
|
835
|
-
/* @__PURE__ */ t("dd", { className: "mt-0.5 text-[12.5px] text-slate-800 dark:text-foreground", children:
|
|
836
|
-
C && /* @__PURE__ */
|
|
834
|
+
/* @__PURE__ */ t("dt", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: o.label }),
|
|
835
|
+
/* @__PURE__ */ t("dd", { className: "mt-0.5 text-[12.5px] text-slate-800 dark:text-foreground", children: N ?? /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) }),
|
|
836
|
+
C && /* @__PURE__ */ n("dd", { className: "text-[11px] text-slate-400", children: [
|
|
837
837
|
"stored: ",
|
|
838
|
-
|
|
838
|
+
w ?? /* @__PURE__ */ t("span", { className: "italic", children: "empty" })
|
|
839
839
|
] })
|
|
840
840
|
]
|
|
841
841
|
},
|
|
842
|
-
|
|
842
|
+
o.key
|
|
843
843
|
);
|
|
844
844
|
}) })
|
|
845
|
-
] }) : /* @__PURE__ */
|
|
845
|
+
] }) : /* @__PURE__ */ n("p", { className: "mt-3 text-[12px] text-slate-500 dark:text-muted-foreground", children: [
|
|
846
846
|
"No directory entry matches ",
|
|
847
847
|
e.email,
|
|
848
848
|
"."
|
|
849
|
-
] }) : /* @__PURE__ */
|
|
849
|
+
] }) : /* @__PURE__ */ n("div", { className: "mt-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] text-amber-900 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-200", children: [
|
|
850
850
|
/* @__PURE__ */ t("p", { className: "font-medium", children: "Directory access is not granted yet." }),
|
|
851
|
-
/* @__PURE__ */ t("p", { className: "mt-0.5", children:
|
|
851
|
+
/* @__PURE__ */ t("p", { className: "mt-0.5", children: l.data.reason ?? "The app token cannot read other users. Grant User.Read.All as an application permission with admin consent." })
|
|
852
852
|
] })
|
|
853
853
|
]
|
|
854
854
|
}
|
|
855
855
|
);
|
|
856
856
|
}
|
|
857
|
-
function
|
|
858
|
-
var
|
|
859
|
-
const
|
|
860
|
-
mutationFn: () =>
|
|
861
|
-
onSuccess: (
|
|
862
|
-
|
|
857
|
+
function _t({ profile: e }) {
|
|
858
|
+
var f;
|
|
859
|
+
const r = Q(), s = ce(e.id), [i, l] = P(null), [h, b] = P(!1), d = j({
|
|
860
|
+
mutationFn: () => r.request(H(`/users/${e.id}/token`)).then((u) => u.data.token),
|
|
861
|
+
onSuccess: (u) => {
|
|
862
|
+
l(u), b(!0), s(), F.success("Token generated — copy it now, it is shown once");
|
|
863
863
|
},
|
|
864
|
-
onError: (
|
|
865
|
-
}),
|
|
866
|
-
mutationFn: () =>
|
|
864
|
+
onError: (u) => F.error(J(u, "Could not generate a token"))
|
|
865
|
+
}), $ = j({
|
|
866
|
+
mutationFn: () => r.request(Ne(`/users/${e.id}/token`)),
|
|
867
867
|
onSuccess: () => {
|
|
868
|
-
|
|
868
|
+
l(null), b(!1), s(), F.success("Token revoked");
|
|
869
869
|
},
|
|
870
|
-
onError: (
|
|
871
|
-
}),
|
|
870
|
+
onError: (u) => F.error(J(u, "Could not revoke the token"))
|
|
871
|
+
}), c = !!((f = e.admin) != null && f.has_static_token) || !!i;
|
|
872
872
|
return /* @__PURE__ */ t(
|
|
873
|
-
|
|
873
|
+
Y,
|
|
874
874
|
{
|
|
875
|
-
icon: /* @__PURE__ */ t(
|
|
875
|
+
icon: /* @__PURE__ */ t(Pe, { className: "h-4 w-4" }),
|
|
876
876
|
title: "API token",
|
|
877
877
|
hint: "Static bearer token for scripts and the SDK",
|
|
878
878
|
testId: "api-token",
|
|
879
|
-
children:
|
|
880
|
-
i ? /* @__PURE__ */
|
|
881
|
-
/* @__PURE__ */ t("code", { className: "flex-1 break-all rounded-md border border-slate-200 bg-slate-50 px-3 py-2 font-mono text-[12px] text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-200", children:
|
|
879
|
+
children: c ? /* @__PURE__ */ n("div", { className: "space-y-3", children: [
|
|
880
|
+
i ? /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
|
|
881
|
+
/* @__PURE__ */ t("code", { className: "flex-1 break-all rounded-md border border-slate-200 bg-slate-50 px-3 py-2 font-mono text-[12px] text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-200", children: h ? i : "•".repeat(24) }),
|
|
882
882
|
/* @__PURE__ */ t(
|
|
883
883
|
"button",
|
|
884
884
|
{
|
|
885
885
|
type: "button",
|
|
886
|
-
onClick: () =>
|
|
887
|
-
"aria-label":
|
|
886
|
+
onClick: () => b((u) => !u),
|
|
887
|
+
"aria-label": h ? "Hide token" : "Reveal token",
|
|
888
888
|
className: "rounded-md border border-slate-200 p-2 text-slate-500 hover:bg-slate-50 dark:border-border dark:hover:bg-muted",
|
|
889
|
-
children:
|
|
889
|
+
children: h ? /* @__PURE__ */ t(Te, { className: "h-4 w-4" }) : /* @__PURE__ */ t(De, { className: "h-4 w-4" })
|
|
890
890
|
}
|
|
891
891
|
),
|
|
892
892
|
/* @__PURE__ */ t(
|
|
@@ -894,56 +894,56 @@ function Nt({ profile: e }) {
|
|
|
894
894
|
{
|
|
895
895
|
type: "button",
|
|
896
896
|
onClick: () => {
|
|
897
|
-
navigator.clipboard.writeText(i),
|
|
897
|
+
navigator.clipboard.writeText(i), F.success("Copied");
|
|
898
898
|
},
|
|
899
899
|
"aria-label": "Copy token",
|
|
900
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(
|
|
901
|
+
children: /* @__PURE__ */ t(Fe, { className: "h-4 w-4" })
|
|
902
902
|
}
|
|
903
903
|
)
|
|
904
904
|
] }) : /* @__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
|
-
/* @__PURE__ */
|
|
906
|
-
/* @__PURE__ */
|
|
907
|
-
|
|
905
|
+
/* @__PURE__ */ n("div", { className: "flex gap-2", children: [
|
|
906
|
+
/* @__PURE__ */ n(
|
|
907
|
+
I,
|
|
908
908
|
{
|
|
909
|
-
onConfirm: () =>
|
|
910
|
-
disabled:
|
|
909
|
+
onConfirm: () => d.mutate(),
|
|
910
|
+
disabled: d.isPending,
|
|
911
911
|
confirmLabel: "Replace the current token?",
|
|
912
912
|
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-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
|
|
913
913
|
armedClassName: "border-amber-300 text-amber-700 dark:text-amber-300",
|
|
914
914
|
children: [
|
|
915
|
-
/* @__PURE__ */ t(
|
|
915
|
+
/* @__PURE__ */ t(ae, { className: "h-3 w-3" }),
|
|
916
916
|
" Regenerate"
|
|
917
917
|
]
|
|
918
918
|
}
|
|
919
919
|
),
|
|
920
|
-
/* @__PURE__ */
|
|
921
|
-
|
|
920
|
+
/* @__PURE__ */ n(
|
|
921
|
+
I,
|
|
922
922
|
{
|
|
923
|
-
onConfirm: () =>
|
|
924
|
-
disabled:
|
|
923
|
+
onConfirm: () => $.mutate(),
|
|
924
|
+
disabled: $.isPending,
|
|
925
925
|
confirmLabel: "Revoke — scripts using it stop working?",
|
|
926
926
|
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
927
|
armedClassName: "border-red-300",
|
|
928
928
|
children: [
|
|
929
|
-
/* @__PURE__ */ t(
|
|
929
|
+
/* @__PURE__ */ t(Ke, { className: "h-3 w-3" }),
|
|
930
930
|
" Revoke"
|
|
931
931
|
]
|
|
932
932
|
}
|
|
933
933
|
)
|
|
934
934
|
] })
|
|
935
|
-
] }) : /* @__PURE__ */
|
|
936
|
-
/* @__PURE__ */ t(
|
|
937
|
-
/* @__PURE__ */
|
|
935
|
+
] }) : /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
936
|
+
/* @__PURE__ */ t(we, { children: "No token issued." }),
|
|
937
|
+
/* @__PURE__ */ n(
|
|
938
938
|
"button",
|
|
939
939
|
{
|
|
940
940
|
type: "button",
|
|
941
|
-
onClick: () =>
|
|
942
|
-
disabled:
|
|
941
|
+
onClick: () => d.mutate(),
|
|
942
|
+
disabled: d.isPending,
|
|
943
943
|
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-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
|
|
944
944
|
children: [
|
|
945
|
-
/* @__PURE__ */ t(
|
|
946
|
-
|
|
945
|
+
/* @__PURE__ */ t(ae, { className: T("h-3 w-3", d.isPending && "animate-spin") }),
|
|
946
|
+
d.isPending ? "Generating…" : "Generate token"
|
|
947
947
|
]
|
|
948
948
|
}
|
|
949
949
|
)
|
|
@@ -951,112 +951,214 @@ function Nt({ profile: e }) {
|
|
|
951
951
|
}
|
|
952
952
|
);
|
|
953
953
|
}
|
|
954
|
-
function
|
|
954
|
+
function et(e, r, s) {
|
|
955
|
+
const i = `${M(r)} ${e ? "other " : ""}browser${r === 1 ? "" : "s"}`, l = s > 0 ? ` and ${M(s)} phone${s === 1 ? "" : "s"}` : "";
|
|
956
|
+
return `Sign out ${e ? "" : "all "}${i}${l}?`;
|
|
957
|
+
}
|
|
958
|
+
function tt(e) {
|
|
959
|
+
const r = new Date(e);
|
|
960
|
+
if (Number.isNaN(r.getTime())) return Ge(e);
|
|
961
|
+
const s = r.getFullYear() === (/* @__PURE__ */ new Date()).getFullYear();
|
|
962
|
+
return r.toLocaleString(void 0, {
|
|
963
|
+
month: "short",
|
|
964
|
+
day: "numeric",
|
|
965
|
+
...s ? {} : { year: "numeric" },
|
|
966
|
+
hour: "numeric",
|
|
967
|
+
minute: "2-digit"
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
const ee = 6, te = (e) => !!(e.device || e.ip || e.signed_in_at);
|
|
971
|
+
function rt(e) {
|
|
972
|
+
const r = (s) => s.signed_in_at && Date.parse(s.signed_in_at) || 0;
|
|
973
|
+
return [...e].sort(
|
|
974
|
+
(s, i) => +!!i.current - +!!s.current || Number(te(i)) - Number(te(s)) || r(i) - r(s) || i.ttl_seconds - s.ttl_seconds
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
function nt(e) {
|
|
955
978
|
if (!Number.isFinite(e) || e <= 0) return "Ending now";
|
|
956
979
|
if (e < 3600) return `Ends in ${Math.max(1, Math.round(e / 60))} min`;
|
|
957
|
-
const
|
|
958
|
-
return
|
|
980
|
+
const r = Math.round(e / 3600);
|
|
981
|
+
return r >= 48 ? `Ends in ${Math.round(r / 24)} days` : `Ends in ${r}h`;
|
|
959
982
|
}
|
|
960
|
-
function
|
|
961
|
-
const
|
|
983
|
+
function qt({ userId: e }) {
|
|
984
|
+
const r = Q(), s = oe(), i = ["nvr-user-sessions", e], l = E({
|
|
962
985
|
queryKey: i,
|
|
963
|
-
queryFn: () =>
|
|
986
|
+
queryFn: () => r.request(O("/security/sessions", { user_id: e })).then((m) => m.data ?? []),
|
|
964
987
|
staleTime: 3e4
|
|
965
|
-
}),
|
|
966
|
-
|
|
988
|
+
}), h = e.toUpperCase();
|
|
989
|
+
Ue(
|
|
967
990
|
"sessions",
|
|
968
991
|
() => {
|
|
969
|
-
|
|
992
|
+
s.invalidateQueries({ queryKey: ["nvr-user-sessions", e] }), s.invalidateQueries({ queryKey: ["nvr-signed-in-devices", e] });
|
|
970
993
|
},
|
|
971
994
|
{
|
|
972
995
|
debounceMs: 800,
|
|
973
|
-
match: (
|
|
996
|
+
match: (m) => m.all === !0 || String(m.user_id ?? "").toUpperCase() === h
|
|
974
997
|
}
|
|
975
998
|
);
|
|
976
|
-
const
|
|
977
|
-
mutationFn: (
|
|
978
|
-
onSuccess: (
|
|
979
|
-
|
|
999
|
+
const b = j({
|
|
1000
|
+
mutationFn: (m) => r.request(Ne(`/security/sessions/${m}`)),
|
|
1001
|
+
onSuccess: (m, A) => {
|
|
1002
|
+
s.setQueryData(i, (K) => K == null ? void 0 : K.filter((U) => U.sid_prefix !== A)), F.success("That browser is signed out");
|
|
1003
|
+
},
|
|
1004
|
+
onError: (m) => se(m, "Could not sign that browser out")
|
|
1005
|
+
}), d = de(() => rt(l.data ?? []), [l.data]), $ = je(d.map((m) => m.sid_prefix)), { quiet: c } = Be(), [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
|
+
mutationFn: () => r.request(
|
|
1007
|
+
o ? H("/security/my/sessions/sign-out-others", {}) : H(`/security/users/${encodeURIComponent(e)}/sign-out`, {})
|
|
1008
|
+
),
|
|
1009
|
+
onSuccess: (m) => {
|
|
1010
|
+
var K;
|
|
1011
|
+
s.invalidateQueries({ queryKey: i }), s.invalidateQueries({ queryKey: ["nvr-signed-in-devices", e] });
|
|
1012
|
+
const A = ((K = m == null ? void 0 : m.data) == null ? void 0 : K.revoked) ?? 0;
|
|
1013
|
+
F.success(A === 1 ? "1 sign-in ended" : `${M(A)} sign-ins ended`);
|
|
980
1014
|
},
|
|
981
|
-
onError: (
|
|
982
|
-
}),
|
|
1015
|
+
onError: (m) => se(m, "Could not sign those out")
|
|
1016
|
+
}), C = o ? "Sign out everywhere else" : "Sign out everywhere", L = (E({
|
|
1017
|
+
queryKey: ["nvr-signed-in-devices", e],
|
|
1018
|
+
queryFn: () => r.request(O(`/users/${e}/devices`)).then((m) => m.data ?? []),
|
|
1019
|
+
staleTime: 3e4
|
|
1020
|
+
}).data ?? []).filter((m) => !(o && m.current)).length;
|
|
983
1021
|
return /* @__PURE__ */ t(
|
|
984
|
-
|
|
1022
|
+
Y,
|
|
985
1023
|
{
|
|
986
|
-
icon: /* @__PURE__ */ t(
|
|
987
|
-
title:
|
|
1024
|
+
icon: /* @__PURE__ */ t(Le, { className: "h-4 w-4" }),
|
|
1025
|
+
title: l.isSuccess ? `Signed-in browsers · ${d.length}` : "Signed-in browsers",
|
|
988
1026
|
hint: "Signing a browser out ends it on its next request",
|
|
989
1027
|
testId: "sessions",
|
|
990
|
-
children:
|
|
991
|
-
/* @__PURE__ */ t(
|
|
992
|
-
/* @__PURE__ */ t(
|
|
993
|
-
] }) :
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1028
|
+
children: l.isLoading ? /* @__PURE__ */ n("div", { className: "space-y-3", "aria-hidden": !0, children: [
|
|
1029
|
+
/* @__PURE__ */ t(he, { className: "h-9 w-full" }),
|
|
1030
|
+
/* @__PURE__ */ t(he, { className: "h-9 w-2/3" })
|
|
1031
|
+
] }) : l.isError ? /* @__PURE__ */ t(He, { 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(z, { children: [
|
|
1032
|
+
/* @__PURE__ */ t(
|
|
1033
|
+
"ul",
|
|
1034
|
+
{
|
|
1035
|
+
"data-sessions-list": !0,
|
|
1036
|
+
className: T(
|
|
1037
|
+
"-my-2 divide-y divide-slate-100 dark:divide-border/60",
|
|
1038
|
+
// A long list scrolls inside the card, so its count header stays in view.
|
|
1039
|
+
f && d.length > ee && "max-h-[26rem] overflow-y-auto pr-1"
|
|
1040
|
+
),
|
|
1041
|
+
children: R.map((m) => /* @__PURE__ */ t(
|
|
1042
|
+
at,
|
|
1043
|
+
{
|
|
1044
|
+
session: m,
|
|
1045
|
+
fresh: !c && $.has(m.sid_prefix),
|
|
1046
|
+
pending: b.isPending && b.variables === m.sid_prefix || w.isPending && !m.current,
|
|
1047
|
+
onRevoke: () => b.mutate(m.sid_prefix)
|
|
1048
|
+
},
|
|
1049
|
+
m.sid_prefix
|
|
1050
|
+
))
|
|
1051
|
+
}
|
|
1052
|
+
),
|
|
1053
|
+
(y > 0 || f || N.length > 1) && /* @__PURE__ */ n(
|
|
1054
|
+
"div",
|
|
1055
|
+
{
|
|
1056
|
+
"data-sessions-foot": !0,
|
|
1057
|
+
className: "-mx-4 -mb-4 mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-slate-100 px-4 py-2.5 dark:border-border/60",
|
|
1058
|
+
children: [
|
|
1059
|
+
y > 0 ? /* @__PURE__ */ t(
|
|
1060
|
+
"button",
|
|
1061
|
+
{
|
|
1062
|
+
type: "button",
|
|
1063
|
+
"data-sessions-show-all": !0,
|
|
1064
|
+
onClick: () => u(!0),
|
|
1065
|
+
className: "min-w-0 rounded text-left text-[12px] font-medium text-slate-600 underline decoration-slate-300 underline-offset-2 hover:text-slate-900 hover:decoration-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:text-slate-300 dark:decoration-slate-600 dark:hover:text-slate-100",
|
|
1066
|
+
children: v ? `${y} older sign-in${y === 1 ? "" : "s"} with no browser details · Show` : `Show all ${d.length}`
|
|
1067
|
+
}
|
|
1068
|
+
) : f && d.length > _.slice(0, ee).length ? /* @__PURE__ */ t(
|
|
1069
|
+
"button",
|
|
1070
|
+
{
|
|
1071
|
+
type: "button",
|
|
1072
|
+
onClick: () => u(!1),
|
|
1073
|
+
className: "rounded text-[12px] font-medium text-slate-600 underline decoration-slate-300 underline-offset-2 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:text-slate-300 dark:decoration-slate-600 dark:hover:text-slate-100",
|
|
1074
|
+
children: "Show fewer"
|
|
1075
|
+
}
|
|
1076
|
+
) : null,
|
|
1077
|
+
N.length > 1 && /* @__PURE__ */ t("span", { className: "ml-auto", children: /* @__PURE__ */ n(
|
|
1078
|
+
I,
|
|
1079
|
+
{
|
|
1080
|
+
title: C,
|
|
1081
|
+
onConfirm: () => w.mutate(),
|
|
1082
|
+
confirmLabel: et(o, N.length, L),
|
|
1083
|
+
disabled: w.isPending,
|
|
1084
|
+
className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:border-red-300 hover:text-red-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:border-red-500/40 dark:hover:text-red-400",
|
|
1085
|
+
armedClassName: "border-red-300 font-semibold text-red-600 dark:border-red-500/40 dark:text-red-400",
|
|
1086
|
+
children: [
|
|
1087
|
+
/* @__PURE__ */ t(ke, { className: "h-3 w-3", "aria-hidden": !0 }),
|
|
1088
|
+
w.isPending ? "Signing out…" : C
|
|
1089
|
+
]
|
|
1090
|
+
}
|
|
1091
|
+
) })
|
|
1092
|
+
]
|
|
1093
|
+
}
|
|
1094
|
+
)
|
|
1095
|
+
] })
|
|
1003
1096
|
}
|
|
1004
1097
|
);
|
|
1005
1098
|
}
|
|
1006
|
-
function
|
|
1099
|
+
function at({
|
|
1007
1100
|
session: e,
|
|
1008
|
-
fresh:
|
|
1009
|
-
pending:
|
|
1101
|
+
fresh: r,
|
|
1102
|
+
pending: s,
|
|
1010
1103
|
onRevoke: i
|
|
1011
1104
|
}) {
|
|
1012
|
-
const
|
|
1105
|
+
const l = e.device || "Browser", h = [
|
|
1013
1106
|
e.ip,
|
|
1014
|
-
e.signed_in_at ? `Signed in ${
|
|
1015
|
-
|
|
1016
|
-
].filter(
|
|
1017
|
-
return /* @__PURE__ */
|
|
1107
|
+
e.signed_in_at ? `Signed in ${tt(e.signed_in_at)}` : "Signed in before this was recorded",
|
|
1108
|
+
nt(e.ttl_seconds)
|
|
1109
|
+
].filter((d) => !!d), b = Ie(l);
|
|
1110
|
+
return /* @__PURE__ */ n(
|
|
1018
1111
|
"li",
|
|
1019
1112
|
{
|
|
1020
1113
|
"data-session-row": !0,
|
|
1021
|
-
"data-fresh":
|
|
1114
|
+
"data-fresh": r || void 0,
|
|
1022
1115
|
className: T(
|
|
1023
1116
|
"-mx-2 flex items-center gap-3 rounded-md px-2 py-2.5 transition-colors duration-700 motion-reduce:transition-none",
|
|
1024
|
-
|
|
1117
|
+
r && "bg-nvr-cyan/10"
|
|
1025
1118
|
),
|
|
1026
1119
|
children: [
|
|
1027
|
-
/* @__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(
|
|
1028
|
-
/* @__PURE__ */
|
|
1029
|
-
/* @__PURE__ */
|
|
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(Ee, { className: "h-4 w-4", "aria-hidden": !0 }) : /* @__PURE__ */ t(Oe, { className: "h-4 w-4", "aria-hidden": !0 }) }),
|
|
1121
|
+
/* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
|
|
1122
|
+
/* @__PURE__ */ n("p", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5", children: [
|
|
1123
|
+
/* @__PURE__ */ t(
|
|
1124
|
+
"span",
|
|
1125
|
+
{
|
|
1126
|
+
ref: b,
|
|
1127
|
+
"data-session-device": !0,
|
|
1128
|
+
className: "min-w-0 max-w-full truncate text-[12.5px] font-medium text-slate-800 dark:text-slate-100",
|
|
1129
|
+
children: l
|
|
1130
|
+
}
|
|
1131
|
+
),
|
|
1132
|
+
e.current && /* @__PURE__ */ t(
|
|
1133
|
+
"span",
|
|
1134
|
+
{
|
|
1135
|
+
"data-session-current": !0,
|
|
1136
|
+
className: "shrink-0 rounded-full bg-nvr-cyan/10 px-1.5 py-px text-[10.5px] font-medium text-sky-700 dark:text-nvr-cyan",
|
|
1137
|
+
children: "This browser"
|
|
1138
|
+
}
|
|
1139
|
+
)
|
|
1140
|
+
] }),
|
|
1141
|
+
/* @__PURE__ */ t("div", { "data-session-meta": !0, className: "mt-0.5 overflow-hidden", children: /* @__PURE__ */ t("p", { className: "-ml-3 flex flex-wrap text-[11.5px] leading-snug tabular-nums text-slate-500 dark:text-slate-400", children: h.map((d) => /* @__PURE__ */ t(
|
|
1030
1142
|
"span",
|
|
1031
1143
|
{
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
),
|
|
1038
|
-
/* @__PURE__ */ t(
|
|
1039
|
-
"p",
|
|
1040
|
-
{
|
|
1041
|
-
ref: p,
|
|
1042
|
-
"data-session-meta": !0,
|
|
1043
|
-
className: "mt-0.5 truncate text-[11.5px] tabular-nums text-slate-500 dark:text-slate-400",
|
|
1044
|
-
children: b
|
|
1045
|
-
}
|
|
1046
|
-
)
|
|
1144
|
+
className: "relative whitespace-nowrap pl-3 before:absolute before:left-[0.3rem] before:content-['·']",
|
|
1145
|
+
children: d
|
|
1146
|
+
},
|
|
1147
|
+
d
|
|
1148
|
+
)) }) })
|
|
1047
1149
|
] }),
|
|
1048
|
-
/* @__PURE__ */ t("span", { "data-session-sign-out": !0, className: "contents", children: /* @__PURE__ */
|
|
1049
|
-
|
|
1150
|
+
/* @__PURE__ */ t("span", { "data-session-sign-out": !0, className: "contents", children: /* @__PURE__ */ n(
|
|
1151
|
+
I,
|
|
1050
1152
|
{
|
|
1051
|
-
title: `Sign out ${
|
|
1153
|
+
title: e.current ? "Sign out of this browser" : `Sign out ${l}`,
|
|
1052
1154
|
onConfirm: i,
|
|
1053
|
-
confirmLabel: "Sign it out?",
|
|
1054
|
-
disabled:
|
|
1155
|
+
confirmLabel: e.current ? "Sign out here?" : "Sign it out?",
|
|
1156
|
+
disabled: s,
|
|
1055
1157
|
className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:border-red-300 hover:text-red-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:border-red-500/40 dark:hover:text-red-400",
|
|
1056
1158
|
armedClassName: "border-red-300 font-semibold text-red-600 dark:border-red-500/40 dark:text-red-400",
|
|
1057
1159
|
children: [
|
|
1058
|
-
/* @__PURE__ */ t(
|
|
1059
|
-
|
|
1160
|
+
/* @__PURE__ */ t(ke, { className: "h-3 w-3", "aria-hidden": !0 }),
|
|
1161
|
+
/* @__PURE__ */ t("span", { className: "sr-only sm:not-sr-only", children: s ? "Signing out…" : e.current ? "Sign out here" : "Sign out" })
|
|
1060
1162
|
]
|
|
1061
1163
|
}
|
|
1062
1164
|
) })
|
|
@@ -1065,11 +1167,13 @@ function Ze({
|
|
|
1065
1167
|
);
|
|
1066
1168
|
}
|
|
1067
1169
|
export {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1170
|
+
wt as AccessCard,
|
|
1171
|
+
_t as ApiTokenCard,
|
|
1172
|
+
qt as SessionsCard,
|
|
1173
|
+
St as SuspensionBanner,
|
|
1174
|
+
Ct as UserDirectoryCard,
|
|
1175
|
+
$t as UserScopesCard,
|
|
1176
|
+
rt as orderSessions,
|
|
1177
|
+
nt as sessionEndsIn,
|
|
1178
|
+
et as signOutAllQuestion
|
|
1075
1179
|
};
|