strapi-plugin-magic-sessionmanager 4.18.0 → 4.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +37 -35
  3. package/dist/admin/{Analytics-C8fV6LDV.js → Analytics-AzG-hPvn.js} +1 -1
  4. package/dist/admin/{Analytics-CBspdl1I.mjs → Analytics-DSXe9BPn.mjs} +1 -1
  5. package/dist/admin/{App-PLwqaRSQ.mjs → App-7UDfLwMK.mjs} +1132 -163
  6. package/dist/admin/{App-D92MTQmn.js → App-D08oGxy4.js} +1129 -160
  7. package/dist/admin/{OnlineUsersWidget-CiKapC1B.js → OnlineUsersWidget-CK0_o7Jk.js} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-CwfBJdIX.mjs → OnlineUsersWidget-DIhJZ77w.mjs} +1 -1
  9. package/dist/admin/{Settings-CMgL-Aub.mjs → Settings-CneNJppG.mjs} +2 -2
  10. package/dist/admin/{Settings-Duil_4jv.js → Settings-DnNBDP1I.js} +2 -2
  11. package/dist/admin/{dashboardModel-sksvIc1c.js → dashboardModel-CjU0V7Sx.js} +1 -1
  12. package/dist/admin/{dashboardModel-BhUonEqc.mjs → dashboardModel-OyQ_39aF.mjs} +1 -1
  13. package/dist/admin/{de-CnInuvMY.js → de-CJZtJdhC.js} +65 -4
  14. package/dist/admin/{de-D2BqfY1f.mjs → de-DvYUwhjB.mjs} +65 -4
  15. package/dist/admin/{en-BPy208we.mjs → en-B8m9k-qd.mjs} +65 -4
  16. package/dist/admin/{en-KnmmYHTF.js → en-BZ2YkNIU.js} +65 -4
  17. package/dist/admin/{es-D1NGCAJK.js → es-BBsMtof1.js} +65 -4
  18. package/dist/admin/{es-B4VNeT0A.mjs → es-DBH36rrX.mjs} +65 -4
  19. package/dist/admin/{fr-AwhLN1BC.mjs → fr-CLvB1rGe.mjs} +65 -4
  20. package/dist/admin/{fr-D1KNyogi.js → fr-Cw6nc38j.js} +65 -4
  21. package/dist/admin/{index-BmnC2BPs.mjs → index-5Zb3GVml.mjs} +9 -9
  22. package/dist/admin/{index-Bnt0Jq6O.js → index-BSUrdxxt.js} +9 -9
  23. package/dist/admin/index.js +1 -1
  24. package/dist/admin/index.mjs +1 -1
  25. package/dist/admin/{pt-D6m1TijL.mjs → pt-CVht14if.mjs} +65 -4
  26. package/dist/admin/{pt-EKThRXPY.js → pt-CjnMe7Z-.js} +65 -4
  27. package/dist/server/index.js +41 -8
  28. package/dist/server/index.mjs +41 -8
  29. package/package.json +1 -1
@@ -1,15 +1,14 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useFetchClient, useNotification, useClipboard, useRBAC, useQueryParams, Pagination, Page } from "@strapi/strapi/admin";
2
+ import { useFetchClient, useNotification, useClipboard, useRBAC, useQueryParams, Pagination, BackButton, Page } from "@strapi/strapi/admin";
3
3
  import { NavLink, Link as Link$1, Routes, Route } from "react-router-dom";
4
4
  import { useMemo, useState, useEffect, useRef, useId, useCallback, 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, Tabs, Dialog } from "@strapi/design-system";
7
- import { Earth, Duplicate, Cross, Eye, Trash, More, CaretDown, Download, ArrowClockwise, Check, Clock, User, ChartBubble, Cog, SignOut } from "@strapi/icons";
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, Tag } from "@strapi/design-system";
7
+ import { Earth, Duplicate, Cross, Eye, Trash, More, CaretDown, Download, ArrowClockwise, Check, Clock, User, ChartBubble, Cog, SignOut, Information, Webhooks, WarningCircle, Monitor, Key, Stack, Lock, CrossCircle, Shield, CheckCircle, ArrowRight } 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, u as useSessionFormatters, c as getSessionStatus, d as getDevicePresentation, i as isNativeOnlySession, e as getSessionEndReasonPresentation, D as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, f as pluginId, l as logSafeAdminError, h as PersistentAlert, R as ReadableText, j as pluginPermissions, M as MissingValue, V as ValueOrMissing, k as SESSION_STATES, m as SESSION_STATUS_PRESENTATION, n as isCancelledRequest, o as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, q as PageShell, r as StatGrid, s as StatCard, v as restoreDialogFocus, w as requireSessionList, x as getBadgeColors, T as TargetLink$1 } from "./index-BmnC2BPs.mjs";
11
- import { i as isRiskSource, g as getSessionUserLabels, a as getUserEditPath, R as RISK_SETTINGS_PATH, b as RowActions, s as shouldIsolateActionKey, c as shouldRedispatchEscape, D as DASHBOARD_COMPACT_TABLE_COLUMNS, d as DASHBOARD_TABLE_COLUMNS, r as readDisclosureOpen, e as getBrowserStorage, w as writeDisclosureOpen, u as useElementWidth, p as parseDashboardQuery, A as AUTO_REFRESH_INTERVAL_MS, f as pickFocusSessionId, h as encodeSearchQuery, j as shouldUseCompactTable, P as PAGE_SIZE_OPTIONS, k as DEFAULT_PAGE_SIZE, l as getExportDeviceInfo, m as getErrorStatus, n as hasActiveFilters } from "./dashboardModel-BhUonEqc.mjs";
12
- import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
10
+ import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, u as useSessionFormatters, c as getSessionStatus, d as getDevicePresentation, i as isNativeOnlySession, e as getSessionEndReasonPresentation, D as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, f as pluginId, l as logSafeAdminError, h as PersistentAlert, R as ReadableText, j as pluginPermissions, M as MissingValue, V as ValueOrMissing, k as SESSION_STATES, m as SESSION_STATUS_PRESENTATION, n as isCancelledRequest, o as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, q as PageShell, r as StatGrid, s as StatCard, v as restoreDialogFocus, w as requireSessionList, x as getBadgeColors, T as TargetLink$1 } from "./index-5Zb3GVml.mjs";
11
+ import { i as isRiskSource, g as getSessionUserLabels, a as getUserEditPath, R as RISK_SETTINGS_PATH, b as RowActions, s as shouldIsolateActionKey, c as shouldRedispatchEscape, D as DASHBOARD_COMPACT_TABLE_COLUMNS, d as DASHBOARD_TABLE_COLUMNS, r as readDisclosureOpen, e as getBrowserStorage, w as writeDisclosureOpen, u as useElementWidth, p as parseDashboardQuery, A as AUTO_REFRESH_INTERVAL_MS, f as pickFocusSessionId, h as encodeSearchQuery, j as shouldUseCompactTable, P as PAGE_SIZE_OPTIONS, k as DEFAULT_PAGE_SIZE, l as getExportDeviceInfo, m as getErrorStatus, n as hasActiveFilters } from "./dashboardModel-OyQ_39aF.mjs";
13
12
  const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
14
13
  const { formatMessage } = useIntl();
15
14
  const key = reason || getSessionEndReason(session);
@@ -1674,7 +1673,7 @@ const UntrackedSessionsNotice = ({ stats, onChanged, fallbackFocusRef }) => {
1674
1673
  const CLOCK_TICK_MS = 30 * 1e3;
1675
1674
  const ANALYTICS_PATH = `/settings/${pluginId}/analytics`;
1676
1675
  const CONFIGURATION_PATH = `/settings/${pluginId}/general`;
1677
- const PaginationTargets$1 = styled.div`
1676
+ const PaginationTargets$2 = styled.div`
1678
1677
  nav a {
1679
1678
  min-width: 3.2rem;
1680
1679
  }
@@ -2244,7 +2243,7 @@ const HomePage = () => {
2244
2243
  compact: shouldUseCompactTable(listWidth, isBelowLarge)
2245
2244
  }
2246
2245
  ),
