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.
Files changed (129) hide show
  1. package/README.md +36 -15
  2. package/admin/src/components/EmptyView/index.js +7 -16
  3. package/admin/src/components/Item/ItemCardBadge/index.js +8 -0
  4. package/admin/src/components/Item/ItemCardHeader/Wrapper.js +21 -0
  5. package/admin/src/components/Item/ItemCardHeader/index.js +59 -0
  6. package/admin/src/components/Item/Wrapper.js +39 -0
  7. package/admin/src/components/Item/index.js +76 -124
  8. package/admin/src/components/NavigationItemList/Wrapper.js +22 -0
  9. package/admin/src/components/NavigationItemList/index.js +54 -0
  10. package/admin/src/components/PluginIcon/index.js +6 -0
  11. package/admin/src/index.js +49 -45
  12. package/admin/src/pages/App/index.js +31 -0
  13. package/admin/src/{containers → pages}/DataManagerProvider/actions.js +0 -0
  14. package/admin/src/{containers → pages}/DataManagerProvider/index.js +77 -84
  15. package/admin/src/{containers → pages}/DataManagerProvider/init.js +0 -0
  16. package/admin/src/pages/DataManagerProvider/reducer.js +125 -0
  17. package/admin/src/pages/View/components/NavigationContentHeader/index.js +18 -0
  18. package/admin/src/pages/View/components/NavigationHeader/index.js +60 -0
  19. package/admin/src/pages/View/components/NavigationItemForm/index.js +403 -0
  20. package/admin/src/{containers → pages}/View/components/NavigationItemForm/utils/form.js +2 -2
  21. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +40 -0
  22. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +20 -0
  23. package/admin/src/{containers → pages}/View/components/NavigationItemPopup/index.js +16 -16
  24. package/admin/src/pages/View/index.js +209 -0
  25. package/admin/src/{containers → pages}/View/utils/enums.js +0 -0
  26. package/admin/src/{containers → pages}/View/utils/form.js +1 -1
  27. package/admin/src/{containers → pages}/View/utils/index.js +0 -0
  28. package/admin/src/{containers → pages}/View/utils/parsers.js +13 -12
  29. package/admin/src/pluginId.js +3 -2
  30. package/admin/src/translations/en.json +47 -38
  31. package/admin/src/translations/fr.json +7 -1
  32. package/admin/src/utils/getTrad.js +2 -2
  33. package/package.json +14 -6
  34. package/server/bootstrap.js +41 -0
  35. package/server/config.js +8 -0
  36. package/server/content-types/audience/index.js +9 -0
  37. package/{models/audience.js → server/content-types/audience/lifecycle.js} +0 -0
  38. package/{models/audience.settings.json → server/content-types/audience/schema.json} +4 -2
  39. package/server/content-types/index.js +13 -0
  40. package/server/content-types/navigation/index.js +9 -0
  41. package/{models/navigation.js → server/content-types/navigation/lifecycle.js} +0 -0
  42. package/server/content-types/navigation/schema.js +45 -0
  43. package/server/content-types/navigation-item/index.js +9 -0
  44. package/{models/navigationItem.js → server/content-types/navigation-item/lifecycle.js} +0 -0
  45. package/{models/navigationItem.settings.json → server/content-types/navigation-item/schema.json} +16 -12
  46. package/server/content-types/navigations-items-related/index.js +9 -0
  47. package/{models/navigations_items_related.js → server/content-types/navigations-items-related/lifecycle.js} +0 -0
  48. package/{models/navigations_items_related.settings.json → server/content-types/navigations-items-related/schema.json} +4 -2
  49. package/server/controllers/index.js +7 -0
  50. package/{controllers → server/controllers}/navigation.js +7 -39
  51. package/server/routes/admin.js +38 -0
  52. package/server/routes/index.js +3 -0
  53. package/{services → server/services}/__tests__/navigation.test.js +0 -0
  54. package/server/services/index.js +7 -0
  55. package/server/services/navigation.js +463 -0
  56. package/{services → server/services}/utils/constant.js +3 -1
  57. package/server/services/utils/functions.js +103 -0
  58. package/strapi-admin.js +1 -0
  59. package/strapi-server.js +18 -0
  60. package/__mocks__/helpers/another-plugin/blog-post.settings.json +0 -31
  61. package/__mocks__/helpers/another-plugin/pages.settings.json +0 -28
  62. package/__mocks__/helpers/blog-post.settings.json +0 -31
  63. package/__mocks__/helpers/home-page.settings.json +0 -4
  64. package/__mocks__/helpers/my-homepage.settings.json +0 -27
  65. package/__mocks__/helpers/pages.settings.json +0 -27
  66. package/__mocks__/helpers/strapi.js +0 -101
  67. package/admin/src/assets/images/icon-cross-blue.svg +0 -1
  68. package/admin/src/assets/images/icon_remove.svg +0 -19
  69. package/admin/src/components/Container/index.js +0 -7
  70. package/admin/src/components/Input/index.js +0 -41
  71. package/admin/src/components/Item/CardItem.js +0 -46
  72. package/admin/src/components/Item/CardItemLevelAdd.js +0 -41
  73. package/admin/src/components/Item/CardItemLevelWrapper.js +0 -27
  74. package/admin/src/components/Item/CardItemPath.js +0 -9
  75. package/admin/src/components/Item/CardItemRestore.js +0 -19
  76. package/admin/src/components/Item/CardItemTitle.js +0 -5
  77. package/admin/src/components/Item/CardWrapper.js +0 -78
  78. package/admin/src/components/ItemFooter/CardItemError.js +0 -11
  79. package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
  80. package/admin/src/components/ItemFooter/CardItemRelationStatus.js +0 -17
  81. package/admin/src/components/ItemFooter/CardItemType.js +0 -18
  82. package/admin/src/components/ItemFooter/Wrapper.js +0 -26
  83. package/admin/src/components/ItemFooter/index.js +0 -66
  84. package/admin/src/components/ItemOrdering/CardOrderingButton.js +0 -24
  85. package/admin/src/components/ItemOrdering/Wrapper.js +0 -24
  86. package/admin/src/components/ItemOrdering/index.js +0 -36
  87. package/admin/src/components/List/Container.js +0 -34
  88. package/admin/src/components/List/ListLevelRoot.js +0 -18
  89. package/admin/src/components/List/index.js +0 -81
  90. package/admin/src/components/Option/OptionButton.js +0 -18
  91. package/admin/src/components/Option/OptionSet.js +0 -14
  92. package/admin/src/components/Option/Wrapper.js +0 -15
  93. package/admin/src/components/Option/index.js +0 -47
  94. package/admin/src/components/Search/index.js +0 -86
  95. package/admin/src/components/Select/ClearIndicator.js +0 -15
  96. package/admin/src/components/Select/DropdownIndicator.js +0 -39
  97. package/admin/src/components/Select/ErrorMessage.js +0 -10
  98. package/admin/src/components/Select/IndicatorSeparator.js +0 -3
  99. package/admin/src/components/Select/MultiValueContainer.js +0 -43
  100. package/admin/src/components/Select/StyledOption.js +0 -11
  101. package/admin/src/components/Select/index.js +0 -68
  102. package/admin/src/components/Select/utils/styles.js +0 -92
  103. package/admin/src/containers/App/Wrapper.js +0 -14
  104. package/admin/src/containers/App/index.js +0 -34
  105. package/admin/src/containers/DataManagerProvider/reducer.js +0 -136
  106. package/admin/src/containers/DetailsView/Wrapper.js +0 -21
  107. package/admin/src/containers/DetailsView/index.js +0 -111
  108. package/admin/src/containers/Initializer/index.js +0 -26
  109. package/admin/src/containers/ListView/Footer.js +0 -56
  110. package/admin/src/containers/ListView/components.js +0 -138
  111. package/admin/src/containers/ListView/index.js +0 -54
  112. package/admin/src/containers/View/FadedWrapper.js +0 -51
  113. package/admin/src/containers/View/HeaderForm.js +0 -9
  114. package/admin/src/containers/View/HeaderFormCell.js +0 -25
  115. package/admin/src/containers/View/Wrapper.js +0 -17
  116. package/admin/src/containers/View/components/NavigationItemForm/ModalFooter.js +0 -45
  117. package/admin/src/containers/View/components/NavigationItemForm/index.js +0 -427
  118. package/admin/src/containers/View/components/NavigationItemPopup/MediumPopup.js +0 -6
  119. package/admin/src/containers/View/index.js +0 -240
  120. package/admin/src/lifecycles.js +0 -3
  121. package/admin/src/permissions.js +0 -14
  122. package/config/functions/bootstrap.js +0 -138
  123. package/config/routes.json +0 -60
  124. package/config/schema.graphql.js +0 -204
  125. package/examples/audit-log-integrations.js.md +0 -38
  126. package/models/navigation.settings.json +0 -43
  127. package/public/assets/preview.png +0 -0
  128. package/services/navigation.js +0 -730
  129. 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);
