strapi-plugin-magic-sessionmanager 4.22.1 → 4.23.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 (35) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +116 -82
  3. package/dist/admin/ActiveImpersonationsCard-CbyOAlrL.mjs +396 -0
  4. package/dist/admin/ActiveImpersonationsCard-D1CVmV-w.js +395 -0
  5. package/dist/admin/{Analytics-CIHgaURb.mjs → Analytics-DGAHD19E.mjs} +1 -1
  6. package/dist/admin/{Analytics-B7BAjApz.js → Analytics-_WA68oHb.js} +1 -1
  7. package/dist/admin/{App-DJkJC06E.js → App-CfhAQ17e.js} +304 -104
  8. package/dist/admin/{App-CPE-CQGz.mjs → App-VB66H73A.mjs} +276 -76
  9. package/dist/admin/ImpersonationTabBanner-B6Ps5-oe.mjs +244 -0
  10. package/dist/admin/ImpersonationTabBanner-DdwXNmh4.js +244 -0
  11. package/dist/admin/{OnlineUsersWidget-Dou2hxGY.mjs → OnlineUsersWidget-2u-fYMb7.mjs} +1 -1
  12. package/dist/admin/{OnlineUsersWidget-CcjNfzzf.js → OnlineUsersWidget-CmBqFLAA.js} +1 -1
  13. package/dist/admin/{Settings--eEiHv_a.js → Settings-BBs2FDp7.js} +27 -229
  14. package/dist/admin/{Settings-h_exWUiI.mjs → Settings-CKDNGJhl.mjs} +19 -221
  15. package/dist/admin/{de-Wz5Emtrb.mjs → de-CK-HuY41.mjs} +42 -4
  16. package/dist/admin/{de-oBmcAcXj.js → de-CSRQPn6F.js} +42 -4
  17. package/dist/admin/{en-B1TN5F62.js → en-DCtAgGEa.js} +42 -4
  18. package/dist/admin/{en-B_1Ka64U.mjs → en-KZ5ajaAR.mjs} +42 -4
  19. package/dist/admin/{es-CVgw4zsj.mjs → es-B7k8taWV.mjs} +42 -4
  20. package/dist/admin/{es-Bb515J0p.js → es-CKT00l4K.js} +42 -4
  21. package/dist/admin/{fr-yDdwunmg.js → fr-B2EdBFSb.js} +42 -4
  22. package/dist/admin/{fr-0AgMxTFc.mjs → fr-Q2gmYqCn.mjs} +42 -4
  23. package/dist/admin/{index-DVQ7tdTC.mjs → index-BPbs1GyP.mjs} +365 -57
  24. package/dist/admin/{index-qtN2dOm4.js → index-Cho0XGZ1.js} +319 -11
  25. package/dist/admin/index.js +1 -1
  26. package/dist/admin/index.mjs +2 -2
  27. package/dist/admin/{pt-BAB07LY-.js → pt-CcMUcqDy.js} +42 -4
  28. package/dist/admin/{pt-DtM74ffN.mjs → pt-CmxZTaf2.mjs} +42 -4
  29. package/dist/admin/useBreakpoint-CoBfu0Ov.js +62 -0
  30. package/dist/admin/useBreakpoint-CuyIc2qy.mjs +63 -0
  31. package/dist/server/index.js +867 -10
  32. package/dist/server/index.mjs +867 -10
  33. package/package.json +6 -2
  34. package/dist/admin/dashboardModel-DNT_l-Bk.js +0 -169
  35. package/dist/admin/dashboardModel-fApbKGay.mjs +0 -170
@@ -9,8 +9,9 @@ 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-qtN2dOm4.js");
13
- const dashboardModel = require("./dashboardModel-DNT_l-Bk.js");
12
+ const index = require("./index-Cho0XGZ1.js");
13
+ const useBreakpoint = require("./useBreakpoint-CoBfu0Ov.js");
14
+ const ActiveImpersonationsCard = require("./ActiveImpersonationsCard-D1CVmV-w.js");
14
15
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
15
16
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
16
17
  const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
@@ -94,64 +95,6 @@ function readSessionStats(payload) {
94
95
  stats.nativeOnlyAfterTracking = isCount$1(data?.nativeOnlyAfterTracking) ? data.nativeOnlyAfterTracking : null;
95
96
  return stats;
96
97
  }
