@localazy/strapi-plugin 1.1.0 → 1.1.2

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.
Files changed (65) hide show
  1. package/dist/_chunks/{FetchIdentity-DfV1OWMB.js → FetchIdentity-CevvxeEj.js} +73 -46
  2. package/dist/_chunks/{FetchIdentity-lkoWjYjn.mjs → FetchIdentity-DeThazz9.mjs} +43 -16
  3. package/dist/_chunks/{LanguagesSelector-BmWfSZq6.js → LanguagesSelector-BExpl4Vx.js} +15 -3
  4. package/dist/_chunks/{LanguagesSelector-vSZvVGUT.mjs → LanguagesSelector-D62gLZsM.mjs} +15 -3
  5. package/dist/_chunks/{LocalazyApp-st8mwIbM.mjs → LocalazyApp-Czkb4s5J.mjs} +791 -61
  6. package/dist/_chunks/{LocalazyApp-BUfYt7UL.js → LocalazyApp-DIcO748C.js} +791 -59
  7. package/dist/_chunks/{LocalazyContentTransferSetup-BjLBgqFO.js → LocalazyContentTransferSetup-DAyZdwi9.js} +13 -10
  8. package/dist/_chunks/{LocalazyContentTransferSetup-D2YvBYs_.mjs → LocalazyContentTransferSetup-Dx0Z6DXc.mjs} +13 -10
  9. package/dist/_chunks/{LocalazyGlobalSettings-DHCU2_RH.mjs → LocalazyGlobalSettings-DWMBqlN4.mjs} +149 -12
  10. package/dist/_chunks/{LocalazyGlobalSettings-Do5tOyhB.js → LocalazyGlobalSettings-DjrXGVxl.js} +148 -11
  11. package/dist/_chunks/{LocalazyPanel-CulgT97p.mjs → LocalazyPanel-B-0HBTL_.mjs} +4 -4
  12. package/dist/_chunks/{LocalazyPanel-BDxUI_RH.js → LocalazyPanel-nBOpQo5B.js} +4 -4
  13. package/dist/_chunks/{LocalazyStatusColumn-DoTWD2eL.mjs → LocalazyStatusColumn-CpO3yccG.mjs} +9 -7
  14. package/dist/_chunks/{LocalazyStatusColumn-Dpwoc5Ig.js → LocalazyStatusColumn-cGsUDMlX.js} +9 -7
  15. package/dist/_chunks/{RequireLocalazyAuth-BzM7C6Yw.js → RequireLocalazyAuth-56K8HUNR.js} +4 -4
  16. package/dist/_chunks/{RequireLocalazyAuth-CqHrZ1Ah.mjs → RequireLocalazyAuth-Dh-mAMcg.mjs} +4 -4
  17. package/dist/_chunks/{entry-exclusion-service-DWFMKgkA.mjs → entry-exclusion-service-Dm5_iP7I.mjs} +1 -1
  18. package/dist/_chunks/{entry-exclusion-service-Cvu8PQUI.js → entry-exclusion-service-Rf4Tr0zW.js} +1 -1
  19. package/dist/_chunks/{has-model-changed-CWdMNRB1.mjs → has-model-changed-6p1lR-Ho.mjs} +2 -2
  20. package/dist/_chunks/{has-model-changed-D1f6is8z.js → has-model-changed-CGyDQARr.js} +2 -2
  21. package/dist/_chunks/{i18n-DaBjUC3Y.js → i18n-CAsbU4pi.js} +62 -4
  22. package/dist/_chunks/{i18n-Bga-GG_Z.mjs → i18n-QelOdIB2.mjs} +62 -4
  23. package/dist/_chunks/{index-BSNW1ypR.js → index-BK7lmZSN.js} +57 -19
  24. package/dist/_chunks/{index-CtvR-R3c.mjs → index-Bpf1Mw2A.mjs} +8 -8
  25. package/dist/_chunks/{index-BgPI2yQD.js → index-BsQ_ie4C.js} +8 -8
  26. package/dist/_chunks/{index-BIHAiJnE.mjs → index-CHjIMO9T.mjs} +78 -40
  27. package/dist/_chunks/{strapi-api-base-CturxOqD.mjs → strapi-api-base-Bem_CGuz.mjs} +2 -2
  28. package/dist/_chunks/{strapi-api-base-CN6q5tPh.js → strapi-api-base-W_bUTSlY.js} +2 -2
  29. package/dist/admin/index.js +1 -1
  30. package/dist/admin/index.mjs +1 -1
  31. package/dist/admin/src/components/PluginErrorBoundary.d.ts +5 -0
  32. package/dist/admin/src/modules/@common/locale/en.d.ts +4 -0
  33. package/dist/admin/src/modules/@common/services/project-service.d.ts +9 -0
  34. package/dist/admin/src/modules/@common/styles/heading-fix.d.ts +7 -0
  35. package/dist/admin/src/modules/@common/utils/export-json.d.ts +1 -0
  36. package/dist/admin/src/modules/@common/utils/redirect-to-plugin-route.d.ts +1 -0
  37. package/dist/admin/src/modules/activity-logs/components/HighlightMatch.d.ts +6 -0
  38. package/dist/admin/src/modules/activity-logs/components/SessionMetadata.d.ts +7 -0
  39. package/dist/admin/src/modules/activity-logs/components/SessionsTable.d.ts +17 -0
  40. package/dist/admin/src/modules/activity-logs/components/SortableHeader.d.ts +10 -0
  41. package/dist/admin/src/modules/activity-logs/components/StatusLabel.d.ts +6 -0
  42. package/dist/admin/src/modules/activity-logs/hooks/use-debounced-search.d.ts +6 -0
  43. package/dist/admin/src/modules/activity-logs/locale/en.d.ts +33 -0
  44. package/dist/admin/src/modules/activity-logs/models/activity-logs.d.ts +19 -0
  45. package/dist/admin/src/modules/activity-logs/services/activity-logs-service.d.ts +6 -0
  46. package/dist/admin/src/modules/activity-logs/utils/export-logs.d.ts +1 -0
  47. package/dist/admin/src/modules/activity-logs/utils/format-utils.d.ts +4 -0
  48. package/dist/admin/src/modules/plugin-settings/components/WebhookSetup.d.ts +2 -0
  49. package/dist/admin/src/modules/plugin-settings/locale/en.d.ts +21 -0
  50. package/dist/admin/src/pages/ActivityLogDetail.d.ts +7 -0
  51. package/dist/admin/src/pages/ActivityLogs.d.ts +7 -0
  52. package/dist/server/index.js +395 -49
  53. package/dist/server/index.mjs +395 -49
  54. package/dist/server/src/controllers/activity-logs-controller.d.ts +10 -0
  55. package/dist/server/src/controllers/index.d.ts +12 -1
  56. package/dist/server/src/controllers/localazy-project-controller.d.ts +4 -1
  57. package/dist/server/src/core/index.d.ts +13 -0
  58. package/dist/server/src/db/model/activity-logs.d.ts +20 -0
  59. package/dist/server/src/db/model/plugin-settings.d.ts +14 -0
  60. package/dist/server/src/index.d.ts +27 -1
  61. package/dist/server/src/routes/activity-logs-routes.d.ts +9 -0
  62. package/dist/server/src/services/activity-logs-service.d.ts +17 -0
  63. package/dist/server/src/services/index.d.ts +15 -0
  64. package/dist/server/src/services/localazy-pubapi-service.d.ts +2 -0
  65. package/package.json +4 -3
