strapi-plugin-magic-sessionmanager 4.16.0 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/README.md +84 -36
- package/dist/admin/{Analytics-D4gsVwL0.mjs → Analytics-B-p2Q7th.mjs} +1 -1
- package/dist/admin/{Analytics-me4qzS0I.js → Analytics-BTIByTUY.js} +1 -1
- package/dist/admin/{App-BTG-2Q26.js → App-CH6635JB.js} +112 -184
- package/dist/admin/{App-BJwtFWxl.mjs → App-DmesuM2g.mjs} +82 -154
- package/dist/admin/{OnlineUsersWidget-Yd283YDy.mjs → OnlineUsersWidget-CuqeQ0tb.mjs} +1 -1
- package/dist/admin/{OnlineUsersWidget-DYS3Vy1Q.js → OnlineUsersWidget-TlOp8nie.js} +1 -1
- package/dist/admin/{Settings-DIlvfdjZ.mjs → Settings-C4IgGBjQ.mjs} +1347 -109
- package/dist/admin/{Settings-TPZ9_75s.js → Settings-DtP_H4JS.js} +1351 -113
- package/dist/admin/dashboardModel-0ROcWcB1.mjs +189 -0
- package/dist/admin/dashboardModel-BSJhZdXI.js +188 -0
- package/dist/admin/{de-DB9ldYwN.mjs → de-BoahnYIP.mjs} +126 -11
- package/dist/admin/{de-BuMw1gBJ.js → de-C_ooq6EF.js} +126 -11
- package/dist/admin/{en-BqGhOJDy.js → en-CuUVE2K0.js} +126 -11
- package/dist/admin/{en-BbLMPQB3.mjs → en-DHme92L-.mjs} +126 -11
- package/dist/admin/{es-C5iaiE9G.mjs → es-CjcTgS9Z.mjs} +126 -11
- package/dist/admin/{es-BaIeckl9.js → es-lbDNXcQi.js} +126 -11
- package/dist/admin/{fr-BEvBUCwI.mjs → fr-BPwnrSaC.mjs} +126 -11
- package/dist/admin/{fr-D1YKyTex.js → fr-RtypjgGp.js} +126 -11
- package/dist/admin/{index-DUESEUaO.mjs → index-B102RF2H.mjs} +45 -38
- package/dist/admin/{index-CgZiLcJ1.js → index-w0OuPYFm.js} +17 -10
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-DtnW-s0V.js → pt-BMCAKRQ4.js} +126 -11
- package/dist/admin/{pt-DeDih9cR.mjs → pt-D5FHSP2y.mjs} +126 -11
- package/dist/server/index.js +3577 -1293
- package/dist/server/index.mjs +3577 -1293
- package/package.json +1 -1
- package/dist/admin/riskData-BVs9GpgD.js +0 -26
- package/dist/admin/riskData-CI1gm2yI.mjs +0 -27
|
@@ -9,8 +9,8 @@ const designSystem = require("@strapi/design-system");
|
|
|
9
9
|
const icons = require("@strapi/icons");
|
|
10
10
|
const symbols = require("@strapi/icons/symbols");
|
|
11
11
|
const styled = require("styled-components");
|
|
12
|
-
const index = require("./index-
|
|
13
|
-
const
|
|
12
|
+
const index = require("./index-w0OuPYFm.js");
|
|
13
|
+
const dashboardModel = require("./dashboardModel-BSJhZdXI.js");
|
|
14
14
|
const SectionCard = require("./SectionCard-BlWv8CRt.js");
|
|
15
15
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
16
16
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
@@ -25,7 +25,6 @@ const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800
|
|
|
25
25
|
});
|
|
26
26
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant, textColor, "data-end-reason": presentation.reason, children: translate(presentation) });
|
|
27
27
|
};
|
|
28
|
-
const RowActions = ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", alignItems: "center", gap: 1, "data-row-actions": "", ...props, children });
|
|
29
28
|
const MAX_EXPORT_ROWS = 5e4;
|
|
30
29
|
const EXPORT_BATCH_SIZE = 1e3;
|
|
31
30
|
const EMPTY_SESSION_STATS = Object.freeze({
|
|
@@ -111,7 +110,7 @@ const CSV_HEADERS = Object.freeze([
|
|
|
111
110
|
"Minutes Idle",
|
|
112
111
|
"End Reason"
|
|
113
112
|
]);
|
|
114
|
-
const FORMULA_START = /^[=+\-@\t\r]/;
|
|
113
|
+
const FORMULA_START = /^[\s\u00ad\u200b-\u200f\u2060-\u2064\ufeff]*[=+\-@\uff1d\uff0b\uff0d\uff20\t\r\n]/;
|
|
115
114
|
const escapeCsvValue = (value) => {
|
|
116
115
|
const text = String(value ?? "");
|
|
117
116
|
const safe = typeof value === "string" && FORMULA_START.test(text) ? `'${text}` : text;
|
|
@@ -260,23 +259,6 @@ function useBreakpoint() {
|
|
|
260
259
|
isBelowLarge: isBelowBreakpoint(breakpoint, "large")
|
|
261
260
|
};
|
|
262
261
|
}
|
|
263
|
-
function useElementWidth() {
|
|
264
|
-
const [width, setWidth] = react.useState(0);
|
|
265
|
-
const observerRef = react.useRef(null);
|
|
266
|
-
const ref = react.useCallback((node) => {
|
|
267
|
-
observerRef.current?.disconnect();
|
|
268
|
-
observerRef.current = null;
|
|
269
|
-
if (!node || typeof ResizeObserver === "undefined") return;
|
|
270
|
-
const observer = new ResizeObserver((entries) => {
|
|
271
|
-
const next = Math.round(entries[0]?.contentRect?.width || 0);
|
|
272
|
-
setWidth((previous) => previous === next ? previous : next);
|
|
273
|
-
});
|
|
274
|
-
observer.observe(node);
|
|
275
|
-
observerRef.current = observer;
|
|
276
|
-
}, []);
|
|
277
|
-
react.useEffect(() => () => observerRef.current?.disconnect(), []);
|
|
278
|
-
return [ref, width];
|
|
279
|
-
}
|
|
280
262
|
const RISK_LEVEL_MESSAGES = Object.freeze({
|
|
281
263
|
none: Object.freeze({ messageId: "modal.security.risk.none", defaultMessage: "None" }),
|
|
282
264
|
low: Object.freeze({ messageId: "modal.security.risk.low", defaultMessage: "Low" }),
|
|
@@ -307,7 +289,7 @@ function normalizeGeoData(geo, fallback = {}) {
|
|
|
307
289
|
const city = index.presentText(geo.city);
|
|
308
290
|
const timezone = index.presentText(geo.timezone);
|
|
309
291
|
if (!country && !city && !timezone) return null;
|
|
310
|
-
const riskSource =
|
|
292
|
+
const riskSource = dashboardModel.isRiskSource(geo.riskSource) ? geo.riskSource : null;
|
|
311
293
|
const rawScore = typeof geo.securityScore === "number" ? geo.securityScore : fallback?.securityScore;
|
|
312
294
|
const securityScore = riskSource && typeof rawScore === "number" && Number.isFinite(rawScore) ? rawScore : null;
|
|
313
295
|
return {
|
|
@@ -353,125 +335,6 @@ function interpretLookupResult(payload) {
|
|
|
353
335
|
const geo = normalizeGeoData(data);
|
|
354
336
|
return geo ? { status: "ok", geo } : { status: "failed", geo: null };
|
|
355
337
|
}
|
|
356
|
-
const PAGE_SIZE_OPTIONS = Object.freeze(["10", "25", "50", "100"]);
|
|
357
|
-
const DEFAULT_PAGE_SIZE = "25";
|
|
358
|
-
const DASHBOARD_TABLE_COLUMNS = 7;
|
|
359
|
-
const DASHBOARD_COMPACT_TABLE_COLUMNS = 5;
|
|
360
|
-
const AUTO_REFRESH_INTERVAL_MS = 10 * 60 * 1e3;
|
|
361
|
-
const HOW_IT_WORKS_STORAGE_KEY = "magic-sessionmanager.dashboard.howSessionsWork";
|
|
362
|
-
const USER_EDIT_PATH = "/content-manager/collection-types/plugin::users-permissions.user/";
|
|
363
|
-
const readQueryText = (value) => {
|
|
364
|
-
if (typeof value !== "string") return "";
|
|
365
|
-
try {
|
|
366
|
-
return decodeURIComponent(value).trim();
|
|
367
|
-
} catch {
|
|
368
|
-
return value.trim();
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
function parseDashboardQuery(query = {}) {
|
|
372
|
-
const source = query || {};
|
|
373
|
-
const page = Number.parseInt(String(source.page ?? "1"), 10);
|
|
374
|
-
const pageSize = PAGE_SIZE_OPTIONS.includes(String(source.pageSize)) ? String(source.pageSize) : DEFAULT_PAGE_SIZE;
|
|
375
|
-
const status = index.isSessionFilter(source.status) ? (
|
|
376
|
-
/** @type {string} */
|
|
377
|
-
source.status
|
|
378
|
-
) : index.DEFAULT_SESSION_FILTER;
|
|
379
|
-
const reason = status === "ended" && index.isEndReasonFilter(source.reason) ? (
|
|
380
|
-
/** @type {string} */
|
|
381
|
-
source.reason
|
|
382
|
-
) : index.DEFAULT_END_REASON_FILTER;
|
|
383
|
-
const search = readQueryText(source.search) || readQueryText(source._q);
|
|
384
|
-
return { page: Number.isFinite(page) && page >= 1 ? page : 1, pageSize, status, reason, search };
|
|
385
|
-
}
|
|
386
|
-
function encodeSearchQuery(value) {
|
|
387
|
-
const text = typeof value === "string" ? value.trim() : "";
|
|
388
|
-
return text ? encodeURIComponent(text) : void 0;
|
|
389
|
-
}
|
|
390
|
-
function hasActiveFilters(state) {
|
|
391
|
-
if (!state) return false;
|
|
392
|
-
return state.status !== index.DEFAULT_SESSION_FILTER || Boolean(state.reason) && state.reason !== index.DEFAULT_END_REASON_FILTER || Boolean(state.search);
|
|
393
|
-
}
|
|
394
|
-
function getSessionUserLabels(session) {
|
|
395
|
-
const username = index.presentText(session?.user?.username);
|
|
396
|
-
const email = index.presentText(session?.user?.email);
|
|
397
|
-
const primary = username || email;
|
|
398
|
-
return {
|
|
399
|
-
primary,
|
|
400
|
-
secondary: username && email ? email : "",
|
|
401
|
-
accessible: primary || index.presentText(session?.id)
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
function getUserEditPath(session) {
|
|
405
|
-
const documentId = index.presentText(session?.user?.documentId);
|
|
406
|
-
return documentId ? `${USER_EDIT_PATH}${encodeURIComponent(documentId)}` : null;
|
|
407
|
-
}
|
|
408
|
-
function getExportDeviceInfo(session, unavailableValue = "") {
|
|
409
|
-
const device = index.getDevicePresentation(session);
|
|
410
|
-
return {
|
|
411
|
-
device: device.deviceType || unavailableValue,
|
|
412
|
-
browser: device.browser || unavailableValue,
|
|
413
|
-
browserVersion: device.browserVersion || "",
|
|
414
|
-
os: device.os || unavailableValue
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
function readDisclosureOpen(storage) {
|
|
418
|
-
try {
|
|
419
|
-
return storage?.getItem(HOW_IT_WORKS_STORAGE_KEY) === "open";
|
|
420
|
-
} catch {
|
|
421
|
-
return false;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
function writeDisclosureOpen(storage, open) {
|
|
425
|
-
try {
|
|
426
|
-
storage?.setItem(HOW_IT_WORKS_STORAGE_KEY, open ? "open" : "closed");
|
|
427
|
-
} catch {
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
function getBrowserStorage() {
|
|
431
|
-
try {
|
|
432
|
-
return typeof window !== "undefined" ? window.localStorage : null;
|
|
433
|
-
} catch {
|
|
434
|
-
return null;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
function shouldIsolateActionKey(key, fromInsideGroup) {
|
|
438
|
-
if (!fromInsideGroup) return true;
|
|
439
|
-
return key === "Enter" || key === " " || key === "Spacebar";
|
|
440
|
-
}
|
|
441
|
-
const FULL_TABLE_MIN_WIDTH = 1200;
|
|
442
|
-
function shouldUseCompactTable(listWidth, isBelowLarge) {
|
|
443
|
-
if (isBelowLarge) return true;
|
|
444
|
-
if (!Number.isFinite(listWidth) || listWidth <= 0) return false;
|
|
445
|
-
return listWidth < FULL_TABLE_MIN_WIDTH;
|
|
446
|
-
}
|
|
447
|
-
function shouldRedispatchEscape(key, fromInsideGroup) {
|
|
448
|
-
return !fromInsideGroup && key === "Escape";
|
|
449
|
-
}
|
|
450
|
-
function pickFocusSessionId(previousIds, currentIds, sessionId) {
|
|
451
|
-
const current = Array.isArray(currentIds) ? currentIds.map(String) : [];
|
|
452
|
-
if (current.length === 0) return null;
|
|
453
|
-
const target = String(sessionId);
|
|
454
|
-
if (current.includes(target)) return target;
|
|
455
|
-
const previous = Array.isArray(previousIds) ? previousIds.map(String) : [];
|
|
456
|
-
const index2 = previous.indexOf(target);
|
|
457
|
-
if (index2 >= 0) {
|
|
458
|
-
for (let next = index2 + 1; next < previous.length; next += 1) {
|
|
459
|
-
if (current.includes(previous[next])) return previous[next];
|
|
460
|
-
}
|
|
461
|
-
for (let before = index2 - 1; before >= 0; before -= 1) {
|
|
462
|
-
if (current.includes(previous[before])) return previous[before];
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
return current[0];
|
|
466
|
-
}
|
|
467
|
-
function getErrorStatus(error) {
|
|
468
|
-
const err = (
|
|
469
|
-
/** @type {any} */
|
|
470
|
-
error
|
|
471
|
-
);
|
|
472
|
-
const status = err?.status ?? err?.response?.status;
|
|
473
|
-
return typeof status === "number" ? status : null;
|
|
474
|
-
}
|
|
475
338
|
const TargetLink = styled__default.default(designSystem.Link)`
|
|
476
339
|
min-height: 3.2rem;
|
|
477
340
|
display: inline-flex;
|
|
@@ -517,8 +380,8 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
|
|
|
517
380
|
const userAgent = index.presentText(session.userAgent);
|
|
518
381
|
const sessionId = index.presentText(session.id);
|
|
519
382
|
const ipAddress = index.presentText(session.ipAddress);
|
|
520
|
-
const user = getSessionUserLabels(session);
|
|
521
|
-
const userEditPath = getUserEditPath(session);
|
|
383
|
+
const user = dashboardModel.getSessionUserLabels(session);
|
|
384
|
+
const userEditPath = dashboardModel.getUserEditPath(session);
|
|
522
385
|
const storedGeo = getStoredGeoData(session);
|
|
523
386
|
const liveGeo = lookup.status === "ok" ? lookup.geo : null;
|
|
524
387
|
const geo = liveGeo || storedGeo;
|
|
@@ -750,7 +613,7 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
|
|
|
750
613
|
"modal.security.riskUnavailableNote",
|
|
751
614
|
"Needs a risk data source. Location data alone cannot tell VPNs, proxies or Tor apart, so no score was calculated."
|
|
752
615
|
) }),
|
|
753
|
-
/* @__PURE__ */ jsxRuntime.jsx(TargetLink, { tag: reactRouterDom.NavLink, to:
|
|
616
|
+
/* @__PURE__ */ jsxRuntime.jsx(TargetLink, { tag: reactRouterDom.NavLink, to: dashboardModel.RISK_SETTINGS_PATH, children: t("modal.security.riskSetup", "Set up risk data") })
|
|
754
617
|
] }) : null,
|
|
755
618
|
lookupControls
|
|
756
619
|
] }),
|
|
@@ -893,9 +756,9 @@ const isolateActionKeys = (event) => {
|
|
|
893
756
|
/** @type {Node} */
|
|
894
757
|
event.target
|
|
895
758
|
);
|
|
896
|
-
if (!shouldIsolateActionKey(event.key, fromInsideGroup)) return;
|
|
759
|
+
if (!dashboardModel.shouldIsolateActionKey(event.key, fromInsideGroup)) return;
|
|
897
760
|
event.stopPropagation();
|
|
898
|
-
if (shouldRedispatchEscape(event.key, fromInsideGroup)) {
|
|
761
|
+
if (dashboardModel.shouldRedispatchEscape(event.key, fromInsideGroup)) {
|
|
899
762
|
const { ownerDocument } = event.currentTarget;
|
|
900
763
|
ownerDocument.dispatchEvent(
|
|
901
764
|
new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true })
|
|
@@ -943,7 +806,7 @@ const SessionActions = ({
|
|
|
943
806
|
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
944
807
|
const [deleteOpen, setDeleteOpen] = react.useState(false);
|
|
945
808
|
const moreRef = react.useRef(null);
|
|
946
|
-
const user = getSessionUserLabels(session).accessible;
|
|
809
|
+
const user = dashboardModel.getSessionUserLabels(session).accessible;
|
|
947
810
|
const canEnd = session.isActive === true;
|
|
948
811
|
const device = deviceSummary(session) || deviceTypeLabel(session);
|
|
949
812
|
const copy = getConfirmationCopy(t, { user, device, isOpen: canEnd });
|
|
@@ -970,7 +833,7 @@ const SessionActions = ({
|
|
|
970
833
|
);
|
|
971
834
|
const endKey = `end-${session.id}-${canEnd ? "open" : "ended"}`;
|
|
972
835
|
if (layout === "table") {
|
|
973
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RowActions, { onKeyDown: isolateActionKeys, onClick: (event) => event.stopPropagation(), children: [
|
|
836
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(dashboardModel.RowActions, { onKeyDown: isolateActionKeys, onClick: (event) => event.stopPropagation(), children: [
|
|
974
837
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
975
838
|
designSystem.IconButton,
|
|
976
839
|
{
|
|
@@ -1111,7 +974,7 @@ const SessionTable = ({
|
|
|
1111
974
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1112
975
|
designSystem.Table,
|
|
1113
976
|
{
|
|
1114
|
-
colCount: compact ? DASHBOARD_COMPACT_TABLE_COLUMNS : DASHBOARD_TABLE_COLUMNS,
|
|
977
|
+
colCount: compact ? dashboardModel.DASHBOARD_COMPACT_TABLE_COLUMNS : dashboardModel.DASHBOARD_TABLE_COLUMNS,
|
|
1115
978
|
rowCount: sessions.length + 1,
|
|
1116
979
|
"aria-labelledby": labelledBy,
|
|
1117
980
|
"aria-busy": busy,
|
|
@@ -1126,7 +989,7 @@ const SessionTable = ({
|
|
|
1126
989
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("homepage.table.actions", "Actions") }) })
|
|
1127
990
|
] }) }),
|
|
1128
991
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: sessions.map((session) => {
|
|
1129
|
-
const user = getSessionUserLabels(session);
|
|
992
|
+
const user = dashboardModel.getSessionUserLabels(session);
|
|
1130
993
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1131
994
|
designSystem.Tr,
|
|
1132
995
|
{
|
|
@@ -1202,7 +1065,7 @@ const SessionCardList = ({
|
|
|
1202
1065
|
mutationPending,
|
|
1203
1066
|
getFocusFallback
|
|
1204
1067
|
}) => /* @__PURE__ */ jsxRuntime.jsx(CardList, { "aria-labelledby": labelledBy, "aria-busy": busy, children: sessions.map((session) => {
|
|
1205
|
-
const user = getSessionUserLabels(session);
|
|
1068
|
+
const user = dashboardModel.getSessionUserLabels(session);
|
|
1206
1069
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1207
1070
|
designSystem.Box,
|
|
1208
1071
|
{
|
|
@@ -1338,12 +1201,12 @@ const Legend = styled__default.default.ul`
|
|
|
1338
1201
|
const HowSessionsWork = () => {
|
|
1339
1202
|
const { formatMessage } = reactIntl.useIntl();
|
|
1340
1203
|
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1341
|
-
const [open, setOpen] = react.useState(() => readDisclosureOpen(getBrowserStorage()));
|
|
1204
|
+
const [open, setOpen] = react.useState(() => dashboardModel.readDisclosureOpen(dashboardModel.getBrowserStorage()));
|
|
1342
1205
|
const contentId = `how-sessions-work-${react.useId().replace(/:/g, "")}`;
|
|
1343
1206
|
const toggle = () => {
|
|
1344
1207
|
setOpen((previous) => {
|
|
1345
1208
|
const next = !previous;
|
|
1346
|
-
writeDisclosureOpen(getBrowserStorage(), next);
|
|
1209
|
+
dashboardModel.writeDisclosureOpen(dashboardModel.getBrowserStorage(), next);
|
|
1347
1210
|
return next;
|
|
1348
1211
|
});
|
|
1349
1212
|
};
|
|
@@ -1844,10 +1707,10 @@ const HomePage = () => {
|
|
|
1844
1707
|
const { toggleNotification } = StrapiAdmin.useNotification();
|
|
1845
1708
|
const formatters = index.useSessionFormatters();
|
|
1846
1709
|
const { isBelowSmall, isBelowMedium, isBelowLarge } = useBreakpoint();
|
|
1847
|
-
const [listWidthRef, listWidth] = useElementWidth();
|
|
1710
|
+
const [listWidthRef, listWidth] = dashboardModel.useElementWidth();
|
|
1848
1711
|
const [{ query }, setQuery] = StrapiAdmin.useQueryParams();
|
|
1849
1712
|
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1850
|
-
const dashboard = parseDashboardQuery(query);
|
|
1713
|
+
const dashboard = dashboardModel.parseDashboardQuery(query);
|
|
1851
1714
|
const [sessions, setSessions] = react.useState([]);
|
|
1852
1715
|
const [pagination, setPagination] = react.useState({ total: 0, pageCount: 1 });
|
|
1853
1716
|
const [stats, setStats] = react.useState(EMPTY_SESSION_STATS);
|
|
@@ -1924,7 +1787,7 @@ const HomePage = () => {
|
|
|
1924
1787
|
if (showDetailModal || mutationPending) return void 0;
|
|
1925
1788
|
const interval = setInterval(() => {
|
|
1926
1789
|
fetchSessions();
|
|
1927
|
-
}, AUTO_REFRESH_INTERVAL_MS);
|
|
1790
|
+
}, dashboardModel.AUTO_REFRESH_INTERVAL_MS);
|
|
1928
1791
|
return () => clearInterval(interval);
|
|
1929
1792
|
}, [showDetailModal, mutationPending, fetchSessions]);
|
|
1930
1793
|
const handleTerminateSession = async (session) => {
|
|
@@ -1941,7 +1804,7 @@ const HomePage = () => {
|
|
|
1941
1804
|
});
|
|
1942
1805
|
} catch (err) {
|
|
1943
1806
|
index.logSafeAdminError("dashboard.terminateSession", err);
|
|
1944
|
-
if (getErrorStatus(err) === 404) {
|
|
1807
|
+
if (dashboardModel.getErrorStatus(err) === 404) {
|
|
1945
1808
|
await fetchSessions();
|
|
1946
1809
|
toggleNotification({
|
|
1947
1810
|
type: "warning",
|
|
@@ -1981,7 +1844,7 @@ const HomePage = () => {
|
|
|
1981
1844
|
});
|
|
1982
1845
|
} catch (err) {
|
|
1983
1846
|
index.logSafeAdminError("dashboard.deleteSession", err);
|
|
1984
|
-
if (getErrorStatus(err) === 404) {
|
|
1847
|
+
if (dashboardModel.getErrorStatus(err) === 404) {
|
|
1985
1848
|
await fetchSessions();
|
|
1986
1849
|
toggleNotification({
|
|
1987
1850
|
type: "warning",
|
|
@@ -2037,7 +1900,7 @@ const HomePage = () => {
|
|
|
2037
1900
|
if (format === "csv") {
|
|
2038
1901
|
const csvContent = buildSessionCsv(rows, {
|
|
2039
1902
|
unavailableValue: "",
|
|
2040
|
-
getDeviceInfo: getExportDeviceInfo,
|
|
1903
|
+
getDeviceInfo: dashboardModel.getExportDeviceInfo,
|
|
2041
1904
|
getSessionStatus: index.getSessionStatus
|
|
2042
1905
|
});
|
|
2043
1906
|
downloadFile(csvContent, "text/csv;charset=utf-8;", "csv");
|
|
@@ -2047,7 +1910,7 @@ const HomePage = () => {
|
|
|
2047
1910
|
totalSessions: stats.total,
|
|
2048
1911
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2049
1912
|
unavailableValue: "",
|
|
2050
|
-
getDeviceInfo: getExportDeviceInfo,
|
|
1913
|
+
getDeviceInfo: dashboardModel.getExportDeviceInfo,
|
|
2051
1914
|
getSessionStatus: index.getSessionStatus,
|
|
2052
1915
|
truncated: capped
|
|
2053
1916
|
});
|
|
@@ -2089,7 +1952,7 @@ const HomePage = () => {
|
|
|
2089
1952
|
const getFocusFallback = react.useCallback(
|
|
2090
1953
|
(sessionId) => ({
|
|
2091
1954
|
get current() {
|
|
2092
|
-
const targetId = pickFocusSessionId(
|
|
1955
|
+
const targetId = dashboardModel.pickFocusSessionId(
|
|
2093
1956
|
mutationSnapshotRef.current,
|
|
2094
1957
|
visibleIdsRef.current,
|
|
2095
1958
|
sessionId
|
|
@@ -2120,7 +1983,7 @@ const HomePage = () => {
|
|
|
2120
1983
|
};
|
|
2121
1984
|
const handleSearch = react.useCallback(
|
|
2122
1985
|
(value) => {
|
|
2123
|
-
setQuery({ search: encodeSearchQuery(value), _q: void 0, page: "1" }, "push", true);
|
|
1986
|
+
setQuery({ search: dashboardModel.encodeSearchQuery(value), _q: void 0, page: "1" }, "push", true);
|
|
2124
1987
|
},
|
|
2125
1988
|
[setQuery]
|
|
2126
1989
|
);
|
|
@@ -2131,7 +1994,7 @@ const HomePage = () => {
|
|
|
2131
1994
|
const showSessionData = !loading && hasData;
|
|
2132
1995
|
const showToolbar = showSessionData && stats.total > 0;
|
|
2133
1996
|
const canExport = showSessionData && pageResult.total > 0 && !exporting;
|
|
2134
|
-
const filtersActive = hasActiveFilters(dashboard);
|
|
1997
|
+
const filtersActive = dashboardModel.hasActiveFilters(dashboard);
|
|
2135
1998
|
const exportValues = { count: Math.min(pageResult.total, MAX_EXPORT_ROWS) };
|
|
2136
1999
|
const exportMenu = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2137
2000
|
designSystem.SimpleMenu,
|
|
@@ -2382,7 +2245,7 @@ const HomePage = () => {
|
|
|
2382
2245
|
SessionTable,
|
|
2383
2246
|
{
|
|
2384
2247
|
...listProps,
|
|
2385
|
-
compact: shouldUseCompactTable(listWidth, isBelowLarge)
|
|
2248
|
+
compact: dashboardModel.shouldUseCompactTable(listWidth, isBelowLarge)
|
|
2386
2249
|
}
|
|
2387
2250
|
),
|
|
2388
2251
|
/* @__PURE__ */ jsxRuntime.jsx(PaginationTargets$1, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2390,9 +2253,9 @@ const HomePage = () => {
|
|
|
2390
2253
|
{
|
|
2391
2254
|
pageCount: pageResult.pageCount,
|
|
2392
2255
|
total: pageResult.total,
|
|
2393
|
-
defaultPageSize: Number(DEFAULT_PAGE_SIZE),
|
|
2256
|
+
defaultPageSize: Number(dashboardModel.DEFAULT_PAGE_SIZE),
|
|
2394
2257
|
children: [
|
|
2395
|
-
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...PAGE_SIZE_OPTIONS] }),
|
|
2258
|
+
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.PageSize, { options: [...dashboardModel.PAGE_SIZE_OPTIONS] }),
|
|
2396
2259
|
/* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Pagination.Links, {})
|
|
2397
2260
|
]
|
|
2398
2261
|
}
|
|
@@ -2561,9 +2424,28 @@ function getSignOutErrorMessage(error) {
|
|
|
2561
2424
|
defaultMessage: "The admin could not be signed out. Try again."
|
|
2562
2425
|
};
|
|
2563
2426
|
}
|
|
2427
|
+
function withIdentityPlaceholders(admin, placeholderName, identity) {
|
|
2428
|
+
if (!admin || typeof admin !== "object") return admin;
|
|
2429
|
+
const hidden = !admin.self && !admin.name;
|
|
2430
|
+
return {
|
|
2431
|
+
...admin,
|
|
2432
|
+
name: admin.name || placeholderName(admin.id),
|
|
2433
|
+
identityHidden: hidden,
|
|
2434
|
+
rolesHidden: hidden && identity?.roles === false
|
|
2435
|
+
};
|
|
2436
|
+
}
|
|
2437
|
+
function withEventAdminNames(row, placeholderName) {
|
|
2438
|
+
if (!row || typeof row !== "object") return row;
|
|
2439
|
+
const fill = (admin) => admin && typeof admin === "object" && !admin.name ? { ...admin, name: placeholderName(admin.id), identityHidden: true } : admin;
|
|
2440
|
+
return {
|
|
2441
|
+
...row,
|
|
2442
|
+
...row.admin !== void 0 ? { admin: fill(row.admin) } : {},
|
|
2443
|
+
...row.actor !== void 0 ? { actor: fill(row.actor) } : {}
|
|
2444
|
+
};
|
|
2445
|
+
}
|
|
2564
2446
|
const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
|
|
2565
2447
|
const keepActionKeys = (event) => {
|
|
2566
|
-
if (shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2448
|
+
if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2567
2449
|
};
|
|
2568
2450
|
const SHRINKING_ADMIN_CELL = { maxWidth: 0, width: "34%" };
|
|
2569
2451
|
const SHRINKING_ROLES_CELL = { maxWidth: 0, width: "22%" };
|
|
@@ -2588,13 +2470,13 @@ const AdminIdentity = ({ admin }) => {
|
|
|
2588
2470
|
),
|
|
2589
2471
|
admin.self ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...HIGHLIGHT_BADGE, shrink: 0, children: t("adminPanel.you", "You") }) : null
|
|
2590
2472
|
] }),
|
|
2591
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, title: admin.email, children: admin.email })
|
|
2473
|
+
admin.identityHidden ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("adminPanel.identity.emailHidden", "Email hidden (needs “Read” on Users)") }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, title: admin.email, children: admin.email })
|
|
2592
2474
|
] });
|
|
2593
2475
|
};
|
|
2594
2476
|
const AdminRoles = ({ admin }) => {
|
|
2595
2477
|
const t = useT$3();
|
|
2596
2478
|
const names = (admin.roles || []).map((role) => role.name).filter(Boolean);
|
|
2597
|
-
const text = names.length ? names.join(", ") : t("adminPanel.roles.none", "No role");
|
|
2479
|
+
const text = admin.rolesHidden ? t("adminPanel.roles.hidden", "Hidden (needs “Read” on Roles)") : names.length ? names.join(", ") : t("adminPanel.roles.none", "No role");
|
|
2598
2480
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", ellipsis: true, title: text, children: text });
|
|
2599
2481
|
};
|
|
2600
2482
|
const AdminStatus = ({ admin }) => {
|
|
@@ -2634,7 +2516,7 @@ const AdminTable = ({
|
|
|
2634
2516
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: SHRINKING_ROLES_CELL, children: /* @__PURE__ */ jsxRuntime.jsx(AdminRoles, { admin }) }),
|
|
2635
2517
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(AdminStatus, { admin }) }),
|
|
2636
2518
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LastActive, { value: admin.lastActiveAt }) }),
|
|
2637
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(RowActions, { onKeyDown: keepActionKeys, children: [
|
|
2519
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: [
|
|
2638
2520
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2639
2521
|
designSystem.IconButton,
|
|
2640
2522
|
{
|
|
@@ -3018,6 +2900,15 @@ const SignInEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
|
|
|
3018
2900
|
}
|
|
3019
2901
|
if (row.actor)
|
|
3020
2902
|
facts.push(t("adminPanel.activity.byAdmin", "by {name}", { name: row.actor.name }));
|
|
2903
|
+
if (Number.isInteger(row.attempts) && row.attempts > 1) {
|
|
2904
|
+
facts.push(
|
|
2905
|
+
t(
|
|
2906
|
+
"adminPanel.activity.attempts",
|
|
2907
|
+
"{count, plural, one {# attempt} other {# attempts}} within 5 minutes",
|
|
2908
|
+
{ count: row.attempts }
|
|
2909
|
+
)
|
|
2910
|
+
);
|
|
2911
|
+
}
|
|
3021
2912
|
return /* @__PURE__ */ jsxRuntime.jsxs(EventItem, { id: row.id, kind: event.key, children: [
|
|
3022
2913
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", justifyContent: "space-between", children: [
|
|
3023
2914
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
|
|
@@ -3067,6 +2958,22 @@ const ActivityEventRow = ({ row, showAdmin = false, onOpenAdmin }) => {
|
|
|
3067
2958
|
};
|
|
3068
2959
|
function useEventList({ path, params, logKey }) {
|
|
3069
2960
|
const { get } = StrapiAdmin.useFetchClient();
|
|
2961
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
2962
|
+
const fillNames = react.useCallback(
|
|
2963
|
+
(list) => list.map(
|
|
2964
|
+
(row) => withEventAdminNames(
|
|
2965
|
+
row,
|
|
2966
|
+
(id) => formatMessage(
|
|
2967
|
+
{
|
|
2968
|
+
id: index.getTranslation("adminPanel.identity.placeholder"),
|
|
2969
|
+
defaultMessage: "Admin #{id}"
|
|
2970
|
+
},
|
|
2971
|
+
{ id }
|
|
2972
|
+
)
|
|
2973
|
+
)
|
|
2974
|
+
),
|
|
2975
|
+
[formatMessage]
|
|
2976
|
+
);
|
|
3070
2977
|
const [rows, setRows] = react.useState([]);
|
|
3071
2978
|
const [meta, setMeta] = react.useState(null);
|
|
3072
2979
|
const [page, setPage] = react.useState(1);
|
|
@@ -3085,7 +2992,7 @@ function useEventList({ path, params, logKey }) {
|
|
|
3085
2992
|
const response = await get(path, { params: { ...JSON.parse(key), page: nextPage } });
|
|
3086
2993
|
if (requestId !== requestRef.current) return;
|
|
3087
2994
|
const body = response?.data || {};
|
|
3088
|
-
const data = Array.isArray(body.data) ? body.data : [];
|
|
2995
|
+
const data = fillNames(Array.isArray(body.data) ? body.data : []);
|
|
3089
2996
|
setRows((current) => nextPage === 1 ? data : [...current, ...data]);
|
|
3090
2997
|
setMeta(body.meta || null);
|
|
3091
2998
|
setPage(nextPage);
|
|
@@ -3101,7 +3008,7 @@ function useEventList({ path, params, logKey }) {
|
|
|
3101
3008
|
}
|
|
3102
3009
|
}
|
|
3103
3010
|
},
|
|
3104
|
-
[get, path, key, logKey]
|
|
3011
|
+
[get, path, key, logKey, fillNames]
|
|
3105
3012
|
);
|
|
3106
3013
|
react.useEffect(() => {
|
|
3107
3014
|
load(1);
|
|
@@ -3120,14 +3027,14 @@ function useEventList({ path, params, logKey }) {
|
|
|
3120
3027
|
});
|
|
3121
3028
|
const body = response?.data || {};
|
|
3122
3029
|
if (!Array.isArray(body.data)) throw new Error("Invalid export response");
|
|
3123
|
-
all.push(...body.data);
|
|
3030
|
+
all.push(...fillNames(body.data));
|
|
3124
3031
|
cursor = typeof body.meta?.nextCursor === "string" ? body.meta.nextCursor : null;
|
|
3125
3032
|
} while (cursor && all.length < MAX_EVENT_EXPORT_ROWS);
|
|
3126
3033
|
return {
|
|
3127
3034
|
rows: all.slice(0, MAX_EVENT_EXPORT_ROWS),
|
|
3128
3035
|
capped: all.length > MAX_EVENT_EXPORT_ROWS || Boolean(cursor)
|
|
3129
3036
|
};
|
|
3130
|
-
}, [get, path, key]);
|
|
3037
|
+
}, [get, path, key, fillNames]);
|
|
3131
3038
|
return {
|
|
3132
3039
|
rows,
|
|
3133
3040
|
meta,
|
|
@@ -3585,8 +3492,8 @@ const AdminSessionsModal = ({
|
|
|
3585
3492
|
{
|
|
3586
3493
|
id: "email",
|
|
3587
3494
|
label: t("adminPanel.dialog.email", "Email"),
|
|
3588
|
-
value: admin.email,
|
|
3589
|
-
kind: "email"
|
|
3495
|
+
value: admin.identityHidden ? t("adminPanel.identity.emailHidden", "Email hidden (needs “Read” on Users)") : admin.email,
|
|
3496
|
+
kind: admin.identityHidden ? void 0 : "email"
|
|
3590
3497
|
},
|
|
3591
3498
|
{
|
|
3592
3499
|
id: "roles",
|
|
@@ -3734,7 +3641,15 @@ const AdminPanelPage = () => {
|
|
|
3734
3641
|
const response = await get(`/${index.pluginId}/admin-sessions/admins`, { params: listParams });
|
|
3735
3642
|
if (requestId !== requestIdRef.current) return;
|
|
3736
3643
|
const body = response?.data || {};
|
|
3737
|
-
|
|
3644
|
+
const placeholder = (id) => formatMessage(
|
|
3645
|
+
{ id: index.getTranslation("adminPanel.identity.placeholder"), defaultMessage: "Admin #{id}" },
|
|
3646
|
+
{ id }
|
|
3647
|
+
);
|
|
3648
|
+
setAdmins(
|
|
3649
|
+
(Array.isArray(body.data) ? body.data : []).map(
|
|
3650
|
+
(row) => withIdentityPlaceholders(row, placeholder, body.meta?.identity)
|
|
3651
|
+
)
|
|
3652
|
+
);
|
|
3738
3653
|
setMeta(body.meta || null);
|
|
3739
3654
|
setLoadError(false);
|
|
3740
3655
|
hasLoadedRef.current = true;
|
|
@@ -3748,7 +3663,7 @@ const AdminPanelPage = () => {
|
|
|
3748
3663
|
setRefreshing(false);
|
|
3749
3664
|
}
|
|
3750
3665
|
}
|
|
3751
|
-
}, [get, listParams]);
|
|
3666
|
+
}, [get, listParams, formatMessage]);
|
|
3752
3667
|
react.useEffect(() => {
|
|
3753
3668
|
fetchAdmins();
|
|
3754
3669
|
}, [fetchAdmins]);
|
|
@@ -3762,7 +3677,20 @@ const AdminPanelPage = () => {
|
|
|
3762
3677
|
if (requestId !== dialogRequestRef.current) return;
|
|
3763
3678
|
const body = response?.data || {};
|
|
3764
3679
|
setDialogSessions(Array.isArray(body.data) ? body.data : []);
|
|
3765
|
-
if (body.meta?.admin)
|
|
3680
|
+
if (body.meta?.admin) {
|
|
3681
|
+
const placeholder = (id) => formatMessage(
|
|
3682
|
+
{
|
|
3683
|
+
id: index.getTranslation("adminPanel.identity.placeholder"),
|
|
3684
|
+
defaultMessage: "Admin #{id}"
|
|
3685
|
+
},
|
|
3686
|
+
{ id }
|
|
3687
|
+
);
|
|
3688
|
+
setSelected(
|
|
3689
|
+
(current) => current ? withIdentityPlaceholders(body.meta.admin, placeholder, {
|
|
3690
|
+
roles: current.rolesHidden ? false : void 0
|
|
3691
|
+
}) : current
|
|
3692
|
+
);
|
|
3693
|
+
}
|
|
3766
3694
|
setDialogError(false);
|
|
3767
3695
|
} catch (err) {
|
|
3768
3696
|
if (requestId !== dialogRequestRef.current || index.isCancelledRequest(err)) return;
|
|
@@ -3772,7 +3700,7 @@ const AdminPanelPage = () => {
|
|
|
3772
3700
|
if (requestId === dialogRequestRef.current) setDialogLoading(false);
|
|
3773
3701
|
}
|
|
3774
3702
|
},
|
|
3775
|
-
[get]
|
|
3703
|
+
[get, formatMessage]
|
|
3776
3704
|
);
|
|
3777
3705
|
const openDialog = (admin, trigger, tab = "sessions") => {
|
|
3778
3706
|
openerRef.current = trigger;
|
|
@@ -3798,7 +3726,7 @@ const AdminPanelPage = () => {
|
|
|
3798
3726
|
setQuery({ filter: filter === "all" ? void 0 : filter, page: "1" });
|
|
3799
3727
|
};
|
|
3800
3728
|
const handleSearch = react.useCallback(
|
|
3801
|
-
(value) => setQuery({ search: encodeSearchQuery(value), page: "1" }, "push", true),
|
|
3729
|
+
(value) => setQuery({ search: dashboardModel.encodeSearchQuery(value), page: "1" }, "push", true),
|
|
3802
3730
|
[setQuery]
|
|
3803
3731
|
);
|
|
3804
3732
|
const handleClearFilters = () => {
|
|
@@ -3841,10 +3769,10 @@ const AdminPanelPage = () => {
|
|
|
3841
3769
|
index.logSafeAdminError("adminPanel.signOut", err);
|
|
3842
3770
|
const message2 = getSignOutErrorMessage(err);
|
|
3843
3771
|
toggleNotification({
|
|
3844
|
-
type: getErrorStatus(err) === 404 ? "warning" : "danger",
|
|
3772
|
+
type: dashboardModel.getErrorStatus(err) === 404 ? "warning" : "danger",
|
|
3845
3773
|
message: t(message2.messageId, message2.defaultMessage)
|
|
3846
3774
|
});
|
|
3847
|
-
if (getErrorStatus(err) === 404) {
|
|
3775
|
+
if (dashboardModel.getErrorStatus(err) === 404) {
|
|
3848
3776
|
await Promise.all([fetchAdmins(), selected ? fetchDialogSessions(selected) : null]);
|
|
3849
3777
|
return;
|
|
3850
3778
|
}
|
|
@@ -4057,7 +3985,7 @@ const AdminPanelPage = () => {
|
|
|
4057
3985
|
value: view.search,
|
|
4058
3986
|
onSearch: handleSearch,
|
|
4059
3987
|
label: t("adminPanel.search.label", "Search admins"),
|
|
4060
|
-
placeholder: t("adminPanel.search.placeholder", "Search name or email")
|
|
3988
|
+
placeholder: meta?.identity?.names === false ? t("adminPanel.search.placeholderId", "Search by admin ID") : t("adminPanel.search.placeholder", "Search name or email")
|
|
4061
3989
|
}
|
|
4062
3990
|
) }),
|
|
4063
3991
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", shrink: 0, children: [
|