strapi-plugin-magic-sessionmanager 4.19.1 → 4.21.0
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/CHANGELOG.md +38 -0
- package/README.md +189 -35
- package/dist/admin/{Analytics-BElmzyNJ.js → Analytics-BqdZIBV4.js} +1 -1
- package/dist/admin/{Analytics-BqFlgLnN.mjs → Analytics-C-OLLzoB.mjs} +1 -1
- package/dist/admin/{App-0thsC_P9.mjs → App-BswHmNQT.mjs} +338 -4
- package/dist/admin/{App-D_J2eeEG.js → App-Cx9v6n_7.js} +337 -3
- package/dist/admin/{OnlineUsersWidget-DMZBwqdY.js → OnlineUsersWidget-BRmQPPp9.js} +1 -1
- package/dist/admin/{OnlineUsersWidget-BgJ1ws-5.mjs → OnlineUsersWidget-Dusgjc1d.mjs} +1 -1
- package/dist/admin/{Settings-FOkui_ke.js → Settings-DWGuf_Z3.js} +288 -65
- package/dist/admin/{Settings-QN3Mu4AQ.mjs → Settings-DZyQheUS.mjs} +258 -35
- package/dist/admin/{de-CEyi4lpp.js → de-24TPqzG6.js} +94 -1
- package/dist/admin/{de-uGKSKVYD.mjs → de-DUnrmFWk.mjs} +94 -1
- package/dist/admin/{en-CSXeJYKy.js → en-8mBSkWOF.js} +94 -1
- package/dist/admin/{en-Yu7tfwqx.mjs → en-D8J__tyF.mjs} +94 -1
- package/dist/admin/{es-iNG9Amf9.mjs → es-BgpgWdk0.mjs} +94 -1
- package/dist/admin/{es-BrKqXhAU.js → es-ChUKey-Q.js} +94 -1
- package/dist/admin/{fr-DKZNfdlH.js → fr-DE_CWmgq.js} +94 -1
- package/dist/admin/{fr-CaFICHlf.mjs → fr-k1MHYKJo.mjs} +94 -1
- package/dist/admin/{index-DEYtqPc3.js → index-Ceh3Q1Ki.js} +622 -46
- package/dist/admin/{index-h-ksmM8A.mjs → index-meLDPPwt.mjs} +638 -62
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/{pt-IEagyVDL.js → pt-BjqU5ioB.js} +94 -1
- package/dist/admin/{pt-Bz2hWVrq.mjs → pt-DPO4DmDc.mjs} +94 -1
- package/dist/admin/{settingsTabs-D02CuEvs.mjs → settingsTabs-C1q5iMMw.mjs} +5 -1
- package/dist/admin/{settingsTabs-N4TFn-mw.js → settingsTabs-CfquZuKH.js} +5 -1
- package/dist/server/index.js +1965 -15
- package/dist/server/index.mjs +1965 -15
- package/package.json +1 -1
|
@@ -3,12 +3,12 @@ import { useFetchClient, useNotification, useClipboard, useRBAC, useQueryParams,
|
|
|
3
3
|
import { NavLink, Link as Link$1, Routes, Route } from "react-router-dom";
|
|
4
4
|
import { useMemo, useState, useEffect, useRef, useId, useCallback, useLayoutEffect } from "react";
|
|
5
5
|
import { useIntl } from "react-intl";
|
|
6
|
-
import { Typography, Flex, Loader, Button, Modal, Accordion, Box, IconButton, Link, SimpleMenu, MenuItem, Grid, Table, Thead, Tr, Th, VisuallyHidden, Tbody, Td, Tooltip, SearchForm, Searchbar, TextButton, SingleSelect, SingleSelectOption, EmptyStateLayout, LinkButton, Badge, Tabs, Dialog, Tag } from "@strapi/design-system";
|
|
6
|
+
import { Typography, Flex, Loader, Button, Modal, Accordion, Box, IconButton, Link, SimpleMenu, MenuItem, Grid, Table, Thead, Tr, Th, VisuallyHidden, Tbody, Td, Tooltip, SearchForm, Searchbar, TextButton, SingleSelect, SingleSelectOption, EmptyStateLayout, LinkButton, Badge, Tabs, Field, Textarea, Dialog, Tag } from "@strapi/design-system";
|
|
7
7
|
import { Earth, Duplicate, Cross, Eye, Trash, More, CaretDown, Download, ArrowClockwise, Check, Clock, User, ChartBubble, Cog, SignOut, Information, Webhooks, WarningCircle, Monitor, Key, Stack, Lock, CrossCircle, Shield, CheckCircle, ArrowRight } from "@strapi/icons";
|
|
8
8
|
import { EmptyDocuments } from "@strapi/icons/symbols";
|
|
9
9
|
import styled, { useTheme } from "styled-components";
|
|
10
|
-
import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, u as useSessionFormatters, c as getSessionStatus, d as getDevicePresentation, i as isNativeOnlySession, e as getSessionEndReasonPresentation, D as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, f as pluginId, l as logSafeAdminError, h as PersistentAlert, R as ReadableText, j as pluginPermissions, M as MissingValue, V as ValueOrMissing, k as SESSION_STATES, m as SESSION_STATUS_PRESENTATION, n as isCancelledRequest, o as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, q as PageShell, r as StatGrid, s as StatCard, v as restoreDialogFocus, w as requireSessionList, x as getBadgeColors, T as TargetLink$1 } from "./index-
|
|
11
|
-
import { i as isRiskSource, g as getSessionUserLabels, a as getUserEditPath, R as RISK_SETTINGS_PATH, b as RowActions, s as shouldIsolateActionKey, c as shouldRedispatchEscape, D as DASHBOARD_COMPACT_TABLE_COLUMNS, d as DASHBOARD_TABLE_COLUMNS, r as readDisclosureOpen, e as getBrowserStorage, w as writeDisclosureOpen, u as useElementWidth, p as parseDashboardQuery, A as AUTO_REFRESH_INTERVAL_MS, f as pickFocusSessionId, h as encodeSearchQuery, j as shouldUseCompactTable, P as PAGE_SIZE_OPTIONS, k as DEFAULT_PAGE_SIZE, l as getExportDeviceInfo, m as getErrorStatus, n as hasActiveFilters, S as SETTINGS_TAB_IDS, o as SETTINGS_TAB_FIELDS, q as SETTINGS_FIELD_LABELS, t as SETTINGS_TAB_LABELS } from "./settingsTabs-
|
|
10
|
+
import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, u as useSessionFormatters, c as getSessionStatus, d as getDevicePresentation, i as isNativeOnlySession, e as getSessionEndReasonPresentation, D as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, f as pluginId, l as logSafeAdminError, h as PersistentAlert, R as ReadableText, j as pluginPermissions, M as MissingValue, V as ValueOrMissing, k as SESSION_STATES, m as SESSION_STATUS_PRESENTATION, n as isCancelledRequest, o as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, q as PageShell, r as StatGrid, s as StatCard, v as restoreDialogFocus, w as requireSessionList, x as getBadgeColors, T as TargetLink$1, y as useSettingsTranslate, z as useSecondsLeft, A as validateReason, B as REASON_MAX, F as formatClock } from "./index-meLDPPwt.mjs";
|
|
11
|
+
import { i as isRiskSource, g as getSessionUserLabels, a as getUserEditPath, R as RISK_SETTINGS_PATH, b as RowActions, s as shouldIsolateActionKey, c as shouldRedispatchEscape, D as DASHBOARD_COMPACT_TABLE_COLUMNS, d as DASHBOARD_TABLE_COLUMNS, r as readDisclosureOpen, e as getBrowserStorage, w as writeDisclosureOpen, u as useElementWidth, p as parseDashboardQuery, A as AUTO_REFRESH_INTERVAL_MS, f as pickFocusSessionId, h as encodeSearchQuery, j as shouldUseCompactTable, P as PAGE_SIZE_OPTIONS, k as DEFAULT_PAGE_SIZE, l as getExportDeviceInfo, m as getErrorStatus, n as hasActiveFilters, S as SETTINGS_TAB_IDS, o as SETTINGS_TAB_FIELDS, q as SETTINGS_FIELD_LABELS, t as SETTINGS_TAB_LABELS } from "./settingsTabs-C1q5iMMw.mjs";
|
|
12
12
|
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
13
13
|
const { formatMessage } = useIntl();
|
|
14
14
|
const key = reason || getSessionEndReason(session);
|
|
@@ -2439,6 +2439,7 @@ function withEventAdminNames(row, placeholderName) {
|
|
|
2439
2439
|
};
|
|
2440
2440
|
}
|
|
2441
2441
|
const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
|
|
2442
|
+
const offersPreview = (admin, canPreview) => Boolean(canPreview) && admin.self !== true && !(admin.roles || []).some((role) => role?.superAdmin === true);
|
|
2442
2443
|
const keepActionKeys = (event) => {
|
|
2443
2444
|
if (shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2444
2445
|
};
|
|
@@ -2488,6 +2489,8 @@ const AdminTable = ({
|
|
|
2488
2489
|
canRevoke,
|
|
2489
2490
|
onView,
|
|
2490
2491
|
onSignOutEverywhere,
|
|
2492
|
+
canPreview,
|
|
2493
|
+
onPreview,
|
|
2491
2494
|
busy
|
|
2492
2495
|
}) => {
|
|
2493
2496
|
const t = useT$4();
|
|
@@ -2522,6 +2525,16 @@ const AdminTable = ({
|
|
|
2522
2525
|
children: /* @__PURE__ */ jsx(Eye, {})
|
|
2523
2526
|
}
|
|
2524
2527
|
),
|
|
2528
|
+
offersPreview(admin, canPreview) ? /* @__PURE__ */ jsx(
|
|
2529
|
+
IconButton,
|
|
2530
|
+
{
|
|
2531
|
+
label: t("adminPanel.actions.viewAs", "View as {name}", {
|
|
2532
|
+
name: admin.name || `#${admin.id}`
|
|
2533
|
+
}),
|
|
2534
|
+
onClick: (event) => onPreview?.(admin, event.currentTarget),
|
|
2535
|
+
children: /* @__PURE__ */ jsx(User, {})
|
|
2536
|
+
}
|
|
2537
|
+
) : null,
|
|
2525
2538
|
canRevoke && admin.canSignOut ? /* @__PURE__ */ jsx(
|
|
2526
2539
|
IconButton,
|
|
2527
2540
|
{
|
|
@@ -2543,7 +2556,15 @@ const AdminTable = ({
|
|
|
2543
2556
|
}
|
|
2544
2557
|
) });
|
|
2545
2558
|
};
|
|
2546
|
-
const AdminCardList = ({
|
|
2559
|
+
const AdminCardList = ({
|
|
2560
|
+
admins,
|
|
2561
|
+
labelledBy,
|
|
2562
|
+
canRevoke,
|
|
2563
|
+
onView,
|
|
2564
|
+
onSignOutEverywhere,
|
|
2565
|
+
canPreview,
|
|
2566
|
+
onPreview
|
|
2567
|
+
}) => {
|
|
2547
2568
|
const t = useT$4();
|
|
2548
2569
|
return /* @__PURE__ */ jsx(
|
|
2549
2570
|
Flex,
|
|
@@ -2587,6 +2608,19 @@ const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywh
|
|
|
2587
2608
|
children: t("adminPanel.actions.viewShort", "View sessions")
|
|
2588
2609
|
}
|
|
2589
2610
|
),
|
|
2611
|
+
offersPreview(admin, canPreview) ? /* @__PURE__ */ jsx(
|
|
2612
|
+
Button,
|
|
2613
|
+
{
|
|
2614
|
+
variant: "secondary",
|
|
2615
|
+
startIcon: /* @__PURE__ */ jsx(User, {}),
|
|
2616
|
+
onClick: (event) => onPreview?.(admin, event.currentTarget),
|
|
2617
|
+
"aria-label": t("adminPanel.actions.viewAs", "View as {name}", {
|
|
2618
|
+
name: admin.name || `#${admin.id}`
|
|
2619
|
+
}),
|
|
2620
|
+
flex: "1 1 auto",
|
|
2621
|
+
children: t("adminPanel.actions.viewAsShort", "View as")
|
|
2622
|
+
}
|
|
2623
|
+
) : null,
|
|
2590
2624
|
canRevoke && admin.canSignOut ? /* @__PURE__ */ jsx(
|
|
2591
2625
|
Button,
|
|
2592
2626
|
{
|
|
@@ -4402,6 +4436,276 @@ const AdminSessionsModal = ({
|
|
|
4402
4436
|
] }) })
|
|
4403
4437
|
] }) });
|
|
4404
4438
|
};
|
|
4439
|
+
const ADMIN_PREVIEW_DURATIONS = Object.freeze([15, 30]);
|
|
4440
|
+
const REFUSALS = Object.freeze({
|
|
4441
|
+
disabled: ["impersonation.error.disabled", "Impersonation is turned off in the settings."],
|
|
4442
|
+
self: ["impersonation.preview.error.self", "You cannot view yourself as another admin."],
|
|
4443
|
+
"super-admin": [
|
|
4444
|
+
"impersonation.preview.error.superAdmin",
|
|
4445
|
+
"Super Admins cannot be viewed as another admin."
|
|
4446
|
+
],
|
|
4447
|
+
"not-subset": [
|
|
4448
|
+
"impersonation.preview.error.notSubset",
|
|
4449
|
+
"This admin has permissions that you do not have, so you cannot view as them."
|
|
4450
|
+
],
|
|
4451
|
+
"api-token": ["impersonation.error.apiToken", "API tokens cannot impersonate."]
|
|
4452
|
+
});
|
|
4453
|
+
const ACTION_LABELS = Object.freeze({
|
|
4454
|
+
create: ["impersonation.preview.action.create", "Create"],
|
|
4455
|
+
read: ["impersonation.preview.action.read", "Read"],
|
|
4456
|
+
update: ["impersonation.preview.action.update", "Update"],
|
|
4457
|
+
delete: ["impersonation.preview.action.delete", "Delete"],
|
|
4458
|
+
publish: ["impersonation.preview.action.publish", "Publish"]
|
|
4459
|
+
});
|
|
4460
|
+
const CONDITION_LABELS = Object.freeze({
|
|
4461
|
+
"admin::is-creator": ["impersonation.preview.condition.creator", "entries they created"],
|
|
4462
|
+
"admin::has-same-role-as-creator": [
|
|
4463
|
+
"impersonation.preview.condition.sameRole",
|
|
4464
|
+
"entries created by someone with the same role"
|
|
4465
|
+
]
|
|
4466
|
+
});
|
|
4467
|
+
const ContentTypeRow = ({ type }) => {
|
|
4468
|
+
const { t } = useSettingsTranslate();
|
|
4469
|
+
return /* @__PURE__ */ jsx(Box, { tag: "li", padding: 3, hasRadius: true, borderColor: "neutral150", "data-preview-type": type.uid, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
4470
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: type.name }),
|
|
4471
|
+
/* @__PURE__ */ jsx(Flex, { gap: 2, wrap: "wrap", children: type.actions.map((action) => {
|
|
4472
|
+
const label = ACTION_LABELS[action.action] ? t(...ACTION_LABELS[action.action]) : action.action;
|
|
4473
|
+
const restricted = action.fields !== null || action.locales !== null || action.conditions.length > 0;
|
|
4474
|
+
return /* @__PURE__ */ jsx(
|
|
4475
|
+
Badge,
|
|
4476
|
+
{
|
|
4477
|
+
backgroundColor: restricted ? "warning100" : "success100",
|
|
4478
|
+
textColor: "neutral800",
|
|
4479
|
+
children: restricted ? t("impersonation.preview.restricted", "{action} (restricted)", {
|
|
4480
|
+
action: label
|
|
4481
|
+
}) : label
|
|
4482
|
+
},
|
|
4483
|
+
action.action
|
|
4484
|
+
);
|
|
4485
|
+
}) }),
|
|
4486
|
+
type.actions.filter((action) => action.fields !== null || action.conditions.length > 0).map((action) => {
|
|
4487
|
+
const label = ACTION_LABELS[action.action] ? t(...ACTION_LABELS[action.action]) : action.action;
|
|
4488
|
+
return /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: [
|
|
4489
|
+
action.fields !== null ? t(
|
|
4490
|
+
"impersonation.preview.fields",
|
|
4491
|
+
"{action}: {count, plural, one {# field} other {# fields}}",
|
|
4492
|
+
{ action: label, count: action.fields }
|
|
4493
|
+
) : null,
|
|
4494
|
+
action.fields !== null && action.conditions.length ? " " : null,
|
|
4495
|
+
action.conditions.length ? t("impersonation.preview.conditions", "{action}: only {conditions}", {
|
|
4496
|
+
action: label,
|
|
4497
|
+
conditions: action.conditions.map((id) => CONDITION_LABELS[id] ? t(...CONDITION_LABELS[id]) : id).join(", ")
|
|
4498
|
+
}) : null
|
|
4499
|
+
] }, action.action);
|
|
4500
|
+
})
|
|
4501
|
+
] }) });
|
|
4502
|
+
};
|
|
4503
|
+
const PreviewAdminModal = ({ admin, onClose, onCloseAutoFocus, onChanged }) => {
|
|
4504
|
+
const { t, tError } = useSettingsTranslate();
|
|
4505
|
+
const { post } = useFetchClient();
|
|
4506
|
+
const { toggleNotification } = useNotification();
|
|
4507
|
+
const [reason, setReason] = useState("");
|
|
4508
|
+
const [minutes, setMinutes] = useState(15);
|
|
4509
|
+
const [touched, setTouched] = useState(false);
|
|
4510
|
+
const [pending, setPending] = useState(null);
|
|
4511
|
+
const [failure, setFailure] = useState(null);
|
|
4512
|
+
const [result, setResult] = useState(null);
|
|
4513
|
+
const secondsLeft = useSecondsLeft(result?.impersonation?.expiresAt || null);
|
|
4514
|
+
const ended = Boolean(result) && secondsLeft <= 0;
|
|
4515
|
+
const reasonError = validateReason(reason);
|
|
4516
|
+
const name = result?.preview?.admin?.name || admin.name;
|
|
4517
|
+
const start = async () => {
|
|
4518
|
+
setTouched(true);
|
|
4519
|
+
if (reasonError) return;
|
|
4520
|
+
setPending("start");
|
|
4521
|
+
setFailure(null);
|
|
4522
|
+
try {
|
|
4523
|
+
const { data } = await post(`/${pluginId}/impersonation/admins/${admin.id}/preview`, {
|
|
4524
|
+
reason: reason.trim(),
|
|
4525
|
+
durationMinutes: minutes
|
|
4526
|
+
});
|
|
4527
|
+
setResult(data?.data || null);
|
|
4528
|
+
onChanged?.();
|
|
4529
|
+
} catch (err) {
|
|
4530
|
+
if (isCancelledRequest(err)) return;
|
|
4531
|
+
const response = err?.response;
|
|
4532
|
+
const code = response?.data?.error?.details?.reason;
|
|
4533
|
+
if (response?.status === 429) {
|
|
4534
|
+
setFailure(
|
|
4535
|
+
t(
|
|
4536
|
+
"impersonation.error.rateLimited",
|
|
4537
|
+
"Too many impersonations were started. Try again in a few minutes."
|
|
4538
|
+
)
|
|
4539
|
+
);
|
|
4540
|
+
} else if (REFUSALS[code]) {
|
|
4541
|
+
setFailure(t(...REFUSALS[code]));
|
|
4542
|
+
} else {
|
|
4543
|
+
logSafeAdminError("impersonation.preview", err);
|
|
4544
|
+
setFailure(t("impersonation.preview.error.start", "The preview could not be opened."));
|
|
4545
|
+
}
|
|
4546
|
+
} finally {
|
|
4547
|
+
setPending(null);
|
|
4548
|
+
}
|
|
4549
|
+
};
|
|
4550
|
+
const end = async () => {
|
|
4551
|
+
if (!result?.impersonation?.id) return;
|
|
4552
|
+
setPending("end");
|
|
4553
|
+
try {
|
|
4554
|
+
await post(`/${pluginId}/impersonation/${result.impersonation.id}/end`, {});
|
|
4555
|
+
toggleNotification({
|
|
4556
|
+
type: "success",
|
|
4557
|
+
message: t("impersonation.preview.ended", "Preview ended.")
|
|
4558
|
+
});
|
|
4559
|
+
onChanged?.();
|
|
4560
|
+
onClose();
|
|
4561
|
+
} catch (err) {
|
|
4562
|
+
logSafeAdminError("impersonation.end", err);
|
|
4563
|
+
toggleNotification({
|
|
4564
|
+
type: "danger",
|
|
4565
|
+
message: t("impersonation.error.end", "The impersonation could not be ended.")
|
|
4566
|
+
});
|
|
4567
|
+
} finally {
|
|
4568
|
+
setPending(null);
|
|
4569
|
+
}
|
|
4570
|
+
};
|
|
4571
|
+
const preview = result?.preview;
|
|
4572
|
+
const close = () => {
|
|
4573
|
+
if (result?.impersonation?.id && !ended) {
|
|
4574
|
+
post(`/${pluginId}/impersonation/${result.impersonation.id}/end`, {}).then(() => onChanged?.()).catch((err) => logSafeAdminError("impersonation.end", err));
|
|
4575
|
+
}
|
|
4576
|
+
onClose();
|
|
4577
|
+
};
|
|
4578
|
+
return /* @__PURE__ */ jsx(Modal.Root, { open: true, onOpenChange: (open) => open ? null : close(), children: /* @__PURE__ */ jsxs(Modal.Content, { onCloseAutoFocus, "aria-describedby": void 0, children: [
|
|
4579
|
+
/* @__PURE__ */ jsx(Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsx(Modal.Title, { children: t("impersonation.preview.title", "View as {name}", { name: name || `#${admin.id}` }) }) }),
|
|
4580
|
+
/* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
4581
|
+
failure ? /* @__PURE__ */ jsx(PersistentAlert, { variant: "danger", closeLabel: t("common.close", "Close"), children: failure }) : null,
|
|
4582
|
+
!result ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4583
|
+
/* @__PURE__ */ jsx(ReadableText, { variant: "omega", textColor: "neutral800", tag: "p", children: t(
|
|
4584
|
+
"impersonation.preview.intro",
|
|
4585
|
+
"See which content types and actions this admin can use, worked out from their roles. Read-only: nobody is signed in and nothing can be changed. It is recorded in the security log."
|
|
4586
|
+
) }),
|
|
4587
|
+
/* @__PURE__ */ jsxs(
|
|
4588
|
+
Field.Root,
|
|
4589
|
+
{
|
|
4590
|
+
name: "reason",
|
|
4591
|
+
required: true,
|
|
4592
|
+
error: touched && reasonError ? tError(reasonError) : void 0,
|
|
4593
|
+
hint: t("impersonation.preview.reason.hint", "Stored in the security log."),
|
|
4594
|
+
children: [
|
|
4595
|
+
/* @__PURE__ */ jsx(Field.Label, { children: t("impersonation.reason.label", "Reason") }),
|
|
4596
|
+
/* @__PURE__ */ jsx(
|
|
4597
|
+
Textarea,
|
|
4598
|
+
{
|
|
4599
|
+
value: reason,
|
|
4600
|
+
maxLength: REASON_MAX,
|
|
4601
|
+
placeholder: t("impersonation.reason.placeholder", "For example: ticket 4711"),
|
|
4602
|
+
onChange: (event) => setReason(event.target.value),
|
|
4603
|
+
onBlur: () => setTouched(true)
|
|
4604
|
+
}
|
|
4605
|
+
),
|
|
4606
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
|
4607
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
4608
|
+
]
|
|
4609
|
+
}
|
|
4610
|
+
),
|
|
4611
|
+
/* @__PURE__ */ jsxs(Field.Root, { name: "durationMinutes", children: [
|
|
4612
|
+
/* @__PURE__ */ jsx(Field.Label, { children: t("impersonation.duration.label", "Duration") }),
|
|
4613
|
+
/* @__PURE__ */ jsx(
|
|
4614
|
+
SingleSelect,
|
|
4615
|
+
{
|
|
4616
|
+
value: String(minutes),
|
|
4617
|
+
onChange: (value) => setMinutes(Number(value)),
|
|
4618
|
+
children: ADMIN_PREVIEW_DURATIONS.map((value) => /* @__PURE__ */ jsx(SingleSelectOption, { value: String(value), children: t(
|
|
4619
|
+
"impersonation.duration.minutes",
|
|
4620
|
+
"{count, plural, one {# minute} other {# minutes}}",
|
|
4621
|
+
{ count: value }
|
|
4622
|
+
) }, value))
|
|
4623
|
+
}
|
|
4624
|
+
)
|
|
4625
|
+
] })
|
|
4626
|
+
] }) : null,
|
|
4627
|
+
result ? /* @__PURE__ */ jsx(
|
|
4628
|
+
Box,
|
|
4629
|
+
{
|
|
4630
|
+
padding: 3,
|
|
4631
|
+
hasRadius: true,
|
|
4632
|
+
background: ended ? "neutral150" : "primary100",
|
|
4633
|
+
borderColor: ended ? "neutral200" : "primary200",
|
|
4634
|
+
"data-preview-banner": "",
|
|
4635
|
+
children: /* @__PURE__ */ jsxs(Flex, { gap: 3, wrap: "wrap", justifyContent: "space-between", alignItems: "center", children: [
|
|
4636
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", "aria-live": "polite", children: ended ? t("impersonation.preview.banner.ended", "The preview ended.") : t(
|
|
4637
|
+
"impersonation.preview.banner",
|
|
4638
|
+
"You are viewing as {name} · read-only · ends in {time}",
|
|
4639
|
+
{ name: name || `#${admin.id}`, time: formatClock(secondsLeft) }
|
|
4640
|
+
) }),
|
|
4641
|
+
!ended ? /* @__PURE__ */ jsx(
|
|
4642
|
+
Button,
|
|
4643
|
+
{
|
|
4644
|
+
size: "S",
|
|
4645
|
+
variant: "danger-light",
|
|
4646
|
+
onClick: end,
|
|
4647
|
+
loading: pending === "end",
|
|
4648
|
+
children: t("impersonation.preview.end", "End")
|
|
4649
|
+
}
|
|
4650
|
+
) : null
|
|
4651
|
+
] })
|
|
4652
|
+
}
|
|
4653
|
+
) : null,
|
|
4654
|
+
preview && !ended ? /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, "data-preview-body": "", children: [
|
|
4655
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t("impersonation.preview.roles", "Roles: {roles}", {
|
|
4656
|
+
roles: preview.admin.roles.map((role) => role.name).join(", ") || "—"
|
|
4657
|
+
}) }),
|
|
4658
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
4659
|
+
/* @__PURE__ */ jsx(Typography, { variant: "delta", tag: "h3", textColor: "neutral800", children: t("impersonation.preview.contentTypes", "Content types") }),
|
|
4660
|
+
preview.contentTypes.length ? /* @__PURE__ */ jsx(
|
|
4661
|
+
Flex,
|
|
4662
|
+
{
|
|
4663
|
+
tag: "ul",
|
|
4664
|
+
direction: "column",
|
|
4665
|
+
alignItems: "stretch",
|
|
4666
|
+
gap: 2,
|
|
4667
|
+
margin: 0,
|
|
4668
|
+
padding: 0,
|
|
4669
|
+
style: { listStyle: "none" },
|
|
4670
|
+
children: preview.contentTypes.map((type) => /* @__PURE__ */ jsx(ContentTypeRow, { type }, type.uid))
|
|
4671
|
+
}
|
|
4672
|
+
) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", tag: "p", children: t(
|
|
4673
|
+
"impersonation.preview.noContentTypes",
|
|
4674
|
+
"This admin cannot open any content type in the Content Manager."
|
|
4675
|
+
) })
|
|
4676
|
+
] }),
|
|
4677
|
+
preview.otherPermissions.length ? /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
4678
|
+
/* @__PURE__ */ jsx(Typography, { variant: "delta", tag: "h3", textColor: "neutral800", children: t("impersonation.preview.other", "Other permissions") }),
|
|
4679
|
+
/* @__PURE__ */ jsx(
|
|
4680
|
+
Flex,
|
|
4681
|
+
{
|
|
4682
|
+
tag: "ul",
|
|
4683
|
+
direction: "column",
|
|
4684
|
+
alignItems: "stretch",
|
|
4685
|
+
gap: 1,
|
|
4686
|
+
margin: 0,
|
|
4687
|
+
paddingLeft: 5,
|
|
4688
|
+
children: preview.otherPermissions.map((permission) => /* @__PURE__ */ jsx(
|
|
4689
|
+
Typography,
|
|
4690
|
+
{
|
|
4691
|
+
tag: "li",
|
|
4692
|
+
variant: "pi",
|
|
4693
|
+
textColor: "neutral800",
|
|
4694
|
+
children: permission.name
|
|
4695
|
+
},
|
|
4696
|
+
permission.action
|
|
4697
|
+
))
|
|
4698
|
+
}
|
|
4699
|
+
)
|
|
4700
|
+
] }) : null
|
|
4701
|
+
] }) : null
|
|
4702
|
+
] }) }),
|
|
4703
|
+
/* @__PURE__ */ jsx(Modal.Footer, { children: result ? /* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: ended ? t("impersonation.result.done", "Done") : t("impersonation.preview.close", "End and close") }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4704
|
+
/* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: t("common.cancel", "Cancel") }) }),
|
|
4705
|
+
/* @__PURE__ */ jsx(Button, { onClick: start, loading: pending === "start", children: t("impersonation.preview.start", "View permissions") })
|
|
4706
|
+
] }) })
|
|
4707
|
+
] }) });
|
|
4708
|
+
};
|
|
4405
4709
|
const SETTINGS_USERS_PATH = "/settings/users";
|
|
4406
4710
|
const PaginationTargets$1 = styled.div`
|
|
4407
4711
|
nav a {
|
|
@@ -4432,6 +4736,11 @@ const AdminPanelPage = () => {
|
|
|
4432
4736
|
const {
|
|
4433
4737
|
allowedActions: { canRead: canViewActivity }
|
|
4434
4738
|
} = useRBAC(pluginPermissions.adminActivityRead);
|
|
4739
|
+
const {
|
|
4740
|
+
allowedActions: { canAdmins: canPreviewAdmins }
|
|
4741
|
+
} = useRBAC(pluginPermissions.impersonateAdmins);
|
|
4742
|
+
const [impersonationEnabled, setImpersonationEnabled] = useState(false);
|
|
4743
|
+
const [previewTarget, setPreviewTarget] = useState(null);
|
|
4435
4744
|
const [admins, setAdmins] = useState([]);
|
|
4436
4745
|
const [meta, setMeta] = useState(null);
|
|
4437
4746
|
const [loading, setLoading] = useState(true);
|
|
@@ -4447,6 +4756,18 @@ const AdminPanelPage = () => {
|
|
|
4447
4756
|
const dialogRequestRef = useRef(0);
|
|
4448
4757
|
const hasLoadedRef = useRef(false);
|
|
4449
4758
|
const openerRef = useRef(null);
|
|
4759
|
+
useEffect(() => {
|
|
4760
|
+
if (!canPreviewAdmins) return void 0;
|
|
4761
|
+
let current = true;
|
|
4762
|
+
get(`/${pluginId}/impersonation/status`).then(({ data }) => {
|
|
4763
|
+
if (current) setImpersonationEnabled(data?.data?.enabled === true);
|
|
4764
|
+
}).catch((err) => {
|
|
4765
|
+
if (!isCancelledRequest(err)) logSafeAdminError("impersonation.status", err);
|
|
4766
|
+
});
|
|
4767
|
+
return () => {
|
|
4768
|
+
current = false;
|
|
4769
|
+
};
|
|
4770
|
+
}, [canPreviewAdmins, get]);
|
|
4450
4771
|
const confirmReturnRef = useRef(null);
|
|
4451
4772
|
const captionRef = useRef(null);
|
|
4452
4773
|
const pageRef = useRef(null);
|
|
@@ -4662,6 +4983,11 @@ const AdminPanelPage = () => {
|
|
|
4662
4983
|
canRevoke: Boolean(canRevoke),
|
|
4663
4984
|
onView: openDialog,
|
|
4664
4985
|
onSignOutEverywhere: (admin, trigger) => askSignOut(admin, null, trigger),
|
|
4986
|
+
canPreview: Boolean(canPreviewAdmins) && impersonationEnabled,
|
|
4987
|
+
onPreview: (admin, trigger) => {
|
|
4988
|
+
openerRef.current = trigger;
|
|
4989
|
+
setPreviewTarget({ id: admin.id, name: admin.name });
|
|
4990
|
+
},
|
|
4665
4991
|
busy: refreshing
|
|
4666
4992
|
};
|
|
4667
4993
|
const policy = meta?.policy;
|
|
@@ -4919,6 +5245,14 @@ const AdminPanelPage = () => {
|
|
|
4919
5245
|
},
|
|
4920
5246
|
`${selected.id}-${dialogTab}`
|
|
4921
5247
|
) : null,
|
|
5248
|
+
previewTarget ? /* @__PURE__ */ jsx(
|
|
5249
|
+
PreviewAdminModal,
|
|
5250
|
+
{
|
|
5251
|
+
admin: previewTarget,
|
|
5252
|
+
onClose: () => setPreviewTarget(null),
|
|
5253
|
+
onCloseAutoFocus: (event) => restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
|
|
5254
|
+
}
|
|
5255
|
+
) : null,
|
|
4922
5256
|
confirm ? /* @__PURE__ */ jsx(
|
|
4923
5257
|
ConfirmAction,
|
|
4924
5258
|
{
|