strapi-plugin-navigation 1.0.4 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- 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 +81 -85
- package/admin/src/{containers → pages}/DataManagerProvider/init.js +0 -0
- package/admin/src/{containers → pages}/DataManagerProvider/reducer.js +0 -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 +1 -1
- 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 +19 -19
- package/admin/src/pluginId.js +4 -3
- 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 +13 -5
- package/{config/functions → server}/bootstrap.js +10 -11
- 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/server/content-types/navigation-item/lifecycle.js +34 -0
- package/{models/navigationItem.settings.json → server/content-types/navigation-item/schema.json} +29 -14
- package/server/content-types/navigations-items-related/index.js +9 -0
- package/server/content-types/navigations-items-related/lifecycle.js +19 -0
- package/server/content-types/navigations-items-related/schema.json +47 -0
- package/server/controllers/index.js +7 -0
- package/server/controllers/navigation.js +51 -0
- package/server/routes/admin.js +38 -0
- package/server/routes/index.js +3 -0
- package/server/services/__tests__/navigation.test.js +84 -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 -89
- 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/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/routes.json +0 -60
- package/config/schema.graphql.js +0 -205
- package/controllers/navigation.js +0 -85
- package/examples/audit-log-integrations.js.md +0 -38
- package/models/navigation.settings.json +0 -43
- package/models/navigationItem.js +0 -16
- package/public/assets/preview.png +0 -0
- package/services/__tests__/navigation.test.js +0 -85
- package/services/navigation.js +0 -638
- package/services/utils/functions.js +0 -186
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
isArray,
|
|
3
|
-
isEmpty,
|
|
4
|
-
isObject,
|
|
5
|
-
isString,
|
|
6
|
-
first,
|
|
7
|
-
find,
|
|
8
|
-
flatten,
|
|
9
|
-
get,
|
|
10
|
-
kebabCase,
|
|
11
|
-
last,
|
|
12
|
-
} = require('lodash');
|
|
13
|
-
|
|
14
|
-
const { type: itemType } = require('../../models/navigationItem');
|
|
15
|
-
const { NavigationError } = require('../../utils/NavigationError');
|
|
16
|
-
const { TEMPLATE_DEFAULT } = require('./constant');
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
extractMeta(plugins) {
|
|
20
|
-
const { navigation: plugin } = plugins;
|
|
21
|
-
const { navigation: service } = plugin.services;
|
|
22
|
-
const {
|
|
23
|
-
navigation: masterModel,
|
|
24
|
-
navigationitem: itemModel,
|
|
25
|
-
audience: audienceModel,
|
|
26
|
-
} = plugin.models;
|
|
27
|
-
return {
|
|
28
|
-
masterModel,
|
|
29
|
-
itemModel,
|
|
30
|
-
audienceModel,
|
|
31
|
-
service,
|
|
32
|
-
plugin,
|
|
33
|
-
pluginName: plugin.package.strapi.name.toLowerCase(),
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
singularize(value = '') {
|
|
38
|
-
return last(value) === 's' ? value.substr(0, value.length - 1) : value;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
checkDuplicatePath(parentItem, checkData) {
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
if (parentItem && parentItem.items) {
|
|
44
|
-
for (let item of checkData) {
|
|
45
|
-
for (let _ of parentItem.items) {
|
|
46
|
-
if (_.path === item.path && (_.id !== item.id) && (item.type === itemType.INTERNAL)) {
|
|
47
|
-
return reject(
|
|
48
|
-
new NavigationError(
|
|
49
|
-
`Duplicate path:${item.path} in parent: ${parentItem.title || 'root'} for ${item.title} and ${_.title} items`,
|
|
50
|
-
{
|
|
51
|
-
parentTitle: parentItem.title,
|
|
52
|
-
parentId: parentItem.id,
|
|
53
|
-
path: item.path,
|
|
54
|
-
errorTitles: [item.title, _.title],
|
|
55
|
-
},
|
|
56
|
-
),
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return resolve();
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
buildNestedStructure(entities, id = null, field = 'parent') {
|
|
67
|
-
return entities
|
|
68
|
-
.filter(entity => {
|
|
69
|
-
if (entity[field] === null && id === null) {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
let data = entity[field];
|
|
73
|
-
if (data && typeof id === 'string') {
|
|
74
|
-
data = data.toString();
|
|
75
|
-
}
|
|
76
|
-
return (data && data === id) || (isObject(entity[field]) && (entity[field].id === id));
|
|
77
|
-
})
|
|
78
|
-
.map(entity => {
|
|
79
|
-
return ({
|
|
80
|
-
...entity,
|
|
81
|
-
related: !isEmpty(entity.related) ? [last(entity.related)] : entity.related,
|
|
82
|
-
items: this.buildNestedStructure(entities, entity.id, field),
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
async templateNameFactory(items, strapi, contentTypes = []) {
|
|
88
|
-
const flatRelated = flatten(items.map(i => i.related));
|
|
89
|
-
const relatedMap = flatRelated.reduce((acc, curr) => {
|
|
90
|
-
if (!acc[curr.__contentType]) {
|
|
91
|
-
acc[curr.__contentType] = [];
|
|
92
|
-
}
|
|
93
|
-
acc[curr.__contentType].push(curr.id);
|
|
94
|
-
return acc;
|
|
95
|
-
}, {});
|
|
96
|
-
const responses = await Promise.all(
|
|
97
|
-
Object.entries(relatedMap)
|
|
98
|
-
.map(
|
|
99
|
-
([contentType, ids]) => {
|
|
100
|
-
const contentTypeName = kebabCase(contentType);
|
|
101
|
-
const contentTypeUid = get(find(contentTypes, cnt => cnt.contentTypeName === contentTypeName), 'uid') || contentTypeName;
|
|
102
|
-
return strapi.query(contentTypeUid)
|
|
103
|
-
.find({ id_in: ids, _limit: -1 })
|
|
104
|
-
.then(res => ({ [contentType]: res }))
|
|
105
|
-
}),
|
|
106
|
-
);
|
|
107
|
-
const relatedResponseMap = responses.reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
108
|
-
const singleTypes = new Map(
|
|
109
|
-
contentTypes
|
|
110
|
-
.filter(x => x.isSingle)
|
|
111
|
-
.map(({ contentTypeName, templateName }) => [contentTypeName, templateName || contentTypeName])
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
return (contentType, id) => {
|
|
115
|
-
const template = get(relatedResponseMap[contentType].find(data => data.id === id), 'template');
|
|
116
|
-
|
|
117
|
-
if (template) {
|
|
118
|
-
const templateComponent = this.getTemplateComponentFromTemplate(template);
|
|
119
|
-
return get(templateComponent, 'options.templateName', TEMPLATE_DEFAULT);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (singleTypes.get(contentType)) {
|
|
123
|
-
return singleTypes.get(contentType);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return TEMPLATE_DEFAULT;
|
|
127
|
-
};
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
getTemplateComponentFromTemplate(template = []) {
|
|
131
|
-
const componentName = get(first(template), '__component');
|
|
132
|
-
return componentName ? strapi.components[componentName] : null;
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
sendAuditLog(auditLogInstance, event, data) {
|
|
136
|
-
if (auditLogInstance && auditLogInstance.emit) {
|
|
137
|
-
auditLogInstance.emit(event, data);
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
filterOutUnpublished(item) {
|
|
142
|
-
const relatedItem = item.related && last(item.related);
|
|
143
|
-
const isHandledByPublshFlow = relatedItem ? 'published_at' in relatedItem : false;
|
|
144
|
-
|
|
145
|
-
if (isHandledByPublshFlow) {
|
|
146
|
-
const isRelatedDefinedAndPublished = relatedItem ?
|
|
147
|
-
isHandledByPublshFlow && get(relatedItem, 'published_at') :
|
|
148
|
-
false;
|
|
149
|
-
return item.type === itemType.INTERNAL ? isRelatedDefinedAndPublished : true;
|
|
150
|
-
}
|
|
151
|
-
return (item.type === itemType.EXTERNAL) || relatedItem;
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
composeItemTitle(item = {}, fields = {}, contentTypes = []) {
|
|
155
|
-
const { title, related } = item;
|
|
156
|
-
if (title) {
|
|
157
|
-
return isString(title) && !isEmpty(title) ? title : undefined;
|
|
158
|
-
} else if (related) {
|
|
159
|
-
const relationTitle = this.extractItemRelationTitle(isArray(related) ? last(related) : related, fields, { contentTypes });
|
|
160
|
-
return isString(relationTitle) && !isEmpty(relationTitle) ? relationTitle : undefined;
|
|
161
|
-
}
|
|
162
|
-
return undefined;
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
extractItemRelationTitle(relatedItem = {}, fields = {}, contentTypes = []) {
|
|
166
|
-
const { __contentType } = relatedItem;
|
|
167
|
-
const contentType = find(contentTypes, _ => _.contentTypeName === __contentType);
|
|
168
|
-
const { default: defaultFields = [] } = fields;
|
|
169
|
-
return get(fields, `${contentType ? contentType.collectionName : ''}`, defaultFields).map((_) => relatedItem[_]).filter((_) => _)[0] || '';
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
prepareAuditLog(actions) {
|
|
173
|
-
return [
|
|
174
|
-
...new Set(
|
|
175
|
-
actions
|
|
176
|
-
.filter(_ => !!_)
|
|
177
|
-
.flatMap(({ remove, create, update }) => {
|
|
178
|
-
return [create ? 'CREATE' : '', update ? 'UPDATE' : '', remove ? 'REMOVE' : '']
|
|
179
|
-
.filter(_ => !!_);
|
|
180
|
-
}),
|
|
181
|
-
),
|
|
182
|
-
]
|
|
183
|
-
.join('_');
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
};
|