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