strapi-plugin-magic-sessionmanager 4.21.0 → 4.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +97 -0
- package/README.md +92 -47
- package/dist/admin/{Analytics-BqdZIBV4.js → Analytics-B7BAjApz.js} +1 -1
- package/dist/admin/{Analytics-C-OLLzoB.mjs → Analytics-CIHgaURb.mjs} +1 -1
- package/dist/admin/{App-BswHmNQT.mjs → App-CPE-CQGz.mjs} +1309 -2564
- package/dist/admin/{App-Cx9v6n_7.js → App-DJkJC06E.js} +1336 -2591
- package/dist/admin/{OnlineUsersWidget-BRmQPPp9.js → OnlineUsersWidget-CcjNfzzf.js} +1 -1
- package/dist/admin/{OnlineUsersWidget-Dusgjc1d.mjs → OnlineUsersWidget-Dou2hxGY.mjs} +1 -1
- package/dist/admin/{Settings-DWGuf_Z3.js → Settings--eEiHv_a.js} +104 -81
- package/dist/admin/{Settings-DZyQheUS.mjs → Settings-h_exWUiI.mjs} +62 -39
- package/dist/admin/dashboardModel-DNT_l-Bk.js +169 -0
- package/dist/admin/dashboardModel-fApbKGay.mjs +170 -0
- package/dist/admin/{de-DUnrmFWk.mjs → de-Wz5Emtrb.mjs} +79 -7
- package/dist/admin/{de-24TPqzG6.js → de-oBmcAcXj.js} +79 -7
- package/dist/admin/{en-8mBSkWOF.js → en-B1TN5F62.js} +80 -8
- package/dist/admin/{en-D8J__tyF.mjs → en-B_1Ka64U.mjs} +80 -8
- package/dist/admin/{es-ChUKey-Q.js → es-Bb515J0p.js} +79 -7
- package/dist/admin/{es-BgpgWdk0.mjs → es-CVgw4zsj.mjs} +79 -7
- package/dist/admin/{fr-k1MHYKJo.mjs → fr-0AgMxTFc.mjs} +79 -7
- package/dist/admin/{fr-DE_CWmgq.js → fr-yDdwunmg.js} +79 -7
- package/dist/admin/index-DVQ7tdTC.mjs +4746 -0
- package/dist/admin/index-qtN2dOm4.js +4747 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/{pt-BjqU5ioB.js → pt-BAB07LY-.js} +79 -7
- package/dist/admin/{pt-DPO4DmDc.mjs → pt-DtM74ffN.mjs} +79 -7
- package/dist/server/index.js +1487 -438
- package/dist/server/index.mjs +1487 -438
- package/package.json +4 -3
- package/dist/admin/index-Ceh3Q1Ki.js +0 -2308
- package/dist/admin/index-meLDPPwt.mjs +0 -2307
- package/dist/admin/settingsTabs-C1q5iMMw.mjs +0 -437
- package/dist/admin/settingsTabs-CfquZuKH.js +0 -436
|
@@ -9,8 +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
|
|
12
|
+
const index = require("./index-qtN2dOm4.js");
|
|
13
|
+
const dashboardModel = require("./dashboardModel-DNT_l-Bk.js");
|
|
14
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
15
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
16
16
|
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
@@ -94,112 +94,6 @@ function readSessionStats(payload) {
|
|
|
94
94
|
stats.nativeOnlyAfterTracking = isCount$1(data?.nativeOnlyAfterTracking) ? data.nativeOnlyAfterTracking : null;
|
|
95
95
|
return stats;
|
|
96
96
|
}
|
|
97
|
-
const CSV_HEADERS = Object.freeze([
|
|
98
|
-
"ID",
|
|
99
|
-
"Status",
|
|
100
|
-
"User Email",
|
|
101
|
-
"Username",
|
|
102
|
-
"Device",
|
|
103
|
-
"Browser",
|
|
104
|
-
"OS",
|
|
105
|
-
"IP Address",
|
|
106
|
-
"Login Time",
|
|
107
|
-
"Last Active",
|
|
108
|
-
"Logout Time",
|
|
109
|
-
"Minutes Idle",
|
|
110
|
-
"End Reason"
|
|
111
|
-
]);
|
|
112
|
-
const FORMULA_START = /^[\s\u00ad\u200b-\u200f\u2060-\u2064\ufeff]*[=+\-@\uff1d\uff0b\uff0d\uff20\t\r\n]/;
|
|
113
|
-
const escapeCsvValue = (value) => {
|
|
114
|
-
const text = String(value ?? "");
|
|
115
|
-
const safe = typeof value === "string" && FORMULA_START.test(text) ? `'${text}` : text;
|
|
116
|
-
return `"${safe.replace(/"/g, '""')}"`;
|
|
117
|
-
};
|
|
118
|
-
function toIsoTimestamp(value) {
|
|
119
|
-
if (value === null || value === void 0 || value === "") return "";
|
|
120
|
-
const date = value instanceof Date ? value : new Date(
|
|
121
|
-
/** @type {any} */
|
|
122
|
-
value
|
|
123
|
-
);
|
|
124
|
-
return Number.isFinite(date.getTime()) ? date.toISOString() : "";
|
|
125
|
-
}
|
|
126
|
-
function buildSessionCsv(sessions, {
|
|
127
|
-
unavailableValue,
|
|
128
|
-
getDeviceInfo,
|
|
129
|
-
getSessionStatus,
|
|
130
|
-
getSessionEndReason = index.getSessionEndReason
|
|
131
|
-
}) {
|
|
132
|
-
const rows = Array.isArray(sessions) ? sessions : [];
|
|
133
|
-
const csvRows = rows.map((session) => {
|
|
134
|
-
const deviceInfo = getDeviceInfo(session, unavailableValue);
|
|
135
|
-
const minutesIdle = Number.isFinite(session.minutesSinceActive) ? session.minutesSinceActive : "";
|
|
136
|
-
return [
|
|
137
|
-
session.id,
|
|
138
|
-
getSessionStatus(session),
|
|
139
|
-
session.user?.email || "",
|
|
140
|
-
session.user?.username || "",
|
|
141
|
-
deviceInfo.device,
|
|
142
|
-
deviceInfo.browser,
|
|
143
|
-
deviceInfo.os,
|
|
144
|
-
session.ipAddress || unavailableValue,
|
|
145
|
-
toIsoTimestamp(session.loginTime),
|
|
146
|
-
toIsoTimestamp(session.lastActive || session.loginTime),
|
|
147
|
-
toIsoTimestamp(session.logoutTime),
|
|
148
|
-
minutesIdle,
|
|
149
|
-
getSessionEndReason(session) || ""
|
|
150
|
-
];
|
|
151
|
-
});
|
|
152
|
-
return [
|
|
153
|
-
CSV_HEADERS.map(escapeCsvValue).join(","),
|
|
154
|
-
...csvRows.map((row) => row.map(escapeCsvValue).join(","))
|
|
155
|
-
].join("\n");
|
|
156
|
-
}
|
|
157
|
-
function buildSessionJson(sessions, {
|
|
158
|
-
filterStatus,
|
|
159
|
-
totalSessions,
|
|
160
|
-
exportedAt,
|
|
161
|
-
unavailableValue,
|
|
162
|
-
getDeviceInfo,
|
|
163
|
-
getSessionStatus,
|
|
164
|
-
getSessionEndReason = index.getSessionEndReason,
|
|
165
|
-
truncated = false
|
|
166
|
-
}) {
|
|
167
|
-
const rows = Array.isArray(sessions) ? sessions : [];
|
|
168
|
-
const exportData = {
|
|
169
|
-
exportedAt,
|
|
170
|
-
filter: filterStatus,
|
|
171
|
-
totalSessions,
|
|
172
|
-
exportedSessions: rows.length,
|
|
173
|
-
...truncated ? { truncated: true } : {},
|
|
174
|
-
sessions: rows.map((session) => {
|
|
175
|
-
const deviceInfo = getDeviceInfo(session, unavailableValue);
|
|
176
|
-
return {
|
|
177
|
-
id: session.id,
|
|
178
|
-
status: getSessionStatus(session),
|
|
179
|
-
endReason: getSessionEndReason(session) || null,
|
|
180
|
-
user: {
|
|
181
|
-
id: session.user?.documentId || session.user?.id,
|
|
182
|
-
email: session.user?.email,
|
|
183
|
-
username: session.user?.username
|
|
184
|
-
},
|
|
185
|
-
device: {
|
|
186
|
-
type: deviceInfo.device,
|
|
187
|
-
browser: deviceInfo.browser,
|
|
188
|
-
browserVersion: deviceInfo.browserVersion,
|
|
189
|
-
os: deviceInfo.os
|
|
190
|
-
},
|
|
191
|
-
ipAddress: session.ipAddress || unavailableValue,
|
|
192
|
-
loginTime: session.loginTime,
|
|
193
|
-
lastActive: session.lastActive,
|
|
194
|
-
logoutTime: session.logoutTime,
|
|
195
|
-
minutesSinceActive: session.minutesSinceActive,
|
|
196
|
-
isActive: session.isActive,
|
|
197
|
-
isTrulyActive: session.isTrulyActive
|
|
198
|
-
};
|
|
199
|
-
})
|
|
200
|
-
};
|
|
201
|
-
return JSON.stringify(exportData, null, 2);
|
|
202
|
-
}
|
|
203
97
|
const DS_BREAKPOINTS = Object.freeze({
|
|
204
98
|
small: "@media(min-width: 520px)",
|
|
205
99
|
medium: "@media(min-width: 768px)",
|
|
@@ -288,7 +182,7 @@ function normalizeGeoData(geo, fallback = {}) {
|
|
|
288
182
|
const city = index.presentText(geo.city);
|
|
289
183
|
const timezone = index.presentText(geo.timezone);
|
|
290
184
|
if (!country && !city && !timezone) return null;
|
|
291
|
-
const riskSource =
|
|
185
|
+
const riskSource = dashboardModel.isRiskSource(geo.riskSource) ? geo.riskSource : null;
|
|
292
186
|
const rawScore = typeof geo.securityScore === "number" ? geo.securityScore : fallback?.securityScore;
|
|
293
187
|
const securityScore = riskSource && typeof rawScore === "number" && Number.isFinite(rawScore) ? rawScore : null;
|
|
294
188
|
return {
|
|
@@ -379,8 +273,8 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
|
|
|
379
273
|
const userAgent = index.presentText(session.userAgent);
|
|
380
274
|
const sessionId = index.presentText(session.id);
|
|
381
275
|
const ipAddress = index.presentText(session.ipAddress);
|
|
382
|
-
const user =
|
|
383
|
-
const userEditPath =
|
|
276
|
+
const user = dashboardModel.getSessionUserLabels(session);
|
|
277
|
+
const userEditPath = dashboardModel.getUserEditPath(session);
|
|
384
278
|
const storedGeo = getStoredGeoData(session);
|
|
385
279
|
const liveGeo = lookup.status === "ok" ? lookup.geo : null;
|
|
386
280
|
const geo = liveGeo || storedGeo;
|
|
@@ -612,7 +506,7 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
|
|
|
612
506
|
"modal.security.riskUnavailableNote",
|
|
613
507
|
"Needs a risk data source. Location data alone cannot tell VPNs, proxies or Tor apart, so no score was calculated."
|
|
614
508
|
) }),
|
|
615
|
-
/* @__PURE__ */ jsxRuntime.jsx(TargetLink, { tag: reactRouterDom.NavLink, to:
|
|
509
|
+
/* @__PURE__ */ jsxRuntime.jsx(TargetLink, { tag: reactRouterDom.NavLink, to: dashboardModel.RISK_SETTINGS_PATH, children: t("modal.security.riskSetup", "Set up risk data") })
|
|
616
510
|
] }) : null,
|
|
617
511
|
lookupControls
|
|
618
512
|
] }),
|
|
@@ -755,9 +649,9 @@ const isolateActionKeys = (event) => {
|
|
|
755
649
|
/** @type {Node} */
|
|
756
650
|
event.target
|
|
757
651
|
);
|
|
758
|
-
if (!
|
|
652
|
+
if (!dashboardModel.shouldIsolateActionKey(event.key, fromInsideGroup)) return;
|
|
759
653
|
event.stopPropagation();
|
|
760
|
-
if (
|
|
654
|
+
if (dashboardModel.shouldRedispatchEscape(event.key, fromInsideGroup)) {
|
|
761
655
|
const { ownerDocument } = event.currentTarget;
|
|
762
656
|
ownerDocument.dispatchEvent(
|
|
763
657
|
new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true })
|
|
@@ -805,7 +699,7 @@ const SessionActions = ({
|
|
|
805
699
|
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
806
700
|
const [deleteOpen, setDeleteOpen] = react.useState(false);
|
|
807
701
|
const moreRef = react.useRef(null);
|
|
808
|
-
const user =
|
|
702
|
+
const user = dashboardModel.getSessionUserLabels(session).accessible;
|
|
809
703
|
const canEnd = session.isActive === true;
|
|
810
704
|
const device = deviceSummary(session) || deviceTypeLabel(session);
|
|
811
705
|
const copy = getConfirmationCopy(t, { user, device, isOpen: canEnd });
|
|
@@ -832,7 +726,7 @@ const SessionActions = ({
|
|
|
832
726
|
);
|
|
833
727
|
const endKey = `end-${session.id}-${canEnd ? "open" : "ended"}`;
|
|
834
728
|
if (layout === "table") {
|
|
835
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
729
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(dashboardModel.RowActions, { onKeyDown: isolateActionKeys, onClick: (event) => event.stopPropagation(), children: [
|
|
836
730
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
837
731
|
designSystem.IconButton,
|
|
838
732
|
{
|
|
@@ -973,7 +867,7 @@ const SessionTable = ({
|
|
|
973
867
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
974
868
|
designSystem.Table,
|
|
975
869
|
{
|
|
976
|
-
colCount: compact ?
|
|
870
|
+
colCount: compact ? dashboardModel.DASHBOARD_COMPACT_TABLE_COLUMNS : dashboardModel.DASHBOARD_TABLE_COLUMNS,
|
|
977
871
|
rowCount: sessions.length + 1,
|
|
978
872
|
"aria-labelledby": labelledBy,
|
|
979
873
|
"aria-busy": busy,
|
|
@@ -988,7 +882,7 @@ const SessionTable = ({
|
|
|
988
882
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("homepage.table.actions", "Actions") }) })
|
|
989
883
|
] }) }),
|
|
990
884
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: sessions.map((session) => {
|
|
991
|
-
const user =
|
|
885
|
+
const user = dashboardModel.getSessionUserLabels(session);
|
|
992
886
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
993
887
|
designSystem.Tr,
|
|
994
888
|
{
|
|
@@ -1064,7 +958,7 @@ const SessionCardList = ({
|
|
|
1064
958
|
mutationPending,
|
|
1065
959
|
getFocusFallback
|
|
1066
960
|
}) => /* @__PURE__ */ jsxRuntime.jsx(CardList, { "aria-labelledby": labelledBy, "aria-busy": busy, children: sessions.map((session) => {
|
|
1067
|
-
const user =
|
|
961
|
+
const user = dashboardModel.getSessionUserLabels(session);
|
|
1068
962
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1069
963
|
designSystem.Box,
|
|
1070
964
|
{
|
|
@@ -1200,12 +1094,12 @@ const Legend = styled__default.default.ul`
|
|
|
1200
1094
|
const HowSessionsWork = () => {
|
|
1201
1095
|
const { formatMessage } = reactIntl.useIntl();
|
|
1202
1096
|
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1203
|
-
const [open, setOpen] = react.useState(() =>
|
|
1097
|
+
const [open, setOpen] = react.useState(() => dashboardModel.readDisclosureOpen(dashboardModel.getBrowserStorage()));
|
|
1204
1098
|
const contentId = `how-sessions-work-${react.useId().replace(/:/g, "")}`;
|
|
1205
1099
|
const toggle = () => {
|
|
1206
1100
|
setOpen((previous) => {
|
|
1207
1101
|
const next = !previous;
|
|
1208
|
-
|
|
1102
|
+
dashboardModel.writeDisclosureOpen(dashboardModel.getBrowserStorage(), next);
|
|
1209
1103
|
return next;
|
|
1210
1104
|
});
|
|
1211
1105
|
};
|
|
@@ -1674,2557 +1568,1235 @@ const UntrackedSessionsNotice = ({ stats, onChanged, fallbackFocusRef }) => {
|
|
|
1674
1568
|
)
|
|
1675
1569
|
] });
|
|
1676
1570
|
};
|
|
1677
|
-
const
|
|
1678
|
-
const
|
|
1679
|
-
const
|
|
1680
|
-
const PaginationTargets$2 = styled__default.default.div`
|
|
1681
|
-
nav a {
|
|
1682
|
-
min-width: 3.2rem;
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
& > div {
|
|
1686
|
-
flex-wrap: wrap;
|
|
1687
|
-
gap: ${({ theme }) => theme.spaces[2]} ${({ theme }) => theme.spaces[4]};
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
& > div > div > span {
|
|
1691
|
-
white-space: nowrap;
|
|
1692
|
-
}
|
|
1693
|
-
`;
|
|
1694
|
-
const downloadFile = (content, type, extension) => {
|
|
1695
|
-
const blob = new Blob([content], { type });
|
|
1696
|
-
const url = URL.createObjectURL(blob);
|
|
1697
|
-
const link = document.createElement("a");
|
|
1698
|
-
link.href = url;
|
|
1699
|
-
link.download = `sessions-export-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.${extension}`;
|
|
1700
|
-
link.click();
|
|
1701
|
-
window.setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
1702
|
-
};
|
|
1703
|
-
const HomePage = () => {
|
|
1571
|
+
const ADMIN_ACTIVITY_SETTINGS_PATH = `/settings/${index.pluginId}/general?tab=admin-activity`;
|
|
1572
|
+
const ADMIN_ACTIVITY_PAGE_PATH = `/plugins/${index.pluginId}/admin-panel/activity`;
|
|
1573
|
+
const useT$3 = () => {
|
|
1704
1574
|
const { formatMessage } = reactIntl.useIntl();
|
|
1705
|
-
|
|
1575
|
+
return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1576
|
+
};
|
|
1577
|
+
const PeriodSelect = ({ value, onChange }) => {
|
|
1578
|
+
const t = useT$3();
|
|
1579
|
+
const labels = {
|
|
1580
|
+
1: t("adminPanel.activity.period.day", "Last 24 hours"),
|
|
1581
|
+
7: t("adminPanel.activity.period.week", "Last 7 days"),
|
|
1582
|
+
30: t("adminPanel.activity.period.month", "Last 30 days"),
|
|
1583
|
+
90: t("adminPanel.activity.period.quarter", "Last 90 days"),
|
|
1584
|
+
all: t("adminPanel.activity.period.all", "All kept events")
|
|
1585
|
+
};
|
|
1586
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1587
|
+
designSystem.SingleSelect,
|
|
1588
|
+
{
|
|
1589
|
+
size: "S",
|
|
1590
|
+
"aria-label": t("adminPanel.activity.period.label", "Period"),
|
|
1591
|
+
value,
|
|
1592
|
+
onChange: (next) => onChange(String(next)),
|
|
1593
|
+
children: index.PERIOD_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: labels[option] }, option))
|
|
1594
|
+
}
|
|
1595
|
+
);
|
|
1596
|
+
};
|
|
1597
|
+
const FilterTag = ({ label, onRemove, children, ...rest }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1598
|
+
designSystem.Flex,
|
|
1599
|
+
{
|
|
1600
|
+
gap: 1,
|
|
1601
|
+
alignItems: "center",
|
|
1602
|
+
background: "primary100",
|
|
1603
|
+
borderColor: "primary200",
|
|
1604
|
+
hasRadius: true,
|
|
1605
|
+
paddingLeft: 3,
|
|
1606
|
+
minWidth: 0,
|
|
1607
|
+
...rest,
|
|
1608
|
+
children: [
|
|
1609
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "semiBold", textColor: "primary700", children }),
|
|
1610
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { label, variant: "ghost", size: "S", onClick: onRemove, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}) })
|
|
1611
|
+
]
|
|
1612
|
+
}
|
|
1613
|
+
);
|
|
1614
|
+
const FilterSlot = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", minWidth: 0, flex: "1 1 18rem", children });
|
|
1615
|
+
const EmptyText = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", "data-event-empty": "", children });
|
|
1616
|
+
const EventList = ({
|
|
1617
|
+
filters,
|
|
1618
|
+
notice,
|
|
1619
|
+
list,
|
|
1620
|
+
empty,
|
|
1621
|
+
renderList,
|
|
1622
|
+
toCsv,
|
|
1623
|
+
fileName,
|
|
1624
|
+
exportLabel,
|
|
1625
|
+
footer
|
|
1626
|
+
}) => {
|
|
1627
|
+
const t = useT$3();
|
|
1706
1628
|
const { toggleNotification } = StrapiAdmin.useNotification();
|
|
1707
|
-
const formatters = index.useSessionFormatters();
|
|
1708
|
-
const { isBelowSmall, isBelowMedium, isBelowLarge } = useBreakpoint();
|
|
1709
|
-
const [listWidthRef, listWidth] = settingsTabs.useElementWidth();
|
|
1710
|
-
const [{ query }, setQuery] = StrapiAdmin.useQueryParams();
|
|
1711
|
-
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1712
|
-
const dashboard = settingsTabs.parseDashboardQuery(query);
|
|
1713
|
-
const [sessions, setSessions] = react.useState([]);
|
|
1714
|
-
const [pagination, setPagination] = react.useState({ total: 0, pageCount: 1 });
|
|
1715
|
-
const [stats, setStats] = react.useState(EMPTY_SESSION_STATS);
|
|
1716
1629
|
const [exporting, setExporting] = react.useState(false);
|
|
1717
|
-
const
|
|
1718
|
-
const
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
const [lastUpdated, setLastUpdated] = react.useState(null);
|
|
1722
|
-
const [now, setNow] = react.useState(() => Date.now());
|
|
1723
|
-
const [selectedSession, setSelectedSession] = react.useState(null);
|
|
1724
|
-
const [showDetailModal, setShowDetailModal] = react.useState(false);
|
|
1725
|
-
const [terminatingSessionId, setTerminatingSessionId] = react.useState(null);
|
|
1726
|
-
const [deletingSessionId, setDeletingSessionId] = react.useState(null);
|
|
1727
|
-
const openerRef = react.useRef(null);
|
|
1728
|
-
const dashboardRef = react.useRef(null);
|
|
1729
|
-
const listHeadingRef = react.useRef(null);
|
|
1730
|
-
const hasLoadedRef = react.useRef(false);
|
|
1731
|
-
const requestIdRef = react.useRef(0);
|
|
1732
|
-
const visibleIdsRef = react.useRef([]);
|
|
1733
|
-
const mutationSnapshotRef = react.useRef([]);
|
|
1734
|
-
const listHeadingId = `session-list-caption-${react.useId().replace(/:/g, "")}`;
|
|
1735
|
-
const mutationPending = Boolean(terminatingSessionId || deletingSessionId);
|
|
1736
|
-
const listQuery = react.useMemo(
|
|
1737
|
-
() => ({
|
|
1738
|
-
page: dashboard.page,
|
|
1739
|
-
pageSize: dashboard.pageSize,
|
|
1740
|
-
status: dashboard.status,
|
|
1741
|
-
reason: dashboard.reason,
|
|
1742
|
-
search: dashboard.search
|
|
1743
|
-
}),
|
|
1744
|
-
[dashboard.page, dashboard.pageSize, dashboard.status, dashboard.reason, dashboard.search]
|
|
1745
|
-
);
|
|
1746
|
-
react.useEffect(() => {
|
|
1747
|
-
const timer = setInterval(() => setNow(Date.now()), CLOCK_TICK_MS);
|
|
1748
|
-
return () => clearInterval(timer);
|
|
1749
|
-
}, []);
|
|
1750
|
-
const fetchSessions = react.useCallback(async () => {
|
|
1751
|
-
const requestId = requestIdRef.current + 1;
|
|
1752
|
-
requestIdRef.current = requestId;
|
|
1753
|
-
if (hasLoadedRef.current) setRefreshing(true);
|
|
1754
|
-
else setLoading(true);
|
|
1755
|
-
try {
|
|
1756
|
-
const [listResponse, statsResponse] = await Promise.all([
|
|
1757
|
-
get(`/${index.pluginId}/sessions`, { params: buildListParams(listQuery) }),
|
|
1758
|
-
get(`/${index.pluginId}/sessions/stats`)
|
|
1759
|
-
]);
|
|
1760
|
-
const page = readSessionPage(listResponse.data);
|
|
1761
|
-
const nextStats = readSessionStats(statsResponse.data);
|
|
1762
|
-
if (requestId !== requestIdRef.current) return;
|
|
1763
|
-
setSessions(page.rows);
|
|
1764
|
-
setPagination(page.pagination);
|
|
1765
|
-
setStats(nextStats);
|
|
1766
|
-
setLoadError(false);
|
|
1767
|
-
setHasData(true);
|
|
1768
|
-
setLastUpdated(Date.now());
|
|
1769
|
-
setNow(Date.now());
|
|
1770
|
-
hasLoadedRef.current = true;
|
|
1771
|
-
} catch (err) {
|
|
1772
|
-
if (requestId !== requestIdRef.current || index.isCancelledRequest(err)) return;
|
|
1773
|
-
setLoadError(true);
|
|
1774
|
-
index.logSafeAdminError("dashboard.loadSessions", err);
|
|
1775
|
-
} finally {
|
|
1776
|
-
if (requestId === requestIdRef.current) {
|
|
1777
|
-
setLoading(false);
|
|
1778
|
-
setRefreshing(false);
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
}, [get, listQuery]);
|
|
1782
|
-
react.useEffect(() => {
|
|
1783
|
-
fetchSessions();
|
|
1784
|
-
}, [fetchSessions]);
|
|
1785
|
-
react.useEffect(() => {
|
|
1786
|
-
if (showDetailModal || mutationPending) return void 0;
|
|
1787
|
-
const interval = setInterval(() => {
|
|
1788
|
-
fetchSessions();
|
|
1789
|
-
}, settingsTabs.AUTO_REFRESH_INTERVAL_MS);
|
|
1790
|
-
return () => clearInterval(interval);
|
|
1791
|
-
}, [showDetailModal, mutationPending, fetchSessions]);
|
|
1792
|
-
const handleTerminateSession = async (session) => {
|
|
1793
|
-
if (terminatingSessionId || deletingSessionId) return;
|
|
1794
|
-
const sessionId = session.id;
|
|
1795
|
-
mutationSnapshotRef.current = visibleIdsRef.current;
|
|
1796
|
-
setTerminatingSessionId(sessionId);
|
|
1630
|
+
const total = list.meta?.pagination?.total ?? 0;
|
|
1631
|
+
const handleExport = async () => {
|
|
1632
|
+
if (exporting) return;
|
|
1633
|
+
setExporting(true);
|
|
1797
1634
|
try {
|
|
1798
|
-
await
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
type: "success",
|
|
1802
|
-
message: t("notifications.success.sessionEnded", "Session ended.")
|
|
1803
|
-
});
|
|
1804
|
-
} catch (err) {
|
|
1805
|
-
index.logSafeAdminError("dashboard.terminateSession", err);
|
|
1806
|
-
if (settingsTabs.getErrorStatus(err) === 404) {
|
|
1807
|
-
await fetchSessions();
|
|
1635
|
+
const { rows, capped } = await list.exportAll();
|
|
1636
|
+
index.downloadCsv(toCsv(rows), fileName);
|
|
1637
|
+
if (capped) {
|
|
1808
1638
|
toggleNotification({
|
|
1809
1639
|
type: "warning",
|
|
1810
1640
|
message: t(
|
|
1811
|
-
"
|
|
1812
|
-
"
|
|
1641
|
+
"adminPanel.activity.export.capped",
|
|
1642
|
+
"The export contains the newest {limit, number} events. Narrow the filter to export the rest.",
|
|
1643
|
+
{ limit: index.MAX_EVENT_EXPORT_ROWS }
|
|
1813
1644
|
)
|
|
1814
1645
|
});
|
|
1815
|
-
return;
|
|
1816
1646
|
}
|
|
1817
|
-
toggleNotification({
|
|
1818
|
-
type: "danger",
|
|
1819
|
-
message: t(
|
|
1820
|
-
"notifications.error.endSession",
|
|
1821
|
-
"The session could not be ended. Please try again."
|
|
1822
|
-
)
|
|
1823
|
-
});
|
|
1824
|
-
throw err;
|
|
1825
|
-
} finally {
|
|
1826
|
-
setTerminatingSessionId(null);
|
|
1827
|
-
}
|
|
1828
|
-
};
|
|
1829
|
-
const handleDeleteSession = async (session) => {
|
|
1830
|
-
if (terminatingSessionId || deletingSessionId) return;
|
|
1831
|
-
const sessionId = session.id;
|
|
1832
|
-
mutationSnapshotRef.current = visibleIdsRef.current;
|
|
1833
|
-
setDeletingSessionId(sessionId);
|
|
1834
|
-
try {
|
|
1835
|
-
await del(`/${index.pluginId}/sessions/${sessionId}`);
|
|
1836
|
-
await fetchSessions();
|
|
1837
|
-
toggleNotification({
|
|
1838
|
-
type: "success",
|
|
1839
|
-
message: t(
|
|
1840
|
-
"notifications.success.recordDeleted",
|
|
1841
|
-
"Session record deleted. Its token stays revoked."
|
|
1842
|
-
)
|
|
1843
|
-
});
|
|
1844
1647
|
} catch (err) {
|
|
1845
|
-
index.
|
|
1846
|
-
|
|
1847
|
-
await fetchSessions();
|
|
1848
|
-
toggleNotification({
|
|
1849
|
-
type: "warning",
|
|
1850
|
-
message: t(
|
|
1851
|
-
"notifications.error.sessionGone",
|
|
1852
|
-
"This session no longer exists. The list was refreshed."
|
|
1853
|
-
)
|
|
1854
|
-
});
|
|
1855
|
-
return;
|
|
1856
|
-
}
|
|
1648
|
+
if (index.isCancelledRequest(err)) return;
|
|
1649
|
+
index.logSafeAdminError("adminPanel.activity.export", err);
|
|
1857
1650
|
toggleNotification({
|
|
1858
1651
|
type: "danger",
|
|
1859
|
-
message: t(
|
|
1860
|
-
"notifications.error.deleteRecord",
|
|
1861
|
-
"The record could not be deleted. Please try again."
|
|
1862
|
-
)
|
|
1652
|
+
message: t("adminPanel.activity.export.error", "The export could not be created.")
|
|
1863
1653
|
});
|
|
1864
|
-
throw err;
|
|
1865
1654
|
} finally {
|
|
1866
|
-
|
|
1655
|
+
setExporting(false);
|
|
1867
1656
|
}
|
|
1868
1657
|
};
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
let cursor = null;
|
|
1884
|
-
do {
|
|
1885
|
-
const { data } = await get(`/${index.pluginId}/sessions/export`, {
|
|
1886
|
-
params: buildExportParams(listQuery, cursor)
|
|
1887
|
-
});
|
|
1888
|
-
rows.push(...index.requireSessionList(data));
|
|
1889
|
-
cursor = typeof data?.meta?.nextCursor === "string" ? data.meta.nextCursor : null;
|
|
1890
|
-
} while (cursor && rows.length < MAX_EXPORT_ROWS);
|
|
1891
|
-
const capped = rows.length > MAX_EXPORT_ROWS || Boolean(cursor) && rows.length >= MAX_EXPORT_ROWS;
|
|
1892
|
-
return { rows: rows.slice(0, MAX_EXPORT_ROWS), capped };
|
|
1893
|
-
};
|
|
1894
|
-
const handleExport = async (format) => {
|
|
1895
|
-
if (exporting) return;
|
|
1896
|
-
setExporting(true);
|
|
1897
|
-
try {
|
|
1898
|
-
const { rows, capped } = await fetchExportRows();
|
|
1899
|
-
if (format === "csv") {
|
|
1900
|
-
const csvContent = buildSessionCsv(rows, {
|
|
1901
|
-
unavailableValue: "",
|
|
1902
|
-
getDeviceInfo: settingsTabs.getExportDeviceInfo,
|
|
1903
|
-
getSessionStatus: index.getSessionStatus
|
|
1904
|
-
});
|
|
1905
|
-
downloadFile(csvContent, "text/csv;charset=utf-8;", "csv");
|
|
1906
|
-
} else {
|
|
1907
|
-
const jsonContent = buildSessionJson(rows, {
|
|
1908
|
-
filterStatus: dashboard.status,
|
|
1909
|
-
totalSessions: stats.total,
|
|
1910
|
-
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1911
|
-
unavailableValue: "",
|
|
1912
|
-
getDeviceInfo: settingsTabs.getExportDeviceInfo,
|
|
1913
|
-
getSessionStatus: index.getSessionStatus,
|
|
1914
|
-
truncated: capped
|
|
1915
|
-
});
|
|
1916
|
-
downloadFile(jsonContent, "application/json", "json");
|
|
1917
|
-
}
|
|
1918
|
-
if (capped) {
|
|
1919
|
-
toggleNotification({
|
|
1920
|
-
type: "warning",
|
|
1921
|
-
message: t(
|
|
1922
|
-
"homepage.export.capped",
|
|
1923
|
-
"The export contains the newest {limit, number} sessions. Narrow the filter to export the rest.",
|
|
1924
|
-
{ limit: MAX_EXPORT_ROWS }
|
|
1925
|
-
)
|
|
1926
|
-
});
|
|
1927
|
-
}
|
|
1928
|
-
} catch (err) {
|
|
1929
|
-
if (index.isCancelledRequest(err)) return;
|
|
1930
|
-
index.logSafeAdminError(format === "csv" ? "dashboard.exportCsv" : "dashboard.exportJson", err);
|
|
1931
|
-
toggleNotification({
|
|
1932
|
-
type: "danger",
|
|
1933
|
-
message: t("notifications.error.exportFailed", "The export could not be created.")
|
|
1934
|
-
});
|
|
1935
|
-
} finally {
|
|
1936
|
-
setExporting(false);
|
|
1937
|
-
}
|
|
1938
|
-
};
|
|
1939
|
-
const handleSessionClick = (session, opener) => {
|
|
1940
|
-
openerRef.current = opener;
|
|
1941
|
-
setSelectedSession(session);
|
|
1942
|
-
setShowDetailModal(true);
|
|
1943
|
-
};
|
|
1944
|
-
const handleModalClose = () => {
|
|
1945
|
-
setShowDetailModal(false);
|
|
1946
|
-
setSelectedSession(null);
|
|
1947
|
-
};
|
|
1948
|
-
const handleCloseAutoFocus = (event) => {
|
|
1949
|
-
index.restoreDialogFocus(event, openerRef.current, listHeadingRef.current || dashboardRef.current);
|
|
1950
|
-
};
|
|
1951
|
-
const getFocusFallback = react.useCallback(
|
|
1952
|
-
(sessionId) => ({
|
|
1953
|
-
get current() {
|
|
1954
|
-
const targetId = settingsTabs.pickFocusSessionId(
|
|
1955
|
-
mutationSnapshotRef.current,
|
|
1956
|
-
visibleIdsRef.current,
|
|
1957
|
-
sessionId
|
|
1958
|
-
);
|
|
1959
|
-
const root = dashboardRef.current;
|
|
1960
|
-
if (targetId && root) {
|
|
1961
|
-
const escaped = typeof CSS !== "undefined" && CSS.escape ? CSS.escape(targetId) : targetId;
|
|
1962
|
-
const button = root.querySelector(`[data-session-view="${escaped}"]`);
|
|
1963
|
-
if (button) return button;
|
|
1658
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
|
|
1659
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
|
|
1660
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", flex: "1 1 auto", minWidth: 0, children: filters }),
|
|
1661
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1662
|
+
designSystem.Button,
|
|
1663
|
+
{
|
|
1664
|
+
size: "S",
|
|
1665
|
+
variant: "tertiary",
|
|
1666
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
|
|
1667
|
+
onClick: handleExport,
|
|
1668
|
+
loading: exporting,
|
|
1669
|
+
disabled: list.loading || total === 0,
|
|
1670
|
+
"aria-label": exportLabel,
|
|
1671
|
+
children: t("adminPanel.activity.export.csv", "Export CSV")
|
|
1964
1672
|
}
|
|
1965
|
-
|
|
1673
|
+
)
|
|
1674
|
+
] }),
|
|
1675
|
+
notice,
|
|
1676
|
+
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,
|
|
1677
|
+
!list.loading && list.error ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1678
|
+
index.PersistentAlert,
|
|
1679
|
+
{
|
|
1680
|
+
variant: "danger",
|
|
1681
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: list.reload, children: t("common.tryAgain", "Try again") }),
|
|
1682
|
+
children: t("adminPanel.activity.error", "The events could not be loaded.")
|
|
1966
1683
|
}
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1684
|
+
) : null,
|
|
1685
|
+
!list.loading && !list.error && list.rows.length === 0 ? empty : null,
|
|
1686
|
+
list.rows.length > 0 ? renderList(list.rows) : null,
|
|
1687
|
+
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
|
|
1688
|
+
] });
|
|
1689
|
+
};
|
|
1690
|
+
const RecordingOff = ({ children, to = ADMIN_ACTIVITY_SETTINGS_PATH }) => {
|
|
1691
|
+
const t = useT$3();
|
|
1692
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1693
|
+
index.PersistentAlert,
|
|
1694
|
+
{
|
|
1695
|
+
variant: "neutral",
|
|
1696
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Link, { tag: reactRouterDom.Link, to, children: t("adminPanel.activity.openSettings", "Open settings") }),
|
|
1697
|
+
children
|
|
1973
1698
|
}
|
|
1974
|
-
}, [loading, refreshing, dashboard.page, pageResult.pageCount, setQuery]);
|
|
1975
|
-
const handleStatusChange = (value) => {
|
|
1976
|
-
const status = String(value);
|
|
1977
|
-
setQuery({ status: status === "all" ? void 0 : status, reason: void 0, page: "1" });
|
|
1978
|
-
};
|
|
1979
|
-
const handleReasonChange = (value) => {
|
|
1980
|
-
const reason = String(value);
|
|
1981
|
-
setQuery({ reason: reason === "all" ? void 0 : reason, page: "1" });
|
|
1982
|
-
};
|
|
1983
|
-
const handleSearch = react.useCallback(
|
|
1984
|
-
(value) => {
|
|
1985
|
-
setQuery({ search: settingsTabs.encodeSearchQuery(value), _q: void 0, page: "1" }, "push", true);
|
|
1986
|
-
},
|
|
1987
|
-
[setQuery]
|
|
1988
1699
|
);
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1700
|
+
};
|
|
1701
|
+
const SignInHistoryPanel = ({ admin }) => {
|
|
1702
|
+
const t = useT$3();
|
|
1703
|
+
const [event, setEvent] = react.useState("all");
|
|
1704
|
+
const [period, setPeriod] = react.useState("30");
|
|
1705
|
+
const params = react.useMemo(
|
|
1706
|
+
() => index.buildSignInParams({ adminId: admin.id, event, period }),
|
|
1707
|
+
[admin.id, event, period]
|
|
1708
|
+
);
|
|
1709
|
+
const list = index.useEventList({
|
|
1710
|
+
path: `/${index.pluginId}/admin-activity/sign-ins`,
|
|
1711
|
+
params,
|
|
1712
|
+
logKey: "adminPanel.activity.signIns"
|
|
1713
|
+
});
|
|
1714
|
+
const recording = list.meta?.recording;
|
|
1715
|
+
const labels = {
|
|
1716
|
+
all: t("adminPanel.activity.filter.allEvents", "All events"),
|
|
1717
|
+
succeeded: t("adminPanel.activity.filter.succeeded", "Sign-ins"),
|
|
1718
|
+
failed: t("adminPanel.activity.filter.failed", "Failed and locked out"),
|
|
1719
|
+
"signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs")
|
|
1992
1720
|
};
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
const canExport = showSessionData && pageResult.total > 0 && !exporting;
|
|
1996
|
-
const filtersActive = settingsTabs.hasActiveFilters(dashboard);
|
|
1997
|
-
const exportValues = { count: Math.min(pageResult.total, MAX_EXPORT_ROWS) };
|
|
1998
|
-
const exportMenu = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1999
|
-
designSystem.SimpleMenu,
|
|
1721
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1722
|
+
EventList,
|
|
2000
1723
|
{
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
1724
|
+
list,
|
|
1725
|
+
filters: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1726
|
+
/* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1727
|
+
designSystem.SingleSelect,
|
|
1728
|
+
{
|
|
1729
|
+
size: "S",
|
|
1730
|
+
"aria-label": t("adminPanel.activity.filter.event", "Event"),
|
|
1731
|
+
value: event,
|
|
1732
|
+
onChange: (next) => setEvent(String(next)),
|
|
1733
|
+
children: index.SIGN_IN_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: labels[option] }, option))
|
|
1734
|
+
}
|
|
2010
1735
|
) }),
|
|
2011
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
1736
|
+
/* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(PeriodSelect, { value: period, onChange: setPeriod }) })
|
|
1737
|
+
] }),
|
|
1738
|
+
notice: recording && !recording.signIns ? /* @__PURE__ */ jsxRuntime.jsx(RecordingOff, { children: t(
|
|
1739
|
+
"adminPanel.activity.signIns.off",
|
|
1740
|
+
"Sign-in history is turned off. New sign-ins are not recorded."
|
|
1741
|
+
) }) : null,
|
|
1742
|
+
empty: /* @__PURE__ */ jsxRuntime.jsx(EmptyText, { children: t("adminPanel.activity.signIns.empty", "No sign-in events in this period.") }),
|
|
1743
|
+
renderList: (rows) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1744
|
+
index.SignInEventTable,
|
|
1745
|
+
{
|
|
1746
|
+
rows,
|
|
1747
|
+
busy: list.loading,
|
|
1748
|
+
label: t("adminPanel.activity.signIns.listLabel", "Sign-in history of {name}", {
|
|
1749
|
+
name: admin.name
|
|
1750
|
+
})
|
|
1751
|
+
}
|
|
1752
|
+
),
|
|
1753
|
+
toCsv: index.buildSignInCsv,
|
|
1754
|
+
fileName: "admin-sign-in-history",
|
|
1755
|
+
exportLabel: t(
|
|
1756
|
+
"adminPanel.activity.signIns.export",
|
|
1757
|
+
"Export the sign-in history of {name} as CSV",
|
|
1758
|
+
{
|
|
1759
|
+
name: admin.name
|
|
1760
|
+
}
|
|
1761
|
+
)
|
|
2017
1762
|
}
|
|
2018
1763
|
);
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
const
|
|
2022
|
-
const
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
1764
|
+
};
|
|
1765
|
+
const ContentActivityPanel = ({ admin }) => {
|
|
1766
|
+
const t = useT$3();
|
|
1767
|
+
const [action, setAction] = react.useState("all");
|
|
1768
|
+
const [contentType, setContentType] = react.useState("all");
|
|
1769
|
+
const [period, setPeriod] = react.useState("30");
|
|
1770
|
+
const params = react.useMemo(
|
|
1771
|
+
() => index.buildActivityParams({ adminId: admin.id, action, contentType, period }),
|
|
1772
|
+
[admin.id, action, contentType, period]
|
|
1773
|
+
);
|
|
1774
|
+
const list = index.useEventList({
|
|
1775
|
+
path: `/${index.pluginId}/admin-activity/content`,
|
|
1776
|
+
params,
|
|
1777
|
+
logKey: "adminPanel.activity.content"
|
|
1778
|
+
});
|
|
1779
|
+
const recording = list.meta?.recording;
|
|
1780
|
+
const types = Array.isArray(list.meta?.contentTypes) ? list.meta.contentTypes : [];
|
|
1781
|
+
const noAccess = list.meta?.contentManagerAccess === false;
|
|
1782
|
+
let notice = null;
|
|
1783
|
+
if (recording && !recording.contentActivity) {
|
|
1784
|
+
notice = /* @__PURE__ */ jsxRuntime.jsx(RecordingOff, { children: t(
|
|
1785
|
+
"adminPanel.activity.content.off",
|
|
1786
|
+
"Content Manager activity is not recorded. An admin can turn it on in the settings; inform your team first."
|
|
1787
|
+
) });
|
|
1788
|
+
} else if (noAccess) {
|
|
1789
|
+
notice = /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "neutral", children: t(
|
|
1790
|
+
"adminPanel.activity.content.noAccess",
|
|
1791
|
+
"{name} has no Content Manager access, so there is no activity to show.",
|
|
1792
|
+
{ name: admin.name }
|
|
1793
|
+
) });
|
|
1794
|
+
}
|
|
1795
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1796
|
+
EventList,
|
|
1797
|
+
{
|
|
1798
|
+
list,
|
|
1799
|
+
filters: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1800
|
+
/* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1801
|
+
designSystem.SingleSelect,
|
|
1802
|
+
{
|
|
1803
|
+
size: "S",
|
|
1804
|
+
"aria-label": t("adminPanel.activity.filter.action", "Action"),
|
|
1805
|
+
value: action,
|
|
1806
|
+
onChange: (next) => setAction(String(next)),
|
|
1807
|
+
children: index.ACTIVITY_ACTION_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: t(
|
|
1808
|
+
index.ACTIVITY_ACTION_LABELS[option].messageId,
|
|
1809
|
+
index.ACTIVITY_ACTION_LABELS[option].defaultMessage
|
|
1810
|
+
) }, option))
|
|
1811
|
+
}
|
|
1812
|
+
) }),
|
|
1813
|
+
/* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1814
|
+
designSystem.SingleSelect,
|
|
1815
|
+
{
|
|
1816
|
+
size: "S",
|
|
1817
|
+
"aria-label": t("adminPanel.activity.filter.contentType", "Content type"),
|
|
1818
|
+
value: contentType,
|
|
1819
|
+
onChange: (next) => setContentType(String(next)),
|
|
1820
|
+
children: [
|
|
1821
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "all", children: t("adminPanel.activity.filter.allTypes", "All content types") }),
|
|
1822
|
+
types.map((type) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: type.uid, children: type.name }, type.uid))
|
|
1823
|
+
]
|
|
1824
|
+
}
|
|
1825
|
+
) }),
|
|
1826
|
+
/* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(PeriodSelect, { value: period, onChange: setPeriod }) })
|
|
1827
|
+
] }),
|
|
1828
|
+
notice,
|
|
1829
|
+
empty: /* @__PURE__ */ jsxRuntime.jsx(EmptyText, { children: t("adminPanel.activity.content.empty", "No Content Manager activity in this period.") }),
|
|
1830
|
+
renderList: (rows) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1831
|
+
index.ActivityEventTable,
|
|
1832
|
+
{
|
|
1833
|
+
rows,
|
|
1834
|
+
busy: list.loading,
|
|
1835
|
+
label: t("adminPanel.activity.content.listLabel", "Content Manager activity of {name}", {
|
|
1836
|
+
name: admin.name
|
|
1837
|
+
})
|
|
1838
|
+
}
|
|
1839
|
+
),
|
|
1840
|
+
toCsv: index.buildActivityCsv,
|
|
1841
|
+
fileName: "admin-content-activity",
|
|
1842
|
+
exportLabel: t(
|
|
1843
|
+
"adminPanel.activity.content.export",
|
|
1844
|
+
"Export the Content Manager activity of {name} as CSV",
|
|
1845
|
+
{ name: admin.name }
|
|
1846
|
+
)
|
|
1847
|
+
}
|
|
1848
|
+
);
|
|
1849
|
+
};
|
|
1850
|
+
const RecentEvents = ({
|
|
1851
|
+
title,
|
|
1852
|
+
subtitle,
|
|
1853
|
+
showAllTo,
|
|
1854
|
+
emptyText,
|
|
1855
|
+
list,
|
|
1856
|
+
renderTable,
|
|
1857
|
+
dataKey
|
|
1858
|
+
}) => {
|
|
1859
|
+
const t = useT$3();
|
|
1860
|
+
const headingId = `recent-events-${react.useId().replace(/:/g, "")}`;
|
|
1861
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2083
1862
|
designSystem.Flex,
|
|
2084
1863
|
{
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
1864
|
+
tag: "section",
|
|
1865
|
+
"aria-labelledby": headingId,
|
|
1866
|
+
direction: "column",
|
|
1867
|
+
alignItems: "stretch",
|
|
1868
|
+
gap: 4,
|
|
1869
|
+
minWidth: 0,
|
|
1870
|
+
...{ [`data-${dataKey}`]: "" },
|
|
2088
1871
|
children: [
|
|
2089
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2090
|
-
|
|
1872
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-end", gap: 4, wrap: "wrap", children: [
|
|
1873
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, flex: "1 1 32rem", children: [
|
|
1874
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: headingId, variant: "delta", tag: "h2", textColor: "neutral800", children: title }),
|
|
1875
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: subtitle })
|
|
1876
|
+
] }),
|
|
1877
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1878
|
+
designSystem.LinkButton,
|
|
1879
|
+
{
|
|
1880
|
+
tag: reactRouterDom.Link,
|
|
1881
|
+
to: showAllTo,
|
|
1882
|
+
variant: "tertiary",
|
|
1883
|
+
endIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRight, {}),
|
|
1884
|
+
"data-show-all-activity": "",
|
|
1885
|
+
children: t("adminPanel.activity.recent.showAll", "Show all")
|
|
1886
|
+
}
|
|
1887
|
+
)
|
|
1888
|
+
] }),
|
|
1889
|
+
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,
|
|
1890
|
+
!list.loading && list.error ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1891
|
+
index.PersistentAlert,
|
|
1892
|
+
{
|
|
1893
|
+
variant: "danger",
|
|
1894
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: list.reload, children: t("common.tryAgain", "Try again") }),
|
|
1895
|
+
children: t("adminPanel.activity.error", "The events could not be loaded.")
|
|
1896
|
+
}
|
|
1897
|
+
) : null,
|
|
1898
|
+
!list.loading && !list.error && list.rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", "data-event-empty": "", children: emptyText }) : null,
|
|
1899
|
+
list.rows.length > 0 ? renderTable(title) : null
|
|
2091
1900
|
]
|
|
2092
1901
|
}
|
|
2093
|
-
)
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
labelledBy: listHeadingId,
|
|
2103
|
-
busy: refreshing,
|
|
2104
|
-
onView: handleSessionClick,
|
|
2105
|
-
onEnd: handleTerminateSession,
|
|
2106
|
-
onDelete: handleDeleteSession,
|
|
2107
|
-
mutationPending,
|
|
2108
|
-
getFocusFallback
|
|
2109
|
-
};
|
|
2110
|
-
const statusCard = (status) => ({
|
|
2111
|
-
onClick: () => handleStatusChange(status),
|
|
2112
|
-
pressed: dashboard.status === status
|
|
1902
|
+
);
|
|
1903
|
+
};
|
|
1904
|
+
const RecentSignInActivity = ({ onOpenAdmin }) => {
|
|
1905
|
+
const t = useT$3();
|
|
1906
|
+
const params = react.useMemo(() => index.buildSignInParams({ pageSize: index.RECENT_EVENT_LIMIT }), []);
|
|
1907
|
+
const list = index.useEventList({
|
|
1908
|
+
path: `/${index.pluginId}/admin-activity/sign-ins`,
|
|
1909
|
+
params,
|
|
1910
|
+
logKey: "adminPanel.activity.recent"
|
|
2113
1911
|
});
|
|
1912
|
+
if (list.meta?.recording && !list.meta.recording.signIns) return null;
|
|
2114
1913
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2115
|
-
|
|
1914
|
+
RecentEvents,
|
|
2116
1915
|
{
|
|
2117
|
-
|
|
2118
|
-
title: t("homepage.title", "Sessions"),
|
|
1916
|
+
title: t("adminPanel.activity.recent.title", "Recent security activity"),
|
|
2119
1917
|
subtitle: t(
|
|
2120
|
-
"
|
|
2121
|
-
"
|
|
1918
|
+
"adminPanel.activity.recent.subtitle",
|
|
1919
|
+
"The latest sign-ins, failed attempts, sign-outs and settings changes of all admins. Select an event for its details."
|
|
2122
1920
|
),
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
1921
|
+
showAllTo: ADMIN_ACTIVITY_PAGE_PATH,
|
|
1922
|
+
emptyText: t("adminPanel.activity.recent.empty", "No events recorded yet."),
|
|
1923
|
+
list,
|
|
1924
|
+
dataKey: "recent-activity",
|
|
1925
|
+
renderTable: (title) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1926
|
+
index.SignInEventTable,
|
|
2126
1927
|
{
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
minWidth: 0,
|
|
2133
|
-
children: [
|
|
2134
|
-
/* @__PURE__ */ jsxRuntime.jsx(SessionViewNav, { current: "users" }),
|
|
2135
|
-
!loading && loadError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2136
|
-
index.PersistentAlert,
|
|
2137
|
-
{
|
|
2138
|
-
variant: "danger",
|
|
2139
|
-
closeLabel: t("common.close", "Close"),
|
|
2140
|
-
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: fetchSessions, children: t("common.tryAgain", "Try again") }),
|
|
2141
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: t("homepage.error.load", "Sessions could not be loaded.") })
|
|
2142
|
-
}
|
|
2143
|
-
) : null,
|
|
2144
|
-
showSessionData && stats.nativeOnly > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2145
|
-
UntrackedSessionsNotice,
|
|
2146
|
-
{
|
|
2147
|
-
stats,
|
|
2148
|
-
onChanged: fetchSessions,
|
|
2149
|
-
fallbackFocusRef: dashboardRef
|
|
2150
|
-
}
|
|
2151
|
-
) : null,
|
|
2152
|
-
loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: t("homepage.loading", "Loading sessions") }) }) : null,
|
|
2153
|
-
showSessionData && stats.total > 0 ? /* @__PURE__ */ jsxRuntime.jsx(HowSessionsWork, {}) : null,
|
|
2154
|
-
showSessionData && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
2155
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", children: t("homepage.stats.label", "Session statistics") }) }),
|
|
2156
|
-
/* @__PURE__ */ jsxRuntime.jsxs(index.StatGrid, { label: t("homepage.stats.label", "Session statistics"), children: [
|
|
2157
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2158
|
-
index.StatCard,
|
|
2159
|
-
{
|
|
2160
|
-
icon: icons.Check,
|
|
2161
|
-
tone: "success",
|
|
2162
|
-
label: t("homepage.stats.active", "Active sessions"),
|
|
2163
|
-
value: stats.active,
|
|
2164
|
-
description: t(
|
|
2165
|
-
"homepage.stats.usersOnline",
|
|
2166
|
-
"{count, plural, one {# user online} other {# users online}}",
|
|
2167
|
-
{
|
|
2168
|
-
count: stats.usersOnline
|
|
2169
|
-
}
|
|
2170
|
-
),
|
|
2171
|
-
...statusCard("active")
|
|
2172
|
-
}
|
|
2173
|
-
),
|
|
2174
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2175
|
-
index.StatCard,
|
|
2176
|
-
{
|
|
2177
|
-
icon: icons.Clock,
|
|
2178
|
-
tone: "warning",
|
|
2179
|
-
label: t("homepage.stats.idle", "Idle sessions"),
|
|
2180
|
-
value: stats.idle,
|
|
2181
|
-
...statusCard("idle")
|
|
2182
|
-
}
|
|
2183
|
-
),
|
|
2184
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2185
|
-
index.StatCard,
|
|
2186
|
-
{
|
|
2187
|
-
icon: icons.Cross,
|
|
2188
|
-
tone: "neutral",
|
|
2189
|
-
label: t("homepage.stats.ended", "Ended sessions"),
|
|
2190
|
-
value: stats.ended,
|
|
2191
|
-
description: t(
|
|
2192
|
-
"homepage.stats.endedBreakdown",
|
|
2193
|
-
"{loggedOut, number} logged out · {timedOut, number} timed out · {other, number} other reasons",
|
|
2194
|
-
{
|
|
2195
|
-
loggedOut: stats.loggedOut,
|
|
2196
|
-
timedOut: stats.timedOut,
|
|
2197
|
-
other: stats.otherReasons
|
|
2198
|
-
}
|
|
2199
|
-
),
|
|
2200
|
-
...statusCard("ended")
|
|
2201
|
-
}
|
|
2202
|
-
),
|
|
2203
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2204
|
-
index.StatCard,
|
|
2205
|
-
{
|
|
2206
|
-
icon: icons.User,
|
|
2207
|
-
tone: "primary",
|
|
2208
|
-
label: t("homepage.stats.total", "All sessions"),
|
|
2209
|
-
value: stats.total,
|
|
2210
|
-
...statusCard("all")
|
|
2211
|
-
}
|
|
2212
|
-
)
|
|
2213
|
-
] })
|
|
2214
|
-
] }),
|
|
2215
|
-
showToolbar && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { ref: listWidthRef, direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
|
|
2216
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h2", children: t("homepage.list.heading", "Session list") }) }),
|
|
2217
|
-
toolbar,
|
|
2218
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", gap: 4, wrap: "wrap", children: [
|
|
2219
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2220
|
-
designSystem.Typography,
|
|
2221
|
-
{
|
|
2222
|
-
id: listHeadingId,
|
|
2223
|
-
ref: listHeadingRef,
|
|
2224
|
-
tabIndex: -1,
|
|
2225
|
-
variant: "pi",
|
|
2226
|
-
textColor: "neutral600",
|
|
2227
|
-
"aria-live": "polite",
|
|
2228
|
-
"data-session-caption": "",
|
|
2229
|
-
children: pageResult.total > 0 ? t(
|
|
2230
|
-
"homepage.caption",
|
|
2231
|
-
"{from, number}–{to, number} of {total, plural, one {# session} other {# sessions}}",
|
|
2232
|
-
{
|
|
2233
|
-
from: pageResult.startIndex,
|
|
2234
|
-
to: pageResult.endIndex,
|
|
2235
|
-
total: pageResult.total
|
|
2236
|
-
}
|
|
2237
|
-
) : t("homepage.captionNone", "0 sessions")
|
|
2238
|
-
}
|
|
2239
|
-
),
|
|
2240
|
-
lastUpdatedLine
|
|
2241
|
-
] }),
|
|
2242
|
-
pageResult.total > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2243
|
-
isBelowMedium ? /* @__PURE__ */ jsxRuntime.jsx(SessionCardList, { ...listProps }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2244
|
-
SessionTable,
|
|
2245
|
-
{
|
|
2246
|
-
...listProps,
|
|
2247
|
-
compact: settingsTabs.shouldUseCompactTable(listWidth, isBelowLarge)
|
|
2248
|
-
}
|
|
2249
|
-
),
|
|
2250
|
-
/* @__PURE__ */ jsxRuntime.jsx(PaginationTargets$2, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2251
|
-
StrapiAdmin.Pagination.Root,
|
|
2252
|
-
{
|
|
2253
|
-
pageCount: pageResult.pageCount,
|
|
2254
|
-
total: pageResult.total,
|
|
2255
|
-
defaultPageSize: Number(settingsTabs.DEFAULT_PAGE_SIZE),
|
|
2256
|
-
children: [
|
|
2257
|
-
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...settingsTabs.PAGE_SIZE_OPTIONS] }),
|
|
2258
|
-
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.Links, {})
|
|
2259
|
-
]
|
|
2260
|
-
}
|
|
2261
|
-
) })
|
|
2262
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2263
|
-
designSystem.EmptyStateLayout,
|
|
2264
|
-
{
|
|
2265
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
|
|
2266
|
-
content: t(
|
|
2267
|
-
"homepage.noResults.description",
|
|
2268
|
-
"No sessions match your search or filter."
|
|
2269
|
-
),
|
|
2270
|
-
action: filtersActive ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: handleClearFilters, children: t("homepage.noResults.reset", "Clear filters") }) : null
|
|
2271
|
-
}
|
|
2272
|
-
)
|
|
2273
|
-
] }),
|
|
2274
|
-
showSessionData && stats.total === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2275
|
-
designSystem.EmptyStateLayout,
|
|
2276
|
-
{
|
|
2277
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
|
|
2278
|
-
content: t(
|
|
2279
|
-
"homepage.empty.description",
|
|
2280
|
-
"No sessions yet. Sessions appear here when users of your app sign in."
|
|
2281
|
-
)
|
|
2282
|
-
}
|
|
2283
|
-
),
|
|
2284
|
-
showDetailModal && selectedSession && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2285
|
-
SessionDetailModal,
|
|
2286
|
-
{
|
|
2287
|
-
session: selectedSession,
|
|
2288
|
-
now,
|
|
2289
|
-
onClose: handleModalClose,
|
|
2290
|
-
onCloseAutoFocus: handleCloseAutoFocus,
|
|
2291
|
-
onEndSession: handleTerminateSession
|
|
2292
|
-
}
|
|
2293
|
-
)
|
|
2294
|
-
]
|
|
1928
|
+
rows: list.rows,
|
|
1929
|
+
label: title,
|
|
1930
|
+
showAdmin: true,
|
|
1931
|
+
onOpenAdmin,
|
|
1932
|
+
busy: list.loading
|
|
2295
1933
|
}
|
|
2296
1934
|
)
|
|
2297
1935
|
}
|
|
2298
1936
|
);
|
|
2299
1937
|
};
|
|
2300
|
-
const
|
|
2301
|
-
const
|
|
2302
|
-
const
|
|
2303
|
-
const
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
search: search.slice(0, ADMIN_MAX_SEARCH_LENGTH)
|
|
2323
|
-
};
|
|
2324
|
-
}
|
|
2325
|
-
function buildAdminListParams(state) {
|
|
2326
|
-
return {
|
|
2327
|
-
page: state.page,
|
|
2328
|
-
pageSize: state.pageSize,
|
|
2329
|
-
filter: state.filter,
|
|
2330
|
-
...state.search ? { search: state.search } : {}
|
|
2331
|
-
};
|
|
2332
|
-
}
|
|
2333
|
-
function hasAdminFilters(state) {
|
|
2334
|
-
return state.filter !== "all" || Boolean(state.search);
|
|
2335
|
-
}
|
|
2336
|
-
function getAdminStatusPresentation(row) {
|
|
2337
|
-
if (row?.account === "invited") {
|
|
2338
|
-
return {
|
|
2339
|
-
key: "invited",
|
|
2340
|
-
tone: "secondary",
|
|
2341
|
-
label: { messageId: "adminPanel.status.invited", defaultMessage: "Invited" },
|
|
2342
|
-
detail: {
|
|
2343
|
-
messageId: "adminPanel.status.invited.detail",
|
|
2344
|
-
defaultMessage: "Invitation not accepted yet"
|
|
2345
|
-
}
|
|
2346
|
-
};
|
|
2347
|
-
}
|
|
2348
|
-
if (row?.account === "deactivated") {
|
|
2349
|
-
return {
|
|
2350
|
-
key: "deactivated",
|
|
2351
|
-
tone: "neutral",
|
|
2352
|
-
label: { messageId: "adminPanel.status.deactivated", defaultMessage: "Deactivated" },
|
|
2353
|
-
detail: {
|
|
2354
|
-
messageId: "adminPanel.status.deactivated.detail",
|
|
2355
|
-
defaultMessage: "Cannot sign in"
|
|
2356
|
-
}
|
|
2357
|
-
};
|
|
2358
|
-
}
|
|
2359
|
-
const count = Number(row?.sessionCount) || 0;
|
|
2360
|
-
if (count > 0) {
|
|
2361
|
-
return {
|
|
2362
|
-
key: "signed-in",
|
|
2363
|
-
tone: "success",
|
|
2364
|
-
label: { messageId: "adminPanel.status.signedIn", defaultMessage: "Signed in" },
|
|
2365
|
-
detail: {
|
|
2366
|
-
messageId: "adminPanel.status.signedIn.detail",
|
|
2367
|
-
defaultMessage: "{count, plural, one {# session} other {# sessions}}",
|
|
2368
|
-
values: { count }
|
|
2369
|
-
}
|
|
2370
|
-
};
|
|
2371
|
-
}
|
|
2372
|
-
return {
|
|
2373
|
-
key: "not-signed-in",
|
|
2374
|
-
tone: "neutral",
|
|
2375
|
-
label: { messageId: "adminPanel.status.notSignedIn", defaultMessage: "Not signed in" },
|
|
2376
|
-
detail: {
|
|
2377
|
-
messageId: "adminPanel.status.notSignedIn.detail",
|
|
2378
|
-
defaultMessage: "No open session"
|
|
1938
|
+
const RecentUserActivityList = () => {
|
|
1939
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
1940
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1941
|
+
const params = react.useMemo(() => index.buildUserActivityParams({ pageSize: index.RECENT_USER_EVENT_LIMIT }), []);
|
|
1942
|
+
const list = index.useEventList({
|
|
1943
|
+
path: index.USER_ACTIVITY_API_PATH,
|
|
1944
|
+
params,
|
|
1945
|
+
logKey: "userActivity.recent"
|
|
1946
|
+
});
|
|
1947
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1948
|
+
RecentEvents,
|
|
1949
|
+
{
|
|
1950
|
+
title: t("userActivity.recent.title", "Security activity"),
|
|
1951
|
+
subtitle: t(
|
|
1952
|
+
"userActivity.recent.subtitle",
|
|
1953
|
+
"The latest failed and refused sign-ins, lockouts, new devices, impossible travel and impersonations of your app’s users. Select an event for its details."
|
|
1954
|
+
),
|
|
1955
|
+
showAllTo: index.USER_ACTIVITY_PAGE_PATH,
|
|
1956
|
+
emptyText: t("userActivity.recent.empty", "No security events of app users yet."),
|
|
1957
|
+
list,
|
|
1958
|
+
dataKey: "recent-user-activity",
|
|
1959
|
+
renderTable: (title) => /* @__PURE__ */ jsxRuntime.jsx(index.UserEventTable, { rows: list.rows, label: title, busy: list.loading })
|
|
2379
1960
|
}
|
|
2380
|
-
};
|
|
2381
|
-
}
|
|
2382
|
-
function splitDuration(seconds) {
|
|
2383
|
-
const value = Number(seconds);
|
|
2384
|
-
if (!Number.isFinite(value) || value <= 0) return null;
|
|
2385
|
-
if (value % 86400 === 0) return { unit: "days", count: value / 86400 };
|
|
2386
|
-
if (value % 3600 === 0) return { unit: "hours", count: value / 3600 };
|
|
2387
|
-
return { unit: "minutes", count: Math.max(1, Math.round(value / 60)) };
|
|
2388
|
-
}
|
|
2389
|
-
function getSignOutErrorMessage(error) {
|
|
2390
|
-
const response = (
|
|
2391
|
-
/** @type {any} */
|
|
2392
|
-
error?.response
|
|
2393
1961
|
);
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
const
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
1962
|
+
};
|
|
1963
|
+
const RecentUserActivity = () => {
|
|
1964
|
+
const {
|
|
1965
|
+
allowedActions: { canRead },
|
|
1966
|
+
isLoading
|
|
1967
|
+
} = StrapiAdmin.useRBAC(index.pluginPermissions.userActivityRead);
|
|
1968
|
+
if (isLoading || !canRead) return null;
|
|
1969
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RecentUserActivityList, {});
|
|
1970
|
+
};
|
|
1971
|
+
const CLOCK_TICK_MS = 30 * 1e3;
|
|
1972
|
+
const ANALYTICS_PATH = `/settings/${index.pluginId}/analytics`;
|
|
1973
|
+
const CONFIGURATION_PATH = `/settings/${index.pluginId}/general`;
|
|
1974
|
+
const PaginationTargets$3 = styled__default.default.div`
|
|
1975
|
+
nav a {
|
|
1976
|
+
min-width: 3.2rem;
|
|
2408
1977
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
};
|
|
1978
|
+
|
|
1979
|
+
& > div {
|
|
1980
|
+
flex-wrap: wrap;
|
|
1981
|
+
gap: ${({ theme }) => theme.spaces[2]} ${({ theme }) => theme.spaces[4]};
|
|
2414
1982
|
}
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
defaultMessage: "Too many sign-outs in a short time. Wait a minute and try again."
|
|
2419
|
-
};
|
|
1983
|
+
|
|
1984
|
+
& > div > div > span {
|
|
1985
|
+
white-space: nowrap;
|
|
2420
1986
|
}
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
...admin,
|
|
2431
|
-
name: admin.name || placeholderName(admin.id),
|
|
2432
|
-
identityHidden: hidden,
|
|
2433
|
-
rolesHidden: hidden && identity?.roles === false
|
|
2434
|
-
};
|
|
2435
|
-
}
|
|
2436
|
-
function withEventAdminNames(row, placeholderName) {
|
|
2437
|
-
if (!row || typeof row !== "object") return row;
|
|
2438
|
-
const fill = (admin) => admin && typeof admin === "object" && !admin.name ? { ...admin, name: placeholderName(admin.id), identityHidden: true } : admin;
|
|
2439
|
-
return {
|
|
2440
|
-
...row,
|
|
2441
|
-
...row.admin !== void 0 ? { admin: fill(row.admin) } : {},
|
|
2442
|
-
...row.actor !== void 0 ? { actor: fill(row.actor) } : {}
|
|
2443
|
-
};
|
|
2444
|
-
}
|
|
2445
|
-
const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
|
|
2446
|
-
const offersPreview = (admin, canPreview) => Boolean(canPreview) && admin.self !== true && !(admin.roles || []).some((role) => role?.superAdmin === true);
|
|
2447
|
-
const keepActionKeys = (event) => {
|
|
2448
|
-
if (settingsTabs.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
1987
|
+
`;
|
|
1988
|
+
const downloadFile = (content, type, extension) => {
|
|
1989
|
+
const blob = new Blob([content], { type });
|
|
1990
|
+
const url = URL.createObjectURL(blob);
|
|
1991
|
+
const link = document.createElement("a");
|
|
1992
|
+
link.href = url;
|
|
1993
|
+
link.download = `sessions-export-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.${extension}`;
|
|
1994
|
+
link.click();
|
|
1995
|
+
window.setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
2449
1996
|
};
|
|
2450
|
-
const
|
|
2451
|
-
const SHRINKING_ROLES_CELL = { maxWidth: 0, width: "22%" };
|
|
2452
|
-
const useT$4 = () => {
|
|
1997
|
+
const HomePage = () => {
|
|
2453
1998
|
const { formatMessage } = reactIntl.useIntl();
|
|
2454
|
-
|
|
2455
|
-
};
|
|
2456
|
-
const
|
|
2457
|
-
const
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
]
|
|
2475
|
-
|
|
2476
|
-
const
|
|
2477
|
-
const
|
|
2478
|
-
const
|
|
2479
|
-
const
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
const
|
|
2483
|
-
const
|
|
2484
|
-
const
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
onView,
|
|
2495
|
-
onSignOutEverywhere,
|
|
2496
|
-
canPreview,
|
|
2497
|
-
onPreview,
|
|
2498
|
-
busy
|
|
2499
|
-
}) => {
|
|
2500
|
-
const t = useT$4();
|
|
2501
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral0", hasRadius: true, shadow: "tableShadow", "data-admin-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2502
|
-
designSystem.Table,
|
|
2503
|
-
{
|
|
2504
|
-
colCount: 5,
|
|
2505
|
-
rowCount: admins.length + 1,
|
|
2506
|
-
"aria-labelledby": labelledBy,
|
|
2507
|
-
"aria-busy": busy,
|
|
2508
|
-
children: [
|
|
2509
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
2510
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: SHRINKING_ADMIN_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.admin", "Admin") }) }),
|
|
2511
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.roles", "Roles") }) }),
|
|
2512
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.status", "Status") }) }),
|
|
2513
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.lastActive", "Last active") }) }),
|
|
2514
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("adminPanel.table.actions", "Actions") }) })
|
|
2515
|
-
] }) }),
|
|
2516
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: admins.map((admin) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-admin-row": admin.id, children: [
|
|
2517
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_ADMIN_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(AdminIdentity, { admin }) }),
|
|
2518
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin }) }),
|
|
2519
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin }) }),
|
|
2520
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: admin.lastActiveAt }) }),
|
|
2521
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(settingsTabs.RowActions, { onKeyDown: keepActionKeys, children: [
|
|
2522
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2523
|
-
designSystem.IconButton,
|
|
2524
|
-
{
|
|
2525
|
-
label: t("adminPanel.actions.view", "View sessions of {name}", {
|
|
2526
|
-
name: admin.name
|
|
2527
|
-
}),
|
|
2528
|
-
onClick: (event) => onView(admin, event.currentTarget),
|
|
2529
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
|
|
2530
|
-
}
|
|
2531
|
-
),
|
|
2532
|
-
offersPreview(admin, canPreview) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2533
|
-
designSystem.IconButton,
|
|
2534
|
-
{
|
|
2535
|
-
label: t("adminPanel.actions.viewAs", "View as {name}", {
|
|
2536
|
-
name: admin.name || `#${admin.id}`
|
|
2537
|
-
}),
|
|
2538
|
-
onClick: (event) => onPreview?.(admin, event.currentTarget),
|
|
2539
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {})
|
|
2540
|
-
}
|
|
2541
|
-
) : null,
|
|
2542
|
-
canRevoke && admin.canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2543
|
-
designSystem.IconButton,
|
|
2544
|
-
{
|
|
2545
|
-
variant: "danger-light",
|
|
2546
|
-
label: t(
|
|
2547
|
-
"adminPanel.actions.signOutEverywhere",
|
|
2548
|
-
"Sign out {name} everywhere",
|
|
2549
|
-
{
|
|
2550
|
-
name: admin.name
|
|
2551
|
-
}
|
|
2552
|
-
),
|
|
2553
|
-
onClick: (event) => onSignOutEverywhere(admin, event.currentTarget),
|
|
2554
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {})
|
|
2555
|
-
}
|
|
2556
|
-
) : null
|
|
2557
|
-
] }) })
|
|
2558
|
-
] }, admin.id)) })
|
|
2559
|
-
]
|
|
2560
|
-
}
|
|
2561
|
-
) });
|
|
2562
|
-
};
|
|
2563
|
-
const AdminCardList = ({
|
|
2564
|
-
admins,
|
|
2565
|
-
labelledBy,
|
|
2566
|
-
canRevoke,
|
|
2567
|
-
onView,
|
|
2568
|
-
onSignOutEverywhere,
|
|
2569
|
-
canPreview,
|
|
2570
|
-
onPreview
|
|
2571
|
-
}) => {
|
|
2572
|
-
const t = useT$4();
|
|
2573
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2574
|
-
designSystem.Flex,
|
|
2575
|
-
{
|
|
2576
|
-
tag: "ul",
|
|
2577
|
-
direction: "column",
|
|
2578
|
-
alignItems: "stretch",
|
|
2579
|
-
gap: 3,
|
|
2580
|
-
"aria-labelledby": labelledBy,
|
|
2581
|
-
"data-admin-cards": "",
|
|
2582
|
-
children: admins.map((admin) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2583
|
-
designSystem.Box,
|
|
2584
|
-
{
|
|
2585
|
-
tag: "li",
|
|
2586
|
-
background: "neutral0",
|
|
2587
|
-
hasRadius: true,
|
|
2588
|
-
shadow: "tableShadow",
|
|
2589
|
-
padding: 4,
|
|
2590
|
-
"data-admin-row": admin.id,
|
|
2591
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, minWidth: 0, children: [
|
|
2592
|
-
/* @__PURE__ */ jsxRuntime.jsx(AdminIdentity, { admin }),
|
|
2593
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, wrap: "wrap", alignItems: "flex-start", justifyContent: "space-between", children: [
|
|
2594
|
-
/* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin }),
|
|
2595
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
|
|
2596
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.lastActive", "Last active") }),
|
|
2597
|
-
/* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: admin.lastActiveAt })
|
|
2598
|
-
] })
|
|
2599
|
-
] }),
|
|
2600
|
-
/* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin }),
|
|
2601
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
|
|
2602
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2603
|
-
designSystem.Button,
|
|
2604
|
-
{
|
|
2605
|
-
variant: "secondary",
|
|
2606
|
-
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {}),
|
|
2607
|
-
onClick: (event) => onView(admin, event.currentTarget),
|
|
2608
|
-
"aria-label": t("adminPanel.actions.view", "View sessions of {name}", {
|
|
2609
|
-
name: admin.name
|
|
2610
|
-
}),
|
|
2611
|
-
flex: "1 1 auto",
|
|
2612
|
-
children: t("adminPanel.actions.viewShort", "View sessions")
|
|
2613
|
-
}
|
|
2614
|
-
),
|
|
2615
|
-
offersPreview(admin, canPreview) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2616
|
-
designSystem.Button,
|
|
2617
|
-
{
|
|
2618
|
-
variant: "secondary",
|
|
2619
|
-
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
|
|
2620
|
-
onClick: (event) => onPreview?.(admin, event.currentTarget),
|
|
2621
|
-
"aria-label": t("adminPanel.actions.viewAs", "View as {name}", {
|
|
2622
|
-
name: admin.name || `#${admin.id}`
|
|
2623
|
-
}),
|
|
2624
|
-
flex: "1 1 auto",
|
|
2625
|
-
children: t("adminPanel.actions.viewAsShort", "View as")
|
|
2626
|
-
}
|
|
2627
|
-
) : null,
|
|
2628
|
-
canRevoke && admin.canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2629
|
-
designSystem.Button,
|
|
2630
|
-
{
|
|
2631
|
-
variant: "danger-light",
|
|
2632
|
-
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {}),
|
|
2633
|
-
onClick: (event) => onSignOutEverywhere(admin, event.currentTarget),
|
|
2634
|
-
"aria-label": t(
|
|
2635
|
-
"adminPanel.actions.signOutEverywhere",
|
|
2636
|
-
"Sign out {name} everywhere",
|
|
2637
|
-
{
|
|
2638
|
-
name: admin.name
|
|
2639
|
-
}
|
|
2640
|
-
),
|
|
2641
|
-
flex: "1 1 auto",
|
|
2642
|
-
children: t("adminPanel.actions.signOutEverywhereShort", "Sign out everywhere")
|
|
2643
|
-
}
|
|
2644
|
-
) : null
|
|
2645
|
-
] })
|
|
2646
|
-
] })
|
|
2647
|
-
},
|
|
2648
|
-
admin.id
|
|
2649
|
-
))
|
|
2650
|
-
}
|
|
1999
|
+
const { get, post, del } = StrapiAdmin.useFetchClient();
|
|
2000
|
+
const { toggleNotification } = StrapiAdmin.useNotification();
|
|
2001
|
+
const formatters = index.useSessionFormatters();
|
|
2002
|
+
const { isBelowSmall, isBelowMedium, isBelowLarge } = useBreakpoint();
|
|
2003
|
+
const [listWidthRef, listWidth] = index.useElementWidth();
|
|
2004
|
+
const [{ query }, setQuery] = StrapiAdmin.useQueryParams();
|
|
2005
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
2006
|
+
const dashboard = dashboardModel.parseDashboardQuery(query);
|
|
2007
|
+
const [sessions, setSessions] = react.useState([]);
|
|
2008
|
+
const [pagination, setPagination] = react.useState({ total: 0, pageCount: 1 });
|
|
2009
|
+
const [stats, setStats] = react.useState(EMPTY_SESSION_STATS);
|
|
2010
|
+
const [exporting, setExporting] = react.useState(false);
|
|
2011
|
+
const [loading, setLoading] = react.useState(true);
|
|
2012
|
+
const [refreshing, setRefreshing] = react.useState(false);
|
|
2013
|
+
const [loadError, setLoadError] = react.useState(false);
|
|
2014
|
+
const [hasData, setHasData] = react.useState(false);
|
|
2015
|
+
const [lastUpdated, setLastUpdated] = react.useState(null);
|
|
2016
|
+
const [now, setNow] = react.useState(() => Date.now());
|
|
2017
|
+
const [selectedSession, setSelectedSession] = react.useState(null);
|
|
2018
|
+
const [showDetailModal, setShowDetailModal] = react.useState(false);
|
|
2019
|
+
const [terminatingSessionId, setTerminatingSessionId] = react.useState(null);
|
|
2020
|
+
const [deletingSessionId, setDeletingSessionId] = react.useState(null);
|
|
2021
|
+
const openerRef = react.useRef(null);
|
|
2022
|
+
const dashboardRef = react.useRef(null);
|
|
2023
|
+
const listHeadingRef = react.useRef(null);
|
|
2024
|
+
const hasLoadedRef = react.useRef(false);
|
|
2025
|
+
const requestIdRef = react.useRef(0);
|
|
2026
|
+
const visibleIdsRef = react.useRef([]);
|
|
2027
|
+
const mutationSnapshotRef = react.useRef([]);
|
|
2028
|
+
const listHeadingId = `session-list-caption-${react.useId().replace(/:/g, "")}`;
|
|
2029
|
+
const mutationPending = Boolean(terminatingSessionId || deletingSessionId);
|
|
2030
|
+
const listQuery = react.useMemo(
|
|
2031
|
+
() => ({
|
|
2032
|
+
page: dashboard.page,
|
|
2033
|
+
pageSize: dashboard.pageSize,
|
|
2034
|
+
status: dashboard.status,
|
|
2035
|
+
reason: dashboard.reason,
|
|
2036
|
+
search: dashboard.search
|
|
2037
|
+
}),
|
|
2038
|
+
[dashboard.page, dashboard.pageSize, dashboard.status, dashboard.reason, dashboard.search]
|
|
2651
2039
|
);
|
|
2652
|
-
|
|
2653
|
-
const
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
]);
|
|
2666
|
-
const
|
|
2667
|
-
const
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2040
|
+
react.useEffect(() => {
|
|
2041
|
+
const timer = setInterval(() => setNow(Date.now()), CLOCK_TICK_MS);
|
|
2042
|
+
return () => clearInterval(timer);
|
|
2043
|
+
}, []);
|
|
2044
|
+
const fetchSessions = react.useCallback(async () => {
|
|
2045
|
+
const requestId = requestIdRef.current + 1;
|
|
2046
|
+
requestIdRef.current = requestId;
|
|
2047
|
+
if (hasLoadedRef.current) setRefreshing(true);
|
|
2048
|
+
else setLoading(true);
|
|
2049
|
+
try {
|
|
2050
|
+
const [listResponse, statsResponse] = await Promise.all([
|
|
2051
|
+
get(`/${index.pluginId}/sessions`, { params: buildListParams(listQuery) }),
|
|
2052
|
+
get(`/${index.pluginId}/sessions/stats`)
|
|
2053
|
+
]);
|
|
2054
|
+
const page = readSessionPage(listResponse.data);
|
|
2055
|
+
const nextStats = readSessionStats(statsResponse.data);
|
|
2056
|
+
if (requestId !== requestIdRef.current) return;
|
|
2057
|
+
setSessions(page.rows);
|
|
2058
|
+
setPagination(page.pagination);
|
|
2059
|
+
setStats(nextStats);
|
|
2060
|
+
setLoadError(false);
|
|
2061
|
+
setHasData(true);
|
|
2062
|
+
setLastUpdated(Date.now());
|
|
2063
|
+
setNow(Date.now());
|
|
2064
|
+
hasLoadedRef.current = true;
|
|
2065
|
+
} catch (err) {
|
|
2066
|
+
if (requestId !== requestIdRef.current || index.isCancelledRequest(err)) return;
|
|
2067
|
+
setLoadError(true);
|
|
2068
|
+
index.logSafeAdminError("dashboard.loadSessions", err);
|
|
2069
|
+
} finally {
|
|
2070
|
+
if (requestId === requestIdRef.current) {
|
|
2071
|
+
setLoading(false);
|
|
2072
|
+
setRefreshing(false);
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
}, [get, listQuery]);
|
|
2076
|
+
react.useEffect(() => {
|
|
2077
|
+
fetchSessions();
|
|
2078
|
+
}, [fetchSessions]);
|
|
2079
|
+
react.useEffect(() => {
|
|
2080
|
+
if (showDetailModal || mutationPending) return void 0;
|
|
2081
|
+
const interval = setInterval(() => {
|
|
2082
|
+
fetchSessions();
|
|
2083
|
+
}, dashboardModel.AUTO_REFRESH_INTERVAL_MS);
|
|
2084
|
+
return () => clearInterval(interval);
|
|
2085
|
+
}, [showDetailModal, mutationPending, fetchSessions]);
|
|
2086
|
+
const handleTerminateSession = async (session) => {
|
|
2087
|
+
if (terminatingSessionId || deletingSessionId) return;
|
|
2088
|
+
const sessionId = session.id;
|
|
2089
|
+
mutationSnapshotRef.current = visibleIdsRef.current;
|
|
2090
|
+
setTerminatingSessionId(sessionId);
|
|
2091
|
+
try {
|
|
2092
|
+
await post(`/${index.pluginId}/sessions/${sessionId}/terminate`);
|
|
2093
|
+
await fetchSessions();
|
|
2094
|
+
toggleNotification({
|
|
2095
|
+
type: "success",
|
|
2096
|
+
message: t("notifications.success.sessionEnded", "Session ended.")
|
|
2097
|
+
});
|
|
2098
|
+
} catch (err) {
|
|
2099
|
+
index.logSafeAdminError("dashboard.terminateSession", err);
|
|
2100
|
+
if (dashboardModel.getErrorStatus(err) === 404) {
|
|
2101
|
+
await fetchSessions();
|
|
2102
|
+
toggleNotification({
|
|
2103
|
+
type: "warning",
|
|
2104
|
+
message: t(
|
|
2105
|
+
"notifications.error.sessionGone",
|
|
2106
|
+
"This session no longer exists. The list was refreshed."
|
|
2107
|
+
)
|
|
2108
|
+
});
|
|
2109
|
+
return;
|
|
2110
|
+
}
|
|
2111
|
+
toggleNotification({
|
|
2112
|
+
type: "danger",
|
|
2113
|
+
message: t(
|
|
2114
|
+
"notifications.error.endSession",
|
|
2115
|
+
"The session could not be ended. Please try again."
|
|
2116
|
+
)
|
|
2117
|
+
});
|
|
2118
|
+
throw err;
|
|
2119
|
+
} finally {
|
|
2120
|
+
setTerminatingSessionId(null);
|
|
2121
|
+
}
|
|
2679
2122
|
};
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2123
|
+
const handleDeleteSession = async (session) => {
|
|
2124
|
+
if (terminatingSessionId || deletingSessionId) return;
|
|
2125
|
+
const sessionId = session.id;
|
|
2126
|
+
mutationSnapshotRef.current = visibleIdsRef.current;
|
|
2127
|
+
setDeletingSessionId(sessionId);
|
|
2128
|
+
try {
|
|
2129
|
+
await del(`/${index.pluginId}/sessions/${sessionId}`);
|
|
2130
|
+
await fetchSessions();
|
|
2131
|
+
toggleNotification({
|
|
2132
|
+
type: "success",
|
|
2133
|
+
message: t(
|
|
2134
|
+
"notifications.success.recordDeleted",
|
|
2135
|
+
"Session record deleted. Its token stays revoked."
|
|
2136
|
+
)
|
|
2137
|
+
});
|
|
2138
|
+
} catch (err) {
|
|
2139
|
+
index.logSafeAdminError("dashboard.deleteSession", err);
|
|
2140
|
+
if (dashboardModel.getErrorStatus(err) === 404) {
|
|
2141
|
+
await fetchSessions();
|
|
2142
|
+
toggleNotification({
|
|
2143
|
+
type: "warning",
|
|
2144
|
+
message: t(
|
|
2145
|
+
"notifications.error.sessionGone",
|
|
2146
|
+
"This session no longer exists. The list was refreshed."
|
|
2147
|
+
)
|
|
2148
|
+
});
|
|
2149
|
+
return;
|
|
2150
|
+
}
|
|
2151
|
+
toggleNotification({
|
|
2152
|
+
type: "danger",
|
|
2153
|
+
message: t(
|
|
2154
|
+
"notifications.error.deleteRecord",
|
|
2155
|
+
"The record could not be deleted. Please try again."
|
|
2156
|
+
)
|
|
2157
|
+
});
|
|
2158
|
+
throw err;
|
|
2159
|
+
} finally {
|
|
2160
|
+
setDeletingSessionId(null);
|
|
2161
|
+
}
|
|
2690
2162
|
};
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
const
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
const
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
};
|
|
2740
|
-
case "admin.lockout":
|
|
2741
|
-
return {
|
|
2742
|
-
key: "lockout",
|
|
2743
|
-
tone: "danger",
|
|
2744
|
-
icon: "lockout",
|
|
2745
|
-
label: message("adminPanel.activity.event.lockout", "Locked out"),
|
|
2746
|
-
detail: FAILURE_REASONS.rate_limited
|
|
2747
|
-
};
|
|
2748
|
-
case "admin.sign-out":
|
|
2749
|
-
return {
|
|
2750
|
-
key: "sign-out",
|
|
2751
|
-
tone: "neutral",
|
|
2752
|
-
icon: "signOut",
|
|
2753
|
-
label: message("adminPanel.activity.event.signOut", "Signed out"),
|
|
2754
|
-
detail: null
|
|
2755
|
-
};
|
|
2756
|
-
case "admin.session.revoked":
|
|
2757
|
-
return {
|
|
2758
|
-
key: "revoked",
|
|
2759
|
-
tone: "warning",
|
|
2760
|
-
icon: "revoked",
|
|
2761
|
-
label: message("adminPanel.activity.event.revoked", "Signed out by an admin"),
|
|
2762
|
-
detail: row.scope === "one_browser" ? message("adminPanel.activity.scope.oneBrowser", "One browser") : message("adminPanel.activity.scope.everywhere", "Every browser")
|
|
2763
|
-
};
|
|
2764
|
-
case "settings.updated":
|
|
2765
|
-
return {
|
|
2766
|
-
key: "settings",
|
|
2767
|
-
tone: "secondary",
|
|
2768
|
-
icon: "settings",
|
|
2769
|
-
label: message("adminPanel.activity.event.settings", "Settings changed"),
|
|
2770
|
-
detail: row.change?.viaToken ? message("adminPanel.activity.via.token", "With an admin API token") : null
|
|
2771
|
-
};
|
|
2772
|
-
case "security-log.read":
|
|
2773
|
-
return {
|
|
2774
|
-
key: "log-read",
|
|
2775
|
-
tone: "secondary",
|
|
2776
|
-
icon: "logRead",
|
|
2777
|
-
label: message("adminPanel.activity.event.logRead", "Log read with an API token"),
|
|
2778
|
-
detail: row.read?.list === "content" ? row.read?.exported ? message(
|
|
2779
|
-
"adminPanel.activity.read.contentExport",
|
|
2780
|
-
"Content Manager activity exported"
|
|
2781
|
-
) : 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")
|
|
2782
|
-
};
|
|
2783
|
-
case "security-log.retention.purged":
|
|
2784
|
-
return {
|
|
2785
|
-
key: "purged",
|
|
2786
|
-
tone: "neutral",
|
|
2787
|
-
icon: "purged",
|
|
2788
|
-
label: message("adminPanel.activity.event.purged", "Old events deleted"),
|
|
2789
|
-
detail: null
|
|
2790
|
-
};
|
|
2791
|
-
// App-user events (4.17 / 4.18). The admin lists of this view do not return them
|
|
2792
|
-
// today; they get their own label and colour so any list that does shows them clearly.
|
|
2793
|
-
case "user.sign-in.failed":
|
|
2794
|
-
return appUserEvent(
|
|
2795
|
-
"user-failed",
|
|
2796
|
-
"danger",
|
|
2797
|
-
"failed",
|
|
2798
|
-
"adminPanel.activity.event.userFailed",
|
|
2799
|
-
"App user sign-in failed"
|
|
2800
|
-
);
|
|
2801
|
-
case "user.sign-in.refused":
|
|
2802
|
-
return appUserEvent(
|
|
2803
|
-
"user-refused",
|
|
2804
|
-
"danger",
|
|
2805
|
-
"refused",
|
|
2806
|
-
"adminPanel.activity.event.userRefused",
|
|
2807
|
-
"App user sign-in refused"
|
|
2808
|
-
);
|
|
2809
|
-
case "user.lockout":
|
|
2810
|
-
return appUserEvent(
|
|
2811
|
-
"user-lockout",
|
|
2812
|
-
"danger",
|
|
2813
|
-
"lockout",
|
|
2814
|
-
"adminPanel.activity.event.userLockout",
|
|
2815
|
-
"App user locked out"
|
|
2816
|
-
);
|
|
2817
|
-
case "user.lockout.lifted":
|
|
2818
|
-
return appUserEvent(
|
|
2819
|
-
"user-unlock",
|
|
2820
|
-
"secondary",
|
|
2821
|
-
"unlock",
|
|
2822
|
-
"adminPanel.activity.event.userUnlock",
|
|
2823
|
-
"Lockout lifted"
|
|
2824
|
-
);
|
|
2825
|
-
case "user.session.limit":
|
|
2826
|
-
return appUserEvent(
|
|
2827
|
-
"user-limit",
|
|
2828
|
-
"warning",
|
|
2829
|
-
"limit",
|
|
2830
|
-
"adminPanel.activity.event.userLimit",
|
|
2831
|
-
"Session limit reached"
|
|
2832
|
-
);
|
|
2833
|
-
case "user.password-change.ended-others":
|
|
2834
|
-
return appUserEvent(
|
|
2835
|
-
"user-password",
|
|
2836
|
-
"warning",
|
|
2837
|
-
"password",
|
|
2838
|
-
"adminPanel.activity.event.userPassword",
|
|
2839
|
-
"Signed out after a password change"
|
|
2840
|
-
);
|
|
2841
|
-
case "user.sign-in.new-device":
|
|
2842
|
-
return appUserEvent(
|
|
2843
|
-
"user-device",
|
|
2844
|
-
"secondary",
|
|
2845
|
-
"device",
|
|
2846
|
-
"adminPanel.activity.event.userNewDevice",
|
|
2847
|
-
"Sign-in from a new device"
|
|
2848
|
-
);
|
|
2849
|
-
case "user.sign-in.impossible-travel":
|
|
2850
|
-
return appUserEvent(
|
|
2851
|
-
"user-travel",
|
|
2852
|
-
"danger",
|
|
2853
|
-
"travel",
|
|
2854
|
-
"adminPanel.activity.event.userTravel",
|
|
2855
|
-
"Impossible travel"
|
|
2856
|
-
);
|
|
2857
|
-
case "user.not-me":
|
|
2858
|
-
return appUserEvent(
|
|
2859
|
-
"user-not-me",
|
|
2860
|
-
"danger",
|
|
2861
|
-
"notMe",
|
|
2862
|
-
"adminPanel.activity.event.userNotMe",
|
|
2863
|
-
'Reported as "This wasn’t me"'
|
|
2864
|
-
);
|
|
2865
|
-
case "user.data.exported":
|
|
2866
|
-
return appUserEvent(
|
|
2867
|
-
"user-export",
|
|
2868
|
-
"secondary",
|
|
2869
|
-
"export",
|
|
2870
|
-
"adminPanel.activity.event.userExport",
|
|
2871
|
-
"Personal data exported"
|
|
2872
|
-
);
|
|
2873
|
-
default:
|
|
2874
|
-
if (typeof row?.event === "string" && row.event.startsWith("impersonation.")) {
|
|
2875
|
-
return appUserEvent(
|
|
2876
|
-
"impersonation",
|
|
2877
|
-
"warning",
|
|
2878
|
-
"impersonation",
|
|
2879
|
-
"adminPanel.activity.event.impersonation",
|
|
2880
|
-
"Impersonation"
|
|
2881
|
-
);
|
|
2163
|
+
const pageSize = Number(dashboard.pageSize);
|
|
2164
|
+
const pageResult = {
|
|
2165
|
+
items: sessions,
|
|
2166
|
+
total: pagination.total,
|
|
2167
|
+
pageCount: pagination.pageCount,
|
|
2168
|
+
startIndex: pagination.total > 0 ? (dashboard.page - 1) * pageSize + 1 : 0,
|
|
2169
|
+
endIndex: pagination.total > 0 ? (dashboard.page - 1) * pageSize + sessions.length : 0
|
|
2170
|
+
};
|
|
2171
|
+
const visibleIds = pageResult.items.map((session) => String(session.id));
|
|
2172
|
+
react.useLayoutEffect(() => {
|
|
2173
|
+
visibleIdsRef.current = visibleIds;
|
|
2174
|
+
});
|
|
2175
|
+
const fetchExportRows = async () => {
|
|
2176
|
+
const rows = [];
|
|
2177
|
+
let cursor = null;
|
|
2178
|
+
do {
|
|
2179
|
+
const { data } = await get(`/${index.pluginId}/sessions/export`, {
|
|
2180
|
+
params: buildExportParams(listQuery, cursor)
|
|
2181
|
+
});
|
|
2182
|
+
rows.push(...index.requireSessionList(data));
|
|
2183
|
+
cursor = typeof data?.meta?.nextCursor === "string" ? data.meta.nextCursor : null;
|
|
2184
|
+
} while (cursor && rows.length < MAX_EXPORT_ROWS);
|
|
2185
|
+
const capped = rows.length > MAX_EXPORT_ROWS || Boolean(cursor) && rows.length >= MAX_EXPORT_ROWS;
|
|
2186
|
+
return { rows: rows.slice(0, MAX_EXPORT_ROWS), capped };
|
|
2187
|
+
};
|
|
2188
|
+
const handleExport = async (format) => {
|
|
2189
|
+
if (exporting) return;
|
|
2190
|
+
setExporting(true);
|
|
2191
|
+
try {
|
|
2192
|
+
const { rows, capped } = await fetchExportRows();
|
|
2193
|
+
if (format === "csv") {
|
|
2194
|
+
const csvContent = index.buildSessionCsv(rows, {
|
|
2195
|
+
unavailableValue: "",
|
|
2196
|
+
getDeviceInfo: dashboardModel.getExportDeviceInfo,
|
|
2197
|
+
getSessionStatus: index.getSessionStatus
|
|
2198
|
+
});
|
|
2199
|
+
downloadFile(csvContent, "text/csv;charset=utf-8;", "csv");
|
|
2200
|
+
} else {
|
|
2201
|
+
const jsonContent = index.buildSessionJson(rows, {
|
|
2202
|
+
filterStatus: dashboard.status,
|
|
2203
|
+
totalSessions: stats.total,
|
|
2204
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2205
|
+
unavailableValue: "",
|
|
2206
|
+
getDeviceInfo: dashboardModel.getExportDeviceInfo,
|
|
2207
|
+
getSessionStatus: index.getSessionStatus,
|
|
2208
|
+
truncated: capped
|
|
2209
|
+
});
|
|
2210
|
+
downloadFile(jsonContent, "application/json", "json");
|
|
2882
2211
|
}
|
|
2883
|
-
if (
|
|
2884
|
-
|
|
2885
|
-
"
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2212
|
+
if (capped) {
|
|
2213
|
+
toggleNotification({
|
|
2214
|
+
type: "warning",
|
|
2215
|
+
message: t(
|
|
2216
|
+
"homepage.export.capped",
|
|
2217
|
+
"The export contains the newest {limit, number} sessions. Narrow the filter to export the rest.",
|
|
2218
|
+
{ limit: MAX_EXPORT_ROWS }
|
|
2219
|
+
)
|
|
2220
|
+
});
|
|
2891
2221
|
}
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
};
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
function getSessionStatePresentation(session) {
|
|
2902
|
-
switch (session?.state) {
|
|
2903
|
-
case "active":
|
|
2904
|
-
return {
|
|
2905
|
-
tone: "success",
|
|
2906
|
-
label: message("adminPanel.activity.session.active", "Still signed in")
|
|
2907
|
-
};
|
|
2908
|
-
case "signed-out":
|
|
2909
|
-
return {
|
|
2910
|
-
tone: "neutral",
|
|
2911
|
-
label: message("adminPanel.activity.session.signedOut", "Signed out")
|
|
2912
|
-
};
|
|
2913
|
-
case "ended":
|
|
2914
|
-
return {
|
|
2915
|
-
tone: "neutral",
|
|
2916
|
-
label: message("adminPanel.activity.session.ended", "Session ended")
|
|
2917
|
-
};
|
|
2918
|
-
default:
|
|
2919
|
-
return null;
|
|
2920
|
-
}
|
|
2921
|
-
}
|
|
2922
|
-
const RECENT_EVENT_LIMIT = 8;
|
|
2923
|
-
const ACTIVITY_PAGE_SIZE_OPTIONS = Object.freeze(["10", "20", "50", "100"]);
|
|
2924
|
-
const EVENT_TABLE_MIN_WIDTH = Object.freeze({ withAdmin: 800, withoutAdmin: 740 });
|
|
2925
|
-
const EVENT_TABLE_FULL_WIDTH = 1e3;
|
|
2926
|
-
function getEventListLayout(width, { showAdmin = false } = {}) {
|
|
2927
|
-
if (!width) return "full";
|
|
2928
|
-
const min = showAdmin ? EVENT_TABLE_MIN_WIDTH.withAdmin : EVENT_TABLE_MIN_WIDTH.withoutAdmin;
|
|
2929
|
-
if (width < min) return "stacked";
|
|
2930
|
-
return width >= EVENT_TABLE_FULL_WIDTH ? "full" : "table";
|
|
2931
|
-
}
|
|
2932
|
-
function getEventPlace(row) {
|
|
2933
|
-
return [row?.location?.city, row?.location?.country].filter(Boolean).join(", ");
|
|
2934
|
-
}
|
|
2935
|
-
function parseActivityPageQuery(query) {
|
|
2936
|
-
const source = query || {};
|
|
2937
|
-
const event = ALL_ADMINS_FILTER_OPTIONS.includes(String(source.event)) ? String(source.event) : "all";
|
|
2938
|
-
const period = PERIOD_OPTIONS.includes(String(source.period)) ? String(source.period) : "30";
|
|
2939
|
-
const adminId = /^[1-9][0-9]{0,11}$/.test(String(source.adminId ?? "")) ? Number(source.adminId) : null;
|
|
2940
|
-
const page = Number.parseInt(String(source.page ?? ""), 10);
|
|
2941
|
-
const pageSize = String(source.pageSize ?? "");
|
|
2942
|
-
return {
|
|
2943
|
-
event,
|
|
2944
|
-
period,
|
|
2945
|
-
adminId,
|
|
2946
|
-
page: Number.isInteger(page) && page > 0 ? page : 1,
|
|
2947
|
-
pageSize: ACTIVITY_PAGE_SIZE_OPTIONS.includes(pageSize) ? Number(pageSize) : EVENT_PAGE_SIZE
|
|
2948
|
-
};
|
|
2949
|
-
}
|
|
2950
|
-
function hasActivityPageFilters(view) {
|
|
2951
|
-
return view.event !== "all" || view.period !== "30" || view.adminId !== null;
|
|
2952
|
-
}
|
|
2953
|
-
function groupChangedSettings(keys) {
|
|
2954
|
-
const list = Array.isArray(keys) ? keys.filter((key) => typeof key === "string" && key) : [];
|
|
2955
|
-
const byTab = /* @__PURE__ */ new Map();
|
|
2956
|
-
const unknown = [];
|
|
2957
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2958
|
-
for (const key of list) {
|
|
2959
|
-
const tab = settingsTabs.SETTINGS_TAB_IDS.find((id) => settingsTabs.SETTINGS_TAB_FIELDS[id]?.includes(key));
|
|
2960
|
-
const entry = settingsTabs.SETTINGS_FIELD_LABELS[key];
|
|
2961
|
-
if (!tab || !entry) {
|
|
2962
|
-
if (!seen.has(`raw:${key}`)) unknown.push({ key, label: null });
|
|
2963
|
-
seen.add(`raw:${key}`);
|
|
2964
|
-
continue;
|
|
2222
|
+
} catch (err) {
|
|
2223
|
+
if (index.isCancelledRequest(err)) return;
|
|
2224
|
+
index.logSafeAdminError(format === "csv" ? "dashboard.exportCsv" : "dashboard.exportJson", err);
|
|
2225
|
+
toggleNotification({
|
|
2226
|
+
type: "danger",
|
|
2227
|
+
message: t("notifications.error.exportFailed", "The export could not be created.")
|
|
2228
|
+
});
|
|
2229
|
+
} finally {
|
|
2230
|
+
setExporting(false);
|
|
2965
2231
|
}
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
}
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
}
|
|
2979
|
-
const
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
}
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
if (!type?.exists || row.action === "delete") return null;
|
|
2998
|
-
const uid = encodeURIComponent(type.uid);
|
|
2999
|
-
const locale = row.entry?.locale ? `?plugins[i18n][locale]=${encodeURIComponent(row.entry.locale)}` : "";
|
|
3000
|
-
if (type.kind === "single") return `/content-manager/single-types/${uid}${locale}`;
|
|
3001
|
-
if (!row.entry?.documentId) return null;
|
|
3002
|
-
return `/content-manager/collection-types/${uid}/${encodeURIComponent(row.entry.documentId)}${locale}`;
|
|
3003
|
-
}
|
|
3004
|
-
const SIGN_IN_CSV_HEADERS = Object.freeze([
|
|
3005
|
-
"Time",
|
|
3006
|
-
"Event",
|
|
3007
|
-
"Reason",
|
|
3008
|
-
"Admin",
|
|
3009
|
-
"Admin ID",
|
|
3010
|
-
"IP Address",
|
|
3011
|
-
"IP Anonymized",
|
|
3012
|
-
"Country",
|
|
3013
|
-
"City",
|
|
3014
|
-
"Browser",
|
|
3015
|
-
"OS",
|
|
3016
|
-
"Device",
|
|
3017
|
-
"Session",
|
|
3018
|
-
"Signed Out By"
|
|
3019
|
-
]);
|
|
3020
|
-
const ACTIVITY_CSV_HEADERS = Object.freeze([
|
|
3021
|
-
"Time",
|
|
3022
|
-
"Action",
|
|
3023
|
-
"Admin",
|
|
3024
|
-
"Admin ID",
|
|
3025
|
-
"Content Type",
|
|
3026
|
-
"Content Type UID",
|
|
3027
|
-
"Document ID",
|
|
3028
|
-
"Locale",
|
|
3029
|
-
"Title",
|
|
3030
|
-
"Entries"
|
|
3031
|
-
]);
|
|
3032
|
-
const toCsv = (headers, rows) => [headers, ...rows].map((cells) => cells.map(escapeCsvValue).join(",")).join("\n");
|
|
3033
|
-
function buildSignInCsv(rows) {
|
|
3034
|
-
return toCsv(
|
|
3035
|
-
SIGN_IN_CSV_HEADERS,
|
|
3036
|
-
rows.map((row) => [
|
|
3037
|
-
row.at || "",
|
|
3038
|
-
row.event || "",
|
|
3039
|
-
row.reason || row.scope || "",
|
|
3040
|
-
row.admin?.name || "",
|
|
3041
|
-
row.admin?.id ?? "",
|
|
3042
|
-
row.ipAddress || "",
|
|
3043
|
-
row.ipAnonymized ? "yes" : "no",
|
|
3044
|
-
row.location?.country || "",
|
|
3045
|
-
row.location?.city || "",
|
|
3046
|
-
row.browser || "",
|
|
3047
|
-
row.os || "",
|
|
3048
|
-
row.deviceType || "",
|
|
3049
|
-
row.session?.state || "",
|
|
3050
|
-
row.actor?.name || ""
|
|
3051
|
-
])
|
|
2232
|
+
};
|
|
2233
|
+
const handleSessionClick = (session, opener) => {
|
|
2234
|
+
openerRef.current = opener;
|
|
2235
|
+
setSelectedSession(session);
|
|
2236
|
+
setShowDetailModal(true);
|
|
2237
|
+
};
|
|
2238
|
+
const handleModalClose = () => {
|
|
2239
|
+
setShowDetailModal(false);
|
|
2240
|
+
setSelectedSession(null);
|
|
2241
|
+
};
|
|
2242
|
+
const handleCloseAutoFocus = (event) => {
|
|
2243
|
+
index.restoreDialogFocus(event, openerRef.current, listHeadingRef.current || dashboardRef.current);
|
|
2244
|
+
};
|
|
2245
|
+
const getFocusFallback = react.useCallback(
|
|
2246
|
+
(sessionId) => ({
|
|
2247
|
+
get current() {
|
|
2248
|
+
const targetId = dashboardModel.pickFocusSessionId(
|
|
2249
|
+
mutationSnapshotRef.current,
|
|
2250
|
+
visibleIdsRef.current,
|
|
2251
|
+
sessionId
|
|
2252
|
+
);
|
|
2253
|
+
const root = dashboardRef.current;
|
|
2254
|
+
if (targetId && root) {
|
|
2255
|
+
const escaped = typeof CSS !== "undefined" && CSS.escape ? CSS.escape(targetId) : targetId;
|
|
2256
|
+
const button = root.querySelector(`[data-session-view="${escaped}"]`);
|
|
2257
|
+
if (button) return button;
|
|
2258
|
+
}
|
|
2259
|
+
return listHeadingRef.current;
|
|
2260
|
+
}
|
|
2261
|
+
}),
|
|
2262
|
+
[]
|
|
3052
2263
|
);
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
2264
|
+
react.useEffect(() => {
|
|
2265
|
+
if (!loading && !refreshing && dashboard.page > pageResult.pageCount) {
|
|
2266
|
+
setQuery({ page: String(pageResult.pageCount) }, "push", true);
|
|
2267
|
+
}
|
|
2268
|
+
}, [loading, refreshing, dashboard.page, pageResult.pageCount, setQuery]);
|
|
2269
|
+
const handleStatusChange = (value) => {
|
|
2270
|
+
const status = String(value);
|
|
2271
|
+
setQuery({ status: status === "all" ? void 0 : status, reason: void 0, page: "1" });
|
|
2272
|
+
};
|
|
2273
|
+
const handleReasonChange = (value) => {
|
|
2274
|
+
const reason = String(value);
|
|
2275
|
+
setQuery({ reason: reason === "all" ? void 0 : reason, page: "1" });
|
|
2276
|
+
};
|
|
2277
|
+
const handleSearch = react.useCallback(
|
|
2278
|
+
(value) => {
|
|
2279
|
+
setQuery({ search: dashboardModel.encodeSearchQuery(value), _q: void 0, page: "1" }, "push", true);
|
|
2280
|
+
},
|
|
2281
|
+
[setQuery]
|
|
3069
2282
|
);
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
const
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
}
|
|
3107
|
-
return row.browser || row.os || "";
|
|
3108
|
-
};
|
|
3109
|
-
const ipText = (t, row) => {
|
|
3110
|
-
if (!row.ipAddress) return "";
|
|
3111
|
-
return row.ipAnonymized ? t("adminPanel.activity.ipAnonymized", "{ip} (anonymised)", { ip: row.ipAddress }) : row.ipAddress;
|
|
3112
|
-
};
|
|
3113
|
-
const eventDetailText = (t, row, presentation, withActor) => {
|
|
3114
|
-
const parts = [];
|
|
3115
|
-
if (presentation.detail) {
|
|
3116
|
-
parts.push(t(presentation.detail.messageId, presentation.detail.defaultMessage));
|
|
3117
|
-
}
|
|
3118
|
-
if (Number.isInteger(row.attempts) && row.attempts > 1) {
|
|
3119
|
-
parts.push(
|
|
3120
|
-
t(
|
|
3121
|
-
"adminPanel.activity.attempts",
|
|
3122
|
-
"{count, plural, one {# attempt} other {# attempts}} within 5 minutes",
|
|
3123
|
-
{ count: row.attempts }
|
|
3124
|
-
)
|
|
3125
|
-
);
|
|
3126
|
-
}
|
|
3127
|
-
const changed = changedSettingsText(t, row.change?.keys, { limit: 3 });
|
|
3128
|
-
if (changed) parts.push(changed);
|
|
3129
|
-
if (Number.isInteger(row.purge?.count)) {
|
|
3130
|
-
parts.push(
|
|
3131
|
-
Number.isInteger(row.purge?.retentionDays) ? t(
|
|
3132
|
-
"adminPanel.activity.purgedDetail",
|
|
3133
|
-
"{count, plural, one {# event} other {# events}}, older than {days, plural, one {# day} other {# days}}",
|
|
3134
|
-
{ count: row.purge.count, days: row.purge.retentionDays }
|
|
3135
|
-
) : t("adminPanel.activity.purgedCount", "{count, plural, one {# event} other {# events}}", {
|
|
3136
|
-
count: row.purge.count
|
|
3137
|
-
})
|
|
3138
|
-
);
|
|
3139
|
-
}
|
|
3140
|
-
if (withActor && row.actor?.name) {
|
|
3141
|
-
parts.push(t("adminPanel.activity.byAdmin", "by {name}", { name: row.actor.name }));
|
|
3142
|
-
}
|
|
3143
|
-
return parts.join(" · ");
|
|
3144
|
-
};
|
|
3145
|
-
const contentTypeText = (row) => [row.contentType?.name, row.entry?.locale].filter(Boolean).join(" · ");
|
|
3146
|
-
const useT$3 = () => {
|
|
3147
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
3148
|
-
return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
3149
|
-
};
|
|
3150
|
-
const SHORT_DATE = Object.freeze({ dateStyle: "medium", timeStyle: "short" });
|
|
3151
|
-
const FULL_DATE = Object.freeze({ dateStyle: "full", timeStyle: "medium" });
|
|
3152
|
-
const EVENT_ICONS = Object.freeze({
|
|
3153
|
-
signIn: icons.CheckCircle,
|
|
3154
|
-
failed: icons.CrossCircle,
|
|
3155
|
-
lockout: icons.Lock,
|
|
3156
|
-
signOut: icons.SignOut,
|
|
3157
|
-
revoked: icons.Shield,
|
|
3158
|
-
settings: icons.Cog,
|
|
3159
|
-
logRead: icons.Key,
|
|
3160
|
-
purged: icons.Trash,
|
|
3161
|
-
refused: icons.CrossCircle,
|
|
3162
|
-
unlock: icons.Lock,
|
|
3163
|
-
limit: icons.Stack,
|
|
3164
|
-
password: icons.Key,
|
|
3165
|
-
device: icons.Monitor,
|
|
3166
|
-
travel: icons.Earth,
|
|
3167
|
-
notMe: icons.WarningCircle,
|
|
3168
|
-
export: icons.Download,
|
|
3169
|
-
impersonation: icons.User,
|
|
3170
|
-
webhook: icons.Webhooks,
|
|
3171
|
-
other: icons.Information
|
|
3172
|
-
});
|
|
3173
|
-
const ICON_FILL = Object.freeze({
|
|
3174
|
-
success: "success600",
|
|
3175
|
-
danger: "danger600",
|
|
3176
|
-
warning: "warning700",
|
|
3177
|
-
secondary: "secondary600",
|
|
3178
|
-
neutral: "neutral600"
|
|
3179
|
-
});
|
|
3180
|
-
const stopCellKeys = (event) => {
|
|
3181
|
-
if (event.key === "Enter" || event.key === " " || event.key === "Spacebar") {
|
|
3182
|
-
event.stopPropagation();
|
|
3183
|
-
}
|
|
3184
|
-
};
|
|
3185
|
-
const ClickableRow = styled__default.default(designSystem.Tr)`
|
|
3186
|
-
cursor: pointer;
|
|
3187
|
-
`;
|
|
3188
|
-
const WrapCell = styled__default.default(designSystem.Td)`
|
|
3189
|
-
white-space: normal;
|
|
3190
|
-
`;
|
|
3191
|
-
const NoWrap = styled__default.default.span`
|
|
3192
|
-
white-space: nowrap;
|
|
3193
|
-
`;
|
|
3194
|
-
const NameButton = styled__default.default(designSystem.TextButton)`
|
|
3195
|
-
min-height: 3.2rem;
|
|
3196
|
-
text-align: start;
|
|
3197
|
-
`;
|
|
3198
|
-
const StackedList = styled__default.default.ul`
|
|
3199
|
-
margin: 0;
|
|
3200
|
-
padding: 0;
|
|
3201
|
-
list-style: none;
|
|
3202
|
-
border: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
3203
|
-
border-radius: ${({ theme }) => theme.borderRadius};
|
|
3204
|
-
background: ${({ theme }) => theme.colors.neutral0};
|
|
3205
|
-
min-width: 0;
|
|
3206
|
-
|
|
3207
|
-
& > li + li {
|
|
3208
|
-
border-top: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
3209
|
-
}
|
|
3210
|
-
`;
|
|
3211
|
-
const StackedItem = styled__default.default.li`
|
|
3212
|
-
cursor: pointer;
|
|
3213
|
-
min-width: 0;
|
|
3214
|
-
`;
|
|
3215
|
-
const BreakAnywhere = styled__default.default(designSystem.Typography)`
|
|
3216
|
-
overflow-wrap: anywhere;
|
|
3217
|
-
`;
|
|
3218
|
-
const getEventBadgeColors = (tone) => tone === "danger" ? { backgroundColor: "danger100", textColor: "danger700" } : index.getBadgeColors(tone);
|
|
3219
|
-
const EventBadge = ({ presentation, nowrap = false }) => {
|
|
3220
|
-
const t = useT$3();
|
|
3221
|
-
const Icon = EVENT_ICONS[presentation.icon] || icons.Information;
|
|
3222
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", shrink: 0, "data-event-kind": presentation.key, children: [
|
|
3223
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3224
|
-
Icon,
|
|
2283
|
+
const handleClearFilters = () => {
|
|
2284
|
+
setQuery({ search: void 0, _q: void 0, status: void 0, reason: void 0, page: "1" });
|
|
2285
|
+
listHeadingRef.current?.focus();
|
|
2286
|
+
};
|
|
2287
|
+
const showSessionData = !loading && hasData;
|
|
2288
|
+
const showToolbar = showSessionData && stats.total > 0;
|
|
2289
|
+
const canExport = showSessionData && pageResult.total > 0 && !exporting;
|
|
2290
|
+
const filtersActive = dashboardModel.hasActiveFilters(dashboard);
|
|
2291
|
+
const exportValues = { count: Math.min(pageResult.total, MAX_EXPORT_ROWS) };
|
|
2292
|
+
const exportMenu = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2293
|
+
designSystem.SimpleMenu,
|
|
2294
|
+
{
|
|
2295
|
+
label: t("homepage.export.label", "Export"),
|
|
2296
|
+
variant: "secondary",
|
|
2297
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
|
|
2298
|
+
disabled: !canExport,
|
|
2299
|
+
children: [
|
|
2300
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => void handleExport("csv"), children: t(
|
|
2301
|
+
"homepage.export.csv",
|
|
2302
|
+
"{count, plural, one {Export # session as CSV} other {Export # sessions as CSV}}",
|
|
2303
|
+
exportValues
|
|
2304
|
+
) }),
|
|
2305
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => void handleExport("json"), children: t(
|
|
2306
|
+
"homepage.export.json",
|
|
2307
|
+
"{count, plural, one {Export # session as JSON} other {Export # sessions as JSON}}",
|
|
2308
|
+
exportValues
|
|
2309
|
+
) })
|
|
2310
|
+
]
|
|
2311
|
+
}
|
|
2312
|
+
);
|
|
2313
|
+
const exportAction = canExport || !showSessionData ? exportMenu : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label: t("homepage.export.disabledHint", "No sessions match the current filter."), children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: exportMenu }) });
|
|
2314
|
+
const analyticsLabel = t("homepage.links.analytics", "Analytics");
|
|
2315
|
+
const settingsLabel = t("homepage.links.settings", "Settings");
|
|
2316
|
+
const primaryAction = /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", children: [
|
|
2317
|
+
isBelowSmall ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { tag: reactRouterDom.Link, to: ANALYTICS_PATH, label: analyticsLabel, variant: "tertiary", children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChartBubble, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2318
|
+
designSystem.LinkButton,
|
|
3225
2319
|
{
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
2320
|
+
tag: reactRouterDom.Link,
|
|
2321
|
+
to: ANALYTICS_PATH,
|
|
2322
|
+
variant: "tertiary",
|
|
2323
|
+
size: "S",
|
|
2324
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ChartBubble, {}),
|
|
2325
|
+
children: analyticsLabel
|
|
3231
2326
|
}
|
|
3232
2327
|
),
|
|
3233
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
3234
|
-
|
|
3235
|
-
};
|
|
3236
|
-
const EventTime = ({ value, compact = false }) => {
|
|
3237
|
-
const { formatDate, formatRelativeTime } = index.useSessionFormatters();
|
|
3238
|
-
const date = index.toValidDate(value);
|
|
3239
|
-
if (!date) return /* @__PURE__ */ jsxRuntime.jsx(index.MissingValue, { variant: "omega" });
|
|
3240
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
|
|
3241
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3242
|
-
designSystem.Typography,
|
|
2328
|
+
isBelowSmall ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { tag: reactRouterDom.Link, to: CONFIGURATION_PATH, label: settingsLabel, variant: "tertiary", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cog, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2329
|
+
designSystem.LinkButton,
|
|
3243
2330
|
{
|
|
3244
|
-
tag:
|
|
3245
|
-
|
|
3246
|
-
variant:
|
|
3247
|
-
|
|
3248
|
-
|
|
2331
|
+
tag: reactRouterDom.Link,
|
|
2332
|
+
to: CONFIGURATION_PATH,
|
|
2333
|
+
variant: "tertiary",
|
|
2334
|
+
size: "S",
|
|
2335
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Cog, {}),
|
|
2336
|
+
children: settingsLabel
|
|
3249
2337
|
}
|
|
3250
2338
|
),
|
|
3251
|
-
|
|
3252
|
-
] });
|
|
3253
|
-
};
|
|
3254
|
-
const AdminName = ({ admin, row, onOpenAdmin }) => {
|
|
3255
|
-
const t = useT$3();
|
|
3256
|
-
if (!admin) {
|
|
3257
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: onOpenAdmin ? "pi" : "omega", textColor: "neutral600", children: noAdminText(t, row) });
|
|
3258
|
-
}
|
|
3259
|
-
if (!onOpenAdmin) {
|
|
3260
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: admin.name });
|
|
3261
|
-
}
|
|
3262
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3263
|
-
NameButton,
|
|
3264
|
-
{
|
|
3265
|
-
onClick: (event) => {
|
|
3266
|
-
event.stopPropagation();
|
|
3267
|
-
onOpenAdmin(admin, event.currentTarget);
|
|
3268
|
-
},
|
|
3269
|
-
onKeyDown: stopCellKeys,
|
|
3270
|
-
"aria-label": t("adminPanel.activity.openAdmin", "Open the details of {name}", {
|
|
3271
|
-
name: admin.name
|
|
3272
|
-
}),
|
|
3273
|
-
children: admin.name
|
|
3274
|
-
}
|
|
3275
|
-
);
|
|
3276
|
-
};
|
|
3277
|
-
const SignInDetails = ({ row }) => {
|
|
3278
|
-
const t = useT$3();
|
|
3279
|
-
const ip = ipText(t, row);
|
|
3280
|
-
const second = [getEventPlace(row), deviceText(t, row)].filter(Boolean).join(" · ");
|
|
3281
|
-
if (!ip && !second) return /* @__PURE__ */ jsxRuntime.jsx(index.MissingValue, { variant: "omega" });
|
|
3282
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
|
|
3283
|
-
ip ? /* @__PURE__ */ jsxRuntime.jsx(BreakAnywhere, { variant: "omega", textColor: "neutral800", children: ip }) : null,
|
|
3284
|
-
second ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: second }) : null
|
|
2339
|
+
exportAction
|
|
3285
2340
|
] });
|
|
3286
|
-
};
|
|
3287
|
-
const
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
const state = getSessionStatePresentation(row.session);
|
|
3291
|
-
if (!state) return /* @__PURE__ */ jsxRuntime.jsx(index.MissingValue, { variant: "omega" });
|
|
3292
|
-
const endedAt = index.toValidDate(row.session?.endedAt);
|
|
3293
|
-
const second = [
|
|
3294
|
-
endedAt ? formatRelativeTime(endedAt) : "",
|
|
3295
|
-
row.session?.endedBy?.name ? t("adminPanel.activity.byAdmin", "by {name}", { name: row.session.endedBy.name }) : ""
|
|
3296
|
-
].filter(Boolean).join(" · ");
|
|
3297
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
|
|
3298
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3299
|
-
designSystem.Typography,
|
|
2341
|
+
const filterSlot = isBelowMedium ? { flex: "1 1 auto", minWidth: 0 } : void 0;
|
|
2342
|
+
const filterControls = /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", wrap: isBelowMedium ? "nowrap" : "wrap", shrink: 0, children: [
|
|
2343
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { ...filterSlot, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2344
|
+
designSystem.SingleSelect,
|
|
3300
2345
|
{
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
children:
|
|
2346
|
+
size: "S",
|
|
2347
|
+
"aria-label": t("homepage.filter.label", "Status"),
|
|
2348
|
+
value: dashboard.status,
|
|
2349
|
+
onChange: handleStatusChange,
|
|
2350
|
+
children: index.SESSION_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelectOption, { value: option, children: [
|
|
2351
|
+
option === "all" && t("homepage.filter.all", "All sessions"),
|
|
2352
|
+
option === "open" && t("homepage.filter.open", "Open"),
|
|
2353
|
+
option !== "all" && option !== "open" && formatters.statusLabel(option)
|
|
2354
|
+
] }, option))
|
|
3306
2355
|
}
|
|
3307
|
-
),
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
};
|
|
3311
|
-
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 }) });
|
|
3312
|
-
const DetailsButton = ({ label, onOpen }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3313
|
-
designSystem.IconButton,
|
|
3314
|
-
{
|
|
3315
|
-
variant: "ghost",
|
|
3316
|
-
label,
|
|
3317
|
-
withTooltip: false,
|
|
3318
|
-
onClick: (event) => {
|
|
3319
|
-
event.stopPropagation();
|
|
3320
|
-
onOpen(event.currentTarget);
|
|
3321
|
-
},
|
|
3322
|
-
onKeyDown: stopCellKeys,
|
|
3323
|
-
"data-event-details": "",
|
|
3324
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
|
|
3325
|
-
}
|
|
3326
|
-
);
|
|
3327
|
-
const ActivityEntry = ({ row }) => {
|
|
3328
|
-
const t = useT$3();
|
|
3329
|
-
const path = getEntryPath(row);
|
|
3330
|
-
const name = row.entry?.count !== null && row.entry?.count !== void 0 ? t("adminPanel.activity.entries", "{count, plural, one {# entry} other {# entries}}", {
|
|
3331
|
-
count: row.entry.count
|
|
3332
|
-
}) : row.entry?.title || row.entry?.documentId || row.contentType?.name || "";
|
|
3333
|
-
if (!name) return /* @__PURE__ */ jsxRuntime.jsx(index.MissingValue, { variant: "omega" });
|
|
3334
|
-
if (!path) {
|
|
3335
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BreakAnywhere, { variant: "omega", textColor: "neutral800", children: name });
|
|
3336
|
-
}
|
|
3337
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3338
|
-
index.TargetLink,
|
|
3339
|
-
{
|
|
3340
|
-
tag: reactRouterDom.Link,
|
|
3341
|
-
to: path,
|
|
3342
|
-
onClick: (event) => event.stopPropagation(),
|
|
3343
|
-
onKeyDown: stopCellKeys,
|
|
3344
|
-
"aria-label": t("adminPanel.activity.openEntry", "Open {entry} in the Content Manager", {
|
|
3345
|
-
entry: name
|
|
3346
|
-
}),
|
|
3347
|
-
children: name
|
|
3348
|
-
}
|
|
3349
|
-
);
|
|
3350
|
-
};
|
|
3351
|
-
const EventDetailsModal = ({ title, items, footerAction, onClose, onCloseAutoFocus }) => {
|
|
3352
|
-
const t = useT$3();
|
|
3353
|
-
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: [
|
|
3354
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
|
|
3355
|
-
/* @__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 }) }) }),
|
|
3356
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
|
3357
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: t("common.close", "Close") }) }),
|
|
3358
|
-
footerAction || null
|
|
3359
|
-
] })
|
|
3360
|
-
] }) });
|
|
3361
|
-
};
|
|
3362
|
-
const useEventDetails = () => {
|
|
3363
|
-
const [selected, setSelected] = react.useState(null);
|
|
3364
|
-
const [opener, setOpener] = react.useState(null);
|
|
3365
|
-
const [container, setContainer] = react.useState(null);
|
|
3366
|
-
return {
|
|
3367
|
-
selected,
|
|
3368
|
-
setContainer,
|
|
3369
|
-
open: (row, trigger) => {
|
|
3370
|
-
const button = trigger?.matches?.("[data-event-details]") ? trigger : trigger?.querySelector?.("[data-event-details]");
|
|
3371
|
-
setOpener(button || null);
|
|
3372
|
-
setSelected(row);
|
|
3373
|
-
},
|
|
3374
|
-
close: () => setSelected(null),
|
|
3375
|
-
onCloseAutoFocus: (event) => index.restoreDialogFocus(event, opener, container)
|
|
3376
|
-
};
|
|
3377
|
-
};
|
|
3378
|
-
const signInDetails = (t, formatDate, row) => {
|
|
3379
|
-
const presentation = getSignInEventPresentation(row);
|
|
3380
|
-
const label = t(presentation.label.messageId, presentation.label.defaultMessage);
|
|
3381
|
-
const state = getSessionStatePresentation(row.session);
|
|
3382
|
-
const revoked = presentation.key === "revoked";
|
|
3383
|
-
const adminName = row.admin?.name || noAdminText(t, row);
|
|
3384
|
-
const items = [
|
|
3385
|
-
{
|
|
3386
|
-
id: "event",
|
|
3387
|
-
label: t("adminPanel.activity.column.event", "Event"),
|
|
3388
|
-
render: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
|
|
3389
|
-
/* @__PURE__ */ jsxRuntime.jsx(EventBadge, { presentation }),
|
|
3390
|
-
presentation.detail ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(presentation.detail.messageId, presentation.detail.defaultMessage) }) : null
|
|
3391
|
-
] })
|
|
3392
|
-
},
|
|
3393
|
-
{
|
|
3394
|
-
id: "time",
|
|
3395
|
-
label: t("adminPanel.activity.details.exactTime", "Exact time"),
|
|
3396
|
-
value: row.at ? formatDate(row.at, FULL_DATE) : null
|
|
3397
|
-
},
|
|
3398
|
-
{ id: "admin", label: t("adminPanel.activity.column.admin", "Admin"), value: adminName }
|
|
3399
|
-
];
|
|
3400
|
-
if (revoked) {
|
|
3401
|
-
items.push(
|
|
3402
|
-
{
|
|
3403
|
-
id: "actor",
|
|
3404
|
-
label: t("adminPanel.activity.column.doneBy", "Done by"),
|
|
3405
|
-
value: row.actor?.name || null
|
|
3406
|
-
},
|
|
2356
|
+
) }),
|
|
2357
|
+
dashboard.status === "ended" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { ...filterSlot, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2358
|
+
designSystem.SingleSelect,
|
|
3407
2359
|
{
|
|
3408
|
-
|
|
3409
|
-
label: t("
|
|
3410
|
-
value:
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
{
|
|
3414
|
-
scope: t(presentation.detail.messageId, presentation.detail.defaultMessage),
|
|
3415
|
-
count: row.sessionsEnded
|
|
3416
|
-
}
|
|
3417
|
-
) : t(presentation.detail.messageId, presentation.detail.defaultMessage)
|
|
2360
|
+
size: "S",
|
|
2361
|
+
"aria-label": t("homepage.filter.reasonLabel", "End reason"),
|
|
2362
|
+
value: dashboard.reason,
|
|
2363
|
+
onChange: handleReasonChange,
|
|
2364
|
+
children: index.END_REASON_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: option === "all" ? t("homepage.filter.allReasons", "All reasons") : formatters.endReasonLabel(option) }, option))
|
|
3418
2365
|
}
|
|
3419
|
-
)
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
const endedAt = index.toValidDate(row.session?.endedAt);
|
|
3423
|
-
items.push({
|
|
3424
|
-
id: "session",
|
|
3425
|
-
label: t("adminPanel.activity.column.session", "Session"),
|
|
3426
|
-
value: [
|
|
3427
|
-
t(state.label.messageId, state.label.defaultMessage),
|
|
3428
|
-
endedAt ? formatDate(endedAt, SHORT_DATE) : "",
|
|
3429
|
-
row.session?.endedBy?.name ? t("adminPanel.activity.byAdmin", "by {name}", { name: row.session.endedBy.name }) : ""
|
|
3430
|
-
].filter(Boolean).join(" · ")
|
|
3431
|
-
});
|
|
3432
|
-
}
|
|
3433
|
-
if (row.change) {
|
|
3434
|
-
const lines = changedSettingsLines(t, row.change.keys);
|
|
3435
|
-
items.push({
|
|
3436
|
-
id: "settings",
|
|
3437
|
-
label: t("adminPanel.activity.details.changedSettings", "Changed settings"),
|
|
3438
|
-
...lines.length ? {
|
|
3439
|
-
render: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-changed-settings": "", children: lines.map((line) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: line }, line)) })
|
|
3440
|
-
} : { value: null },
|
|
3441
|
-
fullWidth: true
|
|
3442
|
-
});
|
|
3443
|
-
}
|
|
3444
|
-
if (row.purge) {
|
|
3445
|
-
items.push(
|
|
3446
|
-
{
|
|
3447
|
-
id: "purged",
|
|
3448
|
-
label: t("adminPanel.activity.details.deleted", "Deleted events"),
|
|
3449
|
-
value: Number.isInteger(row.purge.count) ? row.purge.count : null
|
|
3450
|
-
},
|
|
2366
|
+
) }) : null,
|
|
2367
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2368
|
+
designSystem.IconButton,
|
|
3451
2369
|
{
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
count: row.purge.retentionDays
|
|
3456
|
-
}) : null
|
|
2370
|
+
label: t("homepage.actions.refresh", "Refresh sessions"),
|
|
2371
|
+
onClick: () => fetchSessions(),
|
|
2372
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {})
|
|
3457
2373
|
}
|
|
3458
|
-
)
|
|
3459
|
-
}
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
id: "attempts",
|
|
3463
|
-
label: t("adminPanel.activity.details.attempts", "Attempts"),
|
|
3464
|
-
value: row.attempts
|
|
3465
|
-
});
|
|
3466
|
-
}
|
|
3467
|
-
items.push(
|
|
3468
|
-
{
|
|
3469
|
-
id: "ip",
|
|
3470
|
-
label: t("adminPanel.activity.details.ip", "IP address"),
|
|
3471
|
-
value: ipText(t, row) || null,
|
|
3472
|
-
kind: "id"
|
|
3473
|
-
},
|
|
3474
|
-
{
|
|
3475
|
-
id: "place",
|
|
3476
|
-
label: t("adminPanel.activity.details.location", "Location"),
|
|
3477
|
-
value: getEventPlace(row) || null
|
|
3478
|
-
},
|
|
3479
|
-
{
|
|
3480
|
-
id: "browser",
|
|
3481
|
-
label: t("adminPanel.activity.details.browser", "Browser"),
|
|
3482
|
-
value: row.browser || null
|
|
3483
|
-
},
|
|
3484
|
-
{
|
|
3485
|
-
id: "os",
|
|
3486
|
-
label: t("adminPanel.activity.details.os", "Operating system"),
|
|
3487
|
-
value: row.os || null
|
|
3488
|
-
},
|
|
3489
|
-
{
|
|
3490
|
-
id: "userAgent",
|
|
3491
|
-
label: t("adminPanel.activity.details.userAgent", "User agent"),
|
|
3492
|
-
value: row.userAgent || null,
|
|
3493
|
-
kind: "id",
|
|
3494
|
-
fullWidth: true
|
|
3495
|
-
},
|
|
2374
|
+
)
|
|
2375
|
+
] });
|
|
2376
|
+
const toolbar = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-session-toolbar": "", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2377
|
+
designSystem.Flex,
|
|
3496
2378
|
{
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
2379
|
+
direction: { initial: "column", medium: "row" },
|
|
2380
|
+
alignItems: { initial: "stretch", medium: "center" },
|
|
2381
|
+
gap: 2,
|
|
2382
|
+
children: [
|
|
2383
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { flex: "1 1 auto", minWidth: 0, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(SessionSearch, { value: dashboard.search, onSearch: handleSearch }) }),
|
|
2384
|
+
filterControls
|
|
2385
|
+
]
|
|
3501
2386
|
}
|
|
3502
|
-
);
|
|
3503
|
-
const
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
event: action,
|
|
3519
|
-
name: row.entry.title
|
|
3520
|
-
}) : action,
|
|
3521
|
-
items: [
|
|
3522
|
-
{
|
|
3523
|
-
id: "action",
|
|
3524
|
-
label: t("adminPanel.activity.column.action", "Action"),
|
|
3525
|
-
render: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...index.getBadgeColors(getActivityTone(row.action)), children: action })
|
|
3526
|
-
},
|
|
3527
|
-
{
|
|
3528
|
-
id: "time",
|
|
3529
|
-
label: t("adminPanel.activity.details.exactTime", "Exact time"),
|
|
3530
|
-
value: row.at ? formatDate(row.at, FULL_DATE) : null
|
|
3531
|
-
},
|
|
3532
|
-
{
|
|
3533
|
-
id: "entry",
|
|
3534
|
-
label: t("adminPanel.activity.column.entry", "Entry"),
|
|
3535
|
-
render: /* @__PURE__ */ jsxRuntime.jsx(ActivityEntry, { row })
|
|
3536
|
-
},
|
|
3537
|
-
{
|
|
3538
|
-
id: "admin",
|
|
3539
|
-
label: t("adminPanel.activity.column.admin", "Admin"),
|
|
3540
|
-
value: row.admin?.name || null
|
|
3541
|
-
},
|
|
3542
|
-
{
|
|
3543
|
-
id: "type",
|
|
3544
|
-
label: t("adminPanel.activity.column.contentType", "Content type"),
|
|
3545
|
-
value: row.contentType?.name || null
|
|
3546
|
-
},
|
|
3547
|
-
{
|
|
3548
|
-
id: "uid",
|
|
3549
|
-
label: t("adminPanel.activity.details.uid", "Content type UID"),
|
|
3550
|
-
value: row.contentType?.uid || null,
|
|
3551
|
-
kind: "id"
|
|
3552
|
-
},
|
|
3553
|
-
{
|
|
3554
|
-
id: "documentId",
|
|
3555
|
-
label: t("adminPanel.activity.details.documentId", "Document ID"),
|
|
3556
|
-
value: row.entry?.documentId || null,
|
|
3557
|
-
kind: "id"
|
|
3558
|
-
},
|
|
3559
|
-
{
|
|
3560
|
-
id: "locale",
|
|
3561
|
-
label: t("adminPanel.activity.details.locale", "Locale"),
|
|
3562
|
-
value: row.entry?.locale || null
|
|
3563
|
-
},
|
|
3564
|
-
{
|
|
3565
|
-
id: "eventId",
|
|
3566
|
-
label: t("adminPanel.activity.details.eventId", "Event ID"),
|
|
3567
|
-
value: row.id,
|
|
3568
|
-
kind: "id"
|
|
3569
|
-
}
|
|
3570
|
-
]
|
|
2387
|
+
) });
|
|
2388
|
+
const lastUpdatedLine = lastUpdated ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", wrap: "wrap", justifyContent: "flex-end", children: [
|
|
2389
|
+
refreshing ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, role: "status", "aria-live": "polite", children: t("homepage.refreshing", "Updating sessions") }) : null,
|
|
2390
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", "data-last-updated": "", children: t("homepage.lastUpdated", "Last updated {time}", {
|
|
2391
|
+
time: formatters.formatRelativeTime(lastUpdated, now)
|
|
2392
|
+
}) })
|
|
2393
|
+
] }) : null;
|
|
2394
|
+
const listProps = {
|
|
2395
|
+
sessions: pageResult.items,
|
|
2396
|
+
labelledBy: listHeadingId,
|
|
2397
|
+
busy: refreshing,
|
|
2398
|
+
onView: handleSessionClick,
|
|
2399
|
+
onEnd: handleTerminateSession,
|
|
2400
|
+
onDelete: handleDeleteSession,
|
|
2401
|
+
mutationPending,
|
|
2402
|
+
getFocusFallback
|
|
3571
2403
|
};
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
label,
|
|
3576
|
-
showAdmin = false,
|
|
3577
|
-
onOpenAdmin,
|
|
3578
|
-
detailsAction,
|
|
3579
|
-
busy = false
|
|
3580
|
-
}) => {
|
|
3581
|
-
const t = useT$3();
|
|
3582
|
-
const { formatDate, formatRelativeTime } = index.useSessionFormatters();
|
|
3583
|
-
const [measureRef, width] = settingsTabs.useElementWidth();
|
|
3584
|
-
const {
|
|
3585
|
-
selected,
|
|
3586
|
-
open: openDetails,
|
|
3587
|
-
close: closeDetails,
|
|
3588
|
-
onCloseAutoFocus,
|
|
3589
|
-
setContainer
|
|
3590
|
-
} = useEventDetails();
|
|
3591
|
-
const layout = getEventListLayout(width, { showAdmin });
|
|
3592
|
-
const showDoneBy = layout === "full";
|
|
3593
|
-
const detailsLabel = (row, presentation) => t("adminPanel.activity.details.open", "Details of {event}, {time}", {
|
|
3594
|
-
event: t(presentation.label.messageId, presentation.label.defaultMessage),
|
|
3595
|
-
time: formatRelativeTime(row.at)
|
|
2404
|
+
const statusCard = (status) => ({
|
|
2405
|
+
onClick: () => handleStatusChange(status),
|
|
2406
|
+
pressed: dashboard.status === status
|
|
3596
2407
|
});
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3610
|
-
StackedItem,
|
|
2408
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2409
|
+
index.PageShell,
|
|
2410
|
+
{
|
|
2411
|
+
headingId: "magic-sessionmanager-dashboard-title",
|
|
2412
|
+
title: t("homepage.title", "Sessions"),
|
|
2413
|
+
subtitle: t(
|
|
2414
|
+
"homepage.subtitle",
|
|
2415
|
+
"Sign-ins of your app’s users (Users & Permissions). Strapi administrators are not listed."
|
|
2416
|
+
),
|
|
2417
|
+
primaryAction,
|
|
2418
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2419
|
+
designSystem.Flex,
|
|
3611
2420
|
{
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
2421
|
+
ref: dashboardRef,
|
|
2422
|
+
tabIndex: -1,
|
|
2423
|
+
direction: "column",
|
|
2424
|
+
alignItems: "stretch",
|
|
2425
|
+
gap: 6,
|
|
2426
|
+
minWidth: 0,
|
|
2427
|
+
children: [
|
|
2428
|
+
/* @__PURE__ */ jsxRuntime.jsx(SessionViewNav, { current: "users" }),
|
|
2429
|
+
!loading && loadError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2430
|
+
index.PersistentAlert,
|
|
2431
|
+
{
|
|
2432
|
+
variant: "danger",
|
|
2433
|
+
closeLabel: t("common.close", "Close"),
|
|
2434
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: fetchSessions, children: t("common.tryAgain", "Try again") }),
|
|
2435
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: t("homepage.error.load", "Sessions could not be loaded.") })
|
|
2436
|
+
}
|
|
2437
|
+
) : null,
|
|
2438
|
+
showSessionData && stats.nativeOnly > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2439
|
+
UntrackedSessionsNotice,
|
|
2440
|
+
{
|
|
2441
|
+
stats,
|
|
2442
|
+
onChanged: fetchSessions,
|
|
2443
|
+
fallbackFocusRef: dashboardRef
|
|
2444
|
+
}
|
|
2445
|
+
) : null,
|
|
2446
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: t("homepage.loading", "Loading sessions") }) }) : null,
|
|
2447
|
+
showSessionData && stats.total > 0 ? /* @__PURE__ */ jsxRuntime.jsx(HowSessionsWork, {}) : null,
|
|
2448
|
+
showSessionData && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
2449
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", children: t("homepage.stats.label", "Session statistics") }) }),
|
|
2450
|
+
/* @__PURE__ */ jsxRuntime.jsxs(index.StatGrid, { label: t("homepage.stats.label", "Session statistics"), children: [
|
|
2451
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2452
|
+
index.StatCard,
|
|
2453
|
+
{
|
|
2454
|
+
icon: icons.Check,
|
|
2455
|
+
tone: "success",
|
|
2456
|
+
label: t("homepage.stats.active", "Active sessions"),
|
|
2457
|
+
value: stats.active,
|
|
2458
|
+
description: t(
|
|
2459
|
+
"homepage.stats.usersOnline",
|
|
2460
|
+
"{count, plural, one {# user online} other {# users online}}",
|
|
2461
|
+
{
|
|
2462
|
+
count: stats.usersOnline
|
|
2463
|
+
}
|
|
2464
|
+
),
|
|
2465
|
+
...statusCard("active")
|
|
2466
|
+
}
|
|
2467
|
+
),
|
|
2468
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2469
|
+
index.StatCard,
|
|
2470
|
+
{
|
|
2471
|
+
icon: icons.Clock,
|
|
2472
|
+
tone: "warning",
|
|
2473
|
+
label: t("homepage.stats.idle", "Idle sessions"),
|
|
2474
|
+
value: stats.idle,
|
|
2475
|
+
...statusCard("idle")
|
|
2476
|
+
}
|
|
2477
|
+
),
|
|
2478
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2479
|
+
index.StatCard,
|
|
2480
|
+
{
|
|
2481
|
+
icon: icons.Cross,
|
|
2482
|
+
tone: "neutral",
|
|
2483
|
+
label: t("homepage.stats.ended", "Ended sessions"),
|
|
2484
|
+
value: stats.ended,
|
|
2485
|
+
description: t(
|
|
2486
|
+
"homepage.stats.endedBreakdown",
|
|
2487
|
+
"{loggedOut, number} logged out · {timedOut, number} timed out · {other, number} other reasons",
|
|
2488
|
+
{
|
|
2489
|
+
loggedOut: stats.loggedOut,
|
|
2490
|
+
timedOut: stats.timedOut,
|
|
2491
|
+
other: stats.otherReasons
|
|
2492
|
+
}
|
|
2493
|
+
),
|
|
2494
|
+
...statusCard("ended")
|
|
2495
|
+
}
|
|
2496
|
+
),
|
|
3620
2497
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3621
|
-
|
|
2498
|
+
index.StatCard,
|
|
3622
2499
|
{
|
|
3623
|
-
|
|
3624
|
-
|
|
2500
|
+
icon: icons.User,
|
|
2501
|
+
tone: "primary",
|
|
2502
|
+
label: t("homepage.stats.total", "All sessions"),
|
|
2503
|
+
value: stats.total,
|
|
2504
|
+
...statusCard("all")
|
|
3625
2505
|
}
|
|
3626
2506
|
)
|
|
3627
2507
|
] })
|
|
3628
2508
|
] }),
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
}) })
|
|
3679
|
-
] }) });
|
|
3680
|
-
}
|
|
3681
|
-
const content = selected ? signInDetails(t, formatDate, selected) : null;
|
|
3682
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { ref: measureRef, minWidth: 0, width: "100%", children: [
|
|
3683
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { ref: setContainer, tabIndex: -1, minWidth: 0, children: list }),
|
|
3684
|
-
content ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3685
|
-
EventDetailsModal,
|
|
3686
|
-
{
|
|
3687
|
-
title: content.title,
|
|
3688
|
-
items: content.items,
|
|
3689
|
-
footerAction: detailsAction ? detailsAction(selected, closeDetails) : null,
|
|
3690
|
-
onClose: closeDetails,
|
|
3691
|
-
onCloseAutoFocus
|
|
3692
|
-
}
|
|
3693
|
-
) : null
|
|
3694
|
-
] });
|
|
3695
|
-
};
|
|
3696
|
-
const ActivityEventTable = ({ rows, label, showAdmin = false, busy = false }) => {
|
|
3697
|
-
const t = useT$3();
|
|
3698
|
-
const { formatDate, formatRelativeTime } = index.useSessionFormatters();
|
|
3699
|
-
const [measureRef, width] = settingsTabs.useElementWidth();
|
|
3700
|
-
const {
|
|
3701
|
-
selected,
|
|
3702
|
-
open: openDetails,
|
|
3703
|
-
close: closeDetails,
|
|
3704
|
-
onCloseAutoFocus,
|
|
3705
|
-
setContainer
|
|
3706
|
-
} = useEventDetails();
|
|
3707
|
-
const layout = getEventListLayout(width, { showAdmin });
|
|
3708
|
-
const actionOf = (row) => {
|
|
3709
|
-
const entry = ACTIVITY_ACTION_LABELS[row.action] || ACTIVITY_ACTION_LABELS.view;
|
|
3710
|
-
return t(entry.messageId, entry.defaultMessage);
|
|
3711
|
-
};
|
|
3712
|
-
const detailsLabel = (row) => t("adminPanel.activity.details.open", "Details of {event}, {time}", {
|
|
3713
|
-
event: actionOf(row),
|
|
3714
|
-
time: formatRelativeTime(row.at)
|
|
3715
|
-
});
|
|
3716
|
-
const badge = (row) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3717
|
-
designSystem.Badge,
|
|
3718
|
-
{
|
|
3719
|
-
...index.getBadgeColors(getActivityTone(row.action)),
|
|
3720
|
-
"data-event-tone": getActivityTone(row.action),
|
|
3721
|
-
children: actionOf(row)
|
|
3722
|
-
}
|
|
3723
|
-
);
|
|
3724
|
-
let list;
|
|
3725
|
-
if (layout === "stacked") {
|
|
3726
|
-
list = /* @__PURE__ */ jsxRuntime.jsx(StackedList, { "aria-label": label, "data-event-list": "stacked", children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3727
|
-
StackedItem,
|
|
3728
|
-
{
|
|
3729
|
-
"data-event-row": row.action,
|
|
3730
|
-
"data-event-id": row.id,
|
|
3731
|
-
onClick: (event) => openDetails(row, event.currentTarget),
|
|
3732
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, padding: 3, minWidth: 0, children: [
|
|
3733
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
|
|
3734
|
-
badge(row),
|
|
3735
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", marginLeft: "auto", children: [
|
|
3736
|
-
/* @__PURE__ */ jsxRuntime.jsx(EventTime, { value: row.at, compact: true }),
|
|
3737
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3738
|
-
DetailsButton,
|
|
2509
|
+
showToolbar && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { ref: listWidthRef, direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
|
|
2510
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h2", children: t("homepage.list.heading", "Session list") }) }),
|
|
2511
|
+
toolbar,
|
|
2512
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", gap: 4, wrap: "wrap", children: [
|
|
2513
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2514
|
+
designSystem.Typography,
|
|
2515
|
+
{
|
|
2516
|
+
id: listHeadingId,
|
|
2517
|
+
ref: listHeadingRef,
|
|
2518
|
+
tabIndex: -1,
|
|
2519
|
+
variant: "pi",
|
|
2520
|
+
textColor: "neutral600",
|
|
2521
|
+
"aria-live": "polite",
|
|
2522
|
+
"data-session-caption": "",
|
|
2523
|
+
children: pageResult.total > 0 ? t(
|
|
2524
|
+
"homepage.caption",
|
|
2525
|
+
"{from, number}–{to, number} of {total, plural, one {# session} other {# sessions}}",
|
|
2526
|
+
{
|
|
2527
|
+
from: pageResult.startIndex,
|
|
2528
|
+
to: pageResult.endIndex,
|
|
2529
|
+
total: pageResult.total
|
|
2530
|
+
}
|
|
2531
|
+
) : t("homepage.captionNone", "0 sessions")
|
|
2532
|
+
}
|
|
2533
|
+
),
|
|
2534
|
+
lastUpdatedLine
|
|
2535
|
+
] }),
|
|
2536
|
+
pageResult.total > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2537
|
+
isBelowMedium ? /* @__PURE__ */ jsxRuntime.jsx(SessionCardList, { ...listProps }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2538
|
+
SessionTable,
|
|
2539
|
+
{
|
|
2540
|
+
...listProps,
|
|
2541
|
+
compact: dashboardModel.shouldUseCompactTable(listWidth, isBelowLarge)
|
|
2542
|
+
}
|
|
2543
|
+
),
|
|
2544
|
+
/* @__PURE__ */ jsxRuntime.jsx(PaginationTargets$3, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2545
|
+
StrapiAdmin.Pagination.Root,
|
|
2546
|
+
{
|
|
2547
|
+
pageCount: pageResult.pageCount,
|
|
2548
|
+
total: pageResult.total,
|
|
2549
|
+
defaultPageSize: Number(dashboardModel.DEFAULT_PAGE_SIZE),
|
|
2550
|
+
children: [
|
|
2551
|
+
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...dashboardModel.PAGE_SIZE_OPTIONS] }),
|
|
2552
|
+
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.Links, {})
|
|
2553
|
+
]
|
|
2554
|
+
}
|
|
2555
|
+
) })
|
|
2556
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2557
|
+
designSystem.EmptyStateLayout,
|
|
3739
2558
|
{
|
|
3740
|
-
|
|
3741
|
-
|
|
2559
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
|
|
2560
|
+
content: t(
|
|
2561
|
+
"homepage.noResults.description",
|
|
2562
|
+
"No sessions match your search or filter."
|
|
2563
|
+
),
|
|
2564
|
+
action: filtersActive ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: handleClearFilters, children: t("homepage.noResults.reset", "Clear filters") }) : null
|
|
3742
2565
|
}
|
|
3743
2566
|
)
|
|
3744
|
-
] })
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderCell, { children: t("adminPanel.activity.column.entry", "Entry") }),
|
|
3759
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderCell, { children: t("adminPanel.activity.column.contentType", "Content type") }),
|
|
3760
|
-
showAdmin ? /* @__PURE__ */ jsxRuntime.jsx(HeaderCell, { children: t("adminPanel.activity.column.admin", "Admin") }) : null,
|
|
3761
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderCell, { hidden: true, children: t("adminPanel.table.actions", "Actions") })
|
|
3762
|
-
] }) }),
|
|
3763
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3764
|
-
ClickableRow,
|
|
3765
|
-
{
|
|
3766
|
-
"data-event-row": row.action,
|
|
3767
|
-
"data-event-id": row.id,
|
|
3768
|
-
onClick: (event) => openDetails(row, event.currentTarget),
|
|
3769
|
-
children: [
|
|
3770
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(EventTime, { value: row.at }) }),
|
|
3771
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: badge(row) }),
|
|
3772
|
-
/* @__PURE__ */ jsxRuntime.jsx(WrapCell, { children: /* @__PURE__ */ jsxRuntime.jsx(ActivityEntry, { row }) }),
|
|
3773
|
-
/* @__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" }) }),
|
|
3774
|
-
showAdmin ? /* @__PURE__ */ jsxRuntime.jsx(WrapCell, { children: /* @__PURE__ */ jsxRuntime.jsx(AdminName, { admin: row.admin }) }) : null,
|
|
3775
|
-
/* @__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(
|
|
3776
|
-
DetailsButton,
|
|
2567
|
+
] }),
|
|
2568
|
+
showSessionData && stats.total === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2569
|
+
designSystem.EmptyStateLayout,
|
|
2570
|
+
{
|
|
2571
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
|
|
2572
|
+
content: t(
|
|
2573
|
+
"homepage.empty.description",
|
|
2574
|
+
"No sessions yet. Sessions appear here when users of your app sign in."
|
|
2575
|
+
)
|
|
2576
|
+
}
|
|
2577
|
+
),
|
|
2578
|
+
/* @__PURE__ */ jsxRuntime.jsx(RecentUserActivity, {}),
|
|
2579
|
+
showDetailModal && selectedSession && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2580
|
+
SessionDetailModal,
|
|
3777
2581
|
{
|
|
3778
|
-
|
|
3779
|
-
|
|
2582
|
+
session: selectedSession,
|
|
2583
|
+
now,
|
|
2584
|
+
onClose: handleModalClose,
|
|
2585
|
+
onCloseAutoFocus: handleCloseAutoFocus,
|
|
2586
|
+
onEndSession: handleTerminateSession
|
|
3780
2587
|
}
|
|
3781
|
-
)
|
|
2588
|
+
)
|
|
3782
2589
|
]
|
|
3783
|
-
},
|
|
3784
|
-
row.id
|
|
3785
|
-
)) })
|
|
3786
|
-
] }) });
|
|
3787
|
-
}
|
|
3788
|
-
const content = selected ? activityDetails(t, formatDate, selected) : null;
|
|
3789
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { ref: measureRef, minWidth: 0, width: "100%", children: [
|
|
3790
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { ref: setContainer, tabIndex: -1, minWidth: 0, children: list }),
|
|
3791
|
-
content ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3792
|
-
EventDetailsModal,
|
|
3793
|
-
{
|
|
3794
|
-
title: content.title,
|
|
3795
|
-
items: content.items,
|
|
3796
|
-
onClose: closeDetails,
|
|
3797
|
-
onCloseAutoFocus
|
|
3798
|
-
}
|
|
3799
|
-
) : null
|
|
3800
|
-
] });
|
|
3801
|
-
};
|
|
3802
|
-
function useEventList({ path, params, logKey }) {
|
|
3803
|
-
const { get } = StrapiAdmin.useFetchClient();
|
|
3804
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
3805
|
-
const fillNames = react.useCallback(
|
|
3806
|
-
(list) => list.map(
|
|
3807
|
-
(row) => withEventAdminNames(
|
|
3808
|
-
row,
|
|
3809
|
-
(id) => formatMessage(
|
|
3810
|
-
{
|
|
3811
|
-
id: index.getTranslation("adminPanel.identity.placeholder"),
|
|
3812
|
-
defaultMessage: "Admin #{id}"
|
|
3813
|
-
},
|
|
3814
|
-
{ id }
|
|
3815
|
-
)
|
|
3816
|
-
)
|
|
3817
|
-
),
|
|
3818
|
-
[formatMessage]
|
|
3819
|
-
);
|
|
3820
|
-
const [rows, setRows] = react.useState([]);
|
|
3821
|
-
const [meta, setMeta] = react.useState(null);
|
|
3822
|
-
const [page, setPage] = react.useState(1);
|
|
3823
|
-
const [loading, setLoading] = react.useState(true);
|
|
3824
|
-
const [loadingMore, setLoadingMore] = react.useState(false);
|
|
3825
|
-
const [error, setError] = react.useState(false);
|
|
3826
|
-
const requestRef = react.useRef(0);
|
|
3827
|
-
const key = JSON.stringify(params);
|
|
3828
|
-
const firstPage = Number(params?.page) > 0 ? Number(params.page) : 1;
|
|
3829
|
-
const load = react.useCallback(
|
|
3830
|
-
async (nextPage) => {
|
|
3831
|
-
const requestId = requestRef.current + 1;
|
|
3832
|
-
requestRef.current = requestId;
|
|
3833
|
-
if (nextPage === firstPage) setLoading(true);
|
|
3834
|
-
else setLoadingMore(true);
|
|
3835
|
-
try {
|
|
3836
|
-
const response = await get(path, { params: { ...JSON.parse(key), page: nextPage } });
|
|
3837
|
-
if (requestId !== requestRef.current) return;
|
|
3838
|
-
const body = response?.data || {};
|
|
3839
|
-
const data = fillNames(Array.isArray(body.data) ? body.data : []);
|
|
3840
|
-
setRows((current) => nextPage === firstPage ? data : [...current, ...data]);
|
|
3841
|
-
setMeta(body.meta || null);
|
|
3842
|
-
setPage(nextPage);
|
|
3843
|
-
setError(false);
|
|
3844
|
-
} catch (err) {
|
|
3845
|
-
if (requestId !== requestRef.current || index.isCancelledRequest(err)) return;
|
|
3846
|
-
setError(true);
|
|
3847
|
-
index.logSafeAdminError(logKey, err);
|
|
3848
|
-
} finally {
|
|
3849
|
-
if (requestId === requestRef.current) {
|
|
3850
|
-
setLoading(false);
|
|
3851
|
-
setLoadingMore(false);
|
|
3852
2590
|
}
|
|
3853
|
-
|
|
3854
|
-
},
|
|
3855
|
-
[get, path, key, logKey, fillNames, firstPage]
|
|
3856
|
-
);
|
|
3857
|
-
react.useEffect(() => {
|
|
3858
|
-
load(firstPage);
|
|
3859
|
-
return () => {
|
|
3860
|
-
requestRef.current += 1;
|
|
3861
|
-
};
|
|
3862
|
-
}, [load, firstPage]);
|
|
3863
|
-
const pagination = meta?.pagination;
|
|
3864
|
-
const hasMore = Boolean(pagination && page < pagination.pageCount);
|
|
3865
|
-
const exportAll = react.useCallback(async () => {
|
|
3866
|
-
const all = [];
|
|
3867
|
-
let cursor = null;
|
|
3868
|
-
do {
|
|
3869
|
-
const response = await get(`${path}/export`, {
|
|
3870
|
-
params: toExportParams(JSON.parse(key), cursor)
|
|
3871
|
-
});
|
|
3872
|
-
const body = response?.data || {};
|
|
3873
|
-
if (!Array.isArray(body.data)) throw new Error("Invalid export response");
|
|
3874
|
-
all.push(...fillNames(body.data));
|
|
3875
|
-
cursor = typeof body.meta?.nextCursor === "string" ? body.meta.nextCursor : null;
|
|
3876
|
-
} while (cursor && all.length < MAX_EVENT_EXPORT_ROWS);
|
|
3877
|
-
return {
|
|
3878
|
-
rows: all.slice(0, MAX_EVENT_EXPORT_ROWS),
|
|
3879
|
-
capped: all.length > MAX_EVENT_EXPORT_ROWS || Boolean(cursor)
|
|
3880
|
-
};
|
|
3881
|
-
}, [get, path, key, fillNames]);
|
|
3882
|
-
return {
|
|
3883
|
-
rows,
|
|
3884
|
-
meta,
|
|
3885
|
-
loading,
|
|
3886
|
-
loadingMore,
|
|
3887
|
-
error,
|
|
3888
|
-
hasMore,
|
|
3889
|
-
loadMore: () => load(page + 1),
|
|
3890
|
-
reload: () => load(firstPage),
|
|
3891
|
-
exportAll
|
|
3892
|
-
};
|
|
3893
|
-
}
|
|
3894
|
-
function downloadCsv(content, name) {
|
|
3895
|
-
const blob = new Blob([content], { type: "text/csv;charset=utf-8;" });
|
|
3896
|
-
const url = URL.createObjectURL(blob);
|
|
3897
|
-
const link = document.createElement("a");
|
|
3898
|
-
link.href = url;
|
|
3899
|
-
link.download = `${name}-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`;
|
|
3900
|
-
link.click();
|
|
3901
|
-
window.setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
3902
|
-
}
|
|
3903
|
-
const ADMIN_ACTIVITY_SETTINGS_PATH = `/settings/${index.pluginId}/general?tab=admin-activity`;
|
|
3904
|
-
const ADMIN_ACTIVITY_PAGE_PATH = `/plugins/${index.pluginId}/admin-panel/activity`;
|
|
3905
|
-
const useT$2 = () => {
|
|
3906
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
3907
|
-
return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
3908
|
-
};
|
|
3909
|
-
const PeriodSelect = ({ value, onChange }) => {
|
|
3910
|
-
const t = useT$2();
|
|
3911
|
-
const labels = {
|
|
3912
|
-
1: t("adminPanel.activity.period.day", "Last 24 hours"),
|
|
3913
|
-
7: t("adminPanel.activity.period.week", "Last 7 days"),
|
|
3914
|
-
30: t("adminPanel.activity.period.month", "Last 30 days"),
|
|
3915
|
-
90: t("adminPanel.activity.period.quarter", "Last 90 days"),
|
|
3916
|
-
all: t("adminPanel.activity.period.all", "All kept events")
|
|
3917
|
-
};
|
|
3918
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3919
|
-
designSystem.SingleSelect,
|
|
3920
|
-
{
|
|
3921
|
-
size: "S",
|
|
3922
|
-
"aria-label": t("adminPanel.activity.period.label", "Period"),
|
|
3923
|
-
value,
|
|
3924
|
-
onChange: (next) => onChange(String(next)),
|
|
3925
|
-
children: PERIOD_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: labels[option] }, option))
|
|
2591
|
+
)
|
|
3926
2592
|
}
|
|
3927
2593
|
);
|
|
3928
2594
|
};
|
|
3929
|
-
const
|
|
3930
|
-
const
|
|
3931
|
-
const
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
const [exporting, setExporting] = react.useState(false);
|
|
3945
|
-
const total = list.meta?.pagination?.total ?? 0;
|
|
3946
|
-
const handleExport = async () => {
|
|
3947
|
-
if (exporting) return;
|
|
3948
|
-
setExporting(true);
|
|
3949
|
-
try {
|
|
3950
|
-
const { rows, capped } = await list.exportAll();
|
|
3951
|
-
downloadCsv(toCsv2(rows), fileName);
|
|
3952
|
-
if (capped) {
|
|
3953
|
-
toggleNotification({
|
|
3954
|
-
type: "warning",
|
|
3955
|
-
message: t(
|
|
3956
|
-
"adminPanel.activity.export.capped",
|
|
3957
|
-
"The export contains the newest {limit, number} events. Narrow the filter to export the rest.",
|
|
3958
|
-
{ limit: MAX_EVENT_EXPORT_ROWS }
|
|
3959
|
-
)
|
|
3960
|
-
});
|
|
3961
|
-
}
|
|
3962
|
-
} catch (err) {
|
|
3963
|
-
if (index.isCancelledRequest(err)) return;
|
|
3964
|
-
index.logSafeAdminError("adminPanel.activity.export", err);
|
|
3965
|
-
toggleNotification({
|
|
3966
|
-
type: "danger",
|
|
3967
|
-
message: t("adminPanel.activity.export.error", "The export could not be created.")
|
|
3968
|
-
});
|
|
3969
|
-
} finally {
|
|
3970
|
-
setExporting(false);
|
|
3971
|
-
}
|
|
3972
|
-
};
|
|
3973
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
|
|
3974
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
|
|
3975
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", flex: "1 1 auto", minWidth: 0, children: filters }),
|
|
2595
|
+
const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
|
|
2596
|
+
const offersPreview = (admin, canPreview) => Boolean(canPreview) && admin.self !== true && !(admin.roles || []).some((role) => role?.superAdmin === true);
|
|
2597
|
+
const keepActionKeys = (event) => {
|
|
2598
|
+
if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2599
|
+
};
|
|
2600
|
+
const SHRINKING_ADMIN_CELL = { maxWidth: 0, width: "34%" };
|
|
2601
|
+
const SHRINKING_ROLES_CELL = { maxWidth: 0, width: "22%" };
|
|
2602
|
+
const useT$2 = () => {
|
|
2603
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
2604
|
+
return (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
2605
|
+
};
|
|
2606
|
+
const AdminIdentity = ({ admin }) => {
|
|
2607
|
+
const t = useT$2();
|
|
2608
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, children: [
|
|
2609
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
|
|
3976
2610
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3977
|
-
designSystem.
|
|
2611
|
+
designSystem.Typography,
|
|
3978
2612
|
{
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
"aria-label": exportLabel,
|
|
3986
|
-
children: t("adminPanel.activity.export.csv", "Export CSV")
|
|
2613
|
+
variant: "omega",
|
|
2614
|
+
fontWeight: "semiBold",
|
|
2615
|
+
textColor: "neutral800",
|
|
2616
|
+
ellipsis: true,
|
|
2617
|
+
title: admin.name,
|
|
2618
|
+
children: admin.name
|
|
3987
2619
|
}
|
|
3988
|
-
)
|
|
2620
|
+
),
|
|
2621
|
+
admin.self ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...HIGHLIGHT_BADGE, shrink: 0, children: t("adminPanel.you", "You") }) : null
|
|
3989
2622
|
] }),
|
|
3990
|
-
|
|
3991
|
-
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,
|
|
3992
|
-
!list.loading && list.error ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3993
|
-
index.PersistentAlert,
|
|
3994
|
-
{
|
|
3995
|
-
variant: "danger",
|
|
3996
|
-
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: list.reload, children: t("common.tryAgain", "Try again") }),
|
|
3997
|
-
children: t("adminPanel.activity.error", "The events could not be loaded.")
|
|
3998
|
-
}
|
|
3999
|
-
) : null,
|
|
4000
|
-
!list.loading && !list.error && list.rows.length === 0 ? empty : null,
|
|
4001
|
-
list.rows.length > 0 ? renderList(list.rows) : null,
|
|
4002
|
-
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
|
|
2623
|
+
admin.identityHidden ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("adminPanel.identity.emailHidden", "Email hidden (needs “Read” on Users)") }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, title: admin.email, children: admin.email })
|
|
4003
2624
|
] });
|
|
4004
2625
|
};
|
|
4005
|
-
const
|
|
2626
|
+
const AdminRoles = ({ admin }) => {
|
|
4006
2627
|
const t = useT$2();
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
variant: "neutral",
|
|
4011
|
-
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Link, { tag: reactRouterDom.Link, to: ADMIN_ACTIVITY_SETTINGS_PATH, children: t("adminPanel.activity.openSettings", "Open settings") }),
|
|
4012
|
-
children
|
|
4013
|
-
}
|
|
4014
|
-
);
|
|
2628
|
+
const names = (admin.roles || []).map((role) => role.name).filter(Boolean);
|
|
2629
|
+
const text = admin.rolesHidden ? t("adminPanel.roles.hidden", "Hidden (needs “Read” on Roles)") : names.length ? names.join(", ") : t("adminPanel.roles.none", "No role");
|
|
2630
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", ellipsis: true, title: text, children: text });
|
|
4015
2631
|
};
|
|
4016
|
-
const
|
|
2632
|
+
const AdminStatus = ({ admin }) => {
|
|
4017
2633
|
const t = useT$2();
|
|
4018
|
-
const
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
);
|
|
4024
|
-
const list = useEventList({
|
|
4025
|
-
path: `/${index.pluginId}/admin-activity/sign-ins`,
|
|
4026
|
-
params,
|
|
4027
|
-
logKey: "adminPanel.activity.signIns"
|
|
4028
|
-
});
|
|
4029
|
-
const recording = list.meta?.recording;
|
|
4030
|
-
const labels = {
|
|
4031
|
-
all: t("adminPanel.activity.filter.allEvents", "All events"),
|
|
4032
|
-
succeeded: t("adminPanel.activity.filter.succeeded", "Sign-ins"),
|
|
4033
|
-
failed: t("adminPanel.activity.filter.failed", "Failed and locked out"),
|
|
4034
|
-
"signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs")
|
|
4035
|
-
};
|
|
4036
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4037
|
-
EventList,
|
|
4038
|
-
{
|
|
4039
|
-
list,
|
|
4040
|
-
filters: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4041
|
-
/* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4042
|
-
designSystem.SingleSelect,
|
|
4043
|
-
{
|
|
4044
|
-
size: "S",
|
|
4045
|
-
"aria-label": t("adminPanel.activity.filter.event", "Event"),
|
|
4046
|
-
value: event,
|
|
4047
|
-
onChange: (next) => setEvent(String(next)),
|
|
4048
|
-
children: SIGN_IN_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: labels[option] }, option))
|
|
4049
|
-
}
|
|
4050
|
-
) }),
|
|
4051
|
-
/* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(PeriodSelect, { value: period, onChange: setPeriod }) })
|
|
4052
|
-
] }),
|
|
4053
|
-
notice: recording && !recording.signIns ? /* @__PURE__ */ jsxRuntime.jsx(RecordingOff, { children: t(
|
|
4054
|
-
"adminPanel.activity.signIns.off",
|
|
4055
|
-
"Sign-in history is turned off. New sign-ins are not recorded."
|
|
4056
|
-
) }) : null,
|
|
4057
|
-
empty: /* @__PURE__ */ jsxRuntime.jsx(EmptyText, { children: t("adminPanel.activity.signIns.empty", "No sign-in events in this period.") }),
|
|
4058
|
-
renderList: (rows) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4059
|
-
SignInEventTable,
|
|
4060
|
-
{
|
|
4061
|
-
rows,
|
|
4062
|
-
busy: list.loading,
|
|
4063
|
-
label: t("adminPanel.activity.signIns.listLabel", "Sign-in history of {name}", {
|
|
4064
|
-
name: admin.name
|
|
4065
|
-
})
|
|
4066
|
-
}
|
|
4067
|
-
),
|
|
4068
|
-
toCsv: buildSignInCsv,
|
|
4069
|
-
fileName: "admin-sign-in-history",
|
|
4070
|
-
exportLabel: t(
|
|
4071
|
-
"adminPanel.activity.signIns.export",
|
|
4072
|
-
"Export the sign-in history of {name} as CSV",
|
|
4073
|
-
{
|
|
4074
|
-
name: admin.name
|
|
4075
|
-
}
|
|
4076
|
-
)
|
|
4077
|
-
}
|
|
4078
|
-
);
|
|
2634
|
+
const status = index.getAdminStatusPresentation(admin);
|
|
2635
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-admin-status": status.key, children: [
|
|
2636
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...index.getBadgeColors(status.tone), children: t(status.label.messageId, status.label.defaultMessage) }),
|
|
2637
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(status.detail.messageId, status.detail.defaultMessage, status.detail.values) })
|
|
2638
|
+
] });
|
|
4079
2639
|
};
|
|
4080
|
-
const
|
|
2640
|
+
const AdminTable = ({
|
|
2641
|
+
admins,
|
|
2642
|
+
labelledBy,
|
|
2643
|
+
canRevoke,
|
|
2644
|
+
onView,
|
|
2645
|
+
onSignOutEverywhere,
|
|
2646
|
+
canPreview,
|
|
2647
|
+
onPreview,
|
|
2648
|
+
busy
|
|
2649
|
+
}) => {
|
|
4081
2650
|
const t = useT$2();
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
const [period, setPeriod] = react.useState("30");
|
|
4085
|
-
const params = react.useMemo(
|
|
4086
|
-
() => buildActivityParams({ adminId: admin.id, action, contentType, period }),
|
|
4087
|
-
[admin.id, action, contentType, period]
|
|
4088
|
-
);
|
|
4089
|
-
const list = useEventList({
|
|
4090
|
-
path: `/${index.pluginId}/admin-activity/content`,
|
|
4091
|
-
params,
|
|
4092
|
-
logKey: "adminPanel.activity.content"
|
|
4093
|
-
});
|
|
4094
|
-
const recording = list.meta?.recording;
|
|
4095
|
-
const types = Array.isArray(list.meta?.contentTypes) ? list.meta.contentTypes : [];
|
|
4096
|
-
const noAccess = list.meta?.contentManagerAccess === false;
|
|
4097
|
-
let notice = null;
|
|
4098
|
-
if (recording && !recording.contentActivity) {
|
|
4099
|
-
notice = /* @__PURE__ */ jsxRuntime.jsx(RecordingOff, { children: t(
|
|
4100
|
-
"adminPanel.activity.content.off",
|
|
4101
|
-
"Content Manager activity is not recorded. An admin can turn it on in the settings; inform your team first."
|
|
4102
|
-
) });
|
|
4103
|
-
} else if (noAccess) {
|
|
4104
|
-
notice = /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "neutral", children: t(
|
|
4105
|
-
"adminPanel.activity.content.noAccess",
|
|
4106
|
-
"{name} has no Content Manager access, so there is no activity to show.",
|
|
4107
|
-
{ name: admin.name }
|
|
4108
|
-
) });
|
|
4109
|
-
}
|
|
4110
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4111
|
-
EventList,
|
|
2651
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral0", hasRadius: true, shadow: "tableShadow", "data-admin-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2652
|
+
designSystem.Table,
|
|
4112
2653
|
{
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
}
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
designSystem.
|
|
4130
|
-
{
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
2654
|
+
colCount: 5,
|
|
2655
|
+
rowCount: admins.length + 1,
|
|
2656
|
+
"aria-labelledby": labelledBy,
|
|
2657
|
+
"aria-busy": busy,
|
|
2658
|
+
children: [
|
|
2659
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
2660
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: SHRINKING_ADMIN_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.admin", "Admin") }) }),
|
|
2661
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.roles", "Roles") }) }),
|
|
2662
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.status", "Status") }) }),
|
|
2663
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.lastActive", "Last active") }) }),
|
|
2664
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("adminPanel.table.actions", "Actions") }) })
|
|
2665
|
+
] }) }),
|
|
2666
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: admins.map((admin) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-admin-row": admin.id, children: [
|
|
2667
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_ADMIN_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(AdminIdentity, { admin }) }),
|
|
2668
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin }) }),
|
|
2669
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin }) }),
|
|
2670
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: admin.lastActiveAt }) }),
|
|
2671
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: [
|
|
2672
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2673
|
+
designSystem.IconButton,
|
|
2674
|
+
{
|
|
2675
|
+
label: t("adminPanel.actions.view", "View sessions of {name}", {
|
|
2676
|
+
name: admin.name
|
|
2677
|
+
}),
|
|
2678
|
+
onClick: (event) => onView(admin, event.currentTarget),
|
|
2679
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
|
|
2680
|
+
}
|
|
2681
|
+
),
|
|
2682
|
+
offersPreview(admin, canPreview) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2683
|
+
designSystem.IconButton,
|
|
2684
|
+
{
|
|
2685
|
+
label: t("adminPanel.actions.viewAs", "View as {name}", {
|
|
2686
|
+
name: admin.name || `#${admin.id}`
|
|
2687
|
+
}),
|
|
2688
|
+
onClick: (event) => onPreview?.(admin, event.currentTarget),
|
|
2689
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {})
|
|
2690
|
+
}
|
|
2691
|
+
) : null,
|
|
2692
|
+
canRevoke && admin.canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2693
|
+
designSystem.IconButton,
|
|
2694
|
+
{
|
|
2695
|
+
variant: "danger-light",
|
|
2696
|
+
label: t(
|
|
2697
|
+
"adminPanel.actions.signOutEverywhere",
|
|
2698
|
+
"Sign out {name} everywhere",
|
|
2699
|
+
{
|
|
2700
|
+
name: admin.name
|
|
2701
|
+
}
|
|
2702
|
+
),
|
|
2703
|
+
onClick: (event) => onSignOutEverywhere(admin, event.currentTarget),
|
|
2704
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {})
|
|
2705
|
+
}
|
|
2706
|
+
) : null
|
|
2707
|
+
] }) })
|
|
2708
|
+
] }, admin.id)) })
|
|
2709
|
+
]
|
|
4162
2710
|
}
|
|
4163
|
-
);
|
|
2711
|
+
) });
|
|
4164
2712
|
};
|
|
4165
|
-
const
|
|
2713
|
+
const AdminCardList = ({
|
|
2714
|
+
admins,
|
|
2715
|
+
labelledBy,
|
|
2716
|
+
canRevoke,
|
|
2717
|
+
onView,
|
|
2718
|
+
onSignOutEverywhere,
|
|
2719
|
+
canPreview,
|
|
2720
|
+
onPreview
|
|
2721
|
+
}) => {
|
|
4166
2722
|
const t = useT$2();
|
|
4167
|
-
|
|
4168
|
-
const params = react.useMemo(() => buildSignInParams({ pageSize: RECENT_EVENT_LIMIT }), []);
|
|
4169
|
-
const list = useEventList({
|
|
4170
|
-
path: `/${index.pluginId}/admin-activity/sign-ins`,
|
|
4171
|
-
params,
|
|
4172
|
-
logKey: "adminPanel.activity.recent"
|
|
4173
|
-
});
|
|
4174
|
-
if (list.meta?.recording && !list.meta.recording.signIns) return null;
|
|
4175
|
-
const title = t("adminPanel.activity.recent.title", "Recent security activity");
|
|
4176
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2723
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4177
2724
|
designSystem.Flex,
|
|
4178
2725
|
{
|
|
4179
|
-
tag: "
|
|
4180
|
-
"aria-labelledby": headingId,
|
|
2726
|
+
tag: "ul",
|
|
4181
2727
|
direction: "column",
|
|
4182
2728
|
alignItems: "stretch",
|
|
4183
|
-
gap:
|
|
4184
|
-
|
|
4185
|
-
"data-
|
|
4186
|
-
children:
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
/* @__PURE__ */ jsxRuntime.
|
|
4196
|
-
|
|
4197
|
-
{
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
}
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
2729
|
+
gap: 3,
|
|
2730
|
+
"aria-labelledby": labelledBy,
|
|
2731
|
+
"data-admin-cards": "",
|
|
2732
|
+
children: admins.map((admin) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2733
|
+
designSystem.Box,
|
|
2734
|
+
{
|
|
2735
|
+
tag: "li",
|
|
2736
|
+
background: "neutral0",
|
|
2737
|
+
hasRadius: true,
|
|
2738
|
+
shadow: "tableShadow",
|
|
2739
|
+
padding: 4,
|
|
2740
|
+
"data-admin-row": admin.id,
|
|
2741
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, minWidth: 0, children: [
|
|
2742
|
+
/* @__PURE__ */ jsxRuntime.jsx(AdminIdentity, { admin }),
|
|
2743
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, wrap: "wrap", alignItems: "flex-start", justifyContent: "space-between", children: [
|
|
2744
|
+
/* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin }),
|
|
2745
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
|
|
2746
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("adminPanel.table.lastActive", "Last active") }),
|
|
2747
|
+
/* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: admin.lastActiveAt })
|
|
2748
|
+
] })
|
|
2749
|
+
] }),
|
|
2750
|
+
/* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin }),
|
|
2751
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
|
|
2752
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2753
|
+
designSystem.Button,
|
|
2754
|
+
{
|
|
2755
|
+
variant: "secondary",
|
|
2756
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {}),
|
|
2757
|
+
onClick: (event) => onView(admin, event.currentTarget),
|
|
2758
|
+
"aria-label": t("adminPanel.actions.view", "View sessions of {name}", {
|
|
2759
|
+
name: admin.name
|
|
2760
|
+
}),
|
|
2761
|
+
flex: "1 1 auto",
|
|
2762
|
+
children: t("adminPanel.actions.viewShort", "View sessions")
|
|
2763
|
+
}
|
|
2764
|
+
),
|
|
2765
|
+
offersPreview(admin, canPreview) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2766
|
+
designSystem.Button,
|
|
2767
|
+
{
|
|
2768
|
+
variant: "secondary",
|
|
2769
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
|
|
2770
|
+
onClick: (event) => onPreview?.(admin, event.currentTarget),
|
|
2771
|
+
"aria-label": t("adminPanel.actions.viewAs", "View as {name}", {
|
|
2772
|
+
name: admin.name || `#${admin.id}`
|
|
2773
|
+
}),
|
|
2774
|
+
flex: "1 1 auto",
|
|
2775
|
+
children: t("adminPanel.actions.viewAsShort", "View as")
|
|
2776
|
+
}
|
|
2777
|
+
) : null,
|
|
2778
|
+
canRevoke && admin.canSignOut ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2779
|
+
designSystem.Button,
|
|
2780
|
+
{
|
|
2781
|
+
variant: "danger-light",
|
|
2782
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {}),
|
|
2783
|
+
onClick: (event) => onSignOutEverywhere(admin, event.currentTarget),
|
|
2784
|
+
"aria-label": t(
|
|
2785
|
+
"adminPanel.actions.signOutEverywhere",
|
|
2786
|
+
"Sign out {name} everywhere",
|
|
2787
|
+
{
|
|
2788
|
+
name: admin.name
|
|
2789
|
+
}
|
|
2790
|
+
),
|
|
2791
|
+
flex: "1 1 auto",
|
|
2792
|
+
children: t("adminPanel.actions.signOutEverywhereShort", "Sign out everywhere")
|
|
2793
|
+
}
|
|
2794
|
+
) : null
|
|
2795
|
+
] })
|
|
2796
|
+
] })
|
|
2797
|
+
},
|
|
2798
|
+
admin.id
|
|
2799
|
+
))
|
|
4228
2800
|
}
|
|
4229
2801
|
);
|
|
4230
2802
|
};
|
|
@@ -4711,7 +3283,7 @@ const PreviewAdminModal = ({ admin, onClose, onCloseAutoFocus, onChanged }) => {
|
|
|
4711
3283
|
] }) });
|
|
4712
3284
|
};
|
|
4713
3285
|
const SETTINGS_USERS_PATH = "/settings/users";
|
|
4714
|
-
const PaginationTargets$
|
|
3286
|
+
const PaginationTargets$2 = styled__default.default.div`
|
|
4715
3287
|
nav a {
|
|
4716
3288
|
min-width: 3.2rem;
|
|
4717
3289
|
}
|
|
@@ -4733,7 +3305,7 @@ const AdminPanelPage = () => {
|
|
|
4733
3305
|
const { isBelowMedium } = useBreakpoint();
|
|
4734
3306
|
const [{ query }, setQuery] = StrapiAdmin.useQueryParams();
|
|
4735
3307
|
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
4736
|
-
const view = parseAdminPanelQuery(query);
|
|
3308
|
+
const view = index.parseAdminPanelQuery(query);
|
|
4737
3309
|
const {
|
|
4738
3310
|
allowedActions: { canRevoke }
|
|
4739
3311
|
} = StrapiAdmin.useRBAC(index.pluginPermissions.adminSessionsRevoke);
|
|
@@ -4777,7 +3349,7 @@ const AdminPanelPage = () => {
|
|
|
4777
3349
|
const pageRef = react.useRef(null);
|
|
4778
3350
|
const captionId = `admin-list-caption-${react.useId().replace(/:/g, "")}`;
|
|
4779
3351
|
const listParams = react.useMemo(
|
|
4780
|
-
() => buildAdminListParams({
|
|
3352
|
+
() => index.buildAdminListParams({
|
|
4781
3353
|
page: view.page,
|
|
4782
3354
|
pageSize: view.pageSize,
|
|
4783
3355
|
filter: view.filter,
|
|
@@ -4800,7 +3372,7 @@ const AdminPanelPage = () => {
|
|
|
4800
3372
|
);
|
|
4801
3373
|
setAdmins(
|
|
4802
3374
|
(Array.isArray(body.data) ? body.data : []).map(
|
|
4803
|
-
(row) => withIdentityPlaceholders(row, placeholder, body.meta?.identity)
|
|
3375
|
+
(row) => index.withIdentityPlaceholders(row, placeholder, body.meta?.identity)
|
|
4804
3376
|
)
|
|
4805
3377
|
);
|
|
4806
3378
|
setMeta(body.meta || null);
|
|
@@ -4839,7 +3411,7 @@ const AdminPanelPage = () => {
|
|
|
4839
3411
|
{ id }
|
|
4840
3412
|
);
|
|
4841
3413
|
setSelected(
|
|
4842
|
-
(current) => current ? withIdentityPlaceholders(body.meta.admin, placeholder, {
|
|
3414
|
+
(current) => current ? index.withIdentityPlaceholders(body.meta.admin, placeholder, {
|
|
4843
3415
|
roles: current.rolesHidden ? false : void 0
|
|
4844
3416
|
}) : current
|
|
4845
3417
|
);
|
|
@@ -4879,7 +3451,7 @@ const AdminPanelPage = () => {
|
|
|
4879
3451
|
setQuery({ filter: filter === "all" ? void 0 : filter, page: "1" });
|
|
4880
3452
|
};
|
|
4881
3453
|
const handleSearch = react.useCallback(
|
|
4882
|
-
(value) => setQuery({ search:
|
|
3454
|
+
(value) => setQuery({ search: dashboardModel.encodeSearchQuery(value), page: "1" }, "push", true),
|
|
4883
3455
|
[setQuery]
|
|
4884
3456
|
);
|
|
4885
3457
|
const handleClearFilters = () => {
|
|
@@ -4920,12 +3492,12 @@ const AdminPanelPage = () => {
|
|
|
4920
3492
|
await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
|
|
4921
3493
|
} catch (err) {
|
|
4922
3494
|
index.logSafeAdminError("adminPanel.signOut", err);
|
|
4923
|
-
const
|
|
3495
|
+
const message = index.getSignOutErrorMessage(err);
|
|
4924
3496
|
toggleNotification({
|
|
4925
|
-
type:
|
|
4926
|
-
message: t(
|
|
3497
|
+
type: dashboardModel.getErrorStatus(err) === 404 ? "warning" : "danger",
|
|
3498
|
+
message: t(message.messageId, message.defaultMessage)
|
|
4927
3499
|
});
|
|
4928
|
-
if (
|
|
3500
|
+
if (dashboardModel.getErrorStatus(err) === 404) {
|
|
4929
3501
|
await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
|
|
4930
3502
|
return;
|
|
4931
3503
|
}
|
|
@@ -4935,9 +3507,9 @@ const AdminPanelPage = () => {
|
|
|
4935
3507
|
const stats = meta?.stats || EMPTY_STATS;
|
|
4936
3508
|
const supported = meta?.supported !== false;
|
|
4937
3509
|
const showData = !loading && Boolean(meta) && supported;
|
|
4938
|
-
const filtersActive = hasAdminFilters(view);
|
|
3510
|
+
const filtersActive = index.hasAdminFilters(view);
|
|
4939
3511
|
const durationText = (seconds) => {
|
|
4940
|
-
const parts = splitDuration(seconds);
|
|
3512
|
+
const parts = index.splitDuration(seconds);
|
|
4941
3513
|
if (!parts) return "";
|
|
4942
3514
|
if (parts.unit === "days")
|
|
4943
3515
|
return t("adminPanel.duration.days", "{count, plural, one {# day} other {# days}}", parts);
|
|
@@ -5161,7 +3733,7 @@ const AdminPanelPage = () => {
|
|
|
5161
3733
|
"aria-label": t("adminPanel.filter.label", "Sign-in status"),
|
|
5162
3734
|
value: view.filter,
|
|
5163
3735
|
onChange: handleFilterChange,
|
|
5164
|
-
children: ADMIN_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelectOption, { value: option, children: [
|
|
3736
|
+
children: index.ADMIN_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelectOption, { value: option, children: [
|
|
5165
3737
|
option === "all" && t("adminPanel.filter.all", "All admins"),
|
|
5166
3738
|
option === "signed-in" && t("adminPanel.filter.signedIn", "Signed in"),
|
|
5167
3739
|
option === "not-signed-in" && t("adminPanel.filter.notSignedIn", "Not signed in")
|
|
@@ -5204,14 +3776,14 @@ const AdminPanelPage = () => {
|
|
|
5204
3776
|
] }),
|
|
5205
3777
|
admins.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5206
3778
|
isBelowMedium ? /* @__PURE__ */ jsxRuntime.jsx(AdminCardList, { ...listProps }) : /* @__PURE__ */ jsxRuntime.jsx(AdminTable, { ...listProps }),
|
|
5207
|
-
/* @__PURE__ */ jsxRuntime.jsx(PaginationTargets$
|
|
3779
|
+
/* @__PURE__ */ jsxRuntime.jsx(PaginationTargets$2, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5208
3780
|
StrapiAdmin.Pagination.Root,
|
|
5209
3781
|
{
|
|
5210
3782
|
pageCount: pagination.pageCount,
|
|
5211
3783
|
total: pagination.total,
|
|
5212
|
-
defaultPageSize: Number(ADMIN_DEFAULT_PAGE_SIZE),
|
|
3784
|
+
defaultPageSize: Number(index.ADMIN_DEFAULT_PAGE_SIZE),
|
|
5213
3785
|
children: [
|
|
5214
|
-
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...ADMIN_PAGE_SIZE_OPTIONS] }),
|
|
3786
|
+
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...index.ADMIN_PAGE_SIZE_OPTIONS] }),
|
|
5215
3787
|
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.Links, {})
|
|
5216
3788
|
]
|
|
5217
3789
|
}
|
|
@@ -5278,7 +3850,7 @@ const AdminPanelPage = () => {
|
|
|
5278
3850
|
}
|
|
5279
3851
|
);
|
|
5280
3852
|
};
|
|
5281
|
-
const PaginationTargets = styled__default.default.div`
|
|
3853
|
+
const PaginationTargets$1 = styled__default.default.div`
|
|
5282
3854
|
nav a {
|
|
5283
3855
|
min-width: 3.2rem;
|
|
5284
3856
|
}
|
|
@@ -5299,10 +3871,10 @@ const useT = () => {
|
|
|
5299
3871
|
const AdminActivityPage = () => {
|
|
5300
3872
|
const t = useT();
|
|
5301
3873
|
const [{ query }, setQuery] = StrapiAdmin.useQueryParams();
|
|
5302
|
-
const view = parseActivityPageQuery(query);
|
|
3874
|
+
const view = index.parseActivityPageQuery(query);
|
|
5303
3875
|
const captionRef = react.useRef(null);
|
|
5304
3876
|
const params = react.useMemo(
|
|
5305
|
-
() => buildSignInParams({
|
|
3877
|
+
() => index.buildSignInParams({
|
|
5306
3878
|
adminId: view.adminId ?? void 0,
|
|
5307
3879
|
event: view.event,
|
|
5308
3880
|
period: view.period,
|
|
@@ -5311,7 +3883,7 @@ const AdminActivityPage = () => {
|
|
|
5311
3883
|
}),
|
|
5312
3884
|
[view.adminId, view.event, view.period, view.page, view.pageSize]
|
|
5313
3885
|
);
|
|
5314
|
-
const list = useEventList({
|
|
3886
|
+
const list = index.useEventList({
|
|
5315
3887
|
path: `/${index.pluginId}/admin-activity/sign-ins`,
|
|
5316
3888
|
params,
|
|
5317
3889
|
logKey: "adminPanel.activity.page"
|
|
@@ -5323,7 +3895,7 @@ const AdminActivityPage = () => {
|
|
|
5323
3895
|
}
|
|
5324
3896
|
}, [list.loading, list.meta, view.page, pagination.pageCount, setQuery]);
|
|
5325
3897
|
const recording = list.meta?.recording;
|
|
5326
|
-
const filtered = hasActivityPageFilters(view);
|
|
3898
|
+
const filtered = index.hasActivityPageFilters(view);
|
|
5327
3899
|
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;
|
|
5328
3900
|
const setFilters = (next) => setQuery({ ...next, page: "1" });
|
|
5329
3901
|
const clearFilters = () => {
|
|
@@ -5361,7 +3933,7 @@ const AdminActivityPage = () => {
|
|
|
5361
3933
|
"aria-label": t("adminPanel.activity.filter.event", "Event"),
|
|
5362
3934
|
value: view.event,
|
|
5363
3935
|
onChange: (next) => setFilters({ event: String(next) === "all" ? void 0 : String(next) }),
|
|
5364
|
-
children: ALL_ADMINS_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: labels[option] }, option))
|
|
3936
|
+
children: index.ALL_ADMINS_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: labels[option] }, option))
|
|
5365
3937
|
}
|
|
5366
3938
|
) }),
|
|
5367
3939
|
/* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5372,11 +3944,10 @@ const AdminActivityPage = () => {
|
|
|
5372
3944
|
}
|
|
5373
3945
|
) }),
|
|
5374
3946
|
view.adminId !== null ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5375
|
-
|
|
3947
|
+
FilterTag,
|
|
5376
3948
|
{
|
|
5377
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, { "aria-hidden": "true" }),
|
|
5378
3949
|
label: t("adminPanel.activity.page.removeAdmin", "Show all admins again"),
|
|
5379
|
-
|
|
3950
|
+
onRemove: () => setFilters({ adminId: void 0 }),
|
|
5380
3951
|
"data-admin-filter": view.adminId,
|
|
5381
3952
|
children: t("adminPanel.activity.page.adminFilter", "Admin: {name}", { name: adminName })
|
|
5382
3953
|
}
|
|
@@ -5413,7 +3984,7 @@ const AdminActivityPage = () => {
|
|
|
5413
3984
|
}
|
|
5414
3985
|
),
|
|
5415
3986
|
renderList: (rows) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5416
|
-
SignInEventTable,
|
|
3987
|
+
index.SignInEventTable,
|
|
5417
3988
|
{
|
|
5418
3989
|
rows,
|
|
5419
3990
|
label: title,
|
|
@@ -5434,20 +4005,187 @@ const AdminActivityPage = () => {
|
|
|
5434
4005
|
) : null
|
|
5435
4006
|
}
|
|
5436
4007
|
),
|
|
5437
|
-
toCsv: buildSignInCsv,
|
|
4008
|
+
toCsv: index.buildSignInCsv,
|
|
5438
4009
|
fileName: "admin-security-activity",
|
|
5439
4010
|
exportLabel: t(
|
|
5440
4011
|
"adminPanel.activity.page.export",
|
|
5441
4012
|
"Export the security activity with these filters as CSV"
|
|
5442
4013
|
),
|
|
4014
|
+
footer: /* @__PURE__ */ jsxRuntime.jsx(PaginationTargets$1, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4015
|
+
StrapiAdmin.Pagination.Root,
|
|
4016
|
+
{
|
|
4017
|
+
pageCount: pagination.pageCount,
|
|
4018
|
+
total: pagination.total,
|
|
4019
|
+
defaultPageSize: index.EVENT_PAGE_SIZE,
|
|
4020
|
+
children: [
|
|
4021
|
+
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...index.ACTIVITY_PAGE_SIZE_OPTIONS] }),
|
|
4022
|
+
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.Links, {})
|
|
4023
|
+
]
|
|
4024
|
+
}
|
|
4025
|
+
) })
|
|
4026
|
+
}
|
|
4027
|
+
)
|
|
4028
|
+
}
|
|
4029
|
+
);
|
|
4030
|
+
};
|
|
4031
|
+
const PaginationTargets = styled__default.default.div`
|
|
4032
|
+
nav a {
|
|
4033
|
+
min-width: 3.2rem;
|
|
4034
|
+
}
|
|
4035
|
+
|
|
4036
|
+
& > div {
|
|
4037
|
+
flex-wrap: wrap;
|
|
4038
|
+
gap: ${({ theme }) => theme.spaces[2]} ${({ theme }) => theme.spaces[4]};
|
|
4039
|
+
}
|
|
4040
|
+
|
|
4041
|
+
& > div > div > span {
|
|
4042
|
+
white-space: nowrap;
|
|
4043
|
+
}
|
|
4044
|
+
`;
|
|
4045
|
+
const UserActivityPage = () => {
|
|
4046
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
4047
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
4048
|
+
const [{ query }, setQuery] = StrapiAdmin.useQueryParams();
|
|
4049
|
+
const view = index.parseUserActivityQuery(query);
|
|
4050
|
+
const captionRef = react.useRef(null);
|
|
4051
|
+
const params = react.useMemo(
|
|
4052
|
+
() => index.buildUserActivityParams({
|
|
4053
|
+
userId: view.userId,
|
|
4054
|
+
event: view.event,
|
|
4055
|
+
period: view.period,
|
|
4056
|
+
page: view.page,
|
|
4057
|
+
pageSize: view.pageSize
|
|
4058
|
+
}),
|
|
4059
|
+
[view.userId, view.event, view.period, view.page, view.pageSize]
|
|
4060
|
+
);
|
|
4061
|
+
const list = index.useEventList({
|
|
4062
|
+
path: index.USER_ACTIVITY_API_PATH,
|
|
4063
|
+
params,
|
|
4064
|
+
logKey: "userActivity.page"
|
|
4065
|
+
});
|
|
4066
|
+
const pagination = list.meta?.pagination || { pageCount: 1, total: 0 };
|
|
4067
|
+
react.useEffect(() => {
|
|
4068
|
+
if (!list.loading && list.meta && view.page > pagination.pageCount) {
|
|
4069
|
+
setQuery({ page: String(pagination.pageCount) }, "push", true);
|
|
4070
|
+
}
|
|
4071
|
+
}, [list.loading, list.meta, view.page, pagination.pageCount, setQuery]);
|
|
4072
|
+
const filtered = index.hasUserActivityFilters(view);
|
|
4073
|
+
const filteredUser = view.userId !== null ? list.rows.find((row) => row.user?.documentId === view.userId) : null;
|
|
4074
|
+
const userName = filteredUser ? index.userText(t, filteredUser) : t("userActivity.page.selectedUser", "Selected user");
|
|
4075
|
+
const setFilters = (next) => setQuery({ ...next, page: "1" });
|
|
4076
|
+
const clearFilters = () => {
|
|
4077
|
+
setQuery({ event: void 0, period: void 0, userId: void 0, page: "1" });
|
|
4078
|
+
captionRef.current?.focus();
|
|
4079
|
+
};
|
|
4080
|
+
const title = t("userActivity.page.title", "Security activity of app users");
|
|
4081
|
+
const recordingOff = list.meta?.recording && list.meta.recording.userSignIns === false;
|
|
4082
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4083
|
+
index.PageShell,
|
|
4084
|
+
{
|
|
4085
|
+
headingId: "magic-sessionmanager-user-activity-title",
|
|
4086
|
+
title,
|
|
4087
|
+
subtitle: t(
|
|
4088
|
+
"userActivity.page.subtitle",
|
|
4089
|
+
"Failed and refused sign-ins, lockouts, session limits, new devices, impossible travel, “This wasn’t me” reports, data exports and impersonations of your app’s users. Newest first."
|
|
4090
|
+
),
|
|
4091
|
+
navigationAction: /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.BackButton, { fallback: SESSION_VIEW_PATHS.users }),
|
|
4092
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4093
|
+
EventList,
|
|
4094
|
+
{
|
|
4095
|
+
list,
|
|
4096
|
+
filters: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4097
|
+
/* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4098
|
+
designSystem.SingleSelect,
|
|
4099
|
+
{
|
|
4100
|
+
size: "S",
|
|
4101
|
+
"aria-label": t("adminPanel.activity.filter.event", "Event"),
|
|
4102
|
+
value: view.event,
|
|
4103
|
+
onChange: (next) => setFilters({ event: String(next) === "all" ? void 0 : String(next) }),
|
|
4104
|
+
children: index.USER_ACTIVITY_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: t(...index.USER_ACTIVITY_FILTER_LABELS[option]) }, option))
|
|
4105
|
+
}
|
|
4106
|
+
) }),
|
|
4107
|
+
/* @__PURE__ */ jsxRuntime.jsx(FilterSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4108
|
+
PeriodSelect,
|
|
4109
|
+
{
|
|
4110
|
+
value: view.period,
|
|
4111
|
+
onChange: (next) => setFilters({ period: next === "30" ? void 0 : next })
|
|
4112
|
+
}
|
|
4113
|
+
) }),
|
|
4114
|
+
view.userId !== null ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4115
|
+
FilterTag,
|
|
4116
|
+
{
|
|
4117
|
+
label: t("userActivity.page.removeUser", "Show all users again"),
|
|
4118
|
+
onRemove: () => setFilters({ userId: void 0 }),
|
|
4119
|
+
"data-user-filter": view.userId,
|
|
4120
|
+
children: t("userActivity.page.userFilter", "User: {name}", { name: userName })
|
|
4121
|
+
}
|
|
4122
|
+
) : null
|
|
4123
|
+
] }),
|
|
4124
|
+
notice: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
4125
|
+
recordingOff ? /* @__PURE__ */ jsxRuntime.jsx(RecordingOff, { to: index.USER_ACTIVITY_SETTINGS_PATH, children: t(
|
|
4126
|
+
"userActivity.page.recordingOff",
|
|
4127
|
+
"Failed and refused sign-ins are not recorded. The other events still are."
|
|
4128
|
+
) }) : null,
|
|
4129
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4130
|
+
designSystem.Typography,
|
|
4131
|
+
{
|
|
4132
|
+
ref: captionRef,
|
|
4133
|
+
tabIndex: -1,
|
|
4134
|
+
variant: "pi",
|
|
4135
|
+
textColor: "neutral600",
|
|
4136
|
+
"aria-live": "polite",
|
|
4137
|
+
"data-activity-caption": "",
|
|
4138
|
+
children: t(
|
|
4139
|
+
"adminPanel.activity.page.caption",
|
|
4140
|
+
"{total, plural, =0 {No events} one {# event} other {# events}}",
|
|
4141
|
+
{ total: pagination.total }
|
|
4142
|
+
)
|
|
4143
|
+
}
|
|
4144
|
+
)
|
|
4145
|
+
] }),
|
|
4146
|
+
empty: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4147
|
+
designSystem.EmptyStateLayout,
|
|
4148
|
+
{
|
|
4149
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
|
|
4150
|
+
content: filtered ? t("adminPanel.activity.page.noResults", "No events match these filters.") : t("userActivity.recent.empty", "No security events of app users yet."),
|
|
4151
|
+
action: filtered ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: clearFilters, children: t("adminPanel.noResults.reset", "Clear filters") }) : null
|
|
4152
|
+
}
|
|
4153
|
+
),
|
|
4154
|
+
renderList: (rows) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4155
|
+
index.UserEventTable,
|
|
4156
|
+
{
|
|
4157
|
+
rows,
|
|
4158
|
+
label: title,
|
|
4159
|
+
busy: list.loading,
|
|
4160
|
+
detailsAction: (row, close) => row.user?.documentId && row.user.documentId !== view.userId ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4161
|
+
designSystem.Button,
|
|
4162
|
+
{
|
|
4163
|
+
variant: "secondary",
|
|
4164
|
+
onClick: () => {
|
|
4165
|
+
close();
|
|
4166
|
+
setFilters({ userId: row.user.documentId });
|
|
4167
|
+
},
|
|
4168
|
+
children: t("userActivity.page.onlyUser", "Show only events of {name}", {
|
|
4169
|
+
name: index.userText(t, row)
|
|
4170
|
+
})
|
|
4171
|
+
}
|
|
4172
|
+
) : null
|
|
4173
|
+
}
|
|
4174
|
+
),
|
|
4175
|
+
toCsv: index.buildUserActivityCsv,
|
|
4176
|
+
fileName: "app-user-security-activity",
|
|
4177
|
+
exportLabel: t(
|
|
4178
|
+
"userActivity.page.export",
|
|
4179
|
+
"Export the security activity of app users with these filters as CSV"
|
|
4180
|
+
),
|
|
5443
4181
|
footer: /* @__PURE__ */ jsxRuntime.jsx(PaginationTargets, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5444
4182
|
StrapiAdmin.Pagination.Root,
|
|
5445
4183
|
{
|
|
5446
4184
|
pageCount: pagination.pageCount,
|
|
5447
4185
|
total: pagination.total,
|
|
5448
|
-
defaultPageSize: EVENT_PAGE_SIZE,
|
|
4186
|
+
defaultPageSize: index.EVENT_PAGE_SIZE,
|
|
5449
4187
|
children: [
|
|
5450
|
-
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...ACTIVITY_PAGE_SIZE_OPTIONS] }),
|
|
4188
|
+
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...index.ACTIVITY_PAGE_SIZE_OPTIONS] }),
|
|
5451
4189
|
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.Links, {})
|
|
5452
4190
|
]
|
|
5453
4191
|
}
|
|
@@ -5474,6 +4212,13 @@ const App = () => {
|
|
|
5474
4212
|
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, {}) }) })
|
|
5475
4213
|
}
|
|
5476
4214
|
),
|
|
4215
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4216
|
+
reactRouterDom.Route,
|
|
4217
|
+
{
|
|
4218
|
+
path: "app-users/activity",
|
|
4219
|
+
element: /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Page.Protect, { permissions: index.pluginPermissions.userActivityRead, children: /* @__PURE__ */ jsxRuntime.jsx(UserActivityPage, {}) })
|
|
4220
|
+
}
|
|
4221
|
+
),
|
|
5477
4222
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) })
|
|
5478
4223
|
] }) });
|
|
5479
4224
|
};
|