strapi-plugin-magic-sessionmanager 4.20.0 → 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.
Files changed (29) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +58 -39
  3. package/dist/admin/{Analytics-B5GnwMtH.js → Analytics-BqdZIBV4.js} +1 -1
  4. package/dist/admin/{Analytics-B-MVQ6dQ.mjs → Analytics-C-OLLzoB.mjs} +1 -1
  5. package/dist/admin/{App-DzbP5VPQ.mjs → App-BswHmNQT.mjs} +338 -4
  6. package/dist/admin/{App-xBOmg4g9.js → App-Cx9v6n_7.js} +337 -3
  7. package/dist/admin/{OnlineUsersWidget-FuPPPCCV.js → OnlineUsersWidget-BRmQPPp9.js} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-Bf3BICmx.mjs → OnlineUsersWidget-Dusgjc1d.mjs} +1 -1
  9. package/dist/admin/{Settings-WRIXHLDa.js → Settings-DWGuf_Z3.js} +17 -9
  10. package/dist/admin/{Settings-hpkloyO6.mjs → Settings-DZyQheUS.mjs} +17 -9
  11. package/dist/admin/{de-Uqb30N5n.js → de-24TPqzG6.js} +32 -1
  12. package/dist/admin/{de-Bzd14FzX.mjs → de-DUnrmFWk.mjs} +32 -1
  13. package/dist/admin/{en-CDBcocLk.js → en-8mBSkWOF.js} +32 -1
  14. package/dist/admin/{en-DovyVwa5.mjs → en-D8J__tyF.mjs} +32 -1
  15. package/dist/admin/{es-BygJxl1J.mjs → es-BgpgWdk0.mjs} +32 -1
  16. package/dist/admin/{es-DA1X0RPv.js → es-ChUKey-Q.js} +32 -1
  17. package/dist/admin/{fr-CPPA27jW.js → fr-DE_CWmgq.js} +32 -1
  18. package/dist/admin/{fr-DONxL73-.mjs → fr-k1MHYKJo.mjs} +32 -1
  19. package/dist/admin/{index-Q_D-5LlE.js → index-Ceh3Q1Ki.js} +20 -10
  20. package/dist/admin/{index-DsaGGK7x.mjs → index-meLDPPwt.mjs} +34 -24
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +2 -2
  23. package/dist/admin/{pt-BMuwyaan.js → pt-BjqU5ioB.js} +32 -1
  24. package/dist/admin/{pt-D2yGNz2N.mjs → pt-DPO4DmDc.mjs} +32 -1
  25. package/dist/admin/{settingsTabs--7IsqMdn.mjs → settingsTabs-C1q5iMMw.mjs} +1 -1
  26. package/dist/admin/{settingsTabs-Dxlevody.js → settingsTabs-CfquZuKH.js} +1 -1
  27. package/dist/server/index.js +496 -12
  28. package/dist/server/index.mjs +496 -12
  29. 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-Q_D-5LlE.js");
