strapi-plugin-navigation 1.1.3 → 2.0.0-beta.4

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 (149) hide show
  1. package/README.md +61 -87
  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 +78 -124
  8. package/admin/src/components/NavigationItemList/Wrapper.js +22 -0
  9. package/admin/src/components/NavigationItemList/index.js +56 -0
  10. package/admin/src/components/PluginIcon/index.js +6 -0
  11. package/admin/src/components/Search/index.js +46 -83
  12. package/admin/src/index.js +49 -45
  13. package/admin/src/pages/App/index.js +31 -0
  14. package/admin/src/{containers → pages}/DataManagerProvider/actions.js +0 -0
  15. package/admin/src/{containers → pages}/DataManagerProvider/index.js +77 -84
  16. package/admin/src/{containers → pages}/DataManagerProvider/init.js +0 -0
  17. package/admin/src/pages/DataManagerProvider/reducer.js +125 -0
  18. package/admin/src/pages/View/components/NavigationContentHeader/index.js +18 -0
  19. package/admin/src/pages/View/components/NavigationHeader/index.js +60 -0
  20. package/admin/src/pages/View/components/NavigationItemForm/index.js +403 -0
  21. package/admin/src/{containers → pages}/View/components/NavigationItemForm/utils/form.js +2 -2
  22. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +40 -0
  23. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +20 -0
  24. package/admin/src/{containers → pages}/View/components/NavigationItemPopup/index.js +16 -16
  25. package/admin/src/pages/View/index.js +221 -0
  26. package/admin/src/{containers → pages}/View/utils/enums.js +0 -0
  27. package/admin/src/{containers → pages}/View/utils/form.js +1 -1
  28. package/admin/src/{containers → pages}/View/utils/index.js +0 -0
  29. package/admin/src/{containers → pages}/View/utils/parsers.js +13 -12
  30. package/admin/src/pluginId.js +3 -2
  31. package/admin/src/translations/en.json +47 -38
  32. package/admin/src/translations/fr.json +7 -1
  33. package/admin/src/utils/getTrad.js +2 -2
  34. package/package.json +18 -7
  35. package/server/bootstrap.js +41 -0
  36. package/server/config/index.js +8 -0
  37. package/server/config.js +8 -0
  38. package/server/content-types/audience/index.js +9 -0
  39. package/{models/audience.js → server/content-types/audience/lifecycle.js} +0 -0
  40. package/{models/audience.settings.json → server/content-types/audience/schema.json} +4 -2
  41. package/server/content-types/index.js +13 -0
  42. package/server/content-types/navigation/index.js +9 -0
  43. package/{models/navigation.js → server/content-types/navigation/lifecycle.js} +0 -0
  44. package/server/content-types/navigation/schema.js +45 -0
  45. package/server/content-types/navigation-item/index.js +9 -0
  46. package/{models/navigationItem.js → server/content-types/navigation-item/lifecycle.js} +0 -0
  47. package/{models/navigationItem.settings.json → server/content-types/navigation-item/schema.json} +16 -12
  48. package/server/content-types/navigations-items-related/index.js +9 -0
  49. package/{models/navigations_items_related.js → server/content-types/navigations-items-related/lifecycle.js} +0 -0
  50. package/{models/navigations_items_related.settings.json → server/content-types/navigations-items-related/schema.json} +4 -2
  51. package/server/controllers/index.js +7 -0
  52. package/{controllers → server/controllers}/navigation.js +20 -31
  53. package/server/graphql/index.js +23 -0
  54. package/server/graphql/queries/index.js +17 -0
  55. package/server/graphql/queries/render-navigation-child.js +16 -0
  56. package/server/graphql/queries/render-navigation.js +15 -0
  57. package/server/graphql/resolvers-config.js +4 -0
  58. package/server/graphql/types/content-types-name-fields.js +8 -0
  59. package/server/graphql/types/content-types.js +16 -0
  60. package/server/graphql/types/create-navigation-item.js +17 -0
  61. package/server/graphql/types/create-navigation-related.js +8 -0
  62. package/server/graphql/types/create-navigation.js +7 -0
  63. package/server/graphql/types/index.js +15 -0
  64. package/server/graphql/types/navigation-config.js +9 -0
  65. package/server/graphql/types/navigation-details.js +10 -0
  66. package/server/graphql/types/navigation-item.js +29 -0
  67. package/server/graphql/types/navigation-related.js +23 -0
  68. package/server/graphql/types/navigation-render-type.js +4 -0
  69. package/server/graphql/types/navigation.js +9 -0
  70. package/server/register.js +5 -0
  71. package/server/routes/admin.js +38 -0
  72. package/server/routes/client.js +21 -0
  73. package/server/routes/index.js +4 -0
  74. package/{services → server/services}/__tests__/navigation.test.js +0 -0
  75. package/server/services/index.js +7 -0
  76. package/server/services/navigation.js +729 -0
  77. package/{services → server/services}/utils/constant.js +3 -1
  78. package/server/services/utils/functions.js +185 -0
  79. package/strapi-admin.js +1 -0
  80. package/strapi-server.js +20 -0
  81. package/__mocks__/helpers/another-plugin/blog-post.settings.json +0 -31
  82. package/__mocks__/helpers/another-plugin/pages.settings.json +0 -28
  83. package/__mocks__/helpers/blog-post.settings.json +0 -31
  84. package/__mocks__/helpers/home-page.settings.json +0 -4
  85. package/__mocks__/helpers/my-homepage.settings.json +0 -27
  86. package/__mocks__/helpers/pages.settings.json +0 -27
  87. package/__mocks__/helpers/strapi.js +0 -101
  88. package/admin/src/assets/images/icon-cross-blue.svg +0 -1
  89. package/admin/src/assets/images/icon_remove.svg +0 -19
  90. package/admin/src/components/Container/index.js +0 -7
  91. package/admin/src/components/Input/index.js +0 -41
  92. package/admin/src/components/Item/CardItem.js +0 -46
  93. package/admin/src/components/Item/CardItemLevelAdd.js +0 -41
  94. package/admin/src/components/Item/CardItemLevelWrapper.js +0 -27
  95. package/admin/src/components/Item/CardItemPath.js +0 -9
  96. package/admin/src/components/Item/CardItemRestore.js +0 -19
  97. package/admin/src/components/Item/CardItemTitle.js +0 -5
  98. package/admin/src/components/Item/CardWrapper.js +0 -78
  99. package/admin/src/components/ItemFooter/CardItemError.js +0 -11
  100. package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
  101. package/admin/src/components/ItemFooter/CardItemRelationStatus.js +0 -17
  102. package/admin/src/components/ItemFooter/CardItemType.js +0 -18
  103. package/admin/src/components/ItemFooter/Wrapper.js +0 -26
  104. package/admin/src/components/ItemFooter/index.js +0 -66
  105. package/admin/src/components/ItemOrdering/CardOrderingButton.js +0 -24
  106. package/admin/src/components/ItemOrdering/Wrapper.js +0 -24
  107. package/admin/src/components/ItemOrdering/index.js +0 -36
  108. package/admin/src/components/List/Container.js +0 -34
  109. package/admin/src/components/List/ListLevelRoot.js +0 -18
  110. package/admin/src/components/List/index.js +0 -81
  111. package/admin/src/components/Option/OptionButton.js +0 -18
  112. package/admin/src/components/Option/OptionSet.js +0 -14
  113. package/admin/src/components/Option/Wrapper.js +0 -15
  114. package/admin/src/components/Option/index.js +0 -47
  115. package/admin/src/components/Select/ClearIndicator.js +0 -15
  116. package/admin/src/components/Select/DropdownIndicator.js +0 -39
  117. package/admin/src/components/Select/ErrorMessage.js +0 -10
  118. package/admin/src/components/Select/IndicatorSeparator.js +0 -3
  119. package/admin/src/components/Select/MultiValueContainer.js +0 -43
  120. package/admin/src/components/Select/StyledOption.js +0 -11
  121. package/admin/src/components/Select/index.js +0 -68
  122. package/admin/src/components/Select/utils/styles.js +0 -92
  123. package/admin/src/containers/App/Wrapper.js +0 -14
  124. package/admin/src/containers/App/index.js +0 -34
  125. package/admin/src/containers/DataManagerProvider/reducer.js +0 -136
  126. package/admin/src/containers/DetailsView/Wrapper.js +0 -21
  127. package/admin/src/containers/DetailsView/index.js +0 -111
  128. package/admin/src/containers/Initializer/index.js +0 -26
  129. package/admin/src/containers/ListView/Footer.js +0 -56
  130. package/admin/src/containers/ListView/components.js +0 -138
  131. package/admin/src/containers/ListView/index.js +0 -54
  132. package/admin/src/containers/View/FadedWrapper.js +0 -51
  133. package/admin/src/containers/View/HeaderForm.js +0 -9
  134. package/admin/src/containers/View/HeaderFormCell.js +0 -25
  135. package/admin/src/containers/View/Wrapper.js +0 -17
  136. package/admin/src/containers/View/components/NavigationItemForm/ModalFooter.js +0 -45
  137. package/admin/src/containers/View/components/NavigationItemForm/index.js +0 -427
  138. package/admin/src/containers/View/components/NavigationItemPopup/MediumPopup.js +0 -6
  139. package/admin/src/containers/View/index.js +0 -240
  140. package/admin/src/lifecycles.js +0 -3
  141. package/admin/src/permissions.js +0 -14
  142. package/config/functions/bootstrap.js +0 -138
  143. package/config/routes.json +0 -60
  144. package/config/schema.graphql.js +0 -209
  145. package/examples/audit-log-integrations.js.md +0 -38
  146. package/models/navigation.settings.json +0 -43
  147. package/public/assets/preview.png +0 -0
  148. package/services/navigation.js +0 -732
  149. package/services/utils/functions.js +0 -186
