@mattisvensson/strapi-plugin-webatlas 0.7.1 → 0.8.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 (80) hide show
  1. package/dist/_chunks/FullLoader-Cmsf8xS6.js +0 -12
  2. package/dist/_chunks/FullLoader-Cmsf8xS6.js.map +0 -1
  3. package/dist/_chunks/FullLoader-CrPED_dY.mjs +0 -1
  4. package/dist/_chunks/PageWrapper-B6nLPFak.mjs +55 -0
  5. package/dist/_chunks/PageWrapper-BMzPDWn4.js +0 -0
  6. package/dist/_chunks/PageWrapper-BMzPDWn4.js.map +0 -0
  7. package/dist/_chunks/{de-oxxH8hft.mjs → de-C1QgkRoj.mjs} +3 -2
  8. package/dist/_chunks/de-DYxCPOdb.js +0 -0
  9. package/dist/_chunks/de-DYxCPOdb.js.map +0 -0
  10. package/dist/_chunks/{en-DqC5aDzA.mjs → en--8p5hbLP.mjs} +3 -2
  11. package/dist/_chunks/en-Be-athEA.js +0 -0
  12. package/dist/_chunks/en-Be-athEA.js.map +0 -0
  13. package/dist/_chunks/{index-DcFYhqke.mjs → index-7rox7tGX.mjs} +94 -123
  14. package/dist/_chunks/index-Bu-uQ9jA.js +0 -0
  15. package/dist/_chunks/index-Bu-uQ9jA.js.map +0 -0
  16. package/dist/_chunks/index-C53yDU_z.js +0 -0
  17. package/dist/_chunks/index-C53yDU_z.js.map +0 -0
  18. package/dist/_chunks/index-CAz59RSr.js +0 -0
  19. package/dist/_chunks/index-CAz59RSr.js.map +0 -0
  20. package/dist/_chunks/{index-KC82xDAD.mjs → index-DGSjLYNl.mjs} +1 -1
  21. package/dist/_chunks/index-DKfUSLPc.js +0 -0
  22. package/dist/_chunks/index-DKfUSLPc.js.map +0 -0
  23. package/dist/_chunks/index-DPMhcaxW.js +0 -0
  24. package/dist/_chunks/index-DPMhcaxW.js.map +0 -0
  25. package/dist/_chunks/{index-C6Dorrjz.mjs → index-DSPh-fHL.mjs} +38 -11
  26. package/dist/_chunks/index-VcxUbdMO.mjs +123 -0
  27. package/dist/_chunks/{index-BFMLU2kR.mjs → index-Z3qq1ab8.mjs} +32 -32
  28. package/dist/admin/index.js +0 -5
  29. package/dist/admin/index.js.map +0 -1
  30. package/dist/admin/index.mjs +1 -2
  31. package/dist/admin/src/hooks/usePluginConfig.d.ts +1 -1
  32. package/dist/admin/src/pages/Settings/{ContentTypeAccordion.d.ts → General/ContentTypeAccordion.d.ts} +1 -1
  33. package/dist/admin/src/pages/Settings/Navigation/index.d.ts +2 -0
  34. package/dist/admin/src/pages/Settings/PageWrapper.d.ts +3 -4
  35. package/dist/admin/src/utils/dnd.d.ts +1 -1
  36. package/dist/server/index.js +21 -12
  37. package/dist/server/index.mjs +21 -12
  38. package/dist/server/src/index.d.ts +1 -1
  39. package/dist/server/src/services/admin.d.ts +2 -2
  40. package/dist/server/src/services/index.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/dist/_chunks/FullLoader-CrPED_dY.mjs.map +0 -1
  43. package/dist/_chunks/de-BZc1BkzH.js +0 -121
  44. package/dist/_chunks/de-BZc1BkzH.js.map +0 -1
  45. package/dist/_chunks/de-oxxH8hft.mjs.map +0 -1
  46. package/dist/_chunks/en-Deg4n_IM.js +0 -121
  47. package/dist/_chunks/en-Deg4n_IM.js.map +0 -1
  48. package/dist/_chunks/en-DqC5aDzA.mjs.map +0 -1
  49. package/dist/_chunks/index-2J9mPFyV.js +0 -4177
  50. package/dist/_chunks/index-2J9mPFyV.js.map +0 -1
  51. package/dist/_chunks/index-B79--vLg.js +0 -281
  52. package/dist/_chunks/index-B79--vLg.js.map +0 -1
  53. package/dist/_chunks/index-BFMLU2kR.mjs.map +0 -1
  54. package/dist/_chunks/index-C6Dorrjz.mjs.map +0 -1
  55. package/dist/_chunks/index-C6e9wLau.js +0 -4176
  56. package/dist/_chunks/index-C6e9wLau.js.map +0 -1
  57. package/dist/_chunks/index-CHB_8c7e.js +0 -246
  58. package/dist/_chunks/index-CHB_8c7e.js.map +0 -1
  59. package/dist/_chunks/index-D5Uc0GLu.mjs +0 -12229
  60. package/dist/_chunks/index-D5Uc0GLu.mjs.map +0 -1
  61. package/dist/_chunks/index-DCejsR9X.js +0 -12230
  62. package/dist/_chunks/index-DCejsR9X.js.map +0 -1
  63. package/dist/_chunks/index-DLZJ_sUK.mjs +0 -282
  64. package/dist/_chunks/index-DLZJ_sUK.mjs.map +0 -1
  65. package/dist/_chunks/index-DY1ICa5c.mjs +0 -4160
  66. package/dist/_chunks/index-DY1ICa5c.mjs.map +0 -1
  67. package/dist/_chunks/index-DcFYhqke.mjs.map +0 -1
  68. package/dist/_chunks/index-DeCgextE.js +0 -12229
  69. package/dist/_chunks/index-DeCgextE.js.map +0 -1
  70. package/dist/_chunks/index-DzqTj_0f.mjs +0 -247
  71. package/dist/_chunks/index-DzqTj_0f.mjs.map +0 -1
  72. package/dist/_chunks/index-KC82xDAD.mjs.map +0 -1
  73. package/dist/_chunks/index-NZpDoHIv.js +0 -282
  74. package/dist/_chunks/index-NZpDoHIv.js.map +0 -1
  75. package/dist/_chunks/index-dzRHjemo.js +0 -247
  76. package/dist/_chunks/index-dzRHjemo.js.map +0 -1
  77. package/dist/admin/index.mjs.map +0 -1
  78. package/dist/server/index.js.map +0 -1
  79. package/dist/server/index.mjs.map +0 -1
  80. /package/dist/admin/src/pages/Settings/{index.d.ts → General/index.d.ts} +0 -0
