strapi-plugin-magic-sessionmanager 4.15.0 → 4.16.1

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 +77 -0
  2. package/README.md +112 -14
  3. package/dist/admin/{Analytics-Dbs5QXLb.js → Analytics-CMR62DiD.js} +1 -1
  4. package/dist/admin/{Analytics-HK6_TEmk.mjs → Analytics-FcRt0X62.mjs} +1 -1
  5. package/dist/admin/{App-7SxOBJP5.js → App-CmytGbze.js} +935 -88
  6. package/dist/admin/{App-BOFzZ5d8.mjs → App-DBieSWB0.mjs} +936 -89
  7. package/dist/admin/{OnlineUsersWidget-Dns_74xJ.js → OnlineUsersWidget-Lzx9XB74.js} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-CoCxnww-.mjs → OnlineUsersWidget-zP9Hl_it.mjs} +1 -1
  9. package/dist/admin/{Settings-B6CrR-07.js → Settings-1v--SXC0.js} +350 -68
  10. package/dist/admin/{Settings-DYRShQ8W.mjs → Settings-CZOPusQK.mjs} +351 -69
  11. package/dist/admin/{de-B3mPtxsW.mjs → de-D3TSA066.mjs} +106 -2
  12. package/dist/admin/{de-bkkCvSxX.js → de-y_9mdVT7.js} +106 -2
  13. package/dist/admin/{en-BnU8BNkN.mjs → en-B60I97bK.mjs} +106 -2
  14. package/dist/admin/{en-DMICyIow.js → en-CIQB8nfI.js} +106 -2
  15. package/dist/admin/{es-BxMgfJ1Y.mjs → es-CJEL_iGC.mjs} +106 -2
  16. package/dist/admin/{es-OSzHGRIu.js → es-DHhHzlRY.js} +106 -2
  17. package/dist/admin/{fr-WPrbtx8k.mjs → fr-BfBK_iuV.mjs} +106 -2
  18. package/dist/admin/{fr-Bu_8miJ4.js → fr-D86FTt1w.js} +106 -2
  19. package/dist/admin/{index-CNSJITRX.js → index-CSJJn4qy.js} +18 -10
  20. package/dist/admin/{index-lnZBc5n0.mjs → index-tt61o2VH.mjs} +18 -10
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +1 -1
  23. package/dist/admin/{pt-B08xnb0K.js → pt-BE-FT-L8.js} +106 -2
  24. package/dist/admin/{pt-C41KyEDN.mjs → pt-C3PSvC7z.mjs} +106 -2
  25. package/dist/server/index.js +3114 -457
  26. package/dist/server/index.mjs +3114 -457
  27. package/package.json +1 -1
@@ -9,8 +9,9 @@ const designSystem = require("@strapi/design-system");
9
9
  const icons = require("@strapi/icons");
10
10
  const symbols = require("@strapi/icons/symbols");
11
11
  const styled = require("styled-components");
12
- const index = require("./index-CNSJITRX.js");
12
+ const index = require("./index-CSJJn4qy.js");
13
13
  const riskData = require("./riskData-BVs9GpgD.js");
14
+ const SectionCard = require("./SectionCard-BlWv8CRt.js");
14
15
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
15
16
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
16
17
  const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
@@ -110,7 +111,7 @@ const CSV_HEADERS = Object.freeze([
110
111
  "Minutes Idle",
111
112
  "End Reason"
112
113
  ]);
113
- const FORMULA_START = /^[=+\-@\t\r]/;
114
+ const FORMULA_START = /^[\s\u00ad\u200b-\u200f\u2060-\u2064\ufeff]*[=+\-@\uff1d\uff0b\uff0d\uff20\t\r\n]/;
114
115
  const escapeCsvValue = (value) => {
115
116
  const text = String(value ?? "");
116
117
  const safe = typeof value === "string" && FORMULA_START.test(text) ? `'${text}` : text;
@@ -2560,15 +2561,37 @@ function getSignOutErrorMessage(error) {
2560
2561
  defaultMessage: "The admin could not be signed out. Try again."
2561
2562
  };
2562
2563
  }
2564
+ function withIdentityPlaceholders(admin, placeholderName, identity) {
2565
+ if (!admin || typeof admin !== "object") return admin;
2566
+ const hidden = !admin.self && !admin.name;
2567
+ return {
2568
+ ...admin,
2569
+ name: admin.name || placeholderName(admin.id),
2570
+ identityHidden: hidden,
2571
+ rolesHidden: hidden && identity?.roles === false
2572
+ };
2573
+ }
2574
+ function withEventAdminNames(row, placeholderName) {
2575
+ if (!row || typeof row !== "object") return row;
2576
+ const fill = (admin) => admin && typeof admin === "object" && !admin.name ? { ...admin, name: placeholderName(admin.id), identityHidden: true } : admin;
2577
+ return {
2578
+ ...row,
2579
+ ...row.admin !== void 0 ? { admin: fill(row.admin) } : {},
2580
+ ...row.actor !== void 0 ? { actor: fill(row.actor) } : {}
2581
+ };
2582
+ }
2563
2583
  const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
2584
+ const keepActionKeys = (event) => {
2585
+ if (shouldIsolateActionKey(event.key, true)) event.stopPropagation();
2586
+ };
2564
2587
  const SHRINKING_ADMIN_CELL = { maxWidth: 0, width: "34%" };
2565
2588
  const SHRINKING_ROLES_CELL = { maxWidth: 0, width: "22%" };
2566
- const useT$1 = () => {
2589
+ const useT$3 = () => {
2567
2590
  const { formatMessage } = reactIntl.useIntl();
2568
2591
  return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
2569
2592
  };
2570
2593
  const AdminIdentity = ({ admin }) => {
2571
- const t = useT$1();
2594
+ const t = useT$3();
2572
2595
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children: [
2573
2596
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
2574
2597
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2584,17 +2607,17 @@ const AdminIdentity = ({ admin }) => {
2584
2607
  ),
2585
2608
  admin.self ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...HIGHLIGHT_BADGE, shrink: 0, children: t("adminPanel.you", "You") }) : null
2586
2609
  ] }),
2587
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, title: admin.email, children: admin.email })
2610
+ admin.identityHidden ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("adminPanel.identity.emailHidden", "Email hidden (needs “Read” on Users)") }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, title: admin.email, children: admin.email })
2588
2611
  ] });
2589
2612
  };
2590
2613
  const AdminRoles = ({ admin }) => {
2591
- const t = useT$1();
2614
+ const t = useT$3();
2592
2615
  const names = (admin.roles || []).map((role) => role.name).filter(Boolean);
2593
- const text = names.length ? names.join(", ") : t("adminPanel.roles.none", "No role");
2616
+ const text = admin.rolesHidden ? t("adminPanel.roles.hidden", "Hidden (needs “Read” on Roles)") : names.length ? names.join(", ") : t("adminPanel.roles.none", "No role");
2594
2617
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", ellipsis: true, title: text, children: text });
2595
2618
  };