97
- const DS_BREAKPOINTS = Object.freeze({
98
- small: "@media(min-width: 520px)",
99
- medium: "@media(min-width: 768px)",
100
- large: "@media(min-width: 1080px)"
101
- });
102
- const BREAKPOINT_ORDER = Object.freeze(["initial", "small", "medium", "large"]);
103
- function mediaQueryFromBreakpoint(breakpoint) {
104
- if (typeof breakpoint !== "string") return "";
105
- const query = breakpoint.replace(/^\s*@media\s*/i, "").trim();
106
- return /^\(.*\)$/.test(query) ? query : "";
107
- }
108
- function getBreakpointQueries(theme) {
109
- const source = theme?.breakpoints || {};
110
- return {
111
- small: mediaQueryFromBreakpoint(source.small) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.small),
112
- medium: mediaQueryFromBreakpoint(source.medium) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.medium),
113
- large: mediaQueryFromBreakpoint(source.large) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.large)
114
- };
115
- }
116
- function resolveBreakpoint(matches = {}) {
117
- if (matches.large) return "large";
118
- if (matches.medium) return "medium";
119
- if (matches.small) return "small";
120
- return "initial";
121
- }
122
- function isBelowBreakpoint(current, target) {
123
- return BREAKPOINT_ORDER.indexOf(current) < BREAKPOINT_ORDER.indexOf(target);
124
- }
125
- const readMatches = (queries) => {
126
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
127
- return { small: true, medium: true, large: true };
128
- }
129
- return {
130
- small: window.matchMedia(queries.small).matches,
131
- medium: window.matchMedia(queries.medium).matches,
132
- large: window.matchMedia(queries.large).matches
133
- };
134
- };
135
- function useBreakpoint() {
136
- const theme = styled.useTheme();
137
- const queries = react.useMemo(() => getBreakpointQueries(theme), [theme]);
138
- const [matches, setMatches] = react.useState(() => readMatches(queries));
139
- react.useEffect(() => {
140
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") return void 0;
141
- const lists = ["small", "medium", "large"].map((name) => window.matchMedia(queries[name]));
142
- const update = () => setMatches(readMatches(queries));
143
- update();
144
- lists.forEach((list) => list.addEventListener?.("change", update));
145
- return () => lists.forEach((list) => list.removeEventListener?.("change", update));
146
- }, [queries]);
147
- const breakpoint = resolveBreakpoint(matches);
148
- return {
149
- breakpoint,
150
- isBelowSmall: isBelowBreakpoint(breakpoint, "small"),
151
- isBelowMedium: isBelowBreakpoint(breakpoint, "medium"),
152
- isBelowLarge: isBelowBreakpoint(breakpoint, "large")
153
- };
154
- }
155
98
  const RISK_LEVEL_MESSAGES = Object.freeze({
156
99
  none: Object.freeze({ messageId: "modal.security.risk.none", defaultMessage: "None" }),
157
100
  low: Object.freeze({ messageId: "modal.security.risk.low", defaultMessage: "Low" }),
@@ -182,7 +125,7 @@ function normalizeGeoData(geo, fallback = {}) {
182
125
  const city = index.presentText(geo.city);
183
126
  const timezone = index.presentText(geo.timezone);
184
127
  if (!country && !city && !timezone) return null;
185
- const riskSource = dashboardModel.isRiskSource(geo.riskSource) ? geo.riskSource : null;
128
+ const riskSource = ActiveImpersonationsCard.isRiskSource(geo.riskSource) ? geo.riskSource : null;
186
129
  const rawScore = typeof geo.securityScore === "number" ? geo.securityScore : fallback?.securityScore;
187
130
  const securityScore = riskSource && typeof rawScore === "number" && Number.isFinite(rawScore) ? rawScore : null;
188
131
  return {
@@ -273,8 +216,8 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
273
216
  const userAgent = index.presentText(session.userAgent);
274
217
  const sessionId = index.presentText(session.id);
275
218
  const ipAddress = index.presentText(session.ipAddress);
276
- const user = dashboardModel.getSessionUserLabels(session);
277
- const userEditPath = dashboardModel.getUserEditPath(session);
219
+ const user = ActiveImpersonationsCard.getSessionUserLabels(session);
220
+ const userEditPath = ActiveImpersonationsCard.getUserEditPath(session);
278
221
  const storedGeo = getStoredGeoData(session);
279
222
  const liveGeo = lookup.status === "ok" ? lookup.geo : null;
280
223
  const geo = liveGeo || storedGeo;
@@ -506,7 +449,7 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
506
449
  "modal.security.riskUnavailableNote",
507
450
  "Needs a risk data source. Location data alone cannot tell VPNs, proxies or Tor apart, so no score was calculated."
508
451
  ) }),
509
- /* @__PURE__ */ jsxRuntime.jsx(TargetLink, { tag: reactRouterDom.NavLink, to: dashboardModel.RISK_SETTINGS_PATH, children: t("modal.security.riskSetup", "Set up risk data") })
452
+ /* @__PURE__ */ jsxRuntime.jsx(TargetLink, { tag: reactRouterDom.NavLink, to: ActiveImpersonationsCard.RISK_SETTINGS_PATH, children: t("modal.security.riskSetup", "Set up risk data") })
510
453
  ] }) : null,
511
454
  lookupControls
512
455
  ] }),
@@ -649,9 +592,9 @@ const isolateActionKeys = (event) => {
649
592
  /** @type {Node} */
650
593
  event.target
651
594
  );
652
- if (!dashboardModel.shouldIsolateActionKey(event.key, fromInsideGroup)) return;
595
+ if (!ActiveImpersonationsCard.shouldIsolateActionKey(event.key, fromInsideGroup)) return;
653
596
  event.stopPropagation();