@@ -1,247 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useState, useEffect, useMemo } from "react";
3
- import { Thead, Tr, Th, Typography, VisuallyHidden, Td, Flex, LinkButton, Grid, Box, Field, Table, Tbody, EmptyStateLayout } from "@strapi/design-system";
4
- import { ChevronDown, Pencil, Cross } from "@strapi/icons";
5
- import { g as getTranslation, u as useApi, d as debounce } from "./index-C6Dorrjz.mjs";
6
- import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
7
- import "@strapi/icons/symbols";
8
- import { F as FullLoader } from "./FullLoader-CrPED_dY.mjs";
9
- import { useIntl } from "react-intl";
10
- import { useSearchParams } from "react-router-dom";
11
- function getRouteType(route) {
12
- if (route.wrapper) {
13
- return "wrapper";
14
- } else if (!route.internal) {
15
- return "external";
16
- } else {
17
- return "internal";
18
- }
19
- }
20
- function TableHeader({
21
- sortKey,
22
- handleSort
23
- }) {
24
- const { formatMessage } = useIntl();
25
- return /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
26
- /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("title"), cursor: "pointer", children: [
27
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
28
- id: getTranslation("title"),
29
- defaultMessage: "Title"
30
- }) }),
31
- sortKey === "title" && /* @__PURE__ */ jsx(ChevronDown, {})
32
- ] }),
33
- /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("fullPath"), cursor: "pointer", children: [
34
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
35
- id: getTranslation("route"),
36
- defaultMessage: "Route"
37
- }) }),
38
- sortKey === "fullPath" && /* @__PURE__ */ jsx(ChevronDown, {})
39
- ] }),
40
- /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("type"), cursor: "pointer", children: [
41
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
42
- id: getTranslation("routes.page.column.type"),
43
- defaultMessage: "Type"
44
- }) }),
45
- sortKey === "type" && /* @__PURE__ */ jsx(ChevronDown, {})
46
- ] }),
47
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: formatMessage({
48
- id: getTranslation("actions"),
49
- defaultMessage: "Actions"
50
- }) }) })
51
- ] }) });
52
- }
53
- function TableRow({ route }) {
54
- const { formatMessage } = useIntl();
55
- return /* @__PURE__ */ jsxs(Tr, { children: [
56
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.title }) }),
57
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.fullPath }) }),
58
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatMessage({
59
- id: getTranslation(`route.type.${getRouteType(route)}`),
60
- defaultMessage: "-"
61
- }) }) }),
62
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Flex, { gap: 2, justifyContent: "end", children: route.internal && /* @__PURE__ */ jsx(
63
- LinkButton,
64
- {
65
- variant: "secondary",
66
- startIcon: /* @__PURE__ */ jsx(Pencil, {}),
67
- href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`,
68
- children: formatMessage({
69
- id: getTranslation("edit"),
70
- defaultMessage: "Edit"
71
- })
72
- }
73
- ) }) })
74
- ] });
75
- }
76
- function PageWrapper({ children }) {
77
- const { formatMessage } = useIntl();
78
- return /* @__PURE__ */ jsxs(Page.Main, { children: [
79
- /* @__PURE__ */ jsx(
80
- Layouts.Header,
81
- {
82
- title: formatMessage({
83
- id: getTranslation("routes.page.title"),
84
- defaultMessage: "Routes"
85
- }),
86
- subtitle: formatMessage({
87
- id: getTranslation("routes.page.subtitle"),
88
- defaultMessage: "Overview of all existing routes"
89
- })
90
- }
91
- ),
92
- /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(Fragment, { children }) })
93
- ] });
94
- }
95
- function compareBy(field, direction) {
96
- if (!field) {
97
- return () => 0;
98
- }
99
- if (field === "type") {
100
- return (a, b) => {
101
- const typeA = a.internal ? "internal" : "external";
102
- const typeB = b.internal ? "internal" : "external";
103
- return direction === "asc" ? typeA.localeCompare(typeB) : typeB.localeCompare(typeA);
104
- };
105
- }
106
- return (a, b) => {
107
- const aValue = a[field];
108
- const bValue = b[field];
109
- if (typeof aValue === "string" && typeof bValue === "string") {
110
- return direction === "asc" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
111
- }
112
- return 0;
113
- };
114
- }
115
- function SearchInput({
116
- searchQuery,
117
- handleSearchChange
118
- }) {
119
- const { formatMessage } = useIntl();
120
- 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(
121
- Field.Input,
122
- {
123
- name: "search",
124
- placeholder: formatMessage({
125
- id: getTranslation("routes.page.searchPlaceholder"),
126
- defaultMessage: "Search routes"
127
- }),
128
- value: searchQuery,
129
- onChange: handleSearchChange,
130
- endAction: searchQuery ? /* @__PURE__ */ jsx(
131
- "button",
132
- {
133
- type: "button",
134
- onClick: () => handleSearchChange({ target: { value: "" } }),
135
- style: { color: "inherit", background: "none", border: "none", cursor: "pointer" },
136
- "aria-label": "Clear search",
137
- children: /* @__PURE__ */ jsx(Cross, {})
138
- }
139
- ) : null
140
- }
141
- ) }) }) }) });
142
- }
143
- function RouteTable({
144
- routes,
145
- sortKey,
146
- handleSort
147
- }) {
148
- const { formatMessage } = useIntl();
149
- return /* @__PURE__ */ jsxs(Table, { colCount: 4, rowCount: routes.length, children: [
150
- /* @__PURE__ */ jsx(TableHeader, { sortKey, handleSort }),
151
- /* @__PURE__ */ jsx(Tbody, { children: routes.length > 0 ? routes.map((route) => /* @__PURE__ */ jsx(TableRow, { route }, route.id)) : /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan: 4, children: /* @__PURE__ */ jsx(
152
- EmptyStateLayout,
153
- {
154
- content: formatMessage({
155
- id: getTranslation("routes.page.emptyRoutes"),
156
- defaultMessage: "No routes found"
157
- }),
158
- shadow: false
159
- }
160
- ) }) }) })
161
- ] });
162
- }
163
- const Routes = () => {
164
- const { getRoutes } = useApi();
165
- const { formatMessage } = useIntl();
166
- const { toggleNotification } = useNotification();
167
- const [allRoutes, setAllRoutes] = useState([]);
168
- const [routes, setRoutes] = useState([]);
169
- const [loading, setLoading] = useState(true);
170
- const [searchParams, setSearchParams] = useSearchParams();
171
- const initialQuery = searchParams.get("search") || "";
172
- const [searchQuery, setSearchQuery] = useState(initialQuery);
173
- const [sortKey, setSortKey] = useState(void 0);
174
- const [sortDirection, setSortDirection] = useState("asc");
175
- useEffect(() => {
176
- const query = searchQuery.toLowerCase();
177
- setRoutes(
178
- allRoutes.filter(
179
- (route) => JSON.stringify(route.id).toLowerCase().includes(query) || route.title.toLowerCase().includes(query) || route.fullPath.toLowerCase().includes(query) || route.relatedDocumentId.toLowerCase().includes(query) || route.relatedContentType.toLowerCase().includes(query)
180
- )
181
- );
182
- }, [searchQuery, allRoutes]);
183
- const debouncedSetSearchParams = useMemo(
184
- () => debounce((value) => {
185
- value ? setSearchParams({ search: value }) : setSearchParams({});
186
- }, 300),
187
- [setSearchParams]
188
- );
189
- const handleSearchChange = (e) => {
190
- const value = e.target.value;
191
- setSearchQuery(value);
192
- debouncedSetSearchParams(value);
193
- };
194
- useEffect(() => {
195
- async function fetchRoutes() {
196
- try {
197
- const data = await getRoutes();
198
- setAllRoutes(data);
199
- setRoutes(data);
200
- } catch (err) {
201
- console.error("Failed to fetch routes:", err);
202
- toggleNotification({
203
- type: "danger",
204
- message: formatMessage({
205
- id: getTranslation("notification.routes.fetchFailed"),
206
- defaultMessage: "Failed to fetch routes"
207
- })
208
- });
209
- } finally {
210
- setLoading(false);
211
- }
212
- }
213
- fetchRoutes();
214
- }, []);
215
- const handleSort = (key) => {
216
- setSortDirection((prev) => prev === "asc" ? "desc" : "asc");
217
- setSortKey(key);
218
- };
219
- useEffect(() => {
220
- const sortedRoutes = sortKey ? [...routes].sort(compareBy(sortKey, sortDirection)) : routes;
221
- setRoutes(sortedRoutes);
222
- }, [sortKey, sortDirection]);
223
- if (loading) {
224
- return /* @__PURE__ */ jsx(PageWrapper, { children: /* @__PURE__ */ jsx(FullLoader, {}) });
225
- }
226
- return /* @__PURE__ */ jsxs(PageWrapper, { children: [
227
- /* @__PURE__ */ jsx(
228
- SearchInput,
229
- {
230
- handleSearchChange,
231
- searchQuery
232
- }
233
- ),
234
- /* @__PURE__ */ jsx(
235
- RouteTable,
236
- {
237
- routes,
238
- sortKey,
239
- handleSort
240
- }
241
- )
242
- ] });
243
- };
244
- export {
245
- Routes as default
246
- };
247
- //# sourceMappingURL=index-DzqTj_0f.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-DzqTj_0f.mjs","sources":["../../admin/src/utils/getRouteType.ts","../../admin/src/pages/Routes/TableHeader.tsx","../../admin/src/pages/Routes/TableRow.tsx","../../admin/src/pages/Routes/PageWrapper.tsx","../../admin/src/pages/Routes/compareBy.ts","../../admin/src/pages/Routes/index.tsx"],"sourcesContent":["import type { Route } from \"../../../types\";\n\nexport default function getRouteType(route: Route): 'internal' | 'external' | 'wrapper' {\n if (route.wrapper) {\n return 'wrapper';\n } else if (!route.internal) {\n return 'external';\n } else {\n return 'internal';\n }\n}","import type { RouteSortKey } from '../../../../types';\nimport { Typography, Thead, Tr, Th, VisuallyHidden } from '@strapi/design-system';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport { ChevronDown } from '@strapi/icons';\n\nexport default function TableHeader({\n sortKey,\n handleSort\n}: {\n sortKey: RouteSortKey,\n handleSort: (key: RouteSortKey) => void\n}) {\n const { formatMessage } = useIntl();\n\n return (\n <Thead>\n <Tr>\n <Th onClick={() => handleSort('title')} cursor=\"pointer\">\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('title'),\n defaultMessage: 'Title',\n })}\n </Typography>\n {sortKey === 'title' && <ChevronDown />}\n </Th>\n <Th onClick={() => handleSort('fullPath')} cursor=\"pointer\">\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('route'),\n defaultMessage: 'Route',\n })}\n </Typography>\n {sortKey === 'fullPath' && <ChevronDown />}\n </Th>\n <Th onClick={() => handleSort('type')} cursor=\"pointer\">\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('routes.page.column.type'),\n defaultMessage: 'Type',\n })}\n </Typography>\n {sortKey === 'type' && <ChevronDown />}\n </Th>\n <Th>\n <VisuallyHidden>\n {formatMessage({\n id: getTranslation('actions'),\n defaultMessage: 'Actions',\n })}\n </VisuallyHidden>\n </Th>\n </Tr>\n </Thead>\n )\n}","import type { Route } from '../../../../types';\nimport { Typography, Tr, Td, Flex, LinkButton } from '@strapi/design-system';\nimport { getTranslation, getRouteType } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport { Pencil } from '@strapi/icons';\n\nexport default function TableRow({ route }: { route: Route }) {\n const { formatMessage } = useIntl();\n \n return (\n <Tr>\n <Td>\n <Typography textColor=\"neutral800\">{route.title}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{route.fullPath}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">\n {formatMessage({\n id: getTranslation(`route.type.${getRouteType(route)}`),\n defaultMessage: '-',\n })}\n </Typography>\n </Td>\n <Td>\n <Flex gap={2} justifyContent=\"end\">\n {route.internal && \n <LinkButton\n variant=\"secondary\"\n startIcon={<Pencil />} \n href={`/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`}\n >\n {formatMessage({\n id: getTranslation('edit'),\n defaultMessage: 'Edit',\n })}\n </LinkButton>\n }\n </Flex>\n </Td>\n </Tr>\n )\n}","import { Layouts, Page } from '@strapi/strapi/admin';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\n\nexport default function PageWrapper({ children }: { children: React.ReactNode }) {\n const { formatMessage } = useIntl();\n\n return (\n <Page.Main>\n <Layouts.Header\n title={formatMessage({\n id: getTranslation('routes.page.title'),\n defaultMessage: 'Routes',\n })}\n subtitle={formatMessage({\n id: getTranslation('routes.page.subtitle'),\n defaultMessage: 'Overview of all existing routes',\n })}\n />\n <Layouts.Content>\n <>\n {children}\n </>\n </Layouts.Content>\n </Page.Main>\n );\n}","import type { Route, RouteSortKey } from '../../../../types';\n\nexport default function compareBy(field: RouteSortKey, direction: 'asc' | 'desc') {\n if (!field) {\n return () => 0;\n }\n if (field === 'type') {\n return (a: Route, b: Route) => {\n const typeA = a.internal ? 'internal' : 'external';\n const typeB = b.internal ? 'internal' : 'external';\n return direction === 'asc'\n ? typeA.localeCompare(typeB)\n : typeB.localeCompare(typeA);\n };\n }\n return (a: Route, b: Route) => {\n const aValue = a[field];\n const bValue = b[field];\n if (typeof aValue === 'string' && typeof bValue === 'string') {\n return direction === 'asc'\n ? aValue.localeCompare(bValue)\n : bValue.localeCompare(aValue);\n }\n return 0;\n };\n}","/*\n *\n * Routes\n * This file contains the Routes page of the Webatlas plugin for Strapi.\n * It displays a table of all existing routes with their details and allows editing.\n *\n*/\n\nimport type { Route, RouteSortKey } from '../../../../types';\nimport { useState, useEffect } from 'react';\nimport { Table, Tbody, Box, Grid, Field, EmptyStateLayout, Tr, Td } from '@strapi/design-system';\nimport { Cross } from '@strapi/icons';\nimport { useApi } from '../../hooks';\nimport { FullLoader } from '../../components/UI';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport TableHeader from './TableHeader';\nimport TableRow from './TableRow';\nimport { useNotification } from '@strapi/strapi/admin'\nimport PageWrapper from './PageWrapper';\nimport { useSearchParams } from 'react-router-dom';\nimport debounce from '../../utils/debounce';\nimport { useMemo } from 'react';\nimport compareBy from './compareBy';\n\nfunction SearchInput({\n searchQuery,\n handleSearchChange\n}: {\n searchQuery: string;\n handleSearchChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n}) {\n\n const { formatMessage } = useIntl();\n\n return (\n <Grid.Root style={{ marginBottom: '16px' }}>\n <Grid.Item col={4} s={12}>\n <Box width=\"100%\">\n <Field.Root>\n <Field.Input\n name=\"search\"\n placeholder={formatMessage({\n id: getTranslation('routes.page.searchPlaceholder'),\n defaultMessage: 'Search routes',\n })}\n value={searchQuery}\n onChange={handleSearchChange}\n endAction={\n searchQuery ? (\n <button\n type=\"button\"\n onClick={() => handleSearchChange({ target: { value: '' } } as React.ChangeEvent<HTMLInputElement>)}\n style={{ color: 'inherit', background: 'none', border: 'none', cursor: 'pointer' }}\n aria-label=\"Clear search\"\n >\n <Cross />\n </button>\n ) : null\n }\n />\n </Field.Root>\n </Box>\n </Grid.Item>\n </Grid.Root>\n );\n}\n\nfunction RouteTable({\n routes, \n sortKey, \n handleSort\n}: { \n routes: Route[], \n sortKey: RouteSortKey, \n handleSort: (key: RouteSortKey) => void\n}) {\n \n const { formatMessage } = useIntl();\n\n return (\n <Table colCount={4} rowCount={routes.length}>\n <TableHeader sortKey={sortKey} handleSort={handleSort} />\n <Tbody>\n {routes.length > 0 ? routes.map((route: Route) => (\n <TableRow key={route.id} route={route} />\n )) : \n <Tr>\n <Td colSpan={4}>\n <EmptyStateLayout \n content={\n formatMessage({\n id: getTranslation('routes.page.emptyRoutes'),\n defaultMessage: 'No routes found',\n })\n } \n shadow={false}\n />\n </Td>\n </Tr>\n }\n </Tbody>\n </Table>\n )\n}\n\nconst Routes = () => {\n const { getRoutes } = useApi();\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n \n const [allRoutes, setAllRoutes] = useState<Route[]>([]);\n const [routes, setRoutes] = useState<Route[]>([]);\n const [loading, setLoading] = useState(true);\n const [searchParams, setSearchParams] = useSearchParams();\n const initialQuery = searchParams.get('search') || '';\n const [searchQuery, setSearchQuery] = useState(initialQuery);\n const [sortKey, setSortKey] = useState<RouteSortKey>(undefined);\n const [sortDirection, setSortDirection] = useState<'asc' | 'desc'>('asc');\n\n useEffect(() => {\n const query = searchQuery.toLowerCase()\n setRoutes(\n allRoutes.filter((route) =>\n JSON.stringify(route.id).toLowerCase().includes(query) ||\n route.title.toLowerCase().includes(query) ||\n route.fullPath.toLowerCase().includes(query) ||\n route.relatedDocumentId.toLowerCase().includes(query) ||\n route.relatedContentType.toLowerCase().includes(query)\n )\n )\n }, [searchQuery, allRoutes]);\n\n const debouncedSetSearchParams = useMemo(() =>\n debounce((value: string) => {\n value\n ? setSearchParams({ search: value })\n : setSearchParams({});\n }, 300),\n [setSearchParams]);\n\n const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value\n setSearchQuery(value);\n debouncedSetSearchParams(value);\n }\n\n useEffect(() => {\n async function fetchRoutes() {\n try {\n const data = await getRoutes();\n setAllRoutes(data);\n setRoutes(data);\n } catch (err) {\n console.error('Failed to fetch routes:', err);\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: getTranslation('notification.routes.fetchFailed'),\n defaultMessage: 'Failed to fetch routes',\n }),\n });\n } finally {\n setLoading(false);\n }\n }\n fetchRoutes();\n }, [])\n\n const handleSort = (key: RouteSortKey) => {\n setSortDirection(prev => (prev === 'asc' ? 'desc' : 'asc'));\n setSortKey(key);\n };\n\n useEffect(() => {\n const sortedRoutes = sortKey\n ? [...routes].sort(compareBy(sortKey, sortDirection))\n : routes; \n setRoutes(sortedRoutes);\n }, [sortKey, sortDirection]);\n\n if (loading) {\n return <PageWrapper>\n <FullLoader />\n </PageWrapper>\n }\n\n return (\n <PageWrapper>\n <SearchInput\n handleSearchChange={handleSearchChange}\n searchQuery={searchQuery}\n />\n <RouteTable\n routes={routes} \n sortKey={sortKey}\n handleSort={handleSort}\n />\n </PageWrapper>\n );\n};\n\nexport default Routes;"],"names":[],"mappings":";;;;;;;;;;AAEA,SAAwB,aAAa,OAAmD;AACtF,MAAI,MAAM,SAAS;AACV,WAAA;AAAA,EAAA,WACE,CAAC,MAAM,UAAU;AACnB,WAAA;AAAA,EAAA,OACF;AACE,WAAA;AAAA,EAAA;AAEX;ACJA,SAAwB,YAAY;AAAA,EAClC;AAAA,EACA;AACF,GAGG;AACK,QAAA,EAAE,cAAc,IAAI,QAAQ;AAGhC,SAAA,oBAAC,OACC,EAAA,UAAA,qBAAC,IACC,EAAA,UAAA;AAAA,IAAA,qBAAC,MAAG,SAAS,MAAM,WAAW,OAAO,GAAG,QAAO,WAC7C,UAAA;AAAA,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C,oBAAA,YAAA,CAAW,CAAA,GACd;AAAA,EAAA;AAGF,8BACG,aACC,EAAA,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,IACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-KC82xDAD.mjs","sources":["../../admin/src/utils/getRouteType.ts","../../admin/src/pages/Routes/TableHeader.tsx","../../admin/src/pages/Routes/TableRow.tsx","../../admin/src/pages/Routes/PageWrapper.tsx","../../admin/src/pages/Routes/compareBy.ts","../../admin/src/pages/Routes/index.tsx"],"sourcesContent":["import type { Route } from \"../../../types\";\n\nexport default function getRouteType(route: Route): 'internal' | 'external' | 'wrapper' {\n if (route.wrapper) {\n return 'wrapper';\n } else if (!route.internal) {\n return 'external';\n } else {\n return 'internal';\n }\n}","import type { RouteSortKey } from '../../../../types';\nimport { Typography, Thead, Tr, Th, VisuallyHidden } from '@strapi/design-system';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport { ChevronDown } from '@strapi/icons';\n\nexport default function TableHeader({\n sortKey,\n handleSort\n}: {\n sortKey: RouteSortKey,\n handleSort: (key: RouteSortKey) => void\n}) {\n const { formatMessage } = useIntl();\n\n return (\n <Thead>\n <Tr>\n <Th onClick={() => handleSort('title')} cursor=\"pointer\">\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('title'),\n defaultMessage: 'Title',\n })}\n </Typography>\n {sortKey === 'title' && <ChevronDown />}\n </Th>\n <Th onClick={() => handleSort('fullPath')} cursor=\"pointer\">\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('route'),\n defaultMessage: 'Route',\n })}\n </Typography>\n {sortKey === 'fullPath' && <ChevronDown />}\n </Th>\n <Th onClick={() => handleSort('type')} cursor=\"pointer\">\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('routes.page.column.type'),\n defaultMessage: 'Type',\n })}\n </Typography>\n {sortKey === 'type' && <ChevronDown />}\n </Th>\n <Th>\n <VisuallyHidden>\n {formatMessage({\n id: getTranslation('actions'),\n defaultMessage: 'Actions',\n })}\n </VisuallyHidden>\n </Th>\n </Tr>\n </Thead>\n )\n}","import type { Route } from '../../../../types';\nimport { Typography, Tr, Td, Flex, LinkButton } from '@strapi/design-system';\nimport { getTranslation, getRouteType } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport { Pencil } from '@strapi/icons';\n\nexport default function TableRow({ route }: { route: Route }) {\n const { formatMessage } = useIntl();\n \n return (\n <Tr>\n <Td>\n <Typography textColor=\"neutral800\">{route.title}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{route.fullPath}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">\n {formatMessage({\n id: getTranslation(`route.type.${getRouteType(route)}`),\n defaultMessage: '-',\n })}\n </Typography>\n </Td>\n <Td>\n <Flex gap={2} justifyContent=\"end\">\n {route.internal && \n <LinkButton\n variant=\"secondary\"\n startIcon={<Pencil />} \n href={`/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`}\n >\n {formatMessage({\n id: getTranslation('edit'),\n defaultMessage: 'Edit',\n })}\n </LinkButton>\n }\n </Flex>\n </Td>\n </Tr>\n )\n}","import { Layouts, Page } from '@strapi/strapi/admin';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\n\nexport default function PageWrapper({ children }: { children: React.ReactNode }) {\n const { formatMessage } = useIntl();\n\n return (\n <Page.Main>\n <Layouts.Header\n title={formatMessage({\n id: getTranslation('routes.page.title'),\n defaultMessage: 'Routes',\n })}\n subtitle={formatMessage({\n id: getTranslation('routes.page.subtitle'),\n defaultMessage: 'Overview of all existing routes',\n })}\n />\n <Layouts.Content>\n <>\n {children}\n </>\n </Layouts.Content>\n </Page.Main>\n );\n}","import type { Route, RouteSortKey } from '../../../../types';\n\nexport default function compareBy(field: RouteSortKey, direction: 'asc' | 'desc') {\n if (!field) {\n return () => 0;\n }\n if (field === 'type') {\n return (a: Route, b: Route) => {\n const typeA = a.internal ? 'internal' : 'external';\n const typeB = b.internal ? 'internal' : 'external';\n return direction === 'asc'\n ? typeA.localeCompare(typeB)\n : typeB.localeCompare(typeA);\n };\n }\n return (a: Route, b: Route) => {\n const aValue = a[field];\n const bValue = b[field];\n if (typeof aValue === 'string' && typeof bValue === 'string') {\n return direction === 'asc'\n ? aValue.localeCompare(bValue)\n : bValue.localeCompare(aValue);\n }\n return 0;\n };\n}","/*\n *\n * Routes\n * This file contains the Routes page of the Webatlas plugin for Strapi.\n * It displays a table of all existing routes with their details and allows editing.\n *\n*/\n\nimport type { Route, RouteSortKey } from '../../../../types';\nimport { useState, useEffect } from 'react';\nimport { Table, Tbody, Box, Grid, Field, EmptyStateLayout, Tr, Td } from '@strapi/design-system';\nimport { Cross } from '@strapi/icons';\nimport { useApi } from '../../hooks';\nimport { FullLoader } from '../../components/UI';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport TableHeader from './TableHeader';\nimport TableRow from './TableRow';\nimport { useNotification } from '@strapi/strapi/admin'\nimport PageWrapper from './PageWrapper';\nimport { useSearchParams } from 'react-router-dom';\nimport debounce from '../../utils/debounce';\nimport { useMemo } from 'react';\nimport compareBy from './compareBy';\n\nfunction SearchInput({\n searchQuery,\n handleSearchChange\n}: {\n searchQuery: string;\n handleSearchChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n}) {\n\n const { formatMessage } = useIntl();\n\n return (\n <Grid.Root style={{ marginBottom: '16px' }}>\n <Grid.Item col={4} s={12}>\n <Box width=\"100%\">\n <Field.Root>\n <Field.Input\n name=\"search\"\n placeholder={formatMessage({\n id: getTranslation('routes.page.searchPlaceholder'),\n defaultMessage: 'Search routes',\n })}\n value={searchQuery}\n onChange={handleSearchChange}\n endAction={\n searchQuery ? (\n <button\n type=\"button\"\n onClick={() => handleSearchChange({ target: { value: '' } } as React.ChangeEvent<HTMLInputElement>)}\n style={{ color: 'inherit', background: 'none', border: 'none', cursor: 'pointer' }}\n aria-label=\"Clear search\"\n >\n <Cross />\n </button>\n ) : null\n }\n />\n </Field.Root>\n </Box>\n </Grid.Item>\n </Grid.Root>\n );\n}\n\nfunction RouteTable({\n routes, \n sortKey, \n handleSort\n}: { \n routes: Route[], \n sortKey: RouteSortKey, \n handleSort: (key: RouteSortKey) => void\n}) {\n \n const { formatMessage } = useIntl();\n\n return (\n <Table colCount={4} rowCount={routes.length}>\n <TableHeader sortKey={sortKey} handleSort={handleSort} />\n <Tbody>\n {routes.length > 0 ? routes.map((route: Route) => (\n <TableRow key={route.id} route={route} />\n )) : \n <Tr>\n <Td colSpan={4}>\n <EmptyStateLayout \n content={\n formatMessage({\n id: getTranslation('routes.page.emptyRoutes'),\n defaultMessage: 'No routes found',\n })\n } \n shadow={false}\n />\n </Td>\n </Tr>\n }\n </Tbody>\n </Table>\n )\n}\n\nconst Routes = () => {\n const { getRoutes } = useApi();\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n \n const [allRoutes, setAllRoutes] = useState<Route[]>([]);\n const [routes, setRoutes] = useState<Route[]>([]);\n const [loading, setLoading] = useState(true);\n const [searchParams, setSearchParams] = useSearchParams();\n const initialQuery = searchParams.get('search') || '';\n const [searchQuery, setSearchQuery] = useState(initialQuery);\n const [sortKey, setSortKey] = useState<RouteSortKey>(undefined);\n const [sortDirection, setSortDirection] = useState<'asc' | 'desc'>('asc');\n\n useEffect(() => {\n const query = searchQuery.toLowerCase()\n setRoutes(\n allRoutes.filter((route) =>\n JSON.stringify(route.id).toLowerCase().includes(query) ||\n route.title.toLowerCase().includes(query) ||\n route.fullPath.toLowerCase().includes(query) ||\n route.relatedDocumentId.toLowerCase().includes(query) ||\n route.relatedContentType.toLowerCase().includes(query)\n )\n )\n }, [searchQuery, allRoutes]);\n\n const debouncedSetSearchParams = useMemo(() =>\n debounce((value: string) => {\n value\n ? setSearchParams({ search: value })\n : setSearchParams({});\n }, 300),\n [setSearchParams]);\n\n const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value\n setSearchQuery(value);\n debouncedSetSearchParams(value);\n }\n\n useEffect(() => {\n async function fetchRoutes() {\n try {\n const data = await getRoutes();\n setAllRoutes(data);\n setRoutes(data);\n } catch (err) {\n console.error('Failed to fetch routes:', err);\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: getTranslation('notification.routes.fetchFailed'),\n defaultMessage: 'Failed to fetch routes',\n }),\n });\n } finally {\n setLoading(false);\n }\n }\n fetchRoutes();\n }, [])\n\n const handleSort = (key: RouteSortKey) => {\n setSortDirection(prev => (prev === 'asc' ? 'desc' : 'asc'));\n setSortKey(key);\n };\n\n useEffect(() => {\n const sortedRoutes = sortKey\n ? [...routes].sort(compareBy(sortKey, sortDirection))\n : routes; \n setRoutes(sortedRoutes);\n }, [sortKey, sortDirection]);\n\n if (loading) {\n return <PageWrapper>\n <FullLoader />\n </PageWrapper>\n }\n\n return (\n <PageWrapper>\n <SearchInput\n handleSearchChange={handleSearchChange}\n searchQuery={searchQuery}\n />\n <RouteTable\n routes={routes} \n sortKey={sortKey}\n handleSort={handleSort}\n />\n </PageWrapper>\n );\n};\n\nexport default Routes;"],"names":[],"mappings":";;;;;;;;;;AAEA,SAAwB,aAAa,OAAmD;AACtF,MAAI,MAAM,SAAS;AACV,WAAA;AAAA,EAAA,WACE,CAAC,MAAM,UAAU;AACnB,WAAA;AAAA,EAAA,OACF;AACE,WAAA;AAAA,EAAA;AAEX;ACJA,SAAwB,YAAY;AAAA,EAClC;AAAA,EACA;AACF,GAGG;AACK,QAAA,EAAE,cAAc,IAAI,QAAQ;AAGhC,SAAA,oBAAC,OACC,EAAA,UAAA,qBAAC,IACC,EAAA,UAAA;AAAA,IAAA,qBAAC,MAAG,SAAS,MAAM,WAAW,OAAO,G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,WAAQ,oBAAA,aAAA,EACN,UAAC,oBAAA,YAAA,CAAW,CAAA,GACd;AAAA,EAAA;AAGF,8BACG,aACC,EAAA,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,IACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
@@ -1,282 +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 designSystem = require("@strapi/design-system");
6
- const admin = require("@strapi/strapi/admin");
7
- const index = require("./index-2J9mPFyV.js");
8
- const reactIntl = require("react-intl");
9
- require("@strapi/icons/symbols");
10
- const FullLoader = require("./FullLoader-Cmsf8xS6.js");
11
- function PageWrapper({
12
- settingsState,
13
- initialState,
14
- save,
15
- isSaving,
16
- children
17
- }) {
18
- const { formatMessage } = reactIntl.useIntl();
19
- return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
20
- /* @__PURE__ */ jsxRuntime.jsx(
21
- admin.Layouts.Header,
22
- {
23
- title: index.PLUGIN_NAME,
24
- subtitle: formatMessage({
25
- id: index.getTranslation("settings.page.subtitle"),
26
- defaultMessage: "Settings"
27
- }),
28
- primaryAction: settingsState && initialState && save && /* @__PURE__ */ jsxRuntime.jsx(
29
- designSystem.Button,
30
- {
31
- type: "submit",
32
- onClick: () => save(),
33
- loading: isSaving,
34
- disabled: JSON.stringify(settingsState) === JSON.stringify(initialState) || settingsState.selectedContentTypes.find((cta) => !cta.default) !== void 0 || isSaving,
35
- children: formatMessage({
36
- id: index.getTranslation("save"),
37
- defaultMessage: "Save"
38
- })
39
- }
40
- )
41
- }
42
- ),
43
- /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
44
- designSystem.Box,
45
- {
46
- background: "neutral0",
47
- borderColor: "neutral150",
48
- hasRadius: true,
49
- paddingBottom: 4,
50
- paddingLeft: 4,
51
- paddingRight: 4,
52
- paddingTop: 6,
53
- shadow: "tableShadow",
54
- children
55
- }
56
- ) })
57
- ] });
58
- }
59
- function ContentTypeAccordion({
60
- contentType,
61
- contentTypeSettings,
62
- dispatch
63
- }) {
64
- const { formatMessage } = reactIntl.useIntl();
65
- if (!contentType) return null;
66
- return /* @__PURE__ */ jsxRuntime.jsx(
67
- designSystem.Box,
68
- {
69
- borderColor: !contentTypeSettings.default && "danger500",
70
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: contentType.uid, size: "S", children: [
71
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: contentType?.info.displayName }) }),
72
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 3, children: [
73
- /* @__PURE__ */ jsxRuntime.jsxs(
74
- designSystem.Field.Root,
75
- {
76
- name: "selectedContentTypes",
77
- hint: formatMessage({
78
- id: index.getTranslation("settings.page.defaultField.hint"),
79
- defaultMessage: 'The selected field from the content type will be used to generate the URL alias. Use a field that is unique and descriptive, such as a "title" or "name".'
80
- }),
81
- error: !contentTypeSettings.default && formatMessage({
82
- id: index.getTranslation("settings.page.defaultField.error"),
83
- defaultMessage: "Please select a default field"
84
- }),
85
- required: true,
86
- children: [
87
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
88
- id: index.getTranslation("settings.page.defaultField"),
89
- defaultMessage: "Default URL Alias field"
90
- }) }),
91
- /* @__PURE__ */ jsxRuntime.jsx(
92
- designSystem.SingleSelect,
93
- {
94
- name: `defaultField-${contentType.uid}`,
95
- onClear: () => dispatch({ type: "SET_DEFAULT_FIELD", payload: { ctUid: contentType.uid, field: "" } }),
96
- value: contentTypeSettings?.default || "",
97
- onChange: (value) => dispatch({ type: "SET_DEFAULT_FIELD", payload: { ctUid: contentType.uid, field: value } }),
98
- children: Object.entries(contentType.attributes).map(([key], index2) => {
99
- if (key === "id" || key === "documentId" || key === "createdAt" || key === "updatedAt" || key === "createdBy" || key === "updatedBy" || key === "webatlas_path" || key === "webatlas_override") return null;
100
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: key, children: key }, index2);
101
- })
102
- }
103
- ),
104
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
105
- ]
106
- }
107
- ),
108
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
109
- designSystem.Field.Root,
110
- {
111
- name: "urlAliasPattern",
112
- hint: formatMessage({
113
- id: index.getTranslation("settings.page.urlAliasPattern.hint"),
114
- defaultMessage: 'The pattern to prepend to the generated URL alias. For example, if you enter "blog" and the value of default field is "My First Post", the generated URL alias will be "blog/my-first-post". Leave empty for no prefix.'
115
- }),
116
- children: [
117
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { children: [
118
- formatMessage({
119
- id: index.getTranslation("settings.page.urlAliasPattern"),
120
- defaultMessage: "URL Alias Pattern"
121
- }),
122
- /* @__PURE__ */ jsxRuntime.jsx(index.Tooltip, { description: formatMessage({
123
- id: index.getTranslation("settings.page.urlAliasPattern.tooltip"),
124
- defaultMessage: "Leading and trailing slashes will be removed. Spaces will be replaced with hyphens. Special characters will be encoded."
125
- }) })
126
- ] }),
127
- /* @__PURE__ */ jsxRuntime.jsx(
128
- designSystem.Field.Input,
129
- {
130
- value: contentTypeSettings.pattern,
131
- onChange: (e) => dispatch({ type: "SET_PATTERN", payload: { ctUid: contentType.uid, pattern: e.target.value } }),
132
- disabled: !contentTypeSettings.default,
133
- type: "text",
134
- placeholder: formatMessage({
135
- id: index.getTranslation("settings.page.urlAliasPattern.placeholder"),
136
- defaultMessage: "e.g. blog"
137
- })
138
- }
139
- ),
140
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
141
- ]
142
- }
143
- ) })
144
- ] }) })
145
- ] }, contentType.uid)
146
- },
147
- contentType.uid
148
- );
149
- }
150
- function reducer(settingsState, action) {
151
- let updatedContentTypes;
152
- switch (action.type) {
153
- case "SET_SELECTED_CONTENT_TYPES":
154
- updatedContentTypes = action.payload.map((ct) => {
155
- return settingsState.selectedContentTypes.find((cta) => cta.uid === ct.uid) || ct;
156
- });
157
- return { ...settingsState, selectedContentTypes: updatedContentTypes };
158
- case "SET_DEFAULT_FIELD":
159
- updatedContentTypes = settingsState.selectedContentTypes.map(
160
- (ct) => ct.uid === action.payload.ctUid ? { ...ct, default: action.payload.field } : ct
161
- );
162
- return { ...settingsState, selectedContentTypes: updatedContentTypes };
163
- case "SET_PATTERN":
164
- updatedContentTypes = settingsState.selectedContentTypes.map(
165
- (ct) => ct.uid === action.payload.ctUid ? { ...ct, pattern: index.transformToUrl(action.payload.pattern) } : ct
166
- );
167
- return { ...settingsState, selectedContentTypes: updatedContentTypes };
168
- default:
169
- throw new Error();
170
- }
171
- }
172
- const Settings = () => {
173
- const { config, setConfig, loading, fetchError } = index.usePluginConfig();
174
- const [settingsState, dispatch] = React.useReducer(reducer, config || { selectedContentTypes: [] });
175
- const { contentTypes: allContentTypesData } = index.useAllContentTypes();
176
- const allContentTypes = allContentTypesData?.filter((ct) => ct.pluginOptions?.webatlas?.active === true);
177
- const [initialState, setInitialState] = React.useState(config || { selectedContentTypes: [] });
178
- const { toggleNotification } = admin.useNotification();
179
- const { formatMessage } = reactIntl.useIntl();
180
- const [isSaving, setIsSaving] = React.useState(false);
181
- React.useEffect(() => {
182
- setInitialState(config || { selectedContentTypes: [] });
183
- }, [config]);
184
- React.useEffect(() => {
185
- if (!config) return;
186
- dispatch({ type: "SET_SELECTED_CONTENT_TYPES", payload: config.selectedContentTypes });
187
- }, [config]);
188
- React.useEffect(() => {
189
- if (fetchError) {
190
- toggleNotification({
191
- type: "danger",
192
- message: formatMessage({
193
- id: index.getTranslation("notification.error"),
194
- defaultMessage: "An error occurred"
195
- }) + ": " + fetchError
196
- });
197
- }
198
- }, [fetchError, toggleNotification, formatMessage]);
199
- async function save() {
200
- if (!settingsState || settingsState.selectedContentTypes.find((cta) => !cta.default) !== void 0) return;
201
- setIsSaving(true);
202
- try {
203
- await setConfig(settingsState);
204
- setInitialState(settingsState);
205
- toggleNotification({
206
- type: "success",
207
- message: formatMessage({
208
- id: index.getTranslation("notification.settings.saved"),
209
- defaultMessage: "Settings saved successfully"
210
- })
211
- });
212
- setIsSaving(false);
213
- } catch (err) {
214
- setIsSaving(false);
215
- toggleNotification({
216
- type: "danger",
217
- message: formatMessage({
218
- id: index.getTranslation("notification.error"),
219
- defaultMessage: "An error occurred"
220
- }) + ": " + err
221
- });
222
- console.error(err);
223
- }
224
- }
225
- if (loading) {
226
- return /* @__PURE__ */ jsxRuntime.jsx(PageWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, { height: 200 }) });
227
- }
228
- return /* @__PURE__ */ jsxRuntime.jsxs(PageWrapper, { settingsState, initialState, save, isSaving, children: [
229
- /* @__PURE__ */ jsxRuntime.jsxs(
230
- designSystem.Field.Root,
231
- {
232
- name: "selectedContentTypes",
233
- hint: formatMessage({
234
- id: index.getTranslation("settings.page.enabledContentTypes.hint"),
235
- defaultMessage: "Select the content types for which you want to enable URL aliases"
236
- }),
237
- children: [
238
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
239
- id: index.getTranslation("settings.page.enabledContentTypes"),
240
- defaultMessage: "Enabled Content Types"
241
- }) }),
242
- /* @__PURE__ */ jsxRuntime.jsx(
243
- designSystem.MultiSelect,
244
- {
245
- placeholder: formatMessage({
246
- id: index.getTranslation("settings.page.enabledContentTypes.placeholder"),
247
- defaultMessage: "Select content types..."
248
- }),
249
- onClear: () => dispatch({ type: "SET_SELECTED_CONTENT_TYPES", payload: [] }),
250
- value: [...settingsState.selectedContentTypes.map((ct) => ct.uid)],
251
- onChange: (value) => dispatch({
252
- type: "SET_SELECTED_CONTENT_TYPES",
253
- payload: value.map((v) => ({
254
- uid: v,
255
- default: "",
256
- pattern: ""
257
- }))
258
- }),
259
- withTags: true,
260
- children: allContentTypes && allContentTypes.map(
261
- (item) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MultiSelectOption, { value: item.uid, children: item.info.displayName }, item.uid)
262
- )
263
- }
264
- ),
265
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
266
- ]
267
- }
268
- ),
269
- settingsState.selectedContentTypes && settingsState.selectedContentTypes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "selectedContentTypesAccordion", children: [
270
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
271
- id: index.getTranslation("settings.page.contentTypeSettings"),
272
- defaultMessage: "Content Type settings"
273
- }) }),
274
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { children: settingsState.selectedContentTypes?.map((contentTypeSettings) => {
275
- const ct = allContentTypes?.find((item) => item.uid === contentTypeSettings.uid);
276
- return /* @__PURE__ */ jsxRuntime.jsx(ContentTypeAccordion, { contentType: ct, contentTypeSettings, dispatch }, contentTypeSettings.uid);
277
- }) })
278
- ] }) })
279
- ] });
280
- };
281
- exports.default = Settings;
282
- //# sourceMappingURL=index-NZpDoHIv.js.map