strapi-plugin-magic-sessionmanager 4.15.0 → 4.16.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 (27) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +91 -7
  3. package/dist/admin/{Analytics-HK6_TEmk.mjs → Analytics-D4gsVwL0.mjs} +1 -1
  4. package/dist/admin/{Analytics-Dbs5QXLb.js → Analytics-me4qzS0I.js} +1 -1
  5. package/dist/admin/{App-BOFzZ5d8.mjs → App-BJwtFWxl.mjs} +863 -81
  6. package/dist/admin/{App-7SxOBJP5.js → App-BTG-2Q26.js} +862 -80
  7. package/dist/admin/{OnlineUsersWidget-Dns_74xJ.js → OnlineUsersWidget-DYS3Vy1Q.js} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-CoCxnww-.mjs → OnlineUsersWidget-Yd283YDy.mjs} +1 -1
  9. package/dist/admin/{Settings-DYRShQ8W.mjs → Settings-DIlvfdjZ.mjs} +170 -19
  10. package/dist/admin/{Settings-B6CrR-07.js → Settings-TPZ9_75s.js} +169 -18
  11. package/dist/admin/{de-bkkCvSxX.js → de-BuMw1gBJ.js} +92 -2
  12. package/dist/admin/{de-B3mPtxsW.mjs → de-DB9ldYwN.mjs} +92 -2
  13. package/dist/admin/{en-BnU8BNkN.mjs → en-BbLMPQB3.mjs} +92 -2
  14. package/dist/admin/{en-DMICyIow.js → en-BqGhOJDy.js} +92 -2
  15. package/dist/admin/{es-OSzHGRIu.js → es-BaIeckl9.js} +92 -2
  16. package/dist/admin/{es-BxMgfJ1Y.mjs → es-C5iaiE9G.mjs} +92 -2
  17. package/dist/admin/{fr-WPrbtx8k.mjs → fr-BEvBUCwI.mjs} +92 -2
  18. package/dist/admin/{fr-Bu_8miJ4.js → fr-D1YKyTex.js} +92 -2
  19. package/dist/admin/{index-CNSJITRX.js → index-CgZiLcJ1.js} +13 -10
  20. package/dist/admin/{index-lnZBc5n0.mjs → index-DUESEUaO.mjs} +13 -10
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +1 -1
  23. package/dist/admin/{pt-C41KyEDN.mjs → pt-DeDih9cR.mjs} +92 -2
  24. package/dist/admin/{pt-B08xnb0K.js → pt-DtnW-s0V.js} +92 -2
  25. package/dist/server/index.js +1917 -103
  26. package/dist/server/index.mjs +1917 -103
  27. package/package.json +1 -1
@@ -3,12 +3,13 @@ import { useFetchClient, useNotification, useClipboard, useRBAC, useQueryParams,
3
3
  import { NavLink, Link as Link$1, Routes, Route } from "react-router-dom";
4
4
  import { useMemo, useState, useEffect, useRef, useCallback, useId, useLayoutEffect } from "react";
5
5
  import { useIntl } from "react-intl";
6
- import { Typography, Flex, Loader, Button, Modal, Accordion, Box, IconButton, Link, SimpleMenu, MenuItem, Grid, Table, Thead, Tr, Th, VisuallyHidden, Tbody, Td, Tooltip, SearchForm, Searchbar, TextButton, SingleSelect, SingleSelectOption, EmptyStateLayout, LinkButton, Badge, Dialog } from "@strapi/design-system";
6
+ import { Typography, Flex, Loader, Button, Modal, Accordion, Box, IconButton, Link, SimpleMenu, MenuItem, Grid, Table, Thead, Tr, Th, VisuallyHidden, Tbody, Td, Tooltip, SearchForm, Searchbar, TextButton, SingleSelect, SingleSelectOption, EmptyStateLayout, LinkButton, Badge, Tabs, Dialog } from "@strapi/design-system";
7
7
  import { Earth, Duplicate, Cross, Eye, Trash, More, CaretDown, Download, ArrowClockwise, Check, Clock, User, ChartBubble, Cog, SignOut } from "@strapi/icons";
8
8
  import { EmptyDocuments } from "@strapi/icons/symbols";
9
9
  import styled, { useTheme } from "styled-components";
10
- import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, i as isSessionFilter, D as DEFAULT_SESSION_FILTER, c as isEndReasonFilter, d as DEFAULT_END_REASON_FILTER, e as getDevicePresentation, u as useSessionFormatters, f as getSessionStatus, h as isNativeOnlySession, j as getSessionEndReasonPresentation, k as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, o as pluginPermissions, M as MissingValue, V as ValueOrMissing, q as SESSION_STATES, r as SESSION_STATUS_PRESENTATION, s as isCancelledRequest, v as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, w as PageShell, x as StatGrid, y as StatCard, z as restoreDialogFocus, A as requireSessionList, B as getBadgeColors } from "./index-lnZBc5n0.mjs";
10
+ import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, i as isSessionFilter, D as DEFAULT_SESSION_FILTER, c as isEndReasonFilter, d as DEFAULT_END_REASON_FILTER, e as getDevicePresentation, u as useSessionFormatters, f as getSessionStatus, h as isNativeOnlySession, j as getSessionEndReasonPresentation, k as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, o as pluginPermissions, M as MissingValue, V as ValueOrMissing, q as SESSION_STATES, r as SESSION_STATUS_PRESENTATION, s as isCancelledRequest, v as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, w as PageShell, x as StatGrid, y as StatCard, z as restoreDialogFocus, A as requireSessionList, B as getBadgeColors, T as TargetLink$1 } from "./index-DUESEUaO.mjs";
11
11
  import { i as isRiskSource, R as RISK_SETTINGS_PATH } from "./riskData-CI1gm2yI.mjs";
12
+ import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
12
13
  const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
13
14
  const { formatMessage } = useIntl();
14
15
  const key = reason || getSessionEndReason(session);
@@ -2557,14 +2558,17 @@ function getSignOutErrorMessage(error) {
2557
2558
  };
2558
2559
  }
2559
2560
  const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
2561
+ const keepActionKeys = (event) => {
2562
+ if (shouldIsolateActionKey(event.key, true)) event.stopPropagation();
2563
+ };
2560
2564
  const SHRINKING_ADMIN_CELL = { maxWidth: 0, width: "34%" };
2561
2565
  const SHRINKING_ROLES_CELL = { maxWidth: 0, width: "22%" };
