strapi-plugin-navigation 2.0.0 → 2.0.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 +16 -1
- package/admin/src/components/Item/ItemCardBadge/index.js +1 -1
- package/admin/src/components/Item/index.js +0 -1
- package/admin/src/pages/View/components/NavigationItemForm/index.js +34 -6
- package/admin/src/translations/en.json +1 -1
- package/package.json +1 -1
- package/server/services/navigation.js +1 -1
- package/.circleci/config.yml +0 -48
- package/.eslintrc +0 -35
- package/.github/pull_request_template.md +0 -13
- package/.github/stale.yml +0 -15
- package/.nvmrc +0 -1
- package/codecov.yml +0 -3
- package/public/assets/logo.png +0 -0
- package/public/assets/preview.png +0 -0
package/README.md
CHANGED
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
<a href="https://codecov.io/gh/VirtusLab/strapi-plugin-navigation">
|
|
17
17
|
<img src="https://codecov.io/gh/VirtusLab/strapi-plugin-navigation/coverage.svg?branch=master" alt="codecov.io" />
|
|
18
18
|
</a>
|
|
19
|
+
<a href="https://sharing.clickup.com/tl/xhcmx-43/strapiv-4-navigation-roadmap">
|
|
20
|
+
<img src="https://img.shields.io/website?down_message=roadmap&label=product&up_message=roadmap&url=https%3A%2F%2Fsharing.clickup.com%2Ftl%2Fxhcmx-43%2Fstrapiv-4-navigation-roadmap" />
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://sharing.clickup.com/b/6-169004201-2/strapiv-4-navigation-board">
|
|
23
|
+
<img src="https://img.shields.io/website?down_message=board&label=product&up_color=blue&up_message=board&url=https%3A%2F%2Fsharing.clickup.com%2Fb%2F6-169004201-2%2Fstrapiv-4-navigation-board" />
|
|
24
|
+
</a>
|
|
19
25
|
</div>
|
|
20
26
|
|
|
21
27
|
---
|
|
@@ -35,10 +41,10 @@ Strapi Navigation Plugin provides a website navigation / menu builder feature fo
|
|
|
35
41
|
- **Navigation Public API:** Simple and ready for use API endpoint for consuming the navigation structure you've created
|
|
36
42
|
- **Visual builder:** Elegant and easy to use visual builder
|
|
37
43
|
- **Any Content Type relation:** Navigation can by linked to any of your Content Types by default. Simply, you're controlling it and also limiting available content types by configuration props
|
|
44
|
+
- **Multiple navigations:** Create as many Navigation containers as you want, setup them and use in the consumer application
|
|
38
45
|
- **Customizable:** Possibility to customize the options like: available Content Types, Maximum level for "attach to menu", Additional fields (audience)
|
|
39
46
|
- **[Audit log](https://github.com/VirtusLab/strapi-molecules/tree/master/packages/strapi-plugin-audit-log):** integration with Strapi Molecules Audit Log plugin that provides changes track record
|
|
40
47
|
|
|
41
|
-
|
|
42
48
|
## ⚙️ Versions
|
|
43
49
|
|
|
44
50
|
- **Strapi v4** - (current) - [v2.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation)
|
|
@@ -389,6 +395,15 @@ Live example of plugin usage can be found in the [VirtusLab Strapi Examples](htt
|
|
|
389
395
|
|
|
390
396
|
## 🤝 Contributing
|
|
391
397
|
|
|
398
|
+
<div>
|
|
399
|
+
<a href="https://sharing.clickup.com/tl/xhcmx-43/strapiv-4-navigation-roadmap">
|
|
400
|
+
<img src="https://img.shields.io/website?down_message=roadmap&label=product&up_message=roadmap&url=https%3A%2F%2Fsharing.clickup.com%2Ftl%2Fxhcmx-43%2Fstrapiv-4-navigation-roadmap" />
|
|
401
|
+
</a>
|
|
402
|
+
<a href="https://sharing.clickup.com/b/6-169004201-2/strapiv-4-navigation-board">
|
|
403
|
+
<img src="https://img.shields.io/website?down_message=board&label=product&up_color=blue&up_message=board&url=https%3A%2F%2Fsharing.clickup.com%2Fb%2F6-169004201-2%2Fstrapiv-4-navigation-board" />
|
|
404
|
+
</a>
|
|
405
|
+
</div>
|
|
406
|
+
|
|
392
407
|
Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!
|
|
393
408
|
|
|
394
409
|
## 👨💻 Community support
|
|
@@ -5,7 +5,7 @@ const ItemCardBadge = styled(Badge)`
|
|
|
5
5
|
border: 1px solid ${({ theme, borderColor }) => theme.colors[borderColor]};
|
|
6
6
|
|
|
7
7
|
${ props => props.small && `
|
|
8
|
-
padding:
|
|
8
|
+
padding: ${props.theme.spaces[1]};
|
|
9
9
|
margin: 0px ${props.theme.spaces[3]};
|
|
10
10
|
vertical-align: middle;
|
|
11
11
|
|
|
@@ -150,7 +150,6 @@ Item.propTypes = {
|
|
|
150
150
|
uiRouterKey: PropTypes.string,
|
|
151
151
|
path: PropTypes.string,
|
|
152
152
|
externalPath: PropTypes.string,
|
|
153
|
-
audience: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
|
154
153
|
related: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
155
154
|
menuAttached: PropTypes.bool
|
|
156
155
|
}).isRequired,
|
|
@@ -6,18 +6,19 @@ import { Formik } from 'formik'
|
|
|
6
6
|
|
|
7
7
|
// Design System
|
|
8
8
|
import { ModalBody } from '@strapi/design-system/ModalLayout';
|
|
9
|
+
import { Select, Option } from '@strapi/design-system/Select';
|
|
9
10
|
import { Grid, GridItem } from '@strapi/design-system/Grid';
|
|
10
11
|
import { Form, GenericInput } from '@strapi/helper-plugin';
|
|
11
12
|
|
|
12
13
|
import { NavigationItemPopupFooter } from '../NavigationItemPopup/NavigationItemPopupFooter';
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
import { navigationItemType } from '../../utils/enums';
|
|
16
|
+
import { navigationItemAdditionalFields, navigationItemType } from '../../utils/enums';
|
|
16
17
|
import slugify from 'slugify';
|
|
17
18
|
import { extractRelatedItemLabel } from '../../utils/parsers';
|
|
18
19
|
import { form as formDefinition } from './utils/form';
|
|
19
20
|
import { checkFormValidity } from '../../utils/form';
|
|
20
|
-
import { getTradId } from '../../../../translations';
|
|
21
|
+
import { getTradId, getTrad } from '../../../../translations';
|
|
21
22
|
|
|
22
23
|
const NavigationItemForm = ({
|
|
23
24
|
isLoading,
|
|
@@ -52,22 +53,29 @@ const NavigationItemForm = ({
|
|
|
52
53
|
...data,
|
|
53
54
|
type: data.type || navigationItemType.INTERNAL,
|
|
54
55
|
related: data.related?.value,
|
|
55
|
-
relatedType: data.relatedType?.value
|
|
56
|
+
relatedType: data.relatedType?.value,
|
|
57
|
+
audience: data.audience?.map(item => item.id),
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
const audience = get(form, `${inputsPrefix}audience`, []);
|
|
62
|
+
const audienceOptions = availableAudience.map((item) => ({
|
|
63
|
+
value: get(item, 'id', " "),
|
|
64
|
+
label: get(item, 'name', " "),
|
|
65
|
+
}));
|
|
66
|
+
|
|
59
67
|
const generatePreviewPath = () => {
|
|
60
68
|
if (!isExternal) {
|
|
61
69
|
const value = `${data.levelPath !== '/' ? `${data.levelPath}` : ''}/${form.path !== '/' ? form.path || '' : ''}`;
|
|
62
70
|
return {
|
|
63
71
|
id: getTradId('popup.item.form.type.external.description'),
|
|
64
72
|
defaultMessage: '',
|
|
65
|
-
values: { value
|
|
73
|
+
values: { value }
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
return null;
|
|
69
77
|
};
|
|
70
|
-
|
|
78
|
+
|
|
71
79
|
const sanitizePayload = (payload = {}) => {
|
|
72
80
|
const { onItemClick, onItemLevelAddClick, related, relatedType, menuAttached, ...purePayload } = payload;
|
|
73
81
|
const sanitizedType = purePayload.type || navigationItemType.INTERNAL;
|
|
@@ -103,6 +111,10 @@ const NavigationItemForm = ({
|
|
|
103
111
|
const onTypeChange = ({ target: { name, value } }) =>
|
|
104
112
|
onChange({ target: { name, value: value ? navigationItemType.INTERNAL : navigationItemType.EXTERNAL } });
|
|
105
113
|
|
|
114
|
+
const onAudienceChange = (value) => {
|
|
115
|
+
onChange({target: {name: `${inputsPrefix}audience`, value}});
|
|
116
|
+
}
|
|
117
|
+
|
|
106
118
|
const onChange = ({ target: { name, value } }) => {
|
|
107
119
|
setFormState(prevState => ({
|
|
108
120
|
...prevState,
|
|
@@ -139,7 +151,7 @@ const NavigationItemForm = ({
|
|
|
139
151
|
.filter((item) => {
|
|
140
152
|
const usedContentTypeEntitiesOfSameType = usedContentTypeEntities
|
|
141
153
|
.filter(uctItem => relatedTypeSelectValue === uctItem.__collectionUid);
|
|
142
|
-
return !find(usedContentTypeEntitiesOfSameType, uctItem => (item.id === uctItem.id && uctItem.id !== form.related));
|
|
154
|
+
return !find(usedContentTypeEntitiesOfSameType, uctItem => (item.id === uctItem.id && uctItem.id !== form.related));
|
|
143
155
|
})
|
|
144
156
|
.map((item) => {
|
|
145
157
|
const label = appendLabelPublicationStatus(
|
|
@@ -380,6 +392,22 @@ const NavigationItemForm = ({
|
|
|
380
392
|
)}
|
|
381
393
|
</>
|
|
382
394
|
)}
|
|
395
|
+
|
|
396
|
+
{additionalFields.includes(navigationItemAdditionalFields.AUDIENCE) && (
|
|
397
|
+
<GridItem key={`${inputsPrefix}audience`} col={6} lg={12}>
|
|
398
|
+
<Select
|
|
399
|
+
id={`${inputsPrefix}audience`}
|
|
400
|
+
placeholder={formatMessage(getTrad('popup.item.form.audience.placeholder'))}
|
|
401
|
+
label={formatMessage(getTrad('popup.item.form.audience.label'))}
|
|
402
|
+
onChange={onAudienceChange}
|
|
403
|
+
value={audience}
|
|
404
|
+
multi
|
|
405
|
+
withTags
|
|
406
|
+
>
|
|
407
|
+
{audienceOptions.map(({ value, label }) => <Option key={value} value={value}>{label}</Option>)}
|
|
408
|
+
</Select>
|
|
409
|
+
</GridItem>
|
|
410
|
+
)}
|
|
383
411
|
</Grid>
|
|
384
412
|
</ModalBody>
|
|
385
413
|
</Form>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"popup.item.form.type.external.label": "External source",
|
|
26
26
|
"popup.item.form.type.external.description": "Output path: {value}",
|
|
27
27
|
"popup.item.form.audience.label": "Audience",
|
|
28
|
-
"popup.item.form.audience.placeholder": "
|
|
28
|
+
"popup.item.form.audience.placeholder": "Select audience...",
|
|
29
29
|
"popup.item.form.relatedSection.label": "Relation to",
|
|
30
30
|
"popup.item.form.relatedType.label": "Content Type",
|
|
31
31
|
"popup.item.form.relatedType.placeholder": "Select content type...",
|
package/package.json
CHANGED
package/.circleci/config.yml
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
version: 2.1
|
|
2
|
-
orbs:
|
|
3
|
-
codecov: codecov/codecov@1.1.1
|
|
4
|
-
jobs:
|
|
5
|
-
build-and-test:
|
|
6
|
-
environment:
|
|
7
|
-
CODECOV_TOKEN: a9097475-0b5b-481f-8733-7b84574d583e
|
|
8
|
-
docker:
|
|
9
|
-
- image: circleci/node:14.17.2
|
|
10
|
-
working_directory: ~/repo
|
|
11
|
-
steps:
|
|
12
|
-
- checkout
|
|
13
|
-
- run:
|
|
14
|
-
name: set GIT name and email
|
|
15
|
-
command: |
|
|
16
|
-
git config --global -l
|
|
17
|
-
git config --global user.email "$GIT_COMMITTER_EMAIL"
|
|
18
|
-
git config --global user.name "$GIT_COMMITTER_NAME"
|
|
19
|
-
git config --global -l
|
|
20
|
-
- restore_cache:
|
|
21
|
-
keys:
|
|
22
|
-
# when lock file changes, use increasingly general patterns to restore cache
|
|
23
|
-
- strapi-plugin-navigation-v1-{{ checksum "yarn.lock" }}
|
|
24
|
-
- strapi-plugin-navigation-
|
|
25
|
-
- run:
|
|
26
|
-
name: Echo versions
|
|
27
|
-
command: |
|
|
28
|
-
node --version
|
|
29
|
-
yarn --version
|
|
30
|
-
- run:
|
|
31
|
-
name: Install
|
|
32
|
-
command: |
|
|
33
|
-
yarn install
|
|
34
|
-
- run:
|
|
35
|
-
name: Test
|
|
36
|
-
command: |
|
|
37
|
-
yarn test:unit
|
|
38
|
-
- codecov/upload:
|
|
39
|
-
flags: unittest
|
|
40
|
-
file:
|
|
41
|
-
- save_cache:
|
|
42
|
-
paths:
|
|
43
|
-
- ./node_modules
|
|
44
|
-
key: strapi-plugin-navigation-v1-{{ checksum "yarn.lock" }}
|
|
45
|
-
workflows:
|
|
46
|
-
build-and-test:
|
|
47
|
-
jobs:
|
|
48
|
-
- build-and-test
|
package/.eslintrc
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"parserOptions": {
|
|
3
|
-
"jsx": true,
|
|
4
|
-
"useJSXTextNode": true,
|
|
5
|
-
"sourceType": "module"
|
|
6
|
-
},
|
|
7
|
-
"plugins": ["react-hooks", "import"],
|
|
8
|
-
"rules": {
|
|
9
|
-
"no-console": "warn",
|
|
10
|
-
"curly": "warn",
|
|
11
|
-
"prefer-template": "warn",
|
|
12
|
-
|
|
13
|
-
"react-hooks/rules-of-hooks": "error",
|
|
14
|
-
"react-hooks/exhaustive-deps": "error",
|
|
15
|
-
|
|
16
|
-
"import/no-default-export": "warn",
|
|
17
|
-
"import/newline-after-import": "warn",
|
|
18
|
-
"import/order": [
|
|
19
|
-
"warn",
|
|
20
|
-
{
|
|
21
|
-
"newlines-between": "always",
|
|
22
|
-
"alphabetize": { "order": "asc" },
|
|
23
|
-
"pathGroupsExcludedImportTypes": ["builtin"],
|
|
24
|
-
"groups": [
|
|
25
|
-
"builtin",
|
|
26
|
-
"external",
|
|
27
|
-
"internal",
|
|
28
|
-
"parent",
|
|
29
|
-
"sibling",
|
|
30
|
-
"index"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
## Ticket
|
|
2
|
-
|
|
3
|
-
https://github.com/VirtusLab/strapi-plugin-navigation/issues/-<your-ticket-#>
|
|
4
|
-
|
|
5
|
-
## Summary
|
|
6
|
-
|
|
7
|
-
What does this PR do/solve?
|
|
8
|
-
|
|
9
|
-
> PRs should be as small as they need to be, if this section starts becoming a novel you should _seriously_ consider breaking it up into multiple PRs
|
|
10
|
-
|
|
11
|
-
## Test Plan
|
|
12
|
-
|
|
13
|
-
How are you testing the work you're submitting?
|
package/.github/stale.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
daysUntilStale: 30
|
|
2
|
-
daysUntilClose: 7
|
|
3
|
-
exemptLabels:
|
|
4
|
-
- pinned
|
|
5
|
-
- security
|
|
6
|
-
- backlog
|
|
7
|
-
- enhancement
|
|
8
|
-
- feature request
|
|
9
|
-
staleLabel: wontfix
|
|
10
|
-
# Comment to post when marking an issue as stale. Set to `false` to disable
|
|
11
|
-
markComment: >
|
|
12
|
-
This issue has been automatically marked as stale because it has not had
|
|
13
|
-
recent activity. It will be closed if no further activity occurs. Thank you
|
|
14
|
-
for your contributions.
|
|
15
|
-
closeComment: false
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v14.17.3
|
package/codecov.yml
DELETED
package/public/assets/logo.png
DELETED
|
Binary file
|
|
Binary file
|