strapi-plugin-navigation 2.0.11 → 2.0.12
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/admin/src/components/Alert/styles.js +8 -0
- package/admin/src/components/Item/ItemCardHeader/index.js +1 -1
- package/admin/src/pages/SettingsPage/index.js +23 -5
- package/admin/src/pages/View/utils/parsers.js +3 -2
- package/admin/src/translations/en.json +2 -0
- package/package.json +1 -1
- package/server/services/navigation.js +8 -5
|
@@ -18,7 +18,7 @@ justify-content: center;
|
|
|
18
18
|
height: ${32 / 16}rem;
|
|
19
19
|
width: ${32 / 16}rem;
|
|
20
20
|
|
|
21
|
-
cursor:
|
|
21
|
+
cursor: move;
|
|
22
22
|
padding: ${({ theme }) => theme.spaces[2]};
|
|
23
23
|
border-radius: ${({ theme }) => theme.borderRadius};
|
|
24
24
|
background: ${({ theme }) => theme.colors.neutral0};
|
|
@@ -22,7 +22,7 @@ import { ToggleInput } from '@strapi/design-system/ToggleInput';
|
|
|
22
22
|
import { NumberInput } from '@strapi/design-system/NumberInput';
|
|
23
23
|
import { Select, Option } from '@strapi/design-system/Select';
|
|
24
24
|
import { Tooltip } from '@strapi/design-system/Tooltip';
|
|
25
|
-
import { Check, Refresh, Play, Information } from '@strapi/icons';
|
|
25
|
+
import { Check, Refresh, Play, Information, ExclamationMarkCircle } from '@strapi/icons';
|
|
26
26
|
|
|
27
27
|
import permissions from '../../permissions';
|
|
28
28
|
import useNavigationConfig from '../../hooks/useNavigationConfig';
|
|
@@ -32,6 +32,7 @@ import ConfirmationDialog from '../../components/ConfirmationDialog';
|
|
|
32
32
|
import RestartAlert from '../../components/RestartAlert';
|
|
33
33
|
import { getMessage } from '../../utils';
|
|
34
34
|
import { isContentTypeEligible, resolveGlobalLikeId } from './utils/functions';
|
|
35
|
+
import { PermanentAlert } from '../../components/Alert/styles';
|
|
35
36
|
|
|
36
37
|
const SettingsPage = () => {
|
|
37
38
|
const { lockApp, unlockApp } = useOverlayBlocker();
|
|
@@ -109,11 +110,24 @@ const SettingsPage = () => {
|
|
|
109
110
|
)
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
const configContentTypes = navigationConfigData?.contentTypes || [];
|
|
114
|
+
|
|
112
115
|
const allContentTypes = !isLoading && Object.values(allContentTypesData).filter(({ uid }) => isContentTypeEligible(uid, {
|
|
113
116
|
allowedContentTypes: navigationConfigData?.allowedContentTypes,
|
|
114
117
|
restrictedContentTypes: navigationConfigData?.restrictedContentTypes,
|
|
115
|
-
}))
|
|
116
|
-
|
|
118
|
+
})).map(ct => {
|
|
119
|
+
const type = configContentTypes.find(_ => _.uid === ct.uid);
|
|
120
|
+
if (type) {
|
|
121
|
+
const { available, isSingle } = type;
|
|
122
|
+
return {
|
|
123
|
+
...ct,
|
|
124
|
+
available,
|
|
125
|
+
isSingle,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return ct;
|
|
129
|
+
});
|
|
130
|
+
const selectedContentTypes = configContentTypes.map(item => item.uid);
|
|
117
131
|
const audienceFieldChecked = navigationConfigData?.additionalFields.includes(navigationItemAdditionalFields.AUDIENCE);
|
|
118
132
|
const allowedLevels = navigationConfigData?.allowedLevels || 2;
|
|
119
133
|
const nameFields = navigationConfigData?.contentTypesNameFields || {}
|
|
@@ -188,7 +202,7 @@ const SettingsPage = () => {
|
|
|
188
202
|
<Information aria-hidden={true} />
|
|
189
203
|
</Tooltip>}>
|
|
190
204
|
{orderBy(values.selectedContentTypes).map(uid => {
|
|
191
|
-
const { attributes, info: { displayName } } = allContentTypes.find(item => item.uid == uid);
|
|
205
|
+
const { attributes, info: { displayName }, available, isSingle } = allContentTypes.find(item => item.uid == uid);
|
|
192
206
|
const stringAttributes = Object.keys(attributes).filter(_ => attributes[_].type === 'string');
|
|
193
207
|
const relationAttributes = Object.keys(attributes).filter(_ => attributes[_].type === 'relation');
|
|
194
208
|
const key = `collectionSettings-${uid}`;
|
|
@@ -198,10 +212,14 @@ const SettingsPage = () => {
|
|
|
198
212
|
key={key}
|
|
199
213
|
id={key}
|
|
200
214
|
size="S">
|
|
201
|
-
<AccordionToggle title={displayName} togglePosition="left" />
|
|
215
|
+
<AccordionToggle title={displayName} togglePosition="left" startIcon={(isSingle && !available) && (<ExclamationMarkCircle aria-hidden={true} />)} />
|
|
202
216
|
<AccordionContent>
|
|
203
217
|
<Box padding={6}>
|
|
204
218
|
<Stack spacing={4}>
|
|
219
|
+
{ (isSingle && !available) && (
|
|
220
|
+
<PermanentAlert title={getMessage('pages.settings.form.contentTypesSettings.initializationWarning.title')} variant="danger" onClose={(e) => e.preventDefault()}>
|
|
221
|
+
{ getMessage('pages.settings.form.contentTypesSettings.initializationWarning.content') }
|
|
222
|
+
</PermanentAlert>)}
|
|
205
223
|
<Select
|
|
206
224
|
name={`collectionSettings-${uid}-entryLabel`}
|
|
207
225
|
label={getMessage('pages.settings.form.nameField.label')}
|
|
@@ -25,6 +25,7 @@ export const transformItemToRESTPayload = (
|
|
|
25
25
|
audience = [],
|
|
26
26
|
items = [],
|
|
27
27
|
collapsed,
|
|
28
|
+
isSingle
|
|
28
29
|
} = item;
|
|
29
30
|
const isExternal = type === navigationItemType.EXTERNAL;
|
|
30
31
|
const isWrapper = type === navigationItemType.WRAPPER;
|
|
@@ -37,7 +38,7 @@ export const transformItemToRESTPayload = (
|
|
|
37
38
|
find(contentTypes,
|
|
38
39
|
ct => ct.uid === relatedType) :
|
|
39
40
|
undefined;
|
|
40
|
-
const itemAttachedToMenu = menuAttached && parentAttachedToMenu
|
|
41
|
+
const itemAttachedToMenu = menuAttached && parentAttachedToMenu;
|
|
41
42
|
return {
|
|
42
43
|
id,
|
|
43
44
|
parent,
|
|
@@ -59,7 +60,7 @@ export const transformItemToRESTPayload = (
|
|
|
59
60
|
? undefined
|
|
60
61
|
: [
|
|
61
62
|
{
|
|
62
|
-
refId: relatedId,
|
|
63
|
+
refId: isSingle && !relatedId ? 1 : relatedId,
|
|
63
64
|
ref: relatedContentType ? relatedContentType.uid : relatedType,
|
|
64
65
|
field: relatedContentType && relatedContentType.relatedField ? relatedContentType.relatedField : 'navigation',
|
|
65
66
|
},
|
|
@@ -92,6 +92,8 @@
|
|
|
92
92
|
"pages.settings.form.populate.empty": "This content type doesn't have any relation fields",
|
|
93
93
|
"pages.settings.form.contentTypesSettings.label": "Content types",
|
|
94
94
|
"pages.settings.form.contentTypesSettings.tooltip": "Custom configuration per content type",
|
|
95
|
+
"pages.settings.form.contentTypesSettings.initializationWarning.title": "Warning",
|
|
96
|
+
"pages.settings.form.contentTypesSettings.initializationWarning.content": "- Content Type hasn't yet been initialized. Initialize it first to be able to use in a Visual Editor.",
|
|
95
97
|
"components.navigationItem.action.newItem": "Add nested item",
|
|
96
98
|
"components.navigationItem.badge.removed": "Removed",
|
|
97
99
|
"components.navigationItem.badge.draft": "Draft",
|
package/package.json
CHANGED
|
@@ -79,7 +79,7 @@ module.exports = ({ strapi }) => {
|
|
|
79
79
|
restrictedContentTypes: RESTRICTED_CONTENT_TYPES,
|
|
80
80
|
};
|
|
81
81
|
const result = {
|
|
82
|
-
contentTypes: await this.configContentTypes(),
|
|
82
|
+
contentTypes: await this.configContentTypes(viaSettingsPage),
|
|
83
83
|
contentTypesNameFields: {
|
|
84
84
|
default: contentTypesNameFieldsDefaults,
|
|
85
85
|
...(isObject(contentTypesNameFields) ? contentTypesNameFields : {}),
|
|
@@ -144,7 +144,7 @@ module.exports = ({ strapi }) => {
|
|
|
144
144
|
await strapi.plugin('navigation').service('navigation').setDefaultConfig();
|
|
145
145
|
},
|
|
146
146
|
|
|
147
|
-
async configContentTypes() {
|
|
147
|
+
async configContentTypes(viaSettingsPage = false) {
|
|
148
148
|
const pluginStore = await this.getPluginStore()
|
|
149
149
|
const config = await pluginStore.get({ key: 'config' });
|
|
150
150
|
const eligibleContentTypes =
|
|
@@ -154,6 +154,7 @@ module.exports = ({ strapi }) => {
|
|
|
154
154
|
.map(
|
|
155
155
|
async (key) => {
|
|
156
156
|
const item = strapi.contentTypes[key];
|
|
157
|
+
|
|
157
158
|
const { kind, options, uid } = item;
|
|
158
159
|
const { draftAndPublish } = options;
|
|
159
160
|
|
|
@@ -175,7 +176,9 @@ module.exports = ({ strapi }) => {
|
|
|
175
176
|
return returnType(itemsCountOrBypass !== 0);
|
|
176
177
|
}
|
|
177
178
|
const isAvailable = await strapi.query(uid).count();
|
|
178
|
-
return isAvailable === 1 ?
|
|
179
|
+
return isAvailable === 1 ?
|
|
180
|
+
returnType(true) :
|
|
181
|
+
(viaSettingsPage ? returnType(false) : undefined);
|
|
179
182
|
}
|
|
180
183
|
return returnType(true);
|
|
181
184
|
},
|
|
@@ -219,7 +222,7 @@ module.exports = ({ strapi }) => {
|
|
|
219
222
|
templateName,
|
|
220
223
|
};
|
|
221
224
|
})
|
|
222
|
-
.filter((item) => item && item.available);
|
|
225
|
+
.filter((item) => viaSettingsPage || (item && item.available));
|
|
223
226
|
},
|
|
224
227
|
|
|
225
228
|
async getRelatedItems(entityItems) {
|
|
@@ -767,7 +770,7 @@ module.exports = ({ strapi }) => {
|
|
|
767
770
|
related_id: relatedItem.refId,
|
|
768
771
|
related_type: relatedItem.ref,
|
|
769
772
|
};
|
|
770
|
-
return model.delete({ where: entityToRemove })
|
|
773
|
+
return model.delete({ where: entityToRemove });
|
|
771
774
|
}));
|
|
772
775
|
},
|
|
773
776
|
|