@@ -1,22 +1,24 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useNavigate, useLocation, NavLink, Routes, Route } from "react-router-dom";
3
- import { i as ForwardRef$2H, j as ForwardRef$d, k as ForwardRef$3P, c as Flex, L as Loader, B as Button, e as Box, T as Typography, l as Link, m as SubNav, n as SubNavHeader, o as SubNavSections, p as SubNavSection, q as SubNavLink, r as ForwardRef$L, G as Grid, D as Divider, s as darkTheme, t as lightTheme, A as Alert, u as Dialog, v as DesignSystemProvider } from "./index-BIHAiJnE.mjs";
4
- import { useState, useEffect } from "react";
5
- import { u as useLocalazyIdentity, v as LocalazyUserService, w as emptyIdentity, P as PluginSettingsService, c as cloneDeep, s as set, L as LocalazyIdentityProvider, F as FetchIdentity } from "./FetchIdentity-lkoWjYjn.mjs";
6
- import { P as PLUGIN_ID } from "./index-CtvR-R3c.mjs";
2
+ import { useNavigate, useLocation, NavLink, useParams, Routes, Route } from "react-router-dom";
3
+ import { o as ForwardRef$2H, p as ForwardRef$d, q as ForwardRef$3P, r as ForwardRef$4j, c as Flex, L as Loader, e as Button, B as Box, T as Typography, g as Link, s as SubNav, t as SubNavHeader, u as SubNavSections, v as SubNavSection, w as SubNavLink, x as ForwardRef$L, G as Grid, j as Divider, f as ForwardRef$3, A as Alert, D as Dialog, y as ForwardRef$4L, z as ForwardRef$4N, P as Pagination, E as PreviousLink, H as PageLink, I as Dots, N as NextLink, J as lodashExports, K as ForwardRef$j, i as ForwardRef$2x, F as Field, O as DatePicker$1, Q as Tabs, R as ForwardRef$57, l as DesignSystemProvider } from "./index-CHjIMO9T.mjs";
4
+ import React__default, { useState, useEffect, useCallback, useMemo, useRef } from "react";
5
+ import { u as useLocalazyIdentity, w as LocalazyUserService, x as emptyIdentity, P as PluginSettingsService, c as cloneDeep, s as set, g as getDefaultTheme, H as HeadingFixGlobalStyle, L as LocalazyIdentityProvider, F as FetchIdentity } from "./FetchIdentity-DeThazz9.mjs";
6
+ import { P as PLUGIN_ID } from "./index-Bpf1Mw2A.mjs";
7
7
  import { u as useTranslation } from "./useTranslation-CZQ4lU1m.mjs";
8
8
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-DWwsNxpa.mjs";
9
- import { c as createStrapiApiAxiosInstance } from "./strapi-api-base-CturxOqD.mjs";
10
- import { P as ProjectService, L as LanguagesSelector } from "./LanguagesSelector-vSZvVGUT.mjs";
9
+ import { c as createStrapiApiAxiosInstance } from "./strapi-api-base-Bem_CGuz.mjs";
10
+ import { P as ProjectService, L as LanguagesSelector } from "./LanguagesSelector-D62gLZsM.mjs";
11
11
  import { Layouts, Page } from "@strapi/strapi/admin";
12
- import "./i18n-Bga-GG_Z.mjs";
13
- import { h as hasModelChanged } from "./has-model-changed-CWdMNRB1.mjs";
12
+ import "./i18n-QelOdIB2.mjs";
13
+ import { h as hasModelChanged } from "./has-model-changed-6p1lR-Ho.mjs";
14
+ import { useTheme } from "styled-components";
14
15
  var PLUGIN_ROUTES = /* @__PURE__ */ ((PLUGIN_ROUTES2) => {
15
16
  PLUGIN_ROUTES2["ROOT"] = "";
16
17
  PLUGIN_ROUTES2["LOGIN"] = "login";
17
18
  PLUGIN_ROUTES2["UPLOAD"] = "upload";
18
19
  PLUGIN_ROUTES2["DOWNLOAD"] = "download";
19
20
  PLUGIN_ROUTES2["OVERVIEW"] = "overview";
21
+ PLUGIN_ROUTES2["ACTIVITY_LOGS"] = "activity-logs";
20
22
  PLUGIN_ROUTES2["CONTENT_TRANSFER_SETUP"] = "content-transfer-setup";
21
23
  PLUGIN_ROUTES2["GLOBAL_SETTINGS"] = "global-settings";
22
24
  return PLUGIN_ROUTES2;
@@ -64,6 +66,14 @@ const useNav = () => {
64
66
  icon: /* @__PURE__ */ jsx(ForwardRef$3P, {}),
65
67
  to: `/plugins/${PLUGIN_ID}/download`,
66
68
  active: false
69
+ },
70
+ {
71
+ id: "activity-logs",
72
+ label: t2("common.activity_logs"),
73
+ description: t2("activity_logs.description"),
74
+ icon: /* @__PURE__ */ jsx(ForwardRef$4j, {}),
75
+ to: `/plugins/${PLUGIN_ID}/activity-logs`,
76
+ active: false
67
77
  }
68
78
  ];
69
79
  };
@@ -1115,12 +1125,12 @@ function l(t2, e2) {
1115
1125
  const n2 = e2 || "https://localazy.com";
1116
1126
  return "/" !== new URL(n2).pathname ? `${n2}?${a2.toString()}` : `${n2}/oauth/authorize?${a2.toString()}`;
1117
1127
  }
1118
- const BASE_PATH$2 = "/auth";
1119
- const axiosInstance = createStrapiApiAxiosInstance();
1128
+ const BASE_PATH$3 = "/auth";
1129
+ const axiosInstance$1 = createStrapiApiAxiosInstance();
1120
1130
  class LocalazyLoginService {
1121
1131
  static async generateKeys() {
1122
1132
  try {
1123
- const result = await axiosInstance.get(`${BASE_PATH$2}/generate-keys`);
1133
+ const result = await axiosInstance$1.get(`${BASE_PATH$3}/generate-keys`);
1124
1134
  return result.data;
1125
1135
  } catch (e2) {
1126
1136
  throw e2;
@@ -1128,7 +1138,7 @@ class LocalazyLoginService {
1128
1138
  }
1129
1139
  static async continuousPoll(readKey) {
1130
1140
  try {
1131
- const result = await axiosInstance.get(`${BASE_PATH$2}/continuous-poll?readKey=${readKey}`);
1141
+ const result = await axiosInstance$1.get(`${BASE_PATH$3}/continuous-poll?readKey=${readKey}`);
1132
1142
  return result.data;
1133
1143
  } catch (e2) {
1134
1144
  throw e2;
@@ -1377,7 +1387,7 @@ const Login = ({ title, subtitle, isLoading = false }) => {
1377
1387
  };
1378
1388
  useEffect(() => {
1379
1389
  if (isLoggedIn && identity.user && identity.project) {
1380
- ProductAnalyticsService.trackAppConnected(identity.user.id, identity.project);
1390
+ void ProductAnalyticsService.trackAppConnected(identity.user.id, identity.project);
1381
1391
  }
1382
1392
  }, [isLoggedIn, identity]);
1383
1393
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -1428,7 +1438,7 @@ const LogoutButton = (props) => {
1428
1438
  const { setIdentity } = useLocalazyIdentity();
1429
1439
  const logout = async () => {
1430
1440
  setIsLoading(true);
1431
- LocalazyUserService.deleteIdentity();
1441
+ void LocalazyUserService.deleteIdentity();
1432
1442
  setIdentity(emptyIdentity);
1433
1443
  setIsLoading(false);
1434
1444
  props.onResultFetched();
@@ -1464,13 +1474,13 @@ const Overview = ({ title, subtitle, isLoadingProp = false }) => {
1464
1474
  setIsLoading(true);
1465
1475
  const project = await ProjectService.getConnectedProject();
1466
1476
  setConnectedProject(project);
1467
- PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.OVERVIEW });
1477
+ void PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.OVERVIEW });
1468
1478
  setIsLoading(false);
1469
1479
  }
1470
- initComponent();
1480
+ void initComponent();
1471
1481
  }, []);
1472
1482
  const onLoggedOut = () => {
1473
- ProductAnalyticsService.trackAppDisconnected(identity.user.id, identity.project);
1483
+ void ProductAnalyticsService.trackAppDisconnected(identity.user.id, identity.project);
1474
1484
  navigateToPluginRoute(PLUGIN_ROUTES.LOGIN);
1475
1485
  };
1476
1486
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -1479,8 +1489,7 @@ const Overview = ({ title, subtitle, isLoadingProp = false }) => {
1479
1489
  {
1480
1490
  title,
1481
1491
  subtitle,
1482
- primaryAction: /* @__PURE__ */ jsx(LogoutButton, { onResultFetched: onLoggedOut }),
1483
- as: "h2"
1492
+ primaryAction: /* @__PURE__ */ jsx(LogoutButton, { onResultFetched: onLoggedOut })
1484
1493
  }
1485
1494
  ),
1486
1495
  (isLoadingProp || isLoading) && /* @__PURE__ */ jsx(PluginPageLoader, {}),
@@ -1526,21 +1535,56 @@ const Overview = ({ title, subtitle, isLoadingProp = false }) => {
1526
1535
  ) })
