@mattisvensson/strapi-plugin-webatlas 0.12.2 → 0.14.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.
Files changed (192) hide show
  1. package/README.md +46 -1
  2. package/dist/admin/{SettingTitle-DXGCUfum.js → ContentBox-CHwpYMiB.js} +1 -5
  3. package/dist/admin/{SettingTitle-C1_2epDJ.mjs → ContentBox-CYnyB_5a.mjs} +2 -6
  4. package/dist/admin/{RoutePicker-C6LpgVMi.mjs → RoutePicker-43YnYCpH.mjs} +1 -1
  5. package/dist/admin/{RoutePicker-DvzQH2CX.js → RoutePicker-D9zf-VdN.js} +1 -1
  6. package/dist/admin/WarningBox-AyYq0Onj.mjs +18 -0
  7. package/dist/admin/{WarningBox-BHlYlKQ8.js → WarningBox-FF1yYDXP.js} +0 -24
  8. package/dist/admin/{de-BWUGdpM0.js → de-DolV3m7M.js} +115 -5
  9. package/dist/admin/{de-Dnk_hvMW.mjs → de-Dt3jjL3h.mjs} +115 -5
  10. package/dist/admin/{en-D5EqZSGy.mjs → en-CCRmKJEV.mjs} +114 -4
  11. package/dist/admin/{en-DOk8P6X5.js → en-jWdO5RMZ.js} +114 -4
  12. package/dist/admin/index-7iO5UsYI.js +174 -0
  13. package/dist/admin/{index-DuSnxRbO.mjs → index-B2k8Pikg.mjs} +44 -12
  14. package/dist/admin/index-CK4JyItR.mjs +5363 -0
  15. package/dist/admin/{index-CVrufPeL.mjs → index-CMuhLgfi.mjs} +74 -30
  16. package/dist/admin/{index-D7zg69uM.js → index-Ciem6YTr.js} +50 -18
  17. package/dist/admin/index-DGYmrx3f.mjs +174 -0
  18. package/dist/admin/index-Ddnt9W-v.mjs +1025 -0
  19. package/dist/admin/index-DfG_hSMk.js +5363 -0
  20. package/dist/admin/{index-DHNPW0YT.js → index-DmOWQK6g.js} +70 -26
  21. package/dist/admin/index-dB79zyxi.js +1025 -0
  22. package/dist/admin/index.js +1 -1
  23. package/dist/admin/index.mjs +1 -1
  24. package/dist/admin/src/components/CMEditViewAside/NewPathInfo.d.ts +5 -0
  25. package/dist/admin/src/components/CMEditViewAside/OverrideCheckbox.d.ts +7 -0
  26. package/dist/admin/src/components/CMEditViewAside/Panel.d.ts +5 -0
  27. package/dist/admin/src/components/CMEditViewAside/PathInput.d.ts +12 -0
  28. package/dist/admin/src/components/CMEditViewAside/RouteStructure.d.ts +3 -0
  29. package/dist/admin/src/components/CMEditViewAside/UidPathDisplay.d.ts +4 -0
  30. package/dist/admin/src/components/CMEditViewAside/index.d.ts +3 -0
  31. package/dist/admin/src/components/Initializer.d.ts +5 -0
  32. package/dist/admin/src/components/PathInfo.d.ts +8 -0
  33. package/dist/admin/src/components/PluginIcon.d.ts +3 -0
  34. package/dist/admin/src/components/Tooltip.d.ts +3 -0
  35. package/dist/admin/src/components/UI/Center.d.ts +4 -0
  36. package/dist/admin/src/components/UI/EmptyBox.d.ts +5 -0
  37. package/dist/admin/src/components/UI/FullLoader.d.ts +3 -0
  38. package/dist/admin/src/components/UI/WarningBox.d.ts +4 -0
  39. package/dist/admin/src/components/UI/index.d.ts +5 -0
  40. package/dist/admin/src/components/customFields/RoutePicker.d.ts +25 -0
  41. package/dist/admin/src/components/modals/Delete.d.ts +7 -0
  42. package/dist/admin/src/components/modals/DiscardChanges.d.ts +3 -0
  43. package/dist/admin/src/components/modals/NavCreate.d.ts +1 -0
  44. package/dist/admin/src/components/modals/NavEdit.d.ts +7 -0
  45. package/dist/admin/src/components/modals/NavModal.d.ts +16 -0
  46. package/dist/admin/src/components/modals/NavOverview.d.ts +10 -0
  47. package/dist/admin/src/components/modals/SaveConfirm.d.ts +8 -0
  48. package/dist/admin/src/components/modals/externalItem/index.d.ts +15 -0
  49. package/dist/admin/src/components/modals/index.d.ts +14 -0
  50. package/dist/admin/src/components/modals/internalItem/EntrySelection.d.ts +17 -0
  51. package/dist/admin/src/components/modals/internalItem/ItemDetails.d.ts +13 -0
  52. package/dist/admin/src/components/modals/internalItem/MultiItemReview.d.ts +23 -0
  53. package/dist/admin/src/components/modals/internalItem/internalItemCreate.d.ts +2 -0
  54. package/dist/admin/src/components/modals/internalItem/internalItemEdit.d.ts +2 -0
  55. package/dist/admin/src/components/modals/useModalSharedLogic.d.ts +2 -0
  56. package/dist/admin/src/components/modals/withModalSharedLogic.d.ts +3 -0
  57. package/dist/admin/src/components/modals/wrapperItem/index.d.ts +15 -0
  58. package/dist/admin/src/contexts/index.d.ts +17 -0
  59. package/dist/admin/src/hooks/index.d.ts +7 -0
  60. package/dist/admin/src/hooks/useAllContentTypes.d.ts +7 -0
  61. package/dist/admin/src/hooks/useAllEntities.d.ts +7 -0
  62. package/dist/admin/src/hooks/useApi.d.ts +23 -0
  63. package/dist/admin/src/hooks/useEntrySearch.d.ts +13 -0
  64. package/dist/admin/src/hooks/useErrorMessage.d.ts +8 -0
  65. package/dist/admin/src/hooks/usePluginConfig.d.ts +9 -0
  66. package/dist/admin/src/pages/Navigation/Page.d.ts +2 -0
  67. package/dist/admin/src/pages/Navigation/PageWrapper.d.ts +8 -0
  68. package/dist/admin/src/pages/Navigation/RouteItem.d.ts +2 -0
  69. package/dist/admin/src/pages/Navigation/RouteItemBadge.d.ts +4 -0
  70. package/dist/admin/src/pages/Navigation/RouteItemIcon.d.ts +5 -0
  71. package/dist/admin/src/pages/Navigation/RouteItemMenu.d.ts +12 -0
  72. package/dist/admin/src/pages/Navigation/RouteItemStatus.d.ts +5 -0
  73. package/dist/admin/src/pages/Navigation/SortableRouteItem.d.ts +2 -0
  74. package/dist/admin/src/pages/Navigation/UnsavedChangesBlocker.d.ts +8 -0
  75. package/dist/admin/src/pages/Navigation/index.d.ts +2 -0
  76. package/dist/admin/src/pages/Navigation/useCollapsedItems.d.ts +13 -0
  77. package/dist/admin/src/pages/Paths/HealthSummary.d.ts +8 -0
  78. package/dist/admin/src/pages/Paths/IssueBadges.d.ts +4 -0
  79. package/dist/admin/src/pages/Paths/PageWrapper.d.ts +5 -0
  80. package/dist/admin/src/pages/Paths/PathActionsMenu.d.ts +7 -0
  81. package/dist/admin/src/pages/Paths/PathFilters.d.ts +14 -0
  82. package/dist/admin/src/pages/Paths/PathTable.d.ts +18 -0
  83. package/dist/admin/src/pages/Paths/SearchInput.d.ts +5 -0
  84. package/dist/admin/src/pages/Paths/TableHeader.d.ts +6 -0
  85. package/dist/admin/src/pages/Paths/TableRow.d.ts +9 -0
  86. package/dist/admin/src/pages/Paths/compareBy.d.ts +3 -0
  87. package/dist/admin/src/pages/Paths/hasPathDeviation.d.ts +2 -0
  88. package/dist/admin/src/pages/Paths/healthMessages.d.ts +11 -0
  89. package/dist/admin/src/pages/Paths/index.d.ts +2 -0
  90. package/dist/admin/src/pages/Settings/ContentBox.d.ts +4 -0
  91. package/dist/admin/src/pages/Settings/General/ContentTypeAccordion.d.ts +9 -0
  92. package/dist/admin/src/pages/Settings/General/index.d.ts +2 -0
  93. package/dist/admin/src/pages/Settings/Navigation/index.d.ts +2 -0
  94. package/dist/admin/src/pages/Settings/PageWrapper.d.ts +7 -0
  95. package/dist/admin/src/pages/Settings/SettingTitle.d.ts +3 -0
  96. package/dist/admin/src/pages/Settings/index.d.ts +4 -0
  97. package/dist/admin/src/permissions.d.ts +51 -0
  98. package/dist/admin/src/types/index.d.ts +4 -0
  99. package/dist/admin/src/types/modal.d.ts +60 -0
  100. package/dist/admin/src/types/navigation.d.ts +24 -0
  101. package/dist/admin/src/types/panel.d.ts +50 -0
  102. package/dist/admin/src/types/route.d.ts +3 -0
  103. package/dist/admin/src/utils/buildBreadcrumbString.d.ts +16 -0
  104. package/dist/admin/src/utils/createTempNavItemObject.d.ts +22 -0
  105. package/dist/admin/src/utils/debounce.d.ts +1 -0
  106. package/dist/admin/src/utils/dnd.d.ts +13 -0
  107. package/dist/admin/src/utils/duplicateCheck.d.ts +19 -0
  108. package/dist/admin/src/utils/findParentNavItem.d.ts +13 -0
  109. package/dist/admin/src/utils/getRouteSourceFields.d.ts +2 -0
  110. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  111. package/dist/admin/src/utils/index.d.ts +11 -0
  112. package/dist/admin/src/utils/isAbortError.d.ts +5 -0
  113. package/dist/admin/src/utils/navTree.d.ts +39 -0
  114. package/dist/admin/src/utils/syncNavItemPaths.d.ts +12 -0
  115. package/dist/admin/src/utils/typeChecks.d.ts +3 -0
  116. package/dist/server/index.js +584 -53
  117. package/dist/server/index.mjs +585 -54
  118. package/dist/server/src/bootstrap/documentMiddleware.d.ts +18 -0
  119. package/dist/server/src/bootstrap/index.d.ts +5 -0
  120. package/dist/server/src/bootstrap/permissions.d.ts +2 -0
  121. package/dist/server/src/bootstrap/syncConfig.d.ts +3 -0
  122. package/dist/server/src/bootstrap/webatlasMiddleware.d.ts +2 -0
  123. package/dist/server/src/bootstrap.d.ts +5 -0
  124. package/dist/server/src/config/index.d.ts +8 -0
  125. package/dist/server/src/content-types/index.d.ts +208 -0
  126. package/dist/server/src/content-types/navigation/index.d.ts +56 -0
  127. package/dist/server/src/content-types/navigation/schema.d.ts +54 -0
  128. package/dist/server/src/content-types/navitem/index.d.ts +51 -0
  129. package/dist/server/src/content-types/navitem/schema.d.ts +49 -0
  130. package/dist/server/src/content-types/route/index.d.ts +101 -0
  131. package/dist/server/src/content-types/route/schema.d.ts +99 -0
  132. package/dist/server/src/controllers/admin.d.ts +19 -0
  133. package/dist/server/src/controllers/client.d.ts +8 -0
  134. package/dist/server/src/controllers/index.d.ts +27 -0
  135. package/dist/server/src/destroy.d.ts +5 -0
  136. package/dist/server/src/index.d.ts +31 -8
  137. package/dist/server/src/middlewares/addWebatlasField.d.ts +10 -0
  138. package/dist/server/src/middlewares/enrichRoutePicker.d.ts +10 -0
  139. package/dist/server/src/middlewares/index.d.ts +9 -0
  140. package/dist/server/src/migrations/001-canonical-path.d.ts +7 -0
  141. package/dist/server/src/migrations/002-webatlas-json-field.d.ts +7 -0
  142. package/dist/server/src/migrations/003-route-source-field.d.ts +7 -0
  143. package/dist/server/src/migrations/004-navigation-max-depth.d.ts +7 -0
  144. package/dist/server/src/migrations/index.d.ts +3 -0
  145. package/dist/server/src/policies/has-permissions.d.ts +2 -0
  146. package/dist/server/src/policies/index.d.ts +4 -0
  147. package/dist/server/src/register.d.ts +5 -0
  148. package/dist/server/src/routes/admin.d.ts +17 -0
  149. package/dist/server/src/routes/client.d.ts +12 -0
  150. package/dist/server/src/routes/index.d.ts +30 -0
  151. package/dist/server/src/services/admin.d.ts +33 -0
  152. package/dist/server/src/services/client.d.ts +48 -0
  153. package/dist/server/src/services/health.d.ts +5 -0
  154. package/dist/server/src/services/index.d.ts +83 -0
  155. package/dist/server/src/utils/addWebatlasBreadcrumb.d.ts +14 -0
  156. package/dist/server/src/utils/assertDescendantPathsAllowed.d.ts +19 -0
  157. package/dist/server/src/utils/assertPathAllowed.d.ts +2 -0
  158. package/dist/server/src/utils/buildCanonicalPath.d.ts +1 -0
  159. package/dist/server/src/utils/buildNavigationPath.d.ts +5 -0
  160. package/dist/server/src/utils/buildStructuredNavigation.d.ts +12 -0
  161. package/dist/server/src/utils/cascadePathUpdates.d.ts +6 -0
  162. package/dist/server/src/utils/cleanRootKeys.d.ts +1 -0
  163. package/dist/server/src/utils/duplicateCheck.d.ts +1 -0
  164. package/dist/server/src/utils/enrichRoutePickerFields.d.ts +7 -0
  165. package/dist/server/src/utils/enrichWebatlasData.d.ts +6 -0
  166. package/dist/server/src/utils/extractRouteAndItems.d.ts +32 -0
  167. package/dist/server/src/utils/getDocumentStatuses.d.ts +12 -0
  168. package/dist/server/src/utils/getNonInternalRouteIds.d.ts +1 -0
  169. package/dist/server/src/utils/getPublishedDocumentIds.d.ts +11 -0
  170. package/dist/server/src/utils/getRouteAncestors.d.ts +1 -0
  171. package/dist/server/src/utils/getRouteDescendants.d.ts +1 -0
  172. package/dist/server/src/utils/health/checks.d.ts +48 -0
  173. package/dist/server/src/utils/index.d.ts +29 -0
  174. package/dist/server/src/utils/isBlacklistedPath.d.ts +1 -0
  175. package/dist/server/src/utils/navItemHandler.d.ts +5 -0
  176. package/dist/server/src/utils/navigationItemStructure.d.ts +27 -0
  177. package/dist/server/src/utils/normalizeRouteBlacklist.d.ts +5 -0
  178. package/dist/server/src/utils/pluginHelpers.d.ts +4 -0
  179. package/dist/server/src/utils/populateDeep.d.ts +4 -0
  180. package/dist/server/src/utils/reduceDepthOfOrphanedItems.d.ts +2 -0
  181. package/dist/server/src/utils/removeUnpublishedNavItems.d.ts +7 -0
  182. package/dist/server/src/utils/removeWaFields.d.ts +1 -0
  183. package/dist/server/src/utils/routeHandler.d.ts +5 -0
  184. package/dist/server/src/utils/validateRouteDependencies.d.ts +4 -0
  185. package/package.json +5 -5
  186. package/dist/admin/WarningBox-CfIVF0O-.mjs +0 -42
  187. package/dist/admin/index-DC-2-FsX.mjs +0 -9622
  188. package/dist/admin/index-Dp_eCRFS.js +0 -249
  189. package/dist/admin/index-Dx4gvFWK.mjs +0 -147
  190. package/dist/admin/index-FuvoHpAT.js +0 -147
  191. package/dist/admin/index-RmZ3LQPu.js +0 -9622
  192. package/dist/admin/index-Y4uwBSjP.mjs +0 -249