@@ -1,4 +1,4 @@
1
- import { getYupInnerErrors } from 'strapi-helper-plugin';
1
+ import { getYupInnerErrors } from '@strapi/helper-plugin';
2
2
 
3
3
  export const checkFormValidity = async (data, schema) => {
4
4
  let errors = null;
@@ -1,4 +1,4 @@
1
- import { isUuid, uuid } from 'uuidv4';
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) => isObject(audienceItem) ? audienceItem.value || audienceItem.id : 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
- const { id, name, visible, items } = payload;
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
- __collectionName: relatedContentType.uid,
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
- __collectionName: uid,
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
- __collectionName: uid,
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 { __collectionName } = item;
253
- const contentType = contentTypes.find(_ => _.uid === __collectionName)
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 = relatedRef ? 'published_at' in relatedRef : false;
279
+ const isHandledByPublshFlow = relatedRef ? 'published_at' in relatedRef : false;
279
280
  if (isHandledByPublshFlow) {
280
281
  return get(relatedRef, 'published_at', true);
281
282
  }
@@ -1,4 +1,5 @@
1
- const pluginPkg = require("../../package.json");
2
- const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, "");
1
+ const pluginPkg = require('../../package.json');
2
+
3
+ const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, '');
3
4
 
4
5
  module.exports = pluginId;