1527
1536
  ] });
1528
1537
  };
1529
- const THEME_KEY = "STRAPI_THEME";
1530
- const getDefaultThemeName = () => {
1531
- const persistedTheme = localStorage.getItem(THEME_KEY);
1532
- return persistedTheme || "system";
1533
- };
1534
- const getDefaultTheme = () => {
1535
- const themeName = getDefaultThemeName();
1536
- return themeName === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? darkTheme : lightTheme : themeName === "dark" ? darkTheme : lightTheme;
1538
+ class ErrorBoundaryInner extends React__default.Component {
1539
+ constructor(props) {
1540
+ super(props);
1541
+ this.state = { hasError: false, error: null };
1542
+ }
1543
+ static getDerivedStateFromError(error) {
1544
+ return { hasError: true, error };
1545
+ }
1546
+ reset = () => {
1547
+ this.setState({ hasError: false, error: null });
1548
+ };
1549
+ render() {
1550
+ if (this.state.hasError && this.state.error) {
1551
+ return this.props.fallback(this.state.error, this.reset);
1552
+ }
1553
+ return this.props.children;
1554
+ }
1555
+ }
1556
+ const ErrorFallback = ({ error, reset }) => {
1557
+ const { t: t2 } = useTranslation();
1558
+ const { setIdentity } = useLocalazyIdentity();
1559
+ const handleDisconnect = useCallback(() => {
1560
+ void LocalazyUserService.deleteIdentity();
1561
+ setIdentity(emptyIdentity);
1562
+ reset();
1563
+ }, [setIdentity, reset]);
1564
+ return /* @__PURE__ */ jsx(Layouts.Root, { children: /* @__PURE__ */ jsx(Box, { padding: 10, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 6, paddingTop: 10, children: [
1565
+ /* @__PURE__ */ jsx(ForwardRef$3, { width: 48, height: 48, fill: "danger600" }),
1566
+ /* @__PURE__ */ jsx(Typography, { variant: "alpha", textColor: "neutral800", children: t2("common.error_boundary_title") }),
1567
+ /* @__PURE__ */ jsx(Box, { maxWidth: "600px", children: /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", textAlign: "center", children: t2("common.error_boundary_description") }) }),
1568
+ /* @__PURE__ */ jsx(Box, { padding: 4, background: "neutral100", hasRadius: true, maxWidth: "600px", width: "100%", children: /* @__PURE__ */ jsx(
1569
+ Typography,
1570
+ {
1571
+ variant: "pi",
1572
+ textColor: "neutral500",
1573
+ tag: "pre",
1574
+ style: { whiteSpace: "pre-wrap", wordBreak: "break-word" },
1575
+ children: error.message
1576
+ }
1577
+ ) }),
1578
+ /* @__PURE__ */ jsx(Button, { startIcon: /* @__PURE__ */ jsx(ForwardRef$L, {}), variant: "danger-light", onClick: handleDisconnect, children: t2("common.error_boundary_disconnect") })
1579
+ ] }) }) });
1537
1580
  };
1538
- const BASE_PATH$1 = "/transfer";
1581
+ const PluginErrorBoundary = ({ children }) => /* @__PURE__ */ jsx(ErrorBoundaryInner, { fallback: (error, reset) => /* @__PURE__ */ jsx(ErrorFallback, { error, reset }), children });
1582
+ const BASE_PATH$2 = "/transfer";
1539
1583
  class LocalazyUploadService {
1540
1584
  static async upload(data = {}) {
1541
1585
  try {
1542
1586
  const strapiApiInstance2 = createStrapiApiAxiosInstance();
1543
- const result = await strapiApiInstance2.post(`${BASE_PATH$1}/upload`, data);
1587
+ const result = await strapiApiInstance2.post(`${BASE_PATH$2}/upload`, data);
1544
1588
  return result.data;
1545
1589
  } catch (e2) {
1546
1590
  throw e2.data;
@@ -5000,7 +5044,7 @@ const Upload = (props) => {
5000
5044
  setIsUploading(false);
5001
5045
  setShowUploadFinishedModal(true);
5002
5046
  });
5003
- ProductAnalyticsService.trackUploadToLocalazy(identity.user.id, identity.project, {
5047
+ void ProductAnalyticsService.trackUploadToLocalazy(identity.user.id, identity.project, {
5004
5048
  "Source Language Code": localazySourceLanguage.code
5005
5049
  });
5006
5050
  };
@@ -5017,10 +5061,10 @@ const Upload = (props) => {
5017
5061
  setLocalazySourceLanguage(sourceLanguage);
5018
5062
  setModelChanged(modelChangedResult);
5019
5063
  setLocalesIncompatible(!localesCompatibleResult);
5020
- PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.UPLOAD });
5064
+ void PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.UPLOAD });
5021
5065
  setIsLoading(false);
5022
5066
  }
5023
- initComponent();
5067
+ void initComponent();
5024
5068
  }, []);
5025
5069
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5026
5070
  /* @__PURE__ */ jsx(
@@ -5037,8 +5081,7 @@ const Upload = (props) => {
5037
5081
  onClick: onUploadClick,
5038
5082
  children: t2("upload.upload_to_localazy")
5039
5083
  }
5040
- ),
5041
- as: "h2"
5084
+ )
5042
5085
  }
5043
5086
  ),
5044
5087
  isLoading && /* @__PURE__ */ jsx(PluginPageLoader, {}),
@@ -5112,12 +5155,12 @@ const Upload = (props) => {
5112
5155
  ] })
5113
5156
  ] });
5114
5157
  };
5115
- const BASE_PATH = "/transfer";
5158
+ const BASE_PATH$1 = "/transfer";
5116
5159
  class LocalazyDownloadService {
5117
5160
  static async download(data = {}) {
5118
5161
  try {
5119
5162
  const strapiApiInstance2 = createStrapiApiAxiosInstance();
5120
- const result = await strapiApiInstance2.post(`${BASE_PATH}/download`, data);
5163
+ const result = await strapiApiInstance2.post(`${BASE_PATH$1}/download`, data);
5121
5164
  return result.data;
5122
5165
  } catch (e2) {
5123
5166
  throw e2.data;
@@ -5157,7 +5200,7 @@ const Download = (props) => {
5157
5200
  set(newFormModel, "download.uiLanguages", languages);
5158
5201
  setFormModel(newFormModel);
5159
5202
  try {
5160
- PluginSettingsService.updatePluginSettings(newFormModel);
5203
+ void PluginSettingsService.updatePluginSettings(newFormModel);
5161
5204
  } catch (e2) {
5162
5205
  console.error(e2.message);
5163
5206
  }
@@ -5191,7 +5234,7 @@ const Download = (props) => {
5191
5234
  } catch {
5192
5235
  }
5193
5236
  });
5194
- ProductAnalyticsService.trackDownloadToStrapi(identity.user.id, identity.project, {
5237
+ void ProductAnalyticsService.trackDownloadToStrapi(identity.user.id, identity.project, {
5195
5238
  "Target Languages Codes": "all"
5196
5239
  });
5197
5240
  };
@@ -5211,10 +5254,10 @@ const Download = (props) => {
5211
5254
  const projectLanguagesWithoutDefaultLanguage = project?.languages?.filter((language) => language.id !== project.sourceLanguage) || [];
5212
5255
  setProjectLanguages(projectLanguagesWithoutDefaultLanguage);
5213
5256
  setFormModel(globalSettings);
5214
- PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.DOWNLOAD });
5257
+ void PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.DOWNLOAD });
5215
5258
  setIsLoading(false);
