strapi-plugin-magic-sessionmanager 4.14.3 → 4.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/README.md +216 -85
- package/dist/admin/{Analytics-CFEgpg-G.mjs → Analytics-D4gsVwL0.mjs} +1 -1
- package/dist/admin/{Analytics-DSpn7W5A.js → Analytics-me4qzS0I.js} +1 -1
- package/dist/admin/{App-BBne8xI6.mjs → App-BJwtFWxl.mjs} +921 -106
- package/dist/admin/{App-UlRrLKcx.js → App-BTG-2Q26.js} +920 -105
- package/dist/admin/{OnlineUsersWidget-GFcYyZ9L.js → OnlineUsersWidget-DYS3Vy1Q.js} +1 -1
- package/dist/admin/{OnlineUsersWidget-C3YMTEGD.mjs → OnlineUsersWidget-Yd283YDy.mjs} +1 -1
- package/dist/admin/{Settings-BbUNvjno.mjs → Settings-DIlvfdjZ.mjs} +427 -83
- package/dist/admin/{Settings-DVhW9XHB.js → Settings-TPZ9_75s.js} +425 -81
- package/dist/admin/{de-B0CBR1Dw.js → de-BuMw1gBJ.js} +130 -8
- package/dist/admin/{de-BlKn1pSD.mjs → de-DB9ldYwN.mjs} +130 -8
- package/dist/admin/{en-IT0YTY8f.mjs → en-BbLMPQB3.mjs} +130 -8
- package/dist/admin/{en-D0ZGIIjz.js → en-BqGhOJDy.js} +130 -8
- package/dist/admin/{es-CWee-XCR.js → es-BaIeckl9.js} +130 -8
- package/dist/admin/{es-BCGzaaCh.mjs → es-C5iaiE9G.mjs} +130 -8
- package/dist/admin/{fr-xBIH4Byq.mjs → fr-BEvBUCwI.mjs} +130 -8
- package/dist/admin/{fr-rQS1M7jE.js → fr-D1YKyTex.js} +130 -8
- package/dist/admin/{index-1KmiZSfy.js → index-CgZiLcJ1.js} +13 -10
- package/dist/admin/{index-MOJkFXcZ.mjs → index-DUESEUaO.mjs} +13 -10
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-DWDeIDVa.mjs → pt-DeDih9cR.mjs} +130 -8
- package/dist/admin/{pt-C-yTLhnS.js → pt-DtnW-s0V.js} +130 -8
- package/dist/admin/riskData-BVs9GpgD.js +26 -0
- package/dist/admin/riskData-CI1gm2yI.mjs +27 -0
- package/dist/server/index.js +2500 -299
- package/dist/server/index.mjs +2500 -299
- package/package.json +1 -1
- package/scripts/geoip-updater.cjs +58 -15
|
@@ -3,11 +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-DUESEUaO.mjs";
|
|
11
|
+
import { i as isRiskSource, R as RISK_SETTINGS_PATH } from "./riskData-CI1gm2yI.mjs";
|
|
12
|
+
import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
|
|
11
13
|
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
12
14
|
const { formatMessage } = useIntl();
|
|
13
15
|
const key = reason || getSessionEndReason(session);
|
|
@@ -301,16 +303,19 @@ function normalizeGeoData(geo, fallback = {}) {
|
|
|
301
303
|
const city = presentText(geo.city);
|
|
302
304
|
const timezone = presentText(geo.timezone);
|
|
303
305
|
if (!country && !city && !timezone) return null;
|
|
306
|
+
const riskSource = isRiskSource(geo.riskSource) ? geo.riskSource : null;
|
|
304
307
|
const rawScore = typeof geo.securityScore === "number" ? geo.securityScore : fallback?.securityScore;
|
|
305
|
-
const securityScore = typeof rawScore === "number" && Number.isFinite(rawScore) ? rawScore : null;
|
|
308
|
+
const securityScore = riskSource && typeof rawScore === "number" && Number.isFinite(rawScore) ? rawScore : null;
|
|
306
309
|
return {
|
|
307
310
|
country,
|
|
308
311
|
city,
|
|
309
312
|
timezone,
|
|
313
|
+
riskSource,
|
|
310
314
|
securityScore,
|
|
311
|
-
riskLevel: normalizeRiskLevel(geo.riskLevel),
|
|
312
|
-
isVpn: booleanOrNull(geo.isVpn),
|
|
313
|
-
isProxy: booleanOrNull(geo.isProxy)
|
|
315
|
+
riskLevel: riskSource ? normalizeRiskLevel(geo.riskLevel) : "",
|
|
316
|
+
isVpn: riskSource === "anonymous-ip" ? booleanOrNull(geo.isVpn) : null,
|
|
317
|
+
isProxy: riskSource === "anonymous-ip" ? booleanOrNull(geo.isProxy) : null,
|
|
318
|
+
isHosting: riskSource ? booleanOrNull(geo.isHosting) : null
|
|
314
319
|
};
|
|
315
320
|
}
|
|
316
321
|
function getStoredGeoData(session) {
|
|
@@ -328,6 +333,7 @@ function getStoredGeoData(session) {
|
|
|
328
333
|
riskLevel: _ignoredLevel,
|
|
329
334
|
isVpn: _ignoredVpn,
|
|
330
335
|
isProxy: _ignoredProxy,
|
|
336
|
+
isHosting: _ignoredHosting,
|
|
331
337
|
...facts
|
|
332
338
|
} = geoLocation;
|
|
333
339
|
return normalizeGeoData(facts, { securityScore: session?.securityScore });
|
|
@@ -571,27 +577,42 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
|
|
|
571
577
|
};
|
|
572
578
|
const yesNoText = (value) => typeof value === "boolean" ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: value ? t("common.yes", "Yes") : t("common.no", "No") }) : void 0;
|
|
573
579
|
const notStoredForPast = /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: t("modal.security.notStored", "Not stored for past sign-ins") });
|
|
574
|
-
const score = typeof geo?.securityScore === "number" ? geo.securityScore :
|
|
575
|
-
const
|
|
580
|
+
const score = typeof geo?.securityScore === "number" ? geo.securityScore : null;
|
|
581
|
+
const riskUnavailable = Boolean(geo) && !geo.riskSource;
|
|
582
|
+
const riskMessage = liveGeo?.riskSource ? RISK_LEVEL_MESSAGES[liveGeo.riskLevel] : null;
|
|
583
|
+
const notAvailable = /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: t("modal.security.riskUnavailable", "Not available") });
|
|
576
584
|
const locationItems = [
|
|
577
585
|
{ id: "country", label: t("modal.security.country", "Country"), value: geo?.country },
|
|
578
586
|
{ id: "city", label: t("modal.security.city", "City"), value: geo?.city },
|
|
579
587
|
{ id: "timezone", label: t("modal.security.timezone", "Time zone"), value: geo?.timezone },
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
588
|
+
...riskUnavailable ? [
|
|
589
|
+
{
|
|
590
|
+
id: "riskData",
|
|
591
|
+
label: t("modal.security.riskData", "VPN, proxy and security score"),
|
|
592
|
+
render: notAvailable
|
|
593
|
+
}
|
|
594
|
+
] : [
|
|
595
|
+
{
|
|
596
|
+
id: "score",
|
|
597
|
+
label: t("modal.security.score", "Security score"),
|
|
598
|
+
value: score === null ? null : t("modal.security.scoreValue", "{score}/100", { score })
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
id: "vpn",
|
|
602
|
+
label: t("modal.security.vpn", "VPN"),
|
|
603
|
+
render: liveGeo ? yesNoText(liveGeo.isVpn) ?? notAvailable : storedGeo ? notStoredForPast : void 0
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
id: "proxy",
|
|
607
|
+
label: t("modal.security.proxy", "Proxy"),
|
|
608
|
+
render: liveGeo ? yesNoText(liveGeo.isProxy) ?? notAvailable : storedGeo ? notStoredForPast : void 0
|
|
609
|
+
},
|
|
610
|
+
liveGeo ? {
|
|
611
|
+
id: "hosting",
|
|
612
|
+
label: t("modal.security.hosting", "Hosting network"),
|
|
613
|
+
render: yesNoText(liveGeo.isHosting)
|
|
614
|
+
} : null
|
|
615
|
+
],
|
|
595
616
|
riskMessage ? {
|
|
596
617
|
id: "risk",
|
|
597
618
|
label: t("modal.security.riskLevel", "Risk level"),
|
|
@@ -710,10 +731,23 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
|
|
|
710
731
|
) }),
|
|
711
732
|
/* @__PURE__ */ jsxs(DetailSection, { title: t("modal.section.security", "Location and security"), children: [
|
|
712
733
|
hasLocationData ? /* @__PURE__ */ jsx(PropertyList, { items: locationItems }) : null,
|
|
713
|
-
score !== null ? /* @__PURE__ */
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
734
|
+
score !== null ? /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", "data-score-note": "", children: [
|
|
735
|
+
t(
|
|
736
|
+
"modal.security.scoreNote",
|
|
737
|
+
"Higher is safer. Below 70 can trigger a suspicious-sign-in email and below 50 a rejection, if those settings are on."
|
|
738
|
+
),
|
|
739
|
+
geo?.riskSource === "asn-heuristic" ? ` ${t(
|
|
740
|
+
"modal.security.asnHeuristicNote",
|
|
741
|
+
"From the ASN heuristic: it only recognises large hosting and cloud networks, not VPNs, proxies or Tor."
|
|
742
|
+
)}` : null
|
|
743
|
+
] }) : null,
|
|
744
|
+
riskUnavailable ? /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-risk-unavailable": "", children: [
|
|
745
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
746
|
+
"modal.security.riskUnavailableNote",
|
|
747
|
+
"Needs a risk data source. Location data alone cannot tell VPNs, proxies or Tor apart, so no score was calculated."
|
|
748
|
+
) }),
|
|
749
|
+
/* @__PURE__ */ jsx(TargetLink, { tag: NavLink, to: RISK_SETTINGS_PATH, children: t("modal.security.riskSetup", "Set up risk data") })
|
|
750
|
+
] }) : null,
|
|
717
751
|
lookupControls
|
|
718
752
|
] }),
|
|
719
753
|
/* @__PURE__ */ jsx(Accordion.Root, { collapsible: true, size: "S", children: /* @__PURE__ */ jsxs(Accordion.Item, { value: "technical", children: [
|
|
@@ -2524,14 +2558,17 @@ function getSignOutErrorMessage(error) {
|
|
|
2524
2558
|
};
|
|
2525
2559
|
}
|
|
2526
2560
|
const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
|
|
2561
|
+
const keepActionKeys = (event) => {
|
|
2562
|
+
if (shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2563
|
+
};
|
|
2527
2564
|
const SHRINKING_ADMIN_CELL = { maxWidth: 0, width: "34%" };
|
|
2528
2565
|
const SHRINKING_ROLES_CELL = { maxWidth: 0, width: "22%" };
|
|
2529
|
-
const useT$
|
|
2566
|
+
const useT$3 = () => {
|
|
2530
2567
|
const { formatMessage } = useIntl();
|
|
2531
2568
|
return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
|
|
2532
2569
|
};
|
|
2533
2570
|
const AdminIdentity = ({ admin }) => {
|
|
2534
|
-
const t = useT$
|
|
2571
|
+
const t = useT$3();
|
|
2535
2572
|
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children: [
|
|
2536
2573
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
|
|
2537
2574
|
/* @__PURE__ */ jsx(
|
|
@@ -2551,13 +2588,13 @@ const AdminIdentity = ({ admin }) => {
|
|
|
2551
2588
|
] });
|
|
2552
2589
|
};
|
|
2553
2590
|
const AdminRoles = ({ admin }) => {
|
|
2554
|
-
const t = useT$
|
|
2591
|
+
const t = useT$3();
|
|
2555
2592
|
const names = (admin.roles || []).map((role) => role.name).filter(Boolean);
|
|
2556
2593
|
const text = names.length ? names.join(", ") : t("adminPanel.roles.none", "No role");
|
|
2557
2594
|
return /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", ellipsis: true, title: text, children: text });
|
|
2558
2595
|
};
|
|
2559
2596
|
const AdminStatus = ({ admin }) => {
|
|
2560
|
-
const t = useT$
|
|
2597
|
+
const t = useT$3();
|
|
2561
2598
|
const status = getAdminStatusPresentation(admin);
|
|
2562
2599
|
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-admin-status": status.key, children: [
|
|
2563
2600
|
/* @__PURE__ */ jsx(Badge, { ...getBadgeColors(status.tone), children: t(status.label.messageId, status.label.defaultMessage) }),
|
|
@@ -2572,7 +2609,7 @@ const AdminTable = ({
|
|
|
2572
2609
|
onSignOutEverywhere,
|
|
2573
2610
|
busy
|
|
2574
2611
|
}) => {
|
|
2575
|
-
const t = useT$
|
|
2612
|
+
const t = useT$3();
|
|
2576
2613
|
return /* @__PURE__ */ jsx(Box, { background: "neutral0", hasRadius: true, shadow: "tableShadow", "data-admin-table": "", children: /* @__PURE__ */ jsxs(
|
|
2577
2614
|
Table,
|
|
2578
2615
|
{
|
|
@@ -2593,7 +2630,7 @@ const AdminTable = ({
|
|
|
2593
2630
|
/* @__PURE__ */ jsx(Td, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsx(AdminRoles, { admin }) }),
|
|
2594
2631
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(AdminStatus, { admin }) }),
|
|
2595
2632
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(LastActive, { value: admin.lastActiveAt }) }),
|
|
2596
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(RowActions, { children: [
|
|
2633
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(RowActions, { onKeyDown: keepActionKeys, children: [
|
|
2597
2634
|
/* @__PURE__ */ jsx(
|
|
2598
2635
|
IconButton,
|
|
2599
2636
|
{
|
|
@@ -2626,7 +2663,7 @@ const AdminTable = ({
|
|
|
2626
2663
|
) });
|
|
2627
2664
|
};
|
|
2628
2665
|
const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywhere }) => {
|
|
2629
|
-
const t = useT$
|
|
2666
|
+
const t = useT$3();
|
|
2630
2667
|
return /* @__PURE__ */ jsx(
|
|
2631
2668
|
Flex,
|
|
2632
2669
|
{
|
|
@@ -2694,6 +2731,743 @@ const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywh
|
|
|
2694
2731
|
}
|
|
2695
2732
|
);
|
|
2696
2733
|
};
|
|
2734
|
+
const SIGN_IN_FILTER_OPTIONS = Object.freeze(["all", "succeeded", "failed", "signed-out"]);
|
|
2735
|
+
const ACTIVITY_ACTION_OPTIONS = Object.freeze([
|
|
2736
|
+
"all",
|
|
2737
|
+
"view",
|
|
2738
|
+
"create",
|
|
2739
|
+
"update",
|
|
2740
|
+
"publish",
|
|
2741
|
+
"unpublish",
|
|
2742
|
+
"discard",
|
|
2743
|
+
"delete",
|
|
2744
|
+
"clone"
|
|
2745
|
+
]);
|
|
2746
|
+
const PERIOD_OPTIONS = Object.freeze(["1", "7", "30", "90", "all"]);
|
|
2747
|
+
const EVENT_PAGE_SIZE = 20;
|
|
2748
|
+
const MAX_EVENT_EXPORT_ROWS = 1e4;
|
|
2749
|
+
function periodStart(period, now = /* @__PURE__ */ new Date()) {
|
|
2750
|
+
const days = Number.parseInt(period, 10);
|
|
2751
|
+
if (!Number.isInteger(days) || days <= 0) return void 0;
|
|
2752
|
+
return new Date(now.getTime() - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
2753
|
+
}
|
|
2754
|
+
function buildSignInParams(filters, now) {
|
|
2755
|
+
const params = {
|
|
2756
|
+
page: filters.page || 1,
|
|
2757
|
+
pageSize: filters.pageSize || EVENT_PAGE_SIZE,
|
|
2758
|
+
event: SIGN_IN_FILTER_OPTIONS.includes(filters.event) ? filters.event : "all"
|
|
2759
|
+
};
|
|
2760
|
+
if (filters.adminId) params.adminId = String(filters.adminId);
|
|
2761
|
+
const from = periodStart(filters.period || "all", now);
|
|
2762
|
+
if (from) params.from = from;
|
|
2763
|
+
return params;
|
|
2764
|
+
}
|
|
2765
|
+
function buildActivityParams(filters, now) {
|
|
2766
|
+
const params = {
|
|
2767
|
+
page: filters.page || 1,
|
|
2768
|
+
pageSize: filters.pageSize || EVENT_PAGE_SIZE,
|
|
2769
|
+
action: ACTIVITY_ACTION_OPTIONS.includes(filters.action) ? filters.action : "all"
|
|
2770
|
+
};
|
|
2771
|
+
if (filters.adminId) params.adminId = String(filters.adminId);
|
|
2772
|
+
if (filters.contentType && filters.contentType !== "all")
|
|
2773
|
+
params.contentType = filters.contentType;
|
|
2774
|
+
const from = periodStart(filters.period || "all", now);
|
|
2775
|
+
if (from) params.from = from;
|
|
2776
|
+
return params;
|
|
2777
|
+
}
|
|
2778
|
+
function toExportParams(params, cursor) {
|
|
2779
|
+
const { page: _page, pageSize: _pageSize, ...rest } = params;
|
|
2780
|
+
return cursor ? { ...rest, cursor } : rest;
|
|
2781
|
+
}
|
|
2782
|
+
const message = (messageId, defaultMessage) => ({ messageId, defaultMessage });
|
|
2783
|
+
const FAILURE_REASONS = Object.freeze({
|
|
2784
|
+
invalid_credentials: message(
|
|
2785
|
+
"adminPanel.activity.reason.invalidCredentials",
|
|
2786
|
+
"Wrong email or password"
|
|
2787
|
+
),
|
|
2788
|
+
account_inactive: message("adminPanel.activity.reason.accountInactive", "Account is deactivated"),
|
|
2789
|
+
login_not_allowed: message("adminPanel.activity.reason.notAllowed", "Sign-in is not allowed"),
|
|
2790
|
+
rate_limited: message("adminPanel.activity.reason.rateLimited", "Too many attempts")
|
|
2791
|
+
});
|
|
2792
|
+
function getSignInEventPresentation(row) {
|
|
2793
|
+
switch (row?.event) {
|
|
2794
|
+
case "admin.sign-in":
|
|
2795
|
+
return {
|
|
2796
|
+
key: "sign-in",
|
|
2797
|
+
tone: "success",
|
|
2798
|
+
label: message("adminPanel.activity.event.signIn", "Signed in"),
|
|
2799
|
+
detail: row.reason === "registration" ? message("adminPanel.activity.reason.registration", "First sign-in after registration") : row.reason === "password_reset" ? message(
|
|
2800
|
+
"adminPanel.activity.reason.passwordReset",
|
|
2801
|
+
"Signed in after a password reset"
|
|
2802
|
+
) : null
|
|
2803
|
+
};
|
|
2804
|
+
case "admin.sign-in.failed":
|
|
2805
|
+
return {
|
|
2806
|
+
key: "failed",
|
|
2807
|
+
tone: "warning",
|
|
2808
|
+
label: message("adminPanel.activity.event.failed", "Sign-in failed"),
|
|
2809
|
+
detail: FAILURE_REASONS[row.reason] || null
|
|
2810
|
+
};
|
|
2811
|
+
case "admin.lockout":
|
|
2812
|
+
return {
|
|
2813
|
+
key: "lockout",
|
|
2814
|
+
tone: "warning",
|
|
2815
|
+
label: message("adminPanel.activity.event.lockout", "Locked out"),
|
|
2816
|
+
detail: FAILURE_REASONS.rate_limited
|
|
2817
|
+
};
|
|
2818
|
+
case "admin.sign-out":
|
|
2819
|
+
return {
|
|
2820
|
+
key: "sign-out",
|
|
2821
|
+
tone: "neutral",
|
|
2822
|
+
label: message("adminPanel.activity.event.signOut", "Signed out"),
|
|
2823
|
+
detail: null
|
|
2824
|
+
};
|
|
2825
|
+
case "admin.session.revoked":
|
|
2826
|
+
return {
|
|
2827
|
+
key: "revoked",
|
|
2828
|
+
tone: "neutral",
|
|
2829
|
+
label: message("adminPanel.activity.event.revoked", "Signed out by an admin"),
|
|
2830
|
+
detail: row.scope === "one_browser" ? message("adminPanel.activity.scope.oneBrowser", "One browser") : message("adminPanel.activity.scope.everywhere", "Every browser")
|
|
2831
|
+
};
|
|
2832
|
+
default:
|
|
2833
|
+
return {
|
|
2834
|
+
key: "other",
|
|
2835
|
+
tone: "neutral",
|
|
2836
|
+
label: message("adminPanel.activity.event.other", "Security event"),
|
|
2837
|
+
detail: null
|
|
2838
|
+
};
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
function getSessionStatePresentation(session) {
|
|
2842
|
+
switch (session?.state) {
|
|
2843
|
+
case "active":
|
|
2844
|
+
return {
|
|
2845
|
+
tone: "success",
|
|
2846
|
+
label: message("adminPanel.activity.session.active", "Still signed in")
|
|
2847
|
+
};
|
|
2848
|
+
case "signed-out":
|
|
2849
|
+
return {
|
|
2850
|
+
tone: "neutral",
|
|
2851
|
+
label: message("adminPanel.activity.session.signedOut", "Signed out")
|
|
2852
|
+
};
|
|
2853
|
+
case "ended":
|
|
2854
|
+
return {
|
|
2855
|
+
tone: "neutral",
|
|
2856
|
+
label: message("adminPanel.activity.session.ended", "Session ended")
|
|
2857
|
+
};
|
|
2858
|
+
default:
|
|
2859
|
+
return null;
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
const ACTIVITY_ACTION_LABELS = Object.freeze({
|
|
2863
|
+
all: message("adminPanel.activity.action.all", "All actions"),
|
|
2864
|
+
view: message("adminPanel.activity.action.view", "Opened"),
|
|
2865
|
+
create: message("adminPanel.activity.action.create", "Created"),
|
|
2866
|
+
update: message("adminPanel.activity.action.update", "Edited"),
|
|
2867
|
+
publish: message("adminPanel.activity.action.publish", "Published"),
|
|
2868
|
+
unpublish: message("adminPanel.activity.action.unpublish", "Unpublished"),
|
|
2869
|
+
discard: message("adminPanel.activity.action.discard", "Discarded draft"),
|
|
2870
|
+
delete: message("adminPanel.activity.action.delete", "Deleted"),
|
|
2871
|
+
clone: message("adminPanel.activity.action.clone", "Duplicated")
|
|
2872
|
+
});
|
|
2873
|
+
function getActivityTone(action) {
|
|
2874
|
+
if (action === "publish") return "success";
|
|
2875
|
+
if (action === "delete") return "warning";
|
|
2876
|
+
return "neutral";
|
|
2877
|
+
}
|
|
2878
|
+
function getEntryPath(row) {
|
|
2879
|
+
const type = row?.contentType;
|
|
2880
|
+
if (!type?.exists || row.action === "delete") return null;
|
|
2881
|
+
const uid = encodeURIComponent(type.uid);
|
|
2882
|
+
const locale = row.entry?.locale ? `?plugins[i18n][locale]=${encodeURIComponent(row.entry.locale)}` : "";
|
|
2883
|
+
if (type.kind === "single") return `/content-manager/single-types/${uid}${locale}`;
|
|
2884
|
+
if (!row.entry?.documentId) return null;
|
|
2885
|
+
return `/content-manager/collection-types/${uid}/${encodeURIComponent(row.entry.documentId)}${locale}`;
|
|
2886
|
+
}
|
|
2887
|
+
const SIGN_IN_CSV_HEADERS = Object.freeze([
|
|
2888
|
+
"Time",
|
|
2889
|
+
"Event",
|
|
2890
|
+
"Reason",
|
|
2891
|
+
"Admin",
|
|
2892
|
+
"Admin ID",
|
|
2893
|
+
"IP Address",
|
|
2894
|
+
"IP Anonymized",
|
|
2895
|
+
"Country",
|
|
2896
|
+
"City",
|
|
2897
|
+
"Browser",
|
|
2898
|
+
"OS",
|
|
2899
|
+
"Device",
|
|
2900
|
+
"Session",
|
|
2901
|
+
"Signed Out By"
|
|
2902
|
+
]);
|
|
2903
|
+
const ACTIVITY_CSV_HEADERS = Object.freeze([
|
|
2904
|
+
"Time",
|
|
2905
|
+
"Action",
|
|
2906
|
+
"Admin",
|
|
2907
|
+
"Admin ID",
|
|
2908
|
+
"Content Type",
|
|
2909
|
+
"Content Type UID",
|
|
2910
|
+
"Document ID",
|
|
2911
|
+
"Locale",
|
|
2912
|
+
"Title",
|
|
2913
|
+
"Entries"
|
|
2914
|
+
]);
|
|
2915
|
+
const toCsv = (headers, rows) => [headers, ...rows].map((cells) => cells.map(escapeCsvValue).join(",")).join("\n");
|
|
2916
|
+
function buildSignInCsv(rows) {
|
|
2917
|
+
return toCsv(
|
|
2918
|
+
SIGN_IN_CSV_HEADERS,
|
|
2919
|
+
rows.map((row) => [
|
|
2920
|
+
row.at || "",
|
|
2921
|
+
row.event || "",
|
|
2922
|
+
row.reason || row.scope || "",
|
|
2923
|
+
row.admin?.name || "",
|
|
2924
|
+
row.admin?.id ?? "",
|
|
2925
|
+
row.ipAddress || "",
|
|
2926
|
+
row.ipAnonymized ? "yes" : "no",
|
|
2927
|
+
row.location?.country || "",
|
|
2928
|
+
row.location?.city || "",
|
|
2929
|
+
row.browser || "",
|
|
2930
|
+
row.os || "",
|
|
2931
|
+
row.deviceType || "",
|
|
2932
|
+
row.session?.state || "",
|
|
2933
|
+
row.actor?.name || ""
|
|
2934
|
+
])
|
|
2935
|
+
);
|
|
2936
|
+
}
|
|
2937
|
+
function buildActivityCsv(rows) {
|
|
2938
|
+
return toCsv(
|
|
2939
|
+
ACTIVITY_CSV_HEADERS,
|
|
2940
|
+
rows.map((row) => [
|
|
2941
|
+
row.at || "",
|
|
2942
|
+
row.action || "",
|
|
2943
|
+
row.admin?.name || "",
|
|
2944
|
+
row.admin?.id ?? "",
|
|
2945
|
+
row.contentType?.name || "",
|
|
2946
|
+
row.contentType?.uid || "",
|
|
2947
|
+
row.entry?.documentId || "",
|
|
2948
|
+
row.entry?.locale || "",
|
|
2949
|
+
row.entry?.title || "",
|
|
2950
|
+
row.entry?.count ?? ""
|
|
2951
|
+
])
|
|
2952
|
+
);
|
|
2953
|
+
}
|
|
2954
|
+
const useT$2 = () => {
|
|
2955
|
+
const { formatMessage } = useIntl();
|
|
2956
|
+
return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
|
|
2957
|
+
};
|
|
2958
|
+
const TargetTextButton = styled(TextButton)`
|
|
2959
|
+
min-height: 3.2rem;
|
|
2960
|
+
`;
|
|
2961
|
+
const EventItem = ({ children, id, kind }) => /* @__PURE__ */ jsx(
|
|
2962
|
+
Box,
|
|
2963
|
+
{
|
|
2964
|
+
tag: "li",
|
|
2965
|
+
background: "neutral0",
|
|
2966
|
+
borderColor: "neutral150",
|
|
2967
|
+
hasRadius: true,
|
|
2968
|
+
padding: 3,
|
|
2969
|
+
"data-event-row": kind,
|
|
2970
|
+
"data-event-id": id,
|
|
2971
|
+
children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children })
|
|
2972
|
+
}
|
|
2973
|
+
);
|
|
2974
|
+
const AdminName = ({ admin, onOpenAdmin }) => {
|
|
2975
|
+
const t = useT$2();
|
|
2976
|
+
if (!admin) {
|
|
2977
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: t("adminPanel.activity.unknownAccount", "Unknown account") });
|
|
2978
|
+
}
|
|
2979
|
+
if (!onOpenAdmin) {
|
|
2980
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: admin.name });
|
|
2981
|
+
}
|
|
2982
|
+
return /* @__PURE__ */ jsx(
|
|
2983
|
+
TargetTextButton,
|
|
2984
|
+
{
|
|
2985
|
+
onClick: (event) => onOpenAdmin(admin, event.currentTarget),
|
|
2986
|
+
"aria-label": t("adminPanel.activity.openAdmin", "Open the details of {name}", {
|
|
2987
|
+
name: admin.name
|
|
2988
|
+
}),
|
|
2989
|
+
children: admin.name
|
|
2990
|
+
}
|
|
2991
|
+
);
|
|
2992
|
+
};
|
|
2993
|
+
const SignInEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
|
|
2994
|
+
const t = useT$2();
|
|
2995
|
+
const event = getSignInEventPresentation(row);
|
|
2996
|
+
const session = getSessionStatePresentation(row.session);
|
|
2997
|
+
const facts = [];
|
|
2998
|
+
if (row.ipAddress) {
|
|
2999
|
+
facts.push(
|
|
3000
|
+
row.ipAnonymized ? t("adminPanel.activity.ipAnonymized", "{ip} (anonymised)", { ip: row.ipAddress }) : row.ipAddress
|
|
3001
|
+
);
|
|
3002
|
+
}
|
|
3003
|
+
const place = [row.location?.city, row.location?.country].filter(Boolean).join(", ");
|
|
3004
|
+
if (place) facts.push(place);
|
|
3005
|
+
if (row.browser && row.os) {
|
|
3006
|
+
facts.push(
|
|
3007
|
+
t("adminPanel.activity.browserOnOs", "{browser} on {os}", {
|
|
3008
|
+
browser: row.browser,
|
|
3009
|
+
os: row.os
|
|
3010
|
+
})
|
|
3011
|
+
);
|
|
3012
|
+
} else if (row.browser || row.os) {
|
|
3013
|
+
facts.push(row.browser || row.os);
|
|
3014
|
+
}
|
|
3015
|
+
if (row.actor)
|
|
3016
|
+
facts.push(t("adminPanel.activity.byAdmin", "by {name}", { name: row.actor.name }));
|
|
3017
|
+
return /* @__PURE__ */ jsxs(EventItem, { id: row.id, kind: event.key, children: [
|
|
3018
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
|
|
3019
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
|
|
3020
|
+
/* @__PURE__ */ jsx(Badge, { ...getBadgeColors(event.tone), children: t(event.label.messageId, event.label.defaultMessage) }),
|
|
3021
|
+
showAdmin ? /* @__PURE__ */ jsx(AdminName, { admin: row.admin, onOpenAdmin }) : null,
|
|
3022
|
+
event.detail ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(event.detail.messageId, event.detail.defaultMessage) }) : null
|
|
3023
|
+
] }),
|
|
3024
|
+
/* @__PURE__ */ jsx(LastActive, { value: row.at })
|
|
3025
|
+
] }),
|
|
3026
|
+
facts.length ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: facts.join(" · ") }) : null,
|
|
3027
|
+
session ? /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
|
|
3028
|
+
/* @__PURE__ */ jsx(Badge, { ...getBadgeColors(session.tone), children: t(session.label.messageId, session.label.defaultMessage) }),
|
|
3029
|
+
row.session?.endedAt ? /* @__PURE__ */ jsx(LastActive, { value: row.session.endedAt }) : null
|
|
3030
|
+
] }) : null
|
|
3031
|
+
] });
|
|
3032
|
+
};
|
|
3033
|
+
const ActivityEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
|
|
3034
|
+
const t = useT$2();
|
|
3035
|
+
const label = ACTIVITY_ACTION_LABELS[row.action] || ACTIVITY_ACTION_LABELS.view;
|
|
3036
|
+
const path = getEntryPath(row);
|
|
3037
|
+
const entryName = row.entry?.count !== null && row.entry?.count !== void 0 ? t("adminPanel.activity.entries", "{count, plural, one {# entry} other {# entries}}", {
|
|
3038
|
+
count: row.entry.count
|
|
3039
|
+
}) : row.entry?.title || row.entry?.documentId || row.contentType?.name || "";
|
|
3040
|
+
const facts = [row.contentType?.name];
|
|
3041
|
+
if (row.entry?.locale) facts.push(row.entry.locale);
|
|
3042
|
+
return /* @__PURE__ */ jsxs(EventItem, { id: row.id, kind: row.action, children: [
|
|
3043
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
|
|
3044
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
|
|
3045
|
+
/* @__PURE__ */ jsx(Badge, { ...getBadgeColors(getActivityTone(row.action)), children: t(label.messageId, label.defaultMessage) }),
|
|
3046
|
+
showAdmin ? /* @__PURE__ */ jsx(AdminName, { admin: row.admin, onOpenAdmin }) : null
|
|
3047
|
+
] }),
|
|
3048
|
+
/* @__PURE__ */ jsx(LastActive, { value: row.at })
|
|
3049
|
+
] }),
|
|
3050
|
+
/* @__PURE__ */ jsx(Box, { minWidth: 0, style: { overflowWrap: "anywhere" }, children: path ? /* @__PURE__ */ jsx(
|
|
3051
|
+
TargetLink$1,
|
|
3052
|
+
{
|
|
3053
|
+
tag: Link$1,
|
|
3054
|
+
to: path,
|
|
3055
|
+
"aria-label": t("adminPanel.activity.openEntry", "Open {entry} in the Content Manager", {
|
|
3056
|
+
entry: entryName
|
|
3057
|
+
}),
|
|
3058
|
+
children: entryName
|
|
3059
|
+
}
|
|
3060
|
+
) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: entryName }) }),
|
|
3061
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: facts.filter(Boolean).join(" · ") })
|
|
3062
|
+
] });
|
|
3063
|
+
};
|
|
3064
|
+
function useEventList({ path, params, logKey }) {
|
|
3065
|
+
const { get } = useFetchClient();
|
|
3066
|
+
const [rows, setRows] = useState([]);
|
|
3067
|
+
const [meta, setMeta] = useState(null);
|
|
3068
|
+
const [page, setPage] = useState(1);
|
|
3069
|
+
const [loading, setLoading] = useState(true);
|
|
3070
|
+
const [loadingMore, setLoadingMore] = useState(false);
|
|
3071
|
+
const [error, setError] = useState(false);
|
|
3072
|
+
const requestRef = useRef(0);
|
|
3073
|
+
const key = JSON.stringify(params);
|
|
3074
|
+
const load = useCallback(
|
|
3075
|
+
async (nextPage) => {
|
|
3076
|
+
const requestId = requestRef.current + 1;
|
|
3077
|
+
requestRef.current = requestId;
|
|
3078
|
+
if (nextPage === 1) setLoading(true);
|
|
3079
|
+
else setLoadingMore(true);
|
|
3080
|
+
try {
|
|
3081
|
+
const response = await get(path, { params: { ...JSON.parse(key), page: nextPage } });
|
|
3082
|
+
if (requestId !== requestRef.current) return;
|
|
3083
|
+
const body = response?.data || {};
|
|
3084
|
+
const data = Array.isArray(body.data) ? body.data : [];
|
|
3085
|
+
setRows((current) => nextPage === 1 ? data : [...current, ...data]);
|
|
3086
|
+
setMeta(body.meta || null);
|
|
3087
|
+
setPage(nextPage);
|
|
3088
|
+
setError(false);
|
|
3089
|
+
} catch (err) {
|
|
3090
|
+
if (requestId !== requestRef.current || isCancelledRequest(err)) return;
|
|
3091
|
+
setError(true);
|
|
3092
|
+
logSafeAdminError(logKey, err);
|
|
3093
|
+
} finally {
|
|
3094
|
+
if (requestId === requestRef.current) {
|
|
3095
|
+
setLoading(false);
|
|
3096
|
+
setLoadingMore(false);
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
},
|
|
3100
|
+
[get, path, key, logKey]
|
|
3101
|
+
);
|
|
3102
|
+
useEffect(() => {
|
|
3103
|
+
load(1);
|
|
3104
|
+
return () => {
|
|
3105
|
+
requestRef.current += 1;
|
|
3106
|
+
};
|
|
3107
|
+
}, [load]);
|
|
3108
|
+
const pagination = meta?.pagination;
|
|
3109
|
+
const hasMore = Boolean(pagination && page < pagination.pageCount);
|
|
3110
|
+
const exportAll = useCallback(async () => {
|
|
3111
|
+
const all = [];
|
|
3112
|
+
let cursor = null;
|
|
3113
|
+
do {
|
|
3114
|
+
const response = await get(`${path}/export`, {
|
|
3115
|
+
params: toExportParams(JSON.parse(key), cursor)
|
|
3116
|
+
});
|
|
3117
|
+
const body = response?.data || {};
|
|
3118
|
+
if (!Array.isArray(body.data)) throw new Error("Invalid export response");
|
|
3119
|
+
all.push(...body.data);
|
|
3120
|
+
cursor = typeof body.meta?.nextCursor === "string" ? body.meta.nextCursor : null;
|
|
3121
|
+
} while (cursor && all.length < MAX_EVENT_EXPORT_ROWS);
|
|
3122
|
+
return {
|
|
3123
|
+
rows: all.slice(0, MAX_EVENT_EXPORT_ROWS),
|
|
3124
|
+
capped: all.length > MAX_EVENT_EXPORT_ROWS || Boolean(cursor)
|
|
3125
|
+
};
|
|
3126
|
+
}, [get, path, key]);
|
|
3127
|
+
return {
|
|
3128
|
+
rows,
|
|
3129
|
+
meta,
|
|
3130
|
+
loading,
|
|
3131
|
+
loadingMore,
|
|
3132
|
+
error,
|
|
3133
|
+
hasMore,
|
|
3134
|
+
loadMore: () => load(page + 1),
|
|
3135
|
+
reload: () => load(1),
|
|
3136
|
+
exportAll
|
|
3137
|
+
};
|
|
3138
|
+
}
|
|
3139
|
+
function downloadCsv(content, name) {
|
|
3140
|
+
const blob = new Blob([content], { type: "text/csv;charset=utf-8;" });
|
|
3141
|
+
const url = URL.createObjectURL(blob);
|
|
3142
|
+
const link = document.createElement("a");
|
|
3143
|
+
link.href = url;
|
|
3144
|
+
link.download = `${name}-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`;
|
|
3145
|
+
link.click();
|
|
3146
|
+
window.setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
3147
|
+
}
|
|
3148
|
+
const ADMIN_ACTIVITY_SETTINGS_PATH = `/settings/${pluginId}/general?tab=admin-activity`;
|
|
3149
|
+
const useT$1 = () => {
|
|
3150
|
+
const { formatMessage } = useIntl();
|
|
3151
|
+
return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
|
|
3152
|
+
};
|
|
3153
|
+
const PeriodSelect = ({ value, onChange }) => {
|
|
3154
|
+
const t = useT$1();
|
|
3155
|
+
const labels = {
|
|
3156
|
+
1: t("adminPanel.activity.period.day", "Last 24 hours"),
|
|
3157
|
+
7: t("adminPanel.activity.period.week", "Last 7 days"),
|
|
3158
|
+
30: t("adminPanel.activity.period.month", "Last 30 days"),
|
|
3159
|
+
90: t("adminPanel.activity.period.quarter", "Last 90 days"),
|
|
3160
|
+
all: t("adminPanel.activity.period.all", "All kept events")
|
|
3161
|
+
};
|
|
3162
|
+
return /* @__PURE__ */ jsx(
|
|
3163
|
+
SingleSelect,
|
|
3164
|
+
{
|
|
3165
|
+
size: "S",
|
|
3166
|
+
"aria-label": t("adminPanel.activity.period.label", "Period"),
|
|
3167
|
+
value,
|
|
3168
|
+
onChange: (next) => onChange(String(next)),
|
|
3169
|
+
children: PERIOD_OPTIONS.map((option) => /* @__PURE__ */ jsx(SingleSelectOption, { value: option, children: labels[option] }, option))
|
|
3170
|
+
}
|
|
3171
|
+
);
|
|
3172
|
+
};
|
|
3173
|
+
const FilterSlot = ({ children }) => /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", minWidth: 0, flex: "1 1 18rem", children });
|
|
3174
|
+
const EventList = ({
|
|
3175
|
+
filters,
|
|
3176
|
+
notice,
|
|
3177
|
+
list,
|
|
3178
|
+
listLabel,
|
|
3179
|
+
emptyText,
|
|
3180
|
+
renderRow,
|
|
3181
|
+
toCsv: toCsv2,
|
|
3182
|
+
fileName,
|
|
3183
|
+
exportLabel
|
|
3184
|
+
}) => {
|
|
3185
|
+
const t = useT$1();
|
|
3186
|
+
const { toggleNotification } = useNotification();
|
|
3187
|
+
const [exporting, setExporting] = useState(false);
|
|
3188
|
+
const total = list.meta?.pagination?.total ?? 0;
|
|
3189
|
+
const handleExport = async () => {
|
|
3190
|
+
if (exporting) return;
|
|
3191
|
+
setExporting(true);
|
|
3192
|
+
try {
|
|
3193
|
+
const { rows, capped } = await list.exportAll();
|
|
3194
|
+
downloadCsv(toCsv2(rows), fileName);
|
|
3195
|
+
if (capped) {
|
|
3196
|
+
toggleNotification({
|
|
3197
|
+
type: "warning",
|
|
3198
|
+
message: t(
|
|
3199
|
+
"adminPanel.activity.export.capped",
|
|
3200
|
+
"The export contains the newest {limit, number} events. Narrow the filter to export the rest.",
|
|
3201
|
+
{ limit: MAX_EVENT_EXPORT_ROWS }
|
|
3202
|
+
)
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
} catch (err) {
|
|
3206
|
+
if (isCancelledRequest(err)) return;
|
|
3207
|
+
logSafeAdminError("adminPanel.activity.export", err);
|
|
3208
|
+
toggleNotification({
|
|
3209
|
+
type: "danger",
|
|
3210
|
+
message: t("adminPanel.activity.export.error", "The export could not be created.")
|
|
3211
|
+
});
|
|
3212
|
+
} finally {
|
|
3213
|
+
setExporting(false);
|
|
3214
|
+
}
|
|
3215
|
+
};
|
|
3216
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
|
|
3217
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
|
|
3218
|
+
/* @__PURE__ */ jsx(Flex, { gap: 2, wrap: "wrap", alignItems: "center", flex: "1 1 auto", minWidth: 0, children: filters }),
|
|
3219
|
+
/* @__PURE__ */ jsx(
|
|
3220
|
+
Button,
|
|
3221
|
+
{
|
|
3222
|
+
size: "S",
|
|
3223
|
+
variant: "tertiary",
|
|
3224
|
+
startIcon: /* @__PURE__ */ jsx(Download, {}),
|
|
3225
|
+
onClick: handleExport,
|
|
3226
|
+
loading: exporting,
|
|
3227
|
+
disabled: list.loading || total === 0,
|
|
3228
|
+
"aria-label": exportLabel,
|
|
3229
|
+
children: t("adminPanel.activity.export.csv", "Export CSV")
|
|
3230
|
+
}
|
|
3231
|
+
)
|
|
3232
|
+
] }),
|
|
3233
|
+
notice,
|
|
3234
|
+
list.loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("adminPanel.activity.loading", "Loading events") }) }) : null,
|
|
3235
|
+
!list.loading && list.error ? /* @__PURE__ */ jsx(
|
|
3236
|
+
PersistentAlert,
|
|
3237
|
+
{
|
|
3238
|
+
variant: "danger",
|
|
3239
|
+
action: /* @__PURE__ */ jsx(Button, { size: "S", variant: "secondary", onClick: list.reload, children: t("common.tryAgain", "Try again") }),
|
|
3240
|
+
children: t("adminPanel.activity.error", "The events could not be loaded.")
|
|
3241
|
+
}
|
|
3242
|
+
) : null,
|
|
3243
|
+
!list.loading && !list.error && list.rows.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", "data-event-empty": "", children: emptyText }) : null,
|
|
3244
|
+
list.rows.length > 0 ? /* @__PURE__ */ jsx(
|
|
3245
|
+
Flex,
|
|
3246
|
+
{
|
|
3247
|
+
tag: "ul",
|
|
3248
|
+
direction: "column",
|
|
3249
|
+
alignItems: "stretch",
|
|
3250
|
+
gap: 2,
|
|
3251
|
+
width: "100%",
|
|
3252
|
+
"aria-label": listLabel,
|
|
3253
|
+
children: list.rows.map((row) => renderRow(row))
|
|
3254
|
+
}
|
|
3255
|
+
) : null,
|
|
3256
|
+
list.hasMore ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: list.loadMore, loading: list.loadingMore, children: t("adminPanel.activity.showMore", "Show more") }) }) : null
|
|
3257
|
+
] });
|
|
3258
|
+
};
|
|
3259
|
+
const RecordingOff = ({ children }) => {
|
|
3260
|
+
const t = useT$1();
|
|
3261
|
+
return /* @__PURE__ */ jsx(
|
|
3262
|
+
PersistentAlert,
|
|
3263
|
+
{
|
|
3264
|
+
variant: "neutral",
|
|
3265
|
+
action: /* @__PURE__ */ jsx(Link, { tag: Link$1, to: ADMIN_ACTIVITY_SETTINGS_PATH, children: t("adminPanel.activity.openSettings", "Open settings") }),
|
|
3266
|
+
children
|
|
3267
|
+
}
|
|
3268
|
+
);
|
|
3269
|
+
};
|
|
3270
|
+
const SignInHistoryPanel = ({ admin }) => {
|
|
3271
|
+
const t = useT$1();
|
|
3272
|
+
const [event, setEvent] = useState("all");
|
|
3273
|
+
const [period, setPeriod] = useState("30");
|
|
3274
|
+
const params = useMemo(
|
|
3275
|
+
() => buildSignInParams({ adminId: admin.id, event, period }),
|
|
3276
|
+
[admin.id, event, period]
|
|
3277
|
+
);
|
|
3278
|
+
const list = useEventList({
|
|
3279
|
+
path: `/${pluginId}/admin-activity/sign-ins`,
|
|
3280
|
+
params,
|
|
3281
|
+
logKey: "adminPanel.activity.signIns"
|
|
3282
|
+
});
|
|
3283
|
+
const recording = list.meta?.recording;
|
|
3284
|
+
const labels = {
|
|
3285
|
+
all: t("adminPanel.activity.filter.allEvents", "All events"),
|
|
3286
|
+
succeeded: t("adminPanel.activity.filter.succeeded", "Sign-ins"),
|
|
3287
|
+
failed: t("adminPanel.activity.filter.failed", "Failed and locked out"),
|
|
3288
|
+
"signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs")
|
|
3289
|
+
};
|
|
3290
|
+
return /* @__PURE__ */ jsx(
|
|
3291
|
+
EventList,
|
|
3292
|
+
{
|
|
3293
|
+
list,
|
|
3294
|
+
filters: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3295
|
+
/* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(
|
|
3296
|
+
SingleSelect,
|
|
3297
|
+
{
|
|
3298
|
+
size: "S",
|
|
3299
|
+
"aria-label": t("adminPanel.activity.filter.event", "Event"),
|
|
3300
|
+
value: event,
|
|
3301
|
+
onChange: (next) => setEvent(String(next)),
|
|
3302
|
+
children: SIGN_IN_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsx(SingleSelectOption, { value: option, children: labels[option] }, option))
|
|
3303
|
+
}
|
|
3304
|
+
) }),
|
|
3305
|
+
/* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(PeriodSelect, { value: period, onChange: setPeriod }) })
|
|
3306
|
+
] }),
|
|
3307
|
+
notice: recording && !recording.signIns ? /* @__PURE__ */ jsx(RecordingOff, { children: t(
|
|
3308
|
+
"adminPanel.activity.signIns.off",
|
|
3309
|
+
"Sign-in history is turned off. New sign-ins are not recorded."
|
|
3310
|
+
) }) : null,
|
|
3311
|
+
listLabel: t("adminPanel.activity.signIns.listLabel", "Sign-in history of {name}", {
|
|
3312
|
+
name: admin.name
|
|
3313
|
+
}),
|
|
3314
|
+
emptyText: t("adminPanel.activity.signIns.empty", "No sign-in events in this period."),
|
|
3315
|
+
renderRow: (row) => /* @__PURE__ */ jsx(SignInEventRow, { row }, row.id),
|
|
3316
|
+
toCsv: buildSignInCsv,
|
|
3317
|
+
fileName: "admin-sign-in-history",
|
|
3318
|
+
exportLabel: t(
|
|
3319
|
+
"adminPanel.activity.signIns.export",
|
|
3320
|
+
"Export the sign-in history of {name} as CSV",
|
|
3321
|
+
{
|
|
3322
|
+
name: admin.name
|
|
3323
|
+
}
|
|
3324
|
+
)
|
|
3325
|
+
}
|
|
3326
|
+
);
|
|
3327
|
+
};
|
|
3328
|
+
const ContentActivityPanel = ({ admin }) => {
|
|
3329
|
+
const t = useT$1();
|
|
3330
|
+
const [action, setAction] = useState("all");
|
|
3331
|
+
const [contentType, setContentType] = useState("all");
|
|
3332
|
+
const [period, setPeriod] = useState("30");
|
|
3333
|
+
const params = useMemo(
|
|
3334
|
+
() => buildActivityParams({ adminId: admin.id, action, contentType, period }),
|
|
3335
|
+
[admin.id, action, contentType, period]
|
|
3336
|
+
);
|
|
3337
|
+
const list = useEventList({
|
|
3338
|
+
path: `/${pluginId}/admin-activity/content`,
|
|
3339
|
+
params,
|
|
3340
|
+
logKey: "adminPanel.activity.content"
|
|
3341
|
+
});
|
|
3342
|
+
const recording = list.meta?.recording;
|
|
3343
|
+
const types = Array.isArray(list.meta?.contentTypes) ? list.meta.contentTypes : [];
|
|
3344
|
+
const noAccess = list.meta?.contentManagerAccess === false;
|
|
3345
|
+
let notice = null;
|
|
3346
|
+
if (recording && !recording.contentActivity) {
|
|
3347
|
+
notice = /* @__PURE__ */ jsx(RecordingOff, { children: t(
|
|
3348
|
+
"adminPanel.activity.content.off",
|
|
3349
|
+
"Content Manager activity is not recorded. An admin can turn it on in the settings; inform your team first."
|
|
3350
|
+
) });
|
|
3351
|
+
} else if (noAccess) {
|
|
3352
|
+
notice = /* @__PURE__ */ jsx(PersistentAlert, { variant: "neutral", children: t(
|
|
3353
|
+
"adminPanel.activity.content.noAccess",
|
|
3354
|
+
"{name} has no Content Manager access, so there is no activity to show.",
|
|
3355
|
+
{ name: admin.name }
|
|
3356
|
+
) });
|
|
3357
|
+
}
|
|
3358
|
+
return /* @__PURE__ */ jsx(
|
|
3359
|
+
EventList,
|
|
3360
|
+
{
|
|
3361
|
+
list,
|
|
3362
|
+
filters: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3363
|
+
/* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(
|
|
3364
|
+
SingleSelect,
|
|
3365
|
+
{
|
|
3366
|
+
size: "S",
|
|
3367
|
+
"aria-label": t("adminPanel.activity.filter.action", "Action"),
|
|
3368
|
+
value: action,
|
|
3369
|
+
onChange: (next) => setAction(String(next)),
|
|
3370
|
+
children: ACTIVITY_ACTION_OPTIONS.map((option) => /* @__PURE__ */ jsx(SingleSelectOption, { value: option, children: t(
|
|
3371
|
+
ACTIVITY_ACTION_LABELS[option].messageId,
|
|
3372
|
+
ACTIVITY_ACTION_LABELS[option].defaultMessage
|
|
3373
|
+
) }, option))
|
|
3374
|
+
}
|
|
3375
|
+
) }),
|
|
3376
|
+
/* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsxs(
|
|
3377
|
+
SingleSelect,
|
|
3378
|
+
{
|
|
3379
|
+
size: "S",
|
|
3380
|
+
"aria-label": t("adminPanel.activity.filter.contentType", "Content type"),
|
|
3381
|
+
value: contentType,
|
|
3382
|
+
onChange: (next) => setContentType(String(next)),
|
|
3383
|
+
children: [
|
|
3384
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "all", children: t("adminPanel.activity.filter.allTypes", "All content types") }),
|
|
3385
|
+
types.map((type) => /* @__PURE__ */ jsx(SingleSelectOption, { value: type.uid, children: type.name }, type.uid))
|
|
3386
|
+
]
|
|
3387
|
+
}
|
|
3388
|
+
) }),
|
|
3389
|
+
/* @__PURE__ */ jsx(FilterSlot, { children: /* @__PURE__ */ jsx(PeriodSelect, { value: period, onChange: setPeriod }) })
|
|
3390
|
+
] }),
|
|
3391
|
+
notice,
|
|
3392
|
+
listLabel: t("adminPanel.activity.content.listLabel", "Content Manager activity of {name}", {
|
|
3393
|
+
name: admin.name
|
|
3394
|
+
}),
|
|
3395
|
+
emptyText: t(
|
|
3396
|
+
"adminPanel.activity.content.empty",
|
|
3397
|
+
"No Content Manager activity in this period."
|
|
3398
|
+
),
|
|
3399
|
+
renderRow: (row) => /* @__PURE__ */ jsx(ActivityEventRow, { row }, row.id),
|
|
3400
|
+
toCsv: buildActivityCsv,
|
|
3401
|
+
fileName: "admin-content-activity",
|
|
3402
|
+
exportLabel: t(
|
|
3403
|
+
"adminPanel.activity.content.export",
|
|
3404
|
+
"Export the Content Manager activity of {name} as CSV",
|
|
3405
|
+
{ name: admin.name }
|
|
3406
|
+
)
|
|
3407
|
+
}
|
|
3408
|
+
);
|
|
3409
|
+
};
|
|
3410
|
+
const RecentSignInActivity = ({ onOpenAdmin }) => {
|
|
3411
|
+
const t = useT$1();
|
|
3412
|
+
const params = useMemo(() => buildSignInParams({ pageSize: 5 }), []);
|
|
3413
|
+
const list = useEventList({
|
|
3414
|
+
path: `/${pluginId}/admin-activity/sign-ins`,
|
|
3415
|
+
params,
|
|
3416
|
+
logKey: "adminPanel.activity.recent"
|
|
3417
|
+
});
|
|
3418
|
+
if (list.meta?.recording && !list.meta.recording.signIns) return null;
|
|
3419
|
+
return /* @__PURE__ */ jsxs(
|
|
3420
|
+
SectionCard,
|
|
3421
|
+
{
|
|
3422
|
+
title: t("adminPanel.activity.recent.title", "Recent sign-in activity"),
|
|
3423
|
+
subtitle: t(
|
|
3424
|
+
"adminPanel.activity.recent.subtitle",
|
|
3425
|
+
"The latest sign-ins, failed attempts and sign-outs of all admins. Open an admin for their full history."
|
|
3426
|
+
),
|
|
3427
|
+
children: [
|
|
3428
|
+
list.loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 2, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("adminPanel.activity.loading", "Loading events") }) }) : null,
|
|
3429
|
+
!list.loading && list.error ? /* @__PURE__ */ jsx(
|
|
3430
|
+
PersistentAlert,
|
|
3431
|
+
{
|
|
3432
|
+
variant: "danger",
|
|
3433
|
+
action: /* @__PURE__ */ jsx(Button, { size: "S", variant: "secondary", onClick: list.reload, children: t("common.tryAgain", "Try again") }),
|
|
3434
|
+
children: t("adminPanel.activity.error", "The events could not be loaded.")
|
|
3435
|
+
}
|
|
3436
|
+
) : null,
|
|
3437
|
+
!list.loading && !list.error && list.rows.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: t("adminPanel.activity.recent.empty", "No sign-in events yet.") }) : null,
|
|
3438
|
+
list.rows.length > 0 ? /* @__PURE__ */ jsx(
|
|
3439
|
+
Flex,
|
|
3440
|
+
{
|
|
3441
|
+
tag: "ul",
|
|
3442
|
+
direction: "column",
|
|
3443
|
+
alignItems: "stretch",
|
|
3444
|
+
gap: 2,
|
|
3445
|
+
width: "100%",
|
|
3446
|
+
"aria-label": t("adminPanel.activity.recent.title", "Recent sign-in activity"),
|
|
3447
|
+
children: list.rows.map((row) => /* @__PURE__ */ jsx(SignInEventRow, { row, showAdmin: true, onOpenAdmin }, row.id))
|
|
3448
|
+
}
|
|
3449
|
+
) : null
|
|
3450
|
+
]
|
|
3451
|
+
}
|
|
3452
|
+
);
|
|
3453
|
+
};
|
|
3454
|
+
const DialogTabsList = styled(Tabs.List)`
|
|
3455
|
+
overflow-x: auto;
|
|
3456
|
+
overflow-y: hidden;
|
|
3457
|
+
max-width: 100%;
|
|
3458
|
+
`;
|
|
3459
|
+
const DialogTabTrigger = styled(Tabs.Trigger)`
|
|
3460
|
+
&& {
|
|
3461
|
+
flex: 0 0 auto;
|
|
3462
|
+
white-space: nowrap;
|
|
3463
|
+
}
|
|
3464
|
+
`;
|
|
3465
|
+
const DialogTabLabel = styled.span`
|
|
3466
|
+
text-transform: none;
|
|
3467
|
+
letter-spacing: normal;
|
|
3468
|
+
font-size: ${({ theme }) => theme.fontSizes[2]};
|
|
3469
|
+
`;
|
|
3470
|
+
const ADMIN_DIALOG_TABS = Object.freeze(["sessions", "history", "activity"]);
|
|
2697
3471
|
const useT = () => {
|
|
2698
3472
|
const { formatMessage } = useIntl();
|
|
2699
3473
|
return (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
|
|
@@ -2778,9 +3552,12 @@ const AdminSessionsModal = ({
|
|
|
2778
3552
|
onSignOut,
|
|
2779
3553
|
onSignOutEverywhere,
|
|
2780
3554
|
onClose,
|
|
2781
|
-
onCloseAutoFocus
|
|
3555
|
+
onCloseAutoFocus,
|
|
3556
|
+
canViewActivity = false,
|
|
3557
|
+
initialTab = "sessions"
|
|
2782
3558
|
}) => {
|
|
2783
3559
|
const t = useT();
|
|
3560
|
+
const [tab, setTab] = useState(ADMIN_DIALOG_TABS.includes(initialTab) ? initialTab : "sessions");
|
|
2784
3561
|
const canSignOut = canRevoke && admin.account === "active" && !admin.protectedReason;
|
|
2785
3562
|
const settingsPath = `/settings/users/${admin.id}`;
|
|
2786
3563
|
let notice = null;
|
|
@@ -2795,70 +3572,80 @@ const AdminSessionsModal = ({
|
|
|
2795
3572
|
"Only a Super Admin can sign out a Super Admin. This keeps at least one Super Admin able to work at all times."
|
|
2796
3573
|
) });
|
|
2797
3574
|
}
|
|
3575
|
+
const sessionsContent = /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
|
|
3576
|
+
/* @__PURE__ */ jsx(
|
|
3577
|
+
PropertyList,
|
|
3578
|
+
{
|
|
3579
|
+
columns: 2,
|
|
3580
|
+
items: [
|
|
3581
|
+
{
|
|
3582
|
+
id: "email",
|
|
3583
|
+
label: t("adminPanel.dialog.email", "Email"),
|
|
3584
|
+
value: admin.email,
|
|
3585
|
+
kind: "email"
|
|
3586
|
+
},
|
|
3587
|
+
{
|
|
3588
|
+
id: "roles",
|
|
3589
|
+
label: t("adminPanel.table.roles", "Roles"),
|
|
3590
|
+
render: /* @__PURE__ */ jsx(AdminRoles, { admin })
|
|
3591
|
+
},
|
|
3592
|
+
{
|
|
3593
|
+
id: "status",
|
|
3594
|
+
label: t("adminPanel.table.status", "Status"),
|
|
3595
|
+
render: /* @__PURE__ */ jsx(AdminStatus, { admin: { ...admin, sessionCount: sessions.length } }),
|
|
3596
|
+
fullWidth: true
|
|
3597
|
+
}
|
|
3598
|
+
]
|
|
3599
|
+
}
|
|
3600
|
+
),
|
|
3601
|
+
notice,
|
|
3602
|
+
loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("adminPanel.dialog.loading", "Loading sessions") }) }) : null,
|
|
3603
|
+
!loading && error ? /* @__PURE__ */ jsx(
|
|
3604
|
+
PersistentAlert,
|
|
3605
|
+
{
|
|
3606
|
+
variant: "danger",
|
|
3607
|
+
action: /* @__PURE__ */ jsx(Button, { size: "S", variant: "secondary", onClick: onRetry, children: t("common.tryAgain", "Try again") }),
|
|
3608
|
+
children: t("adminPanel.dialog.error", "The sessions could not be loaded.")
|
|
3609
|
+
}
|
|
3610
|
+
) : null,
|
|
3611
|
+
!loading && !error && admin.account === "active" && sessions.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", "data-admin-sessions-empty": "", children: t(
|
|
3612
|
+
"adminPanel.dialog.empty",
|
|
3613
|
+
"{name} is not signed in. Sessions appear here after the next sign-in.",
|
|
3614
|
+
{ name: admin.name }
|
|
3615
|
+
) }) : null,
|
|
3616
|
+
!loading && sessions.length > 0 ? /* @__PURE__ */ jsx(
|
|
3617
|
+
Flex,
|
|
3618
|
+
{
|
|
3619
|
+
tag: "ul",
|
|
3620
|
+
direction: "column",
|
|
3621
|
+
alignItems: "stretch",
|
|
3622
|
+
gap: 3,
|
|
3623
|
+
"aria-label": t("adminPanel.dialog.listLabel", "Signed-in browsers"),
|
|
3624
|
+
children: sessions.map((session) => /* @__PURE__ */ jsx(
|
|
3625
|
+
SessionCard,
|
|
3626
|
+
{
|
|
3627
|
+
session,
|
|
3628
|
+
admin,
|
|
3629
|
+
canSignOut,
|
|
3630
|
+
onSignOut
|
|
3631
|
+
},
|
|
3632
|
+
session.id
|
|
3633
|
+
))
|
|
3634
|
+
}
|
|
3635
|
+
) : null
|
|
3636
|
+
] });
|
|
2798
3637
|
return /* @__PURE__ */ jsx(Modal.Root, { open: true, onOpenChange: (open) => open ? null : onClose(), children: /* @__PURE__ */ jsxs(Modal.Content, { onCloseAutoFocus, "aria-describedby": void 0, children: [
|
|
2799
|
-
/* @__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 }) }) }),
|
|
2800
|
-
/* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs(
|
|
2801
|
-
/* @__PURE__ */
|
|
2802
|
-
|
|
2803
|
-
{
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
kind: "email"
|
|
2811
|
-
},
|
|
2812
|
-
{
|
|
2813
|
-
id: "roles",
|
|
2814
|
-
label: t("adminPanel.table.roles", "Roles"),
|
|
2815
|
-
render: /* @__PURE__ */ jsx(AdminRoles, { admin })
|
|
2816
|
-
},
|
|
2817
|
-
{
|
|
2818
|
-
id: "status",
|
|
2819
|
-
label: t("adminPanel.table.status", "Status"),
|
|
2820
|
-
render: /* @__PURE__ */ jsx(AdminStatus, { admin: { ...admin, sessionCount: sessions.length } }),
|
|
2821
|
-
fullWidth: true
|
|
2822
|
-
}
|
|
2823
|
-
]
|
|
2824
|
-
}
|
|
2825
|
-
),
|
|
2826
|
-
notice,
|
|
2827
|
-
loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("adminPanel.dialog.loading", "Loading sessions") }) }) : null,
|
|
2828
|
-
!loading && error ? /* @__PURE__ */ jsx(
|
|
2829
|
-
PersistentAlert,
|
|
2830
|
-
{
|
|
2831
|
-
variant: "danger",
|
|
2832
|
-
action: /* @__PURE__ */ jsx(Button, { size: "S", variant: "secondary", onClick: onRetry, children: t("common.tryAgain", "Try again") }),
|
|
2833
|
-
children: t("adminPanel.dialog.error", "The sessions could not be loaded.")
|
|
2834
|
-
}
|
|
2835
|
-
) : null,
|
|
2836
|
-
!loading && !error && admin.account === "active" && sessions.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", "data-admin-sessions-empty": "", children: t(
|
|
2837
|
-
"adminPanel.dialog.empty",
|
|
2838
|
-
"{name} is not signed in. Sessions appear here after the next sign-in.",
|
|
2839
|
-
{ name: admin.name }
|
|
2840
|
-
) }) : null,
|
|
2841
|
-
!loading && sessions.length > 0 ? /* @__PURE__ */ jsx(
|
|
2842
|
-
Flex,
|
|
2843
|
-
{
|
|
2844
|
-
tag: "ul",
|
|
2845
|
-
direction: "column",
|
|
2846
|
-
alignItems: "stretch",
|
|
2847
|
-
gap: 3,
|
|
2848
|
-
"aria-label": t("adminPanel.dialog.listLabel", "Signed-in browsers"),
|
|
2849
|
-
children: sessions.map((session) => /* @__PURE__ */ jsx(
|
|
2850
|
-
SessionCard,
|
|
2851
|
-
{
|
|
2852
|
-
session,
|
|
2853
|
-
admin,
|
|
2854
|
-
canSignOut,
|
|
2855
|
-
onSignOut
|
|
2856
|
-
},
|
|
2857
|
-
session.id
|
|
2858
|
-
))
|
|
2859
|
-
}
|
|
2860
|
-
) : null
|
|
2861
|
-
] }) }),
|
|
3638
|
+
/* @__PURE__ */ jsx(Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsx(Modal.Title, { children: canViewActivity ? admin.name : t("adminPanel.dialog.title", "Sessions of {name}", { name: admin.name }) }) }),
|
|
3639
|
+
/* @__PURE__ */ jsx(Modal.Body, { children: canViewActivity ? /* @__PURE__ */ jsxs(Tabs.Root, { variant: "simple", value: tab, onValueChange: setTab, children: [
|
|
3640
|
+
/* @__PURE__ */ jsxs(DialogTabsList, { "aria-label": t("adminPanel.dialog.tabs", "Admin details"), children: [
|
|
3641
|
+
/* @__PURE__ */ jsx(DialogTabTrigger, { value: "sessions", children: /* @__PURE__ */ jsx(DialogTabLabel, { children: t("adminPanel.dialog.tab.sessions", "Sessions") }) }),
|
|
3642
|
+
/* @__PURE__ */ jsx(DialogTabTrigger, { value: "history", children: /* @__PURE__ */ jsx(DialogTabLabel, { children: t("adminPanel.dialog.tab.history", "Sign-in history") }) }),
|
|
3643
|
+
/* @__PURE__ */ jsx(DialogTabTrigger, { value: "activity", children: /* @__PURE__ */ jsx(DialogTabLabel, { children: t("adminPanel.dialog.tab.activity", "Activity") }) })
|
|
3644
|
+
] }),
|
|
3645
|
+
/* @__PURE__ */ jsx(Tabs.Content, { value: "sessions", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: sessionsContent }) }),
|
|
3646
|
+
/* @__PURE__ */ jsx(Tabs.Content, { value: "history", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(SignInHistoryPanel, { admin }) }) }),
|
|
3647
|
+
/* @__PURE__ */ jsx(Tabs.Content, { value: "activity", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(ContentActivityPanel, { admin }) }) })
|
|
3648
|
+
] }) : sessionsContent }),
|
|
2862
3649
|
/* @__PURE__ */ jsx(Modal.Footer, { children: /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", justifyContent: "space-between", width: "100%", children: [
|
|
2863
3650
|
/* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: t("common.close", "Close") }) }),
|
|
2864
3651
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", children: [
|
|
@@ -2903,12 +3690,16 @@ const AdminPanelPage = () => {
|
|
|
2903
3690
|
const {
|
|
2904
3691
|
allowedActions: { canRevoke }
|
|
2905
3692
|
} = useRBAC(pluginPermissions.adminSessionsRevoke);
|
|
3693
|
+
const {
|
|
3694
|
+
allowedActions: { canRead: canViewActivity }
|
|
3695
|
+
} = useRBAC(pluginPermissions.adminActivityRead);
|
|
2906
3696
|
const [admins, setAdmins] = useState([]);
|
|
2907
3697
|
const [meta, setMeta] = useState(null);
|
|
2908
3698
|
const [loading, setLoading] = useState(true);
|
|
2909
3699
|
const [refreshing, setRefreshing] = useState(false);
|
|
2910
3700
|
const [loadError, setLoadError] = useState(false);
|
|
2911
3701
|
const [selected, setSelected] = useState(null);
|
|
3702
|
+
const [dialogTab, setDialogTab] = useState("sessions");
|
|
2912
3703
|
const [dialogSessions, setDialogSessions] = useState([]);
|
|
2913
3704
|
const [dialogLoading, setDialogLoading] = useState(false);
|
|
2914
3705
|
const [dialogError, setDialogError] = useState(false);
|
|
@@ -2979,8 +3770,9 @@ const AdminPanelPage = () => {
|
|
|
2979
3770
|
},
|
|
2980
3771
|
[get]
|
|
2981
3772
|
);
|
|
2982
|
-
const openDialog = (admin, trigger) => {
|
|
3773
|
+
const openDialog = (admin, trigger, tab = "sessions") => {
|
|
2983
3774
|
openerRef.current = trigger;
|
|
3775
|
+
setDialogTab(tab);
|
|
2984
3776
|
setSelected(admin);
|
|
2985
3777
|
setDialogSessions([]);
|
|
2986
3778
|
setDialogError(false);
|
|
@@ -3043,10 +3835,10 @@ const AdminPanelPage = () => {
|
|
|
3043
3835
|
await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
|
|
3044
3836
|
} catch (err) {
|
|
3045
3837
|
logSafeAdminError("adminPanel.signOut", err);
|
|
3046
|
-
const
|
|
3838
|
+
const message2 = getSignOutErrorMessage(err);
|
|
3047
3839
|
toggleNotification({
|
|
3048
3840
|
type: getErrorStatus(err) === 404 ? "warning" : "danger",
|
|
3049
|
-
message: t(
|
|
3841
|
+
message: t(message2.messageId, message2.defaultMessage)
|
|
3050
3842
|
});
|
|
3051
3843
|
if (getErrorStatus(err) === 404) {
|
|
3052
3844
|
await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
|
|
@@ -3113,6 +3905,7 @@ const AdminPanelPage = () => {
|
|
|
3113
3905
|
busy: refreshing
|
|
3114
3906
|
};
|
|
3115
3907
|
const policy = meta?.policy;
|
|
3908
|
+
const recording = meta?.recording;
|
|
3116
3909
|
const range = pagination.total > 0 ? {
|
|
3117
3910
|
from: (pagination.page - 1) * pagination.pageSize + 1,
|
|
3118
3911
|
to: Math.min(pagination.page * pagination.pageSize, pagination.total)
|
|
@@ -3213,10 +4006,23 @@ const AdminPanelPage = () => {
|
|
|
3213
4006
|
stacked: true,
|
|
3214
4007
|
title: t("adminPanel.howItWorks.title", "How signing out works"),
|
|
3215
4008
|
children: [
|
|
3216
|
-
/* @__PURE__ */
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
4009
|
+
/* @__PURE__ */ jsxs(ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: [
|
|
4010
|
+
t(
|
|
4011
|
+
"adminPanel.howItWorks.body",
|
|
4012
|
+
"Signing out takes effect on the admin’s next click: Strapi checks the session on every admin request. They can sign in again with their password; to stop that, deactivate the account in Settings > Users. Admin API tokens are not affected."
|
|
4013
|
+
),
|
|
4014
|
+
" ",
|
|
4015
|
+
recording?.ipAddresses ? t(
|
|
4016
|
+
"adminPanel.howItWorks.recorded",
|
|
4017
|
+
"Session Manager records every sign-in with time, browser and IP address in the sign-in history."
|
|
4018
|
+
) : recording?.signIns ? t(
|
|
4019
|
+
"adminPanel.howItWorks.recordedNoIp",
|
|
4020
|
+
"Session Manager records every sign-in with time and browser in the sign-in history, without IP addresses."
|
|
4021
|
+
) : t(
|
|
4022
|
+
"adminPanel.howItWorks.notRecorded",
|
|
4023
|
+
"Sign-in history is turned off, so no IP addresses of admins are recorded."
|
|
4024
|
+
)
|
|
4025
|
+
] }),
|
|
3220
4026
|
policy ? /* @__PURE__ */ jsxs(ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: [
|
|
3221
4027
|
" ",
|
|
3222
4028
|
t(
|
|
@@ -3329,9 +4135,17 @@ const AdminPanelPage = () => {
|
|
|
3329
4135
|
}
|
|
3330
4136
|
)
|
|
3331
4137
|
] }) : null,
|
|
4138
|
+
showData && canViewActivity ? /* @__PURE__ */ jsx(
|
|
4139
|
+
RecentSignInActivity,
|
|
4140
|
+
{
|
|
4141
|
+
onOpenAdmin: (admin, trigger) => openDialog(admin, trigger, "history")
|
|
4142
|
+
}
|
|
4143
|
+
) : null,
|
|
3332
4144
|
selected ? /* @__PURE__ */ jsx(
|
|
3333
4145
|
AdminSessionsModal,
|
|
3334
4146
|
{
|
|
4147
|
+
canViewActivity: Boolean(canViewActivity),
|
|
4148
|
+
initialTab: dialogTab,
|
|
3335
4149
|
admin: selected,
|
|
3336
4150
|
sessions: dialogSessions,
|
|
3337
4151
|
loading: dialogLoading && dialogSessions.length === 0,
|
|
@@ -3342,7 +4156,8 @@ const AdminPanelPage = () => {
|
|
|
3342
4156
|
onSignOutEverywhere: (trigger) => askSignOut(selected, null, trigger),
|
|
3343
4157
|
onClose: closeDialog,
|
|
3344
4158
|
onCloseAutoFocus: (event) => restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
|
|
3345
|
-
}
|
|
4159
|
+
},
|
|
4160
|
+
`${selected.id}-${dialogTab}`
|
|
3346
4161
|
) : null,
|
|
3347
4162
|
confirm ? /* @__PURE__ */ jsx(
|
|
3348
4163
|
ConfirmAction,
|