2596
2619
  const AdminStatus = ({ admin }) => {
2597
- const t = useT$1();
2620
+ const t = useT$3();
2598
2621
  const status = getAdminStatusPresentation(admin);
2599
2622
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-admin-status": status.key, children: [
2600
2623
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...index.getBadgeColors(status.tone), children: t(status.label.messageId, status.label.defaultMessage) }),
@@ -2609,7 +2632,7 @@ const AdminTable = ({
2609
2632
  onSignOutEverywhere,
2610
2633
  busy
2611
2634
  }) => {
2612
- const t = useT$1();
2635
+ const t = useT$3();
2613
2636
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral0", hasRadius: true, shadow: "tableShadow", "data-admin-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(
2614
2637
  designSystem.Table,
2615
2638
  {
@@ -2630,7 +2653,7 @@ const AdminTable = ({
2630
2653
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin }) }),
2631
2654
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin }) }),
2632
2655
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: admin.lastActiveAt }) }),
2633
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(RowActions, { children: [
2656
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(RowActions, { onKeyDown: keepActionKeys, children: [
2634
2657
  /* @__PURE__ */ jsxRuntime.jsx(
2635
2658
  designSystem.IconButton,
2636
2659
  {
@@ -2663,7 +2686,7 @@ const AdminTable = ({
2663
2686
  ) });
2664
2687
  };
2665
2688
  const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywhere }) => {
2666
- const t = useT$1();
2689
+ const t = useT$3();
2667
2690
  return /* @__PURE__ */ jsxRuntime.jsx(
2668
2691
  designSystem.Flex,
2669
2692
  {
@@ -2731,6 +2754,768 @@ const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywh
2731
2754
  }
2732
2755
  );
2733
2756
  };
2757
+ const SIGN_IN_FILTER_OPTIONS = Object.freeze(["all", "succeeded", "failed", "signed-out"]);
2758
+ const ACTIVITY_ACTION_OPTIONS = Object.freeze([
2759
+ "all",
2760
+ "view",
2761
+ "create",
2762
+ "update",
2763
+ "publish",
2764
+ "unpublish",
2765
+ "discard",
2766
+ "delete",
2767
+ "clone"
2768
+ ]);
2769
+ const PERIOD_OPTIONS = Object.freeze(["1", "7", "30", "90", "all"]);
2770
+ const EVENT_PAGE_SIZE = 20;
2771
+ const MAX_EVENT_EXPORT_ROWS = 1e4;
2772
+ function periodStart(period, now = /* @__PURE__ */ new Date()) {
2773
+ const days = Number.parseInt(period, 10);
2774
+ if (!Number.isInteger(days) || days <= 0) return void 0;
2775
+ return new Date(now.getTime() - days * 24 * 60 * 60 * 1e3).toISOString();
2776
+ }
2777
+ function buildSignInParams(filters, now) {
2778
+ const params = {
2779
+ page: filters.page || 1,
2780
+ pageSize: filters.pageSize || EVENT_PAGE_SIZE,
2781
+ event: SIGN_IN_FILTER_OPTIONS.includes(filters.event) ? filters.event : "all"
2782
+ };
2783
+ if (filters.adminId) params.adminId = String(filters.adminId);
2784
+ const from = periodStart(filters.period || "all", now);
2785
+ if (from) params.from = from;
2786
+ return params;
2787
+ }
2788
+ function buildActivityParams(filters, now) {
2789
+ const params = {
2790
+ page: filters.page || 1,
2791
+ pageSize: filters.pageSize || EVENT_PAGE_SIZE,
2792
+ action: ACTIVITY_ACTION_OPTIONS.includes(filters.action) ? filters.action : "all"
2793
+ };
2794
+ if (filters.adminId) params.adminId = String(filters.adminId);
2795
+ if (filters.contentType && filters.contentType !== "all")
2796
+ params.contentType = filters.contentType;
2797
+ const from = periodStart(filters.period || "all", now);
2798
+ if (from) params.from = from;
2799
+ return params;
2800
+ }
2801
+ function toExportParams(params, cursor) {
2802
+ const { page: _page, pageSize: _pageSize, ...rest } = params;
2803
+ return cursor ? { ...rest, cursor } : rest;
2804
+ }
2805
+ const message = (messageId, defaultMessage) => ({ messageId, defaultMessage });
2806
+ const FAILURE_REASONS = Object.freeze({
2807
+ invalid_credentials: message(
2808
+ "adminPanel.activity.reason.invalidCredentials",
2809
+ "Wrong email or password"
2810
+ ),
2811
+ account_inactive: message("adminPanel.activity.reason.accountInactive", "Account is deactivated"),
2812
+ login_not_allowed: message("adminPanel.activity.reason.notAllowed", "Sign-in is not allowed"),
2813
+ rate_limited: message("adminPanel.activity.reason.rateLimited", "Too many attempts")
2814
+ });
2815
+ function getSignInEventPresentation(row) {
2816
+ switch (row?.event) {
2817
+ case "admin.sign-in":
2818
+ return {
2819
+ key: "sign-in",
2820
+ tone: "success",
2821
+ label: message("adminPanel.activity.event.signIn", "Signed in"),
2822
+ detail: row.reason === "registration" ? message("adminPanel.activity.reason.registration", "First sign-in after registration") : row.reason === "password_reset" ? message(
2823
+ "adminPanel.activity.reason.passwordReset",
2824
+ "Signed in after a password reset"
2825
+ ) : null
2826
+ };
2827
+ case "admin.sign-in.failed":
2828
+ return {
2829
+ key: "failed",
2830
+ tone: "warning",
2831
+ label: message("adminPanel.activity.event.failed", "Sign-in failed"),
2832
+ detail: FAILURE_REASONS[row.reason] || null
2833
+ };
2834
+ case "admin.lockout":
2835
+ return {
2836
+ key: "lockout",
2837
+ tone: "warning",
2838
+ label: message("adminPanel.activity.event.lockout", "Locked out"),
2839
+ detail: FAILURE_REASONS.rate_limited
2840
+ };
2841
+ case "admin.sign-out":
2842
+ return {
2843
+ key: "sign-out",
2844
+ tone: "neutral",
2845
+ label: message("adminPanel.activity.event.signOut", "Signed out"),
2846
+ detail: null
2847
+ };
2848
+ case "admin.session.revoked":
2849
+ return {
2850
+ key: "revoked",
2851
+ tone: "neutral",
2852
+ label: message("adminPanel.activity.event.revoked", "Signed out by an admin"),
2853
+ detail: row.scope === "one_browser" ? message("adminPanel.activity.scope.oneBrowser", "One browser") : message("adminPanel.activity.scope.everywhere", "Every browser")
2854
+ };
2855
+ default:
2856
+ return {
2857
+ key: "other",
2858
+ tone: "neutral",
2859
+ label: message("adminPanel.activity.event.other", "Security event"),
2860
+ detail: null
2861
+ };
2862
+ }
2863
+ }
2864
+ function getSessionStatePresentation(session) {
2865
+ switch (session?.state) {
2866
+ case "active":
2867
+ return {
2868
+ tone: "success",
2869
+ label: message("adminPanel.activity.session.active", "Still signed in")
2870
+ };
2871
+ case "signed-out":
2872
+ return {
2873
+ tone: "neutral",
2874
+ label: message("adminPanel.activity.session.signedOut", "Signed out")
2875
+ };
2876
+ case "ended":
2877
+ return {
2878
+ tone: "neutral",
2879
+ label: message("adminPanel.activity.session.ended", "Session ended")
2880
+ };
2881
+ default:
2882
+ return null;
2883
+ }
2884
+ }
2885
+ const ACTIVITY_ACTION_LABELS = Object.freeze({
2886
+ all: message("adminPanel.activity.action.all", "All actions"),
2887
+ view: message("adminPanel.activity.action.view", "Opened"),
2888
+ create: message("adminPanel.activity.action.create", "Created"),
2889
+ update: message("adminPanel.activity.action.update", "Edited"),
2890
+ publish: message("adminPanel.activity.action.publish", "Published"),
2891
+ unpublish: message("adminPanel.activity.action.unpublish", "Unpublished"),
2892
+ discard: message("adminPanel.activity.action.discard", "Discarded draft"),
2893
+ delete: message("adminPanel.activity.action.delete", "Deleted"),
2894
+ clone: message("adminPanel.activity.action.clone", "Duplicated")
2895
+ });
2896
+ function getActivityTone(action) {
2897
+ if (action === "publish") return "success";
2898
+ if (action === "delete") return "warning";
2899
+ return "neutral";
2900
+ }
2901
+ function getEntryPath(row) {
2902
+ const type = row?.contentType;
2903
+ if (!type?.exists || row.action === "delete") return null;
2904
+ const uid = encodeURIComponent(type.uid);
2905
+ const locale = row.entry?.locale ? `?plugins[i18n][locale]=${encodeURIComponent(row.entry.locale)}` : "";
2906
+ if (type.kind === "single") return `/content-manager/single-types/${uid}${locale}`;
2907
+ if (!row.entry?.documentId) return null;
2908
+ return `/content-manager/collection-types/${uid}/${encodeURIComponent(row.entry.documentId)}${locale}`;
2909
+ }
2910
+ const SIGN_IN_CSV_HEADERS = Object.freeze([
2911
+ "Time",
2912
+ "Event",
2913
+ "Reason",
2914
+ "Admin",
2915
+ "Admin ID",
2916
+ "IP Address",
2917
+ "IP Anonymized",
2918
+ "Country",
2919
+ "City",
2920
+ "Browser",
2921
+ "OS",
2922
+ "Device",
2923
+ "Session",
2924
+ "Signed Out By"
2925
+ ]);
2926
+ const ACTIVITY_CSV_HEADERS = Object.freeze([
2927
+ "Time",
2928
+ "Action",
2929
+ "Admin",
2930
+ "Admin ID",
2931
+ "Content Type",
2932
+ "Content Type UID",
2933
+ "Document ID",
2934
+ "Locale",
2935
+ "Title",
2936
+ "Entries"
2937
+ ]);
2938
+ const toCsv = (headers, rows) => [headers, ...rows].map((cells) => cells.map(escapeCsvValue).join(",")).join("\n");
2939
+ function buildSignInCsv(rows) {
2940
+ return toCsv(
2941
+ SIGN_IN_CSV_HEADERS,
2942
+ rows.map((row) => [
2943
+ row.at || "",
2944
+ row.event || "",
2945
+ row.reason || row.scope || "",
2946
+ row.admin?.name || "",
2947
+ row.admin?.id ?? "",
2948
+ row.ipAddress || "",
2949
+ row.ipAnonymized ? "yes" : "no",
2950
+ row.location?.country || "",
2951
+ row.location?.city || "",
2952
+ row.browser || "",
2953
+ row.os || "",
2954
+ row.deviceType || "",
2955
+ row.session?.state || "",
2956
+ row.actor?.name || ""
2957
+ ])
2958
+ );
2959
+ }
2960
+ function buildActivityCsv(rows) {
2961
+ return toCsv(
2962
+ ACTIVITY_CSV_HEADERS,
2963
+ rows.map((row) => [
2964
+ row.at || "",
2965
+ row.action || "",
2966
+ row.admin?.name || "",
2967
+ row.admin?.id ?? "",
2968
+ row.contentType?.name || "",
2969
+ row.contentType?.uid || "",
2970
+ row.entry?.documentId || "",
2971
+ row.entry?.locale || "",
2972
+ row.entry?.title || "",
2973
+ row.entry?.count ?? ""
2974
+ ])
2975
+ );
2976
+ }
2977
+ const useT$2 = () => {
2978
+ const { formatMessage } = reactIntl.useIntl();
2979
+ return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
2980
+ };
2981
+ const TargetTextButton = styled__default.default(designSystem.TextButton)`
2982
+ min-height: 3.2rem;
2983
+ `;
2984
+ const EventItem = ({ children, id, kind }) => /* @__PURE__ */ jsxRuntime.jsx(
2985
+ designSystem.Box,
2986
+ {
2987
+ tag: "li",
2988
+ background: "neutral0",
2989
+ borderColor: "neutral150",
2990
+ hasRadius: true,
2991
+ padding: 3,
2992
+ "data-event-row": kind,
2993
+ "data-event-id": id,
2994
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children })
2995
+ }
2996
+ );
2997
+ const AdminName = ({ admin, onOpenAdmin }) => {
2998
+ const t = useT$2();
2999
+ if (!admin) {
3000
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: t("adminPanel.activity.unknownAccount", "Unknown account") });
3001
+ }
3002
+ if (!onOpenAdmin) {
3003
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: admin.name });
3004
+ }
3005
+ return /* @__PURE__ */ jsxRuntime.jsx(
3006
+ TargetTextButton,
3007
+ {
3008
+ onClick: (event) => onOpenAdmin(admin, event.currentTarget),
3009
+ "aria-label": t("adminPanel.activity.openAdmin", "Open the details of {name}", {
3010
+ name: admin.name
3011
+ }),
3012
+ children: admin.name
3013
+ }
3014
+ );
3015
+ };
3016
+ const SignInEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
3017
+ const t = useT$2();
3018
+ const event = getSignInEventPresentation(row);
3019
+ const session = getSessionStatePresentation(row.session);
3020
+ const facts = [];
3021
+ if (row.ipAddress) {
3022
+ facts.push(
3023
+ row.ipAnonymized ? t("adminPanel.activity.ipAnonymized", "{ip} (anonymised)", { ip: row.ipAddress }) : row.ipAddress
3024
+ );
3025
+ }
3026
+ const place = [row.location?.city, row.location?.country].filter(Boolean).join(", ");
3027
+ if (place) facts.push(place);
3028
+ if (row.browser && row.os) {
3029
+ facts.push(
3030
+ t("adminPanel.activity.browserOnOs", "{browser} on {os}", {
3031
+ browser: row.browser,
3032
+ os: row.os
3033
+ })
3034
+ );
3035
+ } else if (row.browser || row.os) {
3036
+ facts.push(row.browser || row.os);
3037
+ }
3038
+ if (row.actor)
3039
+ facts.push(t("adminPanel.activity.byAdmin", "by {name}", { name: row.actor.name }));
3040
+ if (Number.isInteger(row.attempts) && row.attempts > 1) {
3041
+ facts.push(
3042
+ t(
3043
+ "adminPanel.activity.attempts",
3044
+ "{count, plural, one {# attempt} other {# attempts}} within 5 minutes",
3045
+ { count: row.attempts }
3046
+ )
3047
+ );
3048
+ }
3049
+ return /* @__PURE__ */ jsxRuntime.jsxs(EventItem, { id: row.id, kind: event.key, children: [
3050
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
3051
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
3052
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...index.getBadgeColors(event.tone), children: t(event.label.messageId, event.label.defaultMessage) }),
3053
+ showAdmin ? /* @__PURE__ */ jsxRuntime.jsx(AdminName, { admin: row.admin, onOpenAdmin }) : null,
3054
+ event.detail ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(event.detail.messageId, event.detail.defaultMessage) }) : null
3055
+ ] }),
3056
+ /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: row.at })
3057
+ ] }),
3058
+ facts.length ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: facts.join(" · ") }) : null,
3059
+ session ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
3060
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...index.getBadgeColors(session.tone), children: t(session.label.messageId, session.label.defaultMessage) }),
3061
+ row.session?.endedAt ? /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: row.session.endedAt }) : null
3062
+ ] }) : null
3063
+ ] });
3064
+ };
3065
+ const ActivityEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
3066
+ const t = useT$2();
3067
+ const label = ACTIVITY_ACTION_LABELS[row.action] || ACTIVITY_ACTION_LABELS.view;
3068
+ const path = getEntryPath(row);
3069
+ const entryName = row.entry?.count !== null && row.entry?.count !== void 0 ? t("adminPanel.activity.entries", "{count, plural, one {# entry} other {# entries}}", {
3070
+ count: row.entry.count
3071
+ }) : row.entry?.title || row.entry?.documentId || row.contentType?.name || "";
3072
+ const facts = [row.contentType?.name];
3073
+ if (row.entry?.locale) facts.push(row.entry.locale);
3074
+ return /* @__PURE__ */ jsxRuntime.jsxs(EventItem, { id: row.id, kind: row.action, children: [
3075
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
3076
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
3077
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...index.getBadgeColors(getActivityTone(row.action)), children: t(label.messageId, label.defaultMessage) }),
3078
+ showAdmin ? /* @__PURE__ */ jsxRuntime.jsx(AdminName, { admin: row.admin, onOpenAdmin }) : null
3079
+ ] }),
3080
+ /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: row.at })
3081
+ ] }),
3082
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { minWidth: 0, style: { overflowWrap: "anywhere" }, children: path ? /* @__PURE__ */ jsxRuntime.jsx(
3083
+ index.TargetLink,
3084
+ {
3085
+ tag: reactRouterDom.Link,
3086
+ to: path,
3087
+ "aria-label": t("adminPanel.activity.openEntry", "Open {entry} in the Content Manager", {
3088
+ entry: entryName
3089
+ }),
3090
+ children: entryName
3091
+ }
3092
+ ) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: entryName }) }),
3093
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: facts.filter(Boolean).join(" · ") })
3094
+ ] });
3095
+ };
3096
+ function useEventList({ path, params, logKey }) {
3097
+ const { get } = StrapiAdmin.useFetchClient();
3098
+ const { formatMessage } = reactIntl.useIntl();
3099
+ const fillNames = react.useCallback(
3100
+ (list) => list.map(
3101
+ (row) => withEventAdminNames(
3102
+ row,
3103
+ (id) => formatMessage(
3104
+ {
3105
+ id: index.getTranslation("adminPanel.identity.placeholder"),
3106
+ defaultMessage: "Admin #{id}"
3107
+ },
3108
+ { id }
3109
+ )
3110
+ )
3111
+ ),
3112
+ [formatMessage]
3113
+ );
3114
+ const [rows, setRows] = react.useState([]);
3115
+ const [meta, setMeta] = react.useState(null);
3116
+ const [page, setPage] = react.useState(1);
3117
+ const [loading, setLoading] = react.useState(true);
3118
+ const [loadingMore, setLoadingMore] = react.useState(false);
3119
+ const [error, setError] = react.useState(false);
3120
+ const requestRef = react.useRef(0);
3121
+ const key = JSON.stringify(params);
3122
+ const load = react.useCallback(
3123
+ async (nextPage) => {
3124
+ const requestId = requestRef.current + 1;
3125
+ requestRef.current = requestId;
3126
+ if (nextPage === 1) setLoading(true);
3127
+ else setLoadingMore(true);
3128
+ try {
3129
+ const response = await get(path, { params: { ...JSON.parse(key), page: nextPage } });
3130
+ if (requestId !== requestRef.current) return;
3131
+ const body = response?.data || {};
3132
+ const data = fillNames(Array.isArray(body.data) ? body.data : []);
3133
+ setRows((current) => nextPage === 1 ? data : [...current, ...data]);
3134
+ setMeta(body.meta || null);
3135
+ setPage(nextPage);
3136
+ setError(false);
3137
+ } catch (err) {
3138
+ if (requestId !== requestRef.current || index.isCancelledRequest(err)) return;
3139
+ setError(true);
3140
+ index.logSafeAdminError(logKey, err);
3141
+ } finally {
3142
+ if (requestId === requestRef.current) {
3143
+ setLoading(false);
3144
+ setLoadingMore(false);
3145
+ }
3146
+ }
3147
+ },
3148
+ [get, path, key, logKey, fillNames]
3149
+ );
3150
+ react.useEffect(() => {
3151
+ load(1);
3152
+ return () => {
3153
+ requestRef.current += 1;
3154
+ };
3155
+ }, [load]);
3156
+ const pagination = meta?.pagination;
3157
+ const hasMore = Boolean(pagination && page < pagination.pageCount);
3158
+ const exportAll = react.useCallback(async () => {
3159
+ const all = [];
3160
+ let cursor = null;
3161
+ do {
3162
+ const response = await get(`${path}/export`, {
3163
+ params: toExportParams(JSON.parse(key), cursor)
3164
+ });
3165
+ const body = response?.data || {};
3166
+ if (!Array.isArray(body.data)) throw new Error("Invalid export response");
3167
+ all.push(...fillNames(body.data));
3168
+ cursor = typeof body.meta?.nextCursor === "string" ? body.meta.nextCursor : null;
3169
+ } while (cursor && all.length < MAX_EVENT_EXPORT_ROWS);
3170
+ return {
3171
+ rows: all.slice(0, MAX_EVENT_EXPORT_ROWS),
3172
+ capped: all.length > MAX_EVENT_EXPORT_ROWS || Boolean(cursor)
3173
+ };
3174
+ }, [get, path, key, fillNames]);
3175
+ return {
3176
+ rows,
3177
+ meta,
3178
+ loading,
3179
+ loadingMore,
3180
+ error,
3181
+ hasMore,
3182
+ loadMore: () => load(page + 1),
3183
+ reload: () => load(1),
3184
+ exportAll
3185
+ };
3186
+ }
3187
+ function downloadCsv(content, name) {
3188
+ const blob = new Blob([content], { type: "text/csv;charset=utf-8;" });
3189
+ const url = URL.createObjectURL(blob);
3190
+ const link = document.createElement("a");
3191
+ link.href = url;
3192
+ link.download = `${name}-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`;
3193
+ link.click();
3194
+ window.setTimeout(() => URL.revokeObjectURL(url), 0);
3195
+ }
3196
+ const ADMIN_ACTIVITY_SETTINGS_PATH = `/settings/${index.pluginId}/general?tab=admin-activity`;
3197
+ const useT$1 = () => {
3198
+ const { formatMessage } = reactIntl.useIntl();
3199
+ return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
3200
+ };
3201
+ const PeriodSelect = ({ value, onChange }) => {
3202
+ const t = useT$1();
3203
+ const labels = {
3204
+ 1: t("adminPanel.activity.period.day", "Last 24 hours"),
3205
+ 7: t("adminPanel.activity.period.week", "Last 7 days"),
3206
+ 30: t("adminPanel.activity.period.month", "Last 30 days"),
3207
+ 90: t("adminPanel.activity.period.quarter", "Last 90 days"),
3208
+ all: t("adminPanel.activity.period.all", "All kept events")
3209
+ };
3210
+ return /* @__PURE__ */ jsxRuntime.jsx(
3211
+ designSystem.SingleSelect,
3212
+ {
3213
+ size: "S",
3214
+ "aria-label": t("adminPanel.activity.period.label", "Period"),
3215
+ value,
3216
+ onChange: (next) => onChange(String(next)),
3217
+ children: PERIOD_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: labels[option] }, option))
3218
+ }
3219
+ );
3220
+ };
3221
+ const FilterSlot = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", minWidth: 0, flex: "1 1 18rem", children });
3222
+ const EventList = ({
3223
+ filters,
3224
+ notice,
3225
+ list,
3226
+ listLabel,
3227
+ emptyText,
3228
+ renderRow,
3229
+ toCsv: toCsv2,
3230
+ fileName,
3231
+ exportLabel
3232
+ }) => {
3233
+ const t = useT$1();
3234
+ const { toggleNotification } = StrapiAdmin.useNotification();
3235
+ const [exporting, setExporting] = react.useState(false);
3236
+ const total = list.meta?.pagination?.total ?? 0;
3237
+ const handleExport = async () => {
3238
+ if (exporting) return;
3239
+ setExporting(true);
3240
+ try {
3241
+ const { rows, capped } = await list.exportAll();
3242
+ downloadCsv(toCsv2(rows), fileName);
3243
+ if (capped) {
3244
+ toggleNotification({
3245
+ type: "warning",
3246
+ message: t(
3247
+ "adminPanel.activity.export.capped",
3248
+ "The export contains the newest {limit, number} events. Narrow the filter to export the rest.",
3249
+ { limit: MAX_EVENT_EXPORT_ROWS }
3250
+ )
3251
+ });
3252
+ }
3253
+ } catch (err) {
3254
+ if (index.isCancelledRequest(err)) return;
3255
+ index.logSafeAdminError("adminPanel.activity.export", err);
3256
+ toggleNotification({
3257
+ type: "danger",
3258
+ message: t("adminPanel.activity.export.error", "The export could not be created.")
3259
+ });
3260
+ } finally {
3261
+ setExporting(false);
3262
+ }
3263
+ };
3264
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
3265
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
3266
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", flex: "1 1 auto", minWidth: 0, children: filters }),
3267
+ /* @__PURE__ */ jsxRuntime.jsx(
3268
+ designSystem.Button,
3269
+ {
3270
+ size: "S",
3271
+ variant: "tertiary",
3272
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
3273
+ onClick: handleExport,
3274
+ loading: exporting,
3275
+ disabled: list.loading || total === 0,
3276
+ "aria-label": exportLabel,
3277
+ children: t("adminPanel.activity.export.csv", "Export CSV")
3278
+ }
3279
+ )
3280
+ ] }),
3281
+ notice,
3282
+ list.loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("adminPanel.activity.loading", "Loading events") }) }) : null,
3283
+ !list.loading && list.error ? /* @__PURE__ */ jsxRuntime.jsx(
3284
+ index.PersistentAlert,
3285
+ {
3286
+ variant: "danger",
3287
+ action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: list.reload, children: t("common.tryAgain", "Try again") }),
3288
+ children: t("adminPanel.activity.error", "The events could not be loaded.")
3289
+ }
3290
+ ) : null,
3291
+ !list.loading && !list.error && list.rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", "data-event-empty": "", children: emptyText }) : null,
3292
+ list.rows.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
3293
+ designSystem.Flex,
3294
+ {
3295
+ tag: "ul",
3296
+ direction: "column",
3297
+ alignItems: "stretch",
3298
+ gap: 2,
3299
+ width: "100%",
3300
+ "aria-label": listLabel,
3301
+ children: list.rows.map((row) => renderRow(row))
3302
+ }
3303
+ ) : null,
3304
+ list.hasMore ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: list.loadMore, loading: list.loadingMore, children: t("adminPanel.activity.showMore", "Show more") }) }) : null
3305
+ ] });
3306
+ };
3307
+ const RecordingOff = ({ children }) => {
3308
+ const t = useT$1();
3309
+ return /* @__PURE__ */ jsxRuntime.jsx(
3310
+ index.PersistentAlert,
3311
+ {
3312
+ variant: "neutral",
3313
+ action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Link, { tag: reactRouterDom.Link, to: ADMIN_ACTIVITY_SETTINGS_PATH, children: t("adminPanel.activity.openSettings", "Open settings") }),
3314
+ children
3315
+ }
3316
+ );
3317
+ };
3318
+ const SignInHistoryPanel = ({ admin }) => {
3319
+ const t = useT$1();
3320
+ const [event, setEvent] = react.useState("all");
3321
+ const [period, setPeriod] = react.useState("30");
3322
+ const params = react.useMemo(
3323
+ () => buildSignInParams({ adminId: admin.id, event, period }),
3324
+ [admin.id, event, period]
3325
+ );
3326
+ const list = useEventList({
3327
+ path: `/${index.pluginId}/admin-activity/sign-ins`,
3328
+ params,
3329
+ logKey: "adminPanel.activity.signIns"
3330
+ });
3331
+ const recording = list.meta?.recording;
3332
+ const labels = {
3333
+ all: t("adminPanel.activity.filter.allEvents", "All events"),
3334
+ succeeded: t("adminPanel.activity.filter.succeeded", "Sign-ins"),
3335
+ failed: t("adminPanel.activity.filter.failed", "Failed and locked out"),
3336
+ "signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs")
3337
+ };
3338
+ return /* @__PURE__ */ jsxRuntime.jsx(
3339
+ EventList,
3340
+ {
3341
+ list,
3342
+ filters: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3343
+ /* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
3344
+ designSystem.SingleSelect,
3345
+ {
3346
+ size: "S",
3347
+ "aria-label": t("adminPanel.activity.filter.event", "Event"),
3348
+ value: event,
3349
+ onChange: (next) => setEvent(String(next)),
3350
+ children: SIGN_IN_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: labels[option] }, option))
3351
+ }
3352
+ ) }),
3353
+ /* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(PeriodSelect, { value: period, onChange: setPeriod }) })
3354
+ ] }),
3355
+ notice: recording && !recording.signIns ? /* @__PURE__ */ jsxRuntime.jsx(RecordingOff, { children: t(
3356
+ "adminPanel.activity.signIns.off",
3357
+ "Sign-in history is turned off. New sign-ins are not recorded."
3358
+ ) }) : null,
3359
+ listLabel: t("adminPanel.activity.signIns.listLabel", "Sign-in history of {name}", {
3360
+ name: admin.name
3361
+ }),
3362
+ emptyText: t("adminPanel.activity.signIns.empty", "No sign-in events in this period."),
3363
+ renderRow: (row) => /* @__PURE__ */ jsxRuntime.jsx(SignInEventRow, { row }, row.id),
3364
+ toCsv: buildSignInCsv,
3365
+ fileName: "admin-sign-in-history",
3366
+ exportLabel: t(
3367
+ "adminPanel.activity.signIns.export",
3368
+ "Export the sign-in history of {name} as CSV",
3369
+ {
3370
+ name: admin.name
3371
+ }
3372
+ )
3373
+ }
3374
+ );
3375
+ };
3376
+ const ContentActivityPanel = ({ admin }) => {
3377
+ const t = useT$1();
3378
+ const [action, setAction] = react.useState("all");
3379
+ const [contentType, setContentType] = react.useState("all");
3380
+ const [period, setPeriod] = react.useState("30");
3381
+ const params = react.useMemo(
3382
+ () => buildActivityParams({ adminId: admin.id, action, contentType, period }),
3383
+ [admin.id, action, contentType, period]
3384
+ );
3385
+ const list = useEventList({
3386
+ path: `/${index.pluginId}/admin-activity/content`,
3387
+ params,
3388
+ logKey: "adminPanel.activity.content"
3389
+ });
3390
+ const recording = list.meta?.recording;
3391
+ const types = Array.isArray(list.meta?.contentTypes) ? list.meta.contentTypes : [];
3392
+ const noAccess = list.meta?.contentManagerAccess === false;
3393
+ let notice = null;
3394
+ if (recording && !recording.contentActivity) {
3395
+ notice = /* @__PURE__ */ jsxRuntime.jsx(RecordingOff, { children: t(
3396
+ "adminPanel.activity.content.off",
3397
+ "Content Manager activity is not recorded. An admin can turn it on in the settings; inform your team first."
3398
+ ) });
3399
+ } else if (noAccess) {
3400
+ notice = /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "neutral", children: t(
3401
+ "adminPanel.activity.content.noAccess",
3402
+ "{name} has no Content Manager access, so there is no activity to show.",
3403
+ { name: admin.name }
3404
+ ) });
3405
+ }
3406
+ return /* @__PURE__ */ jsxRuntime.jsx(
3407
+ EventList,
3408
+ {
3409
+ list,
3410
+ filters: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3411
+ /* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
3412
+ designSystem.SingleSelect,
3413
+ {
3414
+ size: "S",
3415
+ "aria-label": t("adminPanel.activity.filter.action", "Action"),
3416
+ value: action,
3417
+ onChange: (next) => setAction(String(next)),
3418
+ children: ACTIVITY_ACTION_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: t(
3419
+ ACTIVITY_ACTION_LABELS[option].messageId,
3420
+ ACTIVITY_ACTION_LABELS[option].defaultMessage
3421
+ ) }, option))
3422
+ }
3423
+ ) }),
3424
+ /* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsxs(
3425
+ designSystem.SingleSelect,
3426
+ {
3427
+ size: "S",
3428
+ "aria-label": t("adminPanel.activity.filter.contentType", "Content type"),
3429
+ value: contentType,
3430
+ onChange: (next) => setContentType(String(next)),
3431
+ children: [
3432
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "all", children: t("adminPanel.activity.filter.allTypes", "All content types") }),
3433
+ types.map((type) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: type.uid, children: type.name }, type.uid))
3434
+ ]
3435
+ }
3436
+ ) }),
3437
+ /* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(PeriodSelect, { value: period, onChange: setPeriod }) })
3438
+ ] }),
3439
+ notice,
3440
+ listLabel: t("adminPanel.activity.content.listLabel", "Content Manager activity of {name}", {
3441
+ name: admin.name
3442
+ }),
3443
+ emptyText: t(
3444
+ "adminPanel.activity.content.empty",
3445
+ "No Content Manager activity in this period."
3446
+ ),
3447
+ renderRow: (row) => /* @__PURE__ */ jsxRuntime.jsx(ActivityEventRow, { row }, row.id),
3448
+ toCsv: buildActivityCsv,
3449
+ fileName: "admin-content-activity",
3450
+ exportLabel: t(
3451
+ "adminPanel.activity.content.export",
3452
+ "Export the Content Manager activity of {name} as CSV",
3453
+ { name: admin.name }
3454
+ )
3455
+ }
3456
+ );
3457
+ };
3458
+ const RecentSignInActivity = ({ onOpenAdmin }) => {
3459
+ const t = useT$1();
3460
+ const params = react.useMemo(() => buildSignInParams({ pageSize: 5 }), []);
3461
+ const list = useEventList({
3462
+ path: `/${index.pluginId}/admin-activity/sign-ins`,
3463
+ params,
3464
+ logKey: "adminPanel.activity.recent"
3465
+ });
3466
+ if (list.meta?.recording && !list.meta.recording.signIns) return null;
3467
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3468
+ SectionCard.SectionCard,
3469
+ {
3470
+ title: t("adminPanel.activity.recent.title", "Recent sign-in activity"),
3471
+ subtitle: t(
3472
+ "adminPanel.activity.recent.subtitle",
3473
+ "The latest sign-ins, failed attempts and sign-outs of all admins. Open an admin for their full history."
3474
+ ),
3475
+ children: [
3476
+ list.loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("adminPanel.activity.loading", "Loading events") }) }) : null,
3477
+ !list.loading && list.error ? /* @__PURE__ */ jsxRuntime.jsx(
3478
+ index.PersistentAlert,
3479
+ {
3480
+ variant: "danger",
3481
+ action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: list.reload, children: t("common.tryAgain", "Try again") }),
3482
+ children: t("adminPanel.activity.error", "The events could not be loaded.")
3483
+ }
3484
+ ) : null,
3485
+ !list.loading && !list.error && list.rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: t("adminPanel.activity.recent.empty", "No sign-in events yet.") }) : null,
3486
+ list.rows.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
3487
+ designSystem.Flex,
3488
+ {
3489
+ tag: "ul",
3490
+ direction: "column",
3491
+ alignItems: "stretch",
3492
+ gap: 2,
3493
+ width: "100%",
3494
+ "aria-label": t("adminPanel.activity.recent.title", "Recent sign-in activity"),
3495
+ children: list.rows.map((row) => /* @__PURE__ */ jsxRuntime.jsx(SignInEventRow, { row, showAdmin: true, onOpenAdmin }, row.id))
3496
+ }
3497
+ ) : null
3498
+ ]
3499
+ }
3500
+ );
3501
+ };
3502
+ const DialogTabsList = styled__default.default(designSystem.Tabs.List)`
3503
+ overflow-x: auto;
3504
+ overflow-y: hidden;
3505
+ max-width: 100%;
3506
+ `;
3507
+ const DialogTabTrigger = styled__default.default(designSystem.Tabs.Trigger)`
3508
+ && {
3509
+ flex: 0 0 auto;
3510
+ white-space: nowrap;
3511
+ }
3512
+ `;
3513
+ const DialogTabLabel = styled__default.default.span`
3514
+ text-transform: none;
3515
+ letter-spacing: normal;
3516
+ font-size: ${({ theme }) => theme.fontSizes[2]};
3517
+ `;
3518
+ const ADMIN_DIALOG_TABS = Object.freeze(["sessions", "history", "activity"]);
2734
3519
  const useT = () => {
2735
3520
  const { formatMessage } = reactIntl.useIntl();
2736
3521
  return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
@@ -2815,9 +3600,12 @@ const AdminSessionsModal = ({
2815
3600
  onSignOut,
2816
3601
  onSignOutEverywhere,
2817
3602
  onClose,
2818
- onCloseAutoFocus
3603
+ onCloseAutoFocus,
3604
+ canViewActivity = false,
3605
+ initialTab = "sessions"
2819
3606
  }) => {
2820
3607
  const t = useT();
3608
+ const [tab, setTab] = react.useState(ADMIN_DIALOG_TABS.includes(initialTab) ? initialTab : "sessions");
2821
3609
  const canSignOut = canRevoke && admin.account === "active" && !admin.protectedReason;
2822
3610
  const settingsPath = `/settings/users/${admin.id}`;
2823
3611
  let notice = null;
@@ -2832,70 +3620,80 @@ const AdminSessionsModal = ({
2832
3620
  "Only a Super Admin can sign out a Super Admin. This keeps at least one Super Admin able to work at all times."
2833
3621
  ) });
2834
3622
  }
