@mattisvensson/strapi-plugin-webatlas 0.13.0 → 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 (184) hide show
  1. package/dist/admin/{ContentBox-D4PGQ8eh.js → ContentBox-CHwpYMiB.js} +1 -1
  2. package/dist/admin/{ContentBox-KyQN2KGV.mjs → ContentBox-CYnyB_5a.mjs} +1 -1
  3. package/dist/admin/{RoutePicker-CgndSXoF.mjs → RoutePicker-43YnYCpH.mjs} +1 -1
  4. package/dist/admin/{RoutePicker-CwoMMhf_.js → RoutePicker-D9zf-VdN.js} +1 -1
  5. package/dist/admin/{de-Cl0vM1wA.js → de-DolV3m7M.js} +64 -1
  6. package/dist/admin/{de-DWs5ckOd.mjs → de-Dt3jjL3h.mjs} +64 -1
  7. package/dist/admin/{en-CyhISGZi.mjs → en-CCRmKJEV.mjs} +63 -0
  8. package/dist/admin/{en-DSmtmPYk.js → en-jWdO5RMZ.js} +63 -0
  9. package/dist/admin/{index-uOC1Clyv.js → index-7iO5UsYI.js} +2 -2
  10. package/dist/admin/{index-Bv5Ri-ri.mjs → index-B2k8Pikg.mjs} +2 -2
  11. package/dist/admin/{index-Ctm4TBT5.mjs → index-CK4JyItR.mjs} +63 -8
  12. package/dist/admin/{index-BKhrfzjO.mjs → index-CMuhLgfi.mjs} +16 -11
  13. package/dist/admin/{index-BxGPKxr_.js → index-Ciem6YTr.js} +2 -2
  14. package/dist/admin/{index-FvaXwOH0.mjs → index-DGYmrx3f.mjs} +2 -2
  15. package/dist/admin/index-Ddnt9W-v.mjs +1025 -0
  16. package/dist/admin/{index-JBUU7dE6.js → index-DfG_hSMk.js} +60 -5
  17. package/dist/admin/{index-DTrsl_uN.js → index-DmOWQK6g.js} +12 -7
  18. package/dist/admin/index-dB79zyxi.js +1025 -0
  19. package/dist/admin/index.js +1 -1
  20. package/dist/admin/index.mjs +1 -1
  21. package/dist/admin/src/components/CMEditViewAside/NewPathInfo.d.ts +5 -0
  22. package/dist/admin/src/components/CMEditViewAside/OverrideCheckbox.d.ts +7 -0
  23. package/dist/admin/src/components/CMEditViewAside/Panel.d.ts +5 -0
  24. package/dist/admin/src/components/CMEditViewAside/PathInput.d.ts +12 -0
  25. package/dist/admin/src/components/CMEditViewAside/RouteStructure.d.ts +3 -0
  26. package/dist/admin/src/components/CMEditViewAside/UidPathDisplay.d.ts +4 -0
  27. package/dist/admin/src/components/CMEditViewAside/index.d.ts +3 -0
  28. package/dist/admin/src/components/Initializer.d.ts +5 -0
  29. package/dist/admin/src/components/PathInfo.d.ts +8 -0
  30. package/dist/admin/src/components/PluginIcon.d.ts +3 -0
  31. package/dist/admin/src/components/Tooltip.d.ts +3 -0
  32. package/dist/admin/src/components/UI/Center.d.ts +4 -0
  33. package/dist/admin/src/components/UI/EmptyBox.d.ts +5 -0
  34. package/dist/admin/src/components/UI/FullLoader.d.ts +3 -0
  35. package/dist/admin/src/components/UI/WarningBox.d.ts +4 -0
  36. package/dist/admin/src/components/UI/index.d.ts +5 -0
  37. package/dist/admin/src/components/customFields/RoutePicker.d.ts +25 -0
  38. package/dist/admin/src/components/modals/Delete.d.ts +7 -0
  39. package/dist/admin/src/components/modals/DiscardChanges.d.ts +3 -0
  40. package/dist/admin/src/components/modals/NavCreate.d.ts +1 -0
  41. package/dist/admin/src/components/modals/NavEdit.d.ts +7 -0
  42. package/dist/admin/src/components/modals/NavModal.d.ts +16 -0
  43. package/dist/admin/src/components/modals/NavOverview.d.ts +10 -0
  44. package/dist/admin/src/components/modals/SaveConfirm.d.ts +8 -0
  45. package/dist/admin/src/components/modals/externalItem/index.d.ts +15 -0
  46. package/dist/admin/src/components/modals/index.d.ts +14 -0
  47. package/dist/admin/src/components/modals/internalItem/EntrySelection.d.ts +17 -0
  48. package/dist/admin/src/components/modals/internalItem/ItemDetails.d.ts +13 -0
  49. package/dist/admin/src/components/modals/internalItem/MultiItemReview.d.ts +23 -0
  50. package/dist/admin/src/components/modals/internalItem/internalItemCreate.d.ts +2 -0
  51. package/dist/admin/src/components/modals/internalItem/internalItemEdit.d.ts +2 -0
  52. package/dist/admin/src/components/modals/useModalSharedLogic.d.ts +2 -0
  53. package/dist/admin/src/components/modals/withModalSharedLogic.d.ts +3 -0
  54. package/dist/admin/src/components/modals/wrapperItem/index.d.ts +15 -0
  55. package/dist/admin/src/contexts/index.d.ts +17 -0
  56. package/dist/admin/src/hooks/index.d.ts +7 -0
  57. package/dist/admin/src/hooks/useAllContentTypes.d.ts +7 -0
  58. package/dist/admin/src/hooks/useAllEntities.d.ts +7 -0
  59. package/dist/admin/src/hooks/useApi.d.ts +23 -0
  60. package/dist/admin/src/hooks/useEntrySearch.d.ts +13 -0
  61. package/dist/admin/src/hooks/useErrorMessage.d.ts +8 -0
  62. package/dist/admin/src/hooks/usePluginConfig.d.ts +9 -0
  63. package/dist/admin/src/pages/Navigation/Page.d.ts +2 -0
  64. package/dist/admin/src/pages/Navigation/PageWrapper.d.ts +8 -0
  65. package/dist/admin/src/pages/Navigation/RouteItem.d.ts +2 -0
  66. package/dist/admin/src/pages/Navigation/RouteItemBadge.d.ts +4 -0
  67. package/dist/admin/src/pages/Navigation/RouteItemIcon.d.ts +5 -0
  68. package/dist/admin/src/pages/Navigation/RouteItemMenu.d.ts +12 -0
  69. package/dist/admin/src/pages/Navigation/RouteItemStatus.d.ts +5 -0
  70. package/dist/admin/src/pages/Navigation/SortableRouteItem.d.ts +2 -0
  71. package/dist/admin/src/pages/Navigation/UnsavedChangesBlocker.d.ts +8 -0
  72. package/dist/admin/src/pages/Navigation/index.d.ts +2 -0
  73. package/dist/admin/src/pages/Navigation/useCollapsedItems.d.ts +13 -0
  74. package/dist/admin/src/pages/Paths/HealthSummary.d.ts +8 -0
  75. package/dist/admin/src/pages/Paths/IssueBadges.d.ts +4 -0
  76. package/dist/admin/src/pages/Paths/PageWrapper.d.ts +5 -0
  77. package/dist/admin/src/pages/Paths/PathActionsMenu.d.ts +7 -0
  78. package/dist/admin/src/pages/Paths/PathFilters.d.ts +14 -0
  79. package/dist/admin/src/pages/Paths/PathTable.d.ts +18 -0
  80. package/dist/admin/src/pages/Paths/SearchInput.d.ts +5 -0
  81. package/dist/admin/src/pages/Paths/TableHeader.d.ts +6 -0
  82. package/dist/admin/src/pages/Paths/TableRow.d.ts +9 -0
  83. package/dist/admin/src/pages/Paths/compareBy.d.ts +3 -0
  84. package/dist/admin/src/pages/Paths/hasPathDeviation.d.ts +2 -0
  85. package/dist/admin/src/pages/Paths/healthMessages.d.ts +11 -0
  86. package/dist/admin/src/pages/Paths/index.d.ts +2 -0
  87. package/dist/admin/src/pages/Settings/ContentBox.d.ts +4 -0
  88. package/dist/admin/src/pages/Settings/General/ContentTypeAccordion.d.ts +9 -0
  89. package/dist/admin/src/pages/Settings/General/index.d.ts +2 -0
  90. package/dist/admin/src/pages/Settings/Navigation/index.d.ts +2 -0
  91. package/dist/admin/src/pages/Settings/PageWrapper.d.ts +7 -0
  92. package/dist/admin/src/pages/Settings/SettingTitle.d.ts +3 -0
  93. package/dist/admin/src/pages/Settings/index.d.ts +4 -0
  94. package/dist/admin/src/permissions.d.ts +51 -0
  95. package/dist/admin/src/types/index.d.ts +4 -0
  96. package/dist/admin/src/types/modal.d.ts +60 -0
  97. package/dist/admin/src/types/navigation.d.ts +24 -0
  98. package/dist/admin/src/types/panel.d.ts +50 -0
  99. package/dist/admin/src/types/route.d.ts +3 -0
  100. package/dist/admin/src/utils/buildBreadcrumbString.d.ts +16 -0
  101. package/dist/admin/src/utils/createTempNavItemObject.d.ts +22 -0
  102. package/dist/admin/src/utils/debounce.d.ts +1 -0
  103. package/dist/admin/src/utils/dnd.d.ts +13 -0
  104. package/dist/admin/src/utils/duplicateCheck.d.ts +19 -0
  105. package/dist/admin/src/utils/findParentNavItem.d.ts +13 -0
  106. package/dist/admin/src/utils/getRouteSourceFields.d.ts +2 -0
  107. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  108. package/dist/admin/src/utils/index.d.ts +11 -0
  109. package/dist/admin/src/utils/isAbortError.d.ts +5 -0
  110. package/dist/admin/src/utils/navTree.d.ts +39 -0
  111. package/dist/admin/src/utils/syncNavItemPaths.d.ts +12 -0
  112. package/dist/admin/src/utils/typeChecks.d.ts +3 -0
  113. package/dist/server/index.js +270 -2
  114. package/dist/server/index.mjs +270 -2
  115. package/dist/server/src/bootstrap/documentMiddleware.d.ts +18 -0
  116. package/dist/server/src/bootstrap/index.d.ts +5 -0
  117. package/dist/server/src/bootstrap/permissions.d.ts +2 -0
  118. package/dist/server/src/bootstrap/syncConfig.d.ts +3 -0
  119. package/dist/server/src/bootstrap/webatlasMiddleware.d.ts +2 -0
  120. package/dist/server/src/bootstrap.d.ts +5 -0
  121. package/dist/server/src/config/index.d.ts +8 -0
  122. package/dist/server/src/content-types/index.d.ts +208 -0
  123. package/dist/server/src/content-types/navigation/index.d.ts +56 -0
  124. package/dist/server/src/content-types/navigation/schema.d.ts +54 -0
  125. package/dist/server/src/content-types/navitem/index.d.ts +51 -0
  126. package/dist/server/src/content-types/navitem/schema.d.ts +49 -0
  127. package/dist/server/src/content-types/route/index.d.ts +101 -0
  128. package/dist/server/src/content-types/route/schema.d.ts +99 -0
  129. package/dist/server/src/controllers/admin.d.ts +19 -0
  130. package/dist/server/src/controllers/client.d.ts +8 -0
  131. package/dist/server/src/controllers/index.d.ts +27 -0
  132. package/dist/server/src/destroy.d.ts +5 -0
  133. package/dist/server/src/index.d.ts +15 -5
  134. package/dist/server/src/middlewares/addWebatlasField.d.ts +10 -0
  135. package/dist/server/src/middlewares/enrichRoutePicker.d.ts +10 -0
  136. package/dist/server/src/middlewares/index.d.ts +9 -0
  137. package/dist/server/src/migrations/001-canonical-path.d.ts +7 -0
  138. package/dist/server/src/migrations/002-webatlas-json-field.d.ts +7 -0
  139. package/dist/server/src/migrations/003-route-source-field.d.ts +7 -0
  140. package/dist/server/src/migrations/004-navigation-max-depth.d.ts +7 -0
  141. package/dist/server/src/migrations/index.d.ts +3 -0
  142. package/dist/server/src/policies/has-permissions.d.ts +2 -0
  143. package/dist/server/src/policies/index.d.ts +4 -0
  144. package/dist/server/src/register.d.ts +5 -0
  145. package/dist/server/src/routes/admin.d.ts +17 -0
  146. package/dist/server/src/routes/client.d.ts +12 -0
  147. package/dist/server/src/routes/index.d.ts +30 -0
  148. package/dist/server/src/services/admin.d.ts +33 -0
  149. package/dist/server/src/services/client.d.ts +48 -0
  150. package/dist/server/src/services/health.d.ts +5 -0
  151. package/dist/server/src/services/index.d.ts +83 -0
  152. package/dist/server/src/utils/addWebatlasBreadcrumb.d.ts +14 -0
  153. package/dist/server/src/utils/assertDescendantPathsAllowed.d.ts +19 -0
  154. package/dist/server/src/utils/assertPathAllowed.d.ts +2 -0
  155. package/dist/server/src/utils/buildCanonicalPath.d.ts +1 -0
  156. package/dist/server/src/utils/buildNavigationPath.d.ts +5 -0
  157. package/dist/server/src/utils/buildStructuredNavigation.d.ts +12 -0
  158. package/dist/server/src/utils/cascadePathUpdates.d.ts +6 -0
  159. package/dist/server/src/utils/cleanRootKeys.d.ts +1 -0
  160. package/dist/server/src/utils/duplicateCheck.d.ts +1 -0
  161. package/dist/server/src/utils/enrichRoutePickerFields.d.ts +7 -0
  162. package/dist/server/src/utils/enrichWebatlasData.d.ts +6 -0
  163. package/dist/server/src/utils/extractRouteAndItems.d.ts +32 -0
  164. package/dist/server/src/utils/getDocumentStatuses.d.ts +12 -0
  165. package/dist/server/src/utils/getNonInternalRouteIds.d.ts +1 -0
  166. package/dist/server/src/utils/getPublishedDocumentIds.d.ts +11 -0
  167. package/dist/server/src/utils/getRouteAncestors.d.ts +1 -0
  168. package/dist/server/src/utils/getRouteDescendants.d.ts +1 -0
  169. package/dist/server/src/utils/health/checks.d.ts +48 -0
  170. package/dist/server/src/utils/index.d.ts +29 -0
  171. package/dist/server/src/utils/isBlacklistedPath.d.ts +1 -0
  172. package/dist/server/src/utils/navItemHandler.d.ts +5 -0
  173. package/dist/server/src/utils/navigationItemStructure.d.ts +27 -0
  174. package/dist/server/src/utils/normalizeRouteBlacklist.d.ts +5 -0
  175. package/dist/server/src/utils/pluginHelpers.d.ts +4 -0
  176. package/dist/server/src/utils/populateDeep.d.ts +4 -0
  177. package/dist/server/src/utils/reduceDepthOfOrphanedItems.d.ts +2 -0
  178. package/dist/server/src/utils/removeUnpublishedNavItems.d.ts +7 -0
  179. package/dist/server/src/utils/removeWaFields.d.ts +1 -0
  180. package/dist/server/src/utils/routeHandler.d.ts +5 -0
  181. package/dist/server/src/utils/validateRouteDependencies.d.ts +4 -0
  182. package/package.json +5 -5
  183. package/dist/admin/index-D2O7sLKs.mjs +0 -249
  184. package/dist/admin/index-jOCO4_-k.js +0 -249