654
- if (dashboardModel.shouldRedispatchEscape(event.key, fromInsideGroup)) {
597
+ if (ActiveImpersonationsCard.shouldRedispatchEscape(event.key, fromInsideGroup)) {
655
598
  const { ownerDocument } = event.currentTarget;
656
599
  ownerDocument.dispatchEvent(
657
600
  new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true })
@@ -699,7 +642,7 @@ const SessionActions = ({
699
642
  const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
700
643
  const [deleteOpen, setDeleteOpen] = react.useState(false);
701
644
  const moreRef = react.useRef(null);
702
- const user = dashboardModel.getSessionUserLabels(session).accessible;
645
+ const user = ActiveImpersonationsCard.getSessionUserLabels(session).accessible;
703
646
  const canEnd = session.isActive === true;
704
647
  const device = deviceSummary(session) || deviceTypeLabel(session);
705
648
  const copy = getConfirmationCopy(t, { user, device, isOpen: canEnd });
@@ -726,7 +669,7 @@ const SessionActions = ({
726
669
  );
727
670
  const endKey = `end-${session.id}-${canEnd ? "open" : "ended"}`;
728
671
  if (layout === "table") {
729
- return /* @__PURE__ */ jsxRuntime.jsxs(dashboardModel.RowActions, { onKeyDown: isolateActionKeys, onClick: (event) => event.stopPropagation(), children: [
672
+ return /* @__PURE__ */ jsxRuntime.jsxs(ActiveImpersonationsCard.RowActions, { onKeyDown: isolateActionKeys, onClick: (event) => event.stopPropagation(), children: [
730
673
  /* @__PURE__ */ jsxRuntime.jsx(
731
674
  designSystem.IconButton,
732
675
  {
@@ -867,7 +810,7 @@ const SessionTable = ({
867
810
  return /* @__PURE__ */ jsxRuntime.jsxs(
868
811
  designSystem.Table,
869
812
  {
870
- colCount: compact ? dashboardModel.DASHBOARD_COMPACT_TABLE_COLUMNS : dashboardModel.DASHBOARD_TABLE_COLUMNS,
813
+ colCount: compact ? ActiveImpersonationsCard.DASHBOARD_COMPACT_TABLE_COLUMNS : ActiveImpersonationsCard.DASHBOARD_TABLE_COLUMNS,
871
814
  rowCount: sessions.length + 1,
872
815
  "aria-labelledby": labelledBy,
873
816
  "aria-busy": busy,
@@ -882,7 +825,7 @@ const SessionTable = ({
882
825
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("homepage.table.actions", "Actions") }) })
883
826
  ] }) }),
884
827
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: sessions.map((session) => {
885
- const user = dashboardModel.getSessionUserLabels(session);
828
+ const user = ActiveImpersonationsCard.getSessionUserLabels(session);
886
829
  return /* @__PURE__ */ jsxRuntime.jsxs(
887
830
  designSystem.Tr,
888
831
  {
@@ -958,7 +901,7 @@ const SessionCardList = ({
958
901
  mutationPending,
959
902
  getFocusFallback
960
903
  }) => /* @__PURE__ */ jsxRuntime.jsx(CardList, { "aria-labelledby": labelledBy, "aria-busy": busy, children: sessions.map((session) => {
961
- const user = dashboardModel.getSessionUserLabels(session);
904
+ const user = ActiveImpersonationsCard.getSessionUserLabels(session);
962
905
  return /* @__PURE__ */ jsxRuntime.jsx(
963
906
  designSystem.Box,
964
907
  {
@@ -1094,12 +1037,12 @@ const Legend = styled__default.default.ul`
1094
1037
  const HowSessionsWork = () => {
1095
1038
  const { formatMessage } = reactIntl.useIntl();
1096
1039
  const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
1097
- const [open, setOpen] = react.useState(() => dashboardModel.readDisclosureOpen(dashboardModel.getBrowserStorage()));
1040
+ const [open, setOpen] = react.useState(() => ActiveImpersonationsCard.readDisclosureOpen(ActiveImpersonationsCard.getBrowserStorage()));
1098
1041
  const contentId = `how-sessions-work-${react.useId().replace(/:/g, "")}`;
1099
1042
  const toggle = () => {
1100
1043
  setOpen((previous) => {
1101
1044
  const next = !previous;
1102
- dashboardModel.writeDisclosureOpen(dashboardModel.getBrowserStorage(), next);
1045
+ ActiveImpersonationsCard.writeDisclosureOpen(ActiveImpersonationsCard.getBrowserStorage(), next);
1103
1046
  return next;
1104
1047
  });
1105
1048
  };
@@ -1716,7 +1659,8 @@ const SignInHistoryPanel = ({ admin }) => {
1716
1659
  all: t("adminPanel.activity.filter.allEvents", "All events"),
1717
1660
  succeeded: t("adminPanel.activity.filter.succeeded", "Sign-ins"),
1718
1661
  failed: t("adminPanel.activity.filter.failed", "Failed and locked out"),
1719
- "signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs")
1662
+ "signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs"),
1663
+ impersonation: t("adminPanel.activity.filter.impersonation", "Impersonation")
1720
1664
  };
1721
1665
  return /* @__PURE__ */ jsxRuntime.jsx(
1722
1666
  EventList,
@@ -1999,11 +1943,11 @@ const HomePage = () => {
1999
1943
  const { get, post, del } = StrapiAdmin.useFetchClient();
2000
1944
  const { toggleNotification } = StrapiAdmin.useNotification();
2001
1945
  const formatters = index.useSessionFormatters();
2002
- const { isBelowSmall, isBelowMedium, isBelowLarge } = useBreakpoint();
1946
+ const { isBelowSmall, isBelowMedium, isBelowLarge } = useBreakpoint.useBreakpoint();
2003
1947
  const [listWidthRef, listWidth] = index.useElementWidth();
2004
1948
  const [{ query }, setQuery] = StrapiAdmin.useQueryParams();
2005
1949
  const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
2006
- const dashboard = dashboardModel.parseDashboardQuery(query);
1950
+ const dashboard = ActiveImpersonationsCard.parseDashboardQuery(query);
2007
1951
  const [sessions, setSessions] = react.useState([]);
2008
1952
  const [pagination, setPagination] = react.useState({ total: 0, pageCount: 1 });
2009
1953
  const [stats, setStats] = react.useState(EMPTY_SESSION_STATS);
@@ -2080,7 +2024,7 @@ const HomePage = () => {
2080
2024
  if (showDetailModal || mutationPending) return void 0;
2081
2025
  const interval = setInterval(() => {
2082
2026
  fetchSessions();
2083
- }, dashboardModel.AUTO_REFRESH_INTERVAL_MS);
2027
+ }, ActiveImpersonationsCard.AUTO_REFRESH_INTERVAL_MS);
2084
2028
  return () => clearInterval(interval);
2085
2029
  }, [showDetailModal, mutationPending, fetchSessions]);
2086
2030
  const handleTerminateSession = async (session) => {
@@ -2097,7 +2041,7 @@ const HomePage = () => {
2097
2041
  });
2098
2042
  } catch (err) {
2099
2043
  index.logSafeAdminError("dashboard.terminateSession", err);
2100
- if (dashboardModel.getErrorStatus(err) === 404) {
2044
+ if (ActiveImpersonationsCard.getErrorStatus(err) === 404) {
2101
2045
  await fetchSessions();
2102
2046
  toggleNotification({
2103
2047
  type: "warning",
@@ -2137,7 +2081,7 @@ const HomePage = () => {
2137
2081
  });
2138
2082
  } catch (err) {
2139
2083
  index.logSafeAdminError("dashboard.deleteSession", err);
2140
- if (dashboardModel.getErrorStatus(err) === 404) {
2084
+ if (ActiveImpersonationsCard.getErrorStatus(err) === 404) {
2141
2085
  await fetchSessions();
2142
2086
  toggleNotification({
2143
2087
  type: "warning",
@@ -2193,7 +2137,7 @@ const HomePage = () => {
2193
2137
  if (format === "csv") {
2194
2138
  const csvContent = index.buildSessionCsv(rows, {
2195
2139
  unavailableValue: "",
2196
- getDeviceInfo: dashboardModel.getExportDeviceInfo,
2140
+ getDeviceInfo: ActiveImpersonationsCard.getExportDeviceInfo,
2197
2141
  getSessionStatus: index.getSessionStatus
2198
2142
  });
2199
2143
  downloadFile(csvContent, "text/csv;charset=utf-8;", "csv");
@@ -2203,7 +2147,7 @@ const HomePage = () => {
2203
2147
  totalSessions: stats.total,
2204
2148
  exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
2205
2149
  unavailableValue: "",
2206
- getDeviceInfo: dashboardModel.getExportDeviceInfo,
2150
+ getDeviceInfo: ActiveImpersonationsCard.getExportDeviceInfo,
2207
2151
  getSessionStatus: index.getSessionStatus,
2208
2152
  truncated: capped
2209
2153
  });
@@ -2245,7 +2189,7 @@ const HomePage = () => {
2245
2189
  const getFocusFallback = react.useCallback(
2246
2190
  (sessionId) => ({
2247
2191
  get current() {
2248
- const targetId = dashboardModel.pickFocusSessionId(
2192
+ const targetId = ActiveImpersonationsCard.pickFocusSessionId(
2249
2193
  mutationSnapshotRef.current,
2250
2194
  visibleIdsRef.current,
2251
2195
  sessionId
@@ -2276,7 +2220,7 @@ const HomePage = () => {
2276
2220
  };
2277
2221
  const handleSearch = react.useCallback(
2278
2222
  (value) => {
2279
- setQuery({ search: dashboardModel.encodeSearchQuery(value), _q: void 0, page: "1" }, "push", true);
2223
+ setQuery({ search: ActiveImpersonationsCard.encodeSearchQuery(value), _q: void 0, page: "1" }, "push", true);
2280
2224
  },
2281
2225
  [setQuery]
2282
2226
  );
@@ -2287,7 +2231,7 @@ const HomePage = () => {
2287
2231
  const showSessionData = !loading && hasData;
2288
2232
  const showToolbar = showSessionData && stats.total > 0;
2289
2233
  const canExport = showSessionData && pageResult.total > 0 && !exporting;
2290
- const filtersActive = dashboardModel.hasActiveFilters(dashboard);
2234
+ const filtersActive = ActiveImpersonationsCard.hasActiveFilters(dashboard);
2291
2235
  const exportValues = { count: Math.min(pageResult.total, MAX_EXPORT_ROWS) };
2292
2236
  const exportMenu = /* @__PURE__ */ jsxRuntime.jsxs(
2293
2237
  designSystem.SimpleMenu,
@@ -2538,7 +2482,7 @@ const HomePage = () => {
2538
2482
  SessionTable,
2539
2483
  {
2540
2484
  ...listProps,
2541
- compact: dashboardModel.shouldUseCompactTable(listWidth, isBelowLarge)
2485
+ compact: ActiveImpersonationsCard.shouldUseCompactTable(listWidth, isBelowLarge)
2542
2486
  }
2543
2487
  ),
2544
2488
  /* @__PURE__ */ jsxRuntime.jsx(PaginationTargets$3, { children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2546,9 +2490,9 @@ const HomePage = () => {
2546
2490
  {
2547
2491
  pageCount: pageResult.pageCount,
2548
2492
  total: pageResult.total,
2549
- defaultPageSize: Number(dashboardModel.DEFAULT_PAGE_SIZE),
2493
+ defaultPageSize: Number(ActiveImpersonationsCard.DEFAULT_PAGE_SIZE),
2550
2494
  children: [
2551
- /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...dashboardModel.PAGE_SIZE_OPTIONS] }),
2495
+ /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...ActiveImpersonationsCard.PAGE_SIZE_OPTIONS] }),
2552
2496
  /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.Links, {})
2553
2497
  ]
2554
2498
  }
@@ -2594,8 +2538,9 @@ const HomePage = () => {
2594
2538
  };
2595
2539
  const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
2596
2540
  const offersPreview = (admin, canPreview) => Boolean(canPreview) && admin.self !== true && !(admin.roles || []).some((role) => role?.superAdmin === true);
2541
+ const offersSignIn = (admin, canSignIn) => offersPreview(admin, canSignIn) && (admin.account === void 0 || admin.account === "active");
2597
2542
  const keepActionKeys = (event) => {
2598
- if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
2543
+ if (ActiveImpersonationsCard.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
2599
2544
  };
2600
2545
  const SHRINKING_ADMIN_CELL = { maxWidth: 0, width: "34%" };
2601
2546
  const SHRINKING_ROLES_CELL = { maxWidth: 0, width: "22%" };
@@ -2645,6 +2590,9 @@ const AdminTable = ({
2645
2590
  onSignOutEverywhere,
2646
2591
  canPreview,
2647
2592
  onPreview,
2593
+ canSignIn,
2594
+ signInUnavailable,
2595
+ onSignIn,
2648
2596
  busy
2649
2597
  }) => {
2650
2598
  const t = useT$2();
@@ -2668,7 +2616,7 @@ const AdminTable = ({
2668
2616
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin }) }),
2669
2617
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin }) }),
2670
2618
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: admin.lastActiveAt }) }),
2671
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: [
2619
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(ActiveImpersonationsCard.RowActions, { onKeyDown: keepActionKeys, children: [
2672
2620
  /* @__PURE__ */ jsxRuntime.jsx(
2673
2621
  designSystem.IconButton,
2674
2622
  {
@@ -2682,13 +2630,24 @@ const AdminTable = ({
2682
2630
  offersPreview(admin, canPreview) ? /* @__PURE__ */ jsxRuntime.jsx(
2683
2631
  designSystem.IconButton,
2684
2632
  {
2685
- label: t("adminPanel.actions.viewAs", "View as {name}", {
2633
+ label: t("adminPanel.actions.viewPermissions", "View permissions of {name}", {
2686
2634
  name: admin.name || `#${admin.id}`
2687
2635
  }),
2688
2636
  onClick: (event) => onPreview?.(admin, event.currentTarget),
2689
2637
  children: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {})
2690
2638
  }
2691
2639
  ) : null,
2640
+ offersSignIn(admin, canSignIn) ? /* @__PURE__ */ jsxRuntime.jsx(
2641
+ designSystem.IconButton,
2642
+ {
2643
+ label: signInUnavailable || t("adminPanel.actions.signInAs", "Sign in as {name}", {
2644
+ name: admin.name || `#${admin.id}`
2645
+ }),
2646
+ disabled: Boolean(signInUnavailable),
2647
+ onClick: (event) => onSignIn?.(admin, event.currentTarget),
2648
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Key, {})
2649
+ }
2650
+ ) : null,
2692
2651
  canRevoke && admin.canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
2693
2652
  designSystem.IconButton,
2694
2653
  {
@@ -2717,7 +2676,10 @@ const AdminCardList = ({
2717
2676
  onView,
2718
2677
  onSignOutEverywhere,
2719
2678
  canPreview,
2720
- onPreview
2679
+ onPreview,
2680
+ canSignIn,
2681
+ signInUnavailable,
2682
+ onSignIn
2721
2683
  }) => {
2722
2684
  const t = useT$2();
2723
2685
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -2768,11 +2730,29 @@ const AdminCardList = ({
2768
2730
  variant: "secondary",
2769
2731
  startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
2770
2732
  onClick: (event) => onPreview?.(admin, event.currentTarget),
2771
- "aria-label": t("adminPanel.actions.viewAs", "View as {name}", {
2733
+ "aria-label": t(
2734
+ "adminPanel.actions.viewPermissions",
2735
+ "View permissions of {name}",
2736
+ {
2737
+ name: admin.name || `#${admin.id}`
2738
+ }
2739
+ ),
2740
+ flex: "1 1 auto",
2741
+ children: t("adminPanel.actions.viewPermissionsShort", "View permissions")
2742
+ }
2743
+ ) : null,
2744
+ offersSignIn(admin, canSignIn) ? /* @__PURE__ */ jsxRuntime.jsx(
2745
+ designSystem.Button,
2746
+ {
2747
+ variant: "secondary",
2748
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Key, {}),
2749
+ disabled: Boolean(signInUnavailable),
2750
+ onClick: (event) => onSignIn?.(admin, event.currentTarget),
2751
+ "aria-label": signInUnavailable || t("adminPanel.actions.signInAs", "Sign in as {name}", {
2772
2752
  name: admin.name || `#${admin.id}`
2773
2753
  }),
2774
2754
  flex: "1 1 auto",
2775
- children: t("adminPanel.actions.viewAsShort", "View as")
2755
+ children: t("adminPanel.actions.signInAsShort", "Sign in as")
2776
2756
  }
2777
2757
  ) : null,
2778
2758
  canRevoke && admin.canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -3013,7 +2993,7 @@ const AdminSessionsModal = ({
3013
2993
  ] }) });
3014
2994
  };
3015
2995
  const ADMIN_PREVIEW_DURATIONS = Object.freeze([15, 30]);
3016
- const REFUSALS = Object.freeze({
2996
+ const REFUSALS$1 = Object.freeze({
3017
2997
  disabled: ["impersonation.error.disabled", "Impersonation is turned off in the settings."],
3018
2998
  self: ["impersonation.preview.error.self", "You cannot view yourself as another admin."],
3019
2999
  "super-admin": [
@@ -3113,8 +3093,8 @@ const PreviewAdminModal = ({ admin, onClose, onCloseAutoFocus, onChanged }) => {
3113
3093
  "Too many impersonations were started. Try again in a few minutes."
3114
3094
  )
3115
3095
  );
3116
- } else if (REFUSALS[code]) {
3117
- setFailure(t(...REFUSALS[code]));
3096
+ } else if (REFUSALS$1[code]) {
3097
+ setFailure(t(...REFUSALS$1[code]));
3118
3098
  } else {
3119
3099
  index.logSafeAdminError("impersonation.preview", err);
3120
3100
  setFailure(t("impersonation.preview.error.start", "The preview could not be opened."));
@@ -3152,7 +3132,9 @@ const PreviewAdminModal = ({ admin, onClose, onCloseAutoFocus, onChanged }) => {
3152
3132
  onClose();
3153
3133
  };
3154
3134
  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: [
3155
- /* @__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}` }) }) }),
3135
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: t("impersonation.preview.title", "Permissions of {name}", {
3136
+ name: name || `#${admin.id}`
3137
+ }) }) }),
3156
3138
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
3157
3139
  failure ? /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "danger", closeLabel: t("common.close", "Close"), children: failure }) : null,
3158
3140
  !result ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -3282,6 +3264,200 @@ const PreviewAdminModal = ({ admin, onClose, onCloseAutoFocus, onChanged }) => {
3282
3264
  ] }) })
3283
3265
  ] }) });
3284
3266
  };
3267
+ const REFUSALS = Object.freeze({
3268
+ disabled: ["impersonation.error.disabled", "Impersonation is turned off in the settings."],
3269
+ unsupported: [
3270
+ "impersonation.signIn.error.unsupported",
3271
+ "Signing in as another admin is not available on this Strapi version."
3272
+ ],
3273
+ self: ["impersonation.signIn.error.self", "You cannot sign in as yourself."],
3274
+ "super-admin": ["impersonation.signIn.error.superAdmin", "You cannot sign in as a Super Admin."],
3275
+ "not-subset": [
3276
+ "impersonation.signIn.error.notSubset",
3277
+ "This admin has permissions that you do not have, so you cannot sign in as them."
3278
+ ],
3279
+ inactive: ["impersonation.signIn.error.inactive", "This admin account is not active."],
3280
+ "already-active": [
3281
+ "impersonation.signIn.error.alreadyActive",
3282
+ "Someone is already signed in as this admin. End that impersonation first."
3283
+ ],
3284
+ nested: [
3285
+ "impersonation.signIn.error.nested",
3286
+ "You cannot start an impersonation while impersonating."
3287
+ ],
3288
+ "api-token": ["impersonation.error.apiToken", "API tokens cannot impersonate."]
3289
+ });
3290
+ const currentAdminBase = () => {
3291
+ const path = window.location.pathname;
3292
+ const index$1 = path.indexOf(`/plugins/${index.pluginId}`);
3293
+ return index$1 >= 0 ? path.slice(0, index$1) : "/admin";
3294
+ };
3295
+ const unsupportedText = (support, t) => {
3296
+ if (!support || support.supported) return null;
3297
+ if (support.reason === "token-lifespan") {
3298
+ return t(
3299
+ "impersonation.signIn.unsupported.lifespan",
3300
+ "Not available: the admin access token lifespan is shorter than 15 minutes."
3301
+ );
3302
+ }
3303
+ return t(
3304
+ "impersonation.signIn.unsupported.version",
3305
+ "Not available on Strapi {version}: this plugin release was tested with Strapi 5.50 to 5.64. Update the plugin to use it.",
3306
+ { version: support.version || "?" }
3307
+ );
3308
+ };
3309
+ const SignInAsAdminModal = ({ admin, support, onClose, onCloseAutoFocus, onChanged }) => {
3310
+ const { t, tError } = index.useSettingsTranslate();
3311
+ const { post } = StrapiAdmin.useFetchClient();
3312
+ const durations = support?.durations?.length ? support.durations : [15];
3313
+ const [reason, setReason] = react.useState("");
3314
+ const [minutes, setMinutes] = react.useState(durations[0]);
3315
+ const [allowChanges, setAllowChanges] = react.useState(false);
3316
+ const [touched, setTouched] = react.useState(false);
3317
+ const [pending, setPending] = react.useState(false);
3318
+ const [failure, setFailure] = react.useState(null);
3319
+ const [handoff, setHandoff] = react.useState(null);
3320
+ const allowHintId = react.useId();
3321
+ const reasonError = index.validateReason(reason);
3322
+ const unsupported = unsupportedText(support, t);
3323
+ const name = admin.name || `#${admin.id}`;
3324
+ const start = async () => {
3325
+ setTouched(true);
3326
+ if (reasonError || unsupported) return;
3327
+ setPending(true);
3328
+ setFailure(null);
3329
+ try {
3330
+ const { data } = await post(`/${index.pluginId}/impersonation/admins/${admin.id}/sign-in`, {
3331
+ reason: reason.trim(),
3332
+ durationMinutes: minutes,
3333
+ allowChanges
3334
+ });
3335
+ setHandoff(data?.data?.handoff || null);
3336
+ onChanged?.();
3337
+ } catch (err) {
3338
+ if (index.isCancelledRequest(err)) return;
3339
+ const response = err?.response;
3340
+ const code = response?.data?.error?.details?.reason;
3341
+ if (response?.status === 429) {
3342
+ setFailure(
3343
+ t(
3344
+ "impersonation.error.rateLimited",
3345
+ "Too many impersonations were started. Try again in a few minutes."
3346
+ )
3347
+ );
3348
+ } else if (REFUSALS[code]) {
3349
+ setFailure(t(...REFUSALS[code]));
3350
+ } else {
3351
+ index.logSafeAdminError("impersonation.signIn", err);
3352
+ setFailure(t("impersonation.signIn.error.start", "The sign-in could not be started."));
3353
+ }
3354
+ } finally {
3355
+ setPending(false);
3356
+ }
3357
+ };
3358
+ const href = handoff ? index.landingUrl(currentAdminBase(), handoff) : null;
3359
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: true, onOpenChange: (open) => open ? null : onClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { onCloseAutoFocus, "aria-describedby": void 0, children: [
3360
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: t("impersonation.signIn.title", "Sign in as {name}", { name }) }) }),
3361
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
3362
+ failure ? /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "danger", closeLabel: t("common.close", "Close"), children: failure }) : null,
3363
+ unsupported ? /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "default", closeLabel: t("common.close", "Close"), children: unsupported }) : null,
3364
+ !handoff ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3365
+ /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "p", children: t(
3366
+ "impersonation.signIn.intro",
3367
+ "Opens a new tab signed in as this admin, with their menu and permissions. Your other tabs stay signed in as you. The start, the end and every change are recorded in the security log."
3368
+ ) }),
3369
+ /* @__PURE__ */ jsxRuntime.jsxs(
3370
+ designSystem.Field.Root,
3371
+ {
3372
+ name: "reason",
3373
+ required: true,
3374
+ error: touched && reasonError ? tError(reasonError) : void 0,
3375
+ hint: t("impersonation.preview.reason.hint", "Stored in the security log."),
3376
+ children: [
3377
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("impersonation.reason.label", "Reason") }),
3378
+ /* @__PURE__ */ jsxRuntime.jsx(
3379
+ designSystem.Textarea,
3380
+ {
3381
+ value: reason,
3382
+ maxLength: index.REASON_MAX,
3383
+ placeholder: t("impersonation.reason.placeholder", "For example: ticket 4711"),
3384
+ onChange: (event) => setReason(event.target.value),
3385
+ onBlur: () => setTouched(true)
3386
+ }
3387
+ ),
3388
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
3389
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
3390
+ ]
3391
+ }
3392
+ ),
3393
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "durationMinutes", children: [
3394
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("impersonation.duration.label", "Duration") }),
3395
+ /* @__PURE__ */ jsxRuntime.jsx(
3396
+ designSystem.SingleSelect,
3397
+ {
3398
+ value: String(minutes),
3399
+ onChange: (value) => setMinutes(Number(value)),
3400
+ children: durations.map((value) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: String(value), children: t(
3401
+ "impersonation.duration.minutes",
3402
+ "{count, plural, one {# minute} other {# minutes}}",
3403
+ { count: value }
3404
+ ) }, value))
3405
+ }
3406
+ )
3407
+ ] }),
3408
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
3409
+ /* @__PURE__ */ jsxRuntime.jsx(
3410
+ designSystem.Checkbox,
3411
+ {
3412
+ checked: allowChanges,
3413
+ "aria-describedby": allowHintId,
3414
+ onCheckedChange: (checked) => setAllowChanges(checked === true),
3415
+ children: t("impersonation.signIn.allowChanges", "Allow changes")
3416
+ }
3417
+ ),
3418
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: allowHintId, variant: "pi", textColor: "neutral600", children: t(
3419
+ "impersonation.signIn.allowChanges.hint",
3420
+ "Off: the tab is read-only. Their account, password, sessions, admin users, roles and API tokens can never be changed."
3421
+ ) })
3422
+ ] }),
3423
+ allowChanges ? /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "warning", closeLabel: t("common.close", "Close"), children: t(
3424
+ "impersonation.signIn.allowChanges.warning",
3425
+ 'Changes you make will appear in Strapi as made by {name} (for example "Last edited by"). The security log records you as the person who made them.',
3426
+ { name }
3427
+ ) }) : null
3428
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, "data-sign-in-ready": "", children: [
3429
+ /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "p", children: t(
3430
+ "impersonation.signIn.ready",
3431
+ "Ready. Open the tab within one minute; the link works once. End the impersonation from the bar at the top of that tab, or from this page."
3432
+ ) }),
3433
+ /* @__PURE__ */ jsxRuntime.jsx(
3434
+ designSystem.LinkButton,
3435
+ {
3436
+ href,
3437
+ isExternal: true,
3438
+ endIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ExternalLink, {}),
3439
+ size: "L",
3440
+ onClick: () => window.setTimeout(onClose, 0),
3441
+ children: t("impersonation.signIn.open", "Open tab signed in as {name}", { name })
3442
+ }
3443
+ )
3444
+ ] })
3445
+ ] }) }),
3446
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
3447
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: handoff ? t("common.close", "Close") : t("common.cancel", "Cancel") }) }),
3448
+ !handoff ? /* @__PURE__ */ jsxRuntime.jsx(
3449
+ designSystem.Button,
3450
+ {
3451
+ variant: allowChanges ? "danger" : "default",
3452
+ onClick: start,
3453
+ loading: pending,
3454
+ disabled: Boolean(unsupported),
3455
+ children: t("impersonation.signIn.start", "Start sign-in")
3456
+ }
3457
+ ) : null
3458
+ ] })
3459
+ ] }) });
3460
+ };
3285
3461
  const SETTINGS_USERS_PATH = "/settings/users";
