@mattisvensson/strapi-plugin-webatlas 0.7.1 → 0.8.1
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.
- package/dist/_chunks/PageWrapper-Bp9vGwpG.js +54 -0
- package/dist/_chunks/PageWrapper-BvOY7VCN.mjs +55 -0
- package/dist/_chunks/PageWrapper-BzDrMm2d.js +55 -0
- package/dist/_chunks/PageWrapper-BzDrMm2d.js.map +1 -0
- package/dist/_chunks/PageWrapper-oLhcg9BA.mjs +56 -0
- package/dist/_chunks/PageWrapper-oLhcg9BA.mjs.map +1 -0
- package/dist/_chunks/{de-BZc1BkzH.js → de-CDBoUBzw.js} +5 -2
- package/dist/_chunks/{en-Deg4n_IM.js.map → de-CDBoUBzw.js.map} +1 -1
- package/dist/_chunks/{de-oxxH8hft.mjs → de-Dt80IqMG.mjs} +5 -2
- package/dist/_chunks/{en-DqC5aDzA.mjs.map → de-Dt80IqMG.mjs.map} +1 -1
- package/dist/_chunks/{en-DqC5aDzA.mjs → en-BHxDiueo.mjs} +5 -2
- package/dist/_chunks/{de-oxxH8hft.mjs.map → en-BHxDiueo.mjs.map} +1 -1
- package/dist/_chunks/{en-Deg4n_IM.js → en-DfvURaup.js} +5 -2
- package/dist/_chunks/{de-BZc1BkzH.js.map → en-DfvURaup.js.map} +1 -1
- package/dist/_chunks/{index-dzRHjemo.js → index--oj1eNcM.js} +2 -2
- package/dist/_chunks/{index-CHB_8c7e.js.map → index--oj1eNcM.js.map} +1 -1
- package/dist/_chunks/index-BBn1ZvsE.mjs +123 -0
- package/dist/_chunks/index-BCPgfhBx.js +124 -0
- package/dist/_chunks/index-BCPgfhBx.js.map +1 -0
- package/dist/_chunks/{index-CHB_8c7e.js → index-BKdvSgDB.js} +1 -1
- package/dist/_chunks/{index-DzqTj_0f.mjs → index-CAged_xE.mjs} +2 -2
- package/dist/_chunks/{index-KC82xDAD.mjs.map → index-CAged_xE.mjs.map} +1 -1
- package/dist/_chunks/index-CHRBu9Xy.mjs +124 -0
- package/dist/_chunks/index-CHRBu9Xy.mjs.map +1 -0
- package/dist/_chunks/{index-C6Dorrjz.mjs → index-CTA8agp7.mjs} +40 -13
- package/dist/_chunks/{index-BFMLU2kR.mjs → index-CUlRMqGG.mjs} +57 -60
- package/dist/_chunks/{index-C6e9wLau.js → index-CbW6k4FH.js} +41 -12
- package/dist/_chunks/index-CbW6k4FH.js.map +1 -0
- package/dist/_chunks/{index-B79--vLg.js → index-CtFERXkl.js} +91 -119
- package/dist/_chunks/index-CtFERXkl.js.map +1 -0
- package/dist/_chunks/{index-D5Uc0GLu.mjs → index-D29zBs5w.mjs} +58 -59
- package/dist/_chunks/index-D29zBs5w.mjs.map +1 -0
- package/dist/_chunks/index-D72CZ5b7.js +123 -0
- package/dist/_chunks/{index-DcFYhqke.mjs → index-DJBXRNlE.mjs} +95 -123
- package/dist/_chunks/index-DJBXRNlE.mjs.map +1 -0
- package/dist/_chunks/{index-DY1ICa5c.mjs → index-DMpiX4hP.mjs} +41 -12
- package/dist/_chunks/index-DMpiX4hP.mjs.map +1 -0
- package/dist/_chunks/{index-DeCgextE.js → index-DTPDMxs_.js} +57 -59
- package/dist/_chunks/{index-NZpDoHIv.js → index-DUgh4AJb.js} +90 -120
- package/dist/_chunks/{index-2J9mPFyV.js → index-Dxn0NT06.js} +40 -13
- package/dist/_chunks/{index-DLZJ_sUK.mjs → index-Nx4IRYIK.mjs} +94 -124
- package/dist/_chunks/{index-KC82xDAD.mjs → index-Rfm9O167.mjs} +1 -1
- package/dist/_chunks/{index-DCejsR9X.js → index-YzPuPn68.js} +58 -60
- package/dist/_chunks/index-YzPuPn68.js.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/modals/NavEdit.d.ts +1 -1
- package/dist/admin/src/components/modals/fields/Visibility.d.ts +5 -0
- package/dist/admin/src/components/modals/fields/index.d.ts +2 -0
- package/dist/admin/src/hooks/usePluginConfig.d.ts +1 -1
- package/dist/admin/src/pages/Settings/{ContentTypeAccordion.d.ts → General/ContentTypeAccordion.d.ts} +1 -1
- package/dist/admin/src/pages/Settings/Navigation/index.d.ts +2 -0
- package/dist/admin/src/pages/Settings/PageWrapper.d.ts +3 -4
- package/dist/admin/src/utils/dnd.d.ts +1 -1
- package/dist/server/index.js +32 -14
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +32 -14
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/index.d.ts +1 -1
- package/dist/server/src/services/admin.d.ts +2 -2
- package/dist/server/src/services/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/_chunks/index-2J9mPFyV.js.map +0 -1
- package/dist/_chunks/index-B79--vLg.js.map +0 -1
- package/dist/_chunks/index-BFMLU2kR.mjs.map +0 -1
- package/dist/_chunks/index-C6Dorrjz.mjs.map +0 -1
- package/dist/_chunks/index-C6e9wLau.js.map +0 -1
- package/dist/_chunks/index-D5Uc0GLu.mjs.map +0 -1
- package/dist/_chunks/index-DCejsR9X.js.map +0 -1
- package/dist/_chunks/index-DLZJ_sUK.mjs.map +0 -1
- package/dist/_chunks/index-DY1ICa5c.mjs.map +0 -1
- package/dist/_chunks/index-DcFYhqke.mjs.map +0 -1
- package/dist/_chunks/index-DeCgextE.js.map +0 -1
- package/dist/_chunks/index-DzqTj_0f.mjs.map +0 -1
- package/dist/_chunks/index-NZpDoHIv.js.map +0 -1
- package/dist/_chunks/index-dzRHjemo.js.map +0 -1
- /package/dist/admin/src/pages/Settings/{index.d.ts → General/index.d.ts} +0 -0
|
@@ -1,59 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useReducer, useState, useEffect } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useReducer, useState, useRef, useEffect } from "react";
|
|
3
|
+
import { Box, Accordion, Field, SingleSelect, SingleSelectOption, MultiSelect, MultiSelectOption } from "@strapi/design-system";
|
|
4
|
+
import { useNotification } from "@strapi/strapi/admin";
|
|
5
|
+
import { g as getTranslation, T as Tooltip, b as usePluginConfig, c as useAllContentTypes, t as transformToUrl } from "./index-CTA8agp7.mjs";
|
|
6
6
|
import { useIntl } from "react-intl";
|
|
7
7
|
import "@strapi/icons/symbols";
|
|
8
8
|
import { F as FullLoader } from "./FullLoader-CrPED_dY.mjs";
|
|
9
|
-
|
|
10
|
-
settingsState,
|
|
11
|
-
initialState,
|
|
12
|
-
save,
|
|
13
|
-
isSaving,
|
|
14
|
-
children
|
|
15
|
-
}) {
|
|
16
|
-
const { formatMessage } = useIntl();
|
|
17
|
-
return /* @__PURE__ */ jsxs(Page.Main, { children: [
|
|
18
|
-
/* @__PURE__ */ jsx(
|
|
19
|
-
Layouts.Header,
|
|
20
|
-
{
|
|
21
|
-
title: PLUGIN_NAME,
|
|
22
|
-
subtitle: formatMessage({
|
|
23
|
-
id: getTranslation("settings.page.subtitle"),
|
|
24
|
-
defaultMessage: "Settings"
|
|
25
|
-
}),
|
|
26
|
-
primaryAction: settingsState && initialState && save && /* @__PURE__ */ jsx(
|
|
27
|
-
Button,
|
|
28
|
-
{
|
|
29
|
-
type: "submit",
|
|
30
|
-
onClick: () => save(),
|
|
31
|
-
loading: isSaving,
|
|
32
|
-
disabled: JSON.stringify(settingsState) === JSON.stringify(initialState) || settingsState.selectedContentTypes.find((cta) => !cta.default) !== void 0 || isSaving,
|
|
33
|
-
children: formatMessage({
|
|
34
|
-
id: getTranslation("save"),
|
|
35
|
-
defaultMessage: "Save"
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
),
|
|
41
|
-
/* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(
|
|
42
|
-
Box,
|
|
43
|
-
{
|
|
44
|
-
background: "neutral0",
|
|
45
|
-
borderColor: "neutral150",
|
|
46
|
-
hasRadius: true,
|
|
47
|
-
paddingBottom: 4,
|
|
48
|
-
paddingLeft: 4,
|
|
49
|
-
paddingRight: 4,
|
|
50
|
-
paddingTop: 6,
|
|
51
|
-
shadow: "tableShadow",
|
|
52
|
-
children
|
|
53
|
-
}
|
|
54
|
-
) })
|
|
55
|
-
] });
|
|
56
|
-
}
|
|
9
|
+
import { P as PageWrapper } from "./PageWrapper-BvOY7VCN.mjs";
|
|
57
10
|
function ContentTypeAccordion({
|
|
58
11
|
contentType,
|
|
59
12
|
contentTypeSettings,
|
|
@@ -145,44 +98,47 @@ function ContentTypeAccordion({
|
|
|
145
98
|
contentType.uid
|
|
146
99
|
);
|
|
147
100
|
}
|
|
148
|
-
function reducer(
|
|
101
|
+
function reducer(newConfig, action) {
|
|
149
102
|
let updatedContentTypes;
|
|
150
103
|
switch (action.type) {
|
|
151
104
|
case "SET_SELECTED_CONTENT_TYPES":
|
|
105
|
+
if (!newConfig) return null;
|
|
152
106
|
updatedContentTypes = action.payload.map((ct) => {
|
|
153
|
-
return
|
|
107
|
+
return newConfig?.selectedContentTypes.find((cta) => cta.uid === ct.uid) || ct;
|
|
154
108
|
});
|
|
155
|
-
return { ...
|
|
109
|
+
return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
|
|
156
110
|
case "SET_DEFAULT_FIELD":
|
|
157
|
-
|
|
111
|
+
if (!newConfig) return null;
|
|
112
|
+
updatedContentTypes = newConfig?.selectedContentTypes.map(
|
|
158
113
|
(ct) => ct.uid === action.payload.ctUid ? { ...ct, default: action.payload.field } : ct
|
|
159
114
|
);
|
|
160
|
-
return { ...
|
|
115
|
+
return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
|
|
161
116
|
case "SET_PATTERN":
|
|
162
|
-
|
|
117
|
+
if (!newConfig) return null;
|
|
118
|
+
updatedContentTypes = newConfig?.selectedContentTypes.map(
|
|
163
119
|
(ct) => ct.uid === action.payload.ctUid ? { ...ct, pattern: transformToUrl(action.payload.pattern) } : ct
|
|
164
120
|
);
|
|
165
|
-
return { ...
|
|
121
|
+
return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
|
|
122
|
+
case "SET_CONFIG":
|
|
123
|
+
return action.payload;
|
|
166
124
|
default:
|
|
167
125
|
throw new Error();
|
|
168
126
|
}
|
|
169
127
|
}
|
|
170
128
|
const Settings = () => {
|
|
171
|
-
const { config, setConfig, loading, fetchError } = usePluginConfig();
|
|
172
|
-
const [
|
|
129
|
+
const { config: fetchedConfig, setConfig, loading, fetchError } = usePluginConfig();
|
|
130
|
+
const [config, dispatch] = useReducer(reducer, fetchedConfig);
|
|
173
131
|
const { contentTypes: allContentTypesData } = useAllContentTypes();
|
|
174
132
|
const allContentTypes = allContentTypesData?.filter((ct) => ct.pluginOptions?.webatlas?.active === true);
|
|
175
|
-
const [initialState, setInitialState] = useState(config || { selectedContentTypes: [] });
|
|
176
133
|
const { toggleNotification } = useNotification();
|
|
177
134
|
const { formatMessage } = useIntl();
|
|
178
135
|
const [isSaving, setIsSaving] = useState(false);
|
|
136
|
+
const initialConfig = useRef(fetchedConfig);
|
|
179
137
|
useEffect(() => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
dispatch({ type: "SET_SELECTED_CONTENT_TYPES", payload: config.selectedContentTypes });
|
|
185
|
-
}, [config]);
|
|
138
|
+
initialConfig.current = fetchedConfig;
|
|
139
|
+
if (fetchedConfig)
|
|
140
|
+
dispatch({ type: "SET_CONFIG", payload: fetchedConfig });
|
|
141
|
+
}, [fetchedConfig]);
|
|
186
142
|
useEffect(() => {
|
|
187
143
|
if (fetchError) {
|
|
188
144
|
toggleNotification({
|
|
@@ -195,11 +151,11 @@ const Settings = () => {
|
|
|
195
151
|
}
|
|
196
152
|
}, [fetchError, toggleNotification, formatMessage]);
|
|
197
153
|
async function save() {
|
|
198
|
-
if (!
|
|
154
|
+
if (!config || config.selectedContentTypes.find((cta) => !cta.default) !== void 0) return;
|
|
199
155
|
setIsSaving(true);
|
|
200
156
|
try {
|
|
201
|
-
await setConfig(
|
|
202
|
-
|
|
157
|
+
await setConfig({ selectedContentTypes: config.selectedContentTypes });
|
|
158
|
+
initialConfig.current = config;
|
|
203
159
|
toggleNotification({
|
|
204
160
|
type: "success",
|
|
205
161
|
message: formatMessage({
|
|
@@ -221,62 +177,76 @@ const Settings = () => {
|
|
|
221
177
|
}
|
|
222
178
|
}
|
|
223
179
|
if (loading) {
|
|
224
|
-
return /* @__PURE__ */ jsx(
|
|
225
|
-
|
|
226
|
-
return /* @__PURE__ */ jsxs(PageWrapper, { settingsState, initialState, save, isSaving, children: [
|
|
227
|
-
/* @__PURE__ */ jsxs(
|
|
228
|
-
Field.Root,
|
|
180
|
+
return /* @__PURE__ */ jsx(
|
|
181
|
+
PageWrapper,
|
|
229
182
|
{
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
183
|
+
isSaving,
|
|
184
|
+
disabledCondition: true,
|
|
185
|
+
children: /* @__PURE__ */ jsx(FullLoader, { height: 200 })
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return /* @__PURE__ */ jsxs(
|
|
190
|
+
PageWrapper,
|
|
191
|
+
{
|
|
192
|
+
save,
|
|
193
|
+
isSaving,
|
|
194
|
+
disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current),
|
|
195
|
+
children: [
|
|
196
|
+
/* @__PURE__ */ jsxs(
|
|
197
|
+
Field.Root,
|
|
198
|
+
{
|
|
199
|
+
name: "selectedContentTypes",
|
|
200
|
+
hint: formatMessage({
|
|
201
|
+
id: getTranslation("settings.page.enabledContentTypes.hint"),
|
|
202
|
+
defaultMessage: "Select the content types for which you want to enable URL aliases"
|
|
203
|
+
}),
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
|
206
|
+
id: getTranslation("settings.page.enabledContentTypes"),
|
|
207
|
+
defaultMessage: "Enabled Content Types"
|
|
208
|
+
}) }),
|
|
209
|
+
/* @__PURE__ */ jsx(
|
|
210
|
+
MultiSelect,
|
|
211
|
+
{
|
|
212
|
+
placeholder: formatMessage({
|
|
213
|
+
id: getTranslation("settings.page.enabledContentTypes.placeholder"),
|
|
214
|
+
defaultMessage: "Select content types..."
|
|
215
|
+
}),
|
|
216
|
+
onClear: () => dispatch({ type: "SET_SELECTED_CONTENT_TYPES", payload: [] }),
|
|
217
|
+
value: [...config?.selectedContentTypes.map((ct) => ct.uid) || []],
|
|
218
|
+
onChange: (value) => dispatch({
|
|
219
|
+
type: "SET_SELECTED_CONTENT_TYPES",
|
|
220
|
+
payload: value.map((v) => ({
|
|
221
|
+
uid: v,
|
|
222
|
+
default: "",
|
|
223
|
+
pattern: ""
|
|
224
|
+
}))
|
|
225
|
+
}),
|
|
226
|
+
withTags: true,
|
|
227
|
+
children: allContentTypes && allContentTypes.map(
|
|
228
|
+
(item) => /* @__PURE__ */ jsx(MultiSelectOption, { value: item.uid, children: item.info.displayName }, item.uid)
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
),
|
|
236
|
+
config?.selectedContentTypes && config.selectedContentTypes.length > 0 && /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsxs(Field.Root, { name: "selectedContentTypesAccordion", children: [
|
|
236
237
|
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
|
237
|
-
id: getTranslation("settings.page.
|
|
238
|
-
defaultMessage: "
|
|
238
|
+
id: getTranslation("settings.page.contentTypeSettings"),
|
|
239
|
+
defaultMessage: "Content Type settings"
|
|
239
240
|
}) }),
|
|
240
|
-
/* @__PURE__ */ jsx(
|
|
241
|
-
|
|
242
|
-
{
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
value: [...settingsState.selectedContentTypes.map((ct) => ct.uid)],
|
|
249
|
-
onChange: (value) => dispatch({
|
|
250
|
-
type: "SET_SELECTED_CONTENT_TYPES",
|
|
251
|
-
payload: value.map((v) => ({
|
|
252
|
-
uid: v,
|
|
253
|
-
default: "",
|
|
254
|
-
pattern: ""
|
|
255
|
-
}))
|
|
256
|
-
}),
|
|
257
|
-
withTags: true,
|
|
258
|
-
children: allContentTypes && allContentTypes.map(
|
|
259
|
-
(item) => /* @__PURE__ */ jsx(MultiSelectOption, { value: item.uid, children: item.info.displayName }, item.uid)
|
|
260
|
-
)
|
|
261
|
-
}
|
|
262
|
-
),
|
|
263
|
-
/* @__PURE__ */ jsx(Field.Hint, {})
|
|
264
|
-
]
|
|
265
|
-
}
|
|
266
|
-
),
|
|
267
|
-
settingsState.selectedContentTypes && settingsState.selectedContentTypes.length > 0 && /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsxs(Field.Root, { name: "selectedContentTypesAccordion", children: [
|
|
268
|
-
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
|
269
|
-
id: getTranslation("settings.page.contentTypeSettings"),
|
|
270
|
-
defaultMessage: "Content Type settings"
|
|
271
|
-
}) }),
|
|
272
|
-
/* @__PURE__ */ jsx(Accordion.Root, { children: settingsState.selectedContentTypes?.map((contentTypeSettings) => {
|
|
273
|
-
const ct = allContentTypes?.find((item) => item.uid === contentTypeSettings.uid);
|
|
274
|
-
return /* @__PURE__ */ jsx(ContentTypeAccordion, { contentType: ct, contentTypeSettings, dispatch }, contentTypeSettings.uid);
|
|
275
|
-
}) })
|
|
276
|
-
] }) })
|
|
277
|
-
] });
|
|
241
|
+
/* @__PURE__ */ jsx(Accordion.Root, { children: config.selectedContentTypes?.map((contentTypeSettings) => {
|
|
242
|
+
const ct = allContentTypes?.find((item) => item.uid === contentTypeSettings.uid);
|
|
243
|
+
return /* @__PURE__ */ jsx(ContentTypeAccordion, { contentType: ct, contentTypeSettings, dispatch }, contentTypeSettings.uid);
|
|
244
|
+
}) })
|
|
245
|
+
] }) })
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
);
|
|
278
249
|
};
|
|
279
250
|
export {
|
|
280
251
|
Settings as default
|
|
281
252
|
};
|
|
282
|
-
//# sourceMappingURL=index-DLZJ_sUK.mjs.map
|
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState, useEffect, useMemo } from "react";
|
|
3
3
|
import { Thead, Tr, Th, Typography, VisuallyHidden, Td, Flex, LinkButton, Grid, Box, Field, Table, Tbody, EmptyStateLayout } from "@strapi/design-system";
|
|
4
4
|
import { ChevronDown, Pencil, Cross } from "@strapi/icons";
|
|
5
|
-
import { g as getTranslation, u as useApi, d as debounce } from "./index-
|
|
5
|
+
import { g as getTranslation, u as useApi, d as debounce } from "./index-CTA8agp7.mjs";
|
|
6
6
|
import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
|
|
7
7
|
import "@strapi/icons/symbols";
|
|
8
8
|
import { F as FullLoader } from "./FullLoader-CrPED_dY.mjs";
|
|
@@ -7,7 +7,7 @@ const designSystem = require("@strapi/design-system");
|
|
|
7
7
|
const React = require("react");
|
|
8
8
|
const ReactDOM = require("react-dom");
|
|
9
9
|
const reactIntl = require("react-intl");
|
|
10
|
-
const index = require("./index-
|
|
10
|
+
const index = require("./index-CbW6k4FH.js");
|
|
11
11
|
const admin = require("@strapi/strapi/admin");
|
|
12
12
|
const FullLoader = require("./FullLoader-Cmsf8xS6.js");
|
|
13
13
|
const symbols = require("@strapi/icons/symbols");
|
|
@@ -233,23 +233,21 @@ function NavCreate() {
|
|
|
233
233
|
setLoading(true);
|
|
234
234
|
try {
|
|
235
235
|
const { data } = await post("/webatlas/navigation", { name, isActive });
|
|
236
|
-
if (data.documentId)
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
} else {
|
|
240
|
-
toggleNotification({
|
|
241
|
-
type: "danger",
|
|
242
|
-
message: formatMessage({
|
|
243
|
-
id: index.getTranslation("notification.navigation.creationFailed"),
|
|
244
|
-
defaultMessage: "Creation of navigation failed"
|
|
245
|
-
})
|
|
246
|
-
});
|
|
247
|
-
}
|
|
236
|
+
if (!data.documentId) throw new Error("No documentId returned");
|
|
237
|
+
navigate(`/plugins/webatlas/navigation/${data.documentId}`);
|
|
238
|
+
setModalType("");
|
|
248
239
|
} catch (err) {
|
|
249
240
|
console.log(err);
|
|
241
|
+
toggleNotification({
|
|
242
|
+
type: "danger",
|
|
243
|
+
message: formatMessage({
|
|
244
|
+
id: index.getTranslation("notification.navigation.creationFailed"),
|
|
245
|
+
defaultMessage: "Creation of navigation failed"
|
|
246
|
+
})
|
|
247
|
+
});
|
|
250
248
|
} finally {
|
|
249
|
+
setLoading(false);
|
|
251
250
|
}
|
|
252
|
-
setLoading(false);
|
|
253
251
|
};
|
|
254
252
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
255
253
|
NavModal,
|
|
@@ -284,14 +282,22 @@ function NavEdit({ item, onEdit }) {
|
|
|
284
282
|
const [loading, setLoading] = React.useState(false);
|
|
285
283
|
const { updateNavigation } = index.useApi();
|
|
286
284
|
const { formatMessage } = reactIntl.useIntl();
|
|
285
|
+
const { toggleNotification } = admin.useNotification();
|
|
287
286
|
const updateNav = async () => {
|
|
288
287
|
setLoading(true);
|
|
289
288
|
try {
|
|
290
289
|
await updateNavigation(item.documentId, { name, visible });
|
|
291
290
|
setModalType("NavOverview");
|
|
292
|
-
onEdit();
|
|
291
|
+
onEdit({ ...item, name, visible });
|
|
293
292
|
} catch (err) {
|
|
294
293
|
console.log(err);
|
|
294
|
+
toggleNotification({
|
|
295
|
+
type: "danger",
|
|
296
|
+
message: formatMessage({
|
|
297
|
+
id: index.getTranslation("notification.navigation.updateFailed"),
|
|
298
|
+
defaultMessage: "Updating navigation failed"
|
|
299
|
+
})
|
|
300
|
+
});
|
|
295
301
|
} finally {
|
|
296
302
|
setLoading(false);
|
|
297
303
|
}
|
|
@@ -305,17 +311,6 @@ function NavEdit({ item, onEdit }) {
|
|
|
305
311
|
loadingText: formatMessage({ id: index.getTranslation("modal.navEdit.loadingText"), defaultMessage: "Updating" }),
|
|
306
312
|
onConfirm: updateNav,
|
|
307
313
|
loading,
|
|
308
|
-
modalToOpen: "NavOverview",
|
|
309
|
-
footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
310
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: () => setModalType("NavOverview"), variant: "tertiary", children: formatMessage({
|
|
311
|
-
id: index.getTranslation("modal.navEdit.closeText"),
|
|
312
|
-
defaultMessage: "Cancel"
|
|
313
|
-
}) }),
|
|
314
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { children: formatMessage({
|
|
315
|
-
id: index.getTranslation("modal.navEdit.confirmText"),
|
|
316
|
-
defaultMessage: "Update"
|
|
317
|
-
}) })
|
|
318
|
-
] }),
|
|
319
314
|
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
|
|
320
315
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { s: 12, m: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
|
|
321
316
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
|
@@ -4651,31 +4646,30 @@ function ItemCreateComponent({
|
|
|
4651
4646
|
}, [path.needsUrlCheck, entityRoute?.documentId]);
|
|
4652
4647
|
React.useEffect(() => {
|
|
4653
4648
|
async function fetchRoute() {
|
|
4654
|
-
if (selectedContentType?.contentType
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
}
|
|
4649
|
+
if (!selectedContentType?.contentType || !selectedEntity?.documentId) return;
|
|
4650
|
+
setLoadingRoute(true);
|
|
4651
|
+
try {
|
|
4652
|
+
const route = await getRelatedRoute(selectedEntity.documentId);
|
|
4653
|
+
if (!route) throw new Error("No route found for the selected entity");
|
|
4654
|
+
dispatchPath({ type: "NO_URL_CHECK", payload: route.fullPath });
|
|
4655
|
+
dispatchPath({ type: "SET_UIDPATH", payload: route.uidPath });
|
|
4656
|
+
dispatchPath({ type: "SET_INITIALPATH", payload: route.fullPath });
|
|
4657
|
+
dispatchItemState({ type: "SET_TITLE", payload: route.title });
|
|
4658
|
+
dispatchItemState({ type: "SET_ACTIVE", payload: route.active });
|
|
4659
|
+
dispatchItemState({ type: "SET_INTERNAL", payload: route.internal });
|
|
4660
|
+
dispatchItemState({ type: "SET_OVERRIDE", payload: route.isOverride });
|
|
4661
|
+
initialState.current = {
|
|
4662
|
+
title: route.title,
|
|
4663
|
+
slug: route.fullPath,
|
|
4664
|
+
active: route.active,
|
|
4665
|
+
internal: route.internal,
|
|
4666
|
+
isOverride: route.isOverride
|
|
4667
|
+
};
|
|
4668
|
+
setEntityRoute(route);
|
|
4669
|
+
} catch (err) {
|
|
4670
|
+
console.log(err);
|
|
4671
|
+
} finally {
|
|
4672
|
+
setLoadingRoute(false);
|
|
4679
4673
|
}
|
|
4680
4674
|
}
|
|
4681
4675
|
fetchRoute();
|
|
@@ -10588,7 +10582,7 @@ const measuring = {
|
|
|
10588
10582
|
}
|
|
10589
10583
|
};
|
|
10590
10584
|
const indentationWidth = 48;
|
|
10591
|
-
function getProjection(items, activeId, overId, dragOffset) {
|
|
10585
|
+
function getProjection(items, activeId, overId, dragOffset, maxDepthValue) {
|
|
10592
10586
|
if (!items) return { depth: 0, maxDepth: 0, minDepth: 0 };
|
|
10593
10587
|
const overItemIndex = items.findIndex(({ id }) => id === overId);
|
|
10594
10588
|
const activeItemIndex = items.findIndex(({ id }) => id === activeId);
|
|
@@ -10597,7 +10591,7 @@ function getProjection(items, activeId, overId, dragOffset) {
|
|
|
10597
10591
|
const previousItem = newItems[overItemIndex - 1];
|
|
10598
10592
|
const dragDepth = getDragDepth(dragOffset, indentationWidth);
|
|
10599
10593
|
const projectedDepth = activeItem && typeof activeItem.depth === "number" ? activeItem.depth + dragDepth : 0;
|
|
10600
|
-
let maxDepth = getMaxDepth({ previousItem });
|
|
10594
|
+
let maxDepth = getMaxDepth({ previousItem, maxDepthValue });
|
|
10601
10595
|
let minDepth = 0;
|
|
10602
10596
|
let depth = projectedDepth;
|
|
10603
10597
|
if (projectedDepth >= maxDepth) {
|
|
@@ -10607,9 +10601,9 @@ function getProjection(items, activeId, overId, dragOffset) {
|
|
|
10607
10601
|
}
|
|
10608
10602
|
return { depth, maxDepth, minDepth };
|
|
10609
10603
|
}
|
|
10610
|
-
function getMaxDepth({ previousItem }) {
|
|
10604
|
+
function getMaxDepth({ previousItem, maxDepthValue }) {
|
|
10611
10605
|
if (previousItem && typeof previousItem.depth === "number") {
|
|
10612
|
-
return previousItem.depth + 1;
|
|
10606
|
+
return Math.min(previousItem.depth + 1, maxDepthValue - 1);
|
|
10613
10607
|
}
|
|
10614
10608
|
return 0;
|
|
10615
10609
|
}
|
|
@@ -11840,6 +11834,7 @@ const Navigation = () => {
|
|
|
11840
11834
|
const [isSavingNavigation, setIsSavingNavigation] = React.useState(false);
|
|
11841
11835
|
const [loading, setLoading] = React.useState(true);
|
|
11842
11836
|
const cachedNavigations = React.useRef(null);
|
|
11837
|
+
const { config } = index.usePluginConfig();
|
|
11843
11838
|
const [projected, setProjected] = React.useState(null);
|
|
11844
11839
|
const [activeItem, setActiveItem] = React.useState();
|
|
11845
11840
|
const [activeId, setActiveId] = React.useState(null);
|
|
@@ -12029,7 +12024,8 @@ const Navigation = () => {
|
|
|
12029
12024
|
navigationItems,
|
|
12030
12025
|
activeId,
|
|
12031
12026
|
overId,
|
|
12032
|
-
offsetLeft
|
|
12027
|
+
offsetLeft,
|
|
12028
|
+
config?.navigation.maxDepth || 3
|
|
12033
12029
|
) : null;
|
|
12034
12030
|
setProjected(projection);
|
|
12035
12031
|
}, [activeId, overId, offsetLeft, navigationItems]);
|
|
@@ -12126,7 +12122,7 @@ const Navigation = () => {
|
|
|
12126
12122
|
{
|
|
12127
12123
|
variant: "NavDelete",
|
|
12128
12124
|
item: actionItem,
|
|
12129
|
-
onDelete:
|
|
12125
|
+
onDelete: (deletedItem) => {
|
|
12130
12126
|
cachedNavigations.current = null;
|
|
12131
12127
|
setNavigations((navs) => navs.filter((nav) => nav.id !== deletedItem.id));
|
|
12132
12128
|
navigate("/plugins/webatlas/navigation");
|
|
@@ -12137,7 +12133,10 @@ const Navigation = () => {
|
|
|
12137
12133
|
NavEdit,
|
|
12138
12134
|
{
|
|
12139
12135
|
item: actionItem,
|
|
12140
|
-
onEdit: () => {
|
|
12136
|
+
onEdit: (editedNavigation) => {
|
|
12137
|
+
setNavigations(
|
|
12138
|
+
(navs) => navs?.map((nav) => nav.id === editedNavigation.id ? editedNavigation : nav)
|
|
12139
|
+
);
|
|
12141
12140
|
}
|
|
12142
12141
|
}
|
|
12143
12142
|
),
|
|
@@ -12167,7 +12166,6 @@ const Navigation = () => {
|
|
|
12167
12166
|
{
|
|
12168
12167
|
item: actionItem,
|
|
12169
12168
|
onEdit: (editedItem) => {
|
|
12170
|
-
console.log(editedItem);
|
|
12171
12169
|
setNavigationItems(
|
|
12172
12170
|
(items) => items?.map((item) => item.id === editedItem.id ? editedItem : item)
|
|
12173
12171
|
);
|
|
@@ -12227,4 +12225,4 @@ const App = () => {
|
|
|
12227
12225
|
] });
|
|
12228
12226
|
};
|
|
12229
12227
|
exports.default = App;
|
|
12230
|
-
//# sourceMappingURL=index-
|
|
12228
|
+
//# sourceMappingURL=index-YzPuPn68.js.map
|