@@ -0,0 +1,1025 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { useState, useMemo, useEffect, useCallback } from "react";
3
+ import { g as getTranslation, P as PLUGIN_ID, T as Tooltip, u as useApi, a as useAllContentTypes, p as pluginPermissions, d as debounce, i as isAbortError } from "./index-CMuhLgfi.mjs";
4
+ import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
5
+ import { Page, Layouts, useClipboard, useNotification, useRBAC, useAuth, Pagination } from "@strapi/strapi/admin";
6
+ import { Box, Field, Thead, Tr, Th, Typography, VisuallyHidden, SimpleMenu, IconButton, MenuItem, Flex, Badge, Td, Table, Tbody, EmptyStateLayout, Button, MultiSelect, MultiSelectOption, SingleSelect, SingleSelectOption, Loader } from "@strapi/design-system";
7
+ import "@strapi/icons/symbols";
8
+ import { Cross, ChevronUp, ChevronDown, More, ArrowClockwise, CheckCircle, WarningCircle } from "@strapi/icons";
9
+ import { useIntl } from "react-intl";
10
+ import { useNavigate, useSearchParams } from "react-router-dom";
11
+ function PageWrapper({
12
+ children,
13
+ total,
14
+ matches
15
+ }) {
16
+ const { formatMessage } = useIntl();
17
+ const totalText = total === void 0 ? void 0 : formatMessage(
18
+ {
19
+ id: getTranslation("paths.page.total"),
20
+ defaultMessage: "{count, plural, one {# path} other {# paths}} total"
21
+ },
22
+ { count: total }
23
+ );
24
+ const matchesText = matches === void 0 ? void 0 : formatMessage(
25
+ {
26
+ id: getTranslation("paths.page.matches"),
27
+ defaultMessage: "{count, plural, one {# match} other {# matches}}"
28
+ },
29
+ { count: matches }
30
+ );
31
+ return /* @__PURE__ */ jsxs(Page.Main, { children: [
32
+ /* @__PURE__ */ jsx(
33
+ Layouts.Header,
34
+ {
35
+ title: formatMessage({
36
+ id: getTranslation("paths.page.title"),
37
+ defaultMessage: "Paths"
38
+ }),
39
+ subtitle: [matchesText, totalText].filter(Boolean).join(" · ") || void 0
40
+ }
41
+ ),
42
+ /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(Fragment, { children }) })
43
+ ] });
44
+ }
45
+ function compareBy(field, direction, contentTypeLabels) {
46
+ if (!field) {
47
+ return () => 0;
48
+ }
49
+ if (field === "contentType") {
50
+ return (a, b) => {
51
+ const aLabel = contentTypeLabels.get(a.relatedContentType);
52
+ const bLabel = contentTypeLabels.get(b.relatedContentType);
53
+ if (!aLabel && !bLabel) return 0;
54
+ if (!aLabel) return 1;
55
+ if (!bLabel) return -1;
56
+ return direction === "asc" ? aLabel.localeCompare(bLabel) : bLabel.localeCompare(aLabel);
57
+ };
58
+ }
59
+ if (field === "type") {
60
+ return (a, b) => {
61
+ return direction === "asc" ? a.type.localeCompare(b.type) : b.type.localeCompare(a.type);
62
+ };
63
+ }
64
+ return (a, b) => {
65
+ const aValue = a[field];
66
+ const bValue = b[field];
67
+ if (aValue == null && bValue == null) {
68
+ return 0;
69
+ }
70
+ if (aValue == null) {
71
+ return direction === "asc" ? 1 : -1;
72
+ }
73
+ if (bValue == null) {
74
+ return direction === "asc" ? -1 : 1;
75
+ }
76
+ if (typeof aValue === "string" && typeof bValue === "string") {
77
+ return direction === "asc" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
78
+ }
79
+ return 0;
80
+ };
81
+ }
82
+ function hasPathDeviation(route) {
83
+ return !!route.canonicalPath && route.canonicalPath !== route.path;
84
+ }
85
+ function SearchInput({
86
+ searchQuery,
87
+ handleSearchChange
88
+ }) {
89
+ const { formatMessage } = useIntl();
90
+ return /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsx(
91
+ Field.Input,
92
+ {
93
+ name: "search",
94
+ placeholder: formatMessage({
95
+ id: getTranslation("paths.page.searchPlaceholder"),
96
+ defaultMessage: "Search paths"
97
+ }),
98
+ value: searchQuery,
99
+ onChange: handleSearchChange,
100
+ endAction: searchQuery ? /* @__PURE__ */ jsx(
101
+ "button",
102
+ {
103
+ type: "button",
104
+ onClick: () => handleSearchChange({
105
+ target: { value: "" }
106
+ }),
107
+ style: {
108
+ color: "inherit",
109
+ background: "none",
110
+ border: "none",
111
+ cursor: "pointer"
112
+ },
113
+ "aria-label": "Clear search",
114
+ children: /* @__PURE__ */ jsx(Cross, {})
115
+ }
116
+ ) : null
117
+ }
118
+ ) }) });
119
+ }
120
+ function TableHeader({
121
+ sortKey,
122
+ sortDirection,
123
+ handleSort
124
+ }) {
125
+ const { formatMessage } = useIntl();
126
+ const SortIcon = sortDirection === "asc" ? ChevronUp : ChevronDown;
127
+ return /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
128
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("title"), cursor: "pointer", children: [
129
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
130
+ id: getTranslation("title"),
131
+ defaultMessage: "Title"
132
+ }) }),
133
+ sortKey === "title" && /* @__PURE__ */ jsx(SortIcon, {})
134
+ ] }),
135
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("path"), cursor: "pointer", children: [
136
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
137
+ id: getTranslation("path"),
138
+ defaultMessage: "Path"
139
+ }) }),
140
+ sortKey === "path" && /* @__PURE__ */ jsx(SortIcon, {})
141
+ ] }),
142
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("contentType"), cursor: "pointer", children: [
143
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
144
+ id: getTranslation("paths.page.column.contentType"),
145
+ defaultMessage: "Content Type"
146
+ }) }),
147
+ sortKey === "contentType" && /* @__PURE__ */ jsx(SortIcon, {})
148
+ ] }),
149
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("type"), cursor: "pointer", children: [
150
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
151
+ id: getTranslation("paths.page.column.type"),
152
+ defaultMessage: "Type"
153
+ }) }),
154
+ sortKey === "type" && /* @__PURE__ */ jsx(SortIcon, {})
155
+ ] }),
156
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: formatMessage({
157
+ id: getTranslation("actions"),
158
+ defaultMessage: "Actions"
159
+ }) }) })
160
+ ] }) });
161
+ }
162
+ const getNavigationPath = (navigationDocumentId, navItemDocumentId) => `/plugins/${PLUGIN_ID}/navigation/${navigationDocumentId}?highlight=${encodeURIComponent(navItemDocumentId)}`;
163
+ function getSafeExternalUrl(path) {
164
+ try {
165
+ const url = new URL(path);
166
+ return url.protocol === "http:" || url.protocol === "https:" ? url.href : null;
167
+ } catch {
168
+ return null;
169
+ }
170
+ }
171
+ function PathActionsMenu({
172
+ route,
173
+ isSingleType,
174
+ canReadNavigation,
175
+ canEdit
176
+ }) {
177
+ const { formatMessage } = useIntl();
178
+ const navigate = useNavigate();
179
+ const { copy } = useClipboard();
180
+ const { toggleNotification } = useNotification();
181
+ const handleCopyPath = async () => {
182
+ const success = await copy(route.path);
183
+ toggleNotification({
184
+ type: success ? "success" : "danger",
185
+ message: success ? formatMessage({
186
+ id: getTranslation("notification.paths.pathCopied"),
187
+ defaultMessage: "Path copied"
188
+ }) : formatMessage({
189
+ id: getTranslation("notification.paths.pathCopyFailed"),
190
+ defaultMessage: "Path could not be copied"
191
+ })
192
+ });
193
+ };
194
+ const editPath = route.type === "internal" && canEdit ? isSingleType ? `/content-manager/single-types/${route.relatedContentType}` : `/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}` : null;
195
+ const externalUrl = route.type === "external" ? getSafeExternalUrl(route.path) : null;
196
+ const navigationsById = /* @__PURE__ */ new Map();
197
+ for (const item of route.navitem ?? []) {
198
+ if (item.navigation && !navigationsById.has(item.navigation.documentId)) {
199
+ navigationsById.set(item.navigation.documentId, {
200
+ ...item.navigation,
201
+ navItemDocumentId: item.documentId
202
+ });
203
+ }
204
+ }
205
+ const navigations = canReadNavigation ? [...navigationsById.values()] : [];
206
+ if (!editPath && !externalUrl && !route.path && navigations.length === 0) return null;
207
+ return /* @__PURE__ */ jsxs(
208
+ SimpleMenu,
209
+ {
210
+ label: formatMessage({
211
+ id: getTranslation("paths.page.actions"),
212
+ defaultMessage: "Path actions"
213
+ }),
214
+ tag: IconButton,
215
+ icon: /* @__PURE__ */ jsx(More, {}),
216
+ children: [
217
+ editPath && /* @__PURE__ */ jsx(MenuItem, { onClick: () => navigate(editPath), children: formatMessage({
218
+ id: getTranslation("edit"),
219
+ defaultMessage: "Edit"
220
+ }) }),
221
+ externalUrl && /* @__PURE__ */ jsx(MenuItem, { isExternal: true, href: externalUrl, children: formatMessage({
222
+ id: getTranslation("paths.page.action.openLink"),
223
+ defaultMessage: "Open link"
224
+ }) }),
225
+ route.path && /* @__PURE__ */ jsx(MenuItem, { onClick: handleCopyPath, children: formatMessage({
226
+ id: getTranslation("paths.page.action.copyPath"),
227
+ defaultMessage: "Copy path"
228
+ }) }),
229
+ navigations.map((navigation) => /* @__PURE__ */ jsx(
230
+ MenuItem,
231
+ {
232
+ onClick: () => navigate(getNavigationPath(navigation.documentId, navigation.navItemDocumentId)),
233
+ children: navigations.length === 1 ? formatMessage({
234
+ id: getTranslation("paths.page.action.showInNavigation"),
235
+ defaultMessage: "Show in navigation"
236
+ }) : formatMessage(
237
+ {
238
+ id: getTranslation("paths.page.action.showInNamedNavigation"),
239
+ defaultMessage: 'Show in navigation "{name}"'
240
+ },
241
+ { name: navigation.name }
242
+ )
243
+ },
244
+ navigation.documentId
245
+ ))
246
+ ]
247
+ }
248
+ );
249
+ }
250
+ const HEALTH_CHECKS = [
251
+ "pathConflict",
252
+ "orphanedRoute",
253
+ "blacklistedPath",
254
+ "invalidExternalUrl",
255
+ "unpublishedInNavigation",
256
+ "tooDeepItem",
257
+ "notInNavigation",
258
+ "emptyWrapper"
259
+ ];
260
+ const SEVERITY_COLORS = {
261
+ error: { backgroundColor: "danger100", textColor: "danger600", borderColor: "danger200" },
262
+ warning: { backgroundColor: "warning100", textColor: "warning600", borderColor: "warning200" },
263
+ info: { backgroundColor: "neutral100", textColor: "neutral600", borderColor: "neutral200" }
264
+ };
265
+ const CHECK_LABELS = {
266
+ pathConflict: "Path conflict",
267
+ orphanedRoute: "Orphaned",
268
+ blacklistedPath: "Blocked path",
269
+ invalidExternalUrl: "Invalid URL",
270
+ unpublishedInNavigation: "Unpublished",
271
+ tooDeepItem: "Too deep",
272
+ notInNavigation: "Not in navigation",
273
+ emptyWrapper: "Empty wrapper"
274
+ };
275
+ const CHECK_DESCRIPTIONS = {
276
+ pathConflict: "Several entries use the same path. The frontend then delivers any one of them.",
277
+ orphanedRoute: "The linked entry or content type no longer exists or is disabled in the plugin settings.",
278
+ blacklistedPath: "The path is blocked by the route blacklist. It only applies to new paths, existing ones stay reachable.",
279
+ invalidExternalUrl: "The external link is no valid URL (http, https, mailto or tel).",
280
+ unpublishedInNavigation: "The entry is not published, so it is missing in the navigation of the frontend.",
281
+ tooDeepItem: "The navigation item is deeper than the maximum depth of its navigation allows.",
282
+ notInNavigation: "The page is not linked in any navigation.",
283
+ emptyWrapper: "The wrapper has no children and shows as an empty item in the navigation."
284
+ };
285
+ const getCheckLabel = (check, { formatMessage }) => formatMessage({
286
+ id: getTranslation(`paths.page.health.check.${check}`),
287
+ defaultMessage: CHECK_LABELS[check]
288
+ });
289
+ const getCheckDescription = (check, { formatMessage }) => formatMessage({
290
+ id: getTranslation(`paths.page.health.check.${check}.description`),
291
+ defaultMessage: CHECK_DESCRIPTIONS[check]
292
+ });
293
+ function getIssueMessage({ check, details = {} }, intl) {
294
+ const { formatMessage } = intl;
295
+ switch (check) {
296
+ case "pathConflict":
297
+ return formatMessage(
298
+ {
299
+ id: getTranslation("paths.page.health.issue.pathConflict"),
300
+ defaultMessage: '"{value}" is also used by: {routes}'
301
+ },
302
+ {
303
+ value: details.value,
304
+ routes: details.conflictingRoutes?.map((route) => route.title).join(", ")
305
+ }
306
+ );
307
+ case "orphanedRoute":
308
+ return formatMessage({
309
+ id: getTranslation(`paths.page.health.issue.orphanedRoute.${details.reason}`),
310
+ defaultMessage: CHECK_DESCRIPTIONS.orphanedRoute
311
+ });
312
+ case "blacklistedPath":
313
+ return formatMessage(
314
+ {
315
+ id: getTranslation("paths.page.health.issue.blacklistedPath"),
316
+ defaultMessage: '"{value}" is blocked by the route blacklist'
317
+ },
318
+ { value: details.value }
319
+ );
320
+ case "invalidExternalUrl":
321
+ return formatMessage(
322
+ {
323
+ id: getTranslation("paths.page.health.issue.invalidExternalUrl"),
324
+ defaultMessage: '"{value}" is no valid URL'
325
+ },
326
+ { value: details.value }
327
+ );
328
+ case "unpublishedInNavigation":
329
+ return formatMessage(
330
+ {
331
+ id: getTranslation("paths.page.health.issue.unpublishedInNavigation"),
332
+ defaultMessage: 'Not published, but used in the navigation "{navigation}"'
333
+ },
334
+ { navigation: details.navigationName }
335
+ );
336
+ case "tooDeepItem":
337
+ return formatMessage(
338
+ {
339
+ id: getTranslation("paths.page.health.issue.tooDeepItem"),
340
+ defaultMessage: 'On level {depth} in "{navigation}", {maxDepth, plural, one {# level is} other {# levels are}} allowed'
341
+ },
342
+ {
343
+ navigation: details.navigationName,
344
+ depth: (details.depth ?? 0) + 1,
345
+ maxDepth: (details.maxDepth ?? 0) + 1
346
+ }
347
+ );
348
+ case "emptyWrapper":
349
+ return formatMessage(
350
+ {
351
+ id: getTranslation("paths.page.health.issue.emptyWrapper"),
352
+ defaultMessage: 'Without children in the navigation "{navigation}"'
353
+ },
354
+ { navigation: details.navigationName }
355
+ );
356
+ default:
357
+ return getCheckDescription(check, intl);
358
+ }
359
+ }
360
+ function IssueBadges({ issues }) {
361
+ const intl = useIntl();
362
+ const issuesByCheck = /* @__PURE__ */ new Map();
363
+ for (const issue of issues) {
364
+ issuesByCheck.set(issue.check, [...issuesByCheck.get(issue.check) ?? [], issue]);
365
+ }
366
+ return /* @__PURE__ */ jsx(Flex, { gap: 2, wrap: "wrap", children: HEALTH_CHECKS.filter((check) => issuesByCheck.has(check)).map((check) => {
367
+ const checkIssues = issuesByCheck.get(check);
368
+ return /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
369
+ /* @__PURE__ */ jsx(Badge, { ...SEVERITY_COLORS[checkIssues[0].severity], children: getCheckLabel(check, intl) }),
370
+ /* @__PURE__ */ jsx(
371
+ Tooltip,
372
+ {
373
+ description: [
374
+ ...new Set(checkIssues.map((issue) => getIssueMessage(issue, intl)))
375
+ ].join("; ")
376
+ }
377
+ )
378
+ ] }, check);
379
+ }) });
380
+ }
381
+ function TableRow({
382
+ route,
383
+ isSingleType,
384
+ contentTypeLabel,
385
+ issues,
386
+ canReadNavigation,
387
+ canEdit
388
+ }) {
389
+ const { formatMessage } = useIntl();
390
+ const hasDeviation = hasPathDeviation(route);
391
+ return /* @__PURE__ */ jsxs(Tr, { children: [
392
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { alignItems: "flex-start", gap: 2, children: [
393
+ /* @__PURE__ */ jsx(Typography, { title: route.title, textColor: "neutral800", children: route.title || "-" }),
394
+ issues && issues.length > 0 && /* @__PURE__ */ jsx(IssueBadges, { issues })
395
+ ] }) }),
396
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
397
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
398
+ /* @__PURE__ */ jsx(Typography, { title: route.path, textColor: "neutral800", children: route.path || "-" }),
399
+ hasDeviation && /* @__PURE__ */ jsxs(Fragment, { children: [
400
+ /* @__PURE__ */ jsx(
401
+ Badge,
402
+ {
403
+ backgroundColor: "secondary100",
404
+ textColor: "secondary600",
405
+ borderColor: "secondary200",
406
+ children: formatMessage({
407
+ id: getTranslation("paths.page.deviation"),
408
+ defaultMessage: "Differs"
409
+ })
410
+ }
411
+ ),
412
+ /* @__PURE__ */ jsx(
413
+ Tooltip,
414
+ {
415
+ description: formatMessage({
416
+ id: getTranslation("paths.page.deviation.description"),
417
+ defaultMessage: "The path differs from the content structure, due to the position in the navigation or a manual override"
418
+ })
419
+ }
420
+ )
421
+ ] })
422
+ ] }),
423
+ hasDeviation && /* @__PURE__ */ jsxs(Typography, { title: route.canonicalPath, variant: "pi", textColor: "neutral600", children: [
424
+ "↳",
425
+ " ",
426
+ formatMessage(
427
+ {
428
+ id: getTranslation("paths.page.canonicalPathHint"),
429
+ defaultMessage: "Canonical Path: {path}"
430
+ },
431
+ { path: route.canonicalPath }
432
+ )
433
+ ] })
434
+ ] }) }),
435
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { title: route.relatedContentType, textColor: "neutral800", children: contentTypeLabel || "-" }) }),
436
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { title: route.type, textColor: "neutral800", children: formatMessage({
437
+ id: getTranslation(`path.type.${route.type}`),
438
+ defaultMessage: "-"
439
+ }) }) }),
440
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Flex, { justifyContent: "end", children: /* @__PURE__ */ jsx(
441
+ PathActionsMenu,
442
+ {
443
+ route,
444
+ isSingleType,
445
+ canReadNavigation,
446
+ canEdit
447
+ }
448
+ ) }) })
449
+ ] });
450
+ }
451
+ function PathTable({
452
+ routes,
453
+ sortKey,
454
+ sortDirection,
455
+ handleSort,
456
+ singleTypeUids,
457
+ contentTypeLabels,
458
+ issuesByRoute,
459
+ canReadNavigation,
460
+ readableContentTypes,
461
+ hasSearch,
462
+ hasActiveFilters,
463
+ handleClearSearch,
464
+ handleResetFilters
465
+ }) {
466
+ const { formatMessage } = useIntl();
467
+ const TABLE_COL_COUNT = 5;
468
+ return /* @__PURE__ */ jsxs(Table, { colCount: TABLE_COL_COUNT, rowCount: routes.length, children: [
469
+ /* @__PURE__ */ jsx(TableHeader, { sortKey, sortDirection, handleSort }),
470
+ /* @__PURE__ */ jsx(Tbody, { children: routes.length > 0 ? routes.map((route) => /* @__PURE__ */ jsx(
471
+ TableRow,
472
+ {
473
+ route,
474
+ isSingleType: singleTypeUids.has(route.relatedContentType),
475
+ contentTypeLabel: contentTypeLabels.get(route.relatedContentType),
476
+ issues: issuesByRoute.get(route.documentId),
477
+ canReadNavigation,
478
+ canEdit: readableContentTypes.has(route.relatedContentType)
479
+ },
480
+ route.id
481
+ )) : /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan: TABLE_COL_COUNT, children: hasSearch || hasActiveFilters ? /* @__PURE__ */ jsx(
482
+ EmptyStateLayout,
483
+ {
484
+ shadow: "none",
485
+ content: formatMessage({
486
+ id: getTranslation("paths.page.emptyFiltered"),
487
+ defaultMessage: "No paths match the current search or filters"
488
+ }),
489
+ action: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
490
+ hasActiveFilters && /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: handleResetFilters, children: formatMessage({
491
+ id: getTranslation("paths.page.filter.reset"),
492
+ defaultMessage: "Reset filters"
493
+ }) }),
494
+ hasSearch && /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: handleClearSearch, children: formatMessage({
495
+ id: getTranslation("paths.page.clearSearch"),
496
+ defaultMessage: "Clear search"
497
+ }) })
498
+ ] })
499
+ }
500
+ ) : /* @__PURE__ */ jsx(
501
+ EmptyStateLayout,
502
+ {
503
+ shadow: "none",
504
+ content: formatMessage({
505
+ id: getTranslation("paths.page.emptyPaths"),
506
+ defaultMessage: "No paths found"
507
+ })
508
+ }
509
+ ) }) }) })
510
+ ] });
511
+ }
512
+ const ROUTE_TYPES = ["internal", "external", "wrapper"];
513
+ const FILTER_WIDTH = "200px";
514
+ function PathFilters({
515
+ contentTypeOptions,
516
+ selectedContentTypes,
517
+ type,
518
+ deviation,
519
+ navigation,
520
+ handleFilterChange,
521
+ handleResetFilters,
522
+ hasActiveFilters
523
+ }) {
524
+ const { formatMessage } = useIntl();
525
+ const clearLabel = formatMessage({
526
+ id: getTranslation("paths.page.filter.clear"),
527
+ defaultMessage: "Clear filter"
528
+ });
529
+ const contentTypePlaceholder = formatMessage({
530
+ id: getTranslation("paths.page.filter.contentType"),
531
+ defaultMessage: "Content Type"
532
+ });
533
+ const typePlaceholder = formatMessage({
534
+ id: getTranslation("paths.page.filter.type"),
535
+ defaultMessage: "Type"
536
+ });
537
+ const deviationPlaceholder = formatMessage({
538
+ id: getTranslation("paths.page.filter.deviation.placeholder"),
539
+ defaultMessage: "Deviation"
540
+ });
541
+ const navigationPlaceholder = formatMessage({
542
+ id: getTranslation("paths.page.filter.navigation.placeholder"),
543
+ defaultMessage: "Navigation"
544
+ });
545
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
546
+ /* @__PURE__ */ jsx(Box, { width: FILTER_WIDTH, children: /* @__PURE__ */ jsx(
547
+ MultiSelect,
548
+ {
549
+ "aria-label": contentTypePlaceholder,
550
+ placeholder: contentTypePlaceholder,
551
+ value: selectedContentTypes,
552
+ onChange: (values) => handleFilterChange("contentType", values),
553
+ onClear: () => handleFilterChange("contentType", []),
554
+ clearLabel,
555
+ customizeContent: (values) => values?.length === 1 ? contentTypeOptions.find((option) => option.uid === values[0])?.label ?? values[0] : `${contentTypePlaceholder} (${values?.length ?? 0})`,
556
+ children: contentTypeOptions.map((option) => /* @__PURE__ */ jsx(MultiSelectOption, { value: option.uid, children: option.label }, option.uid))
557
+ }
558
+ ) }),
559
+ /* @__PURE__ */ jsx(Box, { width: FILTER_WIDTH, children: /* @__PURE__ */ jsx(
560
+ SingleSelect,
561
+ {
562
+ "aria-label": typePlaceholder,
563
+ placeholder: typePlaceholder,
564
+ value: type ?? "",
565
+ onChange: (value) => handleFilterChange("type", [String(value)]),
566
+ onClear: () => handleFilterChange("type", []),
567
+ clearLabel,
568
+ children: ROUTE_TYPES.map((routeType) => /* @__PURE__ */ jsx(SingleSelectOption, { value: routeType, children: formatMessage({
569
+ id: getTranslation(`path.type.${routeType}`),
570
+ defaultMessage: routeType
571
+ }) }, routeType))
572
+ }
573
+ ) }),
574
+ /* @__PURE__ */ jsx(Box, { width: FILTER_WIDTH, children: /* @__PURE__ */ jsxs(
575
+ SingleSelect,
576
+ {
577
+ "aria-label": deviationPlaceholder,
578
+ placeholder: deviationPlaceholder,
579
+ value: deviation ?? "",
580
+ onChange: (value) => handleFilterChange("deviation", [String(value)]),
581
+ onClear: () => handleFilterChange("deviation", []),
582
+ clearLabel,
583
+ children: [
584
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "true", children: formatMessage({
585
+ id: getTranslation("paths.page.filter.deviation.true"),
586
+ defaultMessage: "Differs"
587
+ }) }),
588
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "false", children: formatMessage({
589
+ id: getTranslation("paths.page.filter.deviation.false"),
590
+ defaultMessage: "Matches"
591
+ }) })
592
+ ]
593
+ }
594
+ ) }),
595
+ /* @__PURE__ */ jsx(Box, { width: FILTER_WIDTH, children: /* @__PURE__ */ jsxs(
596
+ SingleSelect,
597
+ {
598
+ "aria-label": navigationPlaceholder,
599
+ placeholder: navigationPlaceholder,
600
+ value: navigation ?? "",
601
+ onChange: (value) => handleFilterChange("navigation", [String(value)]),
602
+ onClear: () => handleFilterChange("navigation", []),
603
+ clearLabel,
604
+ children: [
605
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "true", children: formatMessage({
606
+ id: getTranslation("paths.page.filter.navigation.true"),
607
+ defaultMessage: "In navigation"
608
+ }) }),
609
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "false", children: formatMessage({
610
+ id: getTranslation("paths.page.filter.navigation.false"),
611
+ defaultMessage: "Not in navigation"
612
+ }) })
613
+ ]
614
+ }
615
+ ) }),
616
+ hasActiveFilters && /* @__PURE__ */ jsx(
617
+ Button,
618
+ {
619
+ variant: "tertiary",
620
+ size: "L",
621
+ startIcon: /* @__PURE__ */ jsx(ArrowClockwise, {}),
622
+ onClick: handleResetFilters,
623
+ children: formatMessage({
624
+ id: getTranslation("paths.page.filter.reset"),
625
+ defaultMessage: "Reset filters"
626
+ })
627
+ }
628
+ )
629
+ ] });
630
+ }
631
+ const SEVERITIES = ["error", "warning", "info"];
632
+ function HealthSummary({
633
+ report,
634
+ loading,
635
+ activeCheck,
636
+ handleSelectCheck,
637
+ handleRecheck
638
+ }) {
639
+ const intl = useIntl();
640
+ const { formatMessage } = intl;
641
+ const [expanded, setExpanded] = useState(false);
642
+ const routesByCheck = /* @__PURE__ */ new Map();
643
+ for (const issue of report?.issues ?? []) {
644
+ const routes = routesByCheck.get(issue.check) ?? /* @__PURE__ */ new Set();
645
+ routes.add(issue.routeDocumentId);
646
+ routesByCheck.set(issue.check, routes);
647
+ }
648
+ const checks = HEALTH_CHECKS.filter((check) => routesByCheck.has(check));
649
+ const severityOf = (check) => report.issues.find((issue) => issue.check === check).severity;
650
+ const countBySeverity = (severity) => checks.filter((check) => severityOf(check) === severity).reduce((sum, check) => sum + routesByCheck.get(check).size, 0);
651
+ const summaryText = SEVERITIES.map((severity) => ({ severity, count: countBySeverity(severity) })).filter(({ count }) => count > 0).map(
652
+ ({ severity, count }) => formatMessage(
653
+ {
654
+ id: getTranslation(`paths.page.health.summary.${severity}`),
655
+ defaultMessage: {
656
+ error: "{count, plural, one {# error} other {# errors}}",
657
+ warning: "{count, plural, one {# warning} other {# warnings}}",
658
+ info: "{count, plural, one {# hint} other {# hints}}"
659
+ }[severity]
660
+ },
661
+ { count }
662
+ )
663
+ ).join(" · ");
664
+ const hasErrors = checks.some((check) => severityOf(check) === "error");
665
+ return /* @__PURE__ */ jsxs(
666
+ Box,
667
+ {
668
+ marginBottom: 4,
669
+ padding: 4,
670
+ background: "neutral0",
671
+ hasRadius: true,
672
+ shadow: "tableShadow",
673
+ borderColor: hasErrors ? "danger200" : void 0,
674
+ borderStyle: hasErrors ? "solid" : void 0,
675
+ borderWidth: hasErrors ? "1px" : void 0,
676
+ children: [
677
+ /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
678
+ /* @__PURE__ */ jsx(Flex, { gap: 2, children: loading ? /* @__PURE__ */ jsxs(Fragment, { children: [
679
+ /* @__PURE__ */ jsx(Loader, { small: true }),
680
+ /* @__PURE__ */ jsx(Typography, { children: formatMessage({
681
+ id: getTranslation("paths.page.health.loading"),
682
+ defaultMessage: "Checking paths …"
683
+ }) })
684
+ ] }) : !report ? /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
685
+ id: getTranslation("paths.page.health.unavailable"),
686
+ defaultMessage: "The paths could not be checked"
687
+ }) }) : checks.length === 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
688
+ /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
689
+ /* @__PURE__ */ jsx(Typography, { children: formatMessage({
690
+ id: getTranslation("paths.page.health.noIssues"),
691
+ defaultMessage: "No issues found"
692
+ }) })
693
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
694
+ /* @__PURE__ */ jsx(WarningCircle, { fill: hasErrors ? "danger600" : "warning600" }),
695
+ /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: summaryText })
696
+ ] }) }),
697
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
698
+ !loading && checks.length > 0 && /* @__PURE__ */ jsx(
699
+ Button,
700
+ {
701
+ variant: "tertiary",
702
+ endIcon: expanded ? /* @__PURE__ */ jsx(ChevronUp, {}) : /* @__PURE__ */ jsx(ChevronDown, {}),
703
+ onClick: () => setExpanded((current) => !current),
704
+ children: expanded ? formatMessage({
705
+ id: getTranslation("paths.page.health.hideDetails"),
706
+ defaultMessage: "Hide details"
707
+ }) : formatMessage({
708
+ id: getTranslation("paths.page.health.showDetails"),
709
+ defaultMessage: "Show details"
710
+ })
711
+ }
712
+ ),
713
+ /* @__PURE__ */ jsx(
714
+ Button,
715
+ {
716
+ variant: "tertiary",
717
+ startIcon: /* @__PURE__ */ jsx(ArrowClockwise, {}),
718
+ onClick: handleRecheck,
719
+ disabled: loading,
720
+ children: formatMessage({
721
+ id: getTranslation("paths.page.health.recheck"),
722
+ defaultMessage: "Check again"
723
+ })
724
+ }
725
+ )
726
+ ] })
727
+ ] }),
728
+ expanded && !loading && checks.length > 0 && /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, marginTop: 4, children: checks.map((check) => {
729
+ const isActive = activeCheck === check;
730
+ return /* @__PURE__ */ jsxs(
731
+ Flex,
732
+ {
733
+ gap: 4,
734
+ justifyContent: "space-between",
735
+ padding: 3,
736
+ hasRadius: true,
737
+ background: isActive ? "primary100" : "neutral100",
738
+ children: [
739
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
740
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
741
+ /* @__PURE__ */ jsx(Badge, { ...SEVERITY_COLORS[severityOf(check)], children: getCheckLabel(check, intl) }),
742
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: formatMessage(
743
+ {
744
+ id: getTranslation("paths.page.health.affected"),
745
+ defaultMessage: "{count, plural, one {# path} other {# paths}}"
746
+ },
747
+ { count: routesByCheck.get(check).size }
748
+ ) })
749
+ ] }),
750
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: getCheckDescription(check, intl) })
751
+ ] }),
752
+ /* @__PURE__ */ jsx(
753
+ Button,
754
+ {
755
+ variant: isActive ? "secondary" : "tertiary",
756
+ onClick: () => handleSelectCheck(isActive ? null : check),
757
+ children: isActive ? formatMessage({
758
+ id: getTranslation("paths.page.health.hidePaths"),
759
+ defaultMessage: "Show all paths"
760
+ }) : formatMessage({
761
+ id: getTranslation("paths.page.health.showPaths"),
762
+ defaultMessage: "Show paths"
763
+ })
764
+ }
765
+ )
766
+ ]
767
+ },
768
+ check
769
+ );
770
+ }) })
771
+ ]
772
+ }
773
+ );
774
+ }
775
+ const DEFAULT_PAGE_SIZE = 20;
776
+ const Paths = () => {
777
+ const { getAllRoutes, getHealthReport } = useApi();
778
+ const { formatMessage } = useIntl();
779
+ const { toggleNotification } = useNotification();
780
+ const getErrorMessage = useErrorMessage();
781
+ const { contentTypes } = useAllContentTypes();
782
+ const {
783
+ isLoading: isLoadingNavigationPermission,
784
+ allowedActions: { canRead }
785
+ } = useRBAC(pluginPermissions["navigation.read"]);
786
+ const canReadNavigation = !isLoadingNavigationPermission && canRead;
787
+ const userPermissions = useAuth("Paths", (state) => state.permissions);
788
+ const readableContentTypes = useMemo(
789
+ () => new Set(
790
+ userPermissions.filter(
791
+ (permission) => permission.action === "plugin::content-manager.explorer.read" && permission.subject
792
+ ).map((permission) => permission.subject)
793
+ ),
794
+ [userPermissions]
795
+ );
796
+ const [allRoutes, setAllRoutes] = useState([]);
797
+ const [routes, setRoutes] = useState([]);
798
+ const [loading, setLoading] = useState(true);
799
+ const [searchParams, setSearchParams] = useSearchParams();
800
+ const initialQuery = searchParams.get("search") || "";
801
+ const [searchQuery, setSearchQuery] = useState(initialQuery);
802
+ const [sortKey, setSortKey] = useState("path");
803
+ const [sortDirection, setSortDirection] = useState("asc");
804
+ const [healthReport, setHealthReport] = useState(null);
805
+ const [healthLoading, setHealthLoading] = useState(true);
806
+ const contentTypeFilter = searchParams.getAll("contentType");
807
+ const contentTypeFilterKey = contentTypeFilter.join(",");
808
+ const typeFilter = searchParams.get("type");
809
+ const deviationFilter = searchParams.get("deviation");
810
+ const navigationFilter = searchParams.get("navigation");
811
+ const issueFilter = searchParams.get("issue");
812
+ const issuesByRoute = useMemo(() => {
813
+ const map = /* @__PURE__ */ new Map();
814
+ for (const issue of healthReport?.issues ?? []) {
815
+ map.set(issue.routeDocumentId, [...map.get(issue.routeDocumentId) ?? [], issue]);
816
+ }
817
+ return map;
818
+ }, [healthReport]);
819
+ useEffect(() => {
820
+ const query = searchQuery.toLowerCase();
821
+ setRoutes(
822
+ allRoutes.filter(
823
+ (route) => (contentTypeFilter.length === 0 || contentTypeFilter.includes(route.relatedContentType)) && (!typeFilter || route.type === typeFilter) && (!deviationFilter || String(hasPathDeviation(route)) === deviationFilter) && (!navigationFilter || String(!!route.navitem?.length) === navigationFilter) && (!issueFilter || !!issuesByRoute.get(route.documentId)?.some((issue) => issue.check === issueFilter)) && (JSON.stringify(route.id).toLowerCase().includes(query) || route.title.toLowerCase().includes(query) || route.path.toLowerCase().includes(query) || route.canonicalPath?.toLowerCase().includes(query) || route.relatedDocumentId.toLowerCase().includes(query) || route.relatedContentType.toLowerCase().includes(query))
824
+ )
825
+ );
826
+ }, [
827
+ searchQuery,
828
+ allRoutes,
829
+ contentTypeFilterKey,
830
+ typeFilter,
831
+ deviationFilter,
832
+ navigationFilter,
833
+ issueFilter,
834
+ issuesByRoute
835
+ ]);
836
+ const handleFilterChange = (key, values) => {
837
+ setSearchParams((prev) => {
838
+ const next = new URLSearchParams(prev);
839
+ next.delete(key);
840
+ values.filter(Boolean).forEach((value) => next.append(key, value));
841
+ next.delete("page");
842
+ return next;
843
+ });
844
+ };
845
+ const handleResetFilters = () => {
846
+ setSearchParams((prev) => {
847
+ const next = new URLSearchParams(prev);
848
+ const filterKeys = [
849
+ "contentType",
850
+ "type",
851
+ "deviation",
852
+ "navigation",
853
+ "issue"
854
+ ];
855
+ filterKeys.forEach((key) => next.delete(key));
856
+ next.delete("page");
857
+ return next;
858
+ });
859
+ };
860
+ const debouncedSetSearchParams = useMemo(
861
+ () => debounce((value) => {
862
+ setSearchParams((prev) => {
863
+ const next = new URLSearchParams(prev);
864
+ value ? next.set("search", value) : next.delete("search");
865
+ next.delete("page");
866
+ return next;
867
+ });
868
+ }, 300),
869
+ [setSearchParams]
870
+ );
871
+ const handleSearchChange = (e) => {
872
+ const value = e.target.value;
873
+ setSearchQuery(value);
874
+ debouncedSetSearchParams(value);
875
+ };
876
+ useEffect(() => {
877
+ async function fetchRoutes() {
878
+ try {
879
+ const data = await getAllRoutes();
880
+ setAllRoutes(data);
881
+ setRoutes(data);
882
+ } catch (err) {
883
+ if (isAbortError(err)) return;
884
+ console.error("Failed to fetch paths:", err);
885
+ toggleNotification({
886
+ type: "danger",
887
+ message: getErrorMessage(
888
+ err,
889
+ formatMessage({
890
+ id: getTranslation("notification.paths.fetchFailed"),
891
+ defaultMessage: "Failed to fetch paths"
892
+ })
893
+ )
894
+ });
895
+ } finally {
896
+ setLoading(false);
897
+ }
898
+ }
899
+ fetchRoutes();
900
+ }, []);
901
+ const loadHealthReport = useCallback(async () => {
902
+ setHealthLoading(true);
903
+ try {
904
+ setHealthReport(await getHealthReport());
905
+ } catch (err) {
906
+ if (isAbortError(err)) return;
907
+ console.error("Failed to check paths:", err);
908
+ setHealthReport(null);
909
+ toggleNotification({
910
+ type: "danger",
911
+ message: getErrorMessage(
912
+ err,
913
+ formatMessage({
914
+ id: getTranslation("notification.paths.healthFailed"),
915
+ defaultMessage: "The paths could not be checked"
916
+ })
917
+ )
918
+ });
919
+ } finally {
920
+ setHealthLoading(false);
921
+ }
922
+ }, []);
923
+ useEffect(() => {
924
+ loadHealthReport();
925
+ }, [loadHealthReport]);
926
+ const handleSort = (key) => {
927
+ setSortDirection((prev) => key === sortKey && prev === "asc" ? "desc" : "asc");
928
+ setSortKey(key);
929
+ };
930
+ const singleTypeUids = useMemo(
931
+ () => new Set(contentTypes.filter((ct) => ct.kind === "singleType").map((ct) => ct.uid)),
932
+ [contentTypes]
933
+ );
934
+ const contentTypeOptions = useMemo(() => {
935
+ const uids = [...new Set(allRoutes.map((route) => route.relatedContentType).filter(Boolean))];
936
+ return uids.map((uid) => ({
937
+ uid,
938
+ label: contentTypes.find((ct) => ct.uid === uid)?.info.displayName ?? uid
939
+ })).sort((a, b) => a.label.localeCompare(b.label));
940
+ }, [allRoutes, contentTypes]);
941
+ const hasActiveFilters = contentTypeFilter.length > 0 || !!typeFilter || !!deviationFilter || !!navigationFilter || !!issueFilter;
942
+ const isFiltered = !!searchQuery || hasActiveFilters;
943
+ const handleClearSearch = () => {
944
+ setSearchQuery("");
945
+ debouncedSetSearchParams("");
946
+ };
947
+ const contentTypeLabels = useMemo(
948
+ () => new Map(contentTypeOptions.map((option) => [option.uid, option.label])),
949
+ [contentTypeOptions]
950
+ );
951
+ const sortedRoutes = useMemo(() => {
952
+ return sortKey ? [...routes].sort(compareBy(sortKey, sortDirection, contentTypeLabels)) : routes;
953
+ }, [routes, sortKey, sortDirection, contentTypeLabels]);
954
+ const pageSize = Math.max(1, Number(searchParams.get("pageSize")) || DEFAULT_PAGE_SIZE);
955
+ const pageCount = Math.max(1, Math.ceil(sortedRoutes.length / pageSize));
956
+ const page = Math.min(Math.max(1, Number(searchParams.get("page")) || 1), pageCount);
957
+ const paginatedRoutes = useMemo(
958
+ () => sortedRoutes.slice((page - 1) * pageSize, page * pageSize),
959
+ [sortedRoutes, page, pageSize]
960
+ );
961
+ if (loading) {
962
+ return /* @__PURE__ */ jsx(PageWrapper, { children: /* @__PURE__ */ jsx(FullLoader, {}) });
963
+ }
964
+ return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions["page.routes"], children: /* @__PURE__ */ jsxs(PageWrapper, { total: allRoutes.length, matches: isFiltered ? routes.length : void 0, children: [
965
+ /* @__PURE__ */ jsx(
966
+ HealthSummary,
967
+ {
968
+ report: healthReport,
969
+ loading: healthLoading,
970
+ activeCheck: issueFilter,
971
+ handleSelectCheck: (check) => handleFilterChange("issue", check ? [check] : []),
972
+ handleRecheck: loadHealthReport
973
+ }
974
+ ),
975
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", marginBottom: 4, children: [
976
+ /* @__PURE__ */ jsx(Box, { width: "320px", marginRight: 4, children: /* @__PURE__ */ jsx(SearchInput, { handleSearchChange, searchQuery }) }),
977
+ /* @__PURE__ */ jsx(
978
+ PathFilters,
979
+ {
980
+ contentTypeOptions,
981
+ selectedContentTypes: contentTypeFilter,
982
+ type: typeFilter,
983
+ deviation: deviationFilter,
984
+ navigation: navigationFilter,
985
+ handleFilterChange,
986
+ handleResetFilters,
987
+ hasActiveFilters
988
+ }
989
+ )
990
+ ] }),
991
+ /* @__PURE__ */ jsx(
992
+ PathTable,
993
+ {
994
+ routes: paginatedRoutes,
995
+ sortKey,
996
+ sortDirection,
997
+ handleSort,
998
+ singleTypeUids,
999
+ contentTypeLabels,
1000
+ issuesByRoute,
1001
+ canReadNavigation,
1002
+ readableContentTypes,
1003
+ hasSearch: !!searchQuery,
1004
+ hasActiveFilters,
1005
+ handleClearSearch,
1006
+ handleResetFilters
1007
+ }
1008
+ ),
1009
+ /* @__PURE__ */ jsxs(
1010
+ Pagination.Root,
1011
+ {
1012
+ pageCount,
1013
+ total: sortedRoutes.length,
1014
+ defaultPageSize: DEFAULT_PAGE_SIZE,
1015
+ children: [
1016
+ /* @__PURE__ */ jsx(Pagination.PageSize, {}),
1017
+ /* @__PURE__ */ jsx(Pagination.Links, {})
1018
+ ]
1019
+ }
1020
+ )
1021
+ ] }) });
1022
+ };
1023
+ export {
1024
+ Paths as default
1025
+ };