3286
3462
  const PaginationTargets$2 = styled__default.default.div`
3287
3463
  nav a {
@@ -3302,7 +3478,7 @@ const AdminPanelPage = () => {
3302
3478
  const { formatMessage } = reactIntl.useIntl();
3303
3479
  const { get, post } = StrapiAdmin.useFetchClient();
3304
3480
  const { toggleNotification } = StrapiAdmin.useNotification();
3305
- const { isBelowMedium } = useBreakpoint();
3481
+ const { isBelowMedium } = useBreakpoint.useBreakpoint();
3306
3482
  const [{ query }, setQuery] = StrapiAdmin.useQueryParams();
3307
3483
  const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
3308
3484
  const view = index.parseAdminPanelQuery(query);
@@ -3315,8 +3491,13 @@ const AdminPanelPage = () => {
3315
3491
  const {
3316
3492
  allowedActions: { canAdmins: canPreviewAdmins }
3317
3493
  } = StrapiAdmin.useRBAC(index.pluginPermissions.impersonateAdmins);
3494
+ const {
3495
+ allowedActions: { canSignIn: canSignInAsAdmin }
3496
+ } = StrapiAdmin.useRBAC(index.pluginPermissions.signInAsAdmin);
3318
3497
  const [impersonationEnabled, setImpersonationEnabled] = react.useState(false);
3498
+ const [signInSupport, setSignInSupport] = react.useState(null);
3319
3499
  const [previewTarget, setPreviewTarget] = react.useState(null);
3500
+ const [signInTarget, setSignInTarget] = react.useState(null);
3320
3501
  const [admins, setAdmins] = react.useState([]);
3321
3502
  const [meta, setMeta] = react.useState(null);
3322
3503
  const [loading, setLoading] = react.useState(true);
@@ -3333,17 +3514,19 @@ const AdminPanelPage = () => {
3333
3514
  const hasLoadedRef = react.useRef(false);
3334
3515
  const openerRef = react.useRef(null);
3335
3516
  react.useEffect(() => {
3336
- if (!canPreviewAdmins) return void 0;
3517
+ if (!canPreviewAdmins && !canSignInAsAdmin) return void 0;
3337
3518
  let current = true;
3338
3519
  get(`/${index.pluginId}/impersonation/status`).then(({ data }) => {
3339
- if (current) setImpersonationEnabled(data?.data?.enabled === true);
3520
+ if (!current) return;
3521
+ setImpersonationEnabled(data?.data?.enabled === true);
3522
+ setSignInSupport(data?.data?.adminSignIn || null);
3340
3523
  }).catch((err) => {
3341
3524
  if (!index.isCancelledRequest(err)) index.logSafeAdminError("impersonation.status", err);
3342
3525
  });
3343
3526
  return () => {
3344
3527
  current = false;
3345
3528
  };
3346
- }, [canPreviewAdmins, get]);
3529
+ }, [canPreviewAdmins, canSignInAsAdmin, get]);
3347
3530
  const confirmReturnRef = react.useRef(null);
3348
3531
  const captionRef = react.useRef(null);
3349
3532
  const pageRef = react.useRef(null);
@@ -3451,7 +3634,7 @@ const AdminPanelPage = () => {
3451
3634
  setQuery({ filter: filter === "all" ? void 0 : filter, page: "1" });
3452
3635
  };
3453
3636
  const handleSearch = react.useCallback(
3454
- (value) => setQuery({ search: dashboardModel.encodeSearchQuery(value), page: "1" }, "push", true),
3637
+ (value) => setQuery({ search: ActiveImpersonationsCard.encodeSearchQuery(value), page: "1" }, "push", true),
3455
3638
  [setQuery]
3456
3639
  );
3457
3640
  const handleClearFilters = () => {
@@ -3494,10 +3677,10 @@ const AdminPanelPage = () => {
3494
3677
  index.logSafeAdminError("adminPanel.signOut", err);
3495
3678
  const message = index.getSignOutErrorMessage(err);
3496
3679
  toggleNotification({
3497
- type: dashboardModel.getErrorStatus(err) === 404 ? "warning" : "danger",
3680
+ type: ActiveImpersonationsCard.getErrorStatus(err) === 404 ? "warning" : "danger",
3498
3681
  message: t(message.messageId, message.defaultMessage)
3499
3682
  });
3500
- if (dashboardModel.getErrorStatus(err) === 404) {
3683
+ if (ActiveImpersonationsCard.getErrorStatus(err) === 404) {
3501
3684
  await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
3502
3685
  return;
3503
3686
  }
@@ -3564,6 +3747,12 @@ const AdminPanelPage = () => {
3564
3747
  openerRef.current = trigger;
3565
3748
  setPreviewTarget({ id: admin.id, name: admin.name });
3566
3749
  },
3750
+ canSignIn: Boolean(canSignInAsAdmin) && impersonationEnabled,
3751
+ signInUnavailable: unsupportedText(signInSupport, t),
3752
+ onSignIn: (admin, trigger) => {
3753
+ openerRef.current = trigger;
3754
+ setSignInTarget({ id: admin.id, name: admin.name });
3755
+ },
3567
3756
  busy: refreshing
3568
3757
  };
3569
3758
  const policy = meta?.policy;
@@ -3797,6 +3986,7 @@ const AdminPanelPage = () => {
3797
3986
  }
3798
3987
  )
3799
3988
  ] }) : null,
3989
+ showData && impersonationEnabled && (canSignInAsAdmin || canPreviewAdmins) ? /* @__PURE__ */ jsxRuntime.jsx(ActiveImpersonationsCard.ActiveImpersonationsCard, {}) : null,
3800
3990
  showData && canViewActivity ? /* @__PURE__ */ jsxRuntime.jsx(
3801
3991
  RecentSignInActivity,
3802
3992
  {
@@ -3829,6 +4019,15 @@ const AdminPanelPage = () => {
3829
4019
  onCloseAutoFocus: (event) => index.restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
3830
4020
  }
3831
4021
  ) : null,
4022
+ signInTarget ? /* @__PURE__ */ jsxRuntime.jsx(
4023
+ SignInAsAdminModal,
4024
+ {
4025
+ admin: signInTarget,
4026
+ support: signInSupport,
4027
+ onClose: () => setSignInTarget(null),
4028
+ onCloseAutoFocus: (event) => index.restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
4029
+ }
4030
+ ) : null,
3832
4031
  confirm ? /* @__PURE__ */ jsxRuntime.jsx(
3833
4032
  index.ConfirmAction,
3834
4033
  {
@@ -3907,6 +4106,7 @@ const AdminActivityPage = () => {
3907
4106
  succeeded: t("adminPanel.activity.filter.succeeded", "Sign-ins"),
3908
4107
  failed: t("adminPanel.activity.filter.failed", "Failed and locked out"),
3909
4108
  "signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs"),
4109
+ impersonation: t("adminPanel.activity.filter.impersonation", "Impersonation"),
3910
4110
  changes: t("adminPanel.activity.filter.changes", "Settings and log access")
3911
4111
  };
3912
4112
  const title = t("adminPanel.activity.page.title", "Security activity");