2247
- /* @__PURE__ */ jsx(PaginationTargets$1, { children: /* @__PURE__ */ jsxs(
2246
+ /* @__PURE__ */ jsx(PaginationTargets$2, { children: /* @__PURE__ */ jsxs(
2248
2247
  Pagination.Root,
2249
2248
  {
2250
2249
  pageCount: pageResult.pageCount,
@@ -2445,12 +2444,12 @@ const keepActionKeys = (event) => {
2445
2444
  };
2446
2445
  const SHRINKING_ADMIN_CELL = { maxWidth: 0, width: "34%" };
2447
2446
  const SHRINKING_ROLES_CELL = { maxWidth: 0, width: "22%" };
2448
- const useT$3 = () => {
2447
+ const useT$4 = () => {
2449
2448
  const { formatMessage } = useIntl();
2450
2449
  return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
2451
2450
  };
2452
2451
  const AdminIdentity = ({ admin }) => {
2453
- const t = useT$3();
2452
+ const t = useT$4();
2454
2453
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children: [
2455
2454
  /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
2456
2455
  /* @__PURE__ */ jsx(
@@ -2470,13 +2469,13 @@ const AdminIdentity = ({ admin }) => {
2470
2469
  ] });
2471
2470
  };
2472
2471
  const AdminRoles = ({ admin }) => {
2473
- const t = useT$3();
2472
+ const t = useT$4();
2474
2473
  const names = (admin.roles || []).map((role) => role.name).filter(Boolean);
2475
2474
  const text = admin.rolesHidden ? t("adminPanel.roles.hidden", "Hidden (needs “Read” on Roles)") : names.length ? names.join(", ") : t("adminPanel.roles.none", "No role");
2476
2475
  return /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", ellipsis: true, title: text, children: text });
2477
2476
  };
2478
2477
  const AdminStatus = ({ admin }) => {
2479
- const t = useT$3();
2478
+ const t = useT$4();
2480
2479
  const status = getAdminStatusPresentation(admin);
2481
2480
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-admin-status": status.key, children: [
2482
2481
  /* @__PURE__ */ jsx(Badge, { ...getBadgeColors(status.tone), children: t(status.label.messageId, status.label.defaultMessage) }),
@@ -2491,7 +2490,7 @@ const AdminTable = ({
2491
2490
  onSignOutEverywhere,
2492
2491
  busy
2493
2492
  }) => {
2494
- const t = useT$3();
2493
+ const t = useT$4();
2495
2494
  return /* @__PURE__ */ jsx(Box, { background: "neutral0", hasRadius: true, shadow: "tableShadow", "data-admin-table": "", children: /* @__PURE__ */ jsxs(
2496
2495
  Table,
2497
2496
  {
@@ -2545,7 +2544,7 @@ const AdminTable = ({
2545
2544
  ) });
2546
2545
  };
2547
2546
  const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywhere }) => {
2548
- const t = useT$3();
2547
+ const t = useT$4();
2549
2548
  return /* @__PURE__ */ jsx(
2550
2549
  Flex,
2551
2550
  {
@@ -2614,6 +2613,7 @@ const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywh
2614
2613
  );
2615
2614
  };
2616
2615
  const SIGN_IN_FILTER_OPTIONS = Object.freeze(["all", "succeeded", "failed", "signed-out"]);
2616
+ const ALL_ADMINS_FILTER_OPTIONS = Object.freeze([...SIGN_IN_FILTER_OPTIONS, "changes"]);
2617
2617
  const ACTIVITY_ACTION_OPTIONS = Object.freeze([
2618
2618
  "all",
2619
2619
  "view",
@@ -2637,7 +2637,7 @@ function buildSignInParams(filters, now) {
2637
2637
  const params = {
2638
2638
  page: filters.page || 1,
2639
2639
  pageSize: filters.pageSize || EVENT_PAGE_SIZE,
2640
- event: SIGN_IN_FILTER_OPTIONS.includes(filters.event) ? filters.event : "all"
2640
+ event: ALL_ADMINS_FILTER_OPTIONS.includes(filters.event) ? filters.event : "all"
2641
2641
  };
2642
2642
  if (filters.adminId) params.adminId = String(filters.adminId);
2643
2643
  const from = periodStart(filters.period || "all", now);
@@ -2671,12 +2671,20 @@ const FAILURE_REASONS = Object.freeze({
2671
2671
  login_not_allowed: message("adminPanel.activity.reason.notAllowed", "Sign-in is not allowed"),
2672
2672
  rate_limited: message("adminPanel.activity.reason.rateLimited", "Too many attempts")
2673
2673
  });
2674
+ const appUserEvent = (key, tone, icon, messageId, defaultMessage) => ({
2675
+ key,
2676
+ tone,
2677
+ icon,
2678
+ label: message(messageId, defaultMessage),
2679
+ detail: null
2680
+ });
2674
2681
  function getSignInEventPresentation(row) {
2675
2682
  switch (row?.event) {
2676
2683
  case "admin.sign-in":
2677
2684
  return {
2678
2685
  key: "sign-in",
2679
2686
  tone: "success",
2687
+ icon: "signIn",
2680
2688
  label: message("adminPanel.activity.event.signIn", "Signed in"),
2681
2689
  detail: row.reason === "registration" ? message("adminPanel.activity.reason.registration", "First sign-in after registration") : row.reason === "password_reset" ? message(
2682
2690
  "adminPanel.activity.reason.passwordReset",
@@ -2686,14 +2694,16 @@ function getSignInEventPresentation(row) {
2686
2694
  case "admin.sign-in.failed":
2687
2695
  return {
2688
2696
  key: "failed",
2689
- tone: "warning",
2697
+ tone: "danger",
2698
+ icon: "failed",
2690
2699
  label: message("adminPanel.activity.event.failed", "Sign-in failed"),
2691
2700
  detail: FAILURE_REASONS[row.reason] || null
2692
2701
  };
2693
2702
  case "admin.lockout":
2694
2703
  return {
2695
2704
  key: "lockout",
2696
- tone: "warning",
2705
+ tone: "danger",
2706
+ icon: "lockout",
2697
2707
  label: message("adminPanel.activity.event.lockout", "Locked out"),
2698
2708
  detail: FAILURE_REASONS.rate_limited
2699
2709
  };
@@ -2701,20 +2711,150 @@ function getSignInEventPresentation(row) {
2701
2711
  return {
2702
2712
  key: "sign-out",
2703
2713
  tone: "neutral",
2714
+ icon: "signOut",
2704
2715
  label: message("adminPanel.activity.event.signOut", "Signed out"),
2705
2716
  detail: null
2706
2717
  };
2707
2718
  case "admin.session.revoked":
2708
2719
  return {
2709
2720
  key: "revoked",
2710
- tone: "neutral",
2721
+ tone: "warning",
2722
+ icon: "revoked",
2711
2723
  label: message("adminPanel.activity.event.revoked", "Signed out by an admin"),
2712
2724
  detail: row.scope === "one_browser" ? message("adminPanel.activity.scope.oneBrowser", "One browser") : message("adminPanel.activity.scope.everywhere", "Every browser")
2713
2725
  };
2726
+ case "settings.updated":
2727
+ return {
2728
+ key: "settings",
2729
+ tone: "secondary",
2730
+ icon: "settings",
2731
+ label: message("adminPanel.activity.event.settings", "Settings changed"),
2732
+ detail: row.change?.viaToken ? message("adminPanel.activity.via.token", "With an admin API token") : null
2733
+ };
2734
+ case "security-log.read":
2735
+ return {
2736
+ key: "log-read",
2737
+ tone: "secondary",
2738
+ icon: "logRead",
2739
+ label: message("adminPanel.activity.event.logRead", "Log read with an API token"),
2740
+ detail: row.read?.list === "content" ? row.read?.exported ? message(
2741
+ "adminPanel.activity.read.contentExport",
2742
+ "Content Manager activity exported"
2743
+ ) : message("adminPanel.activity.read.content", "Content Manager activity listed") : row.read?.exported ? message("adminPanel.activity.read.signInsExport", "Sign-in history exported") : message("adminPanel.activity.read.signIns", "Sign-in history listed")
2744
+ };
2745
+ case "security-log.retention.purged":
2746
+ return {
2747
+ key: "purged",
2748
+ tone: "neutral",
2749
+ icon: "purged",
2750
+ label: message("adminPanel.activity.event.purged", "Old events deleted"),
2751
+ detail: null
2752
+ };
2753
+ // App-user events (4.17 / 4.18). The admin lists of this view do not return them
2754
+ // today; they get their own label and colour so any list that does shows them clearly.
2755
+ case "user.sign-in.failed":
2756
+ return appUserEvent(
2757
+ "user-failed",
2758
+ "danger",
2759
+ "failed",
2760
+ "adminPanel.activity.event.userFailed",
2761
+ "App user sign-in failed"
2762
+ );
2763
+ case "user.sign-in.refused":
2764
+ return appUserEvent(
2765
+ "user-refused",
2766
+ "danger",
2767
+ "refused",
2768
+ "adminPanel.activity.event.userRefused",
2769
+ "App user sign-in refused"
2770
+ );
2771
+ case "user.lockout":
2772
+ return appUserEvent(
2773
+ "user-lockout",
2774
+ "danger",
2775
+ "lockout",
2776
+ "adminPanel.activity.event.userLockout",
2777
+ "App user locked out"
2778
+ );
2779
+ case "user.lockout.lifted":
2780
+ return appUserEvent(
2781
+ "user-unlock",
2782
+ "secondary",
2783
+ "unlock",
2784
+ "adminPanel.activity.event.userUnlock",
2785
+ "Lockout lifted"
2786
+ );
2787
+ case "user.session.limit":
2788
+ return appUserEvent(
2789
+ "user-limit",
2790
+ "warning",
2791
+ "limit",
2792
+ "adminPanel.activity.event.userLimit",
2793
+ "Session limit reached"
2794
+ );
2795
+ case "user.password-change.ended-others":
2796
+ return appUserEvent(
2797
+ "user-password",
2798
+ "warning",
2799
+ "password",
2800
+ "adminPanel.activity.event.userPassword",
2801
+ "Signed out after a password change"
2802
+ );
2803
+ case "user.sign-in.new-device":
2804
+ return appUserEvent(
2805
+ "user-device",
2806
+ "secondary",
2807
+ "device",
2808
+ "adminPanel.activity.event.userNewDevice",
2809
+ "Sign-in from a new device"
2810
+ );
2811
+ case "user.sign-in.impossible-travel":
2812
+ return appUserEvent(
2813
+ "user-travel",
2814
+ "danger",
2815
+ "travel",
2816
+ "adminPanel.activity.event.userTravel",
2817
+ "Impossible travel"
2818
+ );
2819
+ case "user.not-me":
2820
+ return appUserEvent(
2821
+ "user-not-me",
2822
+ "danger",
2823
+ "notMe",
2824
+ "adminPanel.activity.event.userNotMe",
2825
+ 'Reported as "This wasn’t me"'
2826
+ );
2827
+ case "user.data.exported":
2828
+ return appUserEvent(
2829
+ "user-export",
2830
+ "secondary",
2831
+ "export",
2832
+ "adminPanel.activity.event.userExport",
2833
+ "Personal data exported"
2834
+ );
2714
2835
  default:
2836
+ if (typeof row?.event === "string" && row.event.startsWith("impersonation.")) {
2837
+ return appUserEvent(
2838
+ "impersonation",
2839
+ "warning",
2840
+ "impersonation",
2841
+ "adminPanel.activity.event.impersonation",
2842
+ "Impersonation"
2843
+ );
2844
+ }
2845
+ if (typeof row?.event === "string" && row.event.startsWith("webhook.")) {
2846
+ return appUserEvent(
2847
+ "webhook",
2848
+ "neutral",
2849
+ "webhook",
2850
+ "adminPanel.activity.event.webhook",
2851
+ "Webhook delivery"
2852
+ );
2853
+ }
2715
2854
  return {
2716
2855
  key: "other",
2717
2856
  tone: "neutral",
2857
+ icon: "other",
2718
2858
  label: message("adminPanel.activity.event.other", "Security event"),
2719
2859
  detail: null
2720
2860
  };
@@ -2741,6 +2881,37 @@ function getSessionStatePresentation(session) {
2741
2881
  return null;
2742
2882
  }
2743
2883
  }
2884
+ const RECENT_EVENT_LIMIT = 8;
2885
+ const ACTIVITY_PAGE_SIZE_OPTIONS = Object.freeze(["10", "20", "50", "100"]);
2886
+ const EVENT_TABLE_MIN_WIDTH = Object.freeze({ withAdmin: 800, withoutAdmin: 740 });
2887
+ const EVENT_TABLE_FULL_WIDTH = 1e3;
2888
+ function getEventListLayout(width, { showAdmin = false } = {}) {
2889
+ if (!width) return "full";
2890
+ const min = showAdmin ? EVENT_TABLE_MIN_WIDTH.withAdmin : EVENT_TABLE_MIN_WIDTH.withoutAdmin;
2891
+ if (width < min) return "stacked";
2892
+ return width >= EVENT_TABLE_FULL_WIDTH ? "full" : "table";
2893
+ }
2894
+ function getEventPlace(row) {
2895
+ return [row?.location?.city, row?.location?.country].filter(Boolean).join(", ");
2896
+ }
2897
+ function parseActivityPageQuery(query) {
2898
+ const source = query || {};
2899
+ const event = ALL_ADMINS_FILTER_OPTIONS.includes(String(source.event)) ? String(source.event) : "all";
2900
+ const period = PERIOD_OPTIONS.includes(String(source.period)) ? String(source.period) : "30";
2901
+ const adminId = /^[1-9][0-9]{0,11}$/.test(String(source.adminId ?? "")) ? Number(source.adminId) : null;
2902
+ const page = Number.parseInt(String(source.page ?? ""), 10);
2903
+ const pageSize = String(source.pageSize ?? "");
2904
+ return {
2905
+ event,
2906
+ period,
2907
+ adminId,
2908
+ page: Number.isInteger(page) && page > 0 ? page : 1,
2909
+ pageSize: ACTIVITY_PAGE_SIZE_OPTIONS.includes(pageSize) ? Number(pageSize) : EVENT_PAGE_SIZE
2910
+ };
2911
+ }
2912
+ function hasActivityPageFilters(view) {
2913
+ return view.event !== "all" || view.period !== "30" || view.adminId !== null;
2914
+ }
2744
2915
  const ACTIVITY_ACTION_LABELS = Object.freeze({
2745
2916
  all: message("adminPanel.activity.action.all", "All actions"),
2746
2917
  view: message("adminPanel.activity.action.view", "Opened"),
@@ -2833,38 +3004,131 @@ function buildActivityCsv(rows) {
2833
3004
  ])
2834
3005
  );
2835
3006
  }
2836
- const useT$2 = () => {
3007
+ const useT$3 = () => {
2837
3008
  const { formatMessage } = useIntl();
2838
3009
  return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
2839
3010
  };
2840
- const TargetTextButton = styled(TextButton)`
3011
+ const SHORT_DATE = Object.freeze({ dateStyle: "medium", timeStyle: "short" });
3012
+ const FULL_DATE = Object.freeze({ dateStyle: "full", timeStyle: "medium" });
3013
+ const EVENT_ICONS = Object.freeze({
3014
+ signIn: CheckCircle,
3015
+ failed: CrossCircle,
3016
+ lockout: Lock,
3017
+ signOut: SignOut,
3018
+ revoked: Shield,
3019
+ settings: Cog,
3020
+ logRead: Key,
3021
+ purged: Trash,
3022
+ refused: CrossCircle,
3023
+ unlock: Lock,
3024
+ limit: Stack,
3025
+ password: Key,
3026
+ device: Monitor,
3027
+ travel: Earth,
3028
+ notMe: WarningCircle,
3029
+ export: Download,
3030
+ impersonation: User,
3031
+ webhook: Webhooks,
3032
+ other: Information
3033
+ });
3034
+ const ICON_FILL = Object.freeze({
3035
+ success: "success600",
3036
+ danger: "danger600",
3037
+ warning: "warning700",
3038
+ secondary: "secondary600",
3039
+ neutral: "neutral600"
3040
+ });
3041
+ const stopCellKeys = (event) => {
3042
+ if (event.key === "Enter" || event.key === " " || event.key === "Spacebar") {
3043
+ event.stopPropagation();
3044
+ }
3045
+ };
3046
+ const ClickableRow = styled(Tr)`
3047
+ cursor: pointer;
3048
+ `;
3049
+ const WrapCell = styled(Td)`
3050
+ white-space: normal;
3051
+ `;
3052
+ const NoWrap = styled.span`
3053
+ white-space: nowrap;
3054
+ `;
3055
+ const NameButton = styled(TextButton)`
2841
3056
  min-height: 3.2rem;
3057
+ text-align: start;
2842
3058
  `;
2843
- const EventItem = ({ children, id, kind }) => /* @__PURE__ */ jsx(
2844
- Box,
2845
- {
2846
- tag: "li",
2847
- background: "neutral0",
2848
- borderColor: "neutral150",
2849
- hasRadius: true,
2850
- padding: 3,
2851
- "data-event-row": kind,
2852
- "data-event-id": id,
2853
- children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children })
3059
+ const StackedList = styled.ul`
3060
+ margin: 0;
3061
+ padding: 0;
3062
+ list-style: none;
3063
+ border: 1px solid ${({ theme }) => theme.colors.neutral150};
3064
+ border-radius: ${({ theme }) => theme.borderRadius};
3065
+ background: ${({ theme }) => theme.colors.neutral0};
3066
+ min-width: 0;
3067
+
3068
+ & > li + li {
3069
+ border-top: 1px solid ${({ theme }) => theme.colors.neutral150};
2854
3070
  }
2855
- );
2856
- const AdminName = ({ admin, onOpenAdmin }) => {
2857
- const t = useT$2();
3071
+ `;
3072
+ const StackedItem = styled.li`
3073
+ cursor: pointer;
3074
+ min-width: 0;
3075
+ `;
3076
+ const BreakAnywhere = styled(Typography)`
3077
+ overflow-wrap: anywhere;
3078
+ `;
3079
+ const getEventBadgeColors = (tone) => tone === "danger" ? { backgroundColor: "danger100", textColor: "danger700" } : getBadgeColors(tone);
3080
+ const EventBadge = ({ presentation, nowrap = false }) => {
3081
+ const t = useT$3();
3082
+ const Icon = EVENT_ICONS[presentation.icon] || Information;
3083
+ return /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", shrink: 0, "data-event-kind": presentation.key, children: [
3084
+ /* @__PURE__ */ jsx(
3085
+ Icon,
3086
+ {
3087
+ "aria-hidden": "true",
3088
+ focusable: "false",
3089
+ width: "1.6rem",
3090
+ height: "1.6rem",
3091
+ fill: ICON_FILL[presentation.tone] || ICON_FILL.neutral
3092
+ }
3093
+ ),
3094
+ /* @__PURE__ */ jsx(Badge, { ...getEventBadgeColors(presentation.tone), "data-event-tone": presentation.tone, children: nowrap ? /* @__PURE__ */ jsx(NoWrap, { children: t(presentation.label.messageId, presentation.label.defaultMessage) }) : t(presentation.label.messageId, presentation.label.defaultMessage) })
3095
+ ] });
3096
+ };
3097
+ const EventTime = ({ value, compact = false }) => {
3098
+ const { formatDate, formatRelativeTime } = useSessionFormatters();
3099
+ const date = toValidDate(value);
3100
+ if (!date) return /* @__PURE__ */ jsx(MissingValue, { variant: "omega" });
3101
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
3102
+ /* @__PURE__ */ jsx(
3103
+ Typography,
3104
+ {
3105
+ tag: "time",
3106
+ dateTime: date.toISOString(),
3107
+ variant: compact ? "pi" : "omega",
3108
+ textColor: "neutral800",
3109
+ children: /* @__PURE__ */ jsx(NoWrap, { children: formatRelativeTime(date) })
3110
+ }
3111
+ ),
3112
+ compact ? null : /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: /* @__PURE__ */ jsx(NoWrap, { children: formatDate(date, SHORT_DATE) }) })
3113
+ ] });
3114
+ };
3115
+ const noAdminText = (t, row) => row?.event === "security-log.retention.purged" ? t("adminPanel.activity.system", "System") : t("adminPanel.activity.unknownAccount", "Unknown account");
3116
+ const AdminName = ({ admin, row, onOpenAdmin }) => {
3117
+ const t = useT$3();
2858
3118
  if (!admin) {
2859
- return /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: t("adminPanel.activity.unknownAccount", "Unknown account") });
3119
+ return /* @__PURE__ */ jsx(Typography, { variant: onOpenAdmin ? "pi" : "omega", textColor: "neutral600", children: noAdminText(t, row) });
2860
3120
  }
2861
3121
  if (!onOpenAdmin) {
2862
3122
  return /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: admin.name });
2863
3123
  }
2864
3124
  return /* @__PURE__ */ jsx(
2865
- TargetTextButton,
3125
+ NameButton,
2866
3126
  {
2867
- onClick: (event) => onOpenAdmin(admin, event.currentTarget),
3127
+ onClick: (event) => {
3128
+ event.stopPropagation();
3129
+ onOpenAdmin(admin, event.currentTarget);
3130
+ },
3131
+ onKeyDown: stopCellKeys,
2868
3132
  "aria-label": t("adminPanel.activity.openAdmin", "Open the details of {name}", {
2869
3133
  name: admin.name
2870
3134
  }),
@@ -2872,32 +3136,26 @@ const AdminName = ({ admin, onOpenAdmin }) => {
2872
3136
  }
2873
3137
  );
2874
3138
  };
2875
- const SignInEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
2876
- const t = useT$2();
2877
- const event = getSignInEventPresentation(row);
2878
- const session = getSessionStatePresentation(row.session);
2879
- const facts = [];
2880
- if (row.ipAddress) {
2881
- facts.push(
2882
- row.ipAnonymized ? t("adminPanel.activity.ipAnonymized", "{ip} (anonymised)", { ip: row.ipAddress }) : row.ipAddress
2883
- );
2884
- }
2885
- const place = [row.location?.city, row.location?.country].filter(Boolean).join(", ");
2886
- if (place) facts.push(place);
3139
+ const deviceText = (t, row) => {
2887
3140
  if (row.browser && row.os) {
2888
- facts.push(
2889
- t("adminPanel.activity.browserOnOs", "{browser} on {os}", {
2890
- browser: row.browser,
2891
- os: row.os
2892
- })
2893
- );
2894
- } else if (row.browser || row.os) {
2895
- facts.push(row.browser || row.os);
3141
+ return t("adminPanel.activity.browserOnOs", "{browser} on {os}", {
3142
+ browser: row.browser,
3143
+ os: row.os
3144
+ });
3145
+ }
3146
+ return row.browser || row.os || "";
3147
+ };
3148
+ const ipText = (t, row) => {
3149
+ if (!row.ipAddress) return "";
3150
+ return row.ipAnonymized ? t("adminPanel.activity.ipAnonymized", "{ip} (anonymised)", { ip: row.ipAddress }) : row.ipAddress;
3151
+ };
3152
+ const eventDetailText = (t, row, presentation, withActor) => {
3153
+ const parts = [];
3154
+ if (presentation.detail) {
3155
+ parts.push(t(presentation.detail.messageId, presentation.detail.defaultMessage));
2896
3156
  }
2897
- if (row.actor)
2898
- facts.push(t("adminPanel.activity.byAdmin", "by {name}", { name: row.actor.name }));
2899
3157
  if (Number.isInteger(row.attempts) && row.attempts > 1) {
2900
- facts.push(
3158
+ parts.push(
2901
3159
  t(
2902
3160
  "adminPanel.activity.attempts",
2903
3161
  "{count, plural, one {# attempt} other {# attempts}} within 5 minutes",
@@ -2905,51 +3163,553 @@ const SignInEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
2905
3163
  )
2906
3164
  );
2907
3165
  }
2908
- return /* @__PURE__ */ jsxs(EventItem, { id: row.id, kind: event.key, children: [
2909
- /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
2910
- /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
2911
- /* @__PURE__ */ jsx(Badge, { ...getBadgeColors(event.tone), children: t(event.label.messageId, event.label.defaultMessage) }),
2912
- showAdmin ? /* @__PURE__ */ jsx(AdminName, { admin: row.admin, onOpenAdmin }) : null,
2913
- event.detail ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(event.detail.messageId, event.detail.defaultMessage) }) : null
2914
- ] }),
2915
- /* @__PURE__ */ jsx(LastActive, { value: row.at })
2916
- ] }),
2917
- facts.length ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: facts.join(" · ") }) : null,
2918
- session ? /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
2919
- /* @__PURE__ */ jsx(Badge, { ...getBadgeColors(session.tone), children: t(session.label.messageId, session.label.defaultMessage) }),
2920
- row.session?.endedAt ? /* @__PURE__ */ jsx(LastActive, { value: row.session.endedAt }) : null
2921
- ] }) : null
3166
+ const keys = Array.isArray(row.change?.keys) ? row.change.keys : [];
3167
+ if (keys.length) {
3168
+ parts.push(
3169
+ keys.length > 3 ? t("adminPanel.activity.settingsMore", "{names} and {count, number} more", {
3170
+ names: keys.slice(0, 3).join(", "),
3171
+ count: keys.length - 3
3172
+ }) : keys.join(", ")
3173
+ );
3174
+ }
3175
+ if (Number.isInteger(row.purge?.count)) {
3176
+ parts.push(
3177
+ Number.isInteger(row.purge?.retentionDays) ? t(
3178
+ "adminPanel.activity.purgedDetail",
3179
+ "{count, plural, one {# event} other {# events}}, older than {days, plural, one {# day} other {# days}}",
3180
+ { count: row.purge.count, days: row.purge.retentionDays }
3181
+ ) : t("adminPanel.activity.purgedCount", "{count, plural, one {# event} other {# events}}", {
3182
+ count: row.purge.count
3183
+ })
3184
+ );
3185
+ }
3186
+ if (withActor && row.actor?.name) {
3187
+ parts.push(t("adminPanel.activity.byAdmin", "by {name}", { name: row.actor.name }));
3188
+ }
3189
+ return parts.join(" · ");
3190
+ };
3191
+ const SignInDetails = ({ row }) => {
3192
+ const t = useT$3();
3193
+ const ip = ipText(t, row);
3194
+ const second = [getEventPlace(row), deviceText(t, row)].filter(Boolean).join(" · ");
3195
+ if (!ip && !second) return /* @__PURE__ */ jsx(MissingValue, { variant: "omega" });
3196
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
3197
+ ip ? /* @__PURE__ */ jsx(BreakAnywhere, { variant: "omega", textColor: "neutral800", children: ip }) : null,
3198
+ second ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: second }) : null
2922
3199
  ] });
2923
3200
  };
2924
- const ActivityEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
2925
- const t = useT$2();
2926
- const label = ACTIVITY_ACTION_LABELS[row.action] || ACTIVITY_ACTION_LABELS.view;
3201
+ const SessionState = ({ row }) => {
3202
+ const t = useT$3();
3203
+ const { formatRelativeTime } = useSessionFormatters();
3204
+ const state = getSessionStatePresentation(row.session);
3205
+ if (!state) return /* @__PURE__ */ jsx(MissingValue, { variant: "omega" });
3206
+ const endedAt = toValidDate(row.session?.endedAt);
3207
+ const second = [
3208
+ endedAt ? formatRelativeTime(endedAt) : "",
3209
+ row.session?.endedBy?.name ? t("adminPanel.activity.byAdmin", "by {name}", { name: row.session.endedBy.name }) : ""
3210
+ ].filter(Boolean).join(" · ");
3211
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
3212
+ /* @__PURE__ */ jsx(
3213
+ Typography,
3214
+ {
3215
+ variant: "omega",
3216
+ fontWeight: state.tone === "success" ? "semiBold" : void 0,
3217
+ textColor: state.tone === "success" ? "success600" : "neutral800",
3218
+ "data-session-state": row.session?.state,
3219
+ children: t(state.label.messageId, state.label.defaultMessage)
3220
+ }
3221
+ ),
3222
+ second ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: second }) : null
3223
+ ] });
3224
+ };
3225
+ const HeaderCell = ({ children, hidden = false }) => /* @__PURE__ */ jsx(Th, { children: hidden ? /* @__PURE__ */ jsx(VisuallyHidden, { children }) : /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children }) });
3226
+ const DetailsButton = ({ label, onOpen }) => /* @__PURE__ */ jsx(
3227
+ IconButton,
3228
+ {
3229
+ variant: "ghost",
3230
+ label,
3231
+ withTooltip: false,
3232
+ onClick: (event) => {
3233
+ event.stopPropagation();
3234
+ onOpen(event.currentTarget);
3235
+ },
3236
+ onKeyDown: stopCellKeys,
3237
+ "data-event-details": "",
3238
+ children: /* @__PURE__ */ jsx(Eye, {})
3239
+ }
3240
+ );
3241
+ const ActivityEntry = ({ row }) => {
3242
+ const t = useT$3();
2927
3243
  const path = getEntryPath(row);
2928
- const entryName = row.entry?.count !== null && row.entry?.count !== void 0 ? t("adminPanel.activity.entries", "{count, plural, one {# entry} other {# entries}}", {
3244
+ const name = row.entry?.count !== null && row.entry?.count !== void 0 ? t("adminPanel.activity.entries", "{count, plural, one {# entry} other {# entries}}", {
2929
3245
  count: row.entry.count
2930
3246
  }) : row.entry?.title || row.entry?.documentId || row.contentType?.name || "";
2931
- const facts = [row.contentType?.name];
2932
- if (row.entry?.locale) facts.push(row.entry.locale);
2933
- return /* @__PURE__ */ jsxs(EventItem, { id: row.id, kind: row.action, children: [
2934
- /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
2935
- /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
2936
- /* @__PURE__ */ jsx(Badge, { ...getBadgeColors(getActivityTone(row.action)), children: t(label.messageId, label.defaultMessage) }),
2937
- showAdmin ? /* @__PURE__ */ jsx(AdminName, { admin: row.admin, onOpenAdmin }) : null
2938
- ] }),
2939
- /* @__PURE__ */ jsx(LastActive, { value: row.at })
2940
- ] }),
2941
- /* @__PURE__ */ jsx(Box, { minWidth: 0, style: { overflowWrap: "anywhere" }, children: path ? /* @__PURE__ */ jsx(
2942
- TargetLink$1,
3247
+ if (!name) return /* @__PURE__ */ jsx(MissingValue, { variant: "omega" });
3248
+ if (!path) {
3249
+ return /* @__PURE__ */ jsx(BreakAnywhere, { variant: "omega", textColor: "neutral800", children: name });
3250
+ }
3251
+ return /* @__PURE__ */ jsx(
3252
+ TargetLink$1,
3253
+ {
3254
+ tag: Link$1,
3255
+ to: path,
3256
+ onClick: (event) => event.stopPropagation(),
3257
+ onKeyDown: stopCellKeys,
3258
+ "aria-label": t("adminPanel.activity.openEntry", "Open {entry} in the Content Manager", {
3259
+ entry: name
3260
+ }),
3261
+ children: name
3262
+ }
3263
+ );
3264
+ };
3265
+ const contentTypeText = (row) => [row.contentType?.name, row.entry?.locale].filter(Boolean).join(" · ");
3266
+ const EventDetailsModal = ({ title, items, footerAction, onClose, onCloseAutoFocus }) => {
3267
+ const t = useT$3();
3268
+ return /* @__PURE__ */ jsx(Modal.Root, { open: true, onOpenChange: (open) => open ? null : onClose(), children: /* @__PURE__ */ jsxs(Modal.Content, { onCloseAutoFocus, "aria-describedby": void 0, children: [
3269
+ /* @__PURE__ */ jsx(Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
3270
+ /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsx(Box, { background: "neutral100", hasRadius: true, padding: { initial: 4, medium: 6 }, children: /* @__PURE__ */ jsx(PropertyList, { columns: 2, items }) }) }),
3271
+ /* @__PURE__ */ jsxs(Modal.Footer, { children: [
3272
+ /* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: t("common.close", "Close") }) }),
3273
+ footerAction || null
3274
+ ] })
3275
+ ] }) });
3276
+ };
3277
+ const useEventDetails = () => {
3278
+ const [selected, setSelected] = useState(null);
3279
+ const [opener, setOpener] = useState(null);
3280
+ const [container, setContainer] = useState(null);
3281
+ return {
3282
+ selected,
3283
+ setContainer,
3284
+ open: (row, trigger) => {
3285
+ const button = trigger?.matches?.("[data-event-details]") ? trigger : trigger?.querySelector?.("[data-event-details]");
3286
+ setOpener(button || null);
3287
+ setSelected(row);
3288
+ },
3289
+ close: () => setSelected(null),
3290
+ onCloseAutoFocus: (event) => restoreDialogFocus(event, opener, container)
3291
+ };
3292
+ };
3293
+ const signInDetails = (t, formatDate, row) => {
3294
+ const presentation = getSignInEventPresentation(row);
3295
+ const label = t(presentation.label.messageId, presentation.label.defaultMessage);
3296
+ const state = getSessionStatePresentation(row.session);
3297
+ const revoked = presentation.key === "revoked";
3298
+ const adminName = row.admin?.name || noAdminText(t, row);
3299
+ const items = [
3300
+ {
3301
+ id: "event",
3302
+ label: t("adminPanel.activity.column.event", "Event"),
3303
+ render: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
3304
+ /* @__PURE__ */ jsx(EventBadge, { presentation }),
3305
+ presentation.detail ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(presentation.detail.messageId, presentation.detail.defaultMessage) }) : null
3306
+ ] })
3307
+ },
3308
+ {
3309
+ id: "time",
3310
+ label: t("adminPanel.activity.details.exactTime", "Exact time"),
3311
+ value: row.at ? formatDate(row.at, FULL_DATE) : null
3312
+ },
3313
+ { id: "admin", label: t("adminPanel.activity.column.admin", "Admin"), value: adminName }
3314
+ ];
3315
+ if (revoked) {
3316
+ items.push(
2943
3317
  {
2944
- tag: Link$1,
2945
- to: path,
2946
- "aria-label": t("adminPanel.activity.openEntry", "Open {entry} in the Content Manager", {
2947
- entry: entryName
2948
- }),
2949
- children: entryName
3318
+ id: "actor",
3319
+ label: t("adminPanel.activity.column.doneBy", "Done by"),
3320
+ value: row.actor?.name || null
3321
+ },
3322
+ {
3323
+ id: "scope",
3324
+ label: t("adminPanel.activity.details.signedOutOf", "Signed out of"),
3325
+ value: Number.isInteger(row.sessionsEnded) && row.sessionsEnded >= 0 ? t(
3326
+ "adminPanel.activity.details.scopeCount",
3327
+ "{scope} ({count, plural, =0 {no open session} one {# session ended} other {# sessions ended}})",
3328
+ {
3329
+ scope: t(presentation.detail.messageId, presentation.detail.defaultMessage),
3330
+ count: row.sessionsEnded
3331
+ }
3332
+ ) : t(presentation.detail.messageId, presentation.detail.defaultMessage)
3333
+ }
3334
+ );
3335
+ }
3336
+ if (state) {
3337
+ const endedAt = toValidDate(row.session?.endedAt);
3338
+ items.push({
3339
+ id: "session",
3340
+ label: t("adminPanel.activity.column.session", "Session"),
3341
+ value: [
3342
+ t(state.label.messageId, state.label.defaultMessage),
3343
+ endedAt ? formatDate(endedAt, SHORT_DATE) : "",
3344
+ row.session?.endedBy?.name ? t("adminPanel.activity.byAdmin", "by {name}", { name: row.session.endedBy.name }) : ""
3345
+ ].filter(Boolean).join(" · ")
3346
+ });
3347
+ }
3348
+ if (row.change) {
3349
+ items.push({
3350
+ id: "settings",
3351
+ label: t("adminPanel.activity.details.changedSettings", "Changed settings"),
3352
+ value: Array.isArray(row.change.keys) && row.change.keys.length ? row.change.keys.join(", ") : null,
3353
+ kind: "id",
3354
+ fullWidth: true
3355
+ });
3356
+ }
3357
+ if (row.purge) {
3358
+ items.push(
3359
+ {
3360
+ id: "purged",
3361
+ label: t("adminPanel.activity.details.deleted", "Deleted events"),
3362
+ value: Number.isInteger(row.purge.count) ? row.purge.count : null
3363
+ },
3364
+ {
3365
+ id: "retention",
3366
+ label: t("adminPanel.activity.details.retention", "Kept for"),
3367
+ value: Number.isInteger(row.purge.retentionDays) ? t("adminPanel.duration.days", "{count, plural, one {# day} other {# days}}", {
3368
+ count: row.purge.retentionDays
3369
+ }) : null
3370
+ }
3371
+ );
3372
+ }
3373
+ if (Number.isInteger(row.attempts) && row.attempts > 1) {
3374
+ items.push({
3375
+ id: "attempts",
3376
+ label: t("adminPanel.activity.details.attempts", "Attempts"),
3377
+ value: row.attempts
3378
+ });
3379
+ }
3380
+ items.push(
3381
+ {
3382
+ id: "ip",
3383
+ label: t("adminPanel.activity.details.ip", "IP address"),
3384
+ value: ipText(t, row) || null,
3385
+ kind: "id"
3386
+ },
3387
+ {
3388
+ id: "place",
3389
+ label: t("adminPanel.activity.details.location", "Location"),
3390
+ value: getEventPlace(row) || null
3391
+ },
3392
+ {
3393
+ id: "browser",
3394
+ label: t("adminPanel.activity.details.browser", "Browser"),
3395
+ value: row.browser || null
3396
+ },
3397
+ {
3398
+ id: "os",
3399
+ label: t("adminPanel.activity.details.os", "Operating system"),
3400
+ value: row.os || null
3401
+ },
3402
+ {
3403
+ id: "userAgent",
3404
+ label: t("adminPanel.activity.details.userAgent", "User agent"),
3405
+ value: row.userAgent || null,
3406
+ kind: "id",
3407
+ fullWidth: true
3408
+ },
3409
+ {
3410
+ id: "eventId",
3411
+ label: t("adminPanel.activity.details.eventId", "Event ID"),
3412
+ value: row.id,
3413
+ kind: "id"
3414
+ }
3415
+ );
3416
+ const title = row.admin?.name ? t("adminPanel.activity.details.title", "{event}: {name}", { event: label, name: adminName }) : label;
3417
+ const logEvent = ["settings", "log-read", "purged"].includes(presentation.key);
3418
+ const deviceFields = /* @__PURE__ */ new Set(["ip", "place", "browser", "os", "userAgent"]);
3419
+ return {
3420
+ title,
3421
+ items: logEvent ? items.filter(
3422
+ (item) => !deviceFields.has(item.id) || item.value !== null && item.value !== ""
3423
+ ) : items
3424
+ };
3425
+ };
3426
+ const activityDetails = (t, formatDate, row) => {
3427
+ const label = ACTIVITY_ACTION_LABELS[row.action] || ACTIVITY_ACTION_LABELS.view;
3428
+ const action = t(label.messageId, label.defaultMessage);
3429
+ return {
3430
+ title: row.entry?.title ? t("adminPanel.activity.details.title", "{event}: {name}", {
3431
+ event: action,
3432
+ name: row.entry.title
3433
+ }) : action,
3434
+ items: [
3435
+ {
3436
+ id: "action",
3437
+ label: t("adminPanel.activity.column.action", "Action"),
3438
+ render: /* @__PURE__ */ jsx(Badge, { ...getBadgeColors(getActivityTone(row.action)), children: action })
3439
+ },
3440
+ {
3441
+ id: "time",
3442
+ label: t("adminPanel.activity.details.exactTime", "Exact time"),
3443
+ value: row.at ? formatDate(row.at, FULL_DATE) : null
3444
+ },
3445
+ {
3446
+ id: "entry",
3447
+ label: t("adminPanel.activity.column.entry", "Entry"),
3448
+ render: /* @__PURE__ */ jsx(ActivityEntry, { row })
3449
+ },
3450
+ {
3451
+ id: "admin",
3452
+ label: t("adminPanel.activity.column.admin", "Admin"),
3453
+ value: row.admin?.name || null
3454
+ },
3455
+ {
3456
+ id: "type",
3457
+ label: t("adminPanel.activity.column.contentType", "Content type"),
3458
+ value: row.contentType?.name || null
3459
+ },
3460
+ {
3461
+ id: "uid",
3462
+ label: t("adminPanel.activity.details.uid", "Content type UID"),
3463
+ value: row.contentType?.uid || null,
3464
+ kind: "id"
3465
+ },
3466
+ {
3467
+ id: "documentId",
3468
+ label: t("adminPanel.activity.details.documentId", "Document ID"),
3469
+ value: row.entry?.documentId || null,
3470
+ kind: "id"
3471
+ },
3472
+ {
3473
+ id: "locale",
3474
+ label: t("adminPanel.activity.details.locale", "Locale"),
3475
+ value: row.entry?.locale || null
3476
+ },
3477
+ {
3478
+ id: "eventId",
3479
+ label: t("adminPanel.activity.details.eventId", "Event ID"),
3480
+ value: row.id,
3481
+ kind: "id"
2950
3482
  }
2951
- ) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: entryName }) }),
2952
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: facts.filter(Boolean).join(" · ") })
3483
+ ]
3484
+ };
3485
+ };
3486
+ const SignInEventTable = ({
3487
+ rows,
3488
+ label,
3489
+ showAdmin = false,
3490
+ onOpenAdmin,
3491
+ detailsAction,
3492
+ busy = false
3493
+ }) => {
3494
+ const t = useT$3();
3495
+ const { formatDate, formatRelativeTime } = useSessionFormatters();
3496
+ const [measureRef, width] = useElementWidth();
3497
+ const {
3498
+ selected,
3499
+ open: openDetails,
3500
+ close: closeDetails,
3501
+ onCloseAutoFocus,
3502
+ setContainer
3503
+ } = useEventDetails();
3504
+ const layout = getEventListLayout(width, { showAdmin });
3505
+ const showDoneBy = layout === "full";
3506
+ const detailsLabel = (row, presentation) => t("adminPanel.activity.details.open", "Details of {event}, {time}", {
3507
+ event: t(presentation.label.messageId, presentation.label.defaultMessage),
3508
+ time: formatRelativeTime(row.at)
3509
+ });
3510
+ let list;
3511
+ if (layout === "stacked") {
3512
+ list = /* @__PURE__ */ jsx(StackedList, { "aria-label": label, "data-event-list": "stacked", children: rows.map((row) => {
3513
+ const presentation = getSignInEventPresentation(row);
3514
+ const state = getSessionStatePresentation(row.session);
3515
+ const second = [
3516
+ eventDetailText(t, row, presentation, true),
3517
+ ipText(t, row),
3518
+ getEventPlace(row),
3519
+ deviceText(t, row),
3520
+ state ? t(state.label.messageId, state.label.defaultMessage) : ""
3521
+ ].filter(Boolean).join(" · ");
3522
+ return /* @__PURE__ */ jsx(
3523
+ StackedItem,
3524
+ {
3525
+ "data-event-row": presentation.key,
3526
+ "data-event-id": row.id,
3527
+ onClick: (event) => openDetails(row, event.currentTarget),
3528
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, padding: 3, minWidth: 0, children: [
3529
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
3530
+ /* @__PURE__ */ jsx(EventBadge, { presentation }),
3531
+ /* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", marginLeft: "auto", children: [
3532
+ /* @__PURE__ */ jsx(EventTime, { value: row.at, compact: true }),
3533
+ /* @__PURE__ */ jsx(
3534
+ DetailsButton,
3535
+ {
3536
+ label: detailsLabel(row, presentation),
3537
+ onOpen: (trigger) => openDetails(row, trigger)
3538
+ }
3539
+ )
3540
+ ] })
3541
+ ] }),
3542
+ showAdmin ? /* @__PURE__ */ jsx(Flex, { minWidth: 0, children: /* @__PURE__ */ jsx(AdminName, { admin: row.admin, row, onOpenAdmin }) }) : null,
3543
+ second ? /* @__PURE__ */ jsx(BreakAnywhere, { variant: "pi", textColor: "neutral600", children: second }) : null
3544
+ ] })
3545
+ },
3546
+ row.id
3547
+ );
3548
+ }) });
3549
+ } else {
3550
+ const colCount = 5 + (showAdmin ? 1 : 0) + (showDoneBy ? 1 : 0);
3551
+ list = /* @__PURE__ */ jsx(Box, { background: "neutral0", hasRadius: true, shadow: "tableShadow", "data-event-list": layout, children: /* @__PURE__ */ jsxs(Table, { colCount, rowCount: rows.length + 1, "aria-label": label, "aria-busy": busy, children: [
3552
+ /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
3553
+ /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.time", "Time") }),
3554
+ /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.event", "Event") }),
3555
+ showAdmin ? /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.admin", "Admin") }) : null,
3556
+ /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.details", "IP address and device") }),
3557
+ /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.session", "Session") }),
3558
+ showDoneBy ? /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.doneBy", "Done by") }) : null,
3559
+ /* @__PURE__ */ jsx(HeaderCell, { hidden: true, children: t("adminPanel.table.actions", "Actions") })
3560
+ ] }) }),
3561
+ /* @__PURE__ */ jsx(Tbody, { children: rows.map((row) => {
3562
+ const presentation = getSignInEventPresentation(row);
3563
+ const eventDetail = eventDetailText(t, row, presentation, !showDoneBy);
3564
+ return /* @__PURE__ */ jsxs(
3565
+ ClickableRow,
3566
+ {
3567
+ "data-event-row": presentation.key,
3568
+ "data-event-id": row.id,
3569
+ onClick: (event) => openDetails(row, event.currentTarget),
3570
+ children: [
3571
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(EventTime, { value: row.at }) }),
3572
+ /* @__PURE__ */ jsx(WrapCell, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
3573
+ /* @__PURE__ */ jsx(EventBadge, { presentation, nowrap: true }),
3574
+ eventDetail ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: eventDetail }) : null
3575
+ ] }) }),
3576
+ showAdmin ? /* @__PURE__ */ jsx(WrapCell, { children: /* @__PURE__ */ jsx(AdminName, { admin: row.admin, row, onOpenAdmin }) }) : null,
3577
+ /* @__PURE__ */ jsx(WrapCell, { children: /* @__PURE__ */ jsx(SignInDetails, { row }) }),
3578
+ /* @__PURE__ */ jsx(WrapCell, { children: /* @__PURE__ */ jsx(SessionState, { row }) }),
3579
+ showDoneBy ? /* @__PURE__ */ jsx(WrapCell, { children: row.actor?.name ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: row.actor.name }) : /* @__PURE__ */ jsx(MissingValue, { variant: "omega" }) }) : null,
3580
+ /* @__PURE__ */ jsx(Td, { onClick: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", gap: 1, onKeyDown: stopCellKeys, children: /* @__PURE__ */ jsx(
3581
+ DetailsButton,
3582
+ {
3583
+ label: detailsLabel(row, presentation),
3584
+ onOpen: (trigger) => openDetails(row, trigger)
3585
+ }
3586
+ ) }) })
3587
+ ]
3588
+ },
3589
+ row.id
3590
+ );
3591
+ }) })
3592
+ ] }) });
3593
+ }
3594
+ const content = selected ? signInDetails(t, formatDate, selected) : null;
3595
+ return /* @__PURE__ */ jsxs(Box, { ref: measureRef, minWidth: 0, width: "100%", children: [
3596
+ /* @__PURE__ */ jsx(Box, { ref: setContainer, tabIndex: -1, minWidth: 0, children: list }),
3597
+ content ? /* @__PURE__ */ jsx(
3598
+ EventDetailsModal,
3599
+ {
3600
+ title: content.title,
3601
+ items: content.items,
3602
+ footerAction: detailsAction ? detailsAction(selected, closeDetails) : null,
3603
+ onClose: closeDetails,
3604
+ onCloseAutoFocus
3605
+ }
3606
+ ) : null
3607
+ ] });
3608
+ };
3609
+ const ActivityEventTable = ({ rows, label, showAdmin = false, busy = false }) => {
3610
+ const t = useT$3();
3611
+ const { formatDate, formatRelativeTime } = useSessionFormatters();
3612
+ const [measureRef, width] = useElementWidth();
3613
+ const {
3614
+ selected,
3615
+ open: openDetails,
3616
+ close: closeDetails,
3617
+ onCloseAutoFocus,
3618
+ setContainer
3619
+ } = useEventDetails();
3620
+ const layout = getEventListLayout(width, { showAdmin });
3621
+ const actionOf = (row) => {
3622
+ const entry = ACTIVITY_ACTION_LABELS[row.action] || ACTIVITY_ACTION_LABELS.view;
3623
+ return t(entry.messageId, entry.defaultMessage);
3624
+ };
3625
+ const detailsLabel = (row) => t("adminPanel.activity.details.open", "Details of {event}, {time}", {
3626
+ event: actionOf(row),
3627
+ time: formatRelativeTime(row.at)
3628
+ });
3629
+ const badge = (row) => /* @__PURE__ */ jsx(
3630
+ Badge,
3631
+ {
3632
+ ...getBadgeColors(getActivityTone(row.action)),
3633
+ "data-event-tone": getActivityTone(row.action),
3634
+ children: actionOf(row)
3635
+ }
3636
+ );
3637
+ let list;
3638
+ if (layout === "stacked") {
3639
+ list = /* @__PURE__ */ jsx(StackedList, { "aria-label": label, "data-event-list": "stacked", children: rows.map((row) => /* @__PURE__ */ jsx(
3640
+ StackedItem,
3641
+ {
3642
+ "data-event-row": row.action,
3643
+ "data-event-id": row.id,
3644
+ onClick: (event) => openDetails(row, event.currentTarget),
3645
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, padding: 3, minWidth: 0, children: [
3646
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
3647
+ badge(row),
3648
+ /* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", marginLeft: "auto", children: [
3649
+ /* @__PURE__ */ jsx(EventTime, { value: row.at, compact: true }),
3650
+ /* @__PURE__ */ jsx(
3651
+ DetailsButton,
3652
+ {
3653
+ label: detailsLabel(row),
3654
+ onOpen: (trigger) => openDetails(row, trigger)
3655
+ }
3656
+ )
3657
+ ] })
3658
+ ] }),
3659
+ /* @__PURE__ */ jsx(Flex, { minWidth: 0, children: /* @__PURE__ */ jsx(ActivityEntry, { row }) }),
3660
+ contentTypeText(row) || showAdmin && row.admin?.name ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: [contentTypeText(row), showAdmin ? row.admin?.name : ""].filter(Boolean).join(" · ") }) : null
3661
+ ] })
3662
+ },
3663
+ row.id
3664
+ )) });
3665
+ } else {
3666
+ const colCount = 5 + (showAdmin ? 1 : 0);
3667
+ list = /* @__PURE__ */ jsx(Box, { background: "neutral0", hasRadius: true, shadow: "tableShadow", "data-event-list": layout, children: /* @__PURE__ */ jsxs(Table, { colCount, rowCount: rows.length + 1, "aria-label": label, "aria-busy": busy, children: [
3668
+ /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
3669
+ /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.time", "Time") }),
3670
+ /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.action", "Action") }),
3671
+ /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.entry", "Entry") }),
3672
+ /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.contentType", "Content type") }),
3673
+ showAdmin ? /* @__PURE__ */ jsx(HeaderCell, { children: t("adminPanel.activity.column.admin", "Admin") }) : null,
3674
+ /* @__PURE__ */ jsx(HeaderCell, { hidden: true, children: t("adminPanel.table.actions", "Actions") })
3675
+ ] }) }),
3676
+ /* @__PURE__ */ jsx(Tbody, { children: rows.map((row) => /* @__PURE__ */ jsxs(
3677
+ ClickableRow,
3678
+ {
3679
+ "data-event-row": row.action,
3680
+ "data-event-id": row.id,
3681
+ onClick: (event) => openDetails(row, event.currentTarget),
3682
+ children: [
3683
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(EventTime, { value: row.at }) }),
3684
+ /* @__PURE__ */ jsx(Td, { children: badge(row) }),
3685
+ /* @__PURE__ */ jsx(WrapCell, { children: /* @__PURE__ */ jsx(ActivityEntry, { row }) }),
3686
+ /* @__PURE__ */ jsx(WrapCell, { children: contentTypeText(row) ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: contentTypeText(row) }) : /* @__PURE__ */ jsx(MissingValue, { variant: "omega" }) }),
3687
+ showAdmin ? /* @__PURE__ */ jsx(WrapCell, { children: /* @__PURE__ */ jsx(AdminName, { admin: row.admin }) }) : null,
3688
+ /* @__PURE__ */ jsx(Td, { onClick: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", gap: 1, onKeyDown: stopCellKeys, children: /* @__PURE__ */ jsx(
3689
+ DetailsButton,
3690
+ {
3691
+ label: detailsLabel(row),
3692
+ onOpen: (trigger) => openDetails(row, trigger)
3693
+ }
3694
+ ) }) })
3695
+ ]
3696
+ },
3697
+ row.id
3698
+ )) })
3699
+ ] }) });
3700
+ }
3701
+ const content = selected ? activityDetails(t, formatDate, selected) : null;
3702
+ return /* @__PURE__ */ jsxs(Box, { ref: measureRef, minWidth: 0, width: "100%", children: [
3703
+ /* @__PURE__ */ jsx(Box, { ref: setContainer, tabIndex: -1, minWidth: 0, children: list }),
3704
+ content ? /* @__PURE__ */ jsx(
3705
+ EventDetailsModal,
3706
+ {
3707
+ title: content.title,
3708
+ items: content.items,
3709
+ onClose: closeDetails,
3710
+ onCloseAutoFocus
3711
+ }
3712
+ ) : null
2953
3713
  ] });
2954
3714
  };
2955
3715
  function useEventList({ path, params, logKey }) {
@@ -2978,18 +3738,19 @@ function useEventList({ path, params, logKey }) {
2978
3738
  const [error, setError] = useState(false);
2979
3739
  const requestRef = useRef(0);
2980
3740
  const key = JSON.stringify(params);
3741
+ const firstPage = Number(params?.page) > 0 ? Number(params.page) : 1;
2981
3742
  const load = useCallback(
2982
3743
  async (nextPage) => {
2983
3744
  const requestId = requestRef.current + 1;
2984
3745
  requestRef.current = requestId;
2985
- if (nextPage === 1) setLoading(true);
3746
+ if (nextPage === firstPage) setLoading(true);
2986
3747
  else setLoadingMore(true);
2987
3748
  try {
2988
3749
  const response = await get(path, { params: { ...JSON.parse(key), page: nextPage } });
2989
3750
  if (requestId !== requestRef.current) return;
2990
3751
  const body = response?.data || {};
2991
3752
  const data = fillNames(Array.isArray(body.data) ? body.data : []);
2992
- setRows((current) => nextPage === 1 ? data : [...current, ...data]);
3753
+ setRows((current) => nextPage === firstPage ? data : [...current, ...data]);
2993
3754
  setMeta(body.meta || null);
2994
3755
  setPage(nextPage);
2995
3756
  setError(false);
@@ -3004,14 +3765,14 @@ function useEventList({ path, params, logKey }) {
3004
3765
  }
3005
3766
  }
3006
3767
  },
3007
- [get, path, key, logKey, fillNames]
3768
+ [get, path, key, logKey, fillNames, firstPage]
3008
3769
  );
3009
3770
  useEffect(() => {
3010
- load(1);
3771
+ load(firstPage);
3011
3772
  return () => {
3012
3773
  requestRef.current += 1;
3013
3774
  };
3014
- }, [load]);
3775
+ }, [load, firstPage]);
3015
3776
  const pagination = meta?.pagination;
3016
3777
  const hasMore = Boolean(pagination && page < pagination.pageCount);
3017
3778
  const exportAll = useCallback(async () => {
@@ -3039,7 +3800,7 @@ function useEventList({ path, params, logKey }) {
3039
3800
  error,
3040
3801
  hasMore,
3041
3802
  loadMore: () => load(page + 1),
3042
- reload: () => load(1),
3803
+ reload: () => load(firstPage),
3043
3804
  exportAll
3044
3805
  };
3045
3806
  }
@@ -3053,12 +3814,13 @@ function downloadCsv(content, name) {
3053
3814
  window.setTimeout(() => URL.revokeObjectURL(url), 0);
3054
3815
  }
3055
3816
  const ADMIN_ACTIVITY_SETTINGS_PATH = `/settings/${pluginId}/general?tab=admin-activity`;
3056
- const useT$1 = () => {
3817
+ const ADMIN_ACTIVITY_PAGE_PATH = `/plugins/${pluginId}/admin-panel/activity`;
3818
+ const useT$2 = () => {
3057
3819
  const { formatMessage } = useIntl();
3058
3820
  return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
3059
3821
  };
3060
3822
  const PeriodSelect = ({ value, onChange }) => {
3061
- const t = useT$1();
3823
+ const t = useT$2();
3062
3824
  const labels = {
3063
3825
  1: t("adminPanel.activity.period.day", "Last 24 hours"),
3064
3826
  7: t("adminPanel.activity.period.week", "Last 7 days"),
@@ -3078,18 +3840,19 @@ const PeriodSelect = ({ value, onChange }) => {
3078
3840
  );
3079
3841
  };
3080
3842
  const FilterSlot = ({ children }) => /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", minWidth: 0, flex: "1 1 18rem", children });
3843
+ const EmptyText = ({ children }) => /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", "data-event-empty": "", children });
3081
3844
  const EventList = ({
3082
3845
  filters,
3083
3846
  notice,
3084
3847
  list,
3085
- listLabel,
3086
- emptyText,
3087
- renderRow,
3848
+ empty,
3849
+ renderList,
3088
3850
  toCsv: toCsv2,
3089
3851
  fileName,
3090
- exportLabel
3852
+ exportLabel,
3853
+ footer
3091
3854
  }) => {
3092
- const t = useT$1();
3855
+ const t = useT$2();
3093
3856
  const { toggleNotification } = useNotification();
3094
3857
  const [exporting, setExporting] = useState(false);
3095
3858
  const total = list.meta?.pagination?.total ?? 0;
@@ -3147,24 +3910,13 @@ const EventList = ({
3147
3910
  children: t("adminPanel.activity.error", "The events could not be loaded.")
3148
3911
  }
3149
3912
  ) : null,
3150
- !list.loading && !list.error && list.rows.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", "data-event-empty": "", children: emptyText }) : null,
3151
- list.rows.length > 0 ? /* @__PURE__ */ jsx(
3152
- Flex,
3153
- {
3154
- tag: "ul",
3155
- direction: "column",
3156
- alignItems: "stretch",
3157
- gap: 2,
3158
- width: "100%",
3159
- "aria-label": listLabel,
3160
- children: list.rows.map((row) => renderRow(row))
3161
- }
3162
- ) : null,
3163
- 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
3913
+ !list.loading && !list.error && list.rows.length === 0 ? empty : null,
3914
+ list.rows.length > 0 ? renderList(list.rows) : null,
3915
+ footer !== void 0 ? list.rows.length > 0 ? footer : null : 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
3164
3916
  ] });
3165
3917
  };
3166
3918
  const RecordingOff = ({ children }) => {
3167
- const t = useT$1();
3919
+ const t = useT$2();
3168
3920
  return /* @__PURE__ */ jsx(
3169
3921
  PersistentAlert,
3170
3922
  {
@@ -3175,7 +3927,7 @@ const RecordingOff = ({ children }) => {
3175
3927
  );
3176
3928
  };
3177
3929
  const SignInHistoryPanel = ({ admin }) => {
3178
- const t = useT$1();
3930
+ const t = useT$2();
3179
3931
  const [event, setEvent] = useState("all");
3180
3932
  const [period, setPeriod] = useState("30");
3181
3933
  const params = useMemo(
@@ -3215,11 +3967,17 @@ const SignInHistoryPanel = ({ admin }) => {
3215
3967
  "adminPanel.activity.signIns.off",
3216
3968
  "Sign-in history is turned off. New sign-ins are not recorded."
3217
3969
  ) }) : null,
3218
- listLabel: t("adminPanel.activity.signIns.listLabel", "Sign-in history of {name}", {
3219
- name: admin.name
3220
- }),
3221
- emptyText: t("adminPanel.activity.signIns.empty", "No sign-in events in this period."),
3222
- renderRow: (row) => /* @__PURE__ */ jsx(SignInEventRow, { row }, row.id),
3970
+ empty: /* @__PURE__ */ jsx(EmptyText, { children: t("adminPanel.activity.signIns.empty", "No sign-in events in this period.") }),
3971
+ renderList: (rows) => /* @__PURE__ */ jsx(
3972
+ SignInEventTable,
3973
+ {
3974
+ rows,
3975
+ busy: list.loading,
3976
+ label: t("adminPanel.activity.signIns.listLabel", "Sign-in history of {name}", {
3977
+ name: admin.name
3978
+ })
3979
+ }
3980
+ ),
3223
3981
  toCsv: buildSignInCsv,
3224
3982
  fileName: "admin-sign-in-history",
3225
3983
  exportLabel: t(
@@ -3233,7 +3991,7 @@ const SignInHistoryPanel = ({ admin }) => {
3233
3991
  );
3234
3992
  };
3235
3993
  const ContentActivityPanel = ({ admin }) => {
3236
- const t = useT$1();
3994
+ const t = useT$2();
3237
3995
  const [action, setAction] = useState("all");
3238
3996
  const [contentType, setContentType] = useState("all");
3239
3997
  const [period, setPeriod] = useState("30");
@@ -3296,14 +4054,17 @@ const ContentActivityPanel = ({ admin }) => {
3296
4054
  /* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(PeriodSelect, { value: period, onChange: setPeriod }) })
3297
4055
  ] }),
3298
4056
  notice,
3299
- listLabel: t("adminPanel.activity.content.listLabel", "Content Manager activity of {name}", {
3300
- name: admin.name
3301
- }),
3302
- emptyText: t(
3303
- "adminPanel.activity.content.empty",
3304
- "No Content Manager activity in this period."
4057
+ empty: /* @__PURE__ */ jsx(EmptyText, { children: t("adminPanel.activity.content.empty", "No Content Manager activity in this period.") }),
4058
+ renderList: (rows) => /* @__PURE__ */ jsx(
4059
+ ActivityEventTable,
4060
+ {
4061
+ rows,
4062
+ busy: list.loading,
4063
+ label: t("adminPanel.activity.content.listLabel", "Content Manager activity of {name}", {
4064
+ name: admin.name
4065
+ })
4066
+ }
3305
4067
  ),
3306
- renderRow: (row) => /* @__PURE__ */ jsx(ActivityEventRow, { row }, row.id),
3307
4068
  toCsv: buildActivityCsv,
3308
4069
  fileName: "admin-content-activity",
3309
4070
  exportLabel: t(
@@ -3315,24 +4076,48 @@ const ContentActivityPanel = ({ admin }) => {
3315
4076
  );
3316
4077
  };
3317
4078
  const RecentSignInActivity = ({ onOpenAdmin }) => {
3318
- const t = useT$1();
3319
- const params = useMemo(() => buildSignInParams({ pageSize: 5 }), []);
4079
+ const t = useT$2();
4080
+ const headingId = `recent-sign-in-activity-${useId().replace(/:/g, "")}`;
4081
+ const params = useMemo(() => buildSignInParams({ pageSize: RECENT_EVENT_LIMIT }), []);
3320
4082
  const list = useEventList({
3321
4083
  path: `/${pluginId}/admin-activity/sign-ins`,
3322
4084
  params,
3323
4085
  logKey: "adminPanel.activity.recent"
3324
4086
  });
3325
4087
  if (list.meta?.recording && !list.meta.recording.signIns) return null;
4088
+ const title = t("adminPanel.activity.recent.title", "Recent security activity");
3326
4089
  return /* @__PURE__ */ jsxs(
3327
- SectionCard,
4090
+ Flex,
3328
4091
  {
3329
- title: t("adminPanel.activity.recent.title", "Recent sign-in activity"),
3330
- subtitle: t(
3331
- "adminPanel.activity.recent.subtitle",
3332
- "The latest sign-ins, failed attempts and sign-outs of all admins. Open an admin for their full history."
3333
- ),
4092
+ tag: "section",
4093
+ "aria-labelledby": headingId,
4094
+ direction: "column",
4095
+ alignItems: "stretch",
4096
+ gap: 4,
4097
+ minWidth: 0,
4098
+ "data-recent-activity": "",
3334
4099
  children: [
3335
- list.loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 2, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("adminPanel.activity.loading", "Loading events") }) }) : null,
4100
+ /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "flex-end", gap: 4, wrap: "wrap", children: [
4101
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, flex: "1 1 32rem", children: [
4102
+ /* @__PURE__ */ jsx(Typography, { id: headingId, variant: "delta", tag: "h2", textColor: "neutral800", children: title }),
4103
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(
4104
+ "adminPanel.activity.recent.subtitle",
4105
+ "The latest sign-ins, failed attempts, sign-outs and settings changes of all admins. Select an event for its details."
4106
+ ) })
4107
+ ] }),
4108
+ /* @__PURE__ */ jsx(
4109
+ LinkButton,
4110
+ {
4111
+ tag: Link$1,
4112
+ to: ADMIN_ACTIVITY_PAGE_PATH,
4113
+ variant: "tertiary",
4114
+ endIcon: /* @__PURE__ */ jsx(ArrowRight, {}),
4115
+ "data-show-all-activity": "",
4116
+ children: t("adminPanel.activity.recent.showAll", "Show all")
4117
+ }
4118
+ )
4119
+ ] }),
4120
+ list.loading && list.rows.length === 0 ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 2, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("adminPanel.activity.loading", "Loading events") }) }) : null,
3336
4121
  !list.loading && list.error ? /* @__PURE__ */ jsx(
3337
4122
  PersistentAlert,
3338
4123
  {
@@ -3341,17 +4126,15 @@ const RecentSignInActivity = ({ onOpenAdmin }) => {
3341
4126
  children: t("adminPanel.activity.error", "The events could not be loaded.")
3342
4127
  }
3343
4128
  ) : null,
3344
- !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,
4129
+ !list.loading && !list.error && list.rows.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: t("adminPanel.activity.recent.empty", "No events recorded yet.") }) : null,
3345
4130
  list.rows.length > 0 ? /* @__PURE__ */ jsx(
3346
- Flex,
4131
+ SignInEventTable,
3347
4132
  {
3348
- tag: "ul",
3349
- direction: "column",
3350
- alignItems: "stretch",
3351
- gap: 2,
3352
- width: "100%",
3353
- "aria-label": t("adminPanel.activity.recent.title", "Recent sign-in activity"),
3354
- children: list.rows.map((row) => /* @__PURE__ */ jsx(SignInEventRow, { row, showAdmin: true, onOpenAdmin }, row.id))
4133
+ rows: list.rows,
4134
+ label: title,
4135
+ showAdmin: true,
4136
+ onOpenAdmin,
4137
+ busy: list.loading
3355
4138
  }
3356
4139
  ) : null
3357
4140
  ]
@@ -3375,7 +4158,7 @@ const DialogTabLabel = styled.span`
3375
4158
  font-size: ${({ theme }) => theme.fontSizes[2]};
3376
4159
  `;
3377
4160
  const ADMIN_DIALOG_TABS = Object.freeze(["sessions", "history", "activity"]);
3378
- const useT = () => {
4161
+ const useT$1 = () => {
3379
4162
  const { formatMessage } = useIntl();
3380
4163
  return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
3381
4164
  };
@@ -3385,7 +4168,7 @@ const DateValue = ({ value }) => {
3385
4168
  return /* @__PURE__ */ jsx(Typography, { tag: "time", dateTime: value, variant: "omega", textColor: "neutral800", children: formatDate(value) });
3386
4169
  };
3387
4170
  const SessionCard = ({ session, admin, canSignOut, onSignOut }) => {
3388
- const t = useT();
4171
+ const t = useT$1();
3389
4172
  const device = session.device || t("adminPanel.session.unknownDevice", "Unknown browser");
3390
4173
  return /* @__PURE__ */ jsx(
3391
4174
  Box,
@@ -3463,7 +4246,7 @@ const AdminSessionsModal = ({
3463
4246
  canViewActivity = false,
3464
4247
  initialTab = "sessions"
3465
4248
  }) => {
3466
- const t = useT();
4249
+ const t = useT$1();
3467
4250
  const [tab, setTab] = useState(ADMIN_DIALOG_TABS.includes(initialTab) ? initialTab : "sessions");
3468
4251
  const canSignOut = canRevoke && admin.account === "active" && !admin.protectedReason;
3469
4252
  const settingsPath = `/settings/users/${admin.id}`;
@@ -3571,7 +4354,7 @@ const AdminSessionsModal = ({
3571
4354
  ] }) });
3572
4355
  };
3573
4356
  const SETTINGS_USERS_PATH = "/settings/users";
3574
- const PaginationTargets = styled.div`
4357
+ const PaginationTargets$1 = styled.div`
3575
4358
  nav a {
3576
4359
  min-width: 3.2rem;
3577
4360
  }
@@ -4042,7 +4825,7 @@ const AdminPanelPage = () => {
4042
4825
  ] }),
4043
4826
  admins.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
4044
4827
  isBelowMedium ? /* @__PURE__ */ jsx(AdminCardList, { ...listProps }) : /* @__PURE__ */ jsx(AdminTable, { ...listProps }),
4045
- /* @__PURE__ */ jsx(PaginationTargets, { children: /* @__PURE__ */ jsxs(
4828
+ /* @__PURE__ */ jsx(PaginationTargets$1, { children: /* @__PURE__ */ jsxs(
4046
4829
  Pagination.Root,
4047
4830
  {
4048
4831
  pageCount: pagination.pageCount,
@@ -4108,6 +4891,185 @@ const AdminPanelPage = () => {
4108
4891
  }
4109
4892
  );
4110
4893
  };
4894
+ const PaginationTargets = styled.div`
4895
+ nav a {
4896
+ min-width: 3.2rem;
4897
+ }
4898
+
4899
+ & > div {
4900
+ flex-wrap: wrap;
4901
+ gap: ${({ theme }) => theme.spaces[2]} ${({ theme }) => theme.spaces[4]};
4902
+ }
4903
+
4904
+ & > div > div > span {
4905
+ white-space: nowrap;
4906
+ }
4907
+ `;
4908
+ const useT = () => {
4909
+ const { formatMessage } = useIntl();
4910
+ return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
4911
+ };
4912
+ const AdminActivityPage = () => {
4913
+ const t = useT();
4914
+ const [{ query }, setQuery] = useQueryParams();
4915
+ const view = parseActivityPageQuery(query);
4916
+ const captionRef = useRef(null);
4917
+ const params = useMemo(
4918
+ () => buildSignInParams({
4919
+ adminId: view.adminId ?? void 0,
4920
+ event: view.event,
4921
+ period: view.period,
4922
+ page: view.page,
4923
+ pageSize: view.pageSize
4924
+ }),
4925
+ [view.adminId, view.event, view.period, view.page, view.pageSize]
4926
+ );
4927
+ const list = useEventList({
4928
+ path: `/${pluginId}/admin-activity/sign-ins`,
4929
+ params,
4930
+ logKey: "adminPanel.activity.page"
4931
+ });
4932
+ const pagination = list.meta?.pagination || { pageCount: 1, total: 0 };
4933
+ useEffect(() => {
4934
+ if (!list.loading && list.meta && view.page > pagination.pageCount) {
4935
+ setQuery({ page: String(pagination.pageCount) }, "push", true);
4936
+ }
4937
+ }, [list.loading, list.meta, view.page, pagination.pageCount, setQuery]);
4938
+ const recording = list.meta?.recording;
4939
+ const filtered = hasActivityPageFilters(view);
4940
+ const adminName = view.adminId !== null ? list.rows.find((row) => row.admin?.id === view.adminId)?.admin?.name || t("adminPanel.identity.placeholder", "Admin #{id}", { id: view.adminId }) : null;
4941
+ const setFilters = (next) => setQuery({ ...next, page: "1" });
4942
+ const clearFilters = () => {
4943
+ setQuery({ event: void 0, period: void 0, adminId: void 0, page: "1" });
4944
+ captionRef.current?.focus();
4945
+ };
4946
+ const labels = {
4947
+ all: t("adminPanel.activity.filter.allEvents", "All events"),
4948
+ succeeded: t("adminPanel.activity.filter.succeeded", "Sign-ins"),
4949
+ failed: t("adminPanel.activity.filter.failed", "Failed and locked out"),
4950
+ "signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs"),
4951
+ changes: t("adminPanel.activity.filter.changes", "Settings and log access")
4952
+ };
4953
+ const title = t("adminPanel.activity.page.title", "Security activity");
4954
+ const total = pagination.total;
4955
+ return /* @__PURE__ */ jsx(
4956
+ PageShell,
4957
+ {
4958
+ headingId: "magic-sessionmanager-admin-activity-title",
4959
+ title,
4960
+ subtitle: t(
4961
+ "adminPanel.activity.page.subtitle",
4962
+ "Sign-ins, failed attempts, lockouts and sign-outs of every admin, plus settings changes, reads of this log with an API token and retention runs. Newest first."
4963
+ ),
4964
+ navigationAction: /* @__PURE__ */ jsx(BackButton, { fallback: SESSION_VIEW_PATHS.admins }),
4965
+ children: /* @__PURE__ */ jsx(
4966
+ EventList,
4967
+ {
4968
+ list,
4969
+ filters: /* @__PURE__ */ jsxs(Fragment, { children: [
4970
+ /* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(
4971
+ SingleSelect,
4972
+ {
4973
+ size: "S",
4974
+ "aria-label": t("adminPanel.activity.filter.event", "Event"),
4975
+ value: view.event,
4976
+ onChange: (next) => setFilters({ event: String(next) === "all" ? void 0 : String(next) }),
4977
+ children: ALL_ADMINS_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsx(SingleSelectOption, { value: option, children: labels[option] }, option))
4978
+ }
4979
+ ) }),
4980
+ /* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(
4981
+ PeriodSelect,
4982
+ {
4983
+ value: view.period,
4984
+ onChange: (next) => setFilters({ period: next === "30" ? void 0 : next })
4985
+ }
4986
+ ) }),
4987
+ view.adminId !== null ? /* @__PURE__ */ jsx(
4988
+ Tag,
4989
+ {
4990
+ icon: /* @__PURE__ */ jsx(Cross, { "aria-hidden": "true" }),
4991
+ label: t("adminPanel.activity.page.removeAdmin", "Show all admins again"),
4992
+ onClick: () => setFilters({ adminId: void 0 }),
4993
+ "data-admin-filter": view.adminId,
4994
+ children: t("adminPanel.activity.page.adminFilter", "Admin: {name}", { name: adminName })
4995
+ }
4996
+ ) : null
4997
+ ] }),
4998
+ notice: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
4999
+ recording && !recording.signIns ? /* @__PURE__ */ jsx(RecordingOff, { children: t(
5000
+ "adminPanel.activity.signIns.off",
5001
+ "Sign-in history is turned off. New sign-ins are not recorded."
5002
+ ) }) : null,
5003
+ /* @__PURE__ */ jsx(
5004
+ Typography,
5005
+ {
5006
+ ref: captionRef,
5007
+ tabIndex: -1,
5008
+ variant: "pi",
5009
+ textColor: "neutral600",
5010
+ "aria-live": "polite",
5011
+ "data-activity-caption": "",
5012
+ children: t(
5013
+ "adminPanel.activity.page.caption",
5014
+ "{total, plural, =0 {No events} one {# event} other {# events}}",
5015
+ { total }
5016
+ )
5017
+ }
5018
+ )
5019
+ ] }),
5020
+ empty: /* @__PURE__ */ jsx(
5021
+ EmptyStateLayout,
5022
+ {
5023
+ icon: /* @__PURE__ */ jsx(EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
5024
+ content: filtered ? t("adminPanel.activity.page.noResults", "No events match these filters.") : t("adminPanel.activity.recent.empty", "No events recorded yet."),
5025
+ action: filtered ? /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: clearFilters, children: t("adminPanel.noResults.reset", "Clear filters") }) : null
5026
+ }
5027
+ ),
5028
+ renderList: (rows) => /* @__PURE__ */ jsx(
5029
+ SignInEventTable,
5030
+ {
5031
+ rows,
5032
+ label: title,
5033
+ showAdmin: true,
5034
+ busy: list.loading,
5035
+ detailsAction: (row, close) => row.admin && row.admin.id !== view.adminId ? /* @__PURE__ */ jsx(
5036
+ Button,
5037
+ {
5038
+ variant: "secondary",
5039
+ onClick: () => {
5040
+ close();
5041
+ setFilters({ adminId: String(row.admin.id) });
5042
+ },
5043
+ children: t("adminPanel.activity.page.onlyAdmin", "Show only events of {name}", {
5044
+ name: row.admin.name
5045
+ })
5046
+ }
5047
+ ) : null
5048
+ }
5049
+ ),
5050
+ toCsv: buildSignInCsv,
5051
+ fileName: "admin-security-activity",
5052
+ exportLabel: t(
5053
+ "adminPanel.activity.page.export",
5054
+ "Export the security activity with these filters as CSV"
5055
+ ),
5056
+ footer: /* @__PURE__ */ jsx(PaginationTargets, { children: /* @__PURE__ */ jsxs(
5057
+ Pagination.Root,
5058
+ {
5059
+ pageCount: pagination.pageCount,
5060
+ total: pagination.total,
5061
+ defaultPageSize: EVENT_PAGE_SIZE,
5062
+ children: [
5063
+ /* @__PURE__ */ jsx(Pagination.PageSize, { options: [...ACTIVITY_PAGE_SIZE_OPTIONS] }),
5064
+ /* @__PURE__ */ jsx(Pagination.Links, {})
5065
+ ]
5066
+ }
5067
+ ) })
5068
+ }
5069
+ )
5070
+ }
5071
+ );
5072
+ };
4111
5073
  const App = () => {
4112
5074
  return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions.access, children: /* @__PURE__ */ jsxs(Routes, { children: [
4113
5075
  /* @__PURE__ */ jsx(Route, { index: true, element: /* @__PURE__ */ jsx(HomePage, {}) }),
@@ -4118,6 +5080,13 @@ const App = () => {
4118
5080
  element: /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions.adminSessionsRead, children: /* @__PURE__ */ jsx(AdminPanelPage, {}) })
4119
5081
  }
4120
5082
  ),
5083
+ /* @__PURE__ */ jsx(
5084
+ Route,
5085
+ {
5086
+ path: "admin-panel/activity",
5087
+ element: /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions.adminSessionsRead, children: /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions.adminActivityRead, children: /* @__PURE__ */ jsx(AdminActivityPage, {}) }) })
5088
+ }
5089
+ ),
4121
5090
  /* @__PURE__ */ jsx(Route, { path: "*", element: /* @__PURE__ */ jsx(HomePage, {}) })
4122
5091
  ] }) });
4123
5092
  };