3623
+ const sessionsContent = /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
3624
+ /* @__PURE__ */ jsxRuntime.jsx(
3625
+ index.PropertyList,
3626
+ {
3627
+ columns: 2,
3628
+ items: [
3629
+ {
3630
+ id: "email",
3631
+ label: t("adminPanel.dialog.email", "Email"),
3632
+ value: admin.identityHidden ? t("adminPanel.identity.emailHidden", "Email hidden (needs “Read” on Users)") : admin.email,
3633
+ kind: admin.identityHidden ? void 0 : "email"
3634
+ },
3635
+ {
3636
+ id: "roles",
3637
+ label: t("adminPanel.table.roles", "Roles"),
3638
+ render: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin })
3639
+ },
3640
+ {
3641
+ id: "status",
3642
+ label: t("adminPanel.table.status", "Status"),
3643
+ render: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin: { ...admin, sessionCount: sessions.length } }),
3644
+ fullWidth: true
3645
+ }
3646
+ ]
3647
+ }
3648
+ ),
3649
+ notice,
3650
+ 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,
3651
+ !loading && error ? /* @__PURE__ */ jsxRuntime.jsx(
3652
+ index.PersistentAlert,
3653
+ {
3654
+ variant: "danger",
3655
+ action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: onRetry, children: t("common.tryAgain", "Try again") }),
3656
+ children: t("adminPanel.dialog.error", "The sessions could not be loaded.")
3657
+ }
3658
+ ) : null,
3659
+ !loading && !error && admin.account === "active" && sessions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", "data-admin-sessions-empty": "", children: t(
3660
+ "adminPanel.dialog.empty",
3661
+ "{name} is not signed in. Sessions appear here after the next sign-in.",
3662
+ { name: admin.name }
3663
+ ) }) : null,
3664
+ !loading && sessions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
3665
+ designSystem.Flex,
3666
+ {
3667
+ tag: "ul",
3668
+ direction: "column",
3669
+ alignItems: "stretch",
3670
+ gap: 3,
3671
+ "aria-label": t("adminPanel.dialog.listLabel", "Signed-in browsers"),
3672
+ children: sessions.map((session) => /* @__PURE__ */ jsxRuntime.jsx(
3673
+ SessionCard,
3674
+ {
3675
+ session,
3676
+ admin,
3677
+ canSignOut,
3678
+ onSignOut
3679
+ },
3680
+ session.id
3681
+ ))
3682
+ }
3683
+ ) : null
3684
+ ] });
2835
3685
  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: [
2836
- /* @__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 }) }) }),
2837
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
2838
- /* @__PURE__ */ jsxRuntime.jsx(
2839
- index.PropertyList,
2840
- {
2841
- columns: 2,
2842
- items: [
2843
- {
2844
- id: "email",
2845
- label: t("adminPanel.dialog.email", "Email"),
2846
- value: admin.email,
2847
- kind: "email"
2848
- },
2849
- {
2850
- id: "roles",
2851
- label: t("adminPanel.table.roles", "Roles"),
2852
- render: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin })
2853
- },
2854
- {
2855
- id: "status",
2856
- label: t("adminPanel.table.status", "Status"),
2857
- render: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin: { ...admin, sessionCount: sessions.length } }),
2858
- fullWidth: true
2859
- }
2860
- ]
2861
- }
2862
- ),
2863
- notice,
2864
- 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,
2865
- !loading && error ? /* @__PURE__ */ jsxRuntime.jsx(
2866
- index.PersistentAlert,
2867
- {
2868
- variant: "danger",
2869
- action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: onRetry, children: t("common.tryAgain", "Try again") }),
2870
- children: t("adminPanel.dialog.error", "The sessions could not be loaded.")
2871
- }
2872
- ) : null,
2873
- !loading && !error && admin.account === "active" && sessions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", "data-admin-sessions-empty": "", children: t(
2874
- "adminPanel.dialog.empty",
2875
- "{name} is not signed in. Sessions appear here after the next sign-in.",
2876
- { name: admin.name }
2877
- ) }) : null,
2878
- !loading && sessions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
2879
- designSystem.Flex,
2880
- {
2881
- tag: "ul",
2882
- direction: "column",
2883
- alignItems: "stretch",
2884
- gap: 3,
2885
- "aria-label": t("adminPanel.dialog.listLabel", "Signed-in browsers"),
2886
- children: sessions.map((session) => /* @__PURE__ */ jsxRuntime.jsx(
2887
- SessionCard,
2888
- {
2889
- session,
2890
- admin,
2891
- canSignOut,
2892
- onSignOut
2893
- },
2894
- session.id
2895
- ))
2896
- }
2897
- ) : null
2898
- ] }) }),
3686
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: canViewActivity ? admin.name : t("adminPanel.dialog.title", "Sessions of {name}", { name: admin.name }) }) }),
3687
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: canViewActivity ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.Root, { variant: "simple", value: tab, onValueChange: setTab, children: [
3688
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogTabsList, { "aria-label": t("adminPanel.dialog.tabs", "Admin details"), children: [
3689
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTabTrigger, { value: "sessions", children: /* @__PURE__ */ jsxRuntime.jsx(DialogTabLabel, { children: t("adminPanel.dialog.tab.sessions", "Sessions") }) }),
3690
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTabTrigger, { value: "history", children: /* @__PURE__ */ jsxRuntime.jsx(DialogTabLabel, { children: t("adminPanel.dialog.tab.history", "Sign-in history") }) }),
3691
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTabTrigger, { value: "activity", children: /* @__PURE__ */ jsxRuntime.jsx(DialogTabLabel, { children: t("adminPanel.dialog.tab.activity", "Activity") }) })
3692
+ ] }),
3693
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "sessions", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: sessionsContent }) }),
3694
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "history", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(SignInHistoryPanel, { admin }) }) }),
3695
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "activity", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ContentActivityPanel, { admin }) }) })
3696
+ ] }) : sessionsContent }),
2899
3697
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", justifyContent: "space-between", width: "100%", children: [
2900
3698
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: t("common.close", "Close") }) }),
2901
3699
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", children: [
@@ -2940,12 +3738,16 @@ const AdminPanelPage = () => {
2940
3738
  const {
2941
3739
  allowedActions: { canRevoke }
2942
3740
  } = StrapiAdmin.useRBAC(index.pluginPermissions.adminSessionsRevoke);
3741
+ const {
3742
+ allowedActions: { canRead: canViewActivity }
3743
+ } = StrapiAdmin.useRBAC(index.pluginPermissions.adminActivityRead);
2943
3744
  const [admins, setAdmins] = react.useState([]);
2944
3745
  const [meta, setMeta] = react.useState(null);
2945
3746
  const [loading, setLoading] = react.useState(true);
2946
3747
  const [refreshing, setRefreshing] = react.useState(false);
2947
3748
  const [loadError, setLoadError] = react.useState(false);
2948
3749
  const [selected, setSelected] = react.useState(null);
3750
+ const [dialogTab, setDialogTab] = react.useState("sessions");
2949
3751
  const [dialogSessions, setDialogSessions] = react.useState([]);
2950
3752
  const [dialogLoading, setDialogLoading] = react.useState(false);
2951
3753
  const [dialogError, setDialogError] = react.useState(false);
@@ -2976,7 +3778,15 @@ const AdminPanelPage = () => {
2976
3778
  const response = await get(`/${index.pluginId}/admin-sessions/admins`, { params: listParams });
2977
3779
  if (requestId !== requestIdRef.current) return;
2978
3780
  const body = response?.data || {};
2979
- setAdmins(Array.isArray(body.data) ? body.data : []);
3781
+ const placeholder = (id) => formatMessage(
3782
+ { id: index.getTranslation("adminPanel.identity.placeholder"), defaultMessage: "Admin #{id}" },
3783
+ { id }
3784
+ );
3785
+ setAdmins(
3786
+ (Array.isArray(body.data) ? body.data : []).map(
3787
+ (row) => withIdentityPlaceholders(row, placeholder, body.meta?.identity)
3788
+ )
3789
+ );
2980
3790
  setMeta(body.meta || null);
2981
3791
  setLoadError(false);
2982
3792
  hasLoadedRef.current = true;
@@ -2990,7 +3800,7 @@ const AdminPanelPage = () => {
2990
3800
  setRefreshing(false);
2991
3801
  }
2992
3802
  }
2993
- }, [get, listParams]);
3803
+ }, [get, listParams, formatMessage]);
2994
3804
  react.useEffect(() => {
2995
3805
  fetchAdmins();
2996
3806
  }, [fetchAdmins]);
