strapi-plugin-magic-sessionmanager 4.13.0 → 4.14.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 (42) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/README.md +109 -76
  3. package/dist/admin/{Analytics-BikQQx_J.js → Analytics-DSG3shUY.js} +1 -1
  4. package/dist/admin/{Analytics-DIY51RI_.mjs → Analytics-oW2QbDj4.mjs} +1 -1
  5. package/dist/admin/{App-B3vaybSO.mjs → App-BRj2qIUs.mjs} +1036 -11
  6. package/dist/admin/{App-BV1LM9Bp.js → App-DcxqQfMT.js} +1034 -9
  7. package/dist/admin/{OnlineUsersWidget-fJogM1xl.js → OnlineUsersWidget-CCTnV-aE.js} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-T-2upsDd.mjs → OnlineUsersWidget-wxDYyK5v.mjs} +1 -1
  9. package/dist/admin/{Settings-BpBlXyMY.mjs → Settings-BNPO9cXS.mjs} +1 -1
  10. package/dist/admin/{Settings-AyYka8wn.js → Settings-XdBlPves.js} +1 -1
  11. package/dist/admin/{de-z0aHRwdw.js → de-B0CBR1Dw.js} +89 -1
  12. package/dist/admin/{de-BSCDuq1i.mjs → de-BlKn1pSD.mjs} +89 -1
  13. package/dist/admin/{en-BWPOiiMt.js → en-D0ZGIIjz.js} +89 -1
  14. package/dist/admin/{en-B4Cuq9JN.mjs → en-IT0YTY8f.mjs} +89 -1
  15. package/dist/admin/{es-DBAmysKi.mjs → es-BCGzaaCh.mjs} +89 -1
  16. package/dist/admin/{es-CMskkUh-.js → es-CWee-XCR.js} +89 -1
  17. package/dist/admin/{fr-ClJ2BkrE.js → fr-rQS1M7jE.js} +89 -1
  18. package/dist/admin/{fr-BNGdtjEl.mjs → fr-xBIH4Byq.mjs} +89 -1
  19. package/dist/admin/{index-DyE1rLW0.js → index-BBZNey0n.js} +15 -10
  20. package/dist/admin/{index-mCVi1j7e.mjs → index-BcQdNWzu.mjs} +33 -28
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +2 -2
  23. package/dist/admin/{pt-CRh_J7JS.js → pt-C-yTLhnS.js} +89 -1
  24. package/dist/admin/{pt-Cl7TWsOV.mjs → pt-DWDeIDVa.mjs} +89 -1
  25. package/dist/server/index.js +666 -1
  26. package/dist/server/index.mjs +666 -1
  27. package/package.json +6 -6
  28. package/pics/analytics.png +0 -0
  29. package/pics/dashboard-dark.png +0 -0
  30. package/pics/dashboard.png +0 -0
  31. package/pics/dashboardsessionmodal.png +0 -0
  32. package/pics/mobile-dashboard.png +0 -0
  33. package/pics/mobile-session.png +0 -0
  34. package/pics/sessioninfopanel.png +0 -0
  35. package/pics/settings1.png +0 -0
  36. package/pics/settings2.png +0 -0
  37. package/pics/untracked-confirm-dialog.webp +0 -0
  38. package/pics/untracked-disclosure-warning-dark.webp +0 -0
  39. package/pics/untracked-disclosure-warning.webp +0 -0
  40. package/pics/untracked-mobile-notice-warning.webp +0 -0
  41. package/pics/untracked-notice-neutral.webp +0 -0
  42. package/pics/widget.png +0 -0
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
+ const StrapiAdmin = require("@strapi/strapi/admin");
5
+ const reactRouterDom = require("react-router-dom");
4
6
  const react = require("react");
5
7
  const reactIntl = require("react-intl");
6
- const reactRouterDom = require("react-router-dom");
7
- const StrapiAdmin = require("@strapi/strapi/admin");
8
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-DyE1rLW0.js");
12
+ const index = require("./index-BBZNey0n.js");
13
13
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
14
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
15
15
  const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
@@ -807,6 +807,52 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
807
807
  ) })
808
808
  ] }) });
809
809
  };
