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
|
@@ -9,8 +9,8 @@ const designSystem = require("@strapi/design-system");
|
|
|
9
9
|
const icons = require("@strapi/icons");
|
|
10
10
|
const symbols = require("@strapi/icons/symbols");
|
|
11
11
|
const styled = require("styled-components");
|
|
12
|
-
const index = require("./index-
|
|
13
|
-
const settingsTabs = require("./settingsTabs-
|
|
12
|
+
const index = require("./index-Ceh3Q1Ki.js");
|
|
13
|
+
const settingsTabs = require("./settingsTabs-CfquZuKH.js");
|
|
14
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
15
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
16
16
|
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
@@ -2443,6 +2443,7 @@ function withEventAdminNames(row, placeholderName) {
|
|
|
2443
2443
|
};
|
|
2444
2444
|
}
|
|
2445
2445
|
const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
|
|
2446
|
+
const offersPreview = (admin, canPreview) => Boolean(canPreview) && admin.self !== true && !(admin.roles || []).some((role) => role?.superAdmin === true);
|
|
2446
2447
|
const keepActionKeys = (event) => {
|
|
2447
2448
|
if (settingsTabs.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2448
2449
|
};
|
|
@@ -2492,6 +2493,8 @@ const AdminTable = ({
|
|
|
2492
2493
|
canRevoke,
|
|
2493
2494
|
onView,
|
|
2494
2495
|
onSignOutEverywhere,
|
|
2496
|
+
canPreview,
|
|
2497
|
+
onPreview,
|
|
2495
2498
|
busy
|
|
2496
2499
|
}) => {
|
|
2497
2500
|
const t = useT$4();
|
|
@@ -2526,6 +2529,16 @@ const AdminTable = ({
|
|
|
2526
2529
|
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
|
|
2527
2530
|
}
|
|
2528
2531
|
),
|
|
2532
|
+
offersPreview(admin, canPreview) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2533
|
+
designSystem.IconButton,
|
|
2534
|
+
{
|
|
2535
|
+
label: t("adminPanel.actions.viewAs", "View as {name}", {
|
|
2536
|
+
name: admin.name || `#${admin.id}`
|
|
2537
|
+
}),
|
|
2538
|
+
onClick: (event) => onPreview?.(admin, event.currentTarget),
|
|
2539
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {})
|
|
2540
|
+
}
|
|
2541
|
+
) : null,
|
|
2529
2542
|
canRevoke && admin.canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2530
2543
|
designSystem.IconButton,
|
|
2531
2544
|
{
|
|
@@ -2547,7 +2560,15 @@ const AdminTable = ({
|
|
|
2547
2560
|
}
|
|
2548
2561
|
) });
|
|
2549
2562
|
};
|
|
2550
|
-
const AdminCardList = ({
|
|
2563
|
+
const AdminCardList = ({
|
|
2564
|
+
admins,
|
|
2565
|
+
labelledBy,
|
|
2566
|
+
canRevoke,
|
|
2567
|
+
onView,
|
|
2568
|
+
onSignOutEverywhere,
|
|
2569
|
+
canPreview,
|
|
2570
|
+
onPreview
|
|
2571
|
+
}) => {
|
|
2551
2572
|
const t = useT$4();
|
|
2552
2573
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2553
2574
|
designSystem.Flex,
|
|
@@ -2591,6 +2612,19 @@ const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywh
|
|
|
2591
2612
|
children: t("adminPanel.actions.viewShort", "View sessions")
|
|
2592
2613
|
}
|
|
2593
2614
|
),
|
|
2615
|
+
offersPreview(admin, canPreview) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2616
|
+
designSystem.Button,
|
|
2617
|
+
{
|
|
2618
|
+
variant: "secondary",
|
|
2619
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
|
|
2620
|
+
onClick: (event) => onPreview?.(admin, event.currentTarget),
|
|
2621
|
+
"aria-label": t("adminPanel.actions.viewAs", "View as {name}", {
|
|
2622
|
+
name: admin.name || `#${admin.id}`
|
|
2623
|
+
}),
|
|
2624
|
+
flex: "1 1 auto",
|
|
2625
|
+
children: t("adminPanel.actions.viewAsShort", "View as")
|
|
2626
|
+
}
|
|
2627
|
+
) : null,
|
|
2594
2628
|
canRevoke && admin.canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2595
2629
|
designSystem.Button,
|
|
2596
2630
|
{
|
|
@@ -4406,6 +4440,276 @@ const AdminSessionsModal = ({
|
|
|
4406
4440
|
] }) })
|
|
4407
4441
|
] }) });
|
|
4408
4442
|
};
|
|
4443
|
+
const ADMIN_PREVIEW_DURATIONS = Object.freeze([15, 30]);
|
|
4444
|
+
const REFUSALS = Object.freeze({
|
|
4445
|
+
disabled: ["impersonation.error.disabled", "Impersonation is turned off in the settings."],
|
|
4446
|
+
self: ["impersonation.preview.error.self", "You cannot view yourself as another admin."],
|
|
4447
|
+
"super-admin": [
|
|
4448
|
+
"impersonation.preview.error.superAdmin",
|
|
4449
|
+
"Super Admins cannot be viewed as another admin."
|
|
4450
|
+
],
|
|
4451
|
+
"not-subset": [
|
|
4452
|
+
"impersonation.preview.error.notSubset",
|
|
4453
|
+
"This admin has permissions that you do not have, so you cannot view as them."
|
|
4454
|
+
],
|
|
4455
|
+
"api-token": ["impersonation.error.apiToken", "API tokens cannot impersonate."]
|
|
4456
|
+
});
|
|
4457
|
+
const ACTION_LABELS = Object.freeze({
|
|
4458
|
+
create: ["impersonation.preview.action.create", "Create"],
|
|
4459
|
+
read: ["impersonation.preview.action.read", "Read"],
|
|
4460
|
+
update: ["impersonation.preview.action.update", "Update"],
|
|
4461
|
+
delete: ["impersonation.preview.action.delete", "Delete"],
|
|
4462
|
+
publish: ["impersonation.preview.action.publish", "Publish"]
|
|
4463
|
+
});
|
|
4464
|
+
const CONDITION_LABELS = Object.freeze({
|
|
4465
|
+
"admin::is-creator": ["impersonation.preview.condition.creator", "entries they created"],
|
|
4466
|
+
"admin::has-same-role-as-creator": [
|
|
4467
|
+
"impersonation.preview.condition.sameRole",
|
|
4468
|
+
"entries created by someone with the same role"
|
|
4469
|
+
]
|
|
4470
|
+
});
|
|
4471
|
+
const ContentTypeRow = ({ type }) => {
|
|
4472
|
+
const { t } = index.useSettingsTranslate();
|
|
4473
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "li", padding: 3, hasRadius: true, borderColor: "neutral150", "data-preview-type": type.uid, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
4474
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: type.name }),
|
|
4475
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, wrap: "wrap", children: type.actions.map((action) => {
|
|
4476
|
+
const label = ACTION_LABELS[action.action] ? t(...ACTION_LABELS[action.action]) : action.action;
|
|
4477
|
+
const restricted = action.fields !== null || action.locales !== null || action.conditions.length > 0;
|
|
4478
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4479
|
+
designSystem.Badge,
|
|
4480
|
+
{
|
|
4481
|
+
backgroundColor: restricted ? "warning100" : "success100",
|
|
4482
|
+
textColor: "neutral800",
|
|
4483
|
+
children: restricted ? t("impersonation.preview.restricted", "{action} (restricted)", {
|
|
4484
|
+
action: label
|
|
4485
|
+
}) : label
|
|
4486
|
+
},
|
|
4487
|
+
action.action
|
|
4488
|
+
);
|
|
4489
|
+
}) }),
|
|
4490
|
+
type.actions.filter((action) => action.fields !== null || action.conditions.length > 0).map((action) => {
|
|
4491
|
+
const label = ACTION_LABELS[action.action] ? t(...ACTION_LABELS[action.action]) : action.action;
|
|
4492
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: [
|
|
4493
|
+
action.fields !== null ? t(
|
|
4494
|
+
"impersonation.preview.fields",
|
|
4495
|
+
"{action}: {count, plural, one {# field} other {# fields}}",
|
|
4496
|
+
{ action: label, count: action.fields }
|
|
4497
|
+
) : null,
|
|
4498
|
+
action.fields !== null && action.conditions.length ? " " : null,
|
|
4499
|
+
action.conditions.length ? t("impersonation.preview.conditions", "{action}: only {conditions}", {
|
|
4500
|
+
action: label,
|
|
4501
|
+
conditions: action.conditions.map((id) => CONDITION_LABELS[id] ? t(...CONDITION_LABELS[id]) : id).join(", ")
|
|
4502
|
+
}) : null
|
|
4503
|
+
] }, action.action);
|
|
4504
|
+
})
|
|
4505
|
+
] }) });
|
|
4506
|
+
};
|
|
4507
|
+
const PreviewAdminModal = ({ admin, onClose, onCloseAutoFocus, onChanged }) => {
|
|
4508
|
+
const { t, tError } = index.useSettingsTranslate();
|
|
4509
|
+
const { post } = StrapiAdmin.useFetchClient();
|
|
4510
|
+
const { toggleNotification } = StrapiAdmin.useNotification();
|
|
4511
|
+
const [reason, setReason] = react.useState("");
|
|
4512
|
+
const [minutes, setMinutes] = react.useState(15);
|
|
4513
|
+
const [touched, setTouched] = react.useState(false);
|
|
4514
|
+
const [pending, setPending] = react.useState(null);
|
|
4515
|
+
const [failure, setFailure] = react.useState(null);
|
|
4516
|
+
const [result, setResult] = react.useState(null);
|
|
4517
|
+
const secondsLeft = index.useSecondsLeft(result?.impersonation?.expiresAt || null);
|
|
4518
|
+
const ended = Boolean(result) && secondsLeft <= 0;
|
|
4519
|
+
const reasonError = index.validateReason(reason);
|
|
4520
|
+
const name = result?.preview?.admin?.name || admin.name;
|
|
4521
|
+
const start = async () => {
|
|
4522
|
+
setTouched(true);
|
|
4523
|
+
if (reasonError) return;
|
|
4524
|
+
setPending("start");
|
|
4525
|
+
setFailure(null);
|
|
4526
|
+
try {
|
|
4527
|
+
const { data } = await post(`/${index.pluginId}/impersonation/admins/${admin.id}/preview`, {
|
|
4528
|
+
reason: reason.trim(),
|
|
4529
|
+
durationMinutes: minutes
|
|
4530
|
+
});
|
|
4531
|
+
setResult(data?.data || null);
|
|
4532
|
+
onChanged?.();
|
|
4533
|
+
} catch (err) {
|
|
4534
|
+
if (index.isCancelledRequest(err)) return;
|
|
4535
|
+
const response = err?.response;
|
|
4536
|
+
const code = response?.data?.error?.details?.reason;
|
|
4537
|
+
if (response?.status === 429) {
|
|
4538
|
+
setFailure(
|
|
4539
|
+
t(
|
|
4540
|
+
"impersonation.error.rateLimited",
|
|
4541
|
+
"Too many impersonations were started. Try again in a few minutes."
|
|
4542
|
+
)
|
|
4543
|
+
);
|
|
4544
|
+
} else if (REFUSALS[code]) {
|
|
4545
|
+
setFailure(t(...REFUSALS[code]));
|
|
4546
|
+
} else {
|
|
4547
|
+
index.logSafeAdminError("impersonation.preview", err);
|
|
4548
|
+
setFailure(t("impersonation.preview.error.start", "The preview could not be opened."));
|
|
4549
|
+
}
|
|
4550
|
+
} finally {
|
|
4551
|
+
setPending(null);
|
|
4552
|
+
}
|
|
4553
|
+
};
|
|
4554
|
+
const end = async () => {
|
|
4555
|
+
if (!result?.impersonation?.id) return;
|
|
4556
|
+
setPending("end");
|
|
4557
|
+
try {
|
|
4558
|
+
await post(`/${index.pluginId}/impersonation/${result.impersonation.id}/end`, {});
|
|
4559
|
+
toggleNotification({
|
|
4560
|
+
type: "success",
|
|
4561
|
+
message: t("impersonation.preview.ended", "Preview ended.")
|
|
4562
|
+
});
|
|
4563
|
+
onChanged?.();
|
|
4564
|
+
onClose();
|
|
4565
|
+
} catch (err) {
|
|
4566
|
+
index.logSafeAdminError("impersonation.end", err);
|
|
4567
|
+
toggleNotification({
|
|
4568
|
+
type: "danger",
|
|
4569
|
+
message: t("impersonation.error.end", "The impersonation could not be ended.")
|
|
4570
|
+
});
|
|
4571
|
+
} finally {
|
|
4572
|
+
setPending(null);
|
|
4573
|
+
}
|
|
4574
|
+
};
|
|
4575
|
+
const preview = result?.preview;
|
|
4576
|
+
const close = () => {
|
|
4577
|
+
if (result?.impersonation?.id && !ended) {
|
|
4578
|
+
post(`/${index.pluginId}/impersonation/${result.impersonation.id}/end`, {}).then(() => onChanged?.()).catch((err) => index.logSafeAdminError("impersonation.end", err));
|
|
4579
|
+
}
|
|
4580
|
+
onClose();
|
|
4581
|
+
};
|
|
4582
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: true, onOpenChange: (open) => open ? null : close(), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { onCloseAutoFocus, "aria-describedby": void 0, children: [
|
|
4583
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: t("impersonation.preview.title", "View as {name}", { name: name || `#${admin.id}` }) }) }),
|
|
4584
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
4585
|
+
failure ? /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "danger", closeLabel: t("common.close", "Close"), children: failure }) : null,
|
|
4586
|
+
!result ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4587
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "p", children: t(
|
|
4588
|
+
"impersonation.preview.intro",
|
|
4589
|
+
"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."
|
|
4590
|
+
) }),
|
|
4591
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4592
|
+
designSystem.Field.Root,
|
|
4593
|
+
{
|
|
4594
|
+
name: "reason",
|
|
4595
|
+
required: true,
|
|
4596
|
+
error: touched && reasonError ? tError(reasonError) : void 0,
|
|
4597
|
+
hint: t("impersonation.preview.reason.hint", "Stored in the security log."),
|
|
4598
|
+
children: [
|
|
4599
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("impersonation.reason.label", "Reason") }),
|
|
4600
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4601
|
+
designSystem.Textarea,
|
|
4602
|
+
{
|
|
4603
|
+
value: reason,
|
|
4604
|
+
maxLength: index.REASON_MAX,
|
|
4605
|
+
placeholder: t("impersonation.reason.placeholder", "For example: ticket 4711"),
|
|
4606
|
+
onChange: (event) => setReason(event.target.value),
|
|
4607
|
+
onBlur: () => setTouched(true)
|
|
4608
|
+
}
|
|
4609
|
+
),
|
|
4610
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
|
|
4611
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
4612
|
+
]
|
|
4613
|
+
}
|
|
4614
|
+
),
|
|
4615
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "durationMinutes", children: [
|
|
4616
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("impersonation.duration.label", "Duration") }),
|
|
4617
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4618
|
+
designSystem.SingleSelect,
|
|
4619
|
+
{
|
|
4620
|
+
value: String(minutes),
|
|
4621
|
+
onChange: (value) => setMinutes(Number(value)),
|
|
4622
|
+
children: ADMIN_PREVIEW_DURATIONS.map((value) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: String(value), children: t(
|
|
4623
|
+
"impersonation.duration.minutes",
|
|
4624
|
+
"{count, plural, one {# minute} other {# minutes}}",
|
|
4625
|
+
{ count: value }
|
|
4626
|
+
) }, value))
|
|
4627
|
+
}
|
|
4628
|
+
)
|
|
4629
|
+
] })
|
|
4630
|
+
] }) : null,
|
|
4631
|
+
result ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4632
|
+
designSystem.Box,
|
|
4633
|
+
{
|
|
4634
|
+
padding: 3,
|
|
4635
|
+
hasRadius: true,
|
|
4636
|
+
background: ended ? "neutral150" : "primary100",
|
|
4637
|
+
borderColor: ended ? "neutral200" : "primary200",
|
|
4638
|
+
"data-preview-banner": "",
|
|
4639
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, wrap: "wrap", justifyContent: "space-between", alignItems: "center", children: [
|
|
4640
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", "aria-live": "polite", children: ended ? t("impersonation.preview.banner.ended", "The preview ended.") : t(
|
|
4641
|
+
"impersonation.preview.banner",
|
|
4642
|
+
"You are viewing as {name} · read-only · ends in {time}",
|
|
4643
|
+
{ name: name || `#${admin.id}`, time: index.formatClock(secondsLeft) }
|
|
4644
|
+
) }),
|
|
4645
|
+
!ended ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4646
|
+
designSystem.Button,
|
|
4647
|
+
{
|
|
4648
|
+
size: "S",
|
|
4649
|
+
variant: "danger-light",
|
|
4650
|
+
onClick: end,
|
|
4651
|
+
loading: pending === "end",
|
|
4652
|
+
children: t("impersonation.preview.end", "End")
|
|
4653
|
+
}
|
|
4654
|
+
) : null
|
|
4655
|
+
] })
|
|
4656
|
+
}
|
|
4657
|
+
) : null,
|
|
4658
|
+
preview && !ended ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, "data-preview-body": "", children: [
|
|
4659
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t("impersonation.preview.roles", "Roles: {roles}", {
|
|
4660
|
+
roles: preview.admin.roles.map((role) => role.name).join(", ") || "—"
|
|
4661
|
+
}) }),
|
|
4662
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
4663
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h3", textColor: "neutral800", children: t("impersonation.preview.contentTypes", "Content types") }),
|
|
4664
|
+
preview.contentTypes.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4665
|
+
designSystem.Flex,
|
|
4666
|
+
{
|
|
4667
|
+
tag: "ul",
|
|
4668
|
+
direction: "column",
|
|
4669
|
+
alignItems: "stretch",
|
|
4670
|
+
gap: 2,
|
|
4671
|
+
margin: 0,
|
|
4672
|
+
padding: 0,
|
|
4673
|
+
style: { listStyle: "none" },
|
|
4674
|
+
children: preview.contentTypes.map((type) => /* @__PURE__ */ jsxRuntime.jsx(ContentTypeRow, { type }, type.uid))
|
|
4675
|
+
}
|
|
4676
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", tag: "p", children: t(
|
|
4677
|
+
"impersonation.preview.noContentTypes",
|
|
4678
|
+
"This admin cannot open any content type in the Content Manager."
|
|
4679
|
+
) })
|
|
4680
|
+
] }),
|
|
4681
|
+
preview.otherPermissions.length ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
4682
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h3", textColor: "neutral800", children: t("impersonation.preview.other", "Other permissions") }),
|
|
4683
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4684
|
+
designSystem.Flex,
|
|
4685
|
+
{
|
|
4686
|
+
tag: "ul",
|
|
4687
|
+
direction: "column",
|
|
4688
|
+
alignItems: "stretch",
|
|
4689
|
+
gap: 1,
|
|
4690
|
+
margin: 0,
|
|
4691
|
+
paddingLeft: 5,
|
|
4692
|
+
children: preview.otherPermissions.map((permission) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4693
|
+
designSystem.Typography,
|
|
4694
|
+
{
|
|
4695
|
+
tag: "li",
|
|
4696
|
+
variant: "pi",
|
|
4697
|
+
textColor: "neutral800",
|
|
4698
|
+
children: permission.name
|
|
4699
|
+
},
|
|
4700
|
+
permission.action
|
|
4701
|
+
))
|
|
4702
|
+
}
|
|
4703
|
+
)
|
|
4704
|
+
] }) : null
|
|
4705
|
+
] }) : null
|
|
4706
|
+
] }) }),
|
|
4707
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { children: result ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: ended ? t("impersonation.result.done", "Done") : t("impersonation.preview.close", "End and close") }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4708
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: t("common.cancel", "Cancel") }) }),
|
|
4709
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: start, loading: pending === "start", children: t("impersonation.preview.start", "View permissions") })
|
|
4710
|
+
] }) })
|
|
4711
|
+
] }) });
|
|
4712
|
+
};
|
|
4409
4713
|
const SETTINGS_USERS_PATH = "/settings/users";
|
|
4410
4714
|
const PaginationTargets$1 = styled__default.default.div`
|
|
4411
4715
|
nav a {
|
|
@@ -4436,6 +4740,11 @@ const AdminPanelPage = () => {
|
|
|
4436
4740
|
const {
|
|
4437
4741
|
allowedActions: { canRead: canViewActivity }
|
|
4438
4742
|
} = StrapiAdmin.useRBAC(index.pluginPermissions.adminActivityRead);
|
|
4743
|
+
const {
|
|
4744
|
+
allowedActions: { canAdmins: canPreviewAdmins }
|
|
4745
|
+
} = StrapiAdmin.useRBAC(index.pluginPermissions.impersonateAdmins);
|
|
4746
|
+
const [impersonationEnabled, setImpersonationEnabled] = react.useState(false);
|
|
4747
|
+
const [previewTarget, setPreviewTarget] = react.useState(null);
|
|
4439
4748
|
const [admins, setAdmins] = react.useState([]);
|
|
4440
4749
|
const [meta, setMeta] = react.useState(null);
|
|
4441
4750
|
const [loading, setLoading] = react.useState(true);
|
|
@@ -4451,6 +4760,18 @@ const AdminPanelPage = () => {
|
|
|
4451
4760
|
const dialogRequestRef = react.useRef(0);
|
|
4452
4761
|
const hasLoadedRef = react.useRef(false);
|
|
4453
4762
|
const openerRef = react.useRef(null);
|
|
4763
|
+
react.useEffect(() => {
|
|
4764
|
+
if (!canPreviewAdmins) return void 0;
|
|
4765
|
+
let current = true;
|
|
4766
|
+
get(`/${index.pluginId}/impersonation/status`).then(({ data }) => {
|
|
4767
|
+
if (current) setImpersonationEnabled(data?.data?.enabled === true);
|
|
4768
|
+
}).catch((err) => {
|
|
4769
|
+
if (!index.isCancelledRequest(err)) index.logSafeAdminError("impersonation.status", err);
|
|
4770
|
+
});
|
|
4771
|
+
return () => {
|
|
4772
|
+
current = false;
|
|
4773
|
+
};
|
|
4774
|
+
}, [canPreviewAdmins, get]);
|
|
4454
4775
|
const confirmReturnRef = react.useRef(null);
|
|
4455
4776
|
const captionRef = react.useRef(null);
|
|
4456
4777
|
const pageRef = react.useRef(null);
|
|
@@ -4666,6 +4987,11 @@ const AdminPanelPage = () => {
|
|
|
4666
4987
|
canRevoke: Boolean(canRevoke),
|
|
4667
4988
|
onView: openDialog,
|
|
4668
4989
|
onSignOutEverywhere: (admin, trigger) => askSignOut(admin, null, trigger),
|
|
4990
|
+
canPreview: Boolean(canPreviewAdmins) && impersonationEnabled,
|
|
4991
|
+
onPreview: (admin, trigger) => {
|
|
4992
|
+
openerRef.current = trigger;
|
|
4993
|
+
setPreviewTarget({ id: admin.id, name: admin.name });
|
|
4994
|
+
},
|
|
4669
4995
|
busy: refreshing
|
|
4670
4996
|
};
|
|
4671
4997
|
const policy = meta?.policy;
|
|
@@ -4923,6 +5249,14 @@ const AdminPanelPage = () => {
|
|
|
4923
5249
|
},
|
|
4924
5250
|
`${selected.id}-${dialogTab}`
|
|
4925
5251
|
) : null,
|
|
5252
|
+
previewTarget ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5253
|
+
PreviewAdminModal,
|
|
5254
|
+
{
|
|
5255
|
+
admin: previewTarget,
|
|
5256
|
+
onClose: () => setPreviewTarget(null),
|
|
5257
|
+
onCloseAutoFocus: (event) => index.restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
|
|
5258
|
+
}
|
|
5259
|
+
) : null,
|
|
4926
5260
|
confirm ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4927
5261
|
index.ConfirmAction,
|
|
4928
5262
|
{
|
|
@@ -7,7 +7,7 @@ const styled = require("styled-components");
|
|
|
7
7
|
const designSystem = require("@strapi/design-system");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
9
|
const StrapiAdmin = require("@strapi/strapi/admin");
|
|
10
|
-
const index = require("./index-
|
|
10
|
+
const index = require("./index-Ceh3Q1Ki.js");
|
|
11
11
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
12
12
|
function _interopNamespace(e) {
|
|
13
13
|
if (e && e.__esModule) return e;
|
|
@@ -6,7 +6,7 @@ import { Flex, Loader, Button, Box, Typography } from "@strapi/design-system";
|
|
|
6
6
|
import { User, Lightning, Clock, Lock, WarningCircle } from "@strapi/icons";
|
|
7
7
|
import * as StrapiAdmin from "@strapi/strapi/admin";
|
|
8
8
|
import { useFetchClient } from "@strapi/strapi/admin";
|
|
9
|
-
import { l as logSafeAdminError, n as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-
|
|
9
|
+
import { l as logSafeAdminError, n as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-meLDPPwt.mjs";
|
|
10
10
|
function normalizeUserCounts(response) {
|
|
11
11
|
const totalUsers = response?.data?.totalUsers;
|
|
12
12
|
const blockedUsers = response?.data?.blockedUsers;
|