package/README.md CHANGED
@@ -1,36 +1,45 @@
1
- # Strapi - Navigation plugin
2
-
3
- <p align="center">
1
+ <div align="center">
2
+ <h1>Strapi v4 - Navigation plugin - BETA</h1>
3
+ <p>Create consumable navigation with a simple and straigthforward visual builder.</p>
4
4
  <a href="https://www.npmjs.org/package/strapi-plugin-navigation">
5
- <img src="https://img.shields.io/npm/v/strapi-plugin-navigation/latest.svg" alt="NPM Version" />
5
+ <img src="https://img.shields.io/github/package-json/v/VirtusLab-Open-Source/strapi-plugin-navigation/feat%252Fstrapi-v4-support?label=npm" alt="NPM Version" />
6
6
  </a>
7
7
  <a href="https://www.npmjs.org/package/strapi-plugin-navigation">
8
8
  <img src="https://img.shields.io/npm/dm/strapi-plugin-navigation.svg" alt="Monthly download on NPM" />
9
9
  </a>
10
10
  <a href="https://circleci.com/gh/VirtusLab/strapi-plugin-navigation">
11
- <img src="https://circleci.com/gh/VirtusLab/strapi-plugin-navigation.svg?style=shield" alt="CircleCI" />
11
+ <img src="https://circleci.com/gh/VirtusLab-Open-Source/strapi-plugin-navigation/tree/feat%2Fstrapi-v4-support.svg?style=shield" alt="CircleCI" />
12
12
  </a>