13
- const settingsTabs = require("./settingsTabs-Dxlevody.js");
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 = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywhere }) => {
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-Q_D-5LlE.js");
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-DsaGGK7x.mjs";
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;
@@ -6,9 +6,9 @@ const designSystem = require("@strapi/design-system");
6
6
  const StrapiAdmin = require("@strapi/strapi/admin");
7
7
  const icons = require("@strapi/icons");
8
8
  const styled = require("styled-components");
9
- const index = require("./index-Q_D-5LlE.js");
9
+ const index = require("./index-Ceh3Q1Ki.js");
10
10
  require("react-intl");
11
- const settingsTabs = require("./settingsTabs-Dxlevody.js");
11
+ const settingsTabs = require("./settingsTabs-CfquZuKH.js");
12
12
  const SectionCard = require("./SectionCard-BlWv8CRt.js");
13
13
  const symbols = require("@strapi/icons/symbols");
14
14
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
@@ -5263,7 +5263,7 @@ const ActiveImpersonationsCard = () => {
5263
5263
  {
5264
5264
  fallbackFocusRef: refreshRef,
5265
5265
  title: t("impersonation.confirm.title", "End the impersonation of {user}?", {
5266
- user: row.targetLabel
5266
+ user: label(row)
5267
5267
  }),
5268
5268
  body: t(
5269
5269
  "impersonation.confirm.body",
@@ -5276,7 +5276,7 @@ const ActiveImpersonationsCard = () => {
5276
5276
  {
5277
5277
  variant: "ghost",
5278
5278
  label: t("impersonation.endLabel", "End impersonation of {user}", {
5279
- user: row.targetLabel
5279
+ user: label(row)
5280
5280
  }),
5281
5281
  children: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {})
5282
5282
  }
@@ -5284,6 +5284,8 @@ const ActiveImpersonationsCard = () => {
5284
5284
  },
5285
5285
  row.id
5286
5286
  );
5287
+ const label = (row) => row.targetLabel || (row.targetType === "admin" ? t("impersonation.list.adminFallback", "Admin #{id}", { id: row.targetId }) : row.targetId);
5288
+ const kind = (row) => row.targetType === "admin" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "primary100", textColor: "neutral800", children: t("impersonation.list.kind.admin", "Admin, view only") }) : null;
5287
5289
  const time = (iso) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "time", dateTime: iso, variant: "omega", textColor: "neutral800", children: formatDate(iso, { hour: "2-digit", minute: "2-digit" }) });
5288
5290
  const startedBy = (row) => row.startedByYou ? t("impersonation.list.you", "You") : row.actorLabel || "—";
5289
5291
  let content;
@@ -5324,7 +5326,10 @@ const ActiveImpersonationsCard = () => {
5324
5326
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("impersonation.list.col.actions", "Actions") }) })
5325
5327
  ] }) }),
5326
5328
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-impersonation-row": "", children: [
5327
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: row.targetLabel }) }),
5329
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
5330
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: label(row) }),
5331
+ kind(row)
5332
+ ] }) }),
5328
5333
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: startedBy(row) }) }),
5329
5334
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { maxWidth: 0, width: "40%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
5330
5335
  designSystem.Typography,
@@ -5343,7 +5348,10 @@ const ActiveImpersonationsCard = () => {
5343
5348
  } else {
5344
5349
  content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", "data-impersonations-list": "", children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "li", padding: 4, hasRadius: true, borderColor: "neutral150", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
5345
5350
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
5346
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: row.targetLabel }),
5351
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
5352
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: label(row) }),
5353
+ kind(row)
5354
+ ] }),
5347
5355
  /* @__PURE__ */ jsxRuntime.jsx(
5348
5356
  designSystem.Typography,
5349
5357
  {
@@ -5406,8 +5414,8 @@ const ImpersonationTab = ({ form }) => {
5406
5414
  const locked = form.canChangeProtected === false;
5407
5415
  const {
5408
5416
  isLoading,
5409
- allowedActions: { canUsers }
5410
- } = StrapiAdmin.useRBAC(index.pluginPermissions.impersonateUsers);
5417
+ allowedActions: { canUsers, canAdmins }
5418
+ } = StrapiAdmin.useRBAC([...index.pluginPermissions.impersonateUsers, ...index.pluginPermissions.impersonateAdmins]);
5411
5419
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
5412
5420
  /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
5413
5421
  "settings.impersonation.intro",
@@ -5432,7 +5440,7 @@ const ImpersonationTab = ({ form }) => {
5432
5440
  ) })
5433
5441
  }
5434
5442
  ) }),
5435
- !isLoading && canUsers ? /* @__PURE__ */ jsxRuntime.jsx(ActiveImpersonationsCard, {}) : null
5443
+ !isLoading && (canUsers || canAdmins) ? /* @__PURE__ */ jsxRuntime.jsx(ActiveImpersonationsCard, {}) : null
5436
5444
  ] });
