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