5216
5259
  }
5217
- initComponent();
5260
+ void initComponent();
5218
5261
  }, []);
5219
5262
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5220
5263
  /* @__PURE__ */ jsx(
@@ -5243,8 +5286,7 @@ const Download = (props) => {
5243
5286
  children: t2("download.incremental_download")
5244
5287
  }
5245
5288
  )
5246
- ] }),
5247
- as: "h2"
5289
+ ] })
5248
5290
  }
5249
5291
  ),
5250
5292
  isLoading && /* @__PURE__ */ jsx(PluginPageLoader, {}),
@@ -5331,7 +5373,7 @@ const Download = (props) => {
5331
5373
  variant: "danger-light",
5332
5374
  onClick: () => {
5333
5375
  setShowFullSyncConfirm(false);
5334
- onDownloadClick(true);
5376
+ void onDownloadClick(true);
5335
5377
  },
5336
5378
  children: t2("download.full_sync")
5337
5379
  }
@@ -5340,6 +5382,677 @@ const Download = (props) => {
5340
5382
  ] }) })
5341
5383
  ] });
5342
5384
  };
5385
+ const BASE_PATH = "/activity-logs";
5386
+ const axiosInstance = createStrapiApiAxiosInstance();
5387
+ class ActivityLogsService {
5388
+ static async getSessions(type) {
5389
+ const params = type ? `?type=${type}` : "";
5390
+ const result = await axiosInstance.get(`${BASE_PATH}${params}`);
5391
+ return result.data;
5392
+ }
5393
+ static async getSession(sessionId) {
5394
+ const result = await axiosInstance.get(`${BASE_PATH}/${sessionId}`);
5395
+ return result.data;
5396
+ }
5397
+ static async exportSessions() {
5398
+ const result = await axiosInstance.get(`${BASE_PATH}/export`);
5399
+ return result.data;
5400
+ }
5401
+ static async clearSessions() {
5402
+ const result = await axiosInstance.delete(`${BASE_PATH}`);
5403
+ return result.data;
5404
+ }
5405
+ }
5406
+ const exportAsJson = (data, filename) => {
5407
+ const json = JSON.stringify(data, null, 2);
5408
+ const blob = new Blob([json], { type: "application/json" });
5409
+ const url2 = URL.createObjectURL(blob);
5410
+ const a2 = document.createElement("a");
5411
+ a2.href = url2;
5412
+ a2.download = filename.endsWith(".json") ? filename : `${filename}.json`;
5413
+ a2.click();
5414
+ URL.revokeObjectURL(url2);
5415
+ };
5416
+ const exportLogsAsJson = async () => {
5417
+ const sessions = await ActivityLogsService.exportSessions();
5418
+ exportAsJson(sessions, `localazy-activity-logs-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}`);
5419
+ };
5420
+ const formatDate = (timestamp) => {
5421
+ return new Date(timestamp).toLocaleString();
5422
+ };
5423
+ const formatTime = (timestamp) => {
5424
+ return new Date(timestamp).toLocaleTimeString(void 0, {
5425
+ hour: "2-digit",
5426
+ minute: "2-digit",
5427
+ second: "2-digit",
5428
+ fractionalSecondDigits: 3
5429
+ });
5430
+ };
5431
+ const formatDuration = (start, end) => {
5432
+ if (!end) return "-";
5433
+ const diff = end - start;
5434
+ if (diff < 1e3) return `${diff}ms`;
5435
+ if (diff < 6e4) return `${Math.round(diff / 1e3)}s`;
5436
+ return `${Math.round(diff / 6e4)}m ${Math.round(diff % 6e4 / 1e3)}s`;
5437
+ };
5438
+ const getStatusColor = (status) => {
5439
+ switch (status) {
5440
+ case "completed":
5441
+ return "success600";
5442
+ case "failed":
5443
+ return "danger600";
5444
+ case "in-progress":
5445
+ return "warning600";
5446
+ default:
5447
+ return "neutral600";
5448
+ }
5449
+ };
5450
+ const SortableHeader = ({ label, sortKey, activeSortKey, direction, onSort }) => {
5451
+ const isActive = sortKey === activeSortKey;
5452
+ const theme = useTheme();
5453
+ return /* @__PURE__ */ jsx(
5454
+ "th",
5455
+ {
5456
+ onClick: () => onSort(sortKey),
5457
+ style: {
5458
+ textAlign: "left",
5459
+ padding: "12px 16px",
5460
+ borderBottom: `1px solid ${theme.colors.neutral150}`,
5461
+ cursor: "pointer",
5462
+ userSelect: "none"
5463
+ },
5464
+ children: /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 1, children: [
5465
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: isActive ? "primary600" : "neutral600", children: label }),
5466
+ /* @__PURE__ */ jsx("span", { style: { width: 8, display: "inline-flex", flexShrink: 0 }, children: isActive && (direction === "asc" ? /* @__PURE__ */ jsx(ForwardRef$4L, { width: 8, height: 8 }) : /* @__PURE__ */ jsx(ForwardRef$4N, { width: 8, height: 8 })) })
5467
+ ] })
5468
+ }
5469
+ );
5470
+ };
5471
+ const HighlightMatch = ({ text, query }) => {
5472
+ const theme = useTheme();
5473
+ if (!query) return /* @__PURE__ */ jsx(Fragment, { children: text });
5474
+ const escaped = query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5475
+ const parts2 = text.split(new RegExp(`(${escaped})`, "gi"));
5476
+ if (parts2.length === 1) return /* @__PURE__ */ jsx(Fragment, { children: text });
5477
+ return /* @__PURE__ */ jsx(Fragment, { children: parts2.map(
5478
+ (part, i2) => part.toLowerCase() === query.toLowerCase() ? /* @__PURE__ */ jsx("span", { style: { backgroundColor: theme.colors.warning200, borderRadius: "2px", padding: "0 1px" }, children: part }, i2) : part
5479
+ ) });
5480
+ };
5481
+ const StatusLabel = ({ status, searchQuery }) => {
5482
+ const { t: t2 } = useTranslation();
5483
+ const label = status === "in-progress" ? t2("activity_logs.status_in_progress") : status === "completed" ? t2("activity_logs.status_completed") : t2("activity_logs.status_failed");
5484
+ return /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: getStatusColor(status), children: searchQuery ? /* @__PURE__ */ jsx(HighlightMatch, { text: label, query: searchQuery }) : label });
5485
+ };
5486
+ const DEFAULT_SORT = { key: "startedAt", direction: "desc" };
5487
+ const PAGE_SIZE = 20;
5488
+ const getDuration = (session) => {
5489
+ if (!session.finishedAt) return Infinity;
5490
+ return session.finishedAt - session.startedAt;
5491
+ };
5492
+ const compareSessions = (a2, b, sortKey, direction) => {
5493
+ let cmp = 0;
5494
+ switch (sortKey) {
5495
+ case "status":
5496
+ cmp = a2.status.localeCompare(b.status);
5497
+ break;
5498
+ case "startedAt":
5499
+ cmp = a2.startedAt - b.startedAt;
5500
+ break;
5501
+ case "duration":
5502
+ cmp = getDuration(a2) - getDuration(b);
5503
+ break;
5504
+ case "initiatedBy":
5505
+ cmp = a2.initiatedBy.localeCompare(b.initiatedBy);
5506
+ break;
5507
+ case "summary":
5508
+ cmp = (a2.summary || "").localeCompare(b.summary || "");
5509
+ break;
5510
+ }
5511
+ return direction === "asc" ? cmp : -cmp;
5512
+ };
5513
+ const SessionsTable = ({ sessions, searchQuery, dateFrom, dateTo, eventType, sortPreferences, onSortChange, onSessionClick, t: t2 }) => {
5514
+ const theme = useTheme();
5515
+ const stored = sortPreferences[eventType];
5516
+ const [sortKey, setSortKey] = useState(stored?.key || DEFAULT_SORT.key);
5517
+ const [sortDirection, setSortDirection] = useState(
5518
+ stored?.direction || DEFAULT_SORT.direction
5519
+ );
5520
+ const [page, setPage] = useState(1);
5521
+ useEffect(() => {
5522
+ const pref = sortPreferences[eventType];
5523
+ if (pref?.key) setSortKey(pref.key);
5524
+ if (pref?.direction) setSortDirection(pref.direction);
5525
+ }, [eventType, sortPreferences]);
5526
+ useEffect(() => {
5527
+ setPage(1);
5528
+ }, [searchQuery, dateFrom, dateTo, eventType]);
5529
+ const onSort = (key) => {
5530
+ const newDirection = key === sortKey ? sortDirection === "asc" ? "desc" : "asc" : "asc";
5531
+ setSortKey(key);
5532
+ setSortDirection(newDirection);
5533
+ onSortChange(eventType, key, newDirection);
5534
+ setPage(1);
5535
+ };
5536
+ const filteredSessions = sessions.filter((session) => {
5537
+ if (dateFrom) {
5538
+ const startOfDay = new Date(dateFrom.getUTCFullYear(), dateFrom.getUTCMonth(), dateFrom.getUTCDate()).getTime();
5539
+ if (session.startedAt < startOfDay) return false;
5540
+ }
5541
+ if (dateTo) {
5542
+ const endOfDay = new Date(
5543
+ dateTo.getUTCFullYear(),
5544
+ dateTo.getUTCMonth(),
5545
+ dateTo.getUTCDate(),
5546
+ 23,
5547
+ 59,
5548
+ 59,
5549
+ 999
5550
+ ).getTime();
5551
+ if (session.startedAt > endOfDay) return false;
5552
+ }
5553
+ if (!searchQuery) return true;
5554
+ const query = searchQuery.toLowerCase();
5555
+ return session.summary.toLowerCase().includes(query) || session.initiatedBy.toLowerCase().includes(query) || session.status.toLowerCase().includes(query) || formatDate(session.startedAt).toLowerCase().includes(query);
5556
+ }).sort((a2, b) => compareSessions(a2, b, sortKey, sortDirection));
5557
+ const totalCount = filteredSessions.length;
5558
+ const totalPages = Math.max(1, Math.ceil(totalCount / PAGE_SIZE));
5559
+ const safePage = Math.min(page, totalPages);
5560
+ const paginatedSessions = filteredSessions.slice((safePage - 1) * PAGE_SIZE, safePage * PAGE_SIZE);
5561
+ if (filteredSessions.length === 0) {
5562
+ return /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: t2("activity_logs.no_sessions") }) });
5563
+ }
5564
+ return /* @__PURE__ */ jsxs(Box, { children: [
5565
+ /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
5566
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
5567
+ /* @__PURE__ */ jsx(
5568
+ SortableHeader,
5569
+ {
5570
+ label: t2("activity_logs.status"),
5571
+ sortKey: "status",
5572
+ activeSortKey: sortKey,
5573
+ direction: sortDirection,
5574
+ onSort
5575
+ }
5576
+ ),
5577
+ /* @__PURE__ */ jsx(
5578
+ SortableHeader,
5579
+ {
5580
+ label: t2("activity_logs.started_at"),
5581
+ sortKey: "startedAt",
5582
+ activeSortKey: sortKey,
5583
+ direction: sortDirection,
5584
+ onSort
5585
+ }
5586
+ ),
5587
+ /* @__PURE__ */ jsx(
5588
+ SortableHeader,
5589
+ {
5590
+ label: t2("activity_logs.duration"),
5591
+ sortKey: "duration",
5592
+ activeSortKey: sortKey,
5593
+ direction: sortDirection,
5594
+ onSort
5595
+ }
5596
+ ),
5597
+ /* @__PURE__ */ jsx(
5598
+ SortableHeader,
5599
+ {
5600
+ label: t2("activity_logs.initiated_by"),
5601
+ sortKey: "initiatedBy",
5602
+ activeSortKey: sortKey,
5603
+ direction: sortDirection,
5604
+ onSort
5605
+ }
5606
+ ),
5607
+ /* @__PURE__ */ jsx(
5608
+ SortableHeader,
5609
+ {
5610
+ label: t2("activity_logs.summary"),
5611
+ sortKey: "summary",
5612
+ activeSortKey: sortKey,
5613
+ direction: sortDirection,
5614
+ onSort
5615
+ }
5616
+ )
5617
+ ] }) }),
5618
+ /* @__PURE__ */ jsx("tbody", { children: paginatedSessions.map((session) => /* @__PURE__ */ jsxs(
5619
+ "tr",
5620
+ {
5621
+ onClick: () => onSessionClick(session.id),
5622
+ style: { cursor: "pointer", borderBottom: `1px solid ${theme.colors.neutral150}` },
5623
+ onMouseEnter: (e2) => {
5624
+ e2.currentTarget.style.backgroundColor = theme.colors.neutral100;
5625
+ },
5626
+ onMouseLeave: (e2) => {
5627
+ e2.currentTarget.style.backgroundColor = "transparent";
5628
+ },
5629
+ children: [
5630
+ /* @__PURE__ */ jsx("td", { style: { padding: "12px 16px" }, children: /* @__PURE__ */ jsx(StatusLabel, { status: session.status, searchQuery }) }),
5631
+ /* @__PURE__ */ jsx("td", { style: { padding: "12px 16px" }, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: /* @__PURE__ */ jsx(HighlightMatch, { text: formatDate(session.startedAt), query: searchQuery }) }) }),
5632
+ /* @__PURE__ */ jsx("td", { style: { padding: "12px 16px" }, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: formatDuration(session.startedAt, session.finishedAt) }) }),
5633
+ /* @__PURE__ */ jsx("td", { style: { padding: "12px 16px" }, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: /* @__PURE__ */ jsx(HighlightMatch, { text: session.initiatedBy, query: searchQuery }) }) }),
5634
+ /* @__PURE__ */ jsx("td", { style: { padding: "12px 16px" }, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: /* @__PURE__ */ jsx(HighlightMatch, { text: session.summary || "-", query: searchQuery }) }) })
5635
+ ]
5636
+ },
5637
+ session.id
5638
+ )) })
5639
+ ] }),
5640
+ /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsxs(Pagination, { activePage: safePage, pageCount: totalPages, children: [
5641
+ /* @__PURE__ */ jsx(PreviousLink, { onClick: () => setPage(Math.max(1, safePage - 1)) }),
5642
+ (() => {
5643
+ const pages = [];
5644
+ const WINDOW = 2;
5645
+ if (totalPages <= 7) {
5646
+ for (let i2 = 1; i2 <= totalPages; i2++) {
5647
+ pages.push(/* @__PURE__ */ jsx(PageLink, { number: i2, onClick: () => setPage(i2) }, i2));
5648
+ }
5649
+ } else {
5650
+ pages.push(/* @__PURE__ */ jsx(PageLink, { number: 1, onClick: () => setPage(1) }, 1));
5651
+ if (safePage > 1 + WINDOW + 1) {
5652
+ pages.push(/* @__PURE__ */ jsx(Dots, {}, "dots-start"));
5653
+ }
5654
+ const start = Math.max(2, safePage - WINDOW);
5655
+ const end = Math.min(totalPages - 1, safePage + WINDOW);
5656
+ for (let i2 = start; i2 <= end; i2++) {
5657
+ pages.push(/* @__PURE__ */ jsx(PageLink, { number: i2, onClick: () => setPage(i2) }, i2));
5658
+ }
5659
+ if (safePage < totalPages - WINDOW - 1) {
5660
+ pages.push(/* @__PURE__ */ jsx(Dots, {}, "dots-end"));
5661
+ }
5662
+ pages.push(/* @__PURE__ */ jsx(PageLink, { number: totalPages, onClick: () => setPage(totalPages) }, totalPages));
5663
+ }
5664
+ return pages;
5665
+ })(),
5666
+ /* @__PURE__ */ jsx(NextLink, { onClick: () => setPage(Math.min(totalPages, safePage + 1)) })
5667
+ ] }) })
5668
+ ] });
5669
+ };
5670
+ const DEBOUNCE_MS = 300;
5671
+ const useDebouncedSearch = () => {
5672
+ const [searchInput, setSearchInput] = useState("");
5673
+ const [searchQuery, setSearchQuery] = useState("");
5674
+ const debouncedSetQuery = useMemo(() => lodashExports.debounce((value2) => setSearchQuery(value2), DEBOUNCE_MS), []);
5675
+ useEffect(() => {
5676
+ return () => {
5677
+ debouncedSetQuery.cancel();
5678
+ };
5679
+ }, [debouncedSetQuery]);
5680
+ const onSearchChange = useCallback(
5681
+ (value2) => {
5682
+ setSearchInput(value2);
5683
+ debouncedSetQuery(value2);
5684
+ },
5685
+ [debouncedSetQuery]
5686
+ );
5687
+ return { searchInput, searchQuery, onSearchChange };
5688
+ };
5689
+ const ActivityLogs = (props) => {
5690
+ const { t: t2 } = useTranslation();
5691
+ const navigate = useNavigate();
5692
+ const [isLoading, setIsLoading] = useState(true);
5693
+ const [sessions, setSessions] = useState([]);
5694
+ const [activeTab, setActiveTab] = useState("upload");
5695
+ const { searchInput, searchQuery, onSearchChange } = useDebouncedSearch();
5696
+ const [dateFrom, setDateFrom] = useState(void 0);
5697
+ const [dateTo, setDateTo] = useState(void 0);
5698
+ const [showClearConfirm, setShowClearConfirm] = useState(false);
5699
+ const [clearSuccess, setClearSuccess] = useState(false);
5700
+ const [sortPreferences, setSortPreferences] = useState({});
5701
+ const saveSortTimerRef = useRef(null);
5702
+ const debouncedSaveSortPrefs = useCallback((prefs) => {
5703
+ if (saveSortTimerRef.current) clearTimeout(saveSortTimerRef.current);
5704
+ saveSortTimerRef.current = setTimeout(() => {
5705
+ void PluginSettingsService.updatePluginSettings({ activityLogsSort: prefs });
5706
+ }, 1e3);
5707
+ }, []);
5708
+ const onSortChange = (eventType, key, direction) => {
5709
+ const updated = { ...sortPreferences, [eventType]: { key, direction } };
5710
+ setSortPreferences(updated);
5711
+ debouncedSaveSortPrefs(updated);
5712
+ };
5713
+ const fetchSessions = async (type, showLoader = true) => {
5714
+ if (showLoader) setIsLoading(true);
5715
+ try {
5716
+ const data = await ActivityLogsService.getSessions(type);
5717
+ setSessions(data || []);
5718
+ } catch (e2) {
5719
+ console.error("Failed to fetch activity logs:", e2);
5720
+ setSessions([]);
5721
+ }
5722
+ if (showLoader) setIsLoading(false);
5723
+ };
5724
+ const onTabChange = (value2) => {
5725
+ setActiveTab(value2);
5726
+ void fetchSessions(value2, false);
5727
+ };
5728
+ const onSessionClick = (sessionId) => {
5729
+ navigate(`/plugins/${PLUGIN_ID}/activity-logs/${sessionId}`);
5730
+ };
5731
+ const onExportLogs = async () => {
5732
+ try {
5733
+ await exportLogsAsJson();
5734
+ } catch (e2) {
5735
+ console.error("Failed to export activity logs:", e2);
5736
+ }
5737
+ };
5738
+ const onClearLogs = async () => {
5739
+ try {
5740
+ await ActivityLogsService.clearSessions();
5741
+ setSessions([]);
5742
+ setClearSuccess(true);
5743
+ setShowClearConfirm(false);
5744
+ setTimeout(() => setClearSuccess(false), 3e3);
5745
+ } catch (e2) {
5746
+ console.error("Failed to clear activity logs:", e2);
5747
+ }
5748
+ };
5749
+ useEffect(() => {
5750
+ const init = async () => {
5751
+ try {
5752
+ const settings = await PluginSettingsService.getPluginSettings();
5753
+ if (settings?.activityLogsSort) {
5754
+ setSortPreferences(settings.activityLogsSort);
5755
+ }
5756
+ } catch {
5757
+ }
5758
+ void fetchSessions("upload");
5759
+ };
5760
+ void init();
5761
+ void PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.ACTIVITY_LOGS });
5762
+ }, []);
5763
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
5764
+ /* @__PURE__ */ jsx(
5765
+ Layouts.Header,
5766
+ {
5767
+ title: props.title,
5768
+ subtitle: props.subtitle,
5769
+ primaryAction: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
5770
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", startIcon: /* @__PURE__ */ jsx(ForwardRef$3P, {}), onClick: onExportLogs, children: t2("activity_logs.export_logs") }),
5771
+ /* @__PURE__ */ jsx(Button, { variant: "danger-light", startIcon: /* @__PURE__ */ jsx(ForwardRef$j, {}), onClick: () => setShowClearConfirm(true), children: t2("activity_logs.clear_logs") })
5772
+ ] })
5773
+ }
5774
+ ),
5775
+ /* @__PURE__ */ jsx(Box, { paddingRight: 10, paddingLeft: 10, paddingBottom: 4, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
5776
+ /* @__PURE__ */ jsx(ForwardRef$2x, { width: 14, height: 14, fill: "neutral500" }),
5777
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: t2("activity_logs.retention_info") })
5778
+ ] }) }),
5779
+ isLoading && /* @__PURE__ */ jsx(PluginPageLoader, {}),
5780
+ !isLoading && /* @__PURE__ */ jsxs(Box, { paddingRight: 10, paddingLeft: 10, children: [
5781
+ clearSuccess && /* @__PURE__ */ jsx(Box, { marginBottom: 4, children: /* @__PURE__ */ jsx(Alert, { onClose: () => setClearSuccess(false), closeLabel: t2("activity_logs.close"), variant: "success", children: t2("activity_logs.clear_logs_success") }) }),
5782
+ /* @__PURE__ */ jsxs(
5783
+ Box,
5784
+ {
5785
+ background: "neutral0",
5786
+ paddingTop: 6,
5787
+ paddingRight: 7,
5788
+ paddingBottom: 6,
5789
+ paddingLeft: 7,
5790
+ hasRadius: true,
5791
+ shadow: "tableShadow",
5792
+ children: [
5793
+ /* @__PURE__ */ jsxs(Flex, { marginBottom: 4, gap: 3, wrap: "wrap", alignItems: "center", children: [
5794
+ /* @__PURE__ */ jsx(Box, { grow: 1, basis: "200px", children: /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsx(
5795
+ Field.Input,
5796
+ {
5797
+ placeholder: t2("activity_logs.search_placeholder"),
5798
+ value: searchInput,
5799
+ onChange: (e2) => onSearchChange(e2.target.value)
5800
+ }
5801
+ ) }) }),
5802
+ /* @__PURE__ */ jsx(Box, { basis: "160px", children: /* @__PURE__ */ jsx(
5803
+ DatePicker$1,
5804
+ {
5805
+ placeholder: t2("activity_logs.date_from"),
5806
+ value: dateFrom,
5807
+ onChange: (date) => {
5808
+ if (!date) {
5809
+ setDateFrom(void 0);
5810
+ return;
5811
+ }
5812
+ setDateFrom(new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())));
5813
+ },
5814
+ onClear: () => setDateFrom(void 0),
5815
+ clearLabel: t2("activity_logs.clear"),
5816
+ size: "M"
5817
+ }
5818
+ ) }),
5819
+ /* @__PURE__ */ jsx(Box, { basis: "160px", children: /* @__PURE__ */ jsx(
5820
+ DatePicker$1,
5821
+ {
5822
+ placeholder: t2("activity_logs.date_to"),
5823
+ value: dateTo,
5824
+ onChange: (date) => {
5825
+ if (!date) {
5826
+ setDateTo(void 0);
5827
+ return;
5828
+ }
5829
+ setDateTo(new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())));
5830
+ },
5831
+ onClear: () => setDateTo(void 0),
5832
+ clearLabel: t2("activity_logs.clear"),
5833
+ size: "M"
5834
+ }
5835
+ ) })
5836
+ ] }),
5837
+ /* @__PURE__ */ jsxs(Tabs.Root, { value: activeTab, onValueChange: onTabChange, children: [
5838
+ /* @__PURE__ */ jsxs(Tabs.List, { children: [
5839
+ /* @__PURE__ */ jsx(Tabs.Trigger, { value: "upload", children: t2("activity_logs.tab_upload") }),
5840
+ /* @__PURE__ */ jsx(Tabs.Trigger, { value: "download", children: t2("activity_logs.tab_download") }),
5841
+ /* @__PURE__ */ jsx(Tabs.Trigger, { value: "webhook", children: t2("activity_logs.tab_webhooks") })
5842
+ ] }),
5843
+ /* @__PURE__ */ jsx(Tabs.Content, { value: "upload", children: /* @__PURE__ */ jsx(
5844
+ SessionsTable,
5845
+ {
5846
+ sessions,
5847
+ searchQuery,
5848
+ dateFrom,
5849
+ dateTo,
5850
+ eventType: "upload",
5851
+ sortPreferences,
5852
+ onSortChange,
5853
+ onSessionClick,
5854
+ t: t2
5855
+ }
5856
+ ) }),
5857
+ /* @__PURE__ */ jsx(Tabs.Content, { value: "download", children: /* @__PURE__ */ jsx(
5858
+ SessionsTable,
5859
+ {
5860
+ sessions,
5861
+ searchQuery,
5862
+ dateFrom,
5863
+ dateTo,
5864
+ eventType: "download",
5865
+ sortPreferences,
5866
+ onSortChange,
5867
+ onSessionClick,
5868
+ t: t2
5869
+ }
5870
+ ) }),
5871
+ /* @__PURE__ */ jsx(Tabs.Content, { value: "webhook", children: /* @__PURE__ */ jsx(
5872
+ SessionsTable,
5873
+ {
5874
+ sessions,
5875
+ searchQuery,
5876
+ dateFrom,
5877
+ dateTo,
5878
+ eventType: "webhook",
5879
+ sortPreferences,
5880
+ onSortChange,
5881
+ onSessionClick,
5882
+ t: t2
5883
+ }
5884
+ ) })
5885
+ ] })
5886
+ ]
5887
+ }
5888
+ )
5889
+ ] }),
5890
+ /* @__PURE__ */ jsx(Dialog.Root, { open: showClearConfirm, onOpenChange: setShowClearConfirm, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
5891
+ /* @__PURE__ */ jsx(Dialog.Header, { children: t2("activity_logs.clear_logs") }),
5892
+ /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: t2("activity_logs.clear_logs_confirm") }) }),
5893
+ /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
5894
+ /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: t2("activity_logs.close") }) }),
5895
+ /* @__PURE__ */ jsx(Dialog.Action, { children: /* @__PURE__ */ jsx(Button, { variant: "danger-light", onClick: onClearLogs, children: t2("activity_logs.clear_logs") }) })
5896
+ ] })
5897
+ ] }) })
5898
+ ] });
5899
+ };
5900
+ const SessionMetadata = ({ session, showEntryCount }) => {
5901
+ const { t: t2 } = useTranslation();
5902
+ return /* @__PURE__ */ jsxs(Flex, { gap: 6, wrap: "wrap", children: [
5903
+ /* @__PURE__ */ jsxs(Box, { children: [
5904
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: t2("activity_logs.status") }),
5905
+ /* @__PURE__ */ jsx("br", {}),
5906
+ /* @__PURE__ */ jsx(StatusLabel, { status: session.status })
5907
+ ] }),
5908
+ /* @__PURE__ */ jsxs(Box, { children: [
5909
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: t2("activity_logs.started_at") }),
5910
+ /* @__PURE__ */ jsx("br", {}),
5911
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", children: formatDate(session.startedAt) })
5912
+ ] }),
5913
+ /* @__PURE__ */ jsxs(Box, { children: [
5914
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: t2("activity_logs.duration") }),
5915
+ /* @__PURE__ */ jsx("br", {}),
5916
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", children: formatDuration(session.startedAt, session.finishedAt) })
5917
+ ] }),
5918
+ /* @__PURE__ */ jsxs(Box, { children: [
5919
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: t2("activity_logs.initiated_by") }),
5920
+ /* @__PURE__ */ jsx("br", {}),
5921
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", children: session.initiatedBy })
5922
+ ] }),
5923
+ showEntryCount !== void 0 && /* @__PURE__ */ jsxs(Box, { children: [
5924
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: t2("activity_logs.entries_count") }),
5925
+ /* @__PURE__ */ jsx("br", {}),
5926
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", children: showEntryCount })
5927
+ ] })
5928
+ ] });
5929
+ };
5930
+ const ActivityLogDetail = (props) => {
5931
+ const { t: t2 } = useTranslation();
5932
+ const theme = useTheme();
5933
+ const { sessionId } = useParams();
5934
+ const [isLoading, setIsLoading] = useState(true);
5935
+ const [session, setSession] = useState(null);
5936
+ const { searchInput, searchQuery, onSearchChange } = useDebouncedSearch();
5937
+ useEffect(() => {
5938
+ const fetchSession = async () => {
5939
+ if (!sessionId) return;
5940
+ setIsLoading(true);
5941
+ try {
5942
+ const data = await ActivityLogsService.getSession(sessionId);
5943
+ setSession(data);
5944
+ } catch (e2) {
5945
+ console.error("Failed to fetch session detail:", e2);
5946
+ }
5947
+ setIsLoading(false);
5948
+ };
5949
+ void fetchSession();
5950
+ }, [sessionId]);
5951
+ const filteredEntries = (session?.entries || []).filter((entry) => {
5952
+ if (!searchQuery) return true;
5953
+ const query = searchQuery.toLowerCase();
5954
+ return entry.message.toLowerCase().includes(query) || formatTime(entry.timestamp).toLowerCase().includes(query);
5955
+ });
5956
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
5957
+ /* @__PURE__ */ jsx(
5958
+ Layouts.Header,
5959
+ {
5960
+ title: props.title,
5961
+ subtitle: props.subtitle,
5962
+ navigationAction: /* @__PURE__ */ jsx(Link, { tag: NavLink, to: `/plugins/${PLUGIN_ID}/activity-logs`, startIcon: /* @__PURE__ */ jsx(ForwardRef$57, {}), children: t2("activity_logs.back_to_list") })
5963
+ }
5964
+ ),
5965
+ isLoading && /* @__PURE__ */ jsx(PluginPageLoader, {}),
5966
+ !isLoading && !session && /* @__PURE__ */ jsx(Box, { paddingRight: 10, paddingLeft: 10, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: t2("activity_logs.no_sessions") }) }),
5967
+ !isLoading && session && /* @__PURE__ */ jsxs(Box, { paddingRight: 10, paddingLeft: 10, children: [
5968
+ /* @__PURE__ */ jsxs(
5969
+ Box,
5970
+ {
5971
+ background: "neutral0",
5972
+ paddingTop: 6,
5973
+ paddingRight: 7,
5974
+ paddingBottom: 6,
5975
+ paddingLeft: 7,
5976
+ hasRadius: true,
5977
+ shadow: "tableShadow",
5978
+ children: [
5979
+ /* @__PURE__ */ jsx(SessionMetadata, { session, showEntryCount: session.entries.length }),
5980
+ session.summary && /* @__PURE__ */ jsxs(Box, { marginTop: 4, children: [
5981
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: t2("activity_logs.summary") }),
5982
+ /* @__PURE__ */ jsx("br", {}),
5983
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", children: session.summary })
5984
+ ] })
5985
+ ]
5986
+ }
5987
+ ),
5988
+ /* @__PURE__ */ jsx(Box, { marginTop: 4, children: /* @__PURE__ */ jsxs(
5989
+ Box,
5990
+ {
5991
+ background: "neutral0",
5992
+ paddingTop: 6,
5993
+ paddingRight: 7,
5994
+ paddingBottom: 6,
5995
+ paddingLeft: 7,
5996
+ hasRadius: true,
5997
+ shadow: "tableShadow",
5998
+ children: [
5999
+ /* @__PURE__ */ jsx(Box, { marginBottom: 4, children: /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsx(
6000
+ Field.Input,
6001
+ {
6002
+ placeholder: t2("activity_logs.search_entries_placeholder"),
6003
+ value: searchInput,
6004
+ onChange: (e2) => onSearchChange(e2.target.value)
6005
+ }
6006
+ ) }) }),
6007
+ /* @__PURE__ */ jsx(Divider, {}),
6008
+ filteredEntries.length === 0 && /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: t2("activity_logs.no_entries") }) }),
6009
+ filteredEntries.map((entry, index) => /* @__PURE__ */ jsxs(
6010
+ Box,
6011
+ {
6012
+ paddingTop: 3,
6013
+ paddingBottom: 3,
6014
+ paddingLeft: 4,
6015
+ paddingRight: 4,
6016
+ style: {
6017
+ borderBottom: index < filteredEntries.length - 1 ? `1px solid ${theme.colors.neutral150}` : "none",
6018
+ fontFamily: "monospace"
6019
+ },
6020
+ children: [
6021
+ /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
6022
+ /* @__PURE__ */ jsx(
6023
+ Typography,
6024
+ {
6025
+ variant: "pi",
6026
+ textColor: "neutral500",
6027
+ style: { whiteSpace: "nowrap", fontFamily: "monospace" },
6028
+ children: /* @__PURE__ */ jsx(HighlightMatch, { text: formatTime(entry.timestamp), query: searchQuery })
6029
+ }
6030
+ ),
6031
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", style: { fontFamily: "monospace" }, children: /* @__PURE__ */ jsx(HighlightMatch, { text: entry.message, query: searchQuery }) })
6032
+ ] }),
6033
+ entry.data && /* @__PURE__ */ jsx(Box, { marginTop: 2, marginLeft: 6, children: /* @__PURE__ */ jsx(
6034
+ Typography,
6035
+ {
6036
+ variant: "pi",
6037
+ textColor: "neutral500",
6038
+ style: {
6039
+ fontFamily: "monospace",
6040
+ whiteSpace: "pre-wrap",
6041
+ wordBreak: "break-all"
6042
+ },
6043
+ children: JSON.stringify(entry.data, null, 2)
6044
+ }
6045
+ ) })
6046
+ ]
6047
+ },
6048
+ index
6049
+ ))
6050
+ ]
6051
+ }
6052
+ ) })
6053
+ ] })
6054
+ ] });
6055
+ };
5343
6056
  const App = () => {
5344
6057
  const { navigateToPluginRoute } = useRedirectToPluginRoute();
5345
6058
  const location2 = useLocation();
@@ -5365,24 +6078,41 @@ const App = () => {
5365
6078
  navigateToPluginRoute(lastRoute);
5366
6079
  }
5367
6080
  };
