@mattisvensson/strapi-plugin-webatlas 0.11.7 → 0.11.9

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.
@@ -0,0 +1,139 @@
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-CFf370lR.js");
8
+ const reactIntl = require("react-intl");
9
+ require("@strapi/icons/symbols");
10
+ const FullLoader = require("./FullLoader-Da2n70bJ.js");
11
+ const SettingTitle = require("./SettingTitle-CwB5CsY0.js");
12
+ function reducer(newConfig, action) {
13
+ switch (action.type) {
14
+ case "SET_MAX_DEPTH":
15
+ if (!newConfig) return null;
16
+ return {
17
+ ...newConfig,
18
+ navigation: { ...newConfig.navigation, maxDepth: action.payload },
19
+ selectedContentTypes: newConfig.selectedContentTypes || []
20
+ };
21
+ case "SET_CONFIG":
22
+ return action.payload;
23
+ default:
24
+ throw new Error();
25
+ }
26
+ }
27
+ const Settings = () => {
28
+ const { config: fetchedConfig, setConfig, loading, fetchError } = index.usePluginConfig();
29
+ const [config, dispatch] = React.useReducer(reducer, fetchedConfig);
30
+ const { toggleNotification } = admin.useNotification();
31
+ const { formatMessage } = reactIntl.useIntl();
32
+ const [isSaving, setIsSaving] = React.useState(false);
33
+ const initialConfig = React.useRef(fetchedConfig);
34
+ React.useEffect(() => {
35
+ initialConfig.current = fetchedConfig;
36
+ if (fetchedConfig) dispatch({ type: "SET_CONFIG", payload: fetchedConfig });
37
+ }, [fetchedConfig]);
38
+ React.useEffect(() => {
39
+ if (fetchError) {
40
+ toggleNotification({
41
+ type: "danger",
42
+ message: formatMessage({
43
+ id: index.getTranslation("notification.error"),
44
+ defaultMessage: "An error occurred"
45
+ }) + ": " + fetchError
46
+ });
47
+ }
48
+ }, [fetchError, toggleNotification, formatMessage]);
49
+ async function save() {
50
+ if (!config) return;
51
+ setIsSaving(true);
52
+ try {
53
+ await setConfig({ navigation: config.navigation });
54
+ initialConfig.current = config;
55
+ toggleNotification({
56
+ type: "success",
57
+ message: formatMessage({
58
+ id: index.getTranslation("notification.settings.saved"),
59
+ defaultMessage: "Settings saved successfully"
60
+ })
61
+ });
62
+ setIsSaving(false);
63
+ } catch (err) {
64
+ setIsSaving(false);
65
+ toggleNotification({
66
+ type: "danger",
67
+ message: formatMessage({
68
+ id: index.getTranslation("notification.error"),
69
+ defaultMessage: "An error occurred"
70
+ }) + ": " + err
71
+ });
72
+ strapi.log.error(err);
73
+ }
74
+ }
75
+ if (loading) {
76
+ return /* @__PURE__ */ jsxRuntime.jsx(
77
+ SettingTitle.PageWrapper,
78
+ {
79
+ isSaving,
80
+ subtitle: formatMessage({
81
+ id: index.getTranslation("loading"),
82
+ defaultMessage: "Loading..."
83
+ }),
84
+ disabledCondition: true,
85
+ children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, { height: 200 })
86
+ }
87
+ );
88
+ }
89
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.pluginPermissions["settings.navigation"], children: /* @__PURE__ */ jsxRuntime.jsx(
90
+ SettingTitle.PageWrapper,
91
+ {
92
+ save,
93
+ isSaving,
94
+ subtitle: formatMessage({
95
+ id: index.getTranslation("settings.page.navigation.subtitle"),
96
+ defaultMessage: "Configure navigation settings"
97
+ }),
98
+ disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current),
99
+ children: /* @__PURE__ */ jsxRuntime.jsx(
100
+ SettingTitle.ContentBox,
101
+ {
102
+ title: formatMessage({
103
+ id: index.getTranslation("settings.page.navigation.navigation"),
104
+ defaultMessage: "Navigation"
105
+ }),
106
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "maxNavDepth", children: [
107
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingTitle.SettingTitle, { children: formatMessage({
108
+ id: index.getTranslation("settings.page.navigation.maxNavDepth.label"),
109
+ defaultMessage: "Max depth of navigation tree"
110
+ }) }) }),
111
+ /* @__PURE__ */ jsxRuntime.jsx(
112
+ designSystem.Field.Input,
113
+ {
114
+ id: "maxNavDepth",
115
+ type: "number",
116
+ min: 0,
117
+ step: 1,
118
+ value: config?.navigation?.maxDepth !== void 0 ? config.navigation.maxDepth + 1 : "",
119
+ onChange: (e) => dispatch({
120
+ type: "SET_MAX_DEPTH",
121
+ payload: Number(e.target.value) - 1
122
+ }),
123
+ onBlur: (e) => {
124
+ if (e.target.value === "") return;
125
+ dispatch({
126
+ type: "SET_MAX_DEPTH",
127
+ payload: Number(e.target.value) - 1
128
+ });
129
+ }
130
+ }
131
+ ),
132
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
133
+ ] })
134
+ }
135
+ )
136
+ }
137
+ ) });
138
+ };
139
+ exports.default = Settings;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const index = require("./index-CFf370lR.js");
4
+ exports.default = index.index;
@@ -0,0 +1,4 @@
1
+ import { i } from "./index-G7qx6Oy7.mjs";
2
+ export {
3
+ i as default
4
+ };
@@ -0,0 +1,12 @@
1
+ import { StrapiApp } from '@strapi/admin/strapi-admin';
2
+ declare const _default: {
3
+ register(app: StrapiApp): void;
4
+ bootstrap(app: StrapiApp): void;
5
+ registerTrads({ locales }: {
6
+ locales: string[];
7
+ }): Promise<{
8
+ data: any;
9
+ locale: string;
10
+ }[]>;
11
+ };
12
+ export default _default;