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