@@ -3004,7 +3814,20 @@ const AdminPanelPage = () => {
3004
3814
  if (requestId !== dialogRequestRef.current) return;
3005
3815
  const body = response?.data || {};
3006
3816
  setDialogSessions(Array.isArray(body.data) ? body.data : []);
3007
- if (body.meta?.admin) setSelected((current) => current ? body.meta.admin : current);
3817
+ if (body.meta?.admin) {
3818
+ const placeholder = (id) => formatMessage(
3819
+ {
3820
+ id: index.getTranslation("adminPanel.identity.placeholder"),
3821
+ defaultMessage: "Admin #{id}"
3822
+ },
3823
+ { id }
3824
+ );
3825
+ setSelected(
3826
+ (current) => current ? withIdentityPlaceholders(body.meta.admin, placeholder, {
3827
+ roles: current.rolesHidden ? false : void 0
3828
+ }) : current
3829
+ );
3830
+ }
3008
3831
  setDialogError(false);
3009
3832
  } catch (err) {
3010
3833
  if (requestId !== dialogRequestRef.current || index.isCancelledRequest(err)) return;
@@ -3014,10 +3837,11 @@ const AdminPanelPage = () => {
3014
3837
  if (requestId === dialogRequestRef.current) setDialogLoading(false);
3015
3838
  }
3016
3839
  },