5437
5445
  };
5438
5446
  const INITIAL_SETTINGS = { ...SETTINGS_DEFAULTS, emailTemplates: fillMissingTemplates({}) };
@@ -4,9 +4,9 @@ import { Field, Typography, Switch, Box, TextInput, Flex, Button, Link, SingleSe
4
4
  import { useFetchClient, useNotification, useRBAC, ConfirmDialog, useQueryParams, Page, Form, Blocker, useForm } from "@strapi/strapi/admin";
5
5
  import { EyeStriked, Eye, Key, Duplicate, Plus, Pencil, Trash, Lock, ArrowClockwise, Cross, Download, Check, SignOut } from "@strapi/icons";
6
6
  import styled from "styled-components";
7
- import { y as ReadableParagraphs, z as useSettingsTranslate, l as logSafeAdminError, R as ReadableText, f as pluginId, n as isCancelledRequest, h as PersistentAlert, A as EqualGrid, u as useSessionFormatters, j as pluginPermissions, C as ConfirmAction, P as PropertyList, B as formatSessionDate, F as refocusIfLost, G as copyText, H as requireSuccessfulMutation, q as PageShell } from "./index-DsaGGK7x.mjs";
7
+ import { G as ReadableParagraphs, y as useSettingsTranslate, l as logSafeAdminError, R as ReadableText, f as pluginId, n as isCancelledRequest, h as PersistentAlert, H as EqualGrid, u as useSessionFormatters, j as pluginPermissions, C as ConfirmAction, P as PropertyList, I as formatSessionDate, J as refocusIfLost, K as copyText, L as requireSuccessfulMutation, q as PageShell } from "./index-meLDPPwt.mjs";
8
8
  import "react-intl";
9
- import { v as buildTabSearch, x as buildSelectOptions, u as useElementWidth, b as RowActions, s as shouldIsolateActionKey, y as SELECT_PRESETS, z as fieldHasError, B as getRiskAvailability, C as riskDependentControl, E as usesLocalDatabase, F as getErrorTab, G as buildSavePayload, q as SETTINGS_FIELD_LABELS, H as getVisibleSettingsTabs, I as resolveSettingsTab, J as getRevealScrollDelta, t as SETTINGS_TAB_LABELS } from "./settingsTabs--7IsqMdn.mjs";
9
+ import { v as buildTabSearch, x as buildSelectOptions, u as useElementWidth, b as RowActions, s as shouldIsolateActionKey, y as SELECT_PRESETS, z as fieldHasError, B as getRiskAvailability, C as riskDependentControl, E as usesLocalDatabase, F as getErrorTab, G as buildSavePayload, q as SETTINGS_FIELD_LABELS, H as getVisibleSettingsTabs, I as resolveSettingsTab, J as getRevealScrollDelta, t as SETTINGS_TAB_LABELS } from "./settingsTabs-C1q5iMMw.mjs";
10
10
  import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
11
11
  import { EmptyPermissions } from "@strapi/icons/symbols";
12
12
  const FieldFrame = styled.div`
@@ -5259,7 +5259,7 @@ const ActiveImpersonationsCard = () => {
5259
5259
  {
5260
5260
  fallbackFocusRef: refreshRef,
5261
5261
  title: t("impersonation.confirm.title", "End the impersonation of {user}?", {
5262
- user: row.targetLabel
5262
+ user: label(row)
5263
5263
  }),
5264
5264
  body: t(
5265
5265
  "impersonation.confirm.body",
@@ -5272,7 +5272,7 @@ const ActiveImpersonationsCard = () => {
5272
5272
  {
5273
5273
  variant: "ghost",
5274
5274
  label: t("impersonation.endLabel", "End impersonation of {user}", {
5275
- user: row.targetLabel
5275
+ user: label(row)
5276
5276
  }),
5277
5277
  children: /* @__PURE__ */ jsx(SignOut, {})
5278
5278
  }
@@ -5280,6 +5280,8 @@ const ActiveImpersonationsCard = () => {
5280
5280
  },
5281
5281
  row.id
5282
5282
  );
5283
+ const label = (row) => row.targetLabel || (row.targetType === "admin" ? t("impersonation.list.adminFallback", "Admin #{id}", { id: row.targetId }) : row.targetId);
5284
+ const kind = (row) => row.targetType === "admin" ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "primary100", textColor: "neutral800", children: t("impersonation.list.kind.admin", "Admin, view only") }) : null;
5283
5285
  const time = (iso) => /* @__PURE__ */ jsx(Typography, { tag: "time", dateTime: iso, variant: "omega", textColor: "neutral800", children: formatDate(iso, { hour: "2-digit", minute: "2-digit" }) });
5284
5286
  const startedBy = (row) => row.startedByYou ? t("impersonation.list.you", "You") : row.actorLabel || "—";
5285
5287
  let content;
@@ -5320,7 +5322,10 @@ const ActiveImpersonationsCard = () => {
5320
5322
  /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: t("impersonation.list.col.actions", "Actions") }) })
5321
5323
  ] }) }),
5322
5324
  /* @__PURE__ */ jsx(Tbody, { children: rows.map((row) => /* @__PURE__ */ jsxs(Tr, { "data-impersonation-row": "", children: [
5323
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: row.targetLabel }) }),
5325
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
5326
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: label(row) }),
5327
+ kind(row)
5328
+ ] }) }),
5324
5329
  /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: startedBy(row) }) }),
5325
5330
  /* @__PURE__ */ jsx(Td, { style: { maxWidth: 0, width: "40%" }, children: /* @__PURE__ */ jsx(
5326
5331
  Typography,
@@ -5339,7 +5344,10 @@ const ActiveImpersonationsCard = () => {
5339
5344
  } else {
5340
5345
  content = /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", "data-impersonations-list": "", children: rows.map((row) => /* @__PURE__ */ jsx(Box, { tag: "li", padding: 4, hasRadius: true, borderColor: "neutral150", children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
5341
5346
  /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
5342
- /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: row.targetLabel }),
5347
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
5348
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: label(row) }),
5349
+ kind(row)
5350
+ ] }),
5343
5351
  /* @__PURE__ */ jsx(
5344
5352
  Typography,
5345
5353
  {
@@ -5402,8 +5410,8 @@ const ImpersonationTab = ({ form }) => {
5402
5410
  const locked = form.canChangeProtected === false;
5403
5411
  const {
5404
5412
  isLoading,
5405
- allowedActions: { canUsers }
5406
- } = useRBAC(pluginPermissions.impersonateUsers);
5413
+ allowedActions: { canUsers, canAdmins }
5414
+ } = useRBAC([...pluginPermissions.impersonateUsers, ...pluginPermissions.impersonateAdmins]);
5407
5415
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
5408
5416
  /* @__PURE__ */ jsx(IntroText, { children: t(
5409
5417
  "settings.impersonation.intro",
@@ -5428,7 +5436,7 @@ const ImpersonationTab = ({ form }) => {
5428
5436
  ) })
5429
5437
  }
5430
5438
  ) }),
5431
- !isLoading && canUsers ? /* @__PURE__ */ jsx(ActiveImpersonationsCard, {}) : null
5439
+ !isLoading && (canUsers || canAdmins) ? /* @__PURE__ */ jsx(ActiveImpersonationsCard, {}) : null
5432
5440
  ] });
5433
5441
  };
5434
5442
  const INITIAL_SETTINGS = { ...SETTINGS_DEFAULTS, emailTemplates: fillMissingTemplates({}) };
@@ -1066,6 +1066,37 @@ const de = {
1066
1066
  "settings.config.tab.impersonation": "Identitätsübernahme",
1067
1067
  "impersonation.reason.tooShort": "Geben Sie einen Grund mit mindestens {min} Zeichen ein.",
1068
1068
  "impersonation.reason.tooLong": "Verwenden Sie höchstens {max} Zeichen.",
1069
- "impersonation.error.csp": "Die Sicherheitseinstellungen von Strapi verhindern, dass die Anmeldung an {origin} gesendet wird. Fügen Sie diesen Ursprung zu form-action der Content-Security-Policy hinzu (siehe Dokumentation) und starten Sie erneut."
1069
+ "impersonation.error.csp": "Die Sicherheitseinstellungen von Strapi verhindern, dass die Anmeldung an {origin} gesendet wird. Fügen Sie diesen Ursprung zu form-action der Content-Security-Policy hinzu (siehe Dokumentation) und starten Sie erneut.",
1070
+ "impersonation.list.adminFallback": "Admin Nr. {id}",
1071
+ "impersonation.list.kind.admin": "Admin, nur Ansicht",
1072
+ "impersonation.preview.error.self": "Sie können sich nicht selbst als anderer Admin ansehen.",
1073
+ "impersonation.preview.error.superAdmin": "Super Admins können nicht als anderer Admin angesehen werden.",
1074
+ "impersonation.preview.error.notSubset": "Dieser Admin hat Berechtigungen, die Sie nicht haben. Deshalb können Sie ihn nicht ansehen.",
1075
+ "impersonation.preview.action.create": "Erstellen",
1076
+ "impersonation.preview.action.read": "Lesen",
1077
+ "impersonation.preview.action.update": "Bearbeiten",
1078
+ "impersonation.preview.action.delete": "Löschen",
1079
+ "impersonation.preview.action.publish": "Veröffentlichen",
1080
+ "impersonation.preview.condition.creator": "selbst erstellte Einträge",
1081
+ "impersonation.preview.condition.sameRole": "Einträge von Personen mit derselben Rolle",
1082
+ "impersonation.preview.restricted": "{action} (eingeschränkt)",
1083
+ "impersonation.preview.fields": "{action}: {count, plural, one {# Feld} other {# Felder}}",
1084
+ "impersonation.preview.conditions": "{action}: nur {conditions}",
1085
+ "impersonation.preview.error.start": "Die Vorschau konnte nicht geöffnet werden.",
1086
+ "impersonation.preview.ended": "Vorschau beendet.",
1087
+ "impersonation.preview.title": "Als {name} ansehen",
1088
+ "impersonation.preview.intro": "Sehen Sie, welche Inhaltstypen und Aktionen dieser Admin nutzen kann, ermittelt aus seinen Rollen. Nur Ansicht: Niemand wird angemeldet und nichts kann geändert werden. Der Vorgang wird im Sicherheitsprotokoll festgehalten.",
1089
+ "impersonation.preview.reason.hint": "Wird im Sicherheitsprotokoll gespeichert.",
1090
+ "impersonation.preview.banner.ended": "Die Vorschau ist beendet.",
1091
+ "impersonation.preview.banner": "Sie sehen die Ansicht von {name} · nur lesen · endet in {time}",
1092
+ "impersonation.preview.end": "Beenden",
1093
+ "impersonation.preview.roles": "Rollen: {roles}",
1094
+ "impersonation.preview.contentTypes": "Inhaltstypen",
1095
+ "impersonation.preview.noContentTypes": "Dieser Admin kann keinen Inhaltstyp im Content Manager öffnen.",
1096
+ "impersonation.preview.other": "Weitere Berechtigungen",
1097
+ "impersonation.preview.close": "Beenden und schließen",
1098
+ "impersonation.preview.start": "Berechtigungen ansehen",
1099
+ "adminPanel.actions.viewAs": "Als {name} ansehen",
1100
+ "adminPanel.actions.viewAsShort": "Ansehen als"
1070
1101
  };
1071
1102
  exports.default = de;