strapi-plugin-magic-sessionmanager 4.15.0 → 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 +39 -0
- package/README.md +91 -7
- package/dist/admin/{Analytics-HK6_TEmk.mjs → Analytics-D4gsVwL0.mjs} +1 -1
- package/dist/admin/{Analytics-Dbs5QXLb.js → Analytics-me4qzS0I.js} +1 -1
- package/dist/admin/{App-BOFzZ5d8.mjs → App-BJwtFWxl.mjs} +863 -81
- package/dist/admin/{App-7SxOBJP5.js → App-BTG-2Q26.js} +862 -80
- package/dist/admin/{OnlineUsersWidget-Dns_74xJ.js → OnlineUsersWidget-DYS3Vy1Q.js} +1 -1
- package/dist/admin/{OnlineUsersWidget-CoCxnww-.mjs → OnlineUsersWidget-Yd283YDy.mjs} +1 -1
- package/dist/admin/{Settings-DYRShQ8W.mjs → Settings-DIlvfdjZ.mjs} +170 -19
- package/dist/admin/{Settings-B6CrR-07.js → Settings-TPZ9_75s.js} +169 -18
- package/dist/admin/{de-bkkCvSxX.js → de-BuMw1gBJ.js} +92 -2
- package/dist/admin/{de-B3mPtxsW.mjs → de-DB9ldYwN.mjs} +92 -2
- package/dist/admin/{en-BnU8BNkN.mjs → en-BbLMPQB3.mjs} +92 -2
- package/dist/admin/{en-DMICyIow.js → en-BqGhOJDy.js} +92 -2
- package/dist/admin/{es-OSzHGRIu.js → es-BaIeckl9.js} +92 -2
- package/dist/admin/{es-BxMgfJ1Y.mjs → es-C5iaiE9G.mjs} +92 -2
- package/dist/admin/{fr-WPrbtx8k.mjs → fr-BEvBUCwI.mjs} +92 -2
- package/dist/admin/{fr-Bu_8miJ4.js → fr-D1YKyTex.js} +92 -2
- package/dist/admin/{index-CNSJITRX.js → index-CgZiLcJ1.js} +13 -10
- package/dist/admin/{index-lnZBc5n0.mjs → index-DUESEUaO.mjs} +13 -10
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-C41KyEDN.mjs → pt-DeDih9cR.mjs} +92 -2
- package/dist/admin/{pt-B08xnb0K.js → pt-DtnW-s0V.js} +92 -2
- package/dist/server/index.js +1917 -103
- package/dist/server/index.mjs +1917 -103
- package/package.json +1 -1
|
@@ -9,8 +9,9 @@ const designSystem = require("@strapi/design-system");
|
|
|
9
9
|
const icons = require("@strapi/icons");
|
|
10
10
|
const symbols = require("@strapi/icons/symbols");
|
|
11
11
|
const styled = require("styled-components");
|
|
12
|
-
const index = require("./index-
|
|
12
|
+
const index = require("./index-CgZiLcJ1.js");
|
|
13
13
|
const riskData = require("./riskData-BVs9GpgD.js");
|
|
14
|
+
const SectionCard = require("./SectionCard-BlWv8CRt.js");
|
|
14
15
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
16
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
16
17
|
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
@@ -2561,14 +2562,17 @@ function getSignOutErrorMessage(error) {
|
|
|
2561
2562
|
};
|
|
2562
2563
|
}
|
|
2563
2564
|
const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
|
|
2565
|
+
const keepActionKeys = (event) => {
|
|
2566
|
+
if (shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2567
|
+
};
|
|
2564
2568
|
const SHRINKING_ADMIN_CELL = { maxWidth: 0, width: "34%" };
|
|
2565
2569
|
const SHRINKING_ROLES_CELL = { maxWidth: 0, width: "22%" };
|
|
2566
|
-
const useT$
|
|
2570
|
+
const useT$3 = () => {
|
|
2567
2571
|
const { formatMessage } = reactIntl.useIntl();
|
|
2568
2572
|
return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
2569
2573
|
};
|
|
2570
2574
|
const AdminIdentity = ({ admin }) => {
|
|
2571
|
-
const t = useT$
|
|
2575
|
+
const t = useT$3();
|
|
2572
2576
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children: [
|
|
2573
2577
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
|
|
2574
2578
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2588,13 +2592,13 @@ const AdminIdentity = ({ admin }) => {
|
|
|
2588
2592
|
] });
|
|
2589
2593
|
};
|
|
2590
2594
|
const AdminRoles = ({ admin }) => {
|
|
2591
|
-
const t = useT$
|
|
2595
|
+
const t = useT$3();
|
|
2592
2596
|
const names = (admin.roles || []).map((role) => role.name).filter(Boolean);
|
|
2593
2597
|
const text = names.length ? names.join(", ") : t("adminPanel.roles.none", "No role");
|
|
2594
2598
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", ellipsis: true, title: text, children: text });
|
|
2595
2599
|
};
|
|
2596
2600
|
const AdminStatus = ({ admin }) => {
|
|
2597
|
-
const t = useT$
|
|
2601
|
+
const t = useT$3();
|
|
2598
2602
|
const status = getAdminStatusPresentation(admin);
|
|
2599
2603
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-admin-status": status.key, children: [
|
|
2600
2604
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...index.getBadgeColors(status.tone), children: t(status.label.messageId, status.label.defaultMessage) }),
|
|
@@ -2609,7 +2613,7 @@ const AdminTable = ({
|
|
|
2609
2613
|
onSignOutEverywhere,
|
|
2610
2614
|
busy
|
|
2611
2615
|
}) => {
|
|
2612
|
-
const t = useT$
|
|
2616
|
+
const t = useT$3();
|
|
2613
2617
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral0", hasRadius: true, shadow: "tableShadow", "data-admin-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2614
2618
|
designSystem.Table,
|
|
2615
2619
|
{
|
|
@@ -2630,7 +2634,7 @@ const AdminTable = ({
|
|
|
2630
2634
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin }) }),
|
|
2631
2635
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin }) }),
|
|
2632
2636
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: admin.lastActiveAt }) }),
|
|
2633
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(RowActions, { children: [
|
|
2637
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(RowActions, { onKeyDown: keepActionKeys, children: [
|
|
2634
2638
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2635
2639
|
designSystem.IconButton,
|
|
2636
2640
|
{
|
|
@@ -2663,7 +2667,7 @@ const AdminTable = ({
|
|
|
2663
2667
|
) });
|
|
2664
2668
|
};
|
|
2665
2669
|
const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywhere }) => {
|
|
2666
|
-
const t = useT$
|
|
2670
|
+
const t = useT$3();
|
|
2667
2671
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2668
2672
|
designSystem.Flex,
|
|
2669
2673
|
{
|
|
@@ -2731,6 +2735,743 @@ const AdminCardList = ({ admins, labelledBy, canRevoke, onView, onSignOutEverywh
|
|
|
2731
2735
|
}
|
|
2732
2736
|
);
|
|
2733
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"]);
|
|
2734
3475
|
const useT = () => {
|
|
2735
3476
|
const { formatMessage } = reactIntl.useIntl();
|
|
2736
3477
|
return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
@@ -2815,9 +3556,12 @@ const AdminSessionsModal = ({
|
|
|
2815
3556
|
onSignOut,
|
|
2816
3557
|
onSignOutEverywhere,
|
|
2817
3558
|
onClose,
|
|
2818
|
-
onCloseAutoFocus
|
|
3559
|
+
onCloseAutoFocus,
|
|
3560
|
+
canViewActivity = false,
|
|
3561
|
+
initialTab = "sessions"
|
|
2819
3562
|
}) => {
|
|
2820
3563
|
const t = useT();
|
|
3564
|
+
const [tab, setTab] = react.useState(ADMIN_DIALOG_TABS.includes(initialTab) ? initialTab : "sessions");
|
|
2821
3565
|
const canSignOut = canRevoke && admin.account === "active" && !admin.protectedReason;
|
|
2822
3566
|
const settingsPath = `/settings/users/${admin.id}`;
|
|
2823
3567
|
let notice = null;
|
|
@@ -2832,70 +3576,80 @@ const AdminSessionsModal = ({
|
|
|
2832
3576
|
"Only a Super Admin can sign out a Super Admin. This keeps at least one Super Admin able to work at all times."
|
|
2833
3577
|
) });
|
|
2834
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
|
+
] });
|
|
2835
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: [
|
|
2836
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: t("adminPanel.dialog.title", "Sessions of {name}", { name: admin.name }) }) }),
|
|
2837
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
|
2838
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2839
|
-
|
|
2840
|
-
{
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
kind: "email"
|
|
2848
|
-
},
|
|
2849
|
-
{
|
|
2850
|
-
id: "roles",
|
|
2851
|
-
label: t("adminPanel.table.roles", "Roles"),
|
|
2852
|
-
render: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin })
|
|
2853
|
-
},
|
|
2854
|
-
{
|
|
2855
|
-
id: "status",
|
|
2856
|
-
label: t("adminPanel.table.status", "Status"),
|
|
2857
|
-
render: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin: { ...admin, sessionCount: sessions.length } }),
|
|
2858
|
-
fullWidth: true
|
|
2859
|
-
}
|
|
2860
|
-
]
|
|
2861
|
-
}
|
|
2862
|
-
),
|
|
2863
|
-
notice,
|
|
2864
|
-
loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("adminPanel.dialog.loading", "Loading sessions") }) }) : null,
|
|
2865
|
-
!loading && error ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2866
|
-
index.PersistentAlert,
|
|
2867
|
-
{
|
|
2868
|
-
variant: "danger",
|
|
2869
|
-
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: onRetry, children: t("common.tryAgain", "Try again") }),
|
|
2870
|
-
children: t("adminPanel.dialog.error", "The sessions could not be loaded.")
|
|
2871
|
-
}
|
|
2872
|
-
) : null,
|
|
2873
|
-
!loading && !error && admin.account === "active" && sessions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", "data-admin-sessions-empty": "", children: t(
|
|
2874
|
-
"adminPanel.dialog.empty",
|
|
2875
|
-
"{name} is not signed in. Sessions appear here after the next sign-in.",
|
|
2876
|
-
{ name: admin.name }
|
|
2877
|
-
) }) : null,
|
|
2878
|
-
!loading && sessions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2879
|
-
designSystem.Flex,
|
|
2880
|
-
{
|
|
2881
|
-
tag: "ul",
|
|
2882
|
-
direction: "column",
|
|
2883
|
-
alignItems: "stretch",
|
|
2884
|
-
gap: 3,
|
|
2885
|
-
"aria-label": t("adminPanel.dialog.listLabel", "Signed-in browsers"),
|
|
2886
|
-
children: sessions.map((session) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2887
|
-
SessionCard,
|
|
2888
|
-
{
|
|
2889
|
-
session,
|
|
2890
|
-
admin,
|
|
2891
|
-
canSignOut,
|
|
2892
|
-
onSignOut
|
|
2893
|
-
},
|
|
2894
|
-
session.id
|
|
2895
|
-
))
|
|
2896
|
-
}
|
|
2897
|
-
) : null
|
|
2898
|
-
] }) }),
|
|
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 }),
|
|
2899
3653
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", justifyContent: "space-between", width: "100%", children: [
|
|
2900
3654
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: t("common.close", "Close") }) }),
|
|
2901
3655
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", children: [
|
|
@@ -2940,12 +3694,16 @@ const AdminPanelPage = () => {
|
|
|
2940
3694
|
const {
|
|
2941
3695
|
allowedActions: { canRevoke }
|
|
2942
3696
|
} = StrapiAdmin.useRBAC(index.pluginPermissions.adminSessionsRevoke);
|
|
3697
|
+
const {
|
|
3698
|
+
allowedActions: { canRead: canViewActivity }
|
|
3699
|
+
} = StrapiAdmin.useRBAC(index.pluginPermissions.adminActivityRead);
|
|
2943
3700
|
const [admins, setAdmins] = react.useState([]);
|
|
2944
3701
|
const [meta, setMeta] = react.useState(null);
|
|
2945
3702
|
const [loading, setLoading] = react.useState(true);
|
|
2946
3703
|
const [refreshing, setRefreshing] = react.useState(false);
|
|
2947
3704
|
const [loadError, setLoadError] = react.useState(false);
|
|
2948
3705
|
const [selected, setSelected] = react.useState(null);
|
|
3706
|
+
const [dialogTab, setDialogTab] = react.useState("sessions");
|
|
2949
3707
|
const [dialogSessions, setDialogSessions] = react.useState([]);
|
|
2950
3708
|
const [dialogLoading, setDialogLoading] = react.useState(false);
|
|
2951
3709
|
const [dialogError, setDialogError] = react.useState(false);
|
|
@@ -3016,8 +3774,9 @@ const AdminPanelPage = () => {
|
|
|
3016
3774
|
},
|
|
3017
3775
|
[get]
|
|
3018
3776
|
);
|
|
3019
|
-
const openDialog = (admin, trigger) => {
|
|
3777
|
+
const openDialog = (admin, trigger, tab = "sessions") => {
|
|
3020
3778
|
openerRef.current = trigger;
|
|
3779
|
+
setDialogTab(tab);
|
|
3021
3780
|
setSelected(admin);
|
|
3022
3781
|
setDialogSessions([]);
|
|
3023
3782
|
setDialogError(false);
|
|
@@ -3080,10 +3839,10 @@ const AdminPanelPage = () => {
|
|
|
3080
3839
|
await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
|
|
3081
3840
|
} catch (err) {
|
|
3082
3841
|
index.logSafeAdminError("adminPanel.signOut", err);
|
|
3083
|
-
const
|
|
3842
|
+
const message2 = getSignOutErrorMessage(err);
|
|
3084
3843
|
toggleNotification({
|
|
3085
3844
|
type: getErrorStatus(err) === 404 ? "warning" : "danger",
|
|
3086
|
-
message: t(
|
|
3845
|
+
message: t(message2.messageId, message2.defaultMessage)
|
|
3087
3846
|
});
|
|
3088
3847
|
if (getErrorStatus(err) === 404) {
|
|
3089
3848
|
await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
|
|
@@ -3150,6 +3909,7 @@ const AdminPanelPage = () => {
|
|
|
3150
3909
|
busy: refreshing
|
|
3151
3910
|
};
|
|
3152
3911
|
const policy = meta?.policy;
|
|
3912
|
+
const recording = meta?.recording;
|
|
3153
3913
|
const range = pagination.total > 0 ? {
|
|
3154
3914
|
from: (pagination.page - 1) * pagination.pageSize + 1,
|
|
3155
3915
|
to: Math.min(pagination.page * pagination.pageSize, pagination.total)
|
|
@@ -3250,10 +4010,23 @@ const AdminPanelPage = () => {
|
|
|
3250
4010
|
stacked: true,
|
|
3251
4011
|
title: t("adminPanel.howItWorks.title", "How signing out works"),
|
|
3252
4012
|
children: [
|
|
3253
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
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
|
+
] }),
|
|
3257
4030
|
policy ? /* @__PURE__ */ jsxRuntime.jsxs(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: [
|
|
3258
4031
|
" ",
|
|
3259
4032
|
t(
|
|
@@ -3366,9 +4139,17 @@ const AdminPanelPage = () => {
|
|
|
3366
4139
|
}
|
|
3367
4140
|
)
|
|
3368
4141
|
] }) : null,
|
|
4142
|
+
showData && canViewActivity ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4143
|
+
RecentSignInActivity,
|
|
4144
|
+
{
|
|
4145
|
+
onOpenAdmin: (admin, trigger) => openDialog(admin, trigger, "history")
|
|
4146
|
+
}
|
|
4147
|
+
) : null,
|
|
3369
4148
|
selected ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3370
4149
|
AdminSessionsModal,
|
|
3371
4150
|
{
|
|
4151
|
+
canViewActivity: Boolean(canViewActivity),
|
|
4152
|
+
initialTab: dialogTab,
|
|
3372
4153
|
admin: selected,
|
|
3373
4154
|
sessions: dialogSessions,
|
|
3374
4155
|
loading: dialogLoading && dialogSessions.length === 0,
|
|
@@ -3379,7 +4160,8 @@ const AdminPanelPage = () => {
|
|
|
3379
4160
|
onSignOutEverywhere: (trigger) => askSignOut(selected, null, trigger),
|
|
3380
4161
|
onClose: closeDialog,
|
|
3381
4162
|
onCloseAutoFocus: (event) => index.restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
|
|
3382
|
-
}
|
|
4163
|
+
},
|
|
4164
|
+
`${selected.id}-${dialogTab}`
|
|
3383
4165
|
) : null,
|
|
3384
4166
|
confirm ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3385
4167
|
index.ConfirmAction,
|