2562
- const useT$1 = () => {
2566
+ const useT$3 = () => {
2563
2567
  const { formatMessage } = useIntl();
2564
2568
  return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
2565
2569
  };
2566
2570
  const AdminIdentity = ({ admin }) => {
2567
- const t = useT$1();
2571
+ const t = useT$3();
2568
2572
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children: [
2569
2573
  /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
2570
2574
  /* @__PURE__ */ jsx(
@@ -2584,13 +2588,13 @@ const AdminIdentity = ({ admin }) => {
2584
2588
  ] });
2585
2589
  };
2586
2590
  const AdminRoles = ({ admin }) => {
2587
- const t = useT$1();
2591
+ const t = useT$3();
2588
2592
  const names = (admin.roles || []).map((role) => role.name).filter(Boolean);
2589
2593
  const text = names.length ? names.join(", ") : t("adminPanel.roles.none", "No role");
2590
2594
  return /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", ellipsis: true, title: text, children: text });
2591
2595
  };
2592
2596
  const AdminStatus = ({ admin }) => {
2593
- const t = useT$1();
2597
+ const t = useT$3();
2594
2598
  const status = getAdminStatusPresentation(admin);
2595
2599
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-admin-status": status.key, children: [
2596
2600
  /* @__PURE__ */ jsx(Badge, { ...getBadgeColors(status.tone), children: t(status.label.messageId, status.label.defaultMessage) }),
@@ -2605,7 +2609,7 @@ const AdminTable = ({
2605
2609
  onSignOutEverywhere,
2606
2610
  busy
2607
2611
  }) => {
2608
- const t = useT$1();
2612
+ const t = useT$3();
2609
2613
  return /* @__PURE__ */ jsx(Box, { background: "neutral0", hasRadius: true, shadow: "tableShadow", "data-admin-table": "", children: /* @__PURE__ */ jsxs(
2610
2614
  Table,
2611
2615
  {
@@ -2626,7 +2630,7 @@ const AdminTable = ({
2626
2630
  /* @__PURE__ */ jsx(Td, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsx(AdminRoles, { admin }) }),
2627
2631
  /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(AdminStatus, { admin }) }),
2628
2632
  /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(LastActive, { value: admin.lastActiveAt }) }),
2629
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(RowActions, { children: [
2633
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(RowActions, { onKeyDown: keepActionKeys, children: [
2630
2634
  /* @__PURE__ */ jsx(
2631
2635
  IconButton,
2632
2636
  {
@@ -2659,7 +2663,7 @@ const AdminTable = ({
2659
2663
  ) });
2660
2664
  };
2661
2665
  const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywhere }) => {
2662
- const t = useT$1();
2666
+ const t = useT$3();
2663
2667
  return /* @__PURE__ */ jsx(
2664
2668
  Flex,
2665
2669
  {
@@ -2727,6 +2731,743 @@ const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywh
2727
2731
  }
2728
2732
  );
2729
2733
  };
2734
+ const SIGN_IN_FILTER_OPTIONS = Object.freeze(["all", "succeeded", "failed", "signed-out"]);
2735
+ const ACTIVITY_ACTION_OPTIONS = Object.freeze([
2736
+ "all",
2737
+ "view",
2738
+ "create",
2739
+ "update",
2740
+ "publish",
2741
+ "unpublish",
2742
+ "discard",
2743
+ "delete",
2744
+ "clone"
2745
+ ]);
2746
+ const PERIOD_OPTIONS = Object.freeze(["1", "7", "30", "90", "all"]);
2747
+ const EVENT_PAGE_SIZE = 20;
2748
+ const MAX_EVENT_EXPORT_ROWS = 1e4;
2749
+ function periodStart(period, now = /* @__PURE__ */ new Date()) {
2750
+ const days = Number.parseInt(period, 10);
2751
+ if (!Number.isInteger(days) || days <= 0) return void 0;
2752
+ return new Date(now.getTime() - days * 24 * 60 * 60 * 1e3).toISOString();
2753
+ }
2754
+ function buildSignInParams(filters, now) {
2755
+ const params = {
2756
+ page: filters.page || 1,
2757
+ pageSize: filters.pageSize || EVENT_PAGE_SIZE,
2758
+ event: SIGN_IN_FILTER_OPTIONS.includes(filters.event) ? filters.event : "all"
2759
+ };
2760
+ if (filters.adminId) params.adminId = String(filters.adminId);
2761
+ const from = periodStart(filters.period || "all", now);
2762
+ if (from) params.from = from;
2763
+ return params;
2764
+ }
2765
+ function buildActivityParams(filters, now) {
2766
+ const params = {
2767
+ page: filters.page || 1,
2768
+ pageSize: filters.pageSize || EVENT_PAGE_SIZE,
2769
+ action: ACTIVITY_ACTION_OPTIONS.includes(filters.action) ? filters.action : "all"
2770
+ };
2771
+ if (filters.adminId) params.adminId = String(filters.adminId);
2772
+ if (filters.contentType && filters.contentType !== "all")
2773
+ params.contentType = filters.contentType;
2774
+ const from = periodStart(filters.period || "all", now);
2775
+ if (from) params.from = from;
2776
+ return params;
2777
+ }
2778
+ function toExportParams(params, cursor) {
2779
+ const { page: _page, pageSize: _pageSize, ...rest } = params;
2780
+ return cursor ? { ...rest, cursor } : rest;
2781
+ }
2782
+ const message = (messageId, defaultMessage) => ({ messageId, defaultMessage });
2783
+ const FAILURE_REASONS = Object.freeze({
2784
+ invalid_credentials: message(
2785
+ "adminPanel.activity.reason.invalidCredentials",
2786
+ "Wrong email or password"
2787
+ ),
2788
+ account_inactive: message("adminPanel.activity.reason.accountInactive", "Account is deactivated"),
2789
+ login_not_allowed: message("adminPanel.activity.reason.notAllowed", "Sign-in is not allowed"),
2790
+ rate_limited: message("adminPanel.activity.reason.rateLimited", "Too many attempts")
2791
+ });
2792
+ function getSignInEventPresentation(row) {
2793
+ switch (row?.event) {
2794
+ case "admin.sign-in":
2795
+ return {
2796
+ key: "sign-in",
2797
+ tone: "success",
2798
+ label: message("adminPanel.activity.event.signIn", "Signed in"),
2799
+ detail: row.reason === "registration" ? message("adminPanel.activity.reason.registration", "First sign-in after registration") : row.reason === "password_reset" ? message(
2800
+ "adminPanel.activity.reason.passwordReset",
2801
+ "Signed in after a password reset"
2802
+ ) : null
2803
+ };
2804
+ case "admin.sign-in.failed":
2805
+ return {
2806
+ key: "failed",
2807
+ tone: "warning",
2808
+ label: message("adminPanel.activity.event.failed", "Sign-in failed"),
2809
+ detail: FAILURE_REASONS[row.reason] || null
2810
+ };
2811
+ case "admin.lockout":
2812
+ return {
2813
+ key: "lockout",
2814
+ tone: "warning",
2815
+ label: message("adminPanel.activity.event.lockout", "Locked out"),
2816
+ detail: FAILURE_REASONS.rate_limited
2817
+ };
2818
+ case "admin.sign-out":
2819
+ return {
2820
+ key: "sign-out",
2821
+ tone: "neutral",
2822
+ label: message("adminPanel.activity.event.signOut", "Signed out"),
2823
+ detail: null
2824
+ };
2825
+ case "admin.session.revoked":
2826
+ return {
2827
+ key: "revoked",
2828
+ tone: "neutral",
2829
+ label: message("adminPanel.activity.event.revoked", "Signed out by an admin"),
2830
+ detail: row.scope === "one_browser" ? message("adminPanel.activity.scope.oneBrowser", "One browser") : message("adminPanel.activity.scope.everywhere", "Every browser")
2831
+ };
2832
+ default:
2833
+ return {
2834
+ key: "other",
2835
+ tone: "neutral",
2836
+ label: message("adminPanel.activity.event.other", "Security event"),
2837
+ detail: null
2838
+ };
2839
+ }
2840
+ }
2841
+ function getSessionStatePresentation(session) {
2842
+ switch (session?.state) {
2843
+ case "active":
2844
+ return {
2845
+ tone: "success",
2846
+ label: message("adminPanel.activity.session.active", "Still signed in")
2847
+ };
2848
+ case "signed-out":
2849
+ return {
2850
+ tone: "neutral",
2851
+ label: message("adminPanel.activity.session.signedOut", "Signed out")
2852
+ };
2853
+ case "ended":
2854
+ return {
2855
+ tone: "neutral",
2856
+ label: message("adminPanel.activity.session.ended", "Session ended")
2857
+ };
2858
+ default:
2859
+ return null;
2860
+ }
2861
+ }
2862
+ const ACTIVITY_ACTION_LABELS = Object.freeze({
2863
+ all: message("adminPanel.activity.action.all", "All actions"),
2864
+ view: message("adminPanel.activity.action.view", "Opened"),
2865
+ create: message("adminPanel.activity.action.create", "Created"),
2866
+ update: message("adminPanel.activity.action.update", "Edited"),
2867
+ publish: message("adminPanel.activity.action.publish", "Published"),
2868
+ unpublish: message("adminPanel.activity.action.unpublish", "Unpublished"),
2869
+ discard: message("adminPanel.activity.action.discard", "Discarded draft"),
2870
+ delete: message("adminPanel.activity.action.delete", "Deleted"),
2871
+ clone: message("adminPanel.activity.action.clone", "Duplicated")
2872
+ });
2873
+ function getActivityTone(action) {
2874
+ if (action === "publish") return "success";
2875
+ if (action === "delete") return "warning";
2876
+ return "neutral";
2877
+ }
2878
+ function getEntryPath(row) {
2879
+ const type = row?.contentType;
2880
+ if (!type?.exists || row.action === "delete") return null;
2881
+ const uid = encodeURIComponent(type.uid);
2882
+ const locale = row.entry?.locale ? `?plugins[i18n][locale]=${encodeURIComponent(row.entry.locale)}` : "";
2883
+ if (type.kind === "single") return `/content-manager/single-types/${uid}${locale}`;
2884
+ if (!row.entry?.documentId) return null;
2885
+ return `/content-manager/collection-types/${uid}/${encodeURIComponent(row.entry.documentId)}${locale}`;
2886
+ }
2887
+ const SIGN_IN_CSV_HEADERS = Object.freeze([
2888
+ "Time",
2889
+ "Event",
2890
+ "Reason",
2891
+ "Admin",
2892
+ "Admin ID",
2893
+ "IP Address",
2894
+ "IP Anonymized",
2895
+ "Country",
2896
+ "City",
2897
+ "Browser",
2898
+ "OS",
2899
+ "Device",
2900
+ "Session",
2901
+ "Signed Out By"
2902
+ ]);
2903
+ const ACTIVITY_CSV_HEADERS = Object.freeze([
2904
+ "Time",
2905
+ "Action",
2906
+ "Admin",
2907
+ "Admin ID",
2908
+ "Content Type",
2909
+ "Content Type UID",
2910
+ "Document ID",
2911
+ "Locale",
2912
+ "Title",
2913
+ "Entries"
2914
+ ]);
2915
+ const toCsv = (headers, rows) => [headers, ...rows].map((cells) => cells.map(escapeCsvValue).join(",")).join("\n");
2916
+ function buildSignInCsv(rows) {
2917
+ return toCsv(
2918
+ SIGN_IN_CSV_HEADERS,
2919
+ rows.map((row) => [
2920
+ row.at || "",
2921
+ row.event || "",
2922
+ row.reason || row.scope || "",
2923
+ row.admin?.name || "",
2924
+ row.admin?.id ?? "",
2925
+ row.ipAddress || "",
2926
+ row.ipAnonymized ? "yes" : "no",
2927
+ row.location?.country || "",
2928
+ row.location?.city || "",
2929
+ row.browser || "",
2930
+ row.os || "",
2931
+ row.deviceType || "",
2932
+ row.session?.state || "",
2933
+ row.actor?.name || ""
2934
+ ])
2935
+ );
2936
+ }
2937
+ function buildActivityCsv(rows) {
2938
+ return toCsv(
2939
+ ACTIVITY_CSV_HEADERS,
2940
+ rows.map((row) => [
2941
+ row.at || "",
2942
+ row.action || "",
2943
+ row.admin?.name || "",
2944
+ row.admin?.id ?? "",
2945
+ row.contentType?.name || "",
2946
+ row.contentType?.uid || "",
2947
+ row.entry?.documentId || "",
2948
+ row.entry?.locale || "",
2949
+ row.entry?.title || "",
2950
+ row.entry?.count ?? ""
2951
+ ])
2952
+ );
2953
+ }
2954
+ const useT$2 = () => {
2955
+ const { formatMessage } = useIntl();
2956
+ return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
2957
+ };
2958
+ const TargetTextButton = styled(TextButton)`
2959
+ min-height: 3.2rem;
2960
+ `;
2961
+ const EventItem = ({ children, id, kind }) => /* @__PURE__ */ jsx(
2962
+ Box,
2963
+ {
2964
+ tag: "li",
2965
+ background: "neutral0",
2966
+ borderColor: "neutral150",
2967
+ hasRadius: true,
2968
+ padding: 3,
2969
+ "data-event-row": kind,
2970
+ "data-event-id": id,
2971
+ children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children })
2972
+ }
2973
+ );
2974
+ const AdminName = ({ admin, onOpenAdmin }) => {
2975
+ const t = useT$2();
2976
+ if (!admin) {
2977
+ return /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: t("adminPanel.activity.unknownAccount", "Unknown account") });
2978
+ }
2979
+ if (!onOpenAdmin) {
2980
+ return /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: admin.name });
2981
+ }
2982
+ return /* @__PURE__ */ jsx(
2983
+ TargetTextButton,
2984
+ {
2985
+ onClick: (event) => onOpenAdmin(admin, event.currentTarget),
2986
+ "aria-label": t("adminPanel.activity.openAdmin", "Open the details of {name}", {
2987
+ name: admin.name
2988
+ }),
2989
+ children: admin.name
2990
+ }
2991
+ );
2992
+ };
2993
+ const SignInEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
2994
+ const t = useT$2();
2995
+ const event = getSignInEventPresentation(row);
2996
+ const session = getSessionStatePresentation(row.session);
2997
+ const facts = [];
2998
+ if (row.ipAddress) {
2999
+ facts.push(
3000
+ row.ipAnonymized ? t("adminPanel.activity.ipAnonymized", "{ip} (anonymised)", { ip: row.ipAddress }) : row.ipAddress
3001
+ );
3002
+ }
3003
+ const place = [row.location?.city, row.location?.country].filter(Boolean).join(", ");
3004
+ if (place) facts.push(place);
3005
+ if (row.browser && row.os) {
3006
+ facts.push(
3007
+ t("adminPanel.activity.browserOnOs", "{browser} on {os}", {
3008
+ browser: row.browser,
3009
+ os: row.os
3010
+ })
3011
+ );
3012
+ } else if (row.browser || row.os) {
3013
+ facts.push(row.browser || row.os);
3014
+ }
3015
+ if (row.actor)
3016
+ facts.push(t("adminPanel.activity.byAdmin", "by {name}", { name: row.actor.name }));
3017
+ return /* @__PURE__ */ jsxs(EventItem, { id: row.id, kind: event.key, children: [
3018
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
3019
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
3020
+ /* @__PURE__ */ jsx(Badge, { ...getBadgeColors(event.tone), children: t(event.label.messageId, event.label.defaultMessage) }),
3021
+ showAdmin ? /* @__PURE__ */ jsx(AdminName, { admin: row.admin, onOpenAdmin }) : null,
3022
+ event.detail ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(event.detail.messageId, event.detail.defaultMessage) }) : null
3023
+ ] }),
3024
+ /* @__PURE__ */ jsx(LastActive, { value: row.at })
3025
+ ] }),
3026
+ facts.length ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: facts.join(" · ") }) : null,
3027
+ session ? /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
3028
+ /* @__PURE__ */ jsx(Badge, { ...getBadgeColors(session.tone), children: t(session.label.messageId, session.label.defaultMessage) }),
3029
+ row.session?.endedAt ? /* @__PURE__ */ jsx(LastActive, { value: row.session.endedAt }) : null
3030
+ ] }) : null
3031
+ ] });
3032
+ };
3033
+ const ActivityEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
3034
+ const t = useT$2();
3035
+ const label = ACTIVITY_ACTION_LABELS[row.action] || ACTIVITY_ACTION_LABELS.view;
3036
+ const path = getEntryPath(row);
3037
+ const entryName = row.entry?.count !== null && row.entry?.count !== void 0 ? t("adminPanel.activity.entries", "{count, plural, one {# entry} other {# entries}}", {
3038
+ count: row.entry.count
3039
+ }) : row.entry?.title || row.entry?.documentId || row.contentType?.name || "";
3040
+ const facts = [row.contentType?.name];
3041
+ if (row.entry?.locale) facts.push(row.entry.locale);
3042
+ return /* @__PURE__ */ jsxs(EventItem, { id: row.id, kind: row.action, children: [
3043
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
3044
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
3045
+ /* @__PURE__ */ jsx(Badge, { ...getBadgeColors(getActivityTone(row.action)), children: t(label.messageId, label.defaultMessage) }),
3046
+ showAdmin ? /* @__PURE__ */ jsx(AdminName, { admin: row.admin, onOpenAdmin }) : null
3047
+ ] }),
3048
+ /* @__PURE__ */ jsx(LastActive, { value: row.at })
3049
+ ] }),
3050
+ /* @__PURE__ */ jsx(Box, { minWidth: 0, style: { overflowWrap: "anywhere" }, children: path ? /* @__PURE__ */ jsx(
3051
+ TargetLink$1,
3052
+ {
3053
+ tag: Link$1,
3054
+ to: path,
3055
+ "aria-label": t("adminPanel.activity.openEntry", "Open {entry} in the Content Manager", {
3056
+ entry: entryName
3057
+ }),
3058
+ children: entryName
3059
+ }
3060
+ ) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: entryName }) }),
3061
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: facts.filter(Boolean).join(" · ") })
3062
+ ] });
3063
+ };
3064
+ function useEventList({ path, params, logKey }) {
3065
+ const { get } = useFetchClient();
3066
+ const [rows, setRows] = useState([]);
3067
+ const [meta, setMeta] = useState(null);
3068
+ const [page, setPage] = useState(1);
3069
+ const [loading, setLoading] = useState(true);
3070
+ const [loadingMore, setLoadingMore] = useState(false);
3071
+ const [error, setError] = useState(false);
3072
+ const requestRef = useRef(0);
3073
+ const key = JSON.stringify(params);
3074
+ const load = useCallback(
3075
+ async (nextPage) => {
3076
+ const requestId = requestRef.current + 1;
3077
+ requestRef.current = requestId;
3078
+ if (nextPage === 1) setLoading(true);
3079
+ else setLoadingMore(true);
3080
+ try {
3081
+ const response = await get(path, { params: { ...JSON.parse(key), page: nextPage } });
3082
+ if (requestId !== requestRef.current) return;
3083
+ const body = response?.data || {};
3084
+ const data = Array.isArray(body.data) ? body.data : [];
3085
+ setRows((current) => nextPage === 1 ? data : [...current, ...data]);
3086
+ setMeta(body.meta || null);
3087
+ setPage(nextPage);
3088
+ setError(false);
3089
+ } catch (err) {
3090
+ if (requestId !== requestRef.current || isCancelledRequest(err)) return;
3091
+ setError(true);
3092
+ logSafeAdminError(logKey, err);
3093
+ } finally {
3094
+ if (requestId === requestRef.current) {
3095
+ setLoading(false);
3096
+ setLoadingMore(false);
3097
+ }
3098
+ }
3099
+ },
3100
+ [get, path, key, logKey]
3101
+ );
3102
+ useEffect(() => {
3103
+ load(1);
3104
+ return () => {
3105
+ requestRef.current += 1;
3106
+ };
3107
+ }, [load]);
3108
+ const pagination = meta?.pagination;
3109
+ const hasMore = Boolean(pagination && page < pagination.pageCount);
3110
+ const exportAll = useCallback(async () => {
3111
+ const all = [];
3112
+ let cursor = null;
3113
+ do {
3114
+ const response = await get(`${path}/export`, {
3115
+ params: toExportParams(JSON.parse(key), cursor)
3116
+ });
3117
+ const body = response?.data || {};
3118
+ if (!Array.isArray(body.data)) throw new Error("Invalid export response");
3119
+ all.push(...body.data);
3120
+ cursor = typeof body.meta?.nextCursor === "string" ? body.meta.nextCursor : null;
3121
+ } while (cursor && all.length < MAX_EVENT_EXPORT_ROWS);
3122
+ return {
3123
+ rows: all.slice(0, MAX_EVENT_EXPORT_ROWS),
3124
+ capped: all.length > MAX_EVENT_EXPORT_ROWS || Boolean(cursor)
3125
+ };
3126
+ }, [get, path, key]);
3127
+ return {
3128
+ rows,
3129
+ meta,
3130
+ loading,
3131
+ loadingMore,
3132
+ error,
3133
+ hasMore,
3134
+ loadMore: () => load(page + 1),
3135
+ reload: () => load(1),
3136
+ exportAll
3137
+ };
3138
+ }
3139
+ function downloadCsv(content, name) {
3140
+ const blob = new Blob([content], { type: "text/csv;charset=utf-8;" });
3141
+ const url = URL.createObjectURL(blob);
3142
+ const link = document.createElement("a");
3143
+ link.href = url;
3144
+ link.download = `${name}-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`;
3145
+ link.click();
3146
+ window.setTimeout(() => URL.revokeObjectURL(url), 0);
3147
+ }
3148
+ const ADMIN_ACTIVITY_SETTINGS_PATH = `/settings/${pluginId}/general?tab=admin-activity`;
3149
+ const useT$1 = () => {
3150
+ const { formatMessage } = useIntl();
3151
+ return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
3152
+ };
3153
+ const PeriodSelect = ({ value, onChange }) => {
3154
+ const t = useT$1();
3155
+ const labels = {
3156
+ 1: t("adminPanel.activity.period.day", "Last 24 hours"),
3157
+ 7: t("adminPanel.activity.period.week", "Last 7 days"),
3158
+ 30: t("adminPanel.activity.period.month", "Last 30 days"),
3159
+ 90: t("adminPanel.activity.period.quarter", "Last 90 days"),
3160
+ all: t("adminPanel.activity.period.all", "All kept events")
3161
+ };
3162
+ return /* @__PURE__ */ jsx(
3163
+ SingleSelect,
3164
+ {
3165
+ size: "S",
3166
+ "aria-label": t("adminPanel.activity.period.label", "Period"),
3167
+ value,
3168
+ onChange: (next) => onChange(String(next)),
3169
+ children: PERIOD_OPTIONS.map((option) => /* @__PURE__ */ jsx(SingleSelectOption, { value: option, children: labels[option] }, option))
3170
+ }
3171
+ );
3172
+ };
3173
+ const FilterSlot = ({ children }) => /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", minWidth: 0, flex: "1 1 18rem", children });
3174
+ const EventList = ({
3175
+ filters,
3176
+ notice,
3177
+ list,
3178
+ listLabel,
3179
+ emptyText,
3180
+ renderRow,
3181
+ toCsv: toCsv2,
3182
+ fileName,
3183
+ exportLabel
3184
+ }) => {
3185
+ const t = useT$1();
3186
+ const { toggleNotification } = useNotification();
3187
+ const [exporting, setExporting] = useState(false);
3188
+ const total = list.meta?.pagination?.total ?? 0;
3189
+ const handleExport = async () => {
3190
+ if (exporting) return;
3191
+ setExporting(true);
3192
+ try {
3193
+ const { rows, capped } = await list.exportAll();
3194
+ downloadCsv(toCsv2(rows), fileName);
3195
+ if (capped) {
3196
+ toggleNotification({
3197
+ type: "warning",
3198
+ message: t(
3199
+ "adminPanel.activity.export.capped",
3200
+ "The export contains the newest {limit, number} events. Narrow the filter to export the rest.",
3201
+ { limit: MAX_EVENT_EXPORT_ROWS }
3202
+ )
3203
+ });
3204
+ }
3205
+ } catch (err) {
3206
+ if (isCancelledRequest(err)) return;
3207
+ logSafeAdminError("adminPanel.activity.export", err);
3208
+ toggleNotification({
3209
+ type: "danger",
3210
+ message: t("adminPanel.activity.export.error", "The export could not be created.")
3211
+ });
3212
+ } finally {
3213
+ setExporting(false);
3214
+ }
3215
+ };
3216
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
3217
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
3218
+ /* @__PURE__ */ jsx(Flex, { gap: 2, wrap: "wrap", alignItems: "center", flex: "1 1 auto", minWidth: 0, children: filters }),
3219
+ /* @__PURE__ */ jsx(
3220
+ Button,
3221
+ {
3222
+ size: "S",
3223
+ variant: "tertiary",
3224
+ startIcon: /* @__PURE__ */ jsx(Download, {}),
3225
+ onClick: handleExport,
3226
+ loading: exporting,
3227
+ disabled: list.loading || total === 0,
3228
+ "aria-label": exportLabel,
3229
+ children: t("adminPanel.activity.export.csv", "Export CSV")
3230
+ }
3231
+ )
3232
+ ] }),
3233
+ notice,
3234
+ list.loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("adminPanel.activity.loading", "Loading events") }) }) : null,
3235
+ !list.loading && list.error ? /* @__PURE__ */ jsx(
3236
+ PersistentAlert,
3237
+ {
3238
+ variant: "danger",
3239
+ action: /* @__PURE__ */ jsx(Button, { size: "S", variant: "secondary", onClick: list.reload, children: t("common.tryAgain", "Try again") }),
3240
+ children: t("adminPanel.activity.error", "The events could not be loaded.")
3241
+ }
3242
+ ) : null,
3243
+ !list.loading && !list.error && list.rows.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", "data-event-empty": "", children: emptyText }) : null,
3244
+ list.rows.length > 0 ? /* @__PURE__ */ jsx(
3245
+ Flex,
3246
+ {
3247
+ tag: "ul",
3248
+ direction: "column",
3249
+ alignItems: "stretch",
3250
+ gap: 2,
3251
+ width: "100%",
3252
+ "aria-label": listLabel,
3253
+ children: list.rows.map((row) => renderRow(row))
3254
+ }
3255
+ ) : null,
3256
+ list.hasMore ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: list.loadMore, loading: list.loadingMore, children: t("adminPanel.activity.showMore", "Show more") }) }) : null
3257
+ ] });
3258
+ };
3259
+ const RecordingOff = ({ children }) => {
3260
+ const t = useT$1();
3261
+ return /* @__PURE__ */ jsx(
3262
+ PersistentAlert,
3263
+ {
3264
+ variant: "neutral",
3265
+ action: /* @__PURE__ */ jsx(Link, { tag: Link$1, to: ADMIN_ACTIVITY_SETTINGS_PATH, children: t("adminPanel.activity.openSettings", "Open settings") }),
3266
+ children
3267
+ }
3268
+ );
3269
+ };
3270
+ const SignInHistoryPanel = ({ admin }) => {
3271
+ const t = useT$1();
3272
+ const [event, setEvent] = useState("all");
3273
+ const [period, setPeriod] = useState("30");
3274
+ const params = useMemo(
3275
+ () => buildSignInParams({ adminId: admin.id, event, period }),
3276
+ [admin.id, event, period]
3277
+ );
3278
+ const list = useEventList({
3279
+ path: `/${pluginId}/admin-activity/sign-ins`,
3280
+ params,
3281
+ logKey: "adminPanel.activity.signIns"
3282
+ });
3283
+ const recording = list.meta?.recording;
3284
+ const labels = {
3285
+ all: t("adminPanel.activity.filter.allEvents", "All events"),
3286
+ succeeded: t("adminPanel.activity.filter.succeeded", "Sign-ins"),
3287
+ failed: t("adminPanel.activity.filter.failed", "Failed and locked out"),
3288
+ "signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs")
3289
+ };
3290
+ return /* @__PURE__ */ jsx(
3291
+ EventList,
3292
+ {
3293
+ list,
3294
+ filters: /* @__PURE__ */ jsxs(Fragment, { children: [
3295
+ /* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(
3296
+ SingleSelect,
3297
+ {
3298
+ size: "S",
3299
+ "aria-label": t("adminPanel.activity.filter.event", "Event"),
3300
+ value: event,
3301
+ onChange: (next) => setEvent(String(next)),
3302
+ children: SIGN_IN_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsx(SingleSelectOption, { value: option, children: labels[option] }, option))
3303
+ }
3304
+ ) }),
3305
+ /* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(PeriodSelect, { value: period, onChange: setPeriod }) })
3306
+ ] }),
3307
+ notice: recording && !recording.signIns ? /* @__PURE__ */ jsx(RecordingOff, { children: t(
3308
+ "adminPanel.activity.signIns.off",
3309
+ "Sign-in history is turned off. New sign-ins are not recorded."
3310
+ ) }) : null,
3311
+ listLabel: t("adminPanel.activity.signIns.listLabel", "Sign-in history of {name}", {
3312
+ name: admin.name
3313
+ }),
3314
+ emptyText: t("adminPanel.activity.signIns.empty", "No sign-in events in this period."),
3315
+ renderRow: (row) => /* @__PURE__ */ jsx(SignInEventRow, { row }, row.id),
3316
+ toCsv: buildSignInCsv,
3317
+ fileName: "admin-sign-in-history",
3318
+ exportLabel: t(
3319
+ "adminPanel.activity.signIns.export",
3320
+ "Export the sign-in history of {name} as CSV",
3321
+ {
3322
+ name: admin.name
3323
+ }
3324
+ )
3325
+ }
3326
+ );
3327
+ };
3328
+ const ContentActivityPanel = ({ admin }) => {
3329
+ const t = useT$1();
3330
+ const [action, setAction] = useState("all");
3331
+ const [contentType, setContentType] = useState("all");
3332
+ const [period, setPeriod] = useState("30");
3333
+ const params = useMemo(
3334
+ () => buildActivityParams({ adminId: admin.id, action, contentType, period }),
3335
+ [admin.id, action, contentType, period]
3336
+ );
3337
+ const list = useEventList({
3338
+ path: `/${pluginId}/admin-activity/content`,
3339
+ params,
3340
+ logKey: "adminPanel.activity.content"
3341
+ });
3342
+ const recording = list.meta?.recording;
3343
+ const types = Array.isArray(list.meta?.contentTypes) ? list.meta.contentTypes : [];
3344
+ const noAccess = list.meta?.contentManagerAccess === false;
3345
+ let notice = null;
3346
+ if (recording && !recording.contentActivity) {
3347
+ notice = /* @__PURE__ */ jsx(RecordingOff, { children: t(
3348
+ "adminPanel.activity.content.off",
3349
+ "Content Manager activity is not recorded. An admin can turn it on in the settings; inform your team first."
3350
+ ) });
3351
+ } else if (noAccess) {
3352
+ notice = /* @__PURE__ */ jsx(PersistentAlert, { variant: "neutral", children: t(
3353
+ "adminPanel.activity.content.noAccess",
3354
+ "{name} has no Content Manager access, so there is no activity to show.",
3355
+ { name: admin.name }
3356
+ ) });
3357
+ }
3358
+ return /* @__PURE__ */ jsx(
3359
+ EventList,
3360
+ {
3361
+ list,
3362
+ filters: /* @__PURE__ */ jsxs(Fragment, { children: [
3363
+ /* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(
3364
+ SingleSelect,
3365
+ {
3366
+ size: "S",
3367
+ "aria-label": t("adminPanel.activity.filter.action", "Action"),
3368
+ value: action,
3369
+ onChange: (next) => setAction(String(next)),
3370
+ children: ACTIVITY_ACTION_OPTIONS.map((option) => /* @__PURE__ */ jsx(SingleSelectOption, { value: option, children: t(
3371
+ ACTIVITY_ACTION_LABELS[option].messageId,
3372
+ ACTIVITY_ACTION_LABELS[option].defaultMessage
3373
+ ) }, option))
3374
+ }
3375
+ ) }),
3376
+ /* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsxs(
3377
+ SingleSelect,
3378
+ {
3379
+ size: "S",
3380
+ "aria-label": t("adminPanel.activity.filter.contentType", "Content type"),
3381
+ value: contentType,
3382
+ onChange: (next) => setContentType(String(next)),
3383
+ children: [
3384
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "all", children: t("adminPanel.activity.filter.allTypes", "All content types") }),
3385
+ types.map((type) => /* @__PURE__ */ jsx(SingleSelectOption, { value: type.uid, children: type.name }, type.uid))
3386
+ ]
3387
+ }
3388
+ ) }),
3389
+ /* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(PeriodSelect, { value: period, onChange: setPeriod }) })
3390
+ ] }),
3391
+ notice,
3392
+ listLabel: t("adminPanel.activity.content.listLabel", "Content Manager activity of {name}", {
3393
+ name: admin.name
3394
+ }),
3395
+ emptyText: t(
3396
+ "adminPanel.activity.content.empty",
3397
+ "No Content Manager activity in this period."
3398
+ ),
3399
+ renderRow: (row) => /* @__PURE__ */ jsx(ActivityEventRow, { row }, row.id),
3400
+ toCsv: buildActivityCsv,
3401
+ fileName: "admin-content-activity",
3402
+ exportLabel: t(
3403
+ "adminPanel.activity.content.export",
3404
+ "Export the Content Manager activity of {name} as CSV",
3405
+ { name: admin.name }
3406
+ )
3407
+ }
3408
+ );
3409
+ };
3410
+ const RecentSignInActivity = ({ onOpenAdmin }) => {
3411
+ const t = useT$1();
3412
+ const params = useMemo(() => buildSignInParams({ pageSize: 5 }), []);
3413
+ const list = useEventList({
3414
+ path: `/${pluginId}/admin-activity/sign-ins`,
3415
+ params,
3416
+ logKey: "adminPanel.activity.recent"
3417
+ });
3418
+ if (list.meta?.recording && !list.meta.recording.signIns) return null;
3419
+ return /* @__PURE__ */ jsxs(
3420
+ SectionCard,
3421
+ {
3422
+ title: t("adminPanel.activity.recent.title", "Recent sign-in activity"),
3423
+ subtitle: t(
3424
+ "adminPanel.activity.recent.subtitle",
3425
+ "The latest sign-ins, failed attempts and sign-outs of all admins. Open an admin for their full history."
3426
+ ),
3427
+ children: [
3428
+ list.loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 2, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("adminPanel.activity.loading", "Loading events") }) }) : null,
3429
+ !list.loading && list.error ? /* @__PURE__ */ jsx(
3430
+ PersistentAlert,
3431
+ {
3432
+ variant: "danger",
3433
+ action: /* @__PURE__ */ jsx(Button, { size: "S", variant: "secondary", onClick: list.reload, children: t("common.tryAgain", "Try again") }),
3434
+ children: t("adminPanel.activity.error", "The events could not be loaded.")
3435
+ }
3436
+ ) : null,
3437
+ !list.loading && !list.error && list.rows.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: t("adminPanel.activity.recent.empty", "No sign-in events yet.") }) : null,
3438
+ list.rows.length > 0 ? /* @__PURE__ */ jsx(
3439
+ Flex,
3440
+ {
3441
+ tag: "ul",
3442
+ direction: "column",
3443
+ alignItems: "stretch",
3444
+ gap: 2,
3445
+ width: "100%",
3446
+ "aria-label": t("adminPanel.activity.recent.title", "Recent sign-in activity"),
3447
+ children: list.rows.map((row) => /* @__PURE__ */ jsx(SignInEventRow, { row, showAdmin: true, onOpenAdmin }, row.id))
3448
+ }
3449
+ ) : null
3450
+ ]
3451
+ }
3452
+ );
3453
+ };
3454
+ const DialogTabsList = styled(Tabs.List)`
3455
+ overflow-x: auto;
3456
+ overflow-y: hidden;
3457
+ max-width: 100%;
3458
+ `;
3459
+ const DialogTabTrigger = styled(Tabs.Trigger)`
3460
+ && {
3461
+ flex: 0 0 auto;
3462
+ white-space: nowrap;
3463
+ }
3464
+ `;
3465
+ const DialogTabLabel = styled.span`
3466
+ text-transform: none;
3467
+ letter-spacing: normal;
3468
+ font-size: ${({ theme }) => theme.fontSizes[2]};
3469
+ `;
3470
+ const ADMIN_DIALOG_TABS = Object.freeze(["sessions", "history", "activity"]);
2730
3471
  const useT = () => {
2731
3472
  const { formatMessage } = useIntl();
2732
3473
  return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
@@ -2811,9 +3552,12 @@ const AdminSessionsModal = ({
2811
3552
  onSignOut,
2812
3553
  onSignOutEverywhere,
2813
3554
  onClose,
2814
- onCloseAutoFocus
3555
+ onCloseAutoFocus,
3556
+ canViewActivity = false,
3557
+ initialTab = "sessions"
2815
3558
  }) => {
2816
3559
  const t = useT();
3560
+ const [tab, setTab] = useState(ADMIN_DIALOG_TABS.includes(initialTab) ? initialTab : "sessions");
2817
3561
  const canSignOut = canRevoke && admin.account === "active" && !admin.protectedReason;
2818
3562
  const settingsPath = `/settings/users/${admin.id}`;
2819
3563
  let notice = null;
@@ -2828,70 +3572,80 @@ const AdminSessionsModal = ({
2828
3572
  "Only a Super Admin can sign out a Super Admin. This keeps at least one Super Admin able to work at all times."
2829
3573
  ) });
2830
3574
  }
