strapi-plugin-navigation 1.1.1 → 2.0.0-beta.3
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 +36 -15
- package/admin/src/components/EmptyView/index.js +7 -16
- package/admin/src/components/Item/ItemCardBadge/index.js +8 -0
- package/admin/src/components/Item/ItemCardHeader/Wrapper.js +21 -0
- package/admin/src/components/Item/ItemCardHeader/index.js +59 -0
- package/admin/src/components/Item/Wrapper.js +39 -0
- package/admin/src/components/Item/index.js +76 -124
- package/admin/src/components/NavigationItemList/Wrapper.js +22 -0
- package/admin/src/components/NavigationItemList/index.js +54 -0
- package/admin/src/components/PluginIcon/index.js +6 -0
- package/admin/src/index.js +49 -45
- package/admin/src/pages/App/index.js +31 -0
- package/admin/src/{containers → pages}/DataManagerProvider/actions.js +0 -0
- package/admin/src/{containers → pages}/DataManagerProvider/index.js +77 -84
- package/admin/src/{containers → pages}/DataManagerProvider/init.js +0 -0
- package/admin/src/pages/DataManagerProvider/reducer.js +125 -0
- package/admin/src/pages/View/components/NavigationContentHeader/index.js +18 -0
- package/admin/src/pages/View/components/NavigationHeader/index.js +60 -0
- package/admin/src/pages/View/components/NavigationItemForm/index.js +403 -0
- package/admin/src/{containers → pages}/View/components/NavigationItemForm/utils/form.js +2 -2
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +40 -0
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +20 -0
- package/admin/src/{containers → pages}/View/components/NavigationItemPopup/index.js +16 -16
- package/admin/src/pages/View/index.js +209 -0
- package/admin/src/{containers → pages}/View/utils/enums.js +0 -0
- package/admin/src/{containers → pages}/View/utils/form.js +1 -1
- package/admin/src/{containers → pages}/View/utils/index.js +0 -0
- package/admin/src/{containers → pages}/View/utils/parsers.js +13 -12
- package/admin/src/pluginId.js +3 -2
- package/admin/src/translations/en.json +47 -38
- package/admin/src/translations/fr.json +7 -1
- package/admin/src/utils/getTrad.js +2 -2
- package/package.json +14 -6
- package/server/bootstrap.js +41 -0
- package/server/config.js +8 -0
- package/server/content-types/audience/index.js +9 -0
- package/{models/audience.js → server/content-types/audience/lifecycle.js} +0 -0
- package/{models/audience.settings.json → server/content-types/audience/schema.json} +4 -2
- package/server/content-types/index.js +13 -0
- package/server/content-types/navigation/index.js +9 -0
- package/{models/navigation.js → server/content-types/navigation/lifecycle.js} +0 -0
- package/server/content-types/navigation/schema.js +45 -0
- package/server/content-types/navigation-item/index.js +9 -0
- package/{models/navigationItem.js → server/content-types/navigation-item/lifecycle.js} +0 -0
- package/{models/navigationItem.settings.json → server/content-types/navigation-item/schema.json} +16 -12
- package/server/content-types/navigations-items-related/index.js +9 -0
- package/{models/navigations_items_related.js → server/content-types/navigations-items-related/lifecycle.js} +0 -0
- package/{models/navigations_items_related.settings.json → server/content-types/navigations-items-related/schema.json} +4 -2
- package/server/controllers/index.js +7 -0
- package/{controllers → server/controllers}/navigation.js +7 -39
- package/server/routes/admin.js +38 -0
- package/server/routes/index.js +3 -0
- package/{services → server/services}/__tests__/navigation.test.js +0 -0
- package/server/services/index.js +7 -0
- package/server/services/navigation.js +463 -0
- package/{services → server/services}/utils/constant.js +3 -1
- package/server/services/utils/functions.js +103 -0
- package/strapi-admin.js +1 -0
- package/strapi-server.js +18 -0
- package/__mocks__/helpers/another-plugin/blog-post.settings.json +0 -31
- package/__mocks__/helpers/another-plugin/pages.settings.json +0 -28
- package/__mocks__/helpers/blog-post.settings.json +0 -31
- package/__mocks__/helpers/home-page.settings.json +0 -4
- package/__mocks__/helpers/my-homepage.settings.json +0 -27
- package/__mocks__/helpers/pages.settings.json +0 -27
- package/__mocks__/helpers/strapi.js +0 -101
- package/admin/src/assets/images/icon-cross-blue.svg +0 -1
- package/admin/src/assets/images/icon_remove.svg +0 -19
- package/admin/src/components/Container/index.js +0 -7
- package/admin/src/components/Input/index.js +0 -41
- package/admin/src/components/Item/CardItem.js +0 -46
- package/admin/src/components/Item/CardItemLevelAdd.js +0 -41
- package/admin/src/components/Item/CardItemLevelWrapper.js +0 -27
- package/admin/src/components/Item/CardItemPath.js +0 -9
- package/admin/src/components/Item/CardItemRestore.js +0 -19
- package/admin/src/components/Item/CardItemTitle.js +0 -5
- package/admin/src/components/Item/CardWrapper.js +0 -78
- package/admin/src/components/ItemFooter/CardItemError.js +0 -11
- package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
- package/admin/src/components/ItemFooter/CardItemRelationStatus.js +0 -17
- package/admin/src/components/ItemFooter/CardItemType.js +0 -18
- package/admin/src/components/ItemFooter/Wrapper.js +0 -26
- package/admin/src/components/ItemFooter/index.js +0 -66
- package/admin/src/components/ItemOrdering/CardOrderingButton.js +0 -24
- package/admin/src/components/ItemOrdering/Wrapper.js +0 -24
- package/admin/src/components/ItemOrdering/index.js +0 -36
- package/admin/src/components/List/Container.js +0 -34
- package/admin/src/components/List/ListLevelRoot.js +0 -18
- package/admin/src/components/List/index.js +0 -81
- package/admin/src/components/Option/OptionButton.js +0 -18
- package/admin/src/components/Option/OptionSet.js +0 -14
- package/admin/src/components/Option/Wrapper.js +0 -15
- package/admin/src/components/Option/index.js +0 -47
- package/admin/src/components/Search/index.js +0 -86
- package/admin/src/components/Select/ClearIndicator.js +0 -15
- package/admin/src/components/Select/DropdownIndicator.js +0 -39
- package/admin/src/components/Select/ErrorMessage.js +0 -10
- package/admin/src/components/Select/IndicatorSeparator.js +0 -3
- package/admin/src/components/Select/MultiValueContainer.js +0 -43
- package/admin/src/components/Select/StyledOption.js +0 -11
- package/admin/src/components/Select/index.js +0 -68
- package/admin/src/components/Select/utils/styles.js +0 -92
- package/admin/src/containers/App/Wrapper.js +0 -14
- package/admin/src/containers/App/index.js +0 -34
- package/admin/src/containers/DataManagerProvider/reducer.js +0 -136
- package/admin/src/containers/DetailsView/Wrapper.js +0 -21
- package/admin/src/containers/DetailsView/index.js +0 -111
- package/admin/src/containers/Initializer/index.js +0 -26
- package/admin/src/containers/ListView/Footer.js +0 -56
- package/admin/src/containers/ListView/components.js +0 -138
- package/admin/src/containers/ListView/index.js +0 -54
- package/admin/src/containers/View/FadedWrapper.js +0 -51
- package/admin/src/containers/View/HeaderForm.js +0 -9
- package/admin/src/containers/View/HeaderFormCell.js +0 -25
- package/admin/src/containers/View/Wrapper.js +0 -17
- package/admin/src/containers/View/components/NavigationItemForm/ModalFooter.js +0 -45
- package/admin/src/containers/View/components/NavigationItemForm/index.js +0 -427
- package/admin/src/containers/View/components/NavigationItemPopup/MediumPopup.js +0 -6
- package/admin/src/containers/View/index.js +0 -240
- package/admin/src/lifecycles.js +0 -3
- package/admin/src/permissions.js +0 -14
- package/config/functions/bootstrap.js +0 -138
- package/config/routes.json +0 -60
- package/config/schema.graphql.js +0 -204
- package/examples/audit-log-integrations.js.md +0 -38
- package/models/navigation.settings.json +0 -43
- package/public/assets/preview.png +0 -0
- package/services/navigation.js +0 -730
- package/services/utils/functions.js +0 -186
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Navigation View
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { memo, useMemo, useState } from 'react';
|
|
8
|
+
import { useIntl } from "react-intl";
|
|
9
|
+
import { isEmpty, get } from "lodash";
|
|
10
|
+
|
|
11
|
+
// Design System
|
|
12
|
+
import { Main } from '@strapi/design-system/Main';
|
|
13
|
+
import { ContentLayout } from '@strapi/design-system/Layout';
|
|
14
|
+
import { Button } from '@strapi/design-system/Button';
|
|
15
|
+
import { LoadingIndicatorPage } from "@strapi/helper-plugin";
|
|
16
|
+
import { EmptyStateLayout } from '@strapi/design-system/EmptyStateLayout';
|
|
17
|
+
import { IconButton } from '@strapi/design-system/IconButton';
|
|
18
|
+
import EmptyDocumentsIcon from '@strapi/icons/EmptyDocuments';
|
|
19
|
+
import PlusIcon from "@strapi/icons/Plus";
|
|
20
|
+
import SearchIcon from "@strapi/icons/Search";
|
|
21
|
+
|
|
22
|
+
// Components
|
|
23
|
+
import List from '../../components/NavigationItemList';
|
|
24
|
+
import NavigationContentHeader from './components/NavigationContentHeader';
|
|
25
|
+
import NavigationHeader from './components/NavigationHeader';
|
|
26
|
+
import NavigationItemPopUp from "./components/NavigationItemPopup";
|
|
27
|
+
import useDataManager from "../../hooks/useDataManager";
|
|
28
|
+
import { getTrad } from '../../translations';
|
|
29
|
+
import {
|
|
30
|
+
transformItemToViewPayload,
|
|
31
|
+
transformToRESTPayload,
|
|
32
|
+
usedContentTypes,
|
|
33
|
+
validateNavigationStructure,
|
|
34
|
+
} from './utils/parsers';
|
|
35
|
+
|
|
36
|
+
const View = () => {
|
|
37
|
+
const {
|
|
38
|
+
items: availableNavigations,
|
|
39
|
+
activeItem: activeNavigation,
|
|
40
|
+
changedActiveItem: changedActiveNavigation,
|
|
41
|
+
config,
|
|
42
|
+
navigationItemPopupOpened,
|
|
43
|
+
isLoading,
|
|
44
|
+
isLoadingForAdditionalDataToBeSet,
|
|
45
|
+
isLoadingForSubmit,
|
|
46
|
+
handleChangeNavigationItemPopupVisibility,
|
|
47
|
+
handleChangeSelection,
|
|
48
|
+
handleChangeNavigationData,
|
|
49
|
+
handleResetNavigationData,
|
|
50
|
+
handleSubmitNavigation,
|
|
51
|
+
getContentTypeItems,
|
|
52
|
+
error
|
|
53
|
+
} = useDataManager();
|
|
54
|
+
|
|
55
|
+
const [activeNavigationItem, setActiveNavigationItemState] = useState({});
|
|
56
|
+
const { formatMessage } = useIntl();
|
|
57
|
+
|
|
58
|
+
const structureHasErrors = !validateNavigationStructure((changedActiveNavigation || {}).items);
|
|
59
|
+
const navigationSelectValue = get(activeNavigation, "id", null);
|
|
60
|
+
const handleSave = () => isLoadingForSubmit || structureHasErrors
|
|
61
|
+
? null
|
|
62
|
+
: handleSubmitNavigation(formatMessage, transformToRESTPayload(changedActiveNavigation, config));
|
|
63
|
+
|
|
64
|
+
const changeNavigationItemPopupState = (visible, editedItem = {}) => {
|
|
65
|
+
setActiveNavigationItemState(editedItem);
|
|
66
|
+
handleChangeNavigationItemPopupVisibility(visible);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const addNewNavigationItem = (
|
|
70
|
+
e,
|
|
71
|
+
viewId = null,
|
|
72
|
+
isMenuAllowedLevel = true,
|
|
73
|
+
levelPath = '',
|
|
74
|
+
parentAttachedToMenu = true,
|
|
75
|
+
) => {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
changeNavigationItemPopupState(true, {
|
|
79
|
+
viewParentId: viewId,
|
|
80
|
+
isMenuAllowedLevel,
|
|
81
|
+
levelPath,
|
|
82
|
+
parentAttachedToMenu,
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const usedContentTypesData = useMemo(
|
|
87
|
+
() => changedActiveNavigation ? usedContentTypes(changedActiveNavigation.items) : [],
|
|
88
|
+
[changedActiveNavigation],
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const pullUsedContentTypeItem = (items = []) =>
|
|
92
|
+
items.reduce((prev, curr) =>
|
|
93
|
+
[...prev, curr.relatedRef ? {
|
|
94
|
+
__collectionUid: curr.relatedRef.__collectionUid,
|
|
95
|
+
id: curr.relatedRef.id
|
|
96
|
+
} : undefined, ...pullUsedContentTypeItem(curr.items)].filter(item => item)
|
|
97
|
+
, []);
|
|
98
|
+
const usedContentTypeItems = pullUsedContentTypeItem((changedActiveNavigation || {}).items);
|
|
99
|
+
const handleSubmitNavigationItem = (payload) => {
|
|
100
|
+
const changedStructure = {
|
|
101
|
+
...changedActiveNavigation,
|
|
102
|
+
items: transformItemToViewPayload(payload, changedActiveNavigation.items, config),
|
|
103
|
+
};
|
|
104
|
+
handleChangeNavigationData(changedStructure, true);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const handleItemRemove = (item) => {
|
|
108
|
+
handleSubmitNavigationItem({
|
|
109
|
+
...item,
|
|
110
|
+
removed: true,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const handleItemRestore = (item) => {
|
|
115
|
+
handleSubmitNavigationItem({
|
|
116
|
+
...item,
|
|
117
|
+
removed: false,
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const handleItemEdit = (
|
|
122
|
+
item,
|
|
123
|
+
levelPath = '',
|
|
124
|
+
parentAttachedToMenu = true,
|
|
125
|
+
) => {
|
|
126
|
+
changeNavigationItemPopupState(true, {
|
|
127
|
+
...item,
|
|
128
|
+
levelPath,
|
|
129
|
+
parentAttachedToMenu,
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const onPopUpClose = (e) => {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
e.stopPropagation();
|
|
136
|
+
changeNavigationItemPopupState(false);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<Main labelledBy="title" aria-busy={isLoadingForSubmit}>
|
|
141
|
+
<NavigationHeader
|
|
142
|
+
structureHasErrors={structureHasErrors}
|
|
143
|
+
handleSave={handleSave}
|
|
144
|
+
/>
|
|
145
|
+
<ContentLayout>
|
|
146
|
+
{isLoading && <LoadingIndicatorPage />}
|
|
147
|
+
{changedActiveNavigation && (
|
|
148
|
+
<>
|
|
149
|
+
<NavigationContentHeader
|
|
150
|
+
startActions={<IconButton icon={<SearchIcon />} />}
|
|
151
|
+
endActions={<Button
|
|
152
|
+
onClick={addNewNavigationItem}
|
|
153
|
+
startIcon={<PlusIcon />}
|
|
154
|
+
disabled={isLoadingForSubmit}
|
|
155
|
+
type="submit"
|
|
156
|
+
>
|
|
157
|
+
{formatMessage(getTrad('header.action.newItem'))}
|
|
158
|
+
</Button>}
|
|
159
|
+
/>
|
|
160
|
+
{isEmpty(changedActiveNavigation.items || []) && (
|
|
161
|
+
<EmptyStateLayout
|
|
162
|
+
action={
|
|
163
|
+
<Button
|
|
164
|
+
variant='secondary'
|
|
165
|
+
startIcon={<PlusIcon />}
|
|
166
|
+
label={formatMessage(getTrad('empty.cta'))}
|
|
167
|
+
onClick={addNewNavigationItem}
|
|
168
|
+
>
|
|
169
|
+
{formatMessage(getTrad('empty.cta'))}
|
|
170
|
+
</Button>
|
|
171
|
+
}
|
|
172
|
+
icon={<EmptyDocumentsIcon width='10rem' />}
|
|
173
|
+
content={formatMessage(getTrad('empty'))}
|
|
174
|
+
/>
|
|
175
|
+
)}
|
|
176
|
+
{
|
|
177
|
+
!isEmpty(changedActiveNavigation.items || [])
|
|
178
|
+
&& <List
|
|
179
|
+
items={changedActiveNavigation.items || []}
|
|
180
|
+
onItemLevelAdd={addNewNavigationItem}
|
|
181
|
+
onItemRemove={handleItemRemove}
|
|
182
|
+
onItemEdit={handleItemEdit}
|
|
183
|
+
onItemRestore={handleItemRestore}
|
|
184
|
+
root
|
|
185
|
+
error={error}
|
|
186
|
+
allowedLevels={config.allowedLevels}
|
|
187
|
+
contentTypes={config.contentTypes}
|
|
188
|
+
isParentAttachedToMenu={true}
|
|
189
|
+
contentTypesNameFields={config.contentTypesNameFields}
|
|
190
|
+
/>
|
|
191
|
+
}
|
|
192
|
+
</>
|
|
193
|
+
)}
|
|
194
|
+
</ContentLayout>
|
|
195
|
+
{navigationItemPopupOpened && <NavigationItemPopUp
|
|
196
|
+
isLoading={isLoadingForAdditionalDataToBeSet}
|
|
197
|
+
data={activeNavigationItem}
|
|
198
|
+
config={config}
|
|
199
|
+
usedContentTypesData={usedContentTypesData}
|
|
200
|
+
usedContentTypeItems={usedContentTypeItems}
|
|
201
|
+
getContentTypeItems={getContentTypeItems}
|
|
202
|
+
onSubmit={handleSubmitNavigationItem}
|
|
203
|
+
onClose={onPopUpClose}
|
|
204
|
+
/>}
|
|
205
|
+
</Main>
|
|
206
|
+
);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export default memo(View);
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v4 as uuid, validate as isUuid } from 'uuid'
|
|
2
2
|
import { find, get, isArray, isEmpty, isNil, isNumber, isObject, isString, last, omit, orderBy } from 'lodash';
|
|
3
3
|
import { navigationItemType } from './enums';
|
|
4
4
|
|
|
@@ -28,7 +28,7 @@ export const transformItemToRESTPayload = (
|
|
|
28
28
|
const { contentTypes = [] } = config;
|
|
29
29
|
|
|
30
30
|
const parsedRelated = Number(related);
|
|
31
|
-
const relatedId = isExternal || isNaN(parsedRelated) ? related : parsedRelated;
|
|
31
|
+
const relatedId = isExternal || isNaN(parsedRelated) ? related.value || related : parsedRelated;
|
|
32
32
|
|
|
33
33
|
const relatedContentType = relatedType ?
|
|
34
34
|
find(contentTypes,
|
|
@@ -46,7 +46,8 @@ export const transformItemToRESTPayload = (
|
|
|
46
46
|
order,
|
|
47
47
|
uiRouterKey,
|
|
48
48
|
menuAttached,
|
|
49
|
-
audience: audience.map((audienceItem) =>
|
|
49
|
+
audience: audience.map((audienceItem) =>
|
|
50
|
+
isObject(audienceItem) ? audienceItem.value : audienceItem,
|
|
50
51
|
),
|
|
51
52
|
path: isExternal ? undefined : path,
|
|
52
53
|
externalPath: isExternal ? externalPath : undefined,
|
|
@@ -64,7 +65,7 @@ export const transformItemToRESTPayload = (
|
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
export const transformToRESTPayload = (payload, config = {}) => {
|
|
67
|
-
|
|
68
|
+
const { id, name, visible, items } = payload;
|
|
68
69
|
return {
|
|
69
70
|
id,
|
|
70
71
|
name,
|
|
@@ -90,7 +91,7 @@ const linkRelations = (item, config) => {
|
|
|
90
91
|
relatedRef: {
|
|
91
92
|
...omit(relatedContentType, 'collectionName'),
|
|
92
93
|
isSingle,
|
|
93
|
-
|
|
94
|
+
__collectionUid: relatedContentType.uid,
|
|
94
95
|
},
|
|
95
96
|
};
|
|
96
97
|
}
|
|
@@ -125,7 +126,7 @@ const linkRelations = (item, config) => {
|
|
|
125
126
|
related: relatedItem.id,
|
|
126
127
|
relatedRef: {
|
|
127
128
|
...relatedItem,
|
|
128
|
-
|
|
129
|
+
__collectionUid: uid,
|
|
129
130
|
isSingle,
|
|
130
131
|
labelSingular,
|
|
131
132
|
},
|
|
@@ -138,7 +139,7 @@ const linkRelations = (item, config) => {
|
|
|
138
139
|
relation = {
|
|
139
140
|
relatedRef: {
|
|
140
141
|
...relatedRef,
|
|
141
|
-
|
|
142
|
+
__collectionUid: uid,
|
|
142
143
|
__contentType: contentTypeName,
|
|
143
144
|
isSingle,
|
|
144
145
|
labelSingular,
|
|
@@ -233,7 +234,7 @@ export const transformItemToViewPayload = (payload, items = [], config) => {
|
|
|
233
234
|
};
|
|
234
235
|
|
|
235
236
|
export const prepareItemToViewPayload = (items = [], viewParentId = null, config = {}) =>
|
|
236
|
-
items.map((item, n) => {
|
|
237
|
+
reOrderItems(items.map((item, n) => {
|
|
237
238
|
const viewId = uuid();
|
|
238
239
|
return {
|
|
239
240
|
...linkRelations({
|
|
@@ -245,12 +246,12 @@ export const prepareItemToViewPayload = (items = [], viewParentId = null, config
|
|
|
245
246
|
}, config),
|
|
246
247
|
items: prepareItemToViewPayload(item.items, viewId, config),
|
|
247
248
|
};
|
|
248
|
-
});
|
|
249
|
+
}));
|
|
249
250
|
|
|
250
251
|
export const extractRelatedItemLabel = (item = {}, fields = {}, config = {}) => {
|
|
251
252
|
const { contentTypes = [] } = config;
|
|
252
|
-
const {
|
|
253
|
-
const contentType = contentTypes.find(_ => _.uid ===
|
|
253
|
+
const { __collectionUid } = item;
|
|
254
|
+
const contentType = contentTypes.find(_ => _.uid === __collectionUid)
|
|
254
255
|
const { default: defaultFields = [] } = fields;
|
|
255
256
|
return get(fields, `${contentType ? contentType.collectionName : ''}`, defaultFields).map((_) => item[_]).filter((_) => _)[0] || '';
|
|
256
257
|
};
|
|
@@ -275,7 +276,7 @@ export const isRelationPublished = ({ relatedRef, relatedType = {}, type, isColl
|
|
|
275
276
|
return relatedType.available || relatedRef.available;
|
|
276
277
|
}
|
|
277
278
|
if ((type === navigationItemType.INTERNAL)) {
|
|
278
|
-
const isHandledByPublshFlow =
|
|
279
|
+
const isHandledByPublshFlow = relatedRef ? 'published_at' in relatedRef : false;
|
|
279
280
|
if (isHandledByPublshFlow) {
|
|
280
281
|
return get(relatedRef, 'published_at', true);
|
|
281
282
|
}
|
package/admin/src/pluginId.js
CHANGED
|
@@ -1,39 +1,48 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
2
|
+
"plugin.name": "UI Navigation",
|
|
3
|
+
"header.title": "Navigation",
|
|
4
|
+
"header.description": "Define your portal navigation",
|
|
5
|
+
"header.action.newItem": "New Item",
|
|
6
|
+
"submit.cta.cancel": "Cancel",
|
|
7
|
+
"submit.cta.save": "Save",
|
|
8
|
+
"empty": "Navigation container is empty",
|
|
9
|
+
"empty.cta": "Create first item",
|
|
10
|
+
"popup.item.header": "Manage navigation item",
|
|
11
|
+
"popup.item.form.title.label": "Title",
|
|
12
|
+
"popup.item.form.title.placeholder": "Enter the item title or leave blank to pull from related entity",
|
|
13
|
+
"popup.item.form.uiRouterKey.label": "UI router key",
|
|
14
|
+
"popup.item.form.uiRouterKey.placeholder": "If empty, auto generated by \"Title\"",
|
|
15
|
+
"popup.item.form.path.label": "URL",
|
|
16
|
+
"popup.item.form.path.placeholder": "Unique url part identifies this item",
|
|
17
|
+
"popup.item.form.path.preview": "Preview:",
|
|
18
|
+
"popup.item.form.externalPath.label": "External URL",
|
|
19
|
+
"popup.item.form.externalPath.placeholder": "Link to the external source",
|
|
20
|
+
"popup.item.form.externalPath.validation.type": "This value is not a proper url." ,
|
|
21
|
+
"popup.item.form.menuAttached.label": "Attach to menu",
|
|
22
|
+
"popup.item.form.type.label": "Internal link",
|
|
23
|
+
"popup.item.form.type.internal.label": "Internal source",
|
|
24
|
+
"popup.item.form.type.external.label": "External source",
|
|
25
|
+
"popup.item.form.audience.label": "Audience",
|
|
26
|
+
"popup.item.form.audience.placeholder": "Type to start searching...",
|
|
27
|
+
"popup.item.form.relatedSection.label": "Relation to",
|
|
28
|
+
"popup.item.form.relatedType.label": "Content Type",
|
|
29
|
+
"popup.item.form.relatedType.placeholder": "Select content type...",
|
|
30
|
+
"popup.item.form.related.label": "Entity",
|
|
31
|
+
"popup.item.form.related.empty": "There are no more entities of \"{ contentTypeName }\" to select",
|
|
32
|
+
"popup.item.form.button.create": "Create item",
|
|
33
|
+
"popup.item.form.button.update": "Update item",
|
|
34
|
+
"popup.item.form.button.restore": "Restore item",
|
|
35
|
+
"popup.item.form.button.remove": "Remove",
|
|
36
|
+
"popup.item.form.button.save": "Save",
|
|
37
|
+
"popup.item.form.button.cancel": "Cancel",
|
|
38
|
+
"notification.navigation.submit": "Navigation changes has been saved",
|
|
39
|
+
"notification.navigation.error": "Duplicate path: { path } in parent: { parentTitle } for { errorTitles } items",
|
|
40
|
+
"notification.navigation.item.relation": "Entity relation does not exist!",
|
|
41
|
+
"notification.navigation.item.relation.status.draft": "draft",
|
|
42
|
+
"notification.navigation.item.relation.status.published": "published",
|
|
43
|
+
"navigation.item.action.newItem": "New nested item",
|
|
44
|
+
"navigation.item.badge.removed": "Removed",
|
|
45
|
+
"navigation.item.badge.draft": "Draft",
|
|
46
|
+
"navigation.item.badge.published": "Published"
|
|
47
|
+
}
|
|
48
|
+
|
|
@@ -31,9 +31,15 @@
|
|
|
31
31
|
"popup.item.form.button.update": "Modifier l'élément",
|
|
32
32
|
"popup.item.form.button.restore": "Restaurer l'élément",
|
|
33
33
|
"popup.item.form.button.remove": "Supprimer",
|
|
34
|
+
"popup.item.form.button.save": "Sauvegarder",
|
|
35
|
+
"popup.item.form.button.cancel": "Annuler",
|
|
34
36
|
"notification.navigation.submit": "Les modifications de navigation ont été enregistrées",
|
|
35
37
|
"notification.navigation.error": "Chemin indisponible: { path } dans le parent: { parentTitle } pour l'élément { errorTitles }",
|
|
36
38
|
"notification.navigation.item.relation": "L'entitée n'a pas de relations!",
|
|
37
39
|
"notification.navigation.item.relation.status.draft": "brouillon",
|
|
38
|
-
"notification.navigation.item.relation.status.published": "publié"
|
|
40
|
+
"notification.navigation.item.relation.status.published": "publié",
|
|
41
|
+
"navigation.item.action.newItem": "Nouvel élément imbriqué",
|
|
42
|
+
"navigation.item.badge.removed": "Supprimé",
|
|
43
|
+
"navigation.item.badge.draft": "Brouillon",
|
|
44
|
+
"navigation.item.badge.published": "Publié"
|
|
39
45
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-navigation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "Strapi - Navigation plugin",
|
|
5
5
|
"strapi": {
|
|
6
|
-
"name": "
|
|
6
|
+
"name": "navigation",
|
|
7
7
|
"icon": "hamburger",
|
|
8
|
-
"description": "UI navigation management"
|
|
8
|
+
"description": "UI navigation management",
|
|
9
|
+
"kind": "plugin"
|
|
9
10
|
},
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
@@ -27,9 +28,6 @@
|
|
|
27
28
|
"reactstrap": "8.4.1",
|
|
28
29
|
"redux-saga": "^0.16.0",
|
|
29
30
|
"request": "^2.83.0",
|
|
30
|
-
"strapi-helper-plugin": "3.6.5",
|
|
31
|
-
"strapi-utils": "3.6.5",
|
|
32
|
-
"uuidv4": "^6.2.6",
|
|
33
31
|
"slugify": "^1.4.5",
|
|
34
32
|
"pluralize": "^8.0.0"
|
|
35
33
|
},
|
|
@@ -50,6 +48,16 @@
|
|
|
50
48
|
"name": "VirtusLab // Mateusz Ziarko",
|
|
51
49
|
"email": "mziarko@virtuslab.com",
|
|
52
50
|
"url": "https://virtuslab.com"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "VirtusLab // Maksymilian Pamuła",
|
|
54
|
+
"email": "mpamula@virtuslab.com",
|
|
55
|
+
"url": "https://virtuslab.com"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "VirtusLab // Maciej Witkowski",
|
|
59
|
+
"email": "mwitkowski@virtuslab.com",
|
|
60
|
+
"url": "https://virtuslab.com"
|
|
53
61
|
}
|
|
54
62
|
],
|
|
55
63
|
"engines": {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { isEmpty } = require("lodash");
|
|
2
|
+
|
|
3
|
+
module.exports = async ({ strapi }) => {
|
|
4
|
+
// Check if the plugin users-permissions is installed because the navigation needs it
|
|
5
|
+
if (Object.keys(strapi.plugins).indexOf("users-permissions") === -1) {
|
|
6
|
+
throw new Error(
|
|
7
|
+
"In order to make the navigation plugin work the users-permissions plugin is required",
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
// Add permissions
|
|
11
|
+
const actions = [
|
|
12
|
+
{
|
|
13
|
+
section: "plugins",
|
|
14
|
+
displayName: "Access the Navigation",
|
|
15
|
+
uid: "read",
|
|
16
|
+
pluginName: "navigation",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
section: "plugins",
|
|
20
|
+
displayName: "Ability to change the Navigation",
|
|
21
|
+
uid: "update",
|
|
22
|
+
pluginName: "navigation",
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const navigations = await strapi
|
|
27
|
+
.query("plugin::navigation.navigation")
|
|
28
|
+
.findMany();
|
|
29
|
+
if (isEmpty(navigations)) {
|
|
30
|
+
await strapi
|
|
31
|
+
.query("plugin::navigation.navigation")
|
|
32
|
+
.create({
|
|
33
|
+
data: {
|
|
34
|
+
name: 'Main navigation',
|
|
35
|
+
slug: 'main-navigation',
|
|
36
|
+
visible: true,
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
await strapi.admin.services.permission.actionProvider.registerMany(actions);
|
|
41
|
+
};
|
package/server/config.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
const navigationsItemsRelated = require("./navigations-items-related");
|
|
4
|
+
const navigationItem = require("./navigation-item");
|
|
5
|
+
const navigation = require("./navigation");
|
|
6
|
+
const audience = require("./audience");
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
audience,
|
|
10
|
+
navigation,
|
|
11
|
+
"navigation-item": navigationItem,
|
|
12
|
+
"navigations-items-related": navigationsItemsRelated
|
|
13
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
collectionName: "navigations",
|
|
3
|
+
info: {
|
|
4
|
+
singularName: "navigation",
|
|
5
|
+
pluralName: "navigations",
|
|
6
|
+
displayName: "Navigation",
|
|
7
|
+
name: "navigation"
|
|
8
|
+
},
|
|
9
|
+
options: {
|
|
10
|
+
increments: true,
|
|
11
|
+
comment: ""
|
|
12
|
+
},
|
|
13
|
+
pluginOptions: {
|
|
14
|
+
"content-manager": {
|
|
15
|
+
visible: true
|
|
16
|
+
},
|
|
17
|
+
"content-type-builder": {
|
|
18
|
+
visible: false
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
attributes: {
|
|
22
|
+
name: {
|
|
23
|
+
type: "text",
|
|
24
|
+
configurable: false,
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
slug: {
|
|
28
|
+
type: "uid",
|
|
29
|
+
target: "name",
|
|
30
|
+
configurable: false,
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
visible: {
|
|
34
|
+
type: "boolean",
|
|
35
|
+
default: false,
|
|
36
|
+
configurable: false
|
|
37
|
+
},
|
|
38
|
+
items: {
|
|
39
|
+
type: "relation",
|
|
40
|
+
relation: "oneToMany",
|
|
41
|
+
target: "plugin::navigation.navigation-item",
|
|
42
|
+
configurable: false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
File without changes
|