810
+ const SESSION_VIEW_PATHS = Object.freeze({
811
+ users: `/plugins/${index.pluginId}`,
812
+ admins: `/plugins/${index.pluginId}/admin-panel`
813
+ });
814
+ const ViewLink = styled__default.default(reactRouterDom.NavLink)`
815
+ display: inline-flex;
816
+ align-items: center;
817
+ min-height: 4rem;
818
+ padding: 0 ${({ theme }) => theme.spaces[4]};
819
+ border-bottom: 2px solid transparent;
820
+ color: ${({ theme }) => theme.colors.neutral600};
821
+ text-decoration: none;
822
+ white-space: nowrap;
823
+
824
+ &:hover {
825
+ color: ${({ theme }) => theme.colors.neutral800};
826
+ }
827
+
828
+ &[aria-current='page'] {
829
+ color: ${({ theme }) => theme.colors.primary700};
830
+ border-bottom-color: ${({ theme }) => theme.colors.primary600};
831
+ }
832
+
833
+ &:focus-visible {
834
+ outline: 2px solid ${({ theme }) => theme.colors.primary600};
835
+ outline-offset: -2px;
836
+ }
837
+ `;
838
+ const ViewNav = styled__default.default.nav`
839
+ border-bottom: 1px solid ${({ theme }) => theme.colors.neutral150};
840
+ min-width: 0;
841
+ `;
842
+ const SessionViewNav = ({ current }) => {
843
+ const { formatMessage } = reactIntl.useIntl();
844
+ const t = (id, defaultMessage) => formatMessage({ id: index.getTranslation(id), defaultMessage });
845
+ const {
846
+ allowedActions: { canRead },
847
+ isLoading
848
+ } = StrapiAdmin.useRBAC(index.pluginPermissions.adminSessionsRead);
849
+ if (isLoading || !canRead && current !== "admins") return null;
850
+ const link = (view, label) => /* @__PURE__ */ jsxRuntime.jsx(ViewLink, { to: SESSION_VIEW_PATHS[view], end: true, "data-session-view": view, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", children: label }) });
851
+ return /* @__PURE__ */ jsxRuntime.jsx(ViewNav, { "aria-label": t("views.label", "Session views"), "data-session-views": "", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
852
+ link("users", t("views.users", "App users")),
853
+ link("admins", t("views.admins", "Admin panel"))
854
+ ] }) });
855
+ };
810
856
  const isolateActionKeys = (event) => {
811
857
  const fromInsideGroup = event.currentTarget.contains(
812
858
  /** @type {Node} */
@@ -1183,7 +1229,7 @@ const SearchWrapper = styled__default.default(designSystem.Box)`
1183
1229
  }
1184
1230
  `;
1185
1231
  const SEARCH_DEBOUNCE_MS = 300;
1186
- const SessionSearch = ({ value, onSearch }) => {
1232
+ const SessionSearch = ({ value, onSearch, label, placeholder }) => {
1187
1233
  const { formatMessage } = reactIntl.useIntl();
1188
1234
  const t = (id, defaultMessage) => formatMessage({ id: index.getTranslation(id), defaultMessage });
1189
1235
  const [draft, setDraft] = react.useState(value);
@@ -1225,8 +1271,8 @@ const SessionSearch = ({ value, onSearch }) => {
1225
1271
  apply("");
1226
1272
  },
1227
1273
  clearLabel: t("homepage.search.clear", "Clear search"),
1228
- placeholder: t("homepage.search.placeholder", "Search user, email, IP or device"),
1229
- children: t("homepage.search.label", "Search sessions")
1274
+ placeholder: placeholder ?? t("homepage.search.placeholder", "Search user, email, IP or device"),
1275
+ children: label ?? t("homepage.search.label", "Search sessions")
1230
1276
  }
1231
1277
  )
1232
1278
  }
@@ -1734,7 +1780,7 @@ const UntrackedSessionsNotice = ({ stats, onChanged, fallbackFocusRef }) => {
1734
1780
  const CLOCK_TICK_MS = 30 * 1e3;
1735
1781
  const ANALYTICS_PATH = `/settings/${index.pluginId}/analytics`;
1736
1782
  const CONFIGURATION_PATH = `/settings/${index.pluginId}/general`;
1737
- const PaginationTargets = styled__default.default.div`
1783
+ const PaginationTargets$1 = styled__default.default.div`
1738
1784
  nav a {
1739
1785
  min-width: 3.2rem;
1740
1786
  }
@@ -2188,6 +2234,7 @@ const HomePage = () => {
2188
2234
  gap: 6,
2189
2235
  minWidth: 0,
2190
2236
  children: [
2237
+ /* @__PURE__ */ jsxRuntime.jsx(SessionViewNav, { current: "users" }),
2191
2238
  !loading && loadError ? /* @__PURE__ */ jsxRuntime.jsx(
2192
2239
  index.PersistentAlert,
2193
2240
  {
@@ -2303,7 +2350,7 @@ const HomePage = () => {
2303
2350
  compact: shouldUseCompactTable(listWidth, isBelowLarge)
2304
2351
  }
2305
2352
  ),
2306
- /* @__PURE__ */ jsxRuntime.jsx(PaginationTargets, { children: /* @__PURE__ */ jsxRuntime.jsxs(
2353
+ /* @__PURE__ */ jsxRuntime.jsx(PaginationTargets$1, { children: /* @__PURE__ */ jsxRuntime.jsxs(
2307
2354
  StrapiAdmin.Pagination.Root,
2308
2355
  {
2309
2356
  pageCount: pageResult.pageCount,
@@ -2353,7 +2400,985 @@ const HomePage = () => {
2353
2400
  }
2354
2401
  );
2355
2402
  };
2403
+ const ADMIN_FILTER_OPTIONS = Object.freeze(["all", "signed-in", "not-signed-in"]);
2404
+ const ADMIN_PAGE_SIZE_OPTIONS = Object.freeze(["10", "25", "50", "100"]);
2405
+ const ADMIN_DEFAULT_PAGE_SIZE = "25";
2406
+ const ADMIN_MAX_SEARCH_LENGTH = 100;
2407
+ function parseAdminPanelQuery(query = {}) {
2408
+ const page = Number.parseInt(String(query?.page ?? ""), 10);
2409
+ const pageSize = String(query?.pageSize ?? "");
2410
+ const filter = String(query?.filter ?? "");
2411
+ let search = "";
2412
+ if (typeof query?.search === "string") {
2413
+ try {
2414
+ search = decodeURIComponent(query.search).trim();
2415
+ } catch {
2416
+ search = query.search.trim();
2417
+ }
2418
+ }
2419
+ return {
2420
+ page: Number.isInteger(page) && page >= 1 && page <= 1e6 ? page : 1,
2421
+ pageSize: Number(
2422
+ ADMIN_PAGE_SIZE_OPTIONS.includes(pageSize) ? pageSize : ADMIN_DEFAULT_PAGE_SIZE
2423
+ ),
2424
+ filter: ADMIN_FILTER_OPTIONS.includes(filter) ? filter : "all",
2425
+ search: search.slice(0, ADMIN_MAX_SEARCH_LENGTH)
2426
+ };
2427
+ }
2428
+ function buildAdminListParams(state) {
2429
+ return {
2430
+ page: state.page,
2431
+ pageSize: state.pageSize,
2432
+ filter: state.filter,
2433
+ ...state.search ? { search: state.search } : {}
2434
+ };
2435
+ }
2436
+ function hasAdminFilters(state) {
2437
+ return state.filter !== "all" || Boolean(state.search);
2438
+ }
2439
+ function getAdminStatusPresentation(row) {
2440
+ if (row?.account === "invited") {
2441
+ return {
2442
+ key: "invited",
2443
+ tone: "secondary",
2444
+ label: { messageId: "adminPanel.status.invited", defaultMessage: "Invited" },
2445
+ detail: {
2446
+ messageId: "adminPanel.status.invited.detail",
2447
+ defaultMessage: "Invitation not accepted yet"
2448
+ }
2449
+ };
2450
+ }
2451
+ if (row?.account === "deactivated") {
2452
+ return {
2453
+ key: "deactivated",
2454
+ tone: "neutral",
2455
+ label: { messageId: "adminPanel.status.deactivated", defaultMessage: "Deactivated" },
2456
+ detail: {
2457
+ messageId: "adminPanel.status.deactivated.detail",
2458
+ defaultMessage: "Cannot sign in"
2459
+ }
2460
+ };
2461
+ }
2462
+ const count = Number(row?.sessionCount) || 0;
2463
+ if (count > 0) {
2464
+ return {
2465
+ key: "signed-in",
2466
+ tone: "success",
2467
+ label: { messageId: "adminPanel.status.signedIn", defaultMessage: "Signed in" },
2468
+ detail: {
2469
+ messageId: "adminPanel.status.signedIn.detail",
2470
+ defaultMessage: "{count, plural, one {# session} other {# sessions}}",
2471
+ values: { count }
2472
+ }
2473
+ };
2474
+ }
2475
+ return {
2476
+ key: "not-signed-in",
2477
+ tone: "neutral",
2478
+ label: { messageId: "adminPanel.status.notSignedIn", defaultMessage: "Not signed in" },
2479
+ detail: {
2480
+ messageId: "adminPanel.status.notSignedIn.detail",
2481
+ defaultMessage: "No open session"
2482
+ }
2483
+ };
2484
+ }
2485
+ function splitDuration(seconds) {
2486
+ const value = Number(seconds);
2487
+ if (!Number.isFinite(value) || value <= 0) return null;
2488
+ if (value % 86400 === 0) return { unit: "days", count: value / 86400 };
2489
+ if (value % 3600 === 0) return { unit: "hours", count: value / 3600 };
2490
+ return { unit: "minutes", count: Math.max(1, Math.round(value / 60)) };
2491
+ }
2492
+ function getSignOutErrorMessage(error) {
2493
+ const response = (
2494
+ /** @type {any} */
2495
+ error?.response
2496
+ );
2497
+ const status = Number(response?.status ?? /** @type {any} */
2498
+ error?.status);
2499
+ const reason = response?.data?.error?.details?.reason;
2500
+ if (status === 403 && reason === "super-admin-protected") {
2501
+ return {
2502
+ messageId: "adminPanel.signOut.error.protected",
2503
+ defaultMessage: "Only a Super Admin can sign out a Super Admin."
2504
+ };
2505
+ }
2506
+ if (status === 403) {
2507
+ return {
2508
+ messageId: "adminPanel.signOut.error.forbidden",
2509
+ defaultMessage: "You do not have permission to sign admins out."
2510
+ };
2511
+ }
2512
+ if (status === 404) {
2513
+ return {
2514
+ messageId: "adminPanel.signOut.error.gone",
2515
+ defaultMessage: "This session has already ended. The list is up to date now."
2516
+ };
2517
+ }
2518
+ if (status === 429) {
2519
+ return {
2520
+ messageId: "adminPanel.signOut.error.rateLimited",
2521
+ defaultMessage: "Too many sign-outs in a short time. Wait a minute and try again."
2522
+ };
2523
+ }
2524
+ return {
2525
+ messageId: "adminPanel.signOut.error.generic",
2526
+ defaultMessage: "The admin could not be signed out. Try again."
2527
+ };
2528
+ }
2529
+ const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
2530
+ const SHRINKING_ADMIN_CELL = { maxWidth: 0, width: "34%" };
2531
+ const SHRINKING_ROLES_CELL = { maxWidth: 0, width: "22%" };
2532
+ const useT$1 = () => {
2533
+ const { formatMessage } = reactIntl.useIntl();
2534
+ return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
2535
+ };
2536
+ const AdminIdentity = ({ admin }) => {
2537
+ const t = useT$1();
2538
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children: [
2539
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
2540
+ /* @__PURE__ */ jsxRuntime.jsx(
2541
+ designSystem.Typography,
2542
+ {
2543
+ variant: "omega",
2544
+ fontWeight: "semiBold",
2545
+ textColor: "neutral800",
2546
+ ellipsis: true,
2547
+ title: admin.name,
2548
+ children: admin.name
2549
+ }
2550
+ ),
2551
+ admin.self ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...HIGHLIGHT_BADGE, shrink: 0, children: t("adminPanel.you", "You") }) : null
2552
+ ] }),
2553
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, title: admin.email, children: admin.email })
2554
+ ] });
2555
+ };
2556
+ const AdminRoles = ({ admin }) => {
2557
+ const t = useT$1();
2558
+ const names = (admin.roles || []).map((role) => role.name).filter(Boolean);
2559
+ const text = names.length ? names.join(", ") : t("adminPanel.roles.none", "No role");
2560
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", ellipsis: true, title: text, children: text });
2561
+ };
2562
+ const AdminStatus = ({ admin }) => {
2563
+ const t = useT$1();
2564
+ const status = getAdminStatusPresentation(admin);
2565
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-admin-status": status.key, children: [
2566
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...index.getBadgeColors(status.tone), children: t(status.label.messageId, status.label.defaultMessage) }),
2567
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(status.detail.messageId, status.detail.defaultMessage, status.detail.values) })
2568
+ ] });
2569
+ };
2570
+ const AdminTable = ({
2571
+ admins,
2572
+ labelledBy,
2573
+ canRevoke,
2574
+ onView,
2575
+ onSignOutEverywhere,
2576
+ busy
2577
+ }) => {
2578
+ const t = useT$1();
2579
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral0", hasRadius: true, shadow: "tableShadow", "data-admin-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(
2580
+ designSystem.Table,
2581
+ {
2582
+ colCount: 5,
2583
+ rowCount: admins.length + 1,
2584
+ "aria-labelledby": labelledBy,
2585
+ "aria-busy": busy,
2586
+ children: [
2587
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
2588
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: SHRINKING_ADMIN_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.admin", "Admin") }) }),
2589
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.roles", "Roles") }) }),
2590
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.status", "Status") }) }),
2591
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.lastActive", "Last active") }) }),
2592
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("adminPanel.table.actions", "Actions") }) })
2593
+ ] }) }),
2594
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: admins.map((admin) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-admin-row": admin.id, children: [
2595
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_ADMIN_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(AdminIdentity, { admin }) }),
2596
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin }) }),
2597
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin }) }),
2598
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: admin.lastActiveAt }) }),
2599
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.IconButtonGroup, { children: [
2600
+ /* @__PURE__ */ jsxRuntime.jsx(
2601
+ designSystem.IconButton,
2602
+ {
2603
+ label: t("adminPanel.actions.view", "View sessions of {name}", {
2604
+ name: admin.name
2605
+ }),
2606
+ onClick: (event) => onView(admin, event.currentTarget),
2607
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
2608
+ }
2609
+ ),
2610
+ canRevoke && admin.canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
2611
+ designSystem.IconButton,
2612
+ {
2613
+ variant: "danger-light",
2614
+ label: t(
2615
+ "adminPanel.actions.signOutEverywhere",
2616
+ "Sign out {name} everywhere",
2617
+ {
2618
+ name: admin.name
2619
+ }
2620
+ ),
2621
+ onClick: (event) => onSignOutEverywhere(admin, event.currentTarget),
2622
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {})
2623
+ }
2624
+ ) : null
2625
+ ] }) }) })
2626
+ ] }, admin.id)) })
2627
+ ]
2628
+ }
2629
+ ) });
2630
+ };
2631
+ const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywhere }) => {
2632
+ const t = useT$1();
2633
+ return /* @__PURE__ */ jsxRuntime.jsx(
2634
+ designSystem.Flex,
2635
+ {
2636
+ tag: "ul",
2637
+ direction: "column",
2638
+ alignItems: "stretch",
2639
+ gap: 3,
2640
+ "aria-labelledby": labelledBy,
2641
+ "data-admin-cards": "",
2642
+ children: admins.map((admin) => /* @__PURE__ */ jsxRuntime.jsx(
2643
+ designSystem.Box,
2644
+ {
2645
+ tag: "li",
2646
+ background: "neutral0",
2647
+ hasRadius: true,
2648
+ shadow: "tableShadow",
2649
+ padding: 4,
2650
+ "data-admin-row": admin.id,
2651
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, minWidth: 0, children: [
2652
+ /* @__PURE__ */ jsxRuntime.jsx(AdminIdentity, { admin }),
2653
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, wrap: "wrap", alignItems: "flex-start", justifyContent: "space-between", children: [
2654
+ /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin }),
2655
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
2656
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.lastActive", "Last active") }),
2657
+ /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: admin.lastActiveAt })
2658
+ ] })
2659
+ ] }),
2660
+ /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin }),
2661
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
2662
+ /* @__PURE__ */ jsxRuntime.jsx(
2663
+ designSystem.Button,
2664
+ {
2665
+ variant: "secondary",
2666
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {}),
2667
+ onClick: (event) => onView(admin, event.currentTarget),
2668
+ "aria-label": t("adminPanel.actions.view", "View sessions of {name}", {
2669
+ name: admin.name
2670
+ }),
2671
+ flex: "1 1 auto",
2672
+ children: t("adminPanel.actions.viewShort", "View sessions")
2673
+ }
2674
+ ),
2675
+ canRevoke && admin.canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
2676
+ designSystem.Button,
2677
+ {
2678
+ variant: "danger-light",
2679
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {}),
2680
+ onClick: (event) => onSignOutEverywhere(admin, event.currentTarget),
2681
+ "aria-label": t(
2682
+ "adminPanel.actions.signOutEverywhere",
2683
+ "Sign out {name} everywhere",
2684
+ {
2685
+ name: admin.name
2686
+ }
2687
+ ),
2688
+ flex: "1 1 auto",
2689
+ children: t("adminPanel.actions.signOutEverywhereShort", "Sign out everywhere")
2690
+ }
2691
+ ) : null
2692
+ ] })
2693
+ ] })
2694
+ },
2695
+ admin.id
2696
+ ))
2697
+ }
2698
+ );
2699
+ };
2700
+ const useT = () => {
2701
+ const { formatMessage } = reactIntl.useIntl();
2702
+ return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
2703
+ };
2704
+ const DateValue = ({ value }) => {
2705
+ const { formatDate } = index.useSessionFormatters();
2706
+ if (!value) return null;
2707
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "time", dateTime: value, variant: "omega", textColor: "neutral800", children: formatDate(value) });
2708
+ };
2709
+ const SessionCard = ({ session, admin, canSignOut, onSignOut }) => {
2710
+ const t = useT();
2711
+ const device = session.device || t("adminPanel.session.unknownDevice", "Unknown browser");
2712
+ return /* @__PURE__ */ jsxRuntime.jsx(
2713
+ designSystem.Box,
2714
+ {
2715
+ tag: "li",
2716
+ background: "neutral0",
2717
+ borderColor: "neutral200",
2718
+ hasRadius: true,
2719
+ padding: 4,
2720
+ "data-admin-session": "",
2721
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, minWidth: 0, children: [
2722
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
2723
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
2724
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: device }),
2725
+ session.current ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...HIGHLIGHT_BADGE, children: t("adminPanel.session.current", "This browser") }) : null,
2726
+ session.rememberMe ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: t("adminPanel.session.rememberMe", "Remember me") }) : null
2727
+ ] }),
2728
+ canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
2729
+ designSystem.Button,
2730
+ {
2731
+ size: "S",
2732
+ variant: "danger-light",
2733
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {}),
2734
+ onClick: (event) => onSignOut(session, event.currentTarget),
2735
+ "aria-label": t("adminPanel.session.signOutLabel", "Sign {name} out of {device}", {
2736
+ name: admin.name,
2737
+ device
2738
+ }),
2739
+ children: t("adminPanel.session.signOut", "Sign out")
2740
+ }
2741
+ ) : null
2742
+ ] }),
2743
+ /* @__PURE__ */ jsxRuntime.jsx(
2744
+ index.PropertyList,
2745
+ {
2746
+ columns: 2,
2747
+ items: [
2748
+ {
2749
+ id: "signedIn",
2750
+ label: t("adminPanel.session.signedInAt", "Signed in"),
2751
+ value: session.signedInAt,
2752
+ render: session.signedInAt ? /* @__PURE__ */ jsxRuntime.jsx(DateValue, { value: session.signedInAt }) : void 0
2753
+ },
2754
+ {
2755
+ id: "lastActive",
2756
+ label: t("adminPanel.session.lastActiveAt", "Last active"),
2757
+ value: session.lastActiveAt,
2758
+ render: session.lastActiveAt ? /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: session.lastActiveAt }) : void 0
2759
+ },
2760
+ {
2761
+ id: "endsAt",
2762
+ label: t("adminPanel.session.endsAt", "Ends at the latest"),
2763
+ value: session.endsAt,
2764
+ render: session.endsAt ? /* @__PURE__ */ jsxRuntime.jsx(DateValue, { value: session.endsAt }) : void 0,
2765
+ fullWidth: true
2766
+ }
2767
+ ]
2768
+ }
2769
+ )
2770
+ ] })
2771
+ }
2772
+ );
2773
+ };
2774
+ const AdminSessionsModal = ({
2775
+ admin,
2776
+ sessions,
2777
+ loading,
2778
+ error,
2779
+ onRetry,
2780
+ canRevoke,
2781
+ onSignOut,
2782
+ onSignOutEverywhere,
2783
+ onClose,
2784
+ onCloseAutoFocus
2785
+ }) => {
2786
+ const t = useT();
2787
+ const canSignOut = canRevoke && admin.account === "active" && !admin.protectedReason;
2788
+ const settingsPath = `/settings/users/${admin.id}`;
2789
+ let notice = null;
2790
+ if (admin.account !== "active") {
2791
+ notice = /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "neutral", title: t("adminPanel.dialog.inactive.title", "No usable session"), children: t(
2792
+ "adminPanel.dialog.inactive.body",
2793
+ "Strapi rejects every request of a deactivated or invited account, so there is nothing to sign out."
2794
+ ) });
2795
+ } else if (admin.protectedReason === "super-admin-protected" && canRevoke) {
2796
+ notice = /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "neutral", title: t("adminPanel.dialog.protected.title", "Super Admin"), children: t(
2797
+ "adminPanel.dialog.protected.body",
2798
+ "Only a Super Admin can sign out a Super Admin. This keeps at least one Super Admin able to work at all times."
2799
+ ) });
2800
+ }
2801
+ 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: [
2802
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: t("adminPanel.dialog.title", "Sessions of {name}", { name: admin.name }) }) }),
2803
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
2804
+ /* @__PURE__ */ jsxRuntime.jsx(
2805
+ index.PropertyList,
2806
+ {
2807
+ columns: 2,
2808
+ items: [
2809
+ {
2810
+ id: "email",
2811
+ label: t("adminPanel.dialog.email", "Email"),
2812
+ value: admin.email,
2813
+ kind: "email"
2814
+ },
2815
+ {
2816
+ id: "roles",
2817
+ label: t("adminPanel.table.roles", "Roles"),
2818
+ render: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin })
2819
+ },
2820
+ {
2821
+ id: "status",
2822
+ label: t("adminPanel.table.status", "Status"),
2823
+ render: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin: { ...admin, sessionCount: sessions.length } }),
2824
+ fullWidth: true
2825
+ }
2826
+ ]
2827
+ }
2828
+ ),
2829
+ notice,
2830
+ loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("adminPanel.dialog.loading", "Loading sessions") }) }) : null,
2831
+ !loading && error ? /* @__PURE__ */ jsxRuntime.jsx(
2832
+ index.PersistentAlert,
2833
+ {
2834
+ variant: "danger",
2835
+ action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: onRetry, children: t("common.tryAgain", "Try again") }),
2836
+ children: t("adminPanel.dialog.error", "The sessions could not be loaded.")
2837
+ }
2838
+ ) : null,
2839
+ !loading && !error && admin.account === "active" && sessions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", "data-admin-sessions-empty": "", children: t(
2840
+ "adminPanel.dialog.empty",
2841
+ "{name} is not signed in. Sessions appear here after the next sign-in.",
2842
+ { name: admin.name }
2843
+ ) }) : null,
2844
+ !loading && sessions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
2845
+ designSystem.Flex,
2846
+ {
2847
+ tag: "ul",
2848
+ direction: "column",
2849
+ alignItems: "stretch",
2850
+ gap: 3,
2851
+ "aria-label": t("adminPanel.dialog.listLabel", "Signed-in browsers"),
2852
+ children: sessions.map((session) => /* @__PURE__ */ jsxRuntime.jsx(
2853
+ SessionCard,
2854
+ {
2855
+ session,
2856
+ admin,
2857
+ canSignOut,
2858
+ onSignOut
2859
+ },
2860
+ session.id
2861
+ ))
2862
+ }
2863
+ ) : null
2864
+ ] }) }),
2865
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", justifyContent: "space-between", width: "100%", children: [
2866
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: t("common.close", "Close") }) }),
2867
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", children: [
2868
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.LinkButton, { tag: reactRouterDom.Link, to: settingsPath, variant: "secondary", children: t("adminPanel.dialog.manage", "Manage in Settings") }),
2869
+ canSignOut && sessions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
2870
+ designSystem.Button,
2871
+ {
2872
+ variant: "danger",
2873
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {}),
2874
+ onClick: (event) => onSignOutEverywhere(event.currentTarget),
2875
+ children: t("adminPanel.actions.signOutEverywhereShort", "Sign out everywhere")
2876
+ }
2877
+ ) : null
2878
+ ] })
2879
+ ] }) })
2880
+ ] }) });
2881
+ };
2882
+ const SETTINGS_USERS_PATH = "/settings/users";
2883
+ const PaginationTargets = styled__default.default.div`
2884
+ nav a {
2885
+ min-width: 3.2rem;
2886
+ }
2887
+
2888
+ & > div {
2889
+ flex-wrap: wrap;
2890
+ gap: ${({ theme }) => theme.spaces[2]} ${({ theme }) => theme.spaces[4]};
2891
+ }
2892
+
2893
+ & > div > div > span {
2894
+ white-space: nowrap;
2895
+ }
2896
+ `;
2897
+ const EMPTY_STATS = { signedInAdmins: 0, activeSessions: 0, activeAccounts: 0, totalAdmins: 0 };
2898
+ const AdminPanelPage = () => {
2899
+ const { formatMessage } = reactIntl.useIntl();
2900
+ const { get, post } = StrapiAdmin.useFetchClient();
2901
+ const { toggleNotification } = StrapiAdmin.useNotification();
2902
+ const { isBelowMedium } = useBreakpoint();
2903
+ const [{ query }, setQuery] = StrapiAdmin.useQueryParams();
2904
+ const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
2905
+ const view = parseAdminPanelQuery(query);
2906
+ const {
2907
+ allowedActions: { canRevoke }
2908
+ } = StrapiAdmin.useRBAC(index.pluginPermissions.adminSessionsRevoke);
2909
+ const [admins, setAdmins] = react.useState([]);
2910
+ const [meta, setMeta] = react.useState(null);
2911
+ const [loading, setLoading] = react.useState(true);
2912
+ const [refreshing, setRefreshing] = react.useState(false);
2913
+ const [loadError, setLoadError] = react.useState(false);
2914
+ const [selected, setSelected] = react.useState(null);
2915
+ const [dialogSessions, setDialogSessions] = react.useState([]);
2916
+ const [dialogLoading, setDialogLoading] = react.useState(false);
2917
+ const [dialogError, setDialogError] = react.useState(false);
2918
+ const [pending, setPending] = react.useState(null);
2919
+ const requestIdRef = react.useRef(0);
2920
+ const dialogRequestRef = react.useRef(0);
2921
+ const hasLoadedRef = react.useRef(false);
2922
+ const openerRef = react.useRef(null);
2923
+ const confirmReturnRef = react.useRef(null);
2924
+ const captionRef = react.useRef(null);
2925
+ const pageRef = react.useRef(null);
2926
+ const captionId = `admin-list-caption-${react.useId().replace(/:/g, "")}`;
2927
+ const listParams = react.useMemo(
2928
+ () => buildAdminListParams({
2929
+ page: view.page,
2930
+ pageSize: view.pageSize,
2931
+ filter: view.filter,
2932
+ search: view.search
2933
+ }),
2934
+ [view.page, view.pageSize, view.filter, view.search]
2935
+ );
2936
+ const fetchAdmins = react.useCallback(async () => {
2937
+ const requestId = requestIdRef.current + 1;
2938
+ requestIdRef.current = requestId;
2939
+ if (hasLoadedRef.current) setRefreshing(true);
2940
+ else setLoading(true);
2941
+ try {
2942
+ const response = await get(`/${index.pluginId}/admin-sessions/admins`, { params: listParams });
2943
+ if (requestId !== requestIdRef.current) return;
2944
+ const body = response?.data || {};
2945
+ setAdmins(Array.isArray(body.data) ? body.data : []);
2946
+ setMeta(body.meta || null);
2947
+ setLoadError(false);
2948
+ hasLoadedRef.current = true;
2949
+ } catch (err) {
2950
+ if (requestId !== requestIdRef.current || index.isCancelledRequest(err)) return;
2951
+ setLoadError(true);
2952
+ index.logSafeAdminError("adminPanel.load", err);
2953
+ } finally {
2954
+ if (requestId === requestIdRef.current) {
2955
+ setLoading(false);
2956
+ setRefreshing(false);
2957
+ }
2958
+ }
2959
+ }, [get, listParams]);
2960
+ react.useEffect(() => {
2961
+ fetchAdmins();
2962
+ }, [fetchAdmins]);
2963
+ const fetchDialogSessions = react.useCallback(
2964
+ async (admin) => {
2965
+ const requestId = dialogRequestRef.current + 1;
2966
+ dialogRequestRef.current = requestId;
2967
+ setDialogLoading(true);
2968
+ try {
2969
+ const response = await get(`/${index.pluginId}/admin-sessions/admins/${admin.id}/sessions`);
2970
+ if (requestId !== dialogRequestRef.current) return;
2971
+ const body = response?.data || {};
2972
+ setDialogSessions(Array.isArray(body.data) ? body.data : []);
2973
+ if (body.meta?.admin) setSelected((current) => current ? body.meta.admin : current);
2974
+ setDialogError(false);
2975
+ } catch (err) {
2976
+ if (requestId !== dialogRequestRef.current || index.isCancelledRequest(err)) return;
2977
+ setDialogError(true);
2978
+ index.logSafeAdminError("adminPanel.sessions", err);
2979
+ } finally {
2980
+ if (requestId === dialogRequestRef.current) setDialogLoading(false);
2981
+ }
2982
+ },
2983
+ [get]
2984
+ );
2985
+ const openDialog = (admin, trigger) => {
2986
+ openerRef.current = trigger;
2987
+ setSelected(admin);
2988
+ setDialogSessions([]);
2989
+ setDialogError(false);
2990
+ fetchDialogSessions(admin);
2991
+ };
2992
+ const closeDialog = () => {
2993
+ dialogRequestRef.current += 1;
2994
+ setSelected(null);
2995
+ setDialogSessions([]);
2996
+ };
2997
+ const pagination = meta?.pagination || { page: 1, pageCount: 1, total: 0 };
2998
+ react.useEffect(() => {
2999
+ if (!loading && !refreshing && view.page > pagination.pageCount) {
3000
+ setQuery({ page: String(pagination.pageCount) }, "push", true);
3001
+ }
3002
+ }, [loading, refreshing, view.page, pagination.pageCount, setQuery]);
3003
+ const handleFilterChange = (value) => {
3004
+ const filter = String(value);
3005
+ setQuery({ filter: filter === "all" ? void 0 : filter, page: "1" });
3006
+ };
3007
+ const handleSearch = react.useCallback(
3008
+ (value) => setQuery({ search: encodeSearchQuery(value), page: "1" }, "push", true),
3009
+ [setQuery]
3010
+ );
3011
+ const handleClearFilters = () => {
3012
+ setQuery({ search: void 0, filter: void 0, page: "1" });
3013
+ captionRef.current?.focus();
3014
+ };
3015
+ const askSignOut = (admin, session, trigger) => {
3016
+ confirmReturnRef.current = trigger;
3017
+ setPending({ admin, session });
3018
+ };
3019
+ const confirmSignOut = async () => {
3020
+ if (!pending) return;
3021
+ const { admin, session } = pending;
3022
+ const device = session?.device || t("adminPanel.session.unknownDevice", "Unknown browser");
3023
+ const url = session ? `/${index.pluginId}/admin-sessions/admins/${admin.id}/sessions/${session.id}/sign-out` : `/${index.pluginId}/admin-sessions/admins/${admin.id}/sign-out-everywhere`;
3024
+ try {
3025
+ const response = await post(url);
3026
+ const result = response?.data?.data || {};
3027
+ if (result.signedOutSelf) {
3028
+ toggleNotification({
3029
+ type: "warning",
3030
+ message: t(
3031
+ "adminPanel.signOut.success.self",
3032
+ "You signed yourself out of this browser. The login page opens next."
3033
+ )
3034
+ });
3035
+ } else {
3036
+ toggleNotification({
3037
+ type: "success",
3038
+ message: session ? t("adminPanel.signOut.success.one", "{name} was signed out of {device}.", {
3039
+ name: admin.name,
3040
+ device
3041
+ }) : t("adminPanel.signOut.success.all", "{name} was signed out everywhere.", {
3042
+ name: admin.name
3043
+ })
3044
+ });
3045
+ }
3046
+ await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
3047
+ } catch (err) {
3048
+ index.logSafeAdminError("adminPanel.signOut", err);
3049
+ const message = getSignOutErrorMessage(err);
3050
+ toggleNotification({
3051
+ type: getErrorStatus(err) === 404 ? "warning" : "danger",
3052
+ message: t(message.messageId, message.defaultMessage)
3053
+ });
3054
+ if (getErrorStatus(err) === 404) {
3055
+ await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
3056
+ return;
3057
+ }
3058
+ throw err;
3059
+ }
3060
+ };
3061
+ const stats = meta?.stats || EMPTY_STATS;
3062
+ const supported = meta?.supported !== false;
3063
+ const showData = !loading && Boolean(meta) && supported;
3064
+ const filtersActive = hasAdminFilters(view);
3065
+ const durationText = (seconds) => {
3066
+ const parts = splitDuration(seconds);
3067
+ if (!parts) return "";
3068
+ if (parts.unit === "days")
3069
+ return t("adminPanel.duration.days", "{count, plural, one {# day} other {# days}}", parts);
3070
+ if (parts.unit === "hours")
3071
+ return t("adminPanel.duration.hours", "{count, plural, one {# hour} other {# hours}}", parts);
3072
+ return t(
3073
+ "adminPanel.duration.minutes",
3074
+ "{count, plural, one {# minute} other {# minutes}}",
3075
+ parts
3076
+ );
3077
+ };
3078
+ const statusCard = (filter) => ({
3079
+ onClick: () => handleFilterChange(filter),
3080
+ pressed: view.filter === filter
3081
+ });
3082
+ let confirm = null;
3083
+ if (pending) {
3084
+ const { admin, session } = pending;
3085
+ const device = session?.device || t("adminPanel.session.unknownDevice", "Unknown browser");
3086
+ const includesThisBrowser = admin.self && (session ? session.current : true);
3087
+ const body = session ? t(
3088
+ "adminPanel.confirm.one.body",
3089
+ "{name} is signed out of {device} on their next click in the admin panel. They can sign in again with their password.",
3090
+ { name: admin.name, device }
3091
+ ) : t(
3092
+ "adminPanel.confirm.all.body",
3093
+ "Every session of {name} ends on their next click in the admin panel. They can sign in again with their password. To stop them from signing in, deactivate the account in Settings > Users.",
3094
+ { name: admin.name }
3095
+ );
3096
+ confirm = {
3097
+ title: includesThisBrowser ? t("adminPanel.confirm.self.title", "Sign yourself out?") : session ? t("adminPanel.confirm.one.title", "Sign {name} out of this browser?", {
3098
+ name: admin.name
3099
+ }) : t("adminPanel.confirm.all.title", "Sign {name} out everywhere?", { name: admin.name }),
3100
+ body: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, children: [
3101
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Description, { children: body }),
3102
+ includesThisBrowser ? /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "warning", children: t(
3103
+ "adminPanel.confirm.self.warning",
3104
+ "This includes the browser you are using now. You will be taken to the login page."
3105
+ ) }) : null
3106
+ ] }),
3107
+ label: session ? t("adminPanel.session.signOut", "Sign out") : t("adminPanel.actions.signOutEverywhereShort", "Sign out everywhere")
3108
+ };
3109
+ }
3110
+ const listProps = {
3111
+ admins,
3112
+ labelledBy: captionId,
3113
+ canRevoke: Boolean(canRevoke),
3114
+ onView: openDialog,
3115
+ onSignOutEverywhere: (admin, trigger) => askSignOut(admin, null, trigger),
3116
+ busy: refreshing
3117
+ };
3118
+ const policy = meta?.policy;
3119
+ const range = pagination.total > 0 ? {
3120
+ from: (pagination.page - 1) * pagination.pageSize + 1,
3121
+ to: Math.min(pagination.page * pagination.pageSize, pagination.total)
3122
+ } : null;
3123
+ return /* @__PURE__ */ jsxRuntime.jsx(
3124
+ index.PageShell,
3125
+ {
3126
+ headingId: "magic-sessionmanager-admin-panel-title",
3127
+ title: t("adminPanel.title", "Admin panel sessions"),
3128
+ subtitle: t(
3129
+ "adminPanel.subtitle",
3130
+ "Who is signed in to this Strapi admin panel. Your app’s users are under App users."
3131
+ ),
3132
+ primaryAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.LinkButton, { tag: reactRouterDom.Link, to: SETTINGS_USERS_PATH, variant: "secondary", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}), children: t("adminPanel.manageUsers", "Manage admins") }),
3133
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
3134
+ designSystem.Flex,
3135
+ {
3136
+ ref: pageRef,
3137
+ tabIndex: -1,
3138
+ direction: "column",
3139
+ alignItems: "stretch",
3140
+ gap: 6,
3141
+ minWidth: 0,
3142
+ children: [
3143
+ /* @__PURE__ */ jsxRuntime.jsx(SessionViewNav, { current: "admins" }),
3144
+ !loading && loadError ? /* @__PURE__ */ jsxRuntime.jsx(
3145
+ index.PersistentAlert,
3146
+ {
3147
+ variant: "danger",
3148
+ action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: fetchAdmins, children: t("common.tryAgain", "Try again") }),
3149
+ children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: t("adminPanel.error.load", "Admin sessions could not be loaded.") })
3150
+ }
3151
+ ) : null,
3152
+ loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: t("adminPanel.loading", "Loading admins") }) }) : null,
3153
+ !loading && meta && !supported ? /* @__PURE__ */ jsxRuntime.jsx(
3154
+ designSystem.EmptyStateLayout,
3155
+ {
3156
+ icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
3157
+ content: t(
3158
+ "adminPanel.unsupported",
3159
+ "Admin panel sessions are not available on this Strapi version. They need Strapi 5 with session management (tested with 5.62)."
3160
+ )
3161
+ }
3162
+ ) : null,
3163
+ showData ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3164
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", children: t("adminPanel.stats.label", "Admin statistics") }) }),
3165
+ /* @__PURE__ */ jsxRuntime.jsxs(index.StatGrid, { columns: 3, label: t("adminPanel.stats.label", "Admin statistics"), children: [
3166
+ /* @__PURE__ */ jsxRuntime.jsx(
3167
+ index.StatCard,
3168
+ {
3169
+ icon: icons.Check,
3170
+ tone: "success",
3171
+ label: t("adminPanel.stats.signedIn", "Signed-in admins"),
3172
+ value: stats.signedInAdmins,
3173
+ description: t(
3174
+ "adminPanel.stats.sessions",
3175
+ "{count, plural, one {# session} other {# sessions}} in total",
3176
+ { count: stats.activeSessions }
3177
+ ),
3178
+ ...statusCard("signed-in")
3179
+ }
3180
+ ),
3181
+ /* @__PURE__ */ jsxRuntime.jsx(
3182
+ index.StatCard,
3183
+ {
3184
+ icon: icons.Cross,
3185
+ tone: "neutral",
3186
+ label: t("adminPanel.stats.notSignedIn", "Not signed in"),
3187
+ value: Math.max(0, stats.totalAdmins - stats.signedInAdmins),
3188
+ description: t(
3189
+ "adminPanel.stats.notSignedIn.detail",
3190
+ "Includes deactivated and invited accounts"
3191
+ ),
3192
+ ...statusCard("not-signed-in")
3193
+ }
3194
+ ),
3195
+ /* @__PURE__ */ jsxRuntime.jsx(
3196
+ index.StatCard,
3197
+ {
3198
+ icon: icons.User,
3199
+ tone: "primary",
3200
+ label: t("adminPanel.stats.all", "All admins"),
3201
+ value: stats.totalAdmins,
3202
+ description: t(
3203
+ "adminPanel.stats.active",
3204
+ "{count, plural, one {# active account} other {# active accounts}}",
3205
+ { count: stats.activeAccounts }
3206
+ ),
3207
+ ...statusCard("all")
3208
+ }
3209
+ )
3210
+ ] })
3211
+ ] }) : null,
3212
+ showData ? /* @__PURE__ */ jsxRuntime.jsxs(
3213
+ index.PersistentAlert,
3214
+ {
3215
+ variant: "neutral",
3216
+ stacked: true,
3217
+ title: t("adminPanel.howItWorks.title", "How signing out works"),
3218
+ children: [
3219
+ /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: t(
3220
+ "adminPanel.howItWorks.body",
3221
+ "Signing out takes effect on the admin’s next click: Strapi checks the session on every admin request. They can sign in again with their password; to stop that, deactivate the account in Settings > Users. Admin API tokens are not affected. Strapi records no IP address for admin sessions."
3222
+ ) }),
3223
+ policy ? /* @__PURE__ */ jsxRuntime.jsxs(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: [
3224
+ " ",
3225
+ t(
3226
+ "adminPanel.howItWorks.policy",
3227
+ "Without activity a session ends after {idle}, or after {rememberIdle} when “Remember me” was ticked.",
3228
+ {
3229
+ idle: durationText(policy.idleSessionLifespan),
3230
+ rememberIdle: durationText(policy.idleRefreshTokenLifespan)
3231
+ }
3232
+ )
3233
+ ] }) : null
3234
+ ]
3235
+ }
3236
+ ) : null,
3237
+ showData ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
3238
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h2", children: t("adminPanel.list.heading", "Admin list") }) }),
3239
+ /* @__PURE__ */ jsxRuntime.jsxs(
3240
+ designSystem.Flex,
3241
+ {
3242
+ direction: { initial: "column", medium: "row" },
3243
+ alignItems: { initial: "stretch", medium: "center" },
3244
+ gap: 2,
3245
+ "data-admin-toolbar": "",
3246
+ children: [
3247
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { flex: "1 1 auto", minWidth: 0, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(
3248
+ SessionSearch,
3249
+ {
3250
+ value: view.search,
3251
+ onSearch: handleSearch,
3252
+ label: t("adminPanel.search.label", "Search admins"),
3253
+ placeholder: t("adminPanel.search.placeholder", "Search name or email")
3254
+ }
3255
+ ) }),
3256
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", shrink: 0, children: [
3257
+ /* @__PURE__ */ jsxRuntime.jsx(
3258
+ designSystem.Flex,
3259
+ {
3260
+ flex: isBelowMedium ? "1 1 auto" : void 0,
3261
+ minWidth: 0,
3262
+ direction: "column",
3263
+ alignItems: "stretch",
3264
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3265
+ designSystem.SingleSelect,
3266
+ {
3267
+ size: "S",
3268
+ "aria-label": t("adminPanel.filter.label", "Sign-in status"),
3269
+ value: view.filter,
3270
+ onChange: handleFilterChange,
3271
+ children: ADMIN_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelectOption, { value: option, children: [
3272
+ option === "all" && t("adminPanel.filter.all", "All admins"),
3273
+ option === "signed-in" && t("adminPanel.filter.signedIn", "Signed in"),
3274
+ option === "not-signed-in" && t("adminPanel.filter.notSignedIn", "Not signed in")
3275
+ ] }, option))
3276
+ }
3277
+ )
3278
+ }
3279
+ ),
3280
+ /* @__PURE__ */ jsxRuntime.jsx(
3281
+ designSystem.IconButton,
3282
+ {
3283
+ label: t("adminPanel.actions.refresh", "Refresh admins"),
3284
+ onClick: () => fetchAdmins(),
3285
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {})
3286
+ }
3287
+ )
3288
+ ] })
3289
+ ]
3290
+ }
3291
+ ),
3292
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", gap: 4, wrap: "wrap", children: [
3293
+ /* @__PURE__ */ jsxRuntime.jsx(
3294
+ designSystem.Typography,
3295
+ {
3296
+ id: captionId,
3297
+ ref: captionRef,
3298
+ tabIndex: -1,
3299
+ variant: "pi",
3300
+ textColor: "neutral600",
3301
+ "aria-live": "polite",
3302
+ "data-admin-caption": "",
3303
+ children: range ? t(
3304
+ "adminPanel.caption",
3305
+ "{from, number}–{to, number} of {total, plural, one {# admin} other {# admins}}",
3306
+ { ...range, total: pagination.total }
3307
+ ) : t("adminPanel.captionNone", "0 admins")
3308
+ }
3309
+ ),
3310
+ refreshing ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, role: "status", "aria-live": "polite", children: t("adminPanel.refreshing", "Updating admins") }) : null
3311
+ ] }),
3312
+ admins.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3313
+ isBelowMedium ? /* @__PURE__ */ jsxRuntime.jsx(AdminCardList, { ...listProps }) : /* @__PURE__ */ jsxRuntime.jsx(AdminTable, { ...listProps }),
3314
+ /* @__PURE__ */ jsxRuntime.jsx(PaginationTargets, { children: /* @__PURE__ */ jsxRuntime.jsxs(
3315
+ StrapiAdmin.Pagination.Root,
3316
+ {
3317
+ pageCount: pagination.pageCount,
3318
+ total: pagination.total,
3319
+ defaultPageSize: Number(ADMIN_DEFAULT_PAGE_SIZE),
3320
+ children: [
3321
+ /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...ADMIN_PAGE_SIZE_OPTIONS] }),
3322
+ /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.Links, {})
3323
+ ]
3324
+ }
3325
+ ) })
3326
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(
3327
+ designSystem.EmptyStateLayout,
3328
+ {
3329
+ icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
3330
+ content: filtersActive ? t("adminPanel.noResults", "No admins match your search or filter.") : t("adminPanel.empty", "No admin accounts yet."),
3331
+ action: filtersActive ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: handleClearFilters, children: t("adminPanel.noResults.reset", "Clear filters") }) : null
3332
+ }
3333
+ )
3334
+ ] }) : null,
3335
+ selected ? /* @__PURE__ */ jsxRuntime.jsx(
3336
+ AdminSessionsModal,
3337
+ {
3338
+ admin: selected,
3339
+ sessions: dialogSessions,
3340
+ loading: dialogLoading && dialogSessions.length === 0,
3341
+ error: dialogError,
3342
+ onRetry: () => fetchDialogSessions(selected),
3343
+ canRevoke: Boolean(canRevoke),
3344
+ onSignOut: (session, trigger) => askSignOut(selected, session, trigger),
3345
+ onSignOutEverywhere: (trigger) => askSignOut(selected, null, trigger),
3346
+ onClose: closeDialog,
3347
+ onCloseAutoFocus: (event) => index.restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
3348
+ }
3349
+ ) : null,
3350
+ confirm ? /* @__PURE__ */ jsxRuntime.jsx(
3351
+ index.ConfirmAction,
3352
+ {
3353
+ isOpen: true,
3354
+ onOpenChange: (open) => {
3355
+ if (!open) setPending(null);
3356
+ },
3357
+ title: confirm.title,
3358
+ body: confirm.body,
3359
+ confirmLabel: confirm.label,
3360
+ onConfirm: confirmSignOut,
3361
+ returnFocusRef: confirmReturnRef,
3362
+ fallbackFocusRef: captionRef
3363
+ }
3364
+ ) : null
3365
+ ]
3366
+ }
3367
+ )
3368
+ }
3369
+ );
3370
+ };
2356
3371
  const App = () => {
2357
- return /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Page.Protect, { permissions: index.pluginPermissions.access, children: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) });
3372
+ return /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Page.Protect, { permissions: index.pluginPermissions.access, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
3373
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) }),
3374
+ /* @__PURE__ */ jsxRuntime.jsx(
3375
+ reactRouterDom.Route,
3376
+ {
3377
+ path: "admin-panel",
3378
+ element: /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Page.Protect, { permissions: index.pluginPermissions.adminSessionsRead, children: /* @__PURE__ */ jsxRuntime.jsx(AdminPanelPage, {}) })
3379
+ }
3380
+ ),
3381
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) })
3382
+ ] }) });
2358
3383
  };
2359
3384
  exports.default = App;