3575
+ const sessionsContent = /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
3576
+ /* @__PURE__ */ jsx(
3577
+ PropertyList,
3578
+ {
3579
+ columns: 2,
3580
+ items: [
3581
+ {
3582
+ id: "email",
3583
+ label: t("adminPanel.dialog.email", "Email"),
3584
+ value: admin.email,
3585
+ kind: "email"
3586
+ },
3587
+ {
3588
+ id: "roles",
3589
+ label: t("adminPanel.table.roles", "Roles"),
3590
+ render: /* @__PURE__ */ jsx(AdminRoles, { admin })
3591
+ },
3592
+ {
3593
+ id: "status",
3594
+ label: t("adminPanel.table.status", "Status"),
3595
+ render: /* @__PURE__ */ jsx(AdminStatus, { admin: { ...admin, sessionCount: sessions.length } }),
3596
+ fullWidth: true
3597
+ }
3598
+ ]
3599
+ }
3600
+ ),
3601
+ notice,
3602
+ loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("adminPanel.dialog.loading", "Loading sessions") }) }) : null,
3603
+ !loading && error ? /* @__PURE__ */ jsx(
3604
+ PersistentAlert,
3605
+ {
3606
+ variant: "danger",
3607
+ action: /* @__PURE__ */ jsx(Button, { size: "S", variant: "secondary", onClick: onRetry, children: t("common.tryAgain", "Try again") }),
3608
+ children: t("adminPanel.dialog.error", "The sessions could not be loaded.")
3609
+ }
3610
+ ) : null,
3611
+ !loading && !error && admin.account === "active" && sessions.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", "data-admin-sessions-empty": "", children: t(
3612
+ "adminPanel.dialog.empty",
3613
+ "{name} is not signed in. Sessions appear here after the next sign-in.",
3614
+ { name: admin.name }
3615
+ ) }) : null,
3616
+ !loading && sessions.length > 0 ? /* @__PURE__ */ jsx(
3617
+ Flex,
3618
+ {
3619
+ tag: "ul",
3620
+ direction: "column",
3621
+ alignItems: "stretch",
3622
+ gap: 3,
3623
+ "aria-label": t("adminPanel.dialog.listLabel", "Signed-in browsers"),
3624
+ children: sessions.map((session) => /* @__PURE__ */ jsx(
3625
+ SessionCard,
3626
+ {
3627
+ session,
3628
+ admin,
3629
+ canSignOut,
3630
+ onSignOut
3631
+ },
3632
+ session.id
3633
+ ))
3634
+ }
3635
+ ) : null
3636
+ ] });
2831
3637
  return /* @__PURE__ */ jsx(Modal.Root, { open: true, onOpenChange: (open) => open ? null : onClose(), children: /* @__PURE__ */ jsxs(Modal.Content, { onCloseAutoFocus, "aria-describedby": void 0, children: [
2832
- /* @__PURE__ */ jsx(Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsx(Modal.Title, { children: t("adminPanel.dialog.title", "Sessions of {name}", { name: admin.name }) }) }),
2833
- /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
2834
- /* @__PURE__ */ jsx(
2835
- PropertyList,
2836
- {
2837
- columns: 2,
2838
- items: [
2839
- {
2840
- id: "email",
2841
- label: t("adminPanel.dialog.email", "Email"),
2842
- value: admin.email,
2843
- kind: "email"
2844
- },
2845
- {
2846
- id: "roles",
2847
- label: t("adminPanel.table.roles", "Roles"),
2848
- render: /* @__PURE__ */ jsx(AdminRoles, { admin })
2849
- },
2850
- {
2851
- id: "status",
2852
- label: t("adminPanel.table.status", "Status"),
2853
- render: /* @__PURE__ */ jsx(AdminStatus, { admin: { ...admin, sessionCount: sessions.length } }),
2854
- fullWidth: true
2855
- }
2856
- ]
2857
- }
2858
- ),
2859
- notice,
2860
- loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("adminPanel.dialog.loading", "Loading sessions") }) }) : null,
2861
- !loading && error ? /* @__PURE__ */ jsx(
2862
- PersistentAlert,
2863
- {
2864
- variant: "danger",
2865
- action: /* @__PURE__ */ jsx(Button, { size: "S", variant: "secondary", onClick: onRetry, children: t("common.tryAgain", "Try again") }),
2866
- children: t("adminPanel.dialog.error", "The sessions could not be loaded.")
2867
- }
2868
- ) : null,
2869
- !loading && !error && admin.account === "active" && sessions.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", "data-admin-sessions-empty": "", children: t(
2870
- "adminPanel.dialog.empty",
2871
- "{name} is not signed in. Sessions appear here after the next sign-in.",
2872
- { name: admin.name }
2873
- ) }) : null,
2874
- !loading && sessions.length > 0 ? /* @__PURE__ */ jsx(
2875
- Flex,
2876
- {
2877
- tag: "ul",
2878
- direction: "column",
2879
- alignItems: "stretch",
2880
- gap: 3,
2881
- "aria-label": t("adminPanel.dialog.listLabel", "Signed-in browsers"),
2882
- children: sessions.map((session) => /* @__PURE__ */ jsx(
2883
- SessionCard,
2884
- {
2885
- session,
2886
- admin,
2887
- canSignOut,
2888
- onSignOut
2889
- },
2890
- session.id
2891
- ))
2892
- }
2893
- ) : null
2894
- ] }) }),
3638
+ /* @__PURE__ */ jsx(Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsx(Modal.Title, { children: canViewActivity ? admin.name : t("adminPanel.dialog.title", "Sessions of {name}", { name: admin.name }) }) }),
3639
+ /* @__PURE__ */ jsx(Modal.Body, { children: canViewActivity ? /* @__PURE__ */ jsxs(Tabs.Root, { variant: "simple", value: tab, onValueChange: setTab, children: [
3640
+ /* @__PURE__ */ jsxs(DialogTabsList, { "aria-label": t("adminPanel.dialog.tabs", "Admin details"), children: [
3641
+ /* @__PURE__ */ jsx(DialogTabTrigger, { value: "sessions", children: /* @__PURE__ */ jsx(DialogTabLabel, { children: t("adminPanel.dialog.tab.sessions", "Sessions") }) }),
3642
+ /* @__PURE__ */ jsx(DialogTabTrigger, { value: "history", children: /* @__PURE__ */ jsx(DialogTabLabel, { children: t("adminPanel.dialog.tab.history", "Sign-in history") }) }),
3643
+ /* @__PURE__ */ jsx(DialogTabTrigger, { value: "activity", children: /* @__PURE__ */ jsx(DialogTabLabel, { children: t("adminPanel.dialog.tab.activity", "Activity") }) })
3644
+ ] }),
3645
+ /* @__PURE__ */ jsx(Tabs.Content, { value: "sessions", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: sessionsContent }) }),
3646
+ /* @__PURE__ */ jsx(Tabs.Content, { value: "history", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(SignInHistoryPanel, { admin }) }) }),
3647
+ /* @__PURE__ */ jsx(Tabs.Content, { value: "activity", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(ContentActivityPanel, { admin }) }) })
3648
+ ] }) : sessionsContent }),
2895
3649
  /* @__PURE__ */ jsx(Modal.Footer, { children: /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", justifyContent: "space-between", width: "100%", children: [
2896
3650
  /* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: t("common.close", "Close") }) }),
2897
3651
  /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", children: [
@@ -2936,12 +3690,16 @@ const AdminPanelPage = () => {
2936
3690
  const {
2937
3691
  allowedActions: { canRevoke }
2938
3692
  } = useRBAC(pluginPermissions.adminSessionsRevoke);
3693
+ const {
3694
+ allowedActions: { canRead: canViewActivity }
3695
+ } = useRBAC(pluginPermissions.adminActivityRead);
2939
3696
  const [admins, setAdmins] = useState([]);
2940
3697
  const [meta, setMeta] = useState(null);
2941
3698
  const [loading, setLoading] = useState(true);
2942
3699
  const [refreshing, setRefreshing] = useState(false);
2943
3700
  const [loadError, setLoadError] = useState(false);
2944
3701
  const [selected, setSelected] = useState(null);
3702
+ const [dialogTab, setDialogTab] = useState("sessions");
2945
3703
  const [dialogSessions, setDialogSessions] = useState([]);
2946
3704
  const [dialogLoading, setDialogLoading] = useState(false);
2947
3705
  const [dialogError, setDialogError] = useState(false);
@@ -3012,8 +3770,9 @@ const AdminPanelPage = () => {
3012
3770
  },
3013
3771
  [get]
3014
3772
  );
3015
- const openDialog = (admin, trigger) => {
3773
+ const openDialog = (admin, trigger, tab = "sessions") => {
3016
3774
  openerRef.current = trigger;
3775
+ setDialogTab(tab);
3017
3776
  setSelected(admin);
3018
3777
  setDialogSessions([]);
3019
3778
  setDialogError(false);
@@ -3076,10 +3835,10 @@ const AdminPanelPage = () => {
3076
3835
  await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
3077
3836
  } catch (err) {
3078
3837
  logSafeAdminError("adminPanel.signOut", err);
3079
- const message = getSignOutErrorMessage(err);
3838
+ const message2 = getSignOutErrorMessage(err);
3080
3839
  toggleNotification({
3081
3840
  type: getErrorStatus(err) === 404 ? "warning" : "danger",
3082
- message: t(message.messageId, message.defaultMessage)
3841
+ message: t(message2.messageId, message2.defaultMessage)
3083
3842
  });
3084
3843
  if (getErrorStatus(err) === 404) {
3085
3844
  await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
@@ -3146,6 +3905,7 @@ const AdminPanelPage = () => {
3146
3905
  busy: refreshing
3147
3906
  };
3148
3907
  const policy = meta?.policy;
3908
+ const recording = meta?.recording;
3149
3909
  const range = pagination.total > 0 ? {
3150
3910
  from: (pagination.page - 1) * pagination.pageSize + 1,
3151
3911
  to: Math.min(pagination.page * pagination.pageSize, pagination.total)
@@ -3246,10 +4006,23 @@ const AdminPanelPage = () => {
3246
4006
  stacked: true,
3247
4007
  title: t("adminPanel.howItWorks.title", "How signing out works"),
3248
4008
  children: [
3249
- /* @__PURE__ */ jsx(ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: t(
3250
- "adminPanel.howItWorks.body",
3251
- "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."
3252
- ) }),
4009
+ /* @__PURE__ */ jsxs(ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: [
4010
+ t(
4011
+ "adminPanel.howItWorks.body",
4012
+ "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."
4013
+ ),
4014
+ " ",
4015
+ recording?.ipAddresses ? t(
4016
+ "adminPanel.howItWorks.recorded",
4017
+ "Session Manager records every sign-in with time, browser and IP address in the sign-in history."
4018
+ ) : recording?.signIns ? t(
4019
+ "adminPanel.howItWorks.recordedNoIp",
4020
+ "Session Manager records every sign-in with time and browser in the sign-in history, without IP addresses."
4021
+ ) : t(
4022
+ "adminPanel.howItWorks.notRecorded",
4023
+ "Sign-in history is turned off, so no IP addresses of admins are recorded."
4024
+ )
4025
+ ] }),
3253
4026
  policy ? /* @__PURE__ */ jsxs(ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: [
3254
4027
  " ",
3255
4028
  t(
@@ -3362,9 +4135,17 @@ const AdminPanelPage = () => {
3362
4135
  }
3363
4136
  )
3364
4137
  ] }) : null,
4138
+ showData && canViewActivity ? /* @__PURE__ */ jsx(
4139
+ RecentSignInActivity,
4140
+ {
4141
+ onOpenAdmin: (admin, trigger) => openDialog(admin, trigger, "history")
4142
+ }
4143
+ ) : null,
3365
4144
  selected ? /* @__PURE__ */ jsx(
3366
4145
  AdminSessionsModal,
3367
4146
  {
4147
+ canViewActivity: Boolean(canViewActivity),
4148
+ initialTab: dialogTab,
3368
4149
  admin: selected,
3369
4150
  sessions: dialogSessions,
3370
4151
  loading: dialogLoading && dialogSessions.length === 0,
@@ -3375,7 +4156,8 @@ const AdminPanelPage = () => {
3375
4156
  onSignOutEverywhere: (trigger) => askSignOut(selected, null, trigger),
3376
4157
  onClose: closeDialog,
3377
4158
  onCloseAutoFocus: (event) => restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
3378
- }
4159
+ },
4160
+ `${selected.id}-${dialogTab}`
3379
4161
  ) : null,
3380
4162
  confirm ? /* @__PURE__ */ jsx(
3381
4163
  ConfirmAction,