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