5368
- fetchData();
6081
+ void fetchData();
5369
6082
  }, [isLoggedIn, isFetchingIdentity, normalizedPath]);
5370
- return /* @__PURE__ */ jsx(DesignSystemProvider, { theme: getDefaultTheme(), children: /* @__PURE__ */ jsx(Box, { background: "neutral100", children: /* @__PURE__ */ jsxs(Layouts.Root, { sideNav: isLoggedIn && /* @__PURE__ */ jsx(SideNav, {}), children: [
5371
- isFetchingIdentity && /* @__PURE__ */ jsx(PluginPageLoader, {}),
5372
- /* @__PURE__ */ jsxs(Routes, { children: [
5373
- /* @__PURE__ */ jsx(Route, { path: `login`, element: /* @__PURE__ */ jsx(Login, { title: headerTitle, subtitle: headerSubtitle, isLoading: false }) }),
5374
- /* @__PURE__ */ jsx(
5375
- Route,
5376
- {
5377
- path: `overview`,
5378
- element: /* @__PURE__ */ jsx(Overview, { title: headerTitle, subtitle: headerSubtitle, isLoadingProp: false })
5379
- }
5380
- ),
5381
- /* @__PURE__ */ jsx(Route, { path: `upload`, element: /* @__PURE__ */ jsx(Upload, { title: headerTitle, subtitle: headerSubtitle }) }),
5382
- /* @__PURE__ */ jsx(Route, { path: `download`, element: /* @__PURE__ */ jsx(Download, { title: headerTitle, subtitle: headerSubtitle }) }),
5383
- /* @__PURE__ */ jsx(Route, { path: "*", element: /* @__PURE__ */ jsx(Page.Error, {}) })
5384
- ] })
5385
- ] }) }) });
6083
+ return /* @__PURE__ */ jsxs(DesignSystemProvider, { theme: getDefaultTheme(), children: [
6084
+ /* @__PURE__ */ jsx(HeadingFixGlobalStyle, {}),
6085
+ /* @__PURE__ */ jsx(PluginErrorBoundary, { children: /* @__PURE__ */ jsx(Box, { background: "neutral100", children: /* @__PURE__ */ jsxs(Layouts.Root, { sideNav: isLoggedIn && /* @__PURE__ */ jsx(SideNav, {}), children: [
6086
+ isFetchingIdentity && /* @__PURE__ */ jsx(PluginPageLoader, {}),
6087
+ /* @__PURE__ */ jsxs(Routes, { children: [
6088
+ /* @__PURE__ */ jsx(
6089
+ Route,
6090
+ {
6091
+ path: `login`,
6092
+ element: /* @__PURE__ */ jsx(Login, { title: headerTitle, subtitle: headerSubtitle, isLoading: false })
6093
+ }
6094
+ ),
6095
+ /* @__PURE__ */ jsx(
6096
+ Route,
6097
+ {
6098
+ path: `overview`,
6099
+ element: /* @__PURE__ */ jsx(Overview, { title: headerTitle, subtitle: headerSubtitle, isLoadingProp: false })
6100
+ }
6101
+ ),
6102
+ /* @__PURE__ */ jsx(Route, { path: `upload`, element: /* @__PURE__ */ jsx(Upload, { title: headerTitle, subtitle: headerSubtitle }) }),
6103
+ /* @__PURE__ */ jsx(Route, { path: `download`, element: /* @__PURE__ */ jsx(Download, { title: headerTitle, subtitle: headerSubtitle }) }),
6104
+ /* @__PURE__ */ jsx(Route, { path: `activity-logs`, element: /* @__PURE__ */ jsx(ActivityLogs, { title: headerTitle, subtitle: headerSubtitle }) }),
6105
+ /* @__PURE__ */ jsx(
6106
+ Route,
6107
+ {
6108
+ path: `activity-logs/:sessionId`,
6109
+ element: /* @__PURE__ */ jsx(ActivityLogDetail, { title: headerTitle, subtitle: headerSubtitle })
6110
+ }
6111
+ ),
6112
+ /* @__PURE__ */ jsx(Route, { path: "*", element: /* @__PURE__ */ jsx(Page.Error, {}) })
6113
+ ] })
6114
+ ] }) }) })
6115
+ ] });
5386
6116
  };
5387
6117
  const LocalazyApp = () => /* @__PURE__ */ jsxs(LocalazyIdentityProvider, { children: [
5388
6118
  /* @__PURE__ */ jsx(FetchIdentity, {}),