13
13
  <a href="https://codecov.io/gh/VirtusLab/strapi-plugin-navigation">
14
- <img src="https://codecov.io/gh/VirtusLab/strapi-plugin-navigation/coverage.svg?branch=master" alt="codecov.io" />
14
+ <img src="https://codecov.io/gh/VirtusLab/strapi-plugin-navigation/coverage.svg?branch=feat%2Fstrapi-v4-support" alt="codecov.io" />
15
15
  </a>
16
- </p>
16
+ </div>
17
+
18
+ ---
17
19
 
18
- A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provides navigation / menu builder feature with their possibility to control the audience and different output structure renderers:
20
+ Strapi Navigation Plugin provides a website navigation / menu builder feature for [Strapi Headless CMS](https://github.com/strapi/strapi) admin panel. Navigation has the possibility to control the audience and can be consumed by the website with different output structure renderers:
19
21
 
20
22
  - Flat
21
23
  - Tree (nested)
22
24
  - RFR (ready for handling by Redux First Router)
23
25
 
24
- <img src="public/assets/preview.png" alt="UI preview" />
26
+ ## Features
27
+
28
+ - **Navigation Public API:** Simple and ready for use API endpoint for consuming the navigation structure you've created
29
+ - **Visual builder:** Elegant and easy to use visual builder
30
+ - **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
31
+ - **Customizable:** Possibility to customize the options like: available Content Types, Maximum level for "attach to menu", Additional fields (audience)
32
+ - **[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
25
33
 
26
- ### Versions
34
+
35
+ ## ⚙️ Versions
27
36
 
28
37
  - **Stable** - [v1.1.2](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation)
29
38
  - **Beta** - v4 support - [v2.0.0-beta.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/feat/strapi-v4-support)
30
39
 
31
- ### ⏳ Installation
40
+ ## ⏳ Installation
32
41
 
33
- (Use **yarn** to install this plugin within your Strapi project (recommended). [Install yarn with these docs](https://yarnpkg.com/lang/en/docs/install/).)
42
+ It's recommended to use **yarn** to install this plugin within your Strapi project. [You can install yarn with these docs](https://yarnpkg.com/lang/en/docs/install/).
34
43
 
35
44
  ```bash
36
45
  yarn add strapi-plugin-navigation@latest
@@ -51,69 +60,53 @@ yarn develop --watch-admin
51
60
 
52
61
  The **UI Navigation** plugin should appear in the **Plugins** section of Strapi sidebar after you run app again.
53
62
 
54
-
55
63
  Enjoy 🎉
56
64
 
57
- ### 🖐 Requirements
65
+ ## 🖐 Requirements
58
66
 
59
- Complete installation requirements are exact same as for Strapi itself and can be found in the documentation under <a href="https://strapi.io/documentation/v3.x/installation/cli.html#step-1-make-sure-requirements-are-met">Installation Requirements</a>.
67
+ Complete installation requirements are exact same as for Strapi itself and can be found in the documentation under <a href="https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/installation/cli.html#preparing-the-installation">Installation Requirements</a>.
60
68
 
61
69
  **Supported Strapi versions**:
62
70
 
63
- - Strapi v3.6.8 (recently tested)
64
- - Strapi v3.x
65
-
66
- (This plugin may work with the older Strapi versions, but these are not tested nor officially supported at this time.)
67
-
68
- **We recommend always using the latest version of Strapi to start your new projects**.
69
-
70
- ## Features
71
-
72
- - **Navigation Public API:** Simple and ready for use API endpoint for getting the navigation structure you've created
73
- - **Visual builder:** Elegant and easy to use visual builder
74
- - **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
75
- - **Customizable:** Possibility to customize the options like: available Content Types, Maximum level for "attach to menu", Additional fields (audience)
76
- - **[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
71
+ - Strapi v4.0.5 (recently tested)
72
+ - Strapi v4.x
77
73
 
74
+ _This plugin is not working with v3.x._
78
75
 
79
- ## Content Type model relation to Navigation Item
76
+ It may or may not work with the older Strapi v4 versions, these are not tested nor officially supported at this time.
80
77
 
81
- We can define in `config/plugins.js`
82
- ```js
83
- navigation: {
84
- ...
85
- relatedContentTypes: [
86
- 'application::pages.pages'
87
- ],
88
- ...
89
- },
90
- ```
78
+ **We recommend always using the latest version of Strapi to start your new projects**.
91
79
 
92
- ## Configuration
93
- To setup the plugin properly we recommend to put following snippet as part of `config/plugins.js` or `config/<env>/plugins.js` file. If you've got already configurations for other plugins stores by this way, use just the `navigation` part within exising `plugins` item.
80
+ ## 🔧 Configuration
81
+ Config for this plugin is stored as a part of `config/plugins.js` or `config/<env>/plugins.js` file. You can use following snippet to make sure that the config structure is correct. If you've got already configurations for other plugins stores by this way, you can use the `navigation` along with them.
94
82
 
95
83
  ```js
96
- ...
97
- navigation: {
98
- additionalFields: ['audience'],
99
- allowedLevels: 2,
100
- contentTypesNameFields: {
101
- 'blog_posts': ['altTitle'],
102
- 'pages': ['title'],
103
- },
104
- gql: { ... }
105
- },
106
- ...
84
+ module.exports = ({ env }) => ({
85
+ // ...
86
+ navigation: {
87
+ enabled: true,
88
+ config: {
89
+ additionalFields: ['audience'],
90
+ contentTypes: ['api::page.page'],
91
+ contentTypesNameFields: {
92
+ 'api::page.page': ['title']
93
+ },
94
+ allowedLevels: 2,
95
+ gql: {...},
96
+ }
97
+ }
98
+ });
107
99
  ```
108
100
 
109
101
  ### Properties
110
102
  - `additionalFields` - Additional fields: 'audience', more in the future
111
103
  - `allowedLevels` - Maximum level for which your're able to mark item as "Menu attached"
112
- - `contentTypesNameFields` - Definition of content type title fields like `'content_type_name': ['field_name_1', 'field_name_2']`, if not set titles are pulled from fields like `['title', 'subject', 'name']`
104
+ - `contentTypes` - UIDs of related content types
105
+ - `contentTypesNameFields` - Definition of content type title fields like `'api::<collection name>.<content type name>': ['field_name_1', 'field_name_2']`, if not set titles are pulled from fields like `['title', 'subject', 'name']`. **TIP** - Proper content type uid you can find in the URL of Content Manager where you're managing relevant entities like: `admin/content-manager/collectionType/< THE UID HERE >?page=1&pageSize=10&sort=Title:ASC&plugins[i18n][locale]=en`
113
106
  - `gql` - If you're using GraphQL that's the right place to put all necessary settings. More **[ here ](#gql-configuration)**
114
107
 
115
108
  ## GQL Configuration
116
- To properly configure GQL to work with navigation you should provide `gql` prop which should contain union types which will be used for define GQL response format for your data while fetching:
109
+ Using navigation with GraphQL requires both plugins to be installed and working. You can find instalation guide for GraphQL plugin **[here](https://docs.strapi.io/developer-docs/latest/plugins/graphql.html#graphql)**. To properly configure GQL to work with navigation you should provide `gql` prop. This should contain union types that will be used to define GQL response format for your data while fetching:
117
110
 
118
111
  ```gql
119
112
  master: Int
@@ -121,11 +114,11 @@ items: [NavigationItem]
121
114
  related: NavigationRelated
122
115
  ```
123
116
 
124
- as follows:
117
+ This prop should look as follows:
125
118
 
126
119
  ```js
127
120
  gql: {
128
- navigationItemRelated: 'union NavigationRelated = <your GQL related entities>',
121
+ navigationItemRelated: ['<your GQL related content types>'],
129
122
  },
130
123
  ```
131
124
 
@@ -133,10 +126,10 @@ for example:
133
126
 
134
127
  ```js
135
128
  gql: {
136
- navigationItemRelated: 'union NavigationRelated = Pages | UploadFile',
129
+ navigationItemRelated: ['Page', 'UploadFile'],
137
130
  },
138
131
  ```
139
- where `Pages` and `UploadFile` are your types to the **Content Types** you're referring by navigation items relations.
132
+ where `Page` and `UploadFile` are your type names for the **Content Types** you're referring by navigation items relations.
140
133
 
141
134
 
142
135
  ## Public API Navigation Item model
@@ -209,13 +202,13 @@ where `Pages` and `UploadFile` are your types to the **Content Types** you're re
209
202
 
210
203
  ### Render
211
204
 
212
- `GET <host>/navigation/render/<idOrSlug>?type=<type>`
205
+ `GET <host>/api/navigation/render/<idOrSlug>?type=<type>`
213
206
 
214
207
  Return a rendered navigation structure depends on passed type (`tree`, `rfr` or nothing to render as `flat/raw`).
215
208
 
216
209
  *Note: The ID of navigation by default is `1`, that's for future extensions and multi-navigation feature.*
217
210
 
218
- **Example URL**: `https://localhost:1337/navigation/render/1`
211
+ **Example URL**: `https://localhost:1337/api/navigation/render/1`
219
212
 
220
213
  **Example response body**
221
214
 
@@ -244,7 +237,7 @@ Return a rendered navigation structure depends on passed type (`tree`, `rfr` or
244
237
  ]
245
238
  ```
246
239
 
247
- **Example URL**: `https://localhost:1337/navigation/render/1?type=tree`
240
+ **Example URL**: `https://localhost:1337/api/navigation/render/1?type=tree`
248
241
 
249
242
  **Example response body**
250
243
 
@@ -280,7 +273,7 @@ Return a rendered navigation structure depends on passed type (`tree`, `rfr` or
280
273
  ]
281
274
  ```
282
275
 
283
- **Example URL**: `https://localhost:1337/navigation/render/1?type=rfr`
276
+ **Example URL**: `https://localhost:1337/api/navigation/render/1?type=rfr`
284
277
 
285
278
  **Example response body**
286
279
 
@@ -371,30 +364,11 @@ For collection types it will be read from content type's attribute name `templat
371
364
 
372
365
  For single types a global name of this content type will be used as a template name or it can be set manually with an option named `templateName`.
373
366
 
374
- ## Audit log
375
- If you would like to use the [Strapi Molecules Audit Log](https://github.com/VirtusLab/strapi-molecules/tree/master/packages/strapi-plugin-audit-log) plugin you've to first install and then add in you `config/middleware.js` following section enable it:
376
- ```js
377
- {
378
- 'audit-log': {
379
- enabled: true,
380
- exclude: [],
381
- map: [
382
- {
383
- pluginName: 'navigation',
384
- serviceName: 'navigation',
385
- Class: Navigation,
386
- },
387
- ]
388
- }
389
- }
390
- ```
391
- As a last step you've to provide the Navigation class to let Audit Log use it. To not provide external & hard dependencies we've added the example of class code in the `examples/audit-log-integration.js` .
392
-
393
- ## Examples
367
+ ## 🧩 Examples
394
368
 
395
369
  Live example of plugin usage can be found in the [VirtusLab Strapi Examples](https://github.com/VirtusLab/strapi-examples/tree/master/strapi-plugin-navigation) repository.
396
370
 
397
- ## Q&A
371
+ ## 💬 Q&A
398
372
 
399
373
  ### Content Types
400
374
 
@@ -402,11 +376,11 @@ Live example of plugin usage can be found in the [VirtusLab Strapi Examples](htt
402
376
 
403
377
  **A:** As an authors of the plugin we're not supporting any editing of mentioned content types via built-in Strapi Content Manager. Plugin delivers highly customized & extended functionality which might be covered only by dedicated editor UI accessible via **Plugins Section > UI Navigation**. Only issues that has been recognized there, are in the scope of support we've providing.
404
378
 
405
- ## Contributing
379
+ ## 🤝 Contributing
406
380
 
407
381
  Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!
408
382
 
409
- ## Community support
383
+ ## 👨‍💻 Community support
410
384
 
411
385
  For general help using Strapi, please refer to [the official Strapi documentation](https://strapi.io/documentation/). For additional help, you can use one of these channels to ask a question:
412
386
 
@@ -414,6 +388,6 @@ For general help using Strapi, please refer to [the official Strapi documentatio
414
388
  - [Slack - VirtusLab Open Source](https://virtuslab-oss.slack.com) We're present on a public channel #strapi-molecules
415
389
  - [GitHub](https://github.com/VirtusLab/strapi-plugin-navigation/issues) (Bug reports, Contributions, Questions and Discussions)
416
390
 
417
- ## License
391
+ ## 📝 License
418
392
 
419
393
  [MIT License](LICENSE.md) Copyright (c) 2021 [VirtusLab Sp. z o.o.](https://virtuslab.com/) &amp; [Strapi Solutions](https://strapi.io/).
@@ -1,7 +1,6 @@
1
1
  import styled from "styled-components";
2
- import { Button } from "@buffetjs/styles";
3
-
4
- import { colors } from "strapi-helper-plugin";
2
+ import { Box } from '@strapi/design-system/Box';
3
+ import { Button } from "@strapi/design-system/Button";
5
4
 
6
5
  const EmptyView = styled.div`
7
6
  display: flex;
@@ -11,24 +10,16 @@ const EmptyView = styled.div`
11
10
  justify-content: center;
12
11
  padding-left: 2rem;
13
12
  padding-right: 2rem;
14
- padding-bottom: ${(props) => (props.fixPosition ? "8rem" : 0)};
13
+ padding-bottom: "8rem" };
15
14
 
16
15
  font-size: 2rem;
17
16
  font-weight: 600;
18
- color: ${colors.leftMenu.grey};
17
+ color: ${({ theme }) => theme.colors.neutral600};
19
18
  text-align: center;
20
19
 
21
- svg {
22
- margin-bottom: 1rem;
23
- }
24
-
25
- ${Button} {
26
- margin-top: 2rem;
27
-
28
- svg {
29
- margin-bottom: 0;
30
- }
31
- }
20
+ > {
21
+ margin: 1rem;
22
+ }
32
23
  `;
33
24
 
34
25
  export default EmptyView;
@@ -0,0 +1,8 @@
1
+ import styled from "styled-components";
2
+ import { Badge } from '@strapi/design-system/Badge';
3
+
4
+ const ItemCardBadge = styled(Badge)`
5
+ border: 1px solid ${({ theme, borderColor }) => theme.colors[borderColor]}
6
+ `;
7
+
8
+ export default ItemCardBadge;
@@ -0,0 +1,21 @@
1
+ import styled from "styled-components";
2
+ import { CardTitle } from '@strapi/design-system/Card';
3
+
4
+ const CardItemTitle = styled(CardTitle)`
5
+ width: 100%;
6
+
7
+ display: flex;
8
+ flex-direction: row;
9
+ justify-content: space-between;
10
+ align-items: center;
11
+
12
+ color: ${({ theme }) => theme.colors.neutral800};
13
+ font-size: ${({ theme }) => theme.fontSizes[2]};
14
+ font-weight: ${({ theme }) => theme.fontWeights.bold};
15
+
16
+ > div > * {
17
+ margin: 0px ${({ theme }) => theme.spaces[1]};
18
+ }
19
+ `;
20
+
21
+ export default CardItemTitle;
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { useIntl } from 'react-intl';
3
+
4
+ import { Flex } from '@strapi/design-system/Flex';
5
+ import { IconButton } from '@strapi/design-system/IconButton';
6
+ import { Typography } from '@strapi/design-system/Typography';
7
+ import PencilIcon from '@strapi/icons/Pencil';
8
+ import TrashIcon from '@strapi/icons/Trash';
9
+ import RefreshIcon from '@strapi/icons/Refresh';
10
+
11
+ import Wrapper from './Wrapper';
12
+ import ItemCardBadge from '../ItemCardBadge';
13
+ import { getTrad } from "../../../translations";
14
+
15
+ const ItemCardHeader = ({ title, path, icon, removed, isExternal, isPublished, onItemRemove, onItemEdit, onItemRestore }) => {
16
+ const badgeColor = isPublished ? 'success' : 'secondary';
17
+ const { formatMessage } = useIntl();
18
+
19
+ return (
20
+ <Wrapper>
21
+ <Flex alignItems="center">
22
+ {icon}
23
+ <Typography variant="omega" fontWeight="bold">
24
+ {title}
25
+ </Typography>
26
+ <Typography variant="omega" fontWeight="bold" textColor='neutral500'>
27
+ {path}
28
+ </Typography>
29
+ </Flex>
30
+ <Flex alignItems="center">
31
+ {removed ?
32
+ <ItemCardBadge
33
+ borderColor={`danger200`}
34
+ backgroundColor={`danger100`}
35
+ textColor={`danger600`}
36
+ >
37
+ {formatMessage(getTrad("navigation.item.badge.removed"))}
38
+ </ItemCardBadge>
39
+ : !isExternal && <ItemCardBadge
40
+ borderColor={`${badgeColor}200`}
41
+ backgroundColor={`${badgeColor}100`}
42
+ textColor={`${badgeColor}600`}
43
+ className="action"
44
+ >
45
+ {formatMessage(getTrad(`navigation.item.badge.${isPublished ? 'published' : 'draft'}`))}
46
+ </ItemCardBadge>
47
+ }
48
+
49
+ <IconButton disabled={removed} onClick={onItemEdit} label="Edit" icon={<PencilIcon />} />
50
+ {removed ?
51
+ <IconButton onClick={onItemRestore} label="Restore" icon={<RefreshIcon />} /> :
52
+ <IconButton onClick={onItemRemove} label="Remove" icon={<TrashIcon />} />
53
+ }
54
+ </Flex>
55
+ </Wrapper>
56
+ );
57
+ }
58
+
59
+ export default ItemCardHeader;
@@ -0,0 +1,39 @@
1
+ import styled from "styled-components";
2
+
3
+ const Wrapper = styled.div`
4
+ position: relative;
5
+ margin-top: ${({theme}) => theme.spaces[2]};
6
+ margin-left: ${({ theme, level }) => level && theme.spaces[8]}};
7
+
8
+ ${({ level, theme, isLast }) => level && `
9
+ &::before {
10
+ ${!isLast && 'content: "";'}
11
+ display: block;
12
+ top: ${theme.spaces[1]};
13
+ left: -24px;
14
+ position: absolute;
15
+ height: calc(100% + ${theme.spaces[2]});
16
+ width: 19px;
17
+ border: 0px solid transparent;
18
+ border-left: 4px solid ${theme.colors.neutral300};
19
+ }
20
+
21
+ &::after {
22
+ content: "";
23
+ display: block;
24
+ height: 22px;
25
+ width: 19px;
26
+ position: absolute;
27
+ top: ${theme.spaces[1]};
28
+ left: -${theme.spaces[6]};
29
+
30
+ background: transparent;
31
+ border: 4px solid ${theme.colors.neutral300};
32
+ border-top: transparent;
33
+ border-right: transparent;
34
+ border-radius: 0 0 0 100%;
35
+ }
36
+ `};
37
+ `;
38
+
39
+ export default Wrapper;