3017
- [get]
3840
+ [get, formatMessage]
3018
3841
  );
3019
- const openDialog = (admin, trigger) => {
3842
+ const openDialog = (admin, trigger, tab = "sessions") => {
3020
3843
  openerRef.current = trigger;
3844
+ setDialogTab(tab);
3021
3845
  setSelected(admin);
3022
3846
  setDialogSessions([]);
3023
3847
  setDialogError(false);
@@ -3080,10 +3904,10 @@ const AdminPanelPage = () => {
3080
3904
  await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
3081
3905
  } catch (err) {
3082
3906
  index.logSafeAdminError("adminPanel.signOut", err);
3083
- const message = getSignOutErrorMessage(err);
3907
+ const message2 = getSignOutErrorMessage(err);
3084
3908
  toggleNotification({
3085
3909
  type: getErrorStatus(err) === 404 ? "warning" : "danger",
3086
- message: t(message.messageId, message.defaultMessage)
3910
+ message: t(message2.messageId, message2.defaultMessage)
3087
3911
  });
3088
3912
  if (getErrorStatus(err) === 404) {
3089
3913
  await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
@@ -3150,6 +3974,7 @@ const AdminPanelPage = () => {
3150
3974
  busy: refreshing
3151
3975
  };
3152
3976
  const policy = meta?.policy;
3977
+ const recording = meta?.recording;
3153
3978
  const range = pagination.total > 0 ? {
3154
3979
  from: (pagination.page - 1) * pagination.pageSize + 1,
3155
3980
  to: Math.min(pagination.page * pagination.pageSize, pagination.total)
@@ -3250,10 +4075,23 @@ const AdminPanelPage = () => {
3250
4075
  stacked: true,
3251
4076
  title: t("adminPanel.howItWorks.title", "How signing out works"),
3252
4077
  children: [
3253
- /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: t(
3254
- "adminPanel.howItWorks.body",
3255
- "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."
3256
- ) }),
4078
+ /* @__PURE__ */ jsxRuntime.jsxs(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: [
4079
+ t(
4080
+ "adminPanel.howItWorks.body",
4081
+ "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."
4082
+ ),
4083
+ " ",
4084
+ recording?.ipAddresses ? t(
4085
+ "adminPanel.howItWorks.recorded",
4086
+ "Session Manager records every sign-in with time, browser and IP address in the sign-in history."
4087
+ ) : recording?.signIns ? t(
4088
+ "adminPanel.howItWorks.recordedNoIp",
4089
+ "Session Manager records every sign-in with time and browser in the sign-in history, without IP addresses."
4090
+ ) : t(
4091
+ "adminPanel.howItWorks.notRecorded",
4092
+ "Sign-in history is turned off, so no IP addresses of admins are recorded."
4093
+ )
4094
+ ] }),
3257
4095
  policy ? /* @__PURE__ */ jsxRuntime.jsxs(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: [
3258
4096
  " ",
3259
4097
  t(
@@ -3284,7 +4122,7 @@ const AdminPanelPage = () => {
3284
4122
  value: view.search,
3285
4123
  onSearch: handleSearch,
3286
4124
  label: t("adminPanel.search.label", "Search admins"),
3287
- placeholder: t("adminPanel.search.placeholder", "Search name or email")
4125
+ placeholder: meta?.identity?.names === false ? t("adminPanel.search.placeholderId", "Search by admin ID") : t("adminPanel.search.placeholder", "Search name or email")
3288
4126
  }
3289
4127
  ) }),
3290
4128
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", shrink: 0, children: [
@@ -3366,9 +4204,17 @@ const AdminPanelPage = () => {
3366
4204
  }
3367
4205
  )
3368
4206
  ] }) : null,
4207
+ showData && canViewActivity ? /* @__PURE__ */ jsxRuntime.jsx(
4208
+ RecentSignInActivity,
4209
+ {
4210
+ onOpenAdmin: (admin, trigger) => openDialog(admin, trigger, "history")
4211
+ }
4212
+ ) : null,
3369
4213
  selected ? /* @__PURE__ */ jsxRuntime.jsx(
3370
4214
  AdminSessionsModal,
3371
4215
  {
4216
+ canViewActivity: Boolean(canViewActivity),
4217
+ initialTab: dialogTab,
3372
4218
  admin: selected,
3373
4219
  sessions: dialogSessions,
3374
4220
  loading: dialogLoading && dialogSessions.length === 0,
@@ -3379,7 +4225,8 @@ const AdminPanelPage = () => {
3379
4225
  onSignOutEverywhere: (trigger) => askSignOut(selected, null, trigger),
3380
4226
  onClose: closeDialog,
3381
4227
  onCloseAutoFocus: (event) => index.restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
3382
- }
4228
+ },
4229
+ `${selected.id}-${dialogTab}`
3383
4230
  ) : null,
3384
4231
  confirm ? /* @__PURE__ */ jsxRuntime.jsx(
3385
4232
  index.ConfirmAction,