strapi-plugin-navigation 2.1.0 → 2.2.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.
- package/README.md +17 -7
- package/admin/src/components/AdditionalFieldInput/index.d.ts +5 -0
- package/admin/src/components/AdditionalFieldInput/index.js +71 -0
- package/admin/src/components/AdditionalFieldInput/types.d.ts +14 -0
- package/admin/src/components/AdditionalFieldInput/types.js +3 -0
- package/admin/src/components/Item/index.js +2 -3
- package/admin/src/components/RestartAlert/index.d.ts +1 -1
- package/admin/src/components/TextArrayInput/index.d.ts +14 -0
- package/admin/src/components/TextArrayInput/index.js +45 -0
- package/admin/src/hooks/useAllContentTypes.d.ts +1 -4
- package/admin/src/hooks/useAllContentTypes.js +3 -7
- package/admin/src/hooks/useNavigationConfig.d.ts +1 -1
- package/admin/src/hooks/useNavigationConfig.js +6 -6
- package/admin/src/pages/DataManagerProvider/index.d.ts +1 -1
- package/admin/src/pages/DataManagerProvider/index.js +9 -11
- package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.d.ts +12 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.js +112 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.d.ts +12 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.js +20 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.d.ts +11 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.js +105 -0
- package/admin/src/pages/SettingsPage/index.d.ts +2 -1
- package/admin/src/pages/SettingsPage/index.js +109 -74
- package/admin/src/pages/SettingsPage/types.d.ts +32 -0
- package/admin/src/pages/SettingsPage/types.js +3 -0
- package/admin/src/pages/SettingsPage/utils/form.d.ts +18 -0
- package/admin/src/pages/SettingsPage/utils/form.js +34 -0
- package/admin/src/pages/SettingsPage/utils/functions.d.ts +2 -2
- package/admin/src/pages/SettingsPage/utils/functions.js +1 -1
- package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +3 -55
- package/admin/src/pages/View/components/NavigationItemForm/index.js +162 -177
- package/admin/src/pages/View/components/NavigationItemForm/types.d.ts +90 -0
- package/admin/src/pages/View/components/NavigationItemForm/types.js +3 -0
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +24 -43
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +78 -45
- package/admin/src/pages/View/components/NavigationItemPopup/index.js +1 -2
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.d.ts +4 -0
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.js +11 -0
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/{List → AllNavigations}/index.js +32 -31
- package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/{Delete → DeletionConfirm}/index.js +18 -12
- package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/{Error → ErrorDetails}/index.js +10 -10
- package/admin/src/pages/View/components/NavigationManager/Footer/index.d.ts +24 -0
- package/admin/src/pages/View/components/NavigationManager/Footer/index.js +13 -0
- package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts +3 -2
- package/admin/src/pages/View/components/NavigationManager/Form/index.js +7 -2
- package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/{Edit → NavigationUpdate}/index.js +16 -11
- package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.d.ts +10 -0
- package/admin/src/pages/View/components/NavigationManager/{Create → NewNavigation}/index.js +16 -11
- package/admin/src/pages/View/components/NavigationManager/index.d.ts +3 -2
- package/admin/src/pages/View/components/NavigationManager/index.js +22 -21
- package/admin/src/pages/View/components/NavigationManager/types.d.ts +2 -15
- package/admin/src/pages/View/index.d.ts +1 -1
- package/admin/src/pages/View/index.js +1 -1
- package/admin/src/pages/View/utils/parsers.d.ts +1 -0
- package/admin/src/pages/View/utils/parsers.js +8 -7
- package/admin/src/translations/en.json +37 -0
- package/admin/src/translations/index.d.ts +2 -1
- package/admin/src/translations/index.js +1 -1
- package/admin/src/utils/api.d.ts +8 -7
- package/admin/src/utils/api.js +6 -41
- package/admin/src/utils/enums.d.ts +25 -0
- package/admin/src/utils/enums.js +30 -0
- package/admin/src/utils/functions.d.ts +16 -0
- package/admin/src/utils/functions.js +46 -0
- package/admin/src/utils/index.d.ts +3 -17
- package/admin/src/utils/index.js +16 -39
- package/package.json +5 -5
- package/server/config/index.js +6 -4
- package/server/config/setupStrategy.js +13 -1
- package/server/content-types/index.d.ts +5 -25
- package/server/content-types/navigation/index.d.ts +0 -7
- package/server/content-types/navigation/index.js +0 -2
- package/server/content-types/navigation-item/index.d.ts +5 -13
- package/server/content-types/navigation-item/index.js +0 -2
- package/server/content-types/navigation-item/schema.d.ts +5 -0
- package/server/content-types/navigation-item/schema.js +5 -0
- package/server/content-types/navigations-items-related/index.d.ts +0 -5
- package/server/content-types/navigations-items-related/index.js +0 -2
- package/server/controllers/admin.js +1 -1
- package/server/controllers/client.js +2 -1
- package/server/graphql/types/navigation-item.d.ts +2 -1
- package/server/graphql/types/navigation-item.js +26 -2
- package/server/index.d.ts +5 -25
- package/server/services/admin.js +26 -14
- package/server/services/client.js +64 -21
- package/server/services/common.js +25 -6
- package/server/utils/constant.d.ts +0 -3
- package/server/utils/constant.js +1 -2
- package/server/utils/functions.d.ts +12 -12
- package/server/utils/functions.js +60 -22
- package/strapi-server.d.ts +5 -25
- package/tsconfig.tsbuildinfo +1 -1
- package/types/config.d.ts +6 -2
- package/types/contentTypes.d.ts +22 -1
- package/types/services.d.ts +14 -5
- package/types/utils.d.ts +6 -1
- package/types/utils.js +15 -1
- package/admin/src/pages/View/components/NavigationManager/Create/index.d.ts +0 -9
- package/admin/src/pages/View/components/NavigationManager/Delete/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/Edit/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/Error/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/List/index.d.ts +0 -8
- package/admin/src/pages/View/utils/enums.d.ts +0 -9
- package/admin/src/pages/View/utils/enums.js +0 -12
- package/admin/src/utils/getTrad.d.ts +0 -3
- package/admin/src/utils/getTrad.js +0 -9
- package/server/content-types/navigation/lifecycle.d.ts +0 -9
- package/server/content-types/navigation/lifecycle.js +0 -10
- package/server/content-types/navigation-item/lifecycle.d.ts +0 -16
- package/server/content-types/navigation-item/lifecycle.js +0 -31
- package/server/content-types/navigations-items-related/lifecycle.d.ts +0 -8
- package/server/content-types/navigations-items-related/lifecycle.js +0 -22
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Footer } from "../Footer";
|
|
3
|
+
import { CommonProps, CreateState, Navigation } from "../types";
|
|
4
|
+
interface Props extends CreateState, CommonProps {
|
|
5
|
+
}
|
|
6
|
+
export declare const INITIAL_NAVIGATION: Navigation;
|
|
7
|
+
export declare const NewNavigation: ({ setState, current, isLoading, alreadyUsedNames, }: Props) => JSX.Element;
|
|
8
|
+
export declare const NewNavigationFooter: Footer;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -23,18 +23,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
const Button_1 = require("@strapi/design-system/Button");
|
|
26
|
+
exports.NewNavigationFooter = exports.NewNavigation = exports.INITIAL_NAVIGATION = void 0;
|
|
28
27
|
const react_1 = __importStar(require("react"));
|
|
29
28
|
const react_intl_1 = require("react-intl");
|
|
30
29
|
const utils_1 = require("../../../../../utils");
|
|
30
|
+
const Footer_1 = require("../Footer");
|
|
31
31
|
const Form_1 = require("../Form");
|
|
32
32
|
exports.INITIAL_NAVIGATION = {
|
|
33
33
|
name: "Navigation",
|
|
34
34
|
items: [],
|
|
35
35
|
visible: true,
|
|
36
36
|
};
|
|
37
|
-
const
|
|
37
|
+
const NewNavigation = ({ setState, current, isLoading, alreadyUsedNames, }) => {
|
|
38
38
|
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
39
39
|
const onSubmit = (0, react_1.useCallback)((updated) => {
|
|
40
40
|
setState({
|
|
@@ -46,12 +46,17 @@ const Create = ({ setState, current, isLoading, alreadyUsedNames, }) => {
|
|
|
46
46
|
const validationSchema = (0, react_1.useMemo)(() => (0, Form_1.validationSchemaFactory)(alreadyUsedNames, formatMessage), [alreadyUsedNames]);
|
|
47
47
|
return (react_1.default.createElement(Form_1.Form, { navigation: current, onChange: onSubmit, isLoading: isLoading, validationSchema: validationSchema }));
|
|
48
48
|
};
|
|
49
|
-
exports.
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
49
|
+
exports.NewNavigation = NewNavigation;
|
|
50
|
+
const NewNavigationFooter = ({ state, onSubmit, onReset, }) => (react_1.default.createElement(Footer_1.FooterBase, { start: {
|
|
51
|
+
children: (0, utils_1.getMessage)("popup.item.form.button.cancel"),
|
|
52
|
+
variant: "tertiary",
|
|
53
|
+
disabled: state.isLoading,
|
|
54
|
+
onClick: onReset,
|
|
55
|
+
}, end: {
|
|
56
|
+
children: (0, utils_1.getMessage)("popup.navigation.manage.button.save"),
|
|
57
|
+
variant: "default",
|
|
58
|
+
disabled: state.isLoading,
|
|
59
|
+
onClick: onSubmit,
|
|
60
|
+
} }));
|
|
61
|
+
exports.NewNavigationFooter = NewNavigationFooter;
|
|
57
62
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { VoidEffect } from "../../../../../../types";
|
|
2
3
|
import { State } from "./types";
|
|
3
4
|
interface Props {
|
|
4
5
|
initialState: State;
|
|
5
|
-
onClose?: () => void;
|
|
6
6
|
isOpened?: boolean;
|
|
7
|
+
onClose?: VoidEffect;
|
|
7
8
|
}
|
|
8
|
-
export declare const NavigationManager: ({ initialState,
|
|
9
|
+
export declare const NavigationManager: ({ initialState, isOpened, onClose, }: Props) => JSX.Element;
|
|
9
10
|
export {};
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -27,20 +27,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.NavigationManager = void 0;
|
|
30
|
-
const lodash_1 = require("lodash");
|
|
31
30
|
const Flex_1 = require("@strapi/design-system/Flex");
|
|
32
31
|
const Loader_1 = require("@strapi/design-system/Loader");
|
|
33
32
|
const ModalLayout_1 = require("@strapi/design-system/ModalLayout");
|
|
33
|
+
const lodash_1 = require("lodash");
|
|
34
|
+
const fp_1 = require("lodash/fp");
|
|
34
35
|
const react_1 = __importStar(require("react"));
|
|
35
36
|
const react_intl_1 = require("react-intl");
|
|
36
37
|
const useDataManager_1 = __importDefault(require("../../../../hooks/useDataManager"));
|
|
37
38
|
const utils_1 = require("../../../../utils");
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const NavigationManager = ({ initialState,
|
|
39
|
+
const AllNavigations_1 = require("./AllNavigations");
|
|
40
|
+
const DeletionConfirm_1 = require("./DeletionConfirm");
|
|
41
|
+
const ErrorDetails_1 = require("./ErrorDetails");
|
|
42
|
+
const NavigationUpdate_1 = require("./NavigationUpdate");
|
|
43
|
+
const NewNavigation_1 = require("./NewNavigation");
|
|
44
|
+
const NavigationManager = ({ initialState, isOpened, onClose, }) => {
|
|
44
45
|
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
45
46
|
const [state, setState] = (0, react_1.useState)(initialState);
|
|
46
47
|
const { items = [], handleNavigationsDeletion, handleSubmitNavigation, hardReset, } = (0, useDataManager_1.default)();
|
|
@@ -49,7 +50,7 @@ const NavigationManager = ({ initialState, onClose, isOpened, }) => {
|
|
|
49
50
|
const onSubmit = (0, react_1.useCallback)(async () => {
|
|
50
51
|
const performAction = state.view === "DELETE"
|
|
51
52
|
? async () => {
|
|
52
|
-
await handleNavigationsDeletion(state.navigations.map((
|
|
53
|
+
await handleNavigationsDeletion(state.navigations.map((0, fp_1.prop)("id")));
|
|
53
54
|
await hardReset();
|
|
54
55
|
}
|
|
55
56
|
: (state.view === "CREATE" || state.view === "EDIT") && state.current
|
|
@@ -90,7 +91,7 @@ const NavigationManager = ({ initialState, onClose, isOpened, }) => {
|
|
|
90
91
|
}, [state.view]);
|
|
91
92
|
const header = renderHeader(state);
|
|
92
93
|
const content = renderContent(state, setState);
|
|
93
|
-
const
|
|
94
|
+
const footer = renderFooter({
|
|
94
95
|
state,
|
|
95
96
|
setState,
|
|
96
97
|
onClose,
|
|
@@ -101,7 +102,7 @@ const NavigationManager = ({ initialState, onClose, isOpened, }) => {
|
|
|
101
102
|
return (react_1.default.createElement(ModalLayout_1.ModalLayout, { labelledBy: "condition-modal-breadcrumbs", onClose: onClose, isOpen: isOpened },
|
|
102
103
|
react_1.default.createElement(ModalLayout_1.ModalHeader, null, header),
|
|
103
104
|
react_1.default.createElement(ModalLayout_1.ModalBody, null, content),
|
|
104
|
-
|
|
105
|
+
footer));
|
|
105
106
|
};
|
|
106
107
|
exports.NavigationManager = NavigationManager;
|
|
107
108
|
const renderHeader = (state) => {
|
|
@@ -137,43 +138,43 @@ const renderContent = (state, setState) => {
|
|
|
137
138
|
};
|
|
138
139
|
switch (state.view) {
|
|
139
140
|
case "LIST": {
|
|
140
|
-
return react_1.default.createElement(
|
|
141
|
+
return react_1.default.createElement(AllNavigations_1.AllNavigations, { ...state, ...commonProps });
|
|
141
142
|
}
|
|
142
143
|
case "EDIT": {
|
|
143
|
-
return react_1.default.createElement(
|
|
144
|
+
return react_1.default.createElement(NavigationUpdate_1.NavigationUpdate, { ...state, ...commonProps });
|
|
144
145
|
}
|
|
145
146
|
case "CREATE": {
|
|
146
|
-
return react_1.default.createElement(
|
|
147
|
+
return react_1.default.createElement(NewNavigation_1.NewNavigation, { ...state, ...commonProps });
|
|
147
148
|
}
|
|
148
149
|
case "DELETE": {
|
|
149
|
-
return react_1.default.createElement(
|
|
150
|
+
return react_1.default.createElement(DeletionConfirm_1.DeletionConfirm, { ...state, ...commonProps });
|
|
150
151
|
}
|
|
151
152
|
case "INITIAL": {
|
|
152
153
|
return react_1.default.createElement(Loader_1.Loader, { small: true });
|
|
153
154
|
}
|
|
154
155
|
case "ERROR": {
|
|
155
|
-
return react_1.default.createElement(
|
|
156
|
+
return react_1.default.createElement(ErrorDetails_1.ErrorDetails, { ...state, ...commonProps });
|
|
156
157
|
}
|
|
157
158
|
default:
|
|
158
159
|
return handleUnknownState(state);
|
|
159
160
|
}
|
|
160
161
|
};
|
|
161
|
-
const
|
|
162
|
+
const renderFooter = (props) => {
|
|
162
163
|
switch (props.state.view) {
|
|
163
164
|
case "LIST": {
|
|
164
|
-
return (
|
|
165
|
+
return react_1.default.createElement(AllNavigations_1.AllNavigationsFooter, { ...props });
|
|
165
166
|
}
|
|
166
167
|
case "CREATE": {
|
|
167
|
-
return (
|
|
168
|
+
return react_1.default.createElement(NewNavigation_1.NewNavigationFooter, { ...props });
|
|
168
169
|
}
|
|
169
170
|
case "EDIT": {
|
|
170
|
-
return (
|
|
171
|
+
return react_1.default.createElement(NavigationUpdate_1.NavigationUpdateFooter, { ...props });
|
|
171
172
|
}
|
|
172
173
|
case "DELETE": {
|
|
173
|
-
return (
|
|
174
|
+
return react_1.default.createElement(DeletionConfirm_1.DeleteConfirmFooter, { ...props });
|
|
174
175
|
}
|
|
175
176
|
case "ERROR": {
|
|
176
|
-
return (
|
|
177
|
+
return react_1.default.createElement(ErrorDetails_1.ErrorDetailsFooter, { ...props });
|
|
177
178
|
}
|
|
178
179
|
case "INITIAL": {
|
|
179
180
|
return null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Dispatch, SetStateAction } from "react";
|
|
2
2
|
import { Navigation as FullNavigationEntity } from "../../../../../../types";
|
|
3
3
|
export declare type Navigation = Pick<FullNavigationEntity, "id" | "items" | "name" | "localeCode" | "localizations" | "visible">;
|
|
4
4
|
export declare type State = InitialState | ListState | EditState | CreateState | DeleteState | ErrorState;
|
|
5
|
-
export declare type SetState =
|
|
5
|
+
export declare type SetState = Dispatch<SetStateAction<State>>;
|
|
6
6
|
interface CommonState {
|
|
7
7
|
isLoading?: boolean;
|
|
8
8
|
}
|
|
@@ -36,18 +36,5 @@ export interface ErrorState extends CommonState {
|
|
|
36
36
|
view: "ERROR";
|
|
37
37
|
errors: Array<Error>;
|
|
38
38
|
}
|
|
39
|
-
export interface FooterActionsFactory {
|
|
40
|
-
(props: {
|
|
41
|
-
onSubmit: () => void;
|
|
42
|
-
onClose: (() => void) | undefined;
|
|
43
|
-
setState: SetState;
|
|
44
|
-
state: State;
|
|
45
|
-
onReset: () => void;
|
|
46
|
-
navigations: Array<Navigation>;
|
|
47
|
-
}): {
|
|
48
|
-
startActions?: React.ReactElement;
|
|
49
|
-
endActions?: React.ReactElement;
|
|
50
|
-
} | null;
|
|
51
|
-
}
|
|
52
39
|
export {};
|
|
53
40
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -197,7 +197,7 @@ const View = () => {
|
|
|
197
197
|
startIcon: react_1.default.createElement(Plus_1.default, null),
|
|
198
198
|
disabled: isLoadingForSubmit,
|
|
199
199
|
type: "submit",
|
|
200
|
-
variant: "
|
|
200
|
+
variant: "default",
|
|
201
201
|
tradId: 'header.action.newItem',
|
|
202
202
|
margin: '16px',
|
|
203
203
|
},
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.validateNavigationStructure = exports.isRelationPublished = exports.isRelationCorrect = exports.usedContentTypes = exports.extractRelatedItemLabel = exports.prepareItemToViewPayload = exports.transformItemToViewPayload = exports.transformToRESTPayload = exports.transformItemToRESTPayload = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
|
-
const
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
7
|
const transformItemToRESTPayload = (item, parent = undefined, master = undefined, config = {}, parentAttachedToMenu = true) => {
|
|
8
|
-
const { id, title, type =
|
|
9
|
-
const isExternal = type ===
|
|
10
|
-
const isWrapper = type ===
|
|
8
|
+
const { id, title, type = utils_1.navigationItemType.INTERNAL, updated = false, removed = false, uiRouterKey, menuAttached, path, externalPath, related, relatedType, order, audience = [], items = [], collapsed, isSingle, additionalFields = {}, } = item;
|
|
9
|
+
const isExternal = type === utils_1.navigationItemType.EXTERNAL;
|
|
10
|
+
const isWrapper = type === utils_1.navigationItemType.WRAPPER;
|
|
11
11
|
const { contentTypes = [] } = config;
|
|
12
12
|
const parsedRelated = Number(related);
|
|
13
13
|
const relatedId = isExternal || isWrapper || isNaN(parsedRelated) ? related?.value || related : parsedRelated;
|
|
@@ -26,6 +26,7 @@ const transformItemToRESTPayload = (item, parent = undefined, master = undefined
|
|
|
26
26
|
order,
|
|
27
27
|
uiRouterKey,
|
|
28
28
|
collapsed,
|
|
29
|
+
additionalFields,
|
|
29
30
|
menuAttached: itemAttachedToMenu,
|
|
30
31
|
audience: audience.map((audienceItem) => (0, lodash_1.isObject)(audienceItem) ? audienceItem.value : audienceItem),
|
|
31
32
|
path: isExternal ? undefined : path,
|
|
@@ -75,7 +76,7 @@ const linkRelations = (item, config) => {
|
|
|
75
76
|
},
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
|
-
if ((type !==
|
|
79
|
+
if ((type !== utils_1.navigationItemType.INTERNAL) || !related || ((0, lodash_1.isObject)(related) && (0, lodash_1.isEmpty)(related))) {
|
|
79
80
|
return {
|
|
80
81
|
...item,
|
|
81
82
|
...relation,
|
|
@@ -244,14 +245,14 @@ const usedContentTypes = (items = []) => items.flatMap((item) => {
|
|
|
244
245
|
exports.usedContentTypes = usedContentTypes;
|
|
245
246
|
const isRelationCorrect = ({ related, type }) => {
|
|
246
247
|
const isRelationDefined = !(0, lodash_1.isNil)(related);
|
|
247
|
-
return type !==
|
|
248
|
+
return type !== utils_1.navigationItemType.INTERNAL || (type === utils_1.navigationItemType.INTERNAL && isRelationDefined);
|
|
248
249
|
};
|
|
249
250
|
exports.isRelationCorrect = isRelationCorrect;
|
|
250
251
|
const isRelationPublished = ({ relatedRef, relatedType = {}, type, isCollection }) => {
|
|
251
252
|
if (isCollection) {
|
|
252
253
|
return relatedType.available || relatedRef.available;
|
|
253
254
|
}
|
|
254
|
-
if ((type ===
|
|
255
|
+
if ((type === utils_1.navigationItemType.INTERNAL)) {
|
|
255
256
|
const isHandledByPublshFlow = relatedRef ? 'published_at' in relatedRef : false;
|
|
256
257
|
if (isHandledByPublshFlow) {
|
|
257
258
|
return (0, lodash_1.get)(relatedRef, 'published_at', true);
|
|
@@ -73,16 +73,20 @@
|
|
|
73
73
|
"popup.navigation.manage.header.ERROR": "Error",
|
|
74
74
|
"popup.navigation.manage.header.EDIT": "Editing \"{name}\"",
|
|
75
75
|
"popup.navigation.manage.error.message": "An error happened :(",
|
|
76
|
+
"popup.navigation.manage.navigation.visible": "visible",
|
|
77
|
+
"popup.navigation.manage.navigation.hidden": "hidden",
|
|
76
78
|
"notification.navigation.submit": "Navigation changes has been saved",
|
|
77
79
|
"notification.navigation.error": "Duplicate path: { path } in parent: { parentTitle } for { errorTitles } items",
|
|
78
80
|
"notification.navigation.item.relation": "Entity relation does not exist!",
|
|
79
81
|
"notification.navigation.item.relation.status.draft": "draft",
|
|
80
82
|
"notification.navigation.item.relation.status.published": "published",
|
|
81
83
|
"notification.error": "Error while processing request.",
|
|
84
|
+
"notification.error.customField.type": "Unsupported type of custom field",
|
|
82
85
|
"pages.main.search.placeholder": "Type to start searching...",
|
|
83
86
|
"pages.main.header.localization.select.placeholder": "Select locale",
|
|
84
87
|
"pages.settings.general.title": "General settings",
|
|
85
88
|
"pages.settings.additional.title": "Additional settings",
|
|
89
|
+
"pages.settings.customFields.title": "Custom fields settings",
|
|
86
90
|
"pages.settings.nameField.title": "Content types settings",
|
|
87
91
|
"pages.settings.restoring.title": "Restoring",
|
|
88
92
|
"pages.settings.section.title": "Navigation Plugin",
|
|
@@ -137,6 +141,10 @@
|
|
|
137
141
|
"pages.settings.form.populate.placeholder": "Select at least one or leave empty to disable populating relation fields",
|
|
138
142
|
"pages.settings.form.populate.hint": "Selected relation fields will be populated inside API responses",
|
|
139
143
|
"pages.settings.form.populate.empty": "This content type doesn't have any relation fields",
|
|
144
|
+
"pages.settings.form.pathDefaultFields.label": "Path default fields",
|
|
145
|
+
"pages.settings.form.pathDefaultFields.placeholder": "Select at least one or leave it empty to disable populating path field with attributes value",
|
|
146
|
+
"pages.settings.form.pathDefaultFields.hint": "Value of selected attribute will be a default value for internal path",
|
|
147
|
+
"pages.settings.form.pathDefaultFields.empty": "This content type doesn't have any suitable attributes",
|
|
140
148
|
"pages.settings.form.contentTypesSettings.label": "Content types",
|
|
141
149
|
"pages.settings.form.contentTypesSettings.tooltip": "Custom configuration per content type",
|
|
142
150
|
"pages.settings.form.contentTypesSettings.initializationWarning.title": "Warning",
|
|
@@ -144,6 +152,35 @@
|
|
|
144
152
|
"pages.view.actions.i18nCopyItems.confirmation.header": "Confirmation",
|
|
145
153
|
"pages.view.actions.i18nCopyItems.confirmation.confirm": "Copy",
|
|
146
154
|
"pages.view.actions.i18nCopyItems.confirmation.content": "Do you want to copy navigations items?",
|
|
155
|
+
"pages.settings.form.customFields.table.confirmation.header": "Removing custom field",
|
|
156
|
+
"pages.settings.form.customFields.table.confirmation.message": "This action will cause removing all custom fields values from navigation items.",
|
|
157
|
+
"pages.settings.form.customFields.table.confirmation.confirm": "Continue",
|
|
158
|
+
"pages.settings.form.customFields.table.confirmation.error": "An error ocurred while removing custom field",
|
|
159
|
+
"pages.settings.form.customFields.table.header.name": "Name",
|
|
160
|
+
"pages.settings.form.customFields.table.header.label": "Label",
|
|
161
|
+
"pages.settings.form.customFields.table.header.type": "Type",
|
|
162
|
+
"pages.settings.form.customFields.table.header.required": "Required",
|
|
163
|
+
"pages.settings.form.customFields.table.footer": "Create new custom field",
|
|
164
|
+
"pages.settings.form.customFields.table.edit": "Edit custom field",
|
|
165
|
+
"pages.settings.form.customFields.table.enable": "Enable custom field",
|
|
166
|
+
"pages.settings.form.customFields.table.disable": "Disable custom field",
|
|
167
|
+
"pages.settings.form.customFields.table.remove": "Remove custom field",
|
|
168
|
+
"pages.settings.form.customFields.table.required": "required",
|
|
169
|
+
"pages.settings.form.customFields.table.notRequired": "not required",
|
|
170
|
+
"pages.settings.form.customFields.popup.header.edit": "Edit custom field",
|
|
171
|
+
"pages.settings.form.customFields.popup.header.new": "Add new custom field",
|
|
172
|
+
"pages.settings.form.customFields.popup.name.label": "Custom field name",
|
|
173
|
+
"pages.settings.form.customFields.popup.name.placeholder": "example_name",
|
|
174
|
+
"pages.settings.form.customFields.popup.name.description": "Name of the custom field must be unique",
|
|
175
|
+
"pages.settings.form.customFields.popup.label.label": "Custom field label",
|
|
176
|
+
"pages.settings.form.customFields.popup.label.placeholder": "Example label",
|
|
177
|
+
"pages.settings.form.customFields.popup.label.description": "This label will be displayed on navigation item form",
|
|
178
|
+
"pages.settings.form.customFields.popup.type.label": "Custom field type",
|
|
179
|
+
"pages.settings.form.customFields.popup.required.label": "Require field",
|
|
180
|
+
"pages.settings.form.customFields.popup.required.description": "Enabling this field will not change already exiting navigation items",
|
|
181
|
+
"pages.settings.form.customFields.popup.options.label": "Options for select input",
|
|
182
|
+
"pages.settings.form.customFields.popup.options.description": "Enabling this field will not change already exiting navigation items",
|
|
183
|
+
"pages.settings.form.customFields.popup.multi.label": "Enable multiple options input",
|
|
147
184
|
"components.navigationItem.action.newItem": "Add nested item",
|
|
148
185
|
"components.navigationItem.badge.removed": "Removed",
|
|
149
186
|
"components.navigationItem.badge.draft": "Draft",
|
|
@@ -13,7 +13,7 @@ const trads = {
|
|
|
13
13
|
};
|
|
14
14
|
const getTradId = (msg) => `${pluginId_1.default}.${msg}`;
|
|
15
15
|
exports.getTradId = getTradId;
|
|
16
|
-
const getTrad = (msg) => ({ id: (0, exports.getTradId)(msg) });
|
|
16
|
+
const getTrad = (msg, defaultMessage) => ({ id: (0, exports.getTradId)(msg), defaultMessage: defaultMessage || (0, exports.getTradId)(msg) });
|
|
17
17
|
exports.getTrad = getTrad;
|
|
18
18
|
exports.default = trads;
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/admin/src/utils/api.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export
|
|
1
|
+
import { NavigationPluginConfig } from '../../../types';
|
|
2
|
+
export declare const fetchNavigationConfig: () => any;
|
|
3
|
+
export declare const updateNavigationConfig: ({ body }: {
|
|
4
|
+
body: NavigationPluginConfig;
|
|
5
|
+
}) => any;
|
|
6
|
+
export declare const restoreNavigationConfig: () => any;
|
|
7
|
+
export declare const fetchAllContentTypes: () => Promise<any>;
|
|
8
|
+
export declare const restartStrapi: () => any;
|
|
8
9
|
//# sourceMappingURL=api.d.ts.map
|
package/admin/src/utils/api.js
CHANGED
|
@@ -5,51 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.restartStrapi = exports.fetchAllContentTypes = exports.restoreNavigationConfig = exports.updateNavigationConfig = exports.fetchNavigationConfig = void 0;
|
|
7
7
|
const helper_plugin_1 = require("@strapi/helper-plugin");
|
|
8
|
+
const fp_1 = require("lodash/fp");
|
|
8
9
|
const pluginId_1 = __importDefault(require("../pluginId"));
|
|
9
|
-
const fetchNavigationConfig =
|
|
10
|
-
try {
|
|
11
|
-
const data = await (0, helper_plugin_1.request)(`/${pluginId_1.default}/settings/config`, { method: 'GET' });
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
catch (err) {
|
|
15
|
-
toggleNotification({
|
|
16
|
-
type: 'warning',
|
|
17
|
-
message: { id: 'notification.error' },
|
|
18
|
-
});
|
|
19
|
-
return { err };
|
|
20
|
-
}
|
|
21
|
-
};
|
|
10
|
+
const fetchNavigationConfig = () => (0, helper_plugin_1.request)(`/${pluginId_1.default}/settings/config`, { method: 'GET' });
|
|
22
11
|
exports.fetchNavigationConfig = fetchNavigationConfig;
|
|
23
|
-
const updateNavigationConfig =
|
|
12
|
+
const updateNavigationConfig = ({ body }) => (0, helper_plugin_1.request)(`/${pluginId_1.default}/config`, { method: 'PUT', body }, true);
|
|
24
13
|
exports.updateNavigationConfig = updateNavigationConfig;
|
|
25
|
-
const restoreNavigationConfig =
|
|
14
|
+
const restoreNavigationConfig = () => (0, helper_plugin_1.request)(`/${pluginId_1.default}/config`, { method: 'DELETE' }, true);
|
|
26
15
|
exports.restoreNavigationConfig = restoreNavigationConfig;
|
|
27
|
-
const fetchAllContentTypes = async () => {
|
|
28
|
-
try {
|
|
29
|
-
const { data } = await (0, helper_plugin_1.request)('/content-manager/content-types');
|
|
30
|
-
return { ...data };
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
toggleNotification({
|
|
34
|
-
type: 'warning',
|
|
35
|
-
message: { id: 'notification.error' },
|
|
36
|
-
});
|
|
37
|
-
return { err };
|
|
38
|
-
}
|
|
39
|
-
};
|
|
16
|
+
const fetchAllContentTypes = async () => (0, helper_plugin_1.request)('/content-manager/content-types', { method: 'GET' }).then((0, fp_1.prop)("data"));
|
|
40
17
|
exports.fetchAllContentTypes = fetchAllContentTypes;
|
|
41
|
-
const restartStrapi =
|
|
42
|
-
try {
|
|
43
|
-
const { data } = await (0, helper_plugin_1.request)(`/${pluginId_1.default}/settings/restart`);
|
|
44
|
-
return data;
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
toggleNotification({
|
|
48
|
-
type: 'warning',
|
|
49
|
-
message: { id: 'notification.error' },
|
|
50
|
-
});
|
|
51
|
-
return { err };
|
|
52
|
-
}
|
|
53
|
-
};
|
|
18
|
+
const restartStrapi = () => (0, helper_plugin_1.request)(`/${pluginId_1.default}/settings/restart`);
|
|
54
19
|
exports.restartStrapi = restartStrapi;
|
|
55
20
|
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const navigationItemType: {
|
|
2
|
+
INTERNAL: string;
|
|
3
|
+
EXTERNAL: string;
|
|
4
|
+
WRAPPER: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const navigationItemAdditionalFields: {
|
|
7
|
+
AUDIENCE: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const ItemTypes: {
|
|
10
|
+
NAVIGATION_ITEM: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const ResourceState: {
|
|
13
|
+
RESOLVED: string;
|
|
14
|
+
LOADING: string;
|
|
15
|
+
ERROR: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const resolvedResourceFor: <T = unknown>(value: T) => {
|
|
18
|
+
type: string;
|
|
19
|
+
value: T;
|
|
20
|
+
};
|
|
21
|
+
export declare const errorStatusResourceFor: (errors: Array<Error>) => {
|
|
22
|
+
type: string;
|
|
23
|
+
errors: Error[];
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorStatusResourceFor = exports.resolvedResourceFor = exports.ResourceState = exports.ItemTypes = exports.navigationItemAdditionalFields = exports.navigationItemType = void 0;
|
|
4
|
+
exports.navigationItemType = {
|
|
5
|
+
INTERNAL: "INTERNAL",
|
|
6
|
+
EXTERNAL: "EXTERNAL",
|
|
7
|
+
WRAPPER: "WRAPPER",
|
|
8
|
+
};
|
|
9
|
+
exports.navigationItemAdditionalFields = {
|
|
10
|
+
AUDIENCE: 'audience',
|
|
11
|
+
};
|
|
12
|
+
exports.ItemTypes = {
|
|
13
|
+
NAVIGATION_ITEM: 'navigationItem'
|
|
14
|
+
};
|
|
15
|
+
exports.ResourceState = {
|
|
16
|
+
RESOLVED: 'RESOLVED',
|
|
17
|
+
LOADING: 'LOADING',
|
|
18
|
+
ERROR: 'ERROR',
|
|
19
|
+
};
|
|
20
|
+
const resolvedResourceFor = (value) => ({
|
|
21
|
+
type: exports.ResourceState.RESOLVED,
|
|
22
|
+
value,
|
|
23
|
+
});
|
|
24
|
+
exports.resolvedResourceFor = resolvedResourceFor;
|
|
25
|
+
const errorStatusResourceFor = (errors) => ({
|
|
26
|
+
type: exports.ResourceState.ERROR,
|
|
27
|
+
errors,
|
|
28
|
+
});
|
|
29
|
+
exports.errorStatusResourceFor = errorStatusResourceFor;
|
|
30
|
+
//# sourceMappingURL=enums.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NavigationItemAdditionalField, NavigationItemAdditionalFieldValues, ToBeFixed } from '../../../types';
|
|
2
|
+
declare type MessageInput = {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage?: string;
|
|
5
|
+
props?: Record<string, ToBeFixed>;
|
|
6
|
+
} | string;
|
|
7
|
+
declare type PrepareNewValueForRecord = (uid: string, current: Record<string, string[] | undefined>, value: string[]) => Record<string, string[] | undefined>;
|
|
8
|
+
export declare const getMessage: (input: MessageInput, defaultMessage?: string, inPluginScope?: boolean) => string;
|
|
9
|
+
export declare const getDefaultCustomFields: (args: {
|
|
10
|
+
additionalFields: NavigationItemAdditionalField[];
|
|
11
|
+
customFieldsValues: NavigationItemAdditionalFieldValues;
|
|
12
|
+
defaultCustomFieldsValues: NavigationItemAdditionalFieldValues;
|
|
13
|
+
}) => NavigationItemAdditionalFieldValues;
|
|
14
|
+
export declare const prepareNewValueForRecord: PrepareNewValueForRecord;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.prepareNewValueForRecord = exports.getDefaultCustomFields = exports.getMessage = void 0;
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
8
|
+
const react_intl_1 = require("react-intl");
|
|
9
|
+
const form_1 = require("../pages/View/components/NavigationItemForm/utils/form");
|
|
10
|
+
const pluginId_1 = __importDefault(require("../pluginId"));
|
|
11
|
+
const getMessage = (input, defaultMessage = '', inPluginScope = true) => {
|
|
12
|
+
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
13
|
+
let formattedId = '';
|
|
14
|
+
if (typeof input === 'string') {
|
|
15
|
+
formattedId = input;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
formattedId = input.id.toString() || formattedId;
|
|
19
|
+
}
|
|
20
|
+
return formatMessage({
|
|
21
|
+
id: `${inPluginScope ? pluginId_1.default : 'app.components'}.${formattedId}`,
|
|
22
|
+
defaultMessage,
|
|
23
|
+
}, typeof input === 'string' ? undefined : input?.props);
|
|
24
|
+
};
|
|
25
|
+
exports.getMessage = getMessage;
|
|
26
|
+
const getDefaultCustomFields = (args) => {
|
|
27
|
+
return args.additionalFields.reduce((acc, additionalField) => {
|
|
28
|
+
if (typeof additionalField === 'string') {
|
|
29
|
+
return acc;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const value = form_1.defaultValues.additionalFields[additionalField.type];
|
|
33
|
+
return {
|
|
34
|
+
...acc,
|
|
35
|
+
[additionalField.name]: (0, lodash_1.get)(args.customFieldsValues, additionalField.name, value),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}, {});
|
|
39
|
+
};
|
|
40
|
+
exports.getDefaultCustomFields = getDefaultCustomFields;
|
|
41
|
+
const prepareNewValueForRecord = (uid, current, value) => ({
|
|
42
|
+
...current,
|
|
43
|
+
[uid]: value && !(0, lodash_1.isEmpty)(value) ? [...value] : undefined,
|
|
44
|
+
});
|
|
45
|
+
exports.prepareNewValueForRecord = prepareNewValueForRecord;
|
|
46
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
export namespace ResourceState {
|
|
6
|
-
const RESOLVED: string;
|
|
7
|
-
const LOADING: string;
|
|
8
|
-
const ERROR: string;
|
|
9
|
-
}
|
|
10
|
-
export function resolvedResourceFor(value: any): {
|
|
11
|
-
type: string;
|
|
12
|
-
value: any;
|
|
13
|
-
};
|
|
14
|
-
export function errorStatusResourceFor(errors: any): {
|
|
15
|
-
type: string;
|
|
16
|
-
errors: any;
|
|
17
|
-
};
|
|
1
|
+
export * from './functions';
|
|
2
|
+
export * from './api';
|
|
3
|
+
export * from './enums';
|
|
18
4
|
//# sourceMappingURL=index.d.ts.map
|