@@ -1,39 +1,48 @@
1
1
  {
2
- "plugin.name": "UI Navigation",
3
- "header.title": "Navigation",
4
- "header.description": "Define your portal navigation",
5
- "submit.cta.cancel": "Cancel",
6
- "submit.cta.save": "Save",
7
- "empty": "Navigation container is empty",
8
- "empty.cta": "Create first item",
9
- "popup.item.header": "Manage navigation item",
10
- "popup.item.form.title.label": "Title",
11
- "popup.item.form.title.placeholder": "Enter the item title or leave blank to pull from related entity",
12
- "popup.item.form.uiRouterKey.label": "UI router key",
13
- "popup.item.form.uiRouterKey.placeholder": "If empty, auto generated by \"Title\"",
14
- "popup.item.form.path.label": "URL",
15
- "popup.item.form.path.placeholder": "Unique url part identifies this item",
16
- "popup.item.form.path.preview": "Preview:",
17
- "popup.item.form.externalPath.label": "External URL",
18
- "popup.item.form.externalPath.placeholder": "Link to the external source",
19
- "popup.item.form.externalPath.validation.type": "This value is not a proper url." ,
20
- "popup.item.form.menuAttached.label": "Attach to menu",
21
- "popup.item.form.type.label": "Type",
22
- "popup.item.form.type.internal.label": "Internal source",
23
- "popup.item.form.type.external.label": "External source",
24
- "popup.item.form.audience.label": "Audience",
25
- "popup.item.form.audience.placeholder": "Type to start searching...",
26
- "popup.item.form.relatedSection.label": "Relation to",
27
- "popup.item.form.relatedType.label": "Content Type",
28
- "popup.item.form.related.label": "Entity",
29
- "popup.item.form.related.empty": "There are no more entities of \"{ contentTypeName }\", you're elligible to select",
30
- "popup.item.form.button.create": "Create item",
31
- "popup.item.form.button.update": "Update item",
32
- "popup.item.form.button.restore": "Restore item",
33
- "popup.item.form.button.remove": "Remove",
34
- "notification.navigation.submit": "Navigation changes has been saved",
35
- "notification.navigation.error": "Duplicate path: { path } in parent: { parentTitle } for { errorTitles } items",
36
- "notification.navigation.item.relation": "Entity relation does not exist!",
37
- "notification.navigation.item.relation.status.draft": "draft",
38
- "notification.navigation.item.relation.status.published": "published"
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
  }
@@ -1,5 +1,5 @@
1
- import pluginId from "../pluginId";
1
+ import pluginId from '../pluginId';
2
2
 
3
- const getTrad = (id) => `${pluginId}.${id}`;
3
+ const getTrad = id => `${pluginId}.${id}`;
4
4
 
5
5
  export default getTrad;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "strapi-plugin-navigation",
3
- "version": "1.1.1",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "Strapi - Navigation plugin",
5
5
  "strapi": {
6
- "name": "Navigation",
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
+ };
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ default: {
3
+ additionalFields: [],
4
+ contentTypes: [],
5
+ contentTypesNameFields: {},
6
+ allowedLevels: 2
7
+ }
8
+ }
@@ -0,0 +1,9 @@
1
+ "use strict"
2
+
3
+ const schema = require("./schema");
4
+ const lifecycle = require("./lifecycle");
5
+
6
+ module.exports = {
7
+ lifecycle,
8
+ schema
9
+ };
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "collectionName": "audience",
3
3
  "info": {
4
- "name": "audience",
5
- "description": ""
4
+ "singularName": "audience",
5
+ "pluralName": "audiences",
6
+ "displayName": "Audience",
7
+ "name": "audience"
6
8
  },
7
9
  "options": {
8
10
  "increments": true,
@@ -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
+ };
@@ -0,0 +1,9 @@
1
+ "use strict"
2
+
3
+ const schema = require("./schema");
4
+ const lifecycle = require("./lifecycle");
5
+
6
+ module.exports = {
7
+ lifecycle,
8
+ schema
9
+ };
@@ -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
+ }
@@ -0,0 +1,9 @@
1
+ "use strict"
2
+
3
+ const schema = require("./schema");
4
+ const lifecycle = require("./lifecycle");
5
+
6
+ module.exports = {
7
+ lifecycle,
8
+ schema
9
+ };