@@ -0,0 +1,27 @@
1
+ import { NestedNavItem } from '../../../types';
2
+ export declare function handleItemDeletion(navigationItems: NestedNavItem[]): Promise<{
3
+ success: boolean;
4
+ items: NestedNavItem[];
5
+ errors: string[];
6
+ }>;
7
+ export declare function handleItemUpdate({ item, calculatedParent, calculatedOrder, navigationId, newNavItemsMap, }: {
8
+ item: NestedNavItem;
9
+ calculatedParent: string | null;
10
+ calculatedOrder: number;
11
+ navigationId: string;
12
+ newNavItemsMap: Map<string, NestedNavItem>;
13
+ }): Promise<{
14
+ success: boolean;
15
+ errors: string[];
16
+ }>;
17
+ export declare function calculateParentAndOrder({ navigationItems, item, index, parentIds, groupIndices, newNavItemsMap, }: {
18
+ navigationItems: NestedNavItem[];
19
+ item: NestedNavItem;
20
+ index: number;
21
+ parentIds: string[];
22
+ groupIndices: number[];
23
+ newNavItemsMap: Map<string, NestedNavItem>;
24
+ }): {
25
+ calculatedParent: string;
26
+ calculatedOrder: number;
27
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Brings blacklist entries into the same shape as stored route paths (lowercase, no surrounding
3
+ * slashes), so that entries like "/Admin/" still match the path "admin".
4
+ */
5
+ export default function normalizeRouteBlacklist(entries: unknown): string[];
@@ -0,0 +1,4 @@
1
+ import { Core } from '@strapi/strapi';
2
+ export declare function getAdminService(): Core.Service;
3
+ export declare function getClientService(): Core.Service;
4
+ export declare function getHealthService(): Core.Service;
@@ -0,0 +1,4 @@
1
+ import { UID } from '@strapi/strapi';
2
+ export default function getFullPopulateObject(modelUid: UID.Schema, maxDepth?: number, ignore?: string[]): boolean | {
3
+ populate: Record<string, boolean | Record<string, any>>;
4
+ };
@@ -0,0 +1,2 @@
1
+ import { NestedNavItem } from '../../../types';
2
+ export default function reduceDepthOfOrphanedItems(navigationItems: NestedNavItem[], itemId: string): NestedNavItem[] | undefined;
@@ -0,0 +1,7 @@
1
+ import { NestedNavItem } from '../../../types';
2
+ /**
3
+ * Removes navigation items whose route points to an entry without a published version, so titles and
4
+ * paths of unpublished pages are not exposed. External and wrapper routes are not linked to an entry
5
+ * and are kept. Descendants of removed items are removed as well, since they would be orphaned.
6
+ */
7
+ export default function removeUnpublishedNavItems(items: NestedNavItem[]): Promise<NestedNavItem[]>;
@@ -0,0 +1 @@
1
+ export default function removeWaFields(obj: any): any;
@@ -0,0 +1,5 @@
1
+ import { Route, RouteSettings } from '../../../types';
2
+ declare function createExternalRoute(data: RouteSettings): Promise<import('@strapi/types/dist/modules/documents').AnyDocument>;
3
+ declare function updateRoute(documentId: string, data: RouteSettings): Promise<Route>;
4
+ declare function deleteRoute(documentId: string): Promise<boolean>;
5
+ export { createExternalRoute, updateRoute, deleteRoute };
@@ -0,0 +1,4 @@
1
+ export default function validateRouteDependencies({ routeId, newParentId, }: {
2
+ routeId?: string | null;
3
+ newParentId: string;
4
+ }): Promise<boolean>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@mattisvensson/strapi-plugin-webatlas",
3
3
  "description": "A strapi plugin to manage URL routes and navigations.",
4
4
  "license": "MIT",
5
- "version": "0.13.0",
5
+ "version": "0.14.0",
6
6
  "keywords": [
7
7
  "strapi",
8
8
  "plugin",
@@ -56,13 +56,13 @@
56
56
  "@strapi/design-system": "^2.0.0",
57
57
  "@strapi/icons": "^2.0.0",
58
58
  "@strapi/pack-up": "^5.0.0",
59
- "@strapi/sdk-plugin": "^6.0.0",
59
+ "@strapi/sdk-plugin": "^6.1.1",
60
60
  "@strapi/strapi": "^5.42.1",
61
- "@strapi/typescript-utils": "^5.0.0",
61
+ "@strapi/typescript-utils": "^5.44.0",
62
62
  "@strapi/utils": "^5.42.1",
63
63
  "@types/lodash": "^4",
64
- "@types/react": "^19.0.0",
65
- "@types/react-dom": "^19.0.0",
64
+ "@types/react": "^18.0.0",
65
+ "@types/react-dom": "^18.0.0",
66
66
  "cypress": "^13.9.0",
67
67
  "cypress-terminal-report": "^6.0.2",
68
68
  "eslint": "^8.57.1",
@@ -1,249 +0,0 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { useState, useEffect, useMemo } from "react";
3
- import { g as getTranslation, u as useApi, d as debounce, p as pluginPermissions, i as isAbortError } from "./index-BKhrfzjO.mjs";
4
- import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
5
- import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
6
- import { Grid, Box, Field, Thead, Tr, Th, Typography, VisuallyHidden, Td, Flex, LinkButton, Table, Tbody, EmptyStateLayout } from "@strapi/design-system";
7
- import "@strapi/icons/symbols";
8
- import { Cross, ChevronDown, Pencil } from "@strapi/icons";
9
- import { useIntl } from "react-intl";
10
- import { useSearchParams } from "react-router-dom";
11
- function PageWrapper({ children }) {
12
- const { formatMessage } = useIntl();
13
- return /* @__PURE__ */ jsxs(Page.Main, { children: [
14
- /* @__PURE__ */ jsx(
15
- Layouts.Header,
16
- {
17
- title: formatMessage({
18
- id: getTranslation("paths.page.title"),
19
- defaultMessage: "Paths"
20
- }),
21
- subtitle: formatMessage({
22
- id: getTranslation("paths.page.subtitle"),
23
- defaultMessage: "Overview of all existing paths"
24
- })
25
- }
26
- ),
27
- /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(Fragment, { children }) })
28
- ] });
29
- }
30
- function compareBy(field, direction) {
31
- if (!field) {
32
- return () => 0;
33
- }
34
- if (field === "type") {
35
- return (a, b) => {
36
- return direction === "asc" ? a.type.localeCompare(b.type) : b.type.localeCompare(a.type);
37
- };
38
- }
39
- return (a, b) => {
40
- const aValue = a[field];
41
- const bValue = b[field];
42
- if (aValue == null && bValue == null) {
43
- return 0;
44
- }
45
- if (aValue == null) {
46
- return direction === "asc" ? 1 : -1;
47
- }
48
- if (bValue == null) {
49
- return direction === "asc" ? -1 : 1;
50
- }
51
- if (typeof aValue === "string" && typeof bValue === "string") {
52
- return direction === "asc" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
53
- }
54
- return 0;
55
- };
56
- }
57
- function SearchInput({
58
- searchQuery,
59
- handleSearchChange
60
- }) {
61
- const { formatMessage } = useIntl();
62
- return /* @__PURE__ */ jsx(Grid.Root, { style: { marginBottom: "16px" }, children: /* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsx(
63
- Field.Input,
64
- {
65
- name: "search",
66
- placeholder: formatMessage({
67
- id: getTranslation("paths.page.searchPlaceholder"),
68
- defaultMessage: "Search paths"
69
- }),
70
- value: searchQuery,
71
- onChange: handleSearchChange,
72
- endAction: searchQuery ? /* @__PURE__ */ jsx(
73
- "button",
74
- {
75
- type: "button",
76
- onClick: () => handleSearchChange({
77
- target: { value: "" }
78
- }),
79
- style: {
80
- color: "inherit",
81
- background: "none",
82
- border: "none",
83
- cursor: "pointer"
84
- },
85
- "aria-label": "Clear search",
86
- children: /* @__PURE__ */ jsx(Cross, {})
87
- }
88
- ) : null
89
- }
90
- ) }) }) }) });
91
- }
92
- function TableHeader({
93
- sortKey,
94
- handleSort
95
- }) {
96
- const { formatMessage } = useIntl();
97
- return /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
98
- /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("title"), cursor: "pointer", children: [
99
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
100
- id: getTranslation("title"),
101
- defaultMessage: "Title"
102
- }) }),
103
- sortKey === "title" && /* @__PURE__ */ jsx(ChevronDown, {})
104
- ] }),
105
- /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("canonicalPath"), cursor: "pointer", children: [
106
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
107
- id: getTranslation("canonicalPath"),
108
- defaultMessage: "Canonical Path"
109
- }) }),
110
- sortKey === "canonicalPath" && /* @__PURE__ */ jsx(ChevronDown, {})
111
- ] }),
112
- /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("path"), cursor: "pointer", children: [
113
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
114
- id: getTranslation("path"),
115
- defaultMessage: "Path"
116
- }) }),
117
- sortKey === "path" && /* @__PURE__ */ jsx(ChevronDown, {})
118
- ] }),
119
- /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("type"), cursor: "pointer", children: [
120
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
121
- id: getTranslation("paths.page.column.type"),
122
- defaultMessage: "Type"
123
- }) }),
124
- sortKey === "type" && /* @__PURE__ */ jsx(ChevronDown, {})
125
- ] }),
126
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: formatMessage({
127
- id: getTranslation("actions"),
128
- defaultMessage: "Actions"
129
- }) }) })
130
- ] }) });
131
- }
132
- function TableRow({ route }) {
133
- const { formatMessage } = useIntl();
134
- return /* @__PURE__ */ jsxs(Tr, { children: [
135
- [route.title, route.canonicalPath, route.path].map((field, index) => /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { title: field, textColor: "neutral800", children: field || "-" }) }, index)),
136
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { title: route.type, textColor: "neutral800", children: formatMessage({
137
- id: getTranslation(`path.type.${route.type}`),
138
- defaultMessage: "-"
139
- }) }) }),
140
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Flex, { gap: 2, justifyContent: "end", children: route.type === "internal" && /* @__PURE__ */ jsx(
141
- LinkButton,
142
- {
143
- variant: "secondary",
144
- startIcon: /* @__PURE__ */ jsx(Pencil, {}),
145
- href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`,
146
- children: formatMessage({
147
- id: getTranslation("edit"),
148
- defaultMessage: "Edit"
149
- })
150
- }
151
- ) }) })
152
- ] });
153
- }
154
- function PathTable({
155
- routes,
156
- sortKey,
157
- handleSort
158
- }) {
159
- const { formatMessage } = useIntl();
160
- const TABLE_COL_COUNT = 5;
161
- return /* @__PURE__ */ jsxs(Table, { colCount: TABLE_COL_COUNT, rowCount: routes.length, children: [
162
- /* @__PURE__ */ jsx(TableHeader, { sortKey, handleSort }),
163
- /* @__PURE__ */ jsx(Tbody, { children: routes.length > 0 ? routes.map((route) => /* @__PURE__ */ jsx(TableRow, { route }, route.id)) : /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan: TABLE_COL_COUNT, children: /* @__PURE__ */ jsx(
164
- EmptyStateLayout,
165
- {
166
- shadow: "none",
167
- content: formatMessage({
168
- id: getTranslation("paths.page.emptyPaths"),
169
- defaultMessage: "No paths found"
170
- })
171
- }
172
- ) }) }) })
173
- ] });
174
- }
175
- const Paths = () => {
176
- const { getAllRoutes } = useApi();
177
- const { formatMessage } = useIntl();
178
- const { toggleNotification } = useNotification();
179
- const getErrorMessage = useErrorMessage();
180
- const [allRoutes, setAllRoutes] = useState([]);
181
- const [routes, setRoutes] = useState([]);
182
- const [loading, setLoading] = useState(true);
183
- const [searchParams, setSearchParams] = useSearchParams();
184
- const initialQuery = searchParams.get("search") || "";
185
- const [searchQuery, setSearchQuery] = useState(initialQuery);
186
- const [sortKey, setSortKey] = useState("canonicalPath");
187
- const [sortDirection, setSortDirection] = useState("asc");
188
- useEffect(() => {
189
- const query = searchQuery.toLowerCase();
190
- setRoutes(
191
- allRoutes.filter(
192
- (route) => JSON.stringify(route.id).toLowerCase().includes(query) || route.title.toLowerCase().includes(query) || route.path.toLowerCase().includes(query) || route.relatedDocumentId.toLowerCase().includes(query) || route.relatedContentType.toLowerCase().includes(query)
193
- )
194
- );
195
- }, [searchQuery, allRoutes]);
196
- const debouncedSetSearchParams = useMemo(
197
- () => debounce((value) => {
198
- value ? setSearchParams({ search: value }) : setSearchParams({});
199
- }, 300),
200
- [setSearchParams]
201
- );
202
- const handleSearchChange = (e) => {
203
- const value = e.target.value;
204
- setSearchQuery(value);
205
- debouncedSetSearchParams(value);
206
- };
207
- useEffect(() => {
208
- async function fetchRoutes() {
209
- try {
210
- const data = await getAllRoutes();
211
- setAllRoutes(data);
212
- setRoutes(data);
213
- } catch (err) {
214
- if (isAbortError(err)) return;
215
- console.error("Failed to fetch paths:", err);
216
- toggleNotification({
217
- type: "danger",
218
- message: getErrorMessage(
219
- err,
220
- formatMessage({
221
- id: getTranslation("notification.paths.fetchFailed"),
222
- defaultMessage: "Failed to fetch paths"
223
- })
224
- )
225
- });
226
- } finally {
227
- setLoading(false);
228
- }
229
- }
230
- fetchRoutes();
231
- }, []);
232
- const handleSort = (key) => {
233
- setSortDirection((prev) => prev === "asc" ? "desc" : "asc");
234
- setSortKey(key);
235
- };
236
- const sortedRoutes = useMemo(() => {
237
- return sortKey ? [...routes].sort(compareBy(sortKey, sortDirection)) : routes;
238
- }, [routes, sortKey, sortDirection]);
239
- if (loading) {
240
- return /* @__PURE__ */ jsx(PageWrapper, { children: /* @__PURE__ */ jsx(FullLoader, {}) });
241
- }
242
- return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions["page.routes"], children: /* @__PURE__ */ jsxs(PageWrapper, { children: [
243
- /* @__PURE__ */ jsx(SearchInput, { handleSearchChange, searchQuery }),
244
- /* @__PURE__ */ jsx(PathTable, { routes: sortedRoutes, sortKey, handleSort })
245
- ] }) });
246
- };
247
- export {
248
- Paths as default
249
- };
@@ -1,249 +0,0 @@
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-DTrsl_uN.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({ children }) {
14
- const { formatMessage } = reactIntl.useIntl();
15
- return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
16
- /* @__PURE__ */ jsxRuntime.jsx(
17
- admin.Layouts.Header,
18
- {
19
- title: formatMessage({
20
- id: index.getTranslation("paths.page.title"),
21
- defaultMessage: "Paths"
22
- }),
23
- subtitle: formatMessage({
24
- id: index.getTranslation("paths.page.subtitle"),
25
- defaultMessage: "Overview of all existing paths"
26
- })
27
- }
28
- ),
29
- /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) })
30
- ] });
31
- }
32
- function compareBy(field, direction) {
33
- if (!field) {
34
- return () => 0;
35
- }
36
- if (field === "type") {
37
- return (a, b) => {
38
- return direction === "asc" ? a.type.localeCompare(b.type) : b.type.localeCompare(a.type);
39
- };
40
- }
41
- return (a, b) => {
42
- const aValue = a[field];
43
- const bValue = b[field];
44
- if (aValue == null && bValue == null) {
45
- return 0;
46
- }
47
- if (aValue == null) {
48
- return direction === "asc" ? 1 : -1;
49
- }
50
- if (bValue == null) {
51
- return direction === "asc" ? -1 : 1;
52
- }
53
- if (typeof aValue === "string" && typeof bValue === "string") {
54
- return direction === "asc" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
55
- }
56
- return 0;
57
- };
58
- }
59
- function SearchInput({
60
- searchQuery,
61
- handleSearchChange
62
- }) {
63
- const { formatMessage } = reactIntl.useIntl();
64
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { style: { marginBottom: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(
65
- designSystem.Field.Input,
66
- {
67
- name: "search",
68
- placeholder: formatMessage({
69
- id: index.getTranslation("paths.page.searchPlaceholder"),
70
- defaultMessage: "Search paths"
71
- }),
72
- value: searchQuery,
73
- onChange: handleSearchChange,
74
- endAction: searchQuery ? /* @__PURE__ */ jsxRuntime.jsx(
75
- "button",
76
- {
77
- type: "button",
78
- onClick: () => handleSearchChange({
79
- target: { value: "" }
80
- }),
81
- style: {
82
- color: "inherit",
83
- background: "none",
84
- border: "none",
85
- cursor: "pointer"
86
- },
87
- "aria-label": "Clear search",
88
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {})
89
- }
90
- ) : null
91
- }
92
- ) }) }) }) });
93
- }
94
- function TableHeader({
95
- sortKey,
96
- handleSort
97
- }) {
98
- const { formatMessage } = reactIntl.useIntl();
99
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
100
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("title"), cursor: "pointer", children: [
101
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
102
- id: index.getTranslation("title"),
103
- defaultMessage: "Title"
104
- }) }),
105
- sortKey === "title" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
106
- ] }),
107
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("canonicalPath"), cursor: "pointer", children: [
108
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
109
- id: index.getTranslation("canonicalPath"),
110
- defaultMessage: "Canonical Path"
111
- }) }),
112
- sortKey === "canonicalPath" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
113
- ] }),
114
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("path"), cursor: "pointer", children: [
115
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
116
- id: index.getTranslation("path"),
117
- defaultMessage: "Path"
118
- }) }),
119
- sortKey === "path" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
120
- ] }),
121
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("type"), cursor: "pointer", children: [
122
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
123
- id: index.getTranslation("paths.page.column.type"),
124
- defaultMessage: "Type"
125
- }) }),
126
- sortKey === "type" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
127
- ] }),
128
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage({
129
- id: index.getTranslation("actions"),
130
- defaultMessage: "Actions"
131
- }) }) })
132
- ] }) });
133
- }
134
- function TableRow({ route }) {
135
- const { formatMessage } = reactIntl.useIntl();
136
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
137
- [route.title, route.canonicalPath, route.path].map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { title: field, textColor: "neutral800", children: field || "-" }) }, index2)),
138
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { title: route.type, textColor: "neutral800", children: formatMessage({
139
- id: index.getTranslation(`path.type.${route.type}`),
140
- defaultMessage: "-"
141
- }) }) }),
142
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, justifyContent: "end", children: route.type === "internal" && /* @__PURE__ */ jsxRuntime.jsx(
143
- designSystem.LinkButton,
144
- {
145
- variant: "secondary",
146
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}),
147
- href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`,
148
- children: formatMessage({
149
- id: index.getTranslation("edit"),
150
- defaultMessage: "Edit"
151
- })
152
- }
153
- ) }) })
154
- ] });
155
- }
156
- function PathTable({
157
- routes,
158
- sortKey,
159
- handleSort
160
- }) {
161
- const { formatMessage } = reactIntl.useIntl();
162
- const TABLE_COL_COUNT = 5;
163
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: TABLE_COL_COUNT, rowCount: routes.length, children: [
164
- /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { sortKey, handleSort }),
165
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: routes.length > 0 ? routes.map((route) => /* @__PURE__ */ jsxRuntime.jsx(TableRow, { route }, route.id)) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: TABLE_COL_COUNT, children: /* @__PURE__ */ jsxRuntime.jsx(
166
- designSystem.EmptyStateLayout,
167
- {
168
- shadow: "none",
169
- content: formatMessage({
170
- id: index.getTranslation("paths.page.emptyPaths"),
171
- defaultMessage: "No paths found"
172
- })
173
- }
174
- ) }) }) })
175
- ] });
176
- }
177
- const Paths = () => {
178
- const { getAllRoutes } = index.useApi();
179
- const { formatMessage } = reactIntl.useIntl();
180
- const { toggleNotification } = admin.useNotification();
181
- const getErrorMessage = FullLoader.useErrorMessage();
182
- const [allRoutes, setAllRoutes] = React.useState([]);
183
- const [routes, setRoutes] = React.useState([]);
184
- const [loading, setLoading] = React.useState(true);
185
- const [searchParams, setSearchParams] = reactRouterDom.useSearchParams();
186
- const initialQuery = searchParams.get("search") || "";
187
- const [searchQuery, setSearchQuery] = React.useState(initialQuery);
188
- const [sortKey, setSortKey] = React.useState("canonicalPath");
189
- const [sortDirection, setSortDirection] = React.useState("asc");
190
- React.useEffect(() => {
191
- const query = searchQuery.toLowerCase();
192
- setRoutes(
193
- allRoutes.filter(
194
- (route) => JSON.stringify(route.id).toLowerCase().includes(query) || route.title.toLowerCase().includes(query) || route.path.toLowerCase().includes(query) || route.relatedDocumentId.toLowerCase().includes(query) || route.relatedContentType.toLowerCase().includes(query)
195
- )
196
- );
197
- }, [searchQuery, allRoutes]);
198
- const debouncedSetSearchParams = React.useMemo(
199
- () => index.debounce((value) => {
200
- value ? setSearchParams({ search: value }) : setSearchParams({});
201
- }, 300),
202
- [setSearchParams]
203
- );
204
- const handleSearchChange = (e) => {
205
- const value = e.target.value;
206
- setSearchQuery(value);
207
- debouncedSetSearchParams(value);
208
- };
209
- React.useEffect(() => {
210
- async function fetchRoutes() {
211
- try {
212
- const data = await getAllRoutes();
213
- setAllRoutes(data);
214
- setRoutes(data);
215
- } catch (err) {
216
- if (index.isAbortError(err)) return;
217
- console.error("Failed to fetch paths:", err);
218
- toggleNotification({
219
- type: "danger",
220
- message: getErrorMessage(
221
- err,
222
- formatMessage({
223
- id: index.getTranslation("notification.paths.fetchFailed"),
224
- defaultMessage: "Failed to fetch paths"
225
- })
226
- )
227
- });
228
- } finally {
229
- setLoading(false);
230
- }
231
- }
232
- fetchRoutes();
233
- }, []);
234
- const handleSort = (key) => {
235
- setSortDirection((prev) => prev === "asc" ? "desc" : "asc");
236
- setSortKey(key);
237
- };
238
- const sortedRoutes = React.useMemo(() => {
239
- return sortKey ? [...routes].sort(compareBy(sortKey, sortDirection)) : routes;
240
- }, [routes, sortKey, sortDirection]);
241
- if (loading) {
242
- return /* @__PURE__ */ jsxRuntime.jsx(PageWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, {}) });
243
- }
244
- return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.pluginPermissions["page.routes"], children: /* @__PURE__ */ jsxRuntime.jsxs(PageWrapper, { children: [
245
- /* @__PURE__ */ jsxRuntime.jsx(SearchInput, { handleSearchChange, searchQuery }),
246
- /* @__PURE__ */ jsxRuntime.jsx(PathTable, { routes: sortedRoutes, sortKey, handleSort })
247
- ] }) });
248
- };
249
- exports.default = Paths;