strapi-plugin-magic-sessionmanager 4.8.0 → 4.9.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 +90 -5
- package/README.md +379 -641
- package/dist/admin/Analytics-dyJmyxO-.mjs +418 -0
- package/dist/admin/Analytics-lVDnHBYp.js +420 -0
- package/dist/admin/App-CdgiY_Y7.js +1896 -0
- package/dist/admin/App-Cgf_CSjw.mjs +1894 -0
- package/dist/admin/License-1XUfQty5.js +443 -0
- package/dist/admin/License-C4WSYoqY.mjs +443 -0
- package/dist/admin/OnlineUsersWidget-DJC4V1KS.mjs +255 -0
- package/dist/admin/OnlineUsersWidget-DMPtuIpm.js +274 -0
- package/dist/admin/SectionCard-BlWv8CRt.js +54 -0
- package/dist/admin/SectionCard-D51bv4Hi.mjs +55 -0
- package/dist/admin/Settings-0QsyY7fe.js +3570 -0
- package/dist/admin/Settings-DgeuUiMF.mjs +3568 -0
- package/dist/admin/de-BFKoGEVT.js +544 -0
- package/dist/admin/de-j0oZH9Pz.mjs +544 -0
- package/dist/admin/en-UY4Tb5tE.mjs +544 -0
- package/dist/admin/en-s7Ksdkcg.js +544 -0
- package/dist/admin/es-07OGMe_5.js +544 -0
- package/dist/admin/es-DGBcZwQy.mjs +544 -0
- package/dist/admin/fr-B6-DWhGO.mjs +544 -0
- package/dist/admin/fr-ETj_2UBY.js +544 -0
- package/dist/admin/index-Ck19e8qw.mjs +1760 -0
- package/dist/admin/index-D-Nr0TCm.js +1761 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/maskSensitiveValue-BWcSjow7.js +9 -0
- package/dist/admin/maskSensitiveValue-lLRhN_S7.mjs +10 -0
- package/dist/admin/pt-C7PwrQtV.js +544 -0
- package/dist/admin/pt-YMRLm9gx.mjs +544 -0
- package/dist/server/index.js +1092 -463
- package/dist/server/index.mjs +1092 -463
- package/package.json +10 -1
- package/pics/analytics.png +0 -0
- package/pics/dashboard-dark.png +0 -0
- package/pics/dashboard.png +0 -0
- package/pics/dashboardsessionmodal.png +0 -0
- package/pics/mobile-dashboard.png +0 -0
- package/pics/mobile-session.png +0 -0
- package/pics/sessioninfopanel.png +0 -0
- package/pics/settings1.png +0 -0
- package/pics/settings2.png +0 -0
- package/pics/widget.png +0 -0
- package/scripts/geoip-updater.cjs +35 -24
- package/dist/admin/Analytics-CaRlu5ad.js +0 -332
- package/dist/admin/Analytics-THqDbNX0.mjs +0 -330
- package/dist/admin/App-AbZwLHtF.js +0 -1263
- package/dist/admin/App-hSh7guii.mjs +0 -1261
- package/dist/admin/FormField-C8kIT2NE.mjs +0 -59
- package/dist/admin/FormField-b5KBvkrj.js +0 -60
- package/dist/admin/License-BXBVwUVu.mjs +0 -299
- package/dist/admin/License-CABdPwnd.js +0 -301
- package/dist/admin/OnlineUsersWidget-BnWFj9IM.mjs +0 -230
- package/dist/admin/OnlineUsersWidget-CPFAACSb.js +0 -230
- package/dist/admin/PluginPageLayout-BPFMcgrx.mjs +0 -42
- package/dist/admin/PluginPageLayout-DmNzMdqu.js +0 -43
- package/dist/admin/Settings-B4DNdeKx.js +0 -2152
- package/dist/admin/Settings-C4RsJosh.mjs +0 -2150
- package/dist/admin/de-AwIFTd9i.mjs +0 -450
- package/dist/admin/de-D23nmqnl.js +0 -450
- package/dist/admin/en-C5iYQ0mC.js +0 -450
- package/dist/admin/en-D6QEGeRh.mjs +0 -450
- package/dist/admin/es-CIXnsG-p.js +0 -435
- package/dist/admin/es-CnFfVdKw.mjs +0 -435
- package/dist/admin/fr-BglXE-W4.js +0 -435
- package/dist/admin/fr-DefoR7uH.mjs +0 -435
- package/dist/admin/index-BFVITQ-o.mjs +0 -624
- package/dist/admin/index-DlMm-NyK.js +0 -625
- package/dist/admin/maskSensitiveValue-1uGWmrfG.mjs +0 -20
- package/dist/admin/maskSensitiveValue-B9vhxPad.js +0 -19
- package/dist/admin/pt-J5sf7jiY.js +0 -435
- package/dist/admin/pt-TODwvNQA.mjs +0 -435
|
@@ -0,0 +1,1896 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const reactIntl = require("react-intl");
|
|
6
|
+
const reactRouterDom = require("react-router-dom");
|
|
7
|
+
const StrapiAdmin = require("@strapi/strapi/admin");
|
|
8
|
+
const designSystem = require("@strapi/design-system");
|
|
9
|
+
const icons = require("@strapi/icons");
|
|
10
|
+
const symbols = require("@strapi/icons/symbols");
|
|
11
|
+
const styled = require("styled-components");
|
|
12
|
+
const index = require("./index-D-Nr0TCm.js");
|
|
13
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
14
|
+
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
15
|
+
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
16
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
17
|
+
const key = reason || index.getSessionEndReason(session);
|
|
18
|
+
if (!key) return null;
|
|
19
|
+
const presentation = index.getEndReasonPresentation(key);
|
|
20
|
+
const translate = (descriptor) => formatMessage({
|
|
21
|
+
id: index.getTranslation(descriptor.messageId),
|
|
22
|
+
defaultMessage: descriptor.defaultMessage
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant, textColor, "data-end-reason": presentation.reason, children: translate(presentation) });
|
|
25
|
+
};
|
|
26
|
+
function paginateSessions(sessions = [], currentPage = 1, pageSize = 25) {
|
|
27
|
+
const items = Array.isArray(sessions) ? sessions : [];
|
|
28
|
+
const requestedSize = Number(pageSize);
|
|
29
|
+
const normalizedSize = Number.isFinite(requestedSize) && requestedSize > 0 ? Math.floor(requestedSize) : 1;
|
|
30
|
+
const total = items.length;
|
|
31
|
+
const pageCount = Math.max(1, Math.ceil(total / normalizedSize));
|
|
32
|
+
const requestedPage = Number(currentPage);
|
|
33
|
+
const page = Math.min(
|
|
34
|
+
pageCount,
|
|
35
|
+
Math.max(1, Number.isFinite(requestedPage) ? Math.floor(requestedPage) : 1)
|
|
36
|
+
);
|
|
37
|
+
const offset = (page - 1) * normalizedSize;
|
|
38
|
+
return {
|
|
39
|
+
items: items.slice(offset, offset + normalizedSize),
|
|
40
|
+
page,
|
|
41
|
+
pageCount,
|
|
42
|
+
startIndex: total === 0 ? 0 : offset + 1,
|
|
43
|
+
endIndex: Math.min(total, offset + normalizedSize),
|
|
44
|
+
total
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const CSV_HEADERS = Object.freeze([
|
|
48
|
+
"ID",
|
|
49
|
+
"Status",
|
|
50
|
+
"User Email",
|
|
51
|
+
"Username",
|
|
52
|
+
"Device",
|
|
53
|
+
"Browser",
|
|
54
|
+
"OS",
|
|
55
|
+
"IP Address",
|
|
56
|
+
"Login Time",
|
|
57
|
+
"Last Active",
|
|
58
|
+
"Logout Time",
|
|
59
|
+
"Minutes Idle",
|
|
60
|
+
"End Reason"
|
|
61
|
+
]);
|
|
62
|
+
const escapeCsvValue = (value) => `"${String(value ?? "").replace(/"/g, '""')}"`;
|
|
63
|
+
function toIsoTimestamp(value) {
|
|
64
|
+
if (value === null || value === void 0 || value === "") return "";
|
|
65
|
+
const date = value instanceof Date ? value : new Date(
|
|
66
|
+
/** @type {any} */
|
|
67
|
+
value
|
|
68
|
+
);
|
|
69
|
+
return Number.isFinite(date.getTime()) ? date.toISOString() : "";
|
|
70
|
+
}
|
|
71
|
+
function buildSessionCsv(sessions, {
|
|
72
|
+
unavailableValue,
|
|
73
|
+
getDeviceInfo,
|
|
74
|
+
getSessionStatus,
|
|
75
|
+
getSessionEndReason = index.getSessionEndReason
|
|
76
|
+
}) {
|
|
77
|
+
const rows = Array.isArray(sessions) ? sessions : [];
|
|
78
|
+
const csvRows = rows.map((session) => {
|
|
79
|
+
const deviceInfo = getDeviceInfo(session, unavailableValue);
|
|
80
|
+
const minutesIdle = Number.isFinite(session.minutesSinceActive) ? session.minutesSinceActive : "";
|
|
81
|
+
return [
|
|
82
|
+
session.id,
|
|
83
|
+
getSessionStatus(session),
|
|
84
|
+
session.user?.email || "",
|
|
85
|
+
session.user?.username || "",
|
|
86
|
+
deviceInfo.device,
|
|
87
|
+
deviceInfo.browser,
|
|
88
|
+
deviceInfo.os,
|
|
89
|
+
session.ipAddress || unavailableValue,
|
|
90
|
+
toIsoTimestamp(session.loginTime),
|
|
91
|
+
toIsoTimestamp(session.lastActive || session.loginTime),
|
|
92
|
+
toIsoTimestamp(session.logoutTime),
|
|
93
|
+
minutesIdle,
|
|
94
|
+
getSessionEndReason(session) || ""
|
|
95
|
+
];
|
|
96
|
+
});
|
|
97
|
+
return [
|
|
98
|
+
CSV_HEADERS.map(escapeCsvValue).join(","),
|
|
99
|
+
...csvRows.map((row) => row.map(escapeCsvValue).join(","))
|
|
100
|
+
].join("\n");
|
|
101
|
+
}
|
|
102
|
+
function buildSessionJson(sessions, {
|
|
103
|
+
filterStatus,
|
|
104
|
+
totalSessions,
|
|
105
|
+
exportedAt,
|
|
106
|
+
unavailableValue,
|
|
107
|
+
getDeviceInfo,
|
|
108
|
+
getSessionStatus,
|
|
109
|
+
getSessionEndReason = index.getSessionEndReason,
|
|
110
|
+
truncated = false
|
|
111
|
+
}) {
|
|
112
|
+
const rows = Array.isArray(sessions) ? sessions : [];
|
|
113
|
+
const exportData = {
|
|
114
|
+
exportedAt,
|
|
115
|
+
filter: filterStatus,
|
|
116
|
+
totalSessions,
|
|
117
|
+
exportedSessions: rows.length,
|
|
118
|
+
...truncated ? { truncated: true } : {},
|
|
119
|
+
sessions: rows.map((session) => {
|
|
120
|
+
const deviceInfo = getDeviceInfo(session, unavailableValue);
|
|
121
|
+
return {
|
|
122
|
+
id: session.id,
|
|
123
|
+
status: getSessionStatus(session),
|
|
124
|
+
endReason: getSessionEndReason(session) || null,
|
|
125
|
+
user: {
|
|
126
|
+
id: session.user?.documentId || session.user?.id,
|
|
127
|
+
email: session.user?.email,
|
|
128
|
+
username: session.user?.username
|
|
129
|
+
},
|
|
130
|
+
device: {
|
|
131
|
+
type: deviceInfo.device,
|
|
132
|
+
browser: deviceInfo.browser,
|
|
133
|
+
browserVersion: deviceInfo.browserVersion,
|
|
134
|
+
os: deviceInfo.os
|
|
135
|
+
},
|
|
136
|
+
ipAddress: session.ipAddress || unavailableValue,
|
|
137
|
+
loginTime: session.loginTime,
|
|
138
|
+
lastActive: session.lastActive,
|
|
139
|
+
logoutTime: session.logoutTime,
|
|
140
|
+
minutesSinceActive: session.minutesSinceActive,
|
|
141
|
+
isActive: session.isActive,
|
|
142
|
+
isTrulyActive: session.isTrulyActive
|
|
143
|
+
};
|
|
144
|
+
})
|
|
145
|
+
};
|
|
146
|
+
return JSON.stringify(exportData, null, 2);
|
|
147
|
+
}
|
|
148
|
+
const DS_BREAKPOINTS = Object.freeze({
|
|
149
|
+
small: "@media(min-width: 520px)",
|
|
150
|
+
medium: "@media(min-width: 768px)",
|
|
151
|
+
large: "@media(min-width: 1080px)"
|
|
152
|
+
});
|
|
153
|
+
const BREAKPOINT_ORDER = Object.freeze(["initial", "small", "medium", "large"]);
|
|
154
|
+
function mediaQueryFromBreakpoint(breakpoint) {
|
|
155
|
+
if (typeof breakpoint !== "string") return "";
|
|
156
|
+
const query = breakpoint.replace(/^\s*@media\s*/i, "").trim();
|
|
157
|
+
return /^\(.*\)$/.test(query) ? query : "";
|
|
158
|
+
}
|
|
159
|
+
function getBreakpointQueries(theme) {
|
|
160
|
+
const source = theme?.breakpoints || {};
|
|
161
|
+
return {
|
|
162
|
+
small: mediaQueryFromBreakpoint(source.small) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.small),
|
|
163
|
+
medium: mediaQueryFromBreakpoint(source.medium) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.medium),
|
|
164
|
+
large: mediaQueryFromBreakpoint(source.large) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.large)
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function resolveBreakpoint(matches = {}) {
|
|
168
|
+
if (matches.large) return "large";
|
|
169
|
+
if (matches.medium) return "medium";
|
|
170
|
+
if (matches.small) return "small";
|
|
171
|
+
return "initial";
|
|
172
|
+
}
|
|
173
|
+
function isBelowBreakpoint(current, target) {
|
|
174
|
+
return BREAKPOINT_ORDER.indexOf(current) < BREAKPOINT_ORDER.indexOf(target);
|
|
175
|
+
}
|
|
176
|
+
const readMatches = (queries) => {
|
|
177
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
178
|
+
return { small: true, medium: true, large: true };
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
small: window.matchMedia(queries.small).matches,
|
|
182
|
+
medium: window.matchMedia(queries.medium).matches,
|
|
183
|
+
large: window.matchMedia(queries.large).matches
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
function useBreakpoint() {
|
|
187
|
+
const theme = styled.useTheme();
|
|
188
|
+
const queries = react.useMemo(() => getBreakpointQueries(theme), [theme]);
|
|
189
|
+
const [matches, setMatches] = react.useState(() => readMatches(queries));
|
|
190
|
+
react.useEffect(() => {
|
|
191
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return void 0;
|
|
192
|
+
const lists = ["small", "medium", "large"].map((name) => window.matchMedia(queries[name]));
|
|
193
|
+
const update = () => setMatches(readMatches(queries));
|
|
194
|
+
update();
|
|
195
|
+
lists.forEach((list) => list.addEventListener?.("change", update));
|
|
196
|
+
return () => lists.forEach((list) => list.removeEventListener?.("change", update));
|
|
197
|
+
}, [queries]);
|
|
198
|
+
const breakpoint = resolveBreakpoint(matches);
|
|
199
|
+
return {
|
|
200
|
+
breakpoint,
|
|
201
|
+
isBelowSmall: isBelowBreakpoint(breakpoint, "small"),
|
|
202
|
+
isBelowMedium: isBelowBreakpoint(breakpoint, "medium"),
|
|
203
|
+
isBelowLarge: isBelowBreakpoint(breakpoint, "large")
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function useElementWidth() {
|
|
207
|
+
const [width, setWidth] = react.useState(0);
|
|
208
|
+
const observerRef = react.useRef(null);
|
|
209
|
+
const ref = react.useCallback((node) => {
|
|
210
|
+
observerRef.current?.disconnect();
|
|
211
|
+
observerRef.current = null;
|
|
212
|
+
if (!node || typeof ResizeObserver === "undefined") return;
|
|
213
|
+
const observer = new ResizeObserver((entries) => {
|
|
214
|
+
const next = Math.round(entries[0]?.contentRect?.width || 0);
|
|
215
|
+
setWidth((previous) => previous === next ? previous : next);
|
|
216
|
+
});
|
|
217
|
+
observer.observe(node);
|
|
218
|
+
observerRef.current = observer;
|
|
219
|
+
}, []);
|
|
220
|
+
react.useEffect(() => () => observerRef.current?.disconnect(), []);
|
|
221
|
+
return [ref, width];
|
|
222
|
+
}
|
|
223
|
+
const RISK_LEVEL_MESSAGES = Object.freeze({
|
|
224
|
+
none: Object.freeze({ messageId: "modal.security.risk.none", defaultMessage: "None" }),
|
|
225
|
+
low: Object.freeze({ messageId: "modal.security.risk.low", defaultMessage: "Low" }),
|
|
226
|
+
medium: Object.freeze({ messageId: "modal.security.risk.medium", defaultMessage: "Medium" }),
|
|
227
|
+
mediumHigh: Object.freeze({
|
|
228
|
+
messageId: "modal.security.risk.mediumHigh",
|
|
229
|
+
defaultMessage: "Medium-high"
|
|
230
|
+
}),
|
|
231
|
+
high: Object.freeze({ messageId: "modal.security.risk.high", defaultMessage: "High" })
|
|
232
|
+
});
|
|
233
|
+
const RISK_ALIASES = Object.freeze({
|
|
234
|
+
none: "none",
|
|
235
|
+
low: "low",
|
|
236
|
+
medium: "medium",
|
|
237
|
+
"medium high": "mediumHigh",
|
|
238
|
+
mediumhigh: "mediumHigh",
|
|
239
|
+
high: "high"
|
|
240
|
+
});
|
|
241
|
+
function normalizeRiskLevel(value) {
|
|
242
|
+
if (typeof value !== "string") return "";
|
|
243
|
+
const key = value.trim().toLowerCase().replace(/[\s_-]+/g, " ");
|
|
244
|
+
return RISK_ALIASES[key] || RISK_ALIASES[key.replace(/ /g, "")] || "";
|
|
245
|
+
}
|
|
246
|
+
const booleanOrNull = (value) => typeof value === "boolean" ? value : null;
|
|
247
|
+
function normalizeGeoData(geo, fallback = {}) {
|
|
248
|
+
if (!geo || typeof geo !== "object") return null;
|
|
249
|
+
const country = index.presentText(geo.country) || index.presentText(geo.country_code);
|
|
250
|
+
const city = index.presentText(geo.city);
|
|
251
|
+
const timezone = index.presentText(geo.timezone);
|
|
252
|
+
if (!country && !city && !timezone) return null;
|
|
253
|
+
const rawScore = typeof geo.securityScore === "number" ? geo.securityScore : fallback?.securityScore;
|
|
254
|
+
const securityScore = typeof rawScore === "number" && Number.isFinite(rawScore) ? rawScore : null;
|
|
255
|
+
return {
|
|
256
|
+
country,
|
|
257
|
+
city,
|
|
258
|
+
timezone,
|
|
259
|
+
securityScore,
|
|
260
|
+
riskLevel: normalizeRiskLevel(geo.riskLevel),
|
|
261
|
+
isVpn: booleanOrNull(geo.isVpn),
|
|
262
|
+
isProxy: booleanOrNull(geo.isProxy)
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function getStoredGeoData(session) {
|
|
266
|
+
let geoLocation = session?.geoLocation;
|
|
267
|
+
if (typeof geoLocation === "string") {
|
|
268
|
+
try {
|
|
269
|
+
geoLocation = JSON.parse(geoLocation);
|
|
270
|
+
} catch {
|
|
271
|
+
geoLocation = null;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (!geoLocation || typeof geoLocation !== "object") return null;
|
|
275
|
+
const {
|
|
276
|
+
securityScore: _ignored,
|
|
277
|
+
riskLevel: _ignoredLevel,
|
|
278
|
+
isVpn: _ignoredVpn,
|
|
279
|
+
isProxy: _ignoredProxy,
|
|
280
|
+
...facts
|
|
281
|
+
} = geoLocation;
|
|
282
|
+
return normalizeGeoData(facts, { securityScore: session?.securityScore });
|
|
283
|
+
}
|
|
284
|
+
function interpretLookupResult(payload) {
|
|
285
|
+
const data = (
|
|
286
|
+
/** @type {any} */
|
|
287
|
+
payload?.data
|
|
288
|
+
);
|
|
289
|
+
if (!data || typeof data !== "object") return { status: "failed", geo: null };
|
|
290
|
+
if (data._status === "disabled") return { status: "disabled", geo: null };
|
|
291
|
+
if (data._status && data._status !== "ok") return { status: "failed", geo: null };
|
|
292
|
+
const geo = normalizeGeoData(data);
|
|
293
|
+
return geo ? { status: "ok", geo } : { status: "failed", geo: null };
|
|
294
|
+
}
|
|
295
|
+
const PAGE_SIZE_OPTIONS = Object.freeze(["10", "25", "50", "100"]);
|
|
296
|
+
const DEFAULT_PAGE_SIZE = "25";
|
|
297
|
+
const DASHBOARD_TABLE_COLUMNS = 7;
|
|
298
|
+
const DASHBOARD_COMPACT_TABLE_COLUMNS = 5;
|
|
299
|
+
const AUTO_REFRESH_INTERVAL_MS = 10 * 60 * 1e3;
|
|
300
|
+
const HOW_IT_WORKS_STORAGE_KEY = "magic-sessionmanager.dashboard.howSessionsWork";
|
|
301
|
+
const USER_EDIT_PATH = "/content-manager/collection-types/plugin::users-permissions.user/";
|
|
302
|
+
const readQueryText = (value) => {
|
|
303
|
+
if (typeof value !== "string") return "";
|
|
304
|
+
try {
|
|
305
|
+
return decodeURIComponent(value).trim();
|
|
306
|
+
} catch {
|
|
307
|
+
return value.trim();
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
function parseDashboardQuery(query = {}) {
|
|
311
|
+
const source = query || {};
|
|
312
|
+
const page = Number.parseInt(String(source.page ?? "1"), 10);
|
|
313
|
+
const pageSize = PAGE_SIZE_OPTIONS.includes(String(source.pageSize)) ? String(source.pageSize) : DEFAULT_PAGE_SIZE;
|
|
314
|
+
const status = index.isSessionFilter(source.status) ? (
|
|
315
|
+
/** @type {string} */
|
|
316
|
+
source.status
|
|
317
|
+
) : index.DEFAULT_SESSION_FILTER;
|
|
318
|
+
const reason = status === "ended" && index.isEndReasonFilter(source.reason) ? (
|
|
319
|
+
/** @type {string} */
|
|
320
|
+
source.reason
|
|
321
|
+
) : index.DEFAULT_END_REASON_FILTER;
|
|
322
|
+
const search = readQueryText(source.search) || readQueryText(source._q);
|
|
323
|
+
return { page: Number.isFinite(page) && page >= 1 ? page : 1, pageSize, status, reason, search };
|
|
324
|
+
}
|
|
325
|
+
function encodeSearchQuery(value) {
|
|
326
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
327
|
+
return text ? encodeURIComponent(text) : void 0;
|
|
328
|
+
}
|
|
329
|
+
function hasActiveFilters(state) {
|
|
330
|
+
if (!state) return false;
|
|
331
|
+
return state.status !== index.DEFAULT_SESSION_FILTER || Boolean(state.reason) && state.reason !== index.DEFAULT_END_REASON_FILTER || Boolean(state.search);
|
|
332
|
+
}
|
|
333
|
+
const getUserKey = (session) => {
|
|
334
|
+
const user = session?.user;
|
|
335
|
+
return index.presentText(user?.documentId) || index.presentText(user?.id) || index.presentText(user?.email);
|
|
336
|
+
};
|
|
337
|
+
function getSessionStats(sessions) {
|
|
338
|
+
const rows = Array.isArray(sessions) ? sessions : [];
|
|
339
|
+
const stats = {
|
|
340
|
+
active: 0,
|
|
341
|
+
idle: 0,
|
|
342
|
+
ended: 0,
|
|
343
|
+
total: rows.length,
|
|
344
|
+
usersOnline: 0,
|
|
345
|
+
loggedOut: 0,
|
|
346
|
+
timedOut: 0,
|
|
347
|
+
otherReasons: 0
|
|
348
|
+
};
|
|
349
|
+
const onlineUsers = /* @__PURE__ */ new Set();
|
|
350
|
+
for (const session of rows) {
|
|
351
|
+
const state = index.getSessionState(session);
|
|
352
|
+
stats[state] += 1;
|
|
353
|
+
if (state === "active") {
|
|
354
|
+
const key = getUserKey(session);
|
|
355
|
+
if (key) onlineUsers.add(key);
|
|
356
|
+
} else if (state === "ended") {
|
|
357
|
+
const reason = index.getSessionEndReason(session);
|
|
358
|
+
if (reason === "logout") stats.loggedOut += 1;
|
|
359
|
+
else if (reason === "idle") stats.timedOut += 1;
|
|
360
|
+
else stats.otherReasons += 1;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
stats.usersOnline = onlineUsers.size;
|
|
364
|
+
return stats;
|
|
365
|
+
}
|
|
366
|
+
function getSessionUserLabels(session) {
|
|
367
|
+
const username = index.presentText(session?.user?.username);
|
|
368
|
+
const email = index.presentText(session?.user?.email);
|
|
369
|
+
const primary = username || email;
|
|
370
|
+
return {
|
|
371
|
+
primary,
|
|
372
|
+
secondary: username && email ? email : "",
|
|
373
|
+
accessible: primary || index.presentText(session?.id)
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function getUserEditPath(session) {
|
|
377
|
+
const documentId = index.presentText(session?.user?.documentId);
|
|
378
|
+
return documentId ? `${USER_EDIT_PATH}${encodeURIComponent(documentId)}` : null;
|
|
379
|
+
}
|
|
380
|
+
function getExportDeviceInfo(session, unavailableValue = "") {
|
|
381
|
+
const device = index.getDevicePresentation(session);
|
|
382
|
+
return {
|
|
383
|
+
device: device.deviceType || unavailableValue,
|
|
384
|
+
browser: device.browser || unavailableValue,
|
|
385
|
+
browserVersion: device.browserVersion || "",
|
|
386
|
+
os: device.os || unavailableValue
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
function readDisclosureOpen(storage) {
|
|
390
|
+
try {
|
|
391
|
+
return storage?.getItem(HOW_IT_WORKS_STORAGE_KEY) === "open";
|
|
392
|
+
} catch {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function writeDisclosureOpen(storage, open) {
|
|
397
|
+
try {
|
|
398
|
+
storage?.setItem(HOW_IT_WORKS_STORAGE_KEY, open ? "open" : "closed");
|
|
399
|
+
} catch {
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function getBrowserStorage() {
|
|
403
|
+
try {
|
|
404
|
+
return typeof window !== "undefined" ? window.localStorage : null;
|
|
405
|
+
} catch {
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
function shouldIsolateActionKey(key, fromInsideGroup) {
|
|
410
|
+
if (!fromInsideGroup) return true;
|
|
411
|
+
return key === "Enter" || key === " " || key === "Spacebar";
|
|
412
|
+
}
|
|
413
|
+
const FULL_TABLE_MIN_WIDTH = 1200;
|
|
414
|
+
function shouldUseCompactTable(listWidth, isBelowLarge) {
|
|
415
|
+
if (isBelowLarge) return true;
|
|
416
|
+
if (!Number.isFinite(listWidth) || listWidth <= 0) return false;
|
|
417
|
+
return listWidth < FULL_TABLE_MIN_WIDTH;
|
|
418
|
+
}
|
|
419
|
+
function shouldRedispatchEscape(key, fromInsideGroup) {
|
|
420
|
+
return !fromInsideGroup && key === "Escape";
|
|
421
|
+
}
|
|
422
|
+
function pickFocusSessionId(previousIds, currentIds, sessionId) {
|
|
423
|
+
const current = Array.isArray(currentIds) ? currentIds.map(String) : [];
|
|
424
|
+
if (current.length === 0) return null;
|
|
425
|
+
const target = String(sessionId);
|
|
426
|
+
if (current.includes(target)) return target;
|
|
427
|
+
const previous = Array.isArray(previousIds) ? previousIds.map(String) : [];
|
|
428
|
+
const index2 = previous.indexOf(target);
|
|
429
|
+
if (index2 >= 0) {
|
|
430
|
+
for (let next = index2 + 1; next < previous.length; next += 1) {
|
|
431
|
+
if (current.includes(previous[next])) return previous[next];
|
|
432
|
+
}
|
|
433
|
+
for (let before = index2 - 1; before >= 0; before -= 1) {
|
|
434
|
+
if (current.includes(previous[before])) return previous[before];
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return current[0];
|
|
438
|
+
}
|
|
439
|
+
function getErrorStatus(error) {
|
|
440
|
+
const err = (
|
|
441
|
+
/** @type {any} */
|
|
442
|
+
error
|
|
443
|
+
);
|
|
444
|
+
const status = err?.status ?? err?.response?.status;
|
|
445
|
+
return typeof status === "number" ? status : null;
|
|
446
|
+
}
|
|
447
|
+
const TargetLink = styled__default.default(designSystem.Link)`
|
|
448
|
+
min-height: 3.2rem;
|
|
449
|
+
display: inline-flex;
|
|
450
|
+
align-items: center;
|
|
451
|
+
|
|
452
|
+
${({ theme }) => theme.breakpoints.medium} {
|
|
453
|
+
min-height: 2.4rem;
|
|
454
|
+
}
|
|
455
|
+
`;
|
|
456
|
+
const MONOSPACE$2 = { fontFamily: "monospace", overflowWrap: "anywhere", minWidth: 0 };
|
|
457
|
+
const IDLE_LOOKUP = { status: "idle", geo: null };
|
|
458
|
+
const DetailSection = ({ title, children }) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "section", direction: "column", alignItems: "stretch", gap: 3, minWidth: 0, children: [
|
|
459
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h3", textColor: "neutral800", children: title }),
|
|
460
|
+
children
|
|
461
|
+
] });
|
|
462
|
+
const getMinutesSinceActive = (session, now) => {
|
|
463
|
+
const fromServer = Number(session.minutesSinceActive);
|
|
464
|
+
if (session.minutesSinceActive !== null && session.minutesSinceActive !== void 0 && Number.isFinite(fromServer)) {
|
|
465
|
+
return fromServer;
|
|
466
|
+
}
|
|
467
|
+
const last = index.toValidDate(session.lastActive || session.loginTime);
|
|
468
|
+
return last ? Math.max(0, Math.floor((now - last.getTime()) / 6e4)) : null;
|
|
469
|
+
};
|
|
470
|
+
const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSession }) => {
|
|
471
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
472
|
+
const { get } = StrapiAdmin.useFetchClient();
|
|
473
|
+
const { toggleNotification } = StrapiAdmin.useNotification();
|
|
474
|
+
const { copy } = StrapiAdmin.useClipboard();
|
|
475
|
+
const { formatDate, formatRelativeTime, deviceTypeLabel, deviceSummary } = index.useSessionFormatters();
|
|
476
|
+
const [lookupState, setLookupState] = react.useState({ sessionId: null, ...IDLE_LOOKUP });
|
|
477
|
+
const lookup = lookupState.sessionId === session?.id ? lookupState : IDLE_LOOKUP;
|
|
478
|
+
const lookupRequest = react.useRef(0);
|
|
479
|
+
const endedReasonId = `session-ended-reason-${react.useId().replace(/:/g, "")}`;
|
|
480
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
481
|
+
react.useEffect(() => {
|
|
482
|
+
lookupRequest.current += 1;
|
|
483
|
+
}, [session?.id]);
|
|
484
|
+
if (!session) return null;
|
|
485
|
+
const status = index.getSessionStatus(session);
|
|
486
|
+
const device = index.getDevicePresentation(session);
|
|
487
|
+
const canEnd = session.isActive === true;
|
|
488
|
+
const native = index.isNativeOnlySession(session);
|
|
489
|
+
const userAgent = index.presentText(session.userAgent);
|
|
490
|
+
const sessionId = index.presentText(session.id);
|
|
491
|
+
const ipAddress = index.presentText(session.ipAddress);
|
|
492
|
+
const user = getSessionUserLabels(session);
|
|
493
|
+
const userEditPath = getUserEditPath(session);
|
|
494
|
+
const storedGeo = getStoredGeoData(session);
|
|
495
|
+
const liveGeo = lookup.status === "ok" ? lookup.geo : null;
|
|
496
|
+
const geo = liveGeo || storedGeo;
|
|
497
|
+
const minutes = getMinutesSinceActive(session, now);
|
|
498
|
+
const reason = index.getSessionEndReasonPresentation(session);
|
|
499
|
+
const translate = (descriptor, values) => formatMessage(
|
|
500
|
+
{ id: index.getTranslation(descriptor.messageId), defaultMessage: descriptor.defaultMessage },
|
|
501
|
+
values
|
|
502
|
+
);
|
|
503
|
+
const formatTimestamp = (value) => index.toValidDate(value) ? formatDate(value) : null;
|
|
504
|
+
const handleLookup = async () => {
|
|
505
|
+
if (!ipAddress) return;
|
|
506
|
+
const requestId = lookupRequest.current + 1;
|
|
507
|
+
lookupRequest.current = requestId;
|
|
508
|
+
const setLookup = (next) => setLookupState({ ...next, sessionId: session.id });
|
|
509
|
+
setLookup({ status: "loading", geo: null });
|
|
510
|
+
try {
|
|
511
|
+
const { data } = await get(`/${index.pluginId}/geolocation/${encodeURIComponent(ipAddress)}`);
|
|
512
|
+
if (requestId !== lookupRequest.current) return;
|
|
513
|
+
setLookup(interpretLookupResult(data));
|
|
514
|
+
} catch (err) {
|
|
515
|
+
index.logSafeAdminError("sessionDetails.geolocation", err);
|
|
516
|
+
if (requestId === lookupRequest.current) setLookup({ status: "failed", geo: null });
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
const handleTerminate = async () => {
|
|
520
|
+
await onEndSession(session);
|
|
521
|
+
onClose();
|
|
522
|
+
};
|
|
523
|
+
const handleCopyId = async () => {
|
|
524
|
+
const copied = sessionId ? await copy(sessionId) : false;
|
|
525
|
+
toggleNotification({
|
|
526
|
+
type: copied ? "success" : "danger",
|
|
527
|
+
message: copied ? t("modal.copy.success", "Record ID copied.") : t("modal.copy.error", "The record ID could not be copied.")
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
const stateSentence = () => {
|
|
531
|
+
if (status === "active") {
|
|
532
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: t("modal.state.active", "Active. Last request {time}.", {
|
|
533
|
+
time: formatRelativeTime(session.lastActive || session.loginTime)
|
|
534
|
+
}) });
|
|
535
|
+
}
|
|
536
|
+
if (status === "idle") {
|
|
537
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "warning", closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", tag: "span", children: t(
|
|
538
|
+
"modal.state.idle",
|
|
539
|
+
"Not used for {minutes} min. It ends on its next request or at the next idle check.",
|
|
540
|
+
{
|
|
541
|
+
minutes: minutes ?? 0
|
|
542
|
+
}
|
|
543
|
+
) }) });
|
|
544
|
+
}
|
|
545
|
+
const endedAt = formatTimestamp(session.logoutTime);
|
|
546
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
|
547
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: endedAt ? t("modal.state.ended", "Ended {endedAt} · {reason}.", {
|
|
548
|
+
endedAt,
|
|
549
|
+
reason: translate(reason)
|
|
550
|
+
}) : t("modal.state.endedNoTime", "Ended · {reason}.", { reason: translate(reason) }) }),
|
|
551
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: translate(reason.description) })
|
|
552
|
+
] });
|
|
553
|
+
};
|
|
554
|
+
const yesNoText = (value) => typeof value === "boolean" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: value ? t("common.yes", "Yes") : t("common.no", "No") }) : void 0;
|
|
555
|
+
const notStoredForPast = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: t("modal.security.notStored", "Not stored for past sign-ins") });
|
|
556
|
+
const score = typeof geo?.securityScore === "number" ? geo.securityScore : typeof session.securityScore === "number" && Number.isFinite(session.securityScore) ? session.securityScore : null;
|
|
557
|
+
const riskMessage = liveGeo ? RISK_LEVEL_MESSAGES[liveGeo.riskLevel] : null;
|
|
558
|
+
const locationItems = [
|
|
559
|
+
{ id: "country", label: t("modal.security.country", "Country"), value: geo?.country },
|
|
560
|
+
{ id: "city", label: t("modal.security.city", "City"), value: geo?.city },
|
|
561
|
+
{ id: "timezone", label: t("modal.security.timezone", "Time zone"), value: geo?.timezone },
|
|
562
|
+
{
|
|
563
|
+
id: "score",
|
|
564
|
+
label: t("modal.security.score", "Security score"),
|
|
565
|
+
value: score === null ? null : t("modal.security.scoreValue", "{score}/100", { score })
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
id: "vpn",
|
|
569
|
+
label: t("modal.security.vpn", "VPN"),
|
|
570
|
+
render: liveGeo ? yesNoText(liveGeo.isVpn) : storedGeo ? notStoredForPast : void 0
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
id: "proxy",
|
|
574
|
+
label: t("modal.security.proxy", "Proxy"),
|
|
575
|
+
render: liveGeo ? yesNoText(liveGeo.isProxy) : storedGeo ? notStoredForPast : void 0
|
|
576
|
+
},
|
|
577
|
+
riskMessage ? {
|
|
578
|
+
id: "risk",
|
|
579
|
+
label: t("modal.security.riskLevel", "Risk level"),
|
|
580
|
+
value: translate(riskMessage),
|
|
581
|
+
fullWidth: true
|
|
582
|
+
} : null
|
|
583
|
+
];
|
|
584
|
+
const canLookUp = !geo && Boolean(ipAddress) && !native;
|
|
585
|
+
const hasLocationData = Boolean(geo) || score !== null || !canLookUp;
|
|
586
|
+
const lookupControls = canLookUp ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
|
|
587
|
+
lookup.status === "loading" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, role: "status", "aria-live": "polite", children: t("modal.security.loading", "Looking up the location") }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", size: "S", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Earth, {}), onClick: handleLookup, children: t("modal.security.lookup", "Look up location") }),
|
|
588
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
589
|
+
"modal.security.lookupHint",
|
|
590
|
+
"Sends the IP address to the configured lookup service, which can be ipapi.co."
|
|
591
|
+
) }),
|
|
592
|
+
lookup.status === "disabled" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral800", role: "status", children: t("modal.security.lookupOff", "IP location lookup is off.") }) : null,
|
|
593
|
+
lookup.status === "failed" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", role: "status", children: t("modal.security.lookupFailed", "The location could not be determined.") }) : null
|
|
594
|
+
] }) : null;
|
|
595
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: true, onOpenChange: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { onCloseAutoFocus, "aria-describedby": void 0, children: [
|
|
596
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "center", wrap: "wrap", minWidth: 0, children: [
|
|
597
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { padding: 2, background: "neutral100", hasRadius: true, shrink: 0, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(index.DeviceIcon, { icon: device.icon }) }),
|
|
598
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: t("modal.title", "Session details") }),
|
|
599
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.StatusBadge, { session, status, size: "S" })
|
|
600
|
+
] }) }),
|
|
601
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, minWidth: 0, children: [
|
|
602
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-state-sentence": "", children: [
|
|
603
|
+
stateSentence(),
|
|
604
|
+
canEnd ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
605
|
+
"modal.state.maxAgeNote",
|
|
606
|
+
"Sessions older than the maximum session age end on their next request."
|
|
607
|
+
) }) : null
|
|
608
|
+
] }),
|
|
609
|
+
/* @__PURE__ */ jsxRuntime.jsx(DetailSection, { title: t("modal.section.user", "User"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
610
|
+
index.PropertyList,
|
|
611
|
+
{
|
|
612
|
+
items: [
|
|
613
|
+
{
|
|
614
|
+
id: "username",
|
|
615
|
+
label: t("modal.user.username", "Username"),
|
|
616
|
+
value: session.user?.username,
|
|
617
|
+
render: index.presentText(session.user?.username) && userEditPath ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "baseline", wrap: "wrap", children: [
|
|
618
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: session.user.username }),
|
|
619
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
620
|
+
TargetLink,
|
|
621
|
+
{
|
|
622
|
+
tag: reactRouterDom.NavLink,
|
|
623
|
+
to: userEditPath,
|
|
624
|
+
"aria-label": t("modal.user.openFor", "Open user {user}", {
|
|
625
|
+
user: user.accessible
|
|
626
|
+
}),
|
|
627
|
+
children: t("modal.user.open", "Open user")
|
|
628
|
+
}
|
|
629
|
+
)
|
|
630
|
+
] }) : void 0
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
id: "email",
|
|
634
|
+
label: t("modal.user.email", "Email"),
|
|
635
|
+
value: session.user?.email,
|
|
636
|
+
kind: "email"
|
|
637
|
+
}
|
|
638
|
+
]
|
|
639
|
+
}
|
|
640
|
+
) }),
|
|
641
|
+
/* @__PURE__ */ jsxRuntime.jsx(DetailSection, { title: t("modal.section.session", "Session"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
642
|
+
index.PropertyList,
|
|
643
|
+
{
|
|
644
|
+
items: [
|
|
645
|
+
{
|
|
646
|
+
id: "login",
|
|
647
|
+
label: t("modal.timeline.signedIn", "Signed in"),
|
|
648
|
+
value: formatTimestamp(session.loginTime)
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
id: "lastActive",
|
|
652
|
+
label: t("modal.timeline.lastActive", "Last active"),
|
|
653
|
+
value: formatTimestamp(session.lastActive || session.loginTime)
|
|
654
|
+
},
|
|
655
|
+
!canEnd ? {
|
|
656
|
+
id: "endedAt",
|
|
657
|
+
label: t("modal.timeline.endedAt", "Ended at"),
|
|
658
|
+
value: formatTimestamp(session.logoutTime)
|
|
659
|
+
} : null,
|
|
660
|
+
!canEnd ? {
|
|
661
|
+
id: "endReason",
|
|
662
|
+
label: t("modal.timeline.endReason", "End reason"),
|
|
663
|
+
render: /* @__PURE__ */ jsxRuntime.jsx(EndReason, { session })
|
|
664
|
+
} : null
|
|
665
|
+
]
|
|
666
|
+
}
|
|
667
|
+
) }),
|
|
668
|
+
/* @__PURE__ */ jsxRuntime.jsx(DetailSection, { title: t("modal.section.device", "Device"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
669
|
+
index.PropertyList,
|
|
670
|
+
{
|
|
671
|
+
items: [
|
|
672
|
+
{
|
|
673
|
+
id: "device",
|
|
674
|
+
label: t("modal.device.device", "Device type"),
|
|
675
|
+
value: native ? null : deviceTypeLabel(session)
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
id: "browser",
|
|
679
|
+
label: t("modal.device.browser", "Browser"),
|
|
680
|
+
value: device.browser
|
|
681
|
+
},
|
|
682
|
+
{ id: "os", label: t("modal.device.os", "Operating system"), value: device.os },
|
|
683
|
+
{
|
|
684
|
+
id: "ip",
|
|
685
|
+
label: t("modal.device.ip", "IP address"),
|
|
686
|
+
value: session.ipAddress,
|
|
687
|
+
kind: "id",
|
|
688
|
+
render: ipAddress ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", style: MONOSPACE$2, children: ipAddress }) : void 0
|
|
689
|
+
}
|
|
690
|
+
]
|
|
691
|
+
}
|
|
692
|
+
) }),
|
|
693
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DetailSection, { title: t("modal.section.security", "Location and security"), children: [
|
|
694
|
+
hasLocationData ? /* @__PURE__ */ jsxRuntime.jsx(index.PropertyList, { items: locationItems }) : null,
|
|
695
|
+
score !== null ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", "data-score-note": "", children: t(
|
|
696
|
+
"modal.security.scoreNote",
|
|
697
|
+
"Higher is safer. Below 70 can trigger a suspicious-sign-in email and below 50 a rejection, if those settings are on. Local database results are always 100."
|
|
698
|
+
) }) : null,
|
|
699
|
+
lookupControls
|
|
700
|
+
] }),
|
|
701
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { collapsible: true, size: "S", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: "technical", children: [
|
|
702
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: t("modal.section.technical", "Technical details") }) }),
|
|
703
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
704
|
+
native ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
705
|
+
"common.status.nativeSession.help",
|
|
706
|
+
"Created by Strapi’s own session store. No device or location details were recorded."
|
|
707
|
+
) }) : null,
|
|
708
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
709
|
+
index.PropertyList,
|
|
710
|
+
{
|
|
711
|
+
columns: 1,
|
|
712
|
+
items: [
|
|
713
|
+
{
|
|
714
|
+
id: "sessionId",
|
|
715
|
+
label: t("modal.technical.recordId", "Record ID"),
|
|
716
|
+
value: sessionId,
|
|
717
|
+
kind: "id",
|
|
718
|
+
render: sessionId ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
|
|
719
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
720
|
+
designSystem.Typography,
|
|
721
|
+
{
|
|
722
|
+
variant: "omega",
|
|
723
|
+
textColor: "neutral800",
|
|
724
|
+
style: MONOSPACE$2,
|
|
725
|
+
children: sessionId
|
|
726
|
+
}
|
|
727
|
+
),
|
|
728
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
729
|
+
designSystem.IconButton,
|
|
730
|
+
{
|
|
731
|
+
label: t("modal.actions.copyId", "Copy record ID"),
|
|
732
|
+
onClick: handleCopyId,
|
|
733
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, {})
|
|
734
|
+
}
|
|
735
|
+
)
|
|
736
|
+
] }) : void 0
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
id: "userId",
|
|
740
|
+
label: t("modal.user.id", "User ID"),
|
|
741
|
+
value: session.user?.documentId || session.user?.id,
|
|
742
|
+
kind: "id"
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
id: "userAgent",
|
|
746
|
+
label: t("modal.technical.userAgent", "User agent"),
|
|
747
|
+
value: userAgent || null,
|
|
748
|
+
kind: "id"
|
|
749
|
+
}
|
|
750
|
+
]
|
|
751
|
+
}
|
|
752
|
+
)
|
|
753
|
+
] }) }) })
|
|
754
|
+
] }) })
|
|
755
|
+
] }) }),
|
|
756
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
757
|
+
designSystem.Flex,
|
|
758
|
+
{
|
|
759
|
+
justifyContent: "space-between",
|
|
760
|
+
alignItems: "center",
|
|
761
|
+
gap: 3,
|
|
762
|
+
wrap: "wrap-reverse",
|
|
763
|
+
width: "100%",
|
|
764
|
+
children: [
|
|
765
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: t("modal.actions.close", "Close") }) }),
|
|
766
|
+
canEnd ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
767
|
+
index.ConfirmAction,
|
|
768
|
+
{
|
|
769
|
+
title: t("homepage.confirm.end.title", "End this session?"),
|
|
770
|
+
body: t(
|
|
771
|
+
"homepage.confirm.end.body",
|
|
772
|
+
"{user} will be signed out on {device}. Their other sessions stay open. The record stays in the history. This cannot be undone.",
|
|
773
|
+
{
|
|
774
|
+
user: user.accessible,
|
|
775
|
+
device: deviceSummary(session) || deviceTypeLabel(session)
|
|
776
|
+
}
|
|
777
|
+
),
|
|
778
|
+
confirmLabel: t("homepage.actions.end", "End session"),
|
|
779
|
+
onConfirm: handleTerminate,
|
|
780
|
+
disabled: !canEnd,
|
|
781
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "danger-light", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}), disabled: !canEnd, children: t("homepage.actions.end", "End session") })
|
|
782
|
+
}
|
|
783
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: endedReasonId, variant: "pi", textColor: "neutral600", children: t("modal.actions.alreadyEnded", "This session has already ended.") })
|
|
784
|
+
]
|
|
785
|
+
}
|
|
786
|
+
) })
|
|
787
|
+
] }) });
|
|
788
|
+
};
|
|
789
|
+
const isolateActionKeys = (event) => {
|
|
790
|
+
const fromInsideGroup = event.currentTarget.contains(
|
|
791
|
+
/** @type {Node} */
|
|
792
|
+
event.target
|
|
793
|
+
);
|
|
794
|
+
if (!shouldIsolateActionKey(event.key, fromInsideGroup)) return;
|
|
795
|
+
event.stopPropagation();
|
|
796
|
+
if (shouldRedispatchEscape(event.key, fromInsideGroup)) {
|
|
797
|
+
const { ownerDocument } = event.currentTarget;
|
|
798
|
+
ownerDocument.dispatchEvent(
|
|
799
|
+
new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true })
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
const getConfirmationCopy = (t, { user, device, isOpen }) => ({
|
|
804
|
+
end: {
|
|
805
|
+
title: t("homepage.confirm.end.title", "End this session?"),
|
|
806
|
+
body: t(
|
|
807
|
+
"homepage.confirm.end.body",
|
|
808
|
+
"{user} will be signed out on {device}. Their other sessions stay open. The record stays in the history. This cannot be undone.",
|
|
809
|
+
{ user, device }
|
|
810
|
+
),
|
|
811
|
+
confirmLabel: t("homepage.actions.end", "End session")
|
|
812
|
+
},
|
|
813
|
+
remove: isOpen ? {
|
|
814
|
+
title: t("homepage.confirm.deleteOpen.title", "Delete record and end session?"),
|
|
815
|
+
body: t(
|
|
816
|
+
"homepage.confirm.deleteOpen.body",
|
|
817
|
+
"This session is still open. {user} will be signed out on {device}, and the record is removed from history, statistics and exports. This cannot be undone.",
|
|
818
|
+
{ user, device }
|
|
819
|
+
),
|
|
820
|
+
confirmLabel: t("homepage.actions.deleteAndEnd", "Delete and end")
|
|
821
|
+
} : {
|
|
822
|
+
title: t("homepage.confirm.deleteEnded.title", "Delete this session record?"),
|
|
823
|
+
body: t(
|
|
824
|
+
"homepage.confirm.deleteEnded.body",
|
|
825
|
+
"The record is removed permanently from history, statistics and exports. This cannot be undone."
|
|
826
|
+
),
|
|
827
|
+
confirmLabel: t("homepage.actions.deleteRecord", "Delete record")
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
const SessionActions = ({
|
|
831
|
+
session,
|
|
832
|
+
layout,
|
|
833
|
+
onView,
|
|
834
|
+
onEnd,
|
|
835
|
+
onDelete,
|
|
836
|
+
mutationPending,
|
|
837
|
+
focusFallback
|
|
838
|
+
}) => {
|
|
839
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
840
|
+
const { deviceSummary, deviceTypeLabel } = index.useSessionFormatters();
|
|
841
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
842
|
+
const [deleteOpen, setDeleteOpen] = react.useState(false);
|
|
843
|
+
const moreRef = react.useRef(null);
|
|
844
|
+
const user = getSessionUserLabels(session).accessible;
|
|
845
|
+
const canEnd = session.isActive === true;
|
|
846
|
+
const device = deviceSummary(session) || deviceTypeLabel(session);
|
|
847
|
+
const copy = getConfirmationCopy(t, { user, device, isOpen: canEnd });
|
|
848
|
+
const viewLabel = t("homepage.actions.viewFor", "View details for {user}", { user });
|
|
849
|
+
const endLabel = t("homepage.actions.endFor", "End session of {user}", { user });
|
|
850
|
+
const endedLabel = t(
|
|
851
|
+
"homepage.actions.alreadyEndedFor",
|
|
852
|
+
"The session of {user} has already ended",
|
|
853
|
+
{ user }
|
|
854
|
+
);
|
|
855
|
+
const moreLabel = t("homepage.actions.moreFor", "More actions for {user}", { user });
|
|
856
|
+
const deleteLabel = t("homepage.actions.deleteRecord", "Delete record");
|
|
857
|
+
const endConfirm = { ...copy.end, onConfirm: () => onEnd(session) };
|
|
858
|
+
const deleteConfirm = /* @__PURE__ */ jsxRuntime.jsx(
|
|
859
|
+
index.ConfirmAction,
|
|
860
|
+
{
|
|
861
|
+
...copy.remove,
|
|
862
|
+
onConfirm: () => onDelete(session),
|
|
863
|
+
isOpen: deleteOpen,
|
|
864
|
+
onOpenChange: setDeleteOpen,
|
|
865
|
+
returnFocusRef: moreRef,
|
|
866
|
+
fallbackFocusRef: focusFallback
|
|
867
|
+
}
|
|
868
|
+
);
|
|
869
|
+
const endKey = `end-${session.id}-${canEnd ? "open" : "ended"}`;
|
|
870
|
+
if (layout === "table") {
|
|
871
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.IconButtonGroup, { onKeyDown: isolateActionKeys, onClick: (event) => event.stopPropagation(), children: [
|
|
872
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
873
|
+
designSystem.IconButton,
|
|
874
|
+
{
|
|
875
|
+
label: viewLabel,
|
|
876
|
+
"data-session-view": session.id,
|
|
877
|
+
onClick: (event) => onView(session, event.currentTarget),
|
|
878
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
|
|
879
|
+
}
|
|
880
|
+
),
|
|
881
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
882
|
+
index.ConfirmAction,
|
|
883
|
+
{
|
|
884
|
+
...endConfirm,
|
|
885
|
+
disabled: !canEnd || mutationPending,
|
|
886
|
+
fallbackFocusRef: focusFallback,
|
|
887
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
888
|
+
designSystem.IconButton,
|
|
889
|
+
{
|
|
890
|
+
label: canEnd ? endLabel : endedLabel,
|
|
891
|
+
variant: "danger-light",
|
|
892
|
+
disabled: !canEnd || mutationPending,
|
|
893
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {})
|
|
894
|
+
}
|
|
895
|
+
)
|
|
896
|
+
},
|
|
897
|
+
endKey
|
|
898
|
+
),
|
|
899
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
900
|
+
designSystem.SimpleMenu,
|
|
901
|
+
{
|
|
902
|
+
ref: moreRef,
|
|
903
|
+
tag: designSystem.IconButton,
|
|
904
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.More, {}),
|
|
905
|
+
label: moreLabel,
|
|
906
|
+
disabled: mutationPending,
|
|
907
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}), variant: "danger", onSelect: () => setDeleteOpen(true), children: deleteLabel })
|
|
908
|
+
}
|
|
909
|
+
),
|
|
910
|
+
deleteConfirm
|
|
911
|
+
] });
|
|
912
|
+
}
|
|
913
|
+
const span = canEnd ? 4 : 6;
|
|
914
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 2, children: [
|
|
915
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: span, m: span, s: span, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
916
|
+
designSystem.Button,
|
|
917
|
+
{
|
|
918
|
+
fullWidth: true,
|
|
919
|
+
variant: "secondary",
|
|
920
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {}),
|
|
921
|
+
"aria-label": viewLabel,
|
|
922
|
+
"data-session-view": session.id,
|
|
923
|
+
onClick: (event) => onView(session, event.currentTarget),
|
|
924
|
+
children: t("homepage.actions.details", "Details")
|
|
925
|
+
}
|
|
926
|
+
) }),
|
|
927
|
+
canEnd ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: span, m: span, s: span, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
928
|
+
index.ConfirmAction,
|
|
929
|
+
{
|
|
930
|
+
...endConfirm,
|
|
931
|
+
disabled: !canEnd || mutationPending,
|
|
932
|
+
fallbackFocusRef: focusFallback,
|
|
933
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
934
|
+
designSystem.Button,
|
|
935
|
+
{
|
|
936
|
+
fullWidth: true,
|
|
937
|
+
variant: "danger-light",
|
|
938
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}),
|
|
939
|
+
"aria-label": endLabel,
|
|
940
|
+
disabled: !canEnd || mutationPending,
|
|
941
|
+
children: t("homepage.actions.end", "End session")
|
|
942
|
+
}
|
|
943
|
+
)
|
|
944
|
+
},
|
|
945
|
+
endKey
|
|
946
|
+
) }) : null,
|
|
947
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Item, { col: span, m: span, s: span, xs: 12, direction: "column", alignItems: "stretch", children: [
|
|
948
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
949
|
+
designSystem.SimpleMenu,
|
|
950
|
+
{
|
|
951
|
+
ref: moreRef,
|
|
952
|
+
label: t("homepage.actions.more", "More"),
|
|
953
|
+
"aria-label": moreLabel,
|
|
954
|
+
variant: "tertiary",
|
|
955
|
+
fullWidth: true,
|
|
956
|
+
endIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.More, {}),
|
|
957
|
+
disabled: mutationPending,
|
|
958
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}), variant: "danger", onSelect: () => setDeleteOpen(true), children: deleteLabel })
|
|
959
|
+
}
|
|
960
|
+
),
|
|
961
|
+
deleteConfirm
|
|
962
|
+
] })
|
|
963
|
+
] });
|
|
964
|
+
};
|
|
965
|
+
const SHRINKING_USER_CELL = { maxWidth: 0, width: "30%" };
|
|
966
|
+
const SHRINKING_DEVICE_CELL = { maxWidth: 0, width: "25%" };
|
|
967
|
+
const COMPACT_STATUS_CELL = { width: "24%", whiteSpace: "normal" };
|
|
968
|
+
const MONOSPACE$1 = { fontFamily: "monospace" };
|
|
969
|
+
const LastActive = ({ value }) => {
|
|
970
|
+
const { formatDate, formatRelativeTime } = index.useSessionFormatters();
|
|
971
|
+
const date = index.toValidDate(value);
|
|
972
|
+
if (!date) return /* @__PURE__ */ jsxRuntime.jsx(index.MissingValue, { variant: "omega" });
|
|
973
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label: formatDate(date), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "time", dateTime: date.toISOString(), variant: "omega", textColor: "neutral800", children: formatRelativeTime(date) }) });
|
|
974
|
+
};
|
|
975
|
+
const SignedIn = ({ value }) => {
|
|
976
|
+
const { formatDate } = index.useSessionFormatters();
|
|
977
|
+
const date = index.toValidDate(value);
|
|
978
|
+
if (!date) return /* @__PURE__ */ jsxRuntime.jsx(index.MissingValue, { variant: "omega" });
|
|
979
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "time", dateTime: date.toISOString(), variant: "omega", textColor: "neutral800", children: formatDate(date) });
|
|
980
|
+
};
|
|
981
|
+
const DeviceSummary = ({ session }) => {
|
|
982
|
+
const { deviceTypeLabel, deviceSummary } = index.useSessionFormatters();
|
|
983
|
+
if (index.isNativeOnlySession(session)) return /* @__PURE__ */ jsxRuntime.jsx(index.MissingValue, { variant: "omega" });
|
|
984
|
+
const device = index.getDevicePresentation(session);
|
|
985
|
+
const typeLabel = deviceTypeLabel(session);
|
|
986
|
+
const summary = device.hasSummary ? deviceSummary(session) : typeLabel;
|
|
987
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", minWidth: 0, children: [
|
|
988
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { shrink: 0, color: "neutral600", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(index.DeviceIcon, { icon: device.icon }) }),
|
|
989
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", minWidth: 0, children: [
|
|
990
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", ellipsis: true, title: summary, children: summary }),
|
|
991
|
+
device.hasSummary && device.hasDeviceType ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, title: typeLabel, children: typeLabel }) : null
|
|
992
|
+
] })
|
|
993
|
+
] });
|
|
994
|
+
};
|
|
995
|
+
const SessionTable = ({
|
|
996
|
+
sessions,
|
|
997
|
+
labelledBy,
|
|
998
|
+
busy,
|
|
999
|
+
compact = false,
|
|
1000
|
+
onView,
|
|
1001
|
+
onEnd,
|
|
1002
|
+
onDelete,
|
|
1003
|
+
mutationPending,
|
|
1004
|
+
getFocusFallback
|
|
1005
|
+
}) => {
|
|
1006
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
1007
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1008
|
+
const header = (id, defaultMessage) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t(id, defaultMessage) });
|
|
1009
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1010
|
+
designSystem.Table,
|
|
1011
|
+
{
|
|
1012
|
+
colCount: compact ? DASHBOARD_COMPACT_TABLE_COLUMNS : DASHBOARD_TABLE_COLUMNS,
|
|
1013
|
+
rowCount: sessions.length + 1,
|
|
1014
|
+
"aria-labelledby": labelledBy,
|
|
1015
|
+
"aria-busy": busy,
|
|
1016
|
+
children: [
|
|
1017
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
1018
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: compact ? COMPACT_STATUS_CELL : void 0, children: header("homepage.table.status", "Status") }),
|
|
1019
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: header("homepage.table.user", "User") }),
|
|
1020
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: header("homepage.table.device", "Device") }),
|
|
1021
|
+
compact ? null : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: header("homepage.table.ipAddress", "IP address") }),
|
|
1022
|
+
compact ? null : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: header("homepage.table.signedIn", "Signed in") }),
|
|
1023
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: header("homepage.table.lastActive", "Last active") }),
|
|
1024
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("homepage.table.actions", "Actions") }) })
|
|
1025
|
+
] }) }),
|
|
1026
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: sessions.map((session) => {
|
|
1027
|
+
const user = getSessionUserLabels(session);
|
|
1028
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1029
|
+
designSystem.Tr,
|
|
1030
|
+
{
|
|
1031
|
+
style: { cursor: "pointer" },
|
|
1032
|
+
onClick: (event) => {
|
|
1033
|
+
const opener = event.currentTarget.querySelector("[data-session-view]");
|
|
1034
|
+
onView(session, opener || event.currentTarget);
|
|
1035
|
+
},
|
|
1036
|
+
children: [
|
|
1037
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: compact ? COMPACT_STATUS_CELL : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(index.StatusBadge, { session, size: "S", detail: true }) }),
|
|
1038
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_USER_CELL, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", minWidth: 0, children: [
|
|
1039
|
+
user.primary ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1040
|
+
designSystem.Typography,
|
|
1041
|
+
{
|
|
1042
|
+
fontWeight: "semiBold",
|
|
1043
|
+
textColor: "neutral800",
|
|
1044
|
+
ellipsis: true,
|
|
1045
|
+
title: user.primary,
|
|
1046
|
+
children: user.primary
|
|
1047
|
+
}
|
|
1048
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(index.MissingValue, { variant: "omega" }),
|
|
1049
|
+
user.secondary ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, title: user.secondary, children: user.secondary }) : null
|
|
1050
|
+
] }) }),
|
|
1051
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_DEVICE_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(DeviceSummary, { session }) }),
|
|
1052
|
+
compact ? null : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", style: MONOSPACE$1, children: /* @__PURE__ */ jsxRuntime.jsx(index.ValueOrMissing, { value: session.ipAddress }) }) }),
|
|
1053
|
+
compact ? null : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(SignedIn, { value: session.loginTime }) }),
|
|
1054
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: session.lastActive || session.loginTime }) }),
|
|
1055
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1056
|
+
SessionActions,
|
|
1057
|
+
{
|
|
1058
|
+
layout: "table",
|
|
1059
|
+
session,
|
|
1060
|
+
onView,
|
|
1061
|
+
onEnd,
|
|
1062
|
+
onDelete,
|
|
1063
|
+
mutationPending,
|
|
1064
|
+
focusFallback: getFocusFallback(session.id)
|
|
1065
|
+
}
|
|
1066
|
+
) }) })
|
|
1067
|
+
]
|
|
1068
|
+
},
|
|
1069
|
+
session.id
|
|
1070
|
+
);
|
|
1071
|
+
}) })
|
|
1072
|
+
]
|
|
1073
|
+
}
|
|
1074
|
+
);
|
|
1075
|
+
};
|
|
1076
|
+
const CardList = styled__default.default.ul`
|
|
1077
|
+
display: flex;
|
|
1078
|
+
flex-direction: column;
|
|
1079
|
+
gap: ${({ theme }) => theme.spaces[4]};
|
|
1080
|
+
list-style: none;
|
|
1081
|
+
margin: 0;
|
|
1082
|
+
padding: 0;
|
|
1083
|
+
min-width: 0;
|
|
1084
|
+
|
|
1085
|
+
/* The page text rhythm caps list items at 72ch and adds li + li margins;
|
|
1086
|
+
cards use the full list width and the flex gap only. */
|
|
1087
|
+
&& > li {
|
|
1088
|
+
max-width: none;
|
|
1089
|
+
margin: 0;
|
|
1090
|
+
}
|
|
1091
|
+
`;
|
|
1092
|
+
const MONOSPACE = { fontFamily: "monospace" };
|
|
1093
|
+
const SessionCardList = ({
|
|
1094
|
+
sessions,
|
|
1095
|
+
labelledBy,
|
|
1096
|
+
busy,
|
|
1097
|
+
onView,
|
|
1098
|
+
onEnd,
|
|
1099
|
+
onDelete,
|
|
1100
|
+
mutationPending,
|
|
1101
|
+
getFocusFallback
|
|
1102
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(CardList, { "aria-labelledby": labelledBy, "aria-busy": busy, children: sessions.map((session) => {
|
|
1103
|
+
const user = getSessionUserLabels(session);
|
|
1104
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1105
|
+
designSystem.Box,
|
|
1106
|
+
{
|
|
1107
|
+
tag: "li",
|
|
1108
|
+
background: "neutral0",
|
|
1109
|
+
hasRadius: true,
|
|
1110
|
+
shadow: "tableShadow",
|
|
1111
|
+
padding: 4,
|
|
1112
|
+
minWidth: 0,
|
|
1113
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, children: [
|
|
1114
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.StatusBadge, { session, size: "S", detail: true }),
|
|
1115
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", minWidth: 0, children: [
|
|
1116
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1117
|
+
designSystem.Typography,
|
|
1118
|
+
{
|
|
1119
|
+
variant: "delta",
|
|
1120
|
+
tag: "h3",
|
|
1121
|
+
textColor: "neutral800",
|
|
1122
|
+
style: { overflowWrap: "anywhere" },
|
|
1123
|
+
children: user.primary || /* @__PURE__ */ jsxRuntime.jsx(index.MissingValue, { variant: "delta" })
|
|
1124
|
+
}
|
|
1125
|
+
),
|
|
1126
|
+
user.secondary ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1127
|
+
designSystem.Typography,
|
|
1128
|
+
{
|
|
1129
|
+
variant: "pi",
|
|
1130
|
+
textColor: "neutral600",
|
|
1131
|
+
style: { overflowWrap: "anywhere" },
|
|
1132
|
+
children: user.secondary
|
|
1133
|
+
}
|
|
1134
|
+
) : null
|
|
1135
|
+
] }),
|
|
1136
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", wrap: "wrap", minWidth: 0, children: [
|
|
1137
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { minWidth: 0, flex: "1 1 auto", children: /* @__PURE__ */ jsxRuntime.jsx(DeviceSummary, { session }) }),
|
|
1138
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: MONOSPACE, children: /* @__PURE__ */ jsxRuntime.jsx(index.ValueOrMissing, { value: session.ipAddress }) })
|
|
1139
|
+
] }),
|
|
1140
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1141
|
+
SessionActions,
|
|
1142
|
+
{
|
|
1143
|
+
layout: "card",
|
|
1144
|
+
session,
|
|
1145
|
+
onView,
|
|
1146
|
+
onEnd,
|
|
1147
|
+
onDelete,
|
|
1148
|
+
mutationPending,
|
|
1149
|
+
focusFallback: getFocusFallback(session.id)
|
|
1150
|
+
}
|
|
1151
|
+
)
|
|
1152
|
+
] })
|
|
1153
|
+
},
|
|
1154
|
+
session.id
|
|
1155
|
+
);
|
|
1156
|
+
}) });
|
|
1157
|
+
const SearchWrapper = styled__default.default(designSystem.Box)`
|
|
1158
|
+
& button {
|
|
1159
|
+
min-width: 2.4rem;
|
|
1160
|
+
min-height: 2.4rem;
|
|
1161
|
+
justify-content: center;
|
|
1162
|
+
}
|
|
1163
|
+
`;
|
|
1164
|
+
const SEARCH_DEBOUNCE_MS = 300;
|
|
1165
|
+
const SessionSearch = ({ value, onSearch }) => {
|
|
1166
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
1167
|
+
const t = (id, defaultMessage) => formatMessage({ id: index.getTranslation(id), defaultMessage });
|
|
1168
|
+
const [draft, setDraft] = react.useState(value);
|
|
1169
|
+
const lastApplied = react.useRef(value);
|
|
1170
|
+
react.useEffect(() => {
|
|
1171
|
+
if (value !== lastApplied.current) {
|
|
1172
|
+
lastApplied.current = value;
|
|
1173
|
+
setDraft(value);
|
|
1174
|
+
}
|
|
1175
|
+
}, [value]);
|
|
1176
|
+
react.useEffect(() => {
|
|
1177
|
+
const next = draft.trim();
|
|
1178
|
+
if (next === lastApplied.current) return void 0;
|
|
1179
|
+
const timer = setTimeout(() => {
|
|
1180
|
+
lastApplied.current = next;
|
|
1181
|
+
onSearch(next);
|
|
1182
|
+
}, SEARCH_DEBOUNCE_MS);
|
|
1183
|
+
return () => clearTimeout(timer);
|
|
1184
|
+
}, [draft, onSearch]);
|
|
1185
|
+
const apply = (next) => {
|
|
1186
|
+
lastApplied.current = next;
|
|
1187
|
+
onSearch(next);
|
|
1188
|
+
};
|
|
1189
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SearchWrapper, { width: "100%", "data-session-search": "", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1190
|
+
designSystem.SearchForm,
|
|
1191
|
+
{
|
|
1192
|
+
onSubmit: (event) => {
|
|
1193
|
+
event.preventDefault();
|
|
1194
|
+
apply(draft.trim());
|
|
1195
|
+
},
|
|
1196
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1197
|
+
designSystem.Searchbar,
|
|
1198
|
+
{
|
|
1199
|
+
name: "search",
|
|
1200
|
+
value: draft,
|
|
1201
|
+
onChange: (event) => setDraft(event.target.value),
|
|
1202
|
+
onClear: () => {
|
|
1203
|
+
setDraft("");
|
|
1204
|
+
apply("");
|
|
1205
|
+
},
|
|
1206
|
+
clearLabel: t("homepage.search.clear", "Clear search"),
|
|
1207
|
+
placeholder: t("homepage.search.placeholder", "Search user, email, IP or device"),
|
|
1208
|
+
children: t("homepage.search.label", "Search sessions")
|
|
1209
|
+
}
|
|
1210
|
+
)
|
|
1211
|
+
}
|
|
1212
|
+
) });
|
|
1213
|
+
};
|
|
1214
|
+
const Caret = styled__default.default(icons.CaretDown)`
|
|
1215
|
+
transform: rotate(${({ $open }) => $open ? "0deg" : "-90deg"});
|
|
1216
|
+
`;
|
|
1217
|
+
const Legend = styled__default.default.ul`
|
|
1218
|
+
display: grid;
|
|
1219
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1220
|
+
gap: ${({ theme }) => theme.spaces[4]};
|
|
1221
|
+
list-style: none;
|
|
1222
|
+
margin: 0;
|
|
1223
|
+
padding: 0;
|
|
1224
|
+
|
|
1225
|
+
/* The page text rhythm spaces stacked list items; grid cells use the gap. */
|
|
1226
|
+
&& > li {
|
|
1227
|
+
margin: 0;
|
|
1228
|
+
max-width: none;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
${({ theme }) => theme.breakpoints.medium} {
|
|
1232
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
1233
|
+
gap: ${({ theme }) => theme.spaces[6]};
|
|
1234
|
+
}
|
|
1235
|
+
`;
|
|
1236
|
+
const HowSessionsWork = () => {
|
|
1237
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
1238
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1239
|
+
const [open, setOpen] = react.useState(() => readDisclosureOpen(getBrowserStorage()));
|
|
1240
|
+
const contentId = `how-sessions-work-${react.useId().replace(/:/g, "")}`;
|
|
1241
|
+
const toggle = () => {
|
|
1242
|
+
setOpen((previous) => {
|
|
1243
|
+
const next = !previous;
|
|
1244
|
+
writeDisclosureOpen(getBrowserStorage(), next);
|
|
1245
|
+
return next;
|
|
1246
|
+
});
|
|
1247
|
+
};
|
|
1248
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, "data-how-sessions-work": "", children: [
|
|
1249
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1250
|
+
designSystem.TextButton,
|
|
1251
|
+
{
|
|
1252
|
+
minHeight: "3.2rem",
|
|
1253
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(Caret, { $open: open, "aria-hidden": true, focusable: false }),
|
|
1254
|
+
"aria-expanded": open,
|
|
1255
|
+
"aria-controls": contentId,
|
|
1256
|
+
onClick: toggle,
|
|
1257
|
+
children: t("homepage.howItWorks.toggle", "How sessions work")
|
|
1258
|
+
}
|
|
1259
|
+
),
|
|
1260
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1261
|
+
designSystem.Box,
|
|
1262
|
+
{
|
|
1263
|
+
id: contentId,
|
|
1264
|
+
hidden: !open,
|
|
1265
|
+
width: "100%",
|
|
1266
|
+
background: "neutral0",
|
|
1267
|
+
hasRadius: true,
|
|
1268
|
+
shadow: "tableShadow",
|
|
1269
|
+
padding: { initial: 4, medium: 6 },
|
|
1270
|
+
children: open ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
1271
|
+
/* @__PURE__ */ jsxRuntime.jsx(Legend, { children: index.SESSION_STATES.map((state) => {
|
|
1272
|
+
const { definition } = index.SESSION_STATUS_PRESENTATION[state];
|
|
1273
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1274
|
+
designSystem.Flex,
|
|
1275
|
+
{
|
|
1276
|
+
tag: "li",
|
|
1277
|
+
direction: "column",
|
|
1278
|
+
alignItems: "flex-start",
|
|
1279
|
+
gap: 2,
|
|
1280
|
+
minWidth: 0,
|
|
1281
|
+
children: [
|
|
1282
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.StatusBadge, { status: state, size: "S" }),
|
|
1283
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: formatMessage({
|
|
1284
|
+
id: index.getTranslation(definition.messageId),
|
|
1285
|
+
defaultMessage: definition.defaultMessage
|
|
1286
|
+
}) })
|
|
1287
|
+
]
|
|
1288
|
+
},
|
|
1289
|
+
state
|
|
1290
|
+
);
|
|
1291
|
+
}) }),
|
|
1292
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
1293
|
+
"homepage.howItWorks.history",
|
|
1294
|
+
"Ended sessions stay in the history until they are deleted."
|
|
1295
|
+
) })
|
|
1296
|
+
] }) : null
|
|
1297
|
+
}
|
|
1298
|
+
)
|
|
1299
|
+
] });
|
|
1300
|
+
};
|
|
1301
|
+
const LOADED_SESSIONS_LIMIT = 1e3;
|
|
1302
|
+
const CLOCK_TICK_MS = 30 * 1e3;
|
|
1303
|
+
const ANALYTICS_PATH = `/settings/${index.pluginId}/analytics`;
|
|
1304
|
+
const CONFIGURATION_PATH = `/settings/${index.pluginId}/general`;
|
|
1305
|
+
const PaginationTargets = styled__default.default.div`
|
|
1306
|
+
nav a {
|
|
1307
|
+
min-width: 3.2rem;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
& > div {
|
|
1311
|
+
flex-wrap: wrap;
|
|
1312
|
+
gap: ${({ theme }) => theme.spaces[2]} ${({ theme }) => theme.spaces[4]};
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
& > div > div > span {
|
|
1316
|
+
white-space: nowrap;
|
|
1317
|
+
}
|
|
1318
|
+
`;
|
|
1319
|
+
const downloadFile = (content, type, extension) => {
|
|
1320
|
+
const blob = new Blob([content], { type });
|
|
1321
|
+
const url = URL.createObjectURL(blob);
|
|
1322
|
+
const link = document.createElement("a");
|
|
1323
|
+
link.href = url;
|
|
1324
|
+
link.download = `sessions-export-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.${extension}`;
|
|
1325
|
+
link.click();
|
|
1326
|
+
window.setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
1327
|
+
};
|
|
1328
|
+
const HomePage = () => {
|
|
1329
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
1330
|
+
const { get, post, del } = StrapiAdmin.useFetchClient();
|
|
1331
|
+
const { toggleNotification } = StrapiAdmin.useNotification();
|
|
1332
|
+
const formatters = index.useSessionFormatters();
|
|
1333
|
+
const { isBelowSmall, isBelowMedium, isBelowLarge } = useBreakpoint();
|
|
1334
|
+
const [listWidthRef, listWidth] = useElementWidth();
|
|
1335
|
+
const [{ query }, setQuery] = StrapiAdmin.useQueryParams();
|
|
1336
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1337
|
+
const dashboard = parseDashboardQuery(query);
|
|
1338
|
+
const [sessions, setSessions] = react.useState([]);
|
|
1339
|
+
const [truncated, setTruncated] = react.useState(false);
|
|
1340
|
+
const [loading, setLoading] = react.useState(true);
|
|
1341
|
+
const [refreshing, setRefreshing] = react.useState(false);
|
|
1342
|
+
const [loadError, setLoadError] = react.useState(false);
|
|
1343
|
+
const [hasData, setHasData] = react.useState(false);
|
|
1344
|
+
const [lastUpdated, setLastUpdated] = react.useState(null);
|
|
1345
|
+
const [now, setNow] = react.useState(() => Date.now());
|
|
1346
|
+
const [selectedSession, setSelectedSession] = react.useState(null);
|
|
1347
|
+
const [showDetailModal, setShowDetailModal] = react.useState(false);
|
|
1348
|
+
const [terminatingSessionId, setTerminatingSessionId] = react.useState(null);
|
|
1349
|
+
const [deletingSessionId, setDeletingSessionId] = react.useState(null);
|
|
1350
|
+
const openerRef = react.useRef(null);
|
|
1351
|
+
const dashboardRef = react.useRef(null);
|
|
1352
|
+
const listHeadingRef = react.useRef(null);
|
|
1353
|
+
const hasLoadedRef = react.useRef(false);
|
|
1354
|
+
const requestIdRef = react.useRef(0);
|
|
1355
|
+
const visibleIdsRef = react.useRef([]);
|
|
1356
|
+
const mutationSnapshotRef = react.useRef([]);
|
|
1357
|
+
const listHeadingId = `session-list-caption-${react.useId().replace(/:/g, "")}`;
|
|
1358
|
+
const mutationPending = Boolean(terminatingSessionId || deletingSessionId);
|
|
1359
|
+
react.useEffect(() => {
|
|
1360
|
+
const timer = setInterval(() => setNow(Date.now()), CLOCK_TICK_MS);
|
|
1361
|
+
return () => clearInterval(timer);
|
|
1362
|
+
}, []);
|
|
1363
|
+
const fetchSessions = react.useCallback(async () => {
|
|
1364
|
+
const requestId = requestIdRef.current + 1;
|
|
1365
|
+
requestIdRef.current = requestId;
|
|
1366
|
+
if (hasLoadedRef.current) setRefreshing(true);
|
|
1367
|
+
else setLoading(true);
|
|
1368
|
+
try {
|
|
1369
|
+
const { data } = await get(`/${index.pluginId}/sessions`);
|
|
1370
|
+
const list = index.requireSessionList(data);
|
|
1371
|
+
if (requestId !== requestIdRef.current) return;
|
|
1372
|
+
setSessions(list);
|
|
1373
|
+
setTruncated(data?.meta?.truncated === true);
|
|
1374
|
+
setLoadError(false);
|
|
1375
|
+
setHasData(true);
|
|
1376
|
+
setLastUpdated(Date.now());
|
|
1377
|
+
setNow(Date.now());
|
|
1378
|
+
hasLoadedRef.current = true;
|
|
1379
|
+
} catch (err) {
|
|
1380
|
+
if (requestId !== requestIdRef.current || index.isCancelledRequest(err)) return;
|
|
1381
|
+
setLoadError(true);
|
|
1382
|
+
index.logSafeAdminError("dashboard.loadSessions", err);
|
|
1383
|
+
} finally {
|
|
1384
|
+
if (requestId === requestIdRef.current) {
|
|
1385
|
+
setLoading(false);
|
|
1386
|
+
setRefreshing(false);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}, [get]);
|
|
1390
|
+
react.useEffect(() => {
|
|
1391
|
+
fetchSessions();
|
|
1392
|
+
}, [fetchSessions]);
|
|
1393
|
+
react.useEffect(() => {
|
|
1394
|
+
if (showDetailModal || mutationPending) return void 0;
|
|
1395
|
+
const interval = setInterval(() => {
|
|
1396
|
+
fetchSessions();
|
|
1397
|
+
}, AUTO_REFRESH_INTERVAL_MS);
|
|
1398
|
+
return () => clearInterval(interval);
|
|
1399
|
+
}, [showDetailModal, mutationPending, fetchSessions]);
|
|
1400
|
+
const handleTerminateSession = async (session) => {
|
|
1401
|
+
if (terminatingSessionId || deletingSessionId) return;
|
|
1402
|
+
const sessionId = session.id;
|
|
1403
|
+
mutationSnapshotRef.current = visibleIdsRef.current;
|
|
1404
|
+
setTerminatingSessionId(sessionId);
|
|
1405
|
+
try {
|
|
1406
|
+
await post(`/${index.pluginId}/sessions/${sessionId}/terminate`);
|
|
1407
|
+
await fetchSessions();
|
|
1408
|
+
toggleNotification({
|
|
1409
|
+
type: "success",
|
|
1410
|
+
message: t("notifications.success.sessionEnded", "Session ended.")
|
|
1411
|
+
});
|
|
1412
|
+
} catch (err) {
|
|
1413
|
+
index.logSafeAdminError("dashboard.terminateSession", err);
|
|
1414
|
+
if (getErrorStatus(err) === 404) {
|
|
1415
|
+
await fetchSessions();
|
|
1416
|
+
toggleNotification({
|
|
1417
|
+
type: "warning",
|
|
1418
|
+
message: t(
|
|
1419
|
+
"notifications.error.sessionGone",
|
|
1420
|
+
"This session no longer exists. The list was refreshed."
|
|
1421
|
+
)
|
|
1422
|
+
});
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
toggleNotification({
|
|
1426
|
+
type: "danger",
|
|
1427
|
+
message: t(
|
|
1428
|
+
"notifications.error.endSession",
|
|
1429
|
+
"The session could not be ended. Please try again."
|
|
1430
|
+
)
|
|
1431
|
+
});
|
|
1432
|
+
throw err;
|
|
1433
|
+
} finally {
|
|
1434
|
+
setTerminatingSessionId(null);
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
const handleDeleteSession = async (session) => {
|
|
1438
|
+
if (terminatingSessionId || deletingSessionId) return;
|
|
1439
|
+
const sessionId = session.id;
|
|
1440
|
+
mutationSnapshotRef.current = visibleIdsRef.current;
|
|
1441
|
+
setDeletingSessionId(sessionId);
|
|
1442
|
+
try {
|
|
1443
|
+
await del(`/${index.pluginId}/sessions/${sessionId}`);
|
|
1444
|
+
await fetchSessions();
|
|
1445
|
+
toggleNotification({
|
|
1446
|
+
type: "success",
|
|
1447
|
+
message: t(
|
|
1448
|
+
"notifications.success.recordDeleted",
|
|
1449
|
+
"Session record deleted. Its token stays revoked."
|
|
1450
|
+
)
|
|
1451
|
+
});
|
|
1452
|
+
} catch (err) {
|
|
1453
|
+
index.logSafeAdminError("dashboard.deleteSession", err);
|
|
1454
|
+
if (getErrorStatus(err) === 404) {
|
|
1455
|
+
await fetchSessions();
|
|
1456
|
+
toggleNotification({
|
|
1457
|
+
type: "warning",
|
|
1458
|
+
message: t(
|
|
1459
|
+
"notifications.error.sessionGone",
|
|
1460
|
+
"This session no longer exists. The list was refreshed."
|
|
1461
|
+
)
|
|
1462
|
+
});
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
toggleNotification({
|
|
1466
|
+
type: "danger",
|
|
1467
|
+
message: t(
|
|
1468
|
+
"notifications.error.deleteRecord",
|
|
1469
|
+
"The record could not be deleted. Please try again."
|
|
1470
|
+
)
|
|
1471
|
+
});
|
|
1472
|
+
throw err;
|
|
1473
|
+
} finally {
|
|
1474
|
+
setDeletingSessionId(null);
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
const filteredSessions = react.useMemo(
|
|
1478
|
+
() => index.filterSessionsBySearch(
|
|
1479
|
+
index.filterSessionsByStatus(sessions, dashboard.status, dashboard.reason),
|
|
1480
|
+
dashboard.search,
|
|
1481
|
+
formatters.deviceTypeLabel
|
|
1482
|
+
),
|
|
1483
|
+
[sessions, dashboard.status, dashboard.reason, dashboard.search, formatters]
|
|
1484
|
+
);
|
|
1485
|
+
const pageResult = paginateSessions(filteredSessions, dashboard.page, dashboard.pageSize);
|
|
1486
|
+
const visibleIds = pageResult.items.map((session) => String(session.id));
|
|
1487
|
+
react.useLayoutEffect(() => {
|
|
1488
|
+
visibleIdsRef.current = visibleIds;
|
|
1489
|
+
});
|
|
1490
|
+
const handleExportCSV = () => {
|
|
1491
|
+
try {
|
|
1492
|
+
const csvContent = buildSessionCsv(filteredSessions, {
|
|
1493
|
+
unavailableValue: "",
|
|
1494
|
+
getDeviceInfo: getExportDeviceInfo,
|
|
1495
|
+
getSessionStatus: index.getSessionStatus
|
|
1496
|
+
});
|
|
1497
|
+
downloadFile(csvContent, "text/csv;charset=utf-8;", "csv");
|
|
1498
|
+
} catch (err) {
|
|
1499
|
+
index.logSafeAdminError("dashboard.exportCsv", err);
|
|
1500
|
+
toggleNotification({
|
|
1501
|
+
type: "danger",
|
|
1502
|
+
message: t("notifications.error.exportFailed", "The export could not be created.")
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
const handleExportJSON = () => {
|
|
1507
|
+
try {
|
|
1508
|
+
const jsonContent = buildSessionJson(filteredSessions, {
|
|
1509
|
+
filterStatus: dashboard.status,
|
|
1510
|
+
totalSessions: sessions.length,
|
|
1511
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1512
|
+
unavailableValue: "",
|
|
1513
|
+
getDeviceInfo: getExportDeviceInfo,
|
|
1514
|
+
getSessionStatus: index.getSessionStatus,
|
|
1515
|
+
truncated
|
|
1516
|
+
});
|
|
1517
|
+
downloadFile(jsonContent, "application/json", "json");
|
|
1518
|
+
} catch (err) {
|
|
1519
|
+
index.logSafeAdminError("dashboard.exportJson", err);
|
|
1520
|
+
toggleNotification({
|
|
1521
|
+
type: "danger",
|
|
1522
|
+
message: t("notifications.error.exportFailed", "The export could not be created.")
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1526
|
+
const handleSessionClick = (session, opener) => {
|
|
1527
|
+
openerRef.current = opener;
|
|
1528
|
+
setSelectedSession(session);
|
|
1529
|
+
setShowDetailModal(true);
|
|
1530
|
+
};
|
|
1531
|
+
const handleModalClose = () => {
|
|
1532
|
+
setShowDetailModal(false);
|
|
1533
|
+
setSelectedSession(null);
|
|
1534
|
+
};
|
|
1535
|
+
const handleCloseAutoFocus = (event) => {
|
|
1536
|
+
index.restoreDialogFocus(event, openerRef.current, listHeadingRef.current || dashboardRef.current);
|
|
1537
|
+
};
|
|
1538
|
+
const getFocusFallback = react.useCallback(
|
|
1539
|
+
(sessionId) => ({
|
|
1540
|
+
get current() {
|
|
1541
|
+
const targetId = pickFocusSessionId(
|
|
1542
|
+
mutationSnapshotRef.current,
|
|
1543
|
+
visibleIdsRef.current,
|
|
1544
|
+
sessionId
|
|
1545
|
+
);
|
|
1546
|
+
const root = dashboardRef.current;
|
|
1547
|
+
if (targetId && root) {
|
|
1548
|
+
const escaped = typeof CSS !== "undefined" && CSS.escape ? CSS.escape(targetId) : targetId;
|
|
1549
|
+
const button = root.querySelector(`[data-session-view="${escaped}"]`);
|
|
1550
|
+
if (button) return button;
|
|
1551
|
+
}
|
|
1552
|
+
return listHeadingRef.current;
|
|
1553
|
+
}
|
|
1554
|
+
}),
|
|
1555
|
+
[]
|
|
1556
|
+
);
|
|
1557
|
+
react.useEffect(() => {
|
|
1558
|
+
if (!loading && dashboard.page > pageResult.pageCount) {
|
|
1559
|
+
setQuery({ page: String(pageResult.pageCount) }, "push", true);
|
|
1560
|
+
}
|
|
1561
|
+
}, [loading, dashboard.page, pageResult.pageCount, setQuery]);
|
|
1562
|
+
const handleStatusChange = (value) => {
|
|
1563
|
+
const status = String(value);
|
|
1564
|
+
setQuery({ status: status === "all" ? void 0 : status, reason: void 0, page: "1" });
|
|
1565
|
+
};
|
|
1566
|
+
const handleReasonChange = (value) => {
|
|
1567
|
+
const reason = String(value);
|
|
1568
|
+
setQuery({ reason: reason === "all" ? void 0 : reason, page: "1" });
|
|
1569
|
+
};
|
|
1570
|
+
const handleSearch = react.useCallback(
|
|
1571
|
+
(value) => {
|
|
1572
|
+
setQuery({ search: encodeSearchQuery(value), _q: void 0, page: "1" }, "push", true);
|
|
1573
|
+
},
|
|
1574
|
+
[setQuery]
|
|
1575
|
+
);
|
|
1576
|
+
const handleClearFilters = () => {
|
|
1577
|
+
setQuery({ search: void 0, _q: void 0, status: void 0, reason: void 0, page: "1" });
|
|
1578
|
+
listHeadingRef.current?.focus();
|
|
1579
|
+
};
|
|
1580
|
+
const stats = getSessionStats(sessions);
|
|
1581
|
+
const showSessionData = !loading && hasData;
|
|
1582
|
+
const showToolbar = showSessionData && sessions.length > 0;
|
|
1583
|
+
const canExport = showSessionData && filteredSessions.length > 0;
|
|
1584
|
+
const filtersActive = hasActiveFilters(dashboard);
|
|
1585
|
+
const exportValues = { count: filteredSessions.length, limit: LOADED_SESSIONS_LIMIT };
|
|
1586
|
+
const exportMenu = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1587
|
+
designSystem.SimpleMenu,
|
|
1588
|
+
{
|
|
1589
|
+
label: t("homepage.export.label", "Export"),
|
|
1590
|
+
variant: "secondary",
|
|
1591
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
|
|
1592
|
+
disabled: !canExport,
|
|
1593
|
+
children: [
|
|
1594
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: handleExportCSV, children: truncated ? t(
|
|
1595
|
+
"homepage.export.csvTruncated",
|
|
1596
|
+
"{count, plural, one {Export # session as CSV} other {Export # sessions as CSV}} (latest {limit, number} sessions only)",
|
|
1597
|
+
exportValues
|
|
1598
|
+
) : t(
|
|
1599
|
+
"homepage.export.csv",
|
|
1600
|
+
"{count, plural, one {Export # session as CSV} other {Export # sessions as CSV}}",
|
|
1601
|
+
exportValues
|
|
1602
|
+
) }),
|
|
1603
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: handleExportJSON, children: truncated ? t(
|
|
1604
|
+
"homepage.export.jsonTruncated",
|
|
1605
|
+
"{count, plural, one {Export # session as JSON} other {Export # sessions as JSON}} (latest {limit, number} sessions only)",
|
|
1606
|
+
exportValues
|
|
1607
|
+
) : t(
|
|
1608
|
+
"homepage.export.json",
|
|
1609
|
+
"{count, plural, one {Export # session as JSON} other {Export # sessions as JSON}}",
|
|
1610
|
+
exportValues
|
|
1611
|
+
) })
|
|
1612
|
+
]
|
|
1613
|
+
}
|
|
1614
|
+
);
|
|
1615
|
+
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 }) });
|
|
1616
|
+
const analyticsLabel = t("homepage.links.analytics", "Analytics");
|
|
1617
|
+
const settingsLabel = t("homepage.links.settings", "Settings");
|
|
1618
|
+
const primaryAction = /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", children: [
|
|
1619
|
+
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(
|
|
1620
|
+
designSystem.LinkButton,
|
|
1621
|
+
{
|
|
1622
|
+
tag: reactRouterDom.Link,
|
|
1623
|
+
to: ANALYTICS_PATH,
|
|
1624
|
+
variant: "tertiary",
|
|
1625
|
+
size: "S",
|
|
1626
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ChartBubble, {}),
|
|
1627
|
+
children: analyticsLabel
|
|
1628
|
+
}
|
|
1629
|
+
),
|
|
1630
|
+
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(
|
|
1631
|
+
designSystem.LinkButton,
|
|
1632
|
+
{
|
|
1633
|
+
tag: reactRouterDom.Link,
|
|
1634
|
+
to: CONFIGURATION_PATH,
|
|
1635
|
+
variant: "tertiary",
|
|
1636
|
+
size: "S",
|
|
1637
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Cog, {}),
|
|
1638
|
+
children: settingsLabel
|
|
1639
|
+
}
|
|
1640
|
+
),
|
|
1641
|
+
exportAction
|
|
1642
|
+
] });
|
|
1643
|
+
const filterSlot = isBelowMedium ? { flex: "1 1 auto", minWidth: 0 } : void 0;
|
|
1644
|
+
const filterControls = /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", wrap: isBelowMedium ? "nowrap" : "wrap", shrink: 0, children: [
|
|
1645
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { ...filterSlot, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1646
|
+
designSystem.SingleSelect,
|
|
1647
|
+
{
|
|
1648
|
+
size: "S",
|
|
1649
|
+
"aria-label": t("homepage.filter.label", "Status"),
|
|
1650
|
+
value: dashboard.status,
|
|
1651
|
+
onChange: handleStatusChange,
|
|
1652
|
+
children: index.SESSION_FILTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelectOption, { value: option, children: [
|
|
1653
|
+
option === "all" && t("homepage.filter.all", "All sessions"),
|
|
1654
|
+
option === "open" && t("homepage.filter.open", "Open"),
|
|
1655
|
+
option !== "all" && option !== "open" && formatters.statusLabel(option)
|
|
1656
|
+
] }, option))
|
|
1657
|
+
}
|
|
1658
|
+
) }),
|
|
1659
|
+
dashboard.status === "ended" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { ...filterSlot, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1660
|
+
designSystem.SingleSelect,
|
|
1661
|
+
{
|
|
1662
|
+
size: "S",
|
|
1663
|
+
"aria-label": t("homepage.filter.reasonLabel", "End reason"),
|
|
1664
|
+
value: dashboard.reason,
|
|
1665
|
+
onChange: handleReasonChange,
|
|
1666
|
+
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))
|
|
1667
|
+
}
|
|
1668
|
+
) }) : null,
|
|
1669
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1670
|
+
designSystem.IconButton,
|
|
1671
|
+
{
|
|
1672
|
+
label: t("homepage.actions.refresh", "Refresh sessions"),
|
|
1673
|
+
onClick: () => fetchSessions(),
|
|
1674
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {})
|
|
1675
|
+
}
|
|
1676
|
+
)
|
|
1677
|
+
] });
|
|
1678
|
+
const toolbar = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-session-toolbar": "", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1679
|
+
designSystem.Flex,
|
|
1680
|
+
{
|
|
1681
|
+
direction: { initial: "column", medium: "row" },
|
|
1682
|
+
alignItems: { initial: "stretch", medium: "center" },
|
|
1683
|
+
gap: 2,
|
|
1684
|
+
children: [
|
|
1685
|
+
/* @__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 }) }),
|
|
1686
|
+
filterControls
|
|
1687
|
+
]
|
|
1688
|
+
}
|
|
1689
|
+
) });
|
|
1690
|
+
const lastUpdatedLine = lastUpdated ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", wrap: "wrap", justifyContent: "flex-end", children: [
|
|
1691
|
+
refreshing ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, role: "status", "aria-live": "polite", children: t("homepage.refreshing", "Updating sessions") }) : null,
|
|
1692
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", "data-last-updated": "", children: t("homepage.lastUpdated", "Last updated {time}", {
|
|
1693
|
+
time: formatters.formatRelativeTime(lastUpdated, now)
|
|
1694
|
+
}) })
|
|
1695
|
+
] }) : null;
|
|
1696
|
+
const listProps = {
|
|
1697
|
+
sessions: pageResult.items,
|
|
1698
|
+
labelledBy: listHeadingId,
|
|
1699
|
+
busy: refreshing,
|
|
1700
|
+
onView: handleSessionClick,
|
|
1701
|
+
onEnd: handleTerminateSession,
|
|
1702
|
+
onDelete: handleDeleteSession,
|
|
1703
|
+
mutationPending,
|
|
1704
|
+
getFocusFallback
|
|
1705
|
+
};
|
|
1706
|
+
const statusCard = (status) => ({
|
|
1707
|
+
onClick: () => handleStatusChange(status),
|
|
1708
|
+
pressed: dashboard.status === status
|
|
1709
|
+
});
|
|
1710
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1711
|
+
index.PageShell,
|
|
1712
|
+
{
|
|
1713
|
+
headingId: "magic-sessionmanager-dashboard-title",
|
|
1714
|
+
title: t("homepage.title", "Sessions"),
|
|
1715
|
+
subtitle: t(
|
|
1716
|
+
"homepage.subtitle",
|
|
1717
|
+
"Sign-ins of your app’s users (Users & Permissions). Strapi administrators are not listed."
|
|
1718
|
+
),
|
|
1719
|
+
primaryAction,
|
|
1720
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1721
|
+
designSystem.Flex,
|
|
1722
|
+
{
|
|
1723
|
+
ref: dashboardRef,
|
|
1724
|
+
tabIndex: -1,
|
|
1725
|
+
direction: "column",
|
|
1726
|
+
alignItems: "stretch",
|
|
1727
|
+
gap: 6,
|
|
1728
|
+
minWidth: 0,
|
|
1729
|
+
children: [
|
|
1730
|
+
!loading && loadError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1731
|
+
index.PersistentAlert,
|
|
1732
|
+
{
|
|
1733
|
+
variant: "danger",
|
|
1734
|
+
closeLabel: t("common.close", "Close"),
|
|
1735
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: fetchSessions, children: t("common.tryAgain", "Try again") }),
|
|
1736
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: t("homepage.error.load", "Sessions could not be loaded.") })
|
|
1737
|
+
}
|
|
1738
|
+
) : null,
|
|
1739
|
+
showSessionData && truncated ? /* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "default", closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "span", children: t(
|
|
1740
|
+
"homepage.truncated.body",
|
|
1741
|
+
"Only the latest {limit, number} sessions are loaded. Counts, filters and exports cover these sessions only.",
|
|
1742
|
+
{ limit: LOADED_SESSIONS_LIMIT }
|
|
1743
|
+
) }) }) : null,
|
|
1744
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: t("homepage.loading", "Loading sessions") }) }) : null,
|
|
1745
|
+
showSessionData && sessions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(HowSessionsWork, {}) : null,
|
|
1746
|
+
showSessionData && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1747
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", children: t("homepage.stats.label", "Session statistics") }) }),
|
|
1748
|
+
/* @__PURE__ */ jsxRuntime.jsxs(index.StatGrid, { label: t("homepage.stats.label", "Session statistics"), children: [
|
|
1749
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1750
|
+
index.StatCard,
|
|
1751
|
+
{
|
|
1752
|
+
icon: icons.Check,
|
|
1753
|
+
tone: "success",
|
|
1754
|
+
label: t("homepage.stats.active", "Active sessions"),
|
|
1755
|
+
value: stats.active,
|
|
1756
|
+
description: t(
|
|
1757
|
+
"homepage.stats.usersOnline",
|
|
1758
|
+
"{count, plural, one {# user online} other {# users online}}",
|
|
1759
|
+
{
|
|
1760
|
+
count: stats.usersOnline
|
|
1761
|
+
}
|
|
1762
|
+
),
|
|
1763
|
+
...statusCard("active")
|
|
1764
|
+
}
|
|
1765
|
+
),
|
|
1766
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1767
|
+
index.StatCard,
|
|
1768
|
+
{
|
|
1769
|
+
icon: icons.Clock,
|
|
1770
|
+
tone: "warning",
|
|
1771
|
+
label: t("homepage.stats.idle", "Idle sessions"),
|
|
1772
|
+
value: stats.idle,
|
|
1773
|
+
...statusCard("idle")
|
|
1774
|
+
}
|
|
1775
|
+
),
|
|
1776
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1777
|
+
index.StatCard,
|
|
1778
|
+
{
|
|
1779
|
+
icon: icons.Cross,
|
|
1780
|
+
tone: "neutral",
|
|
1781
|
+
label: t("homepage.stats.ended", "Ended sessions"),
|
|
1782
|
+
value: stats.ended,
|
|
1783
|
+
description: t(
|
|
1784
|
+
"homepage.stats.endedBreakdown",
|
|
1785
|
+
"{loggedOut, number} logged out · {timedOut, number} timed out · {other, number} other reasons",
|
|
1786
|
+
{
|
|
1787
|
+
loggedOut: stats.loggedOut,
|
|
1788
|
+
timedOut: stats.timedOut,
|
|
1789
|
+
other: stats.otherReasons
|
|
1790
|
+
}
|
|
1791
|
+
),
|
|
1792
|
+
...statusCard("ended")
|
|
1793
|
+
}
|
|
1794
|
+
),
|
|
1795
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1796
|
+
index.StatCard,
|
|
1797
|
+
{
|
|
1798
|
+
icon: icons.User,
|
|
1799
|
+
tone: "primary",
|
|
1800
|
+
label: t("homepage.stats.total", "All sessions"),
|
|
1801
|
+
value: stats.total,
|
|
1802
|
+
...statusCard("all")
|
|
1803
|
+
}
|
|
1804
|
+
)
|
|
1805
|
+
] })
|
|
1806
|
+
] }),
|
|
1807
|
+
showToolbar && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { ref: listWidthRef, direction: "column", alignItems: "stretch", gap: 4, minWidth: 0, children: [
|
|
1808
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h2", children: t("homepage.list.heading", "Session list") }) }),
|
|
1809
|
+
toolbar,
|
|
1810
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", gap: 4, wrap: "wrap", children: [
|
|
1811
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1812
|
+
designSystem.Typography,
|
|
1813
|
+
{
|
|
1814
|
+
id: listHeadingId,
|
|
1815
|
+
ref: listHeadingRef,
|
|
1816
|
+
tabIndex: -1,
|
|
1817
|
+
variant: "pi",
|
|
1818
|
+
textColor: "neutral600",
|
|
1819
|
+
"aria-live": "polite",
|
|
1820
|
+
"data-session-caption": "",
|
|
1821
|
+
children: pageResult.total > 0 ? t(
|
|
1822
|
+
"homepage.caption",
|
|
1823
|
+
"{from, number}–{to, number} of {total, plural, one {# session} other {# sessions}}",
|
|
1824
|
+
{
|
|
1825
|
+
from: pageResult.startIndex,
|
|
1826
|
+
to: pageResult.endIndex,
|
|
1827
|
+
total: pageResult.total
|
|
1828
|
+
}
|
|
1829
|
+
) : t("homepage.captionNone", "0 sessions")
|
|
1830
|
+
}
|
|
1831
|
+
),
|
|
1832
|
+
lastUpdatedLine
|
|
1833
|
+
] }),
|
|
1834
|
+
filteredSessions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1835
|
+
isBelowMedium ? /* @__PURE__ */ jsxRuntime.jsx(SessionCardList, { ...listProps }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1836
|
+
SessionTable,
|
|
1837
|
+
{
|
|
1838
|
+
...listProps,
|
|
1839
|
+
compact: shouldUseCompactTable(listWidth, isBelowLarge)
|
|
1840
|
+
}
|
|
1841
|
+
),
|
|
1842
|
+
/* @__PURE__ */ jsxRuntime.jsx(PaginationTargets, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1843
|
+
StrapiAdmin.Pagination.Root,
|
|
1844
|
+
{
|
|
1845
|
+
pageCount: pageResult.pageCount,
|
|
1846
|
+
total: pageResult.total,
|
|
1847
|
+
defaultPageSize: Number(DEFAULT_PAGE_SIZE),
|
|
1848
|
+
children: [
|
|
1849
|
+
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...PAGE_SIZE_OPTIONS] }),
|
|
1850
|
+
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.Links, {})
|
|
1851
|
+
]
|
|
1852
|
+
}
|
|
1853
|
+
) })
|
|
1854
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1855
|
+
designSystem.EmptyStateLayout,
|
|
1856
|
+
{
|
|
1857
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
|
|
1858
|
+
content: t(
|
|
1859
|
+
"homepage.noResults.description",
|
|
1860
|
+
"No sessions match your search or filter."
|
|
1861
|
+
),
|
|
1862
|
+
action: filtersActive ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: handleClearFilters, children: t("homepage.noResults.reset", "Clear filters") }) : null
|
|
1863
|
+
}
|
|
1864
|
+
)
|
|
1865
|
+
] }),
|
|
1866
|
+
showSessionData && sessions.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1867
|
+
designSystem.EmptyStateLayout,
|
|
1868
|
+
{
|
|
1869
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
|
|
1870
|
+
content: t(
|
|
1871
|
+
"homepage.empty.description",
|
|
1872
|
+
"No sessions yet. Sessions appear here when users of your app sign in."
|
|
1873
|
+
)
|
|
1874
|
+
}
|
|
1875
|
+
),
|
|
1876
|
+
showDetailModal && selectedSession && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1877
|
+
SessionDetailModal,
|
|
1878
|
+
{
|
|
1879
|
+
session: selectedSession,
|
|
1880
|
+
now,
|
|
1881
|
+
onClose: handleModalClose,
|
|
1882
|
+
onCloseAutoFocus: handleCloseAutoFocus,
|
|
1883
|
+
onEndSession: handleTerminateSession
|
|
1884
|
+
}
|
|
1885
|
+
)
|
|
1886
|
+
]
|
|
1887
|
+
}
|
|
1888
|
+
)
|
|
1889
|
+
}
|
|
1890
|
+
);
|
|
1891
|
+
};
|
|
1892
|
+
const LicenseGuard = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
1893
|
+
const App = () => {
|
|
1894
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Page.Protect, { permissions: index.pluginPermissions.access, children: /* @__PURE__ */ jsxRuntime.jsx(LicenseGuard, { children: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) }) });
|
|
1895
|
+
};
|
|
1896
|
+
exports.default = App;
|