strapi-plugin-navigation 2.0.11 → 2.1.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.
Files changed (268) hide show
  1. package/README.md +254 -41
  2. package/admin/src/components/Alert/styles.d.ts +2 -0
  3. package/admin/src/components/Alert/styles.js +14 -0
  4. package/admin/src/components/CollapseButton/index.d.ts +7 -0
  5. package/admin/src/components/CollapseButton/index.js +21 -22
  6. package/admin/src/components/ConfirmationDialog/index.d.ts +28 -0
  7. package/admin/src/components/ConfirmationDialog/index.js +32 -54
  8. package/admin/src/components/EmptyView/index.d.ts +3 -0
  9. package/admin/src/components/EmptyView/index.js +9 -7
  10. package/admin/src/components/Item/ItemCardBadge/index.d.ts +3 -0
  11. package/admin/src/components/Item/ItemCardBadge/index.js +11 -7
  12. package/admin/src/components/Item/ItemCardHeader/Wrapper.d.ts +3 -0
  13. package/admin/src/components/Item/ItemCardHeader/Wrapper.js +10 -6
  14. package/admin/src/components/Item/ItemCardHeader/index.d.ts +12 -0
  15. package/admin/src/components/Item/ItemCardHeader/index.js +34 -53
  16. package/admin/src/components/Item/ItemCardRemovedOverlay/index.d.ts +2 -0
  17. package/admin/src/components/Item/ItemCardRemovedOverlay/index.js +10 -4
  18. package/admin/src/components/Item/Wrapper.d.ts +3 -0
  19. package/admin/src/components/Item/Wrapper.js +10 -6
  20. package/admin/src/components/Item/index.d.ts +31 -0
  21. package/admin/src/components/Item/index.js +169 -242
  22. package/admin/src/components/NavigationItemList/Wrapper.d.ts +3 -0
  23. package/admin/src/components/NavigationItemList/Wrapper.js +9 -5
  24. package/admin/src/components/NavigationItemList/index.d.ts +35 -0
  25. package/admin/src/components/NavigationItemList/index.js +28 -66
  26. package/admin/src/components/RestartAlert/index.d.ts +3 -0
  27. package/admin/src/components/RestartAlert/index.js +10 -5
  28. package/admin/src/components/Search/index.d.ts +6 -0
  29. package/admin/src/components/Search/index.js +57 -46
  30. package/admin/src/components/icons/navigation.d.ts +6 -0
  31. package/admin/src/components/icons/navigation.js +11 -13
  32. package/admin/src/contexts/DataManagerContext.d.ts +3 -0
  33. package/admin/src/contexts/DataManagerContext.js +6 -5
  34. package/admin/src/hooks/useAllContentTypes.d.ts +6 -0
  35. package/admin/src/hooks/useAllContentTypes.js +10 -11
  36. package/admin/src/hooks/useDataManager.d.ts +3 -0
  37. package/admin/src/hooks/useDataManager.js +10 -6
  38. package/admin/src/hooks/useNavigationConfig.d.ts +10 -0
  39. package/admin/src/hooks/useNavigationConfig.js +52 -56
  40. package/admin/src/index.d.ts +14 -0
  41. package/admin/src/index.js +92 -76
  42. package/admin/src/pages/App/index.d.ts +3 -0
  43. package/admin/src/pages/App/index.js +43 -31
  44. package/admin/src/pages/DataManagerProvider/actions.d.ts +19 -0
  45. package/admin/src/pages/DataManagerProvider/actions.js +22 -26
  46. package/admin/src/pages/DataManagerProvider/index.d.ts +12 -0
  47. package/admin/src/pages/DataManagerProvider/index.js +280 -300
  48. package/admin/src/pages/DataManagerProvider/init.d.ts +3 -0
  49. package/admin/src/pages/DataManagerProvider/init.js +5 -3
  50. package/admin/src/pages/DataManagerProvider/reducer.d.ts +19 -0
  51. package/admin/src/pages/DataManagerProvider/reducer.js +119 -121
  52. package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.d.ts +24 -0
  53. package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.js +88 -0
  54. package/admin/src/pages/SettingsPage/index.d.ts +3 -0
  55. package/admin/src/pages/SettingsPage/index.js +242 -317
  56. package/admin/src/pages/SettingsPage/utils/functions.d.ts +5 -0
  57. package/admin/src/pages/SettingsPage/utils/functions.js +3 -8
  58. package/admin/src/pages/View/components/I18nCopyNavigationItems/index.d.ts +20 -0
  59. package/admin/src/pages/View/components/I18nCopyNavigationItems/index.js +60 -0
  60. package/admin/src/pages/View/components/NavigationContentHeader/index.d.ts +6 -0
  61. package/admin/src/pages/View/components/NavigationContentHeader/index.js +13 -17
  62. package/admin/src/pages/View/components/NavigationHeader/index.d.ts +12 -0
  63. package/admin/src/pages/View/components/NavigationHeader/index.js +74 -65
  64. package/admin/src/pages/View/components/NavigationHeader/styles.d.ts +2 -0
  65. package/admin/src/pages/View/components/NavigationHeader/styles.js +10 -5
  66. package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +51 -0
  67. package/admin/src/pages/View/components/NavigationItemForm/index.js +322 -454
  68. package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +45 -0
  69. package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +81 -52
  70. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.d.ts +23 -0
  71. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +24 -34
  72. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.d.ts +4 -0
  73. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +16 -16
  74. package/admin/src/pages/View/components/NavigationItemPopup/index.d.ts +27 -0
  75. package/admin/src/pages/View/components/NavigationItemPopup/index.js +59 -108
  76. package/admin/src/pages/View/index.d.ts +4 -0
  77. package/admin/src/pages/View/index.js +229 -304
  78. package/admin/src/pages/View/utils/enums.d.ts +9 -0
  79. package/admin/src/pages/View/utils/enums.js +11 -8
  80. package/admin/src/pages/View/utils/form.d.ts +2 -0
  81. package/admin/src/pages/View/utils/form.js +15 -12
  82. package/admin/src/pages/View/utils/index.d.ts +2 -0
  83. package/admin/src/pages/View/utils/index.js +11 -3
  84. package/admin/src/pages/View/utils/parsers.d.ts +44 -0
  85. package/admin/src/pages/View/utils/parsers.js +231 -277
  86. package/admin/src/permissions.d.ts +12 -0
  87. package/admin/src/permissions.js +11 -7
  88. package/admin/src/pluginId.d.ts +3 -0
  89. package/admin/src/pluginId.js +2 -2
  90. package/admin/src/translations/en.json +126 -102
  91. package/admin/src/translations/fr.json +44 -44
  92. package/admin/src/translations/index.d.ts +12 -0
  93. package/admin/src/translations/index.js +17 -11
  94. package/admin/src/utils/api.d.ts +8 -0
  95. package/admin/src/utils/api.js +54 -50
  96. package/admin/src/utils/getTrad.d.ts +3 -0
  97. package/admin/src/utils/getTrad.js +9 -5
  98. package/admin/src/utils/index.d.ts +5 -0
  99. package/admin/src/utils/index.js +21 -15
  100. package/package.json +19 -17
  101. package/permissions.d.ts +9 -0
  102. package/permissions.js +5 -4
  103. package/server/bootstrap/index.d.ts +4 -0
  104. package/server/bootstrap/index.js +41 -0
  105. package/server/config/index.d.ts +5 -0
  106. package/server/config/index.js +33 -9
  107. package/server/config/setupStrategy.d.ts +3 -0
  108. package/server/config/setupStrategy.js +38 -0
  109. package/server/content-types/audience/index.d.ts +27 -0
  110. package/server/content-types/audience/index.js +9 -8
  111. package/server/content-types/audience/schema.d.ts +25 -0
  112. package/server/content-types/audience/schema.js +26 -0
  113. package/server/content-types/index.d.ts +255 -0
  114. package/server/content-types/index.js +15 -12
  115. package/server/content-types/navigation/index.d.ts +64 -0
  116. package/server/content-types/navigation/index.js +11 -8
  117. package/server/content-types/navigation/lifecycle.d.ts +9 -0
  118. package/server/content-types/navigation/lifecycle.js +8 -12
  119. package/server/content-types/navigation/schema.d.ts +55 -0
  120. package/server/content-types/navigation/schema.js +56 -0
  121. package/server/content-types/navigation-item/index.d.ts +112 -0
  122. package/server/content-types/navigation-item/index.js +11 -8
  123. package/server/content-types/navigation-item/lifecycle.d.ts +16 -0
  124. package/server/content-types/navigation-item/lifecycle.js +28 -32
  125. package/server/content-types/navigation-item/schema.d.ts +97 -0
  126. package/server/content-types/navigation-item/schema.js +102 -0
  127. package/server/content-types/navigations-items-related/index.d.ts +56 -0
  128. package/server/content-types/navigations-items-related/index.js +11 -8
  129. package/server/content-types/navigations-items-related/lifecycle.d.ts +8 -0
  130. package/server/content-types/navigations-items-related/lifecycle.js +20 -17
  131. package/server/content-types/navigations-items-related/schema.d.ts +49 -0
  132. package/server/content-types/navigations-items-related/schema.js +50 -0
  133. package/server/controllers/admin.d.ts +4 -0
  134. package/server/controllers/admin.js +77 -0
  135. package/server/controllers/client.d.ts +4 -0
  136. package/server/controllers/client.js +34 -0
  137. package/server/controllers/index.d.ts +4 -0
  138. package/server/controllers/index.js +12 -6
  139. package/server/destroy.d.ts +3 -0
  140. package/server/destroy.js +5 -0
  141. package/server/graphql/config.d.ts +4 -0
  142. package/server/graphql/config.js +28 -0
  143. package/server/graphql/index.d.ts +2 -0
  144. package/server/graphql/index.js +18 -22
  145. package/server/graphql/queries/index.d.ts +3 -0
  146. package/server/graphql/queries/index.js +15 -15
  147. package/server/graphql/queries/render-navigation-child.d.ts +15 -0
  148. package/server/graphql/queries/render-navigation-child.js +24 -15
  149. package/server/graphql/queries/render-navigation.d.ts +23 -0
  150. package/server/graphql/queries/render-navigation.js +29 -15
  151. package/server/graphql/resolvers-config.d.ts +10 -0
  152. package/server/graphql/resolvers-config.js +5 -3
  153. package/server/graphql/setupStrategy.d.ts +3 -0
  154. package/server/graphql/setupStrategy.js +15 -0
  155. package/server/graphql/types/content-types-name-fields.d.ts +6 -0
  156. package/server/graphql/types/content-types-name-fields.js +13 -9
  157. package/server/graphql/types/content-types.d.ts +5 -0
  158. package/server/graphql/types/content-types.js +17 -15
  159. package/server/graphql/types/create-navigation-item.d.ts +5 -0
  160. package/server/graphql/types/create-navigation-item.js +18 -16
  161. package/server/graphql/types/create-navigation-related.d.ts +5 -0
  162. package/server/graphql/types/create-navigation-related.js +9 -7
  163. package/server/graphql/types/create-navigation.d.ts +5 -0
  164. package/server/graphql/types/create-navigation.js +8 -6
  165. package/server/graphql/types/index.d.ts +3 -0
  166. package/server/graphql/types/index.js +15 -13
  167. package/server/graphql/types/navigation-config.d.ts +5 -0
  168. package/server/graphql/types/navigation-config.js +10 -8
  169. package/server/graphql/types/navigation-details.d.ts +5 -0
  170. package/server/graphql/types/navigation-details.js +11 -9
  171. package/server/graphql/types/navigation-item-related-data.d.ts +5 -0
  172. package/server/graphql/types/navigation-item-related-data.js +9 -0
  173. package/server/graphql/types/navigation-item-related.d.ts +7 -0
  174. package/server/graphql/types/navigation-item-related.js +25 -0
  175. package/server/graphql/types/navigation-item.d.ts +5 -0
  176. package/server/graphql/types/navigation-item.js +28 -29
  177. package/server/graphql/types/navigation-render-type.d.ts +5 -0
  178. package/server/graphql/types/navigation-render-type.js +7 -4
  179. package/server/graphql/types/navigation.d.ts +5 -0
  180. package/server/graphql/types/navigation.js +10 -8
  181. package/server/i18n/constant.d.ts +2 -0
  182. package/server/i18n/constant.js +5 -0
  183. package/server/i18n/errors.d.ts +7 -0
  184. package/server/i18n/errors.js +14 -0
  185. package/server/i18n/graphQLEnhancers.d.ts +10 -0
  186. package/server/i18n/graphQLEnhancers.js +9 -0
  187. package/server/i18n/index.d.ts +8 -0
  188. package/server/i18n/index.js +23 -0
  189. package/server/i18n/navigationSetupStrategy.d.ts +3 -0
  190. package/server/i18n/navigationSetupStrategy.js +119 -0
  191. package/server/i18n/serviceEnhancers.d.ts +12 -0
  192. package/server/i18n/serviceEnhancers.js +117 -0
  193. package/server/i18n/types.d.ts +54 -0
  194. package/server/i18n/types.js +3 -0
  195. package/server/i18n/utils.d.ts +12 -0
  196. package/server/i18n/utils.js +29 -0
  197. package/server/index.d.ts +273 -0
  198. package/server/index.js +26 -0
  199. package/server/navigation/index.d.ts +2 -0
  200. package/server/navigation/index.js +18 -0
  201. package/server/navigation/setupStrategy.d.ts +3 -0
  202. package/server/navigation/setupStrategy.js +37 -0
  203. package/server/register/index.d.ts +3 -0
  204. package/server/register/index.js +4 -0
  205. package/server/routes/admin.d.ts +4 -0
  206. package/server/routes/admin.js +72 -61
  207. package/server/routes/client.d.ts +4 -0
  208. package/server/routes/client.js +25 -21
  209. package/server/routes/index.d.ts +6 -0
  210. package/server/routes/index.js +13 -4
  211. package/server/services/admin.d.ts +5 -0
  212. package/server/services/admin.js +183 -0
  213. package/server/services/client.d.ts +5 -0
  214. package/server/services/client.js +249 -0
  215. package/server/services/common.d.ts +5 -0
  216. package/server/services/common.js +313 -0
  217. package/server/services/index.d.ts +7 -0
  218. package/server/services/index.js +14 -6
  219. package/server/utils/constant.d.ts +27 -0
  220. package/server/utils/constant.js +24 -0
  221. package/server/utils/functions.d.ts +138 -0
  222. package/server/utils/functions.js +224 -0
  223. package/server/utils/index.d.ts +3 -0
  224. package/server/utils/index.js +19 -0
  225. package/strapi-admin.d.ts +3 -0
  226. package/strapi-admin.js +8 -1
  227. package/strapi-server.d.ts +273 -0
  228. package/strapi-server.js +6 -17
  229. package/tsconfig.tsbuildinfo +1 -0
  230. package/types/bootstrap.d.ts +13 -0
  231. package/types/bootstrap.js +3 -0
  232. package/types/config.d.ts +21 -0
  233. package/types/config.js +3 -0
  234. package/types/contentTypes.d.ts +85 -0
  235. package/types/contentTypes.js +3 -0
  236. package/types/controllers.d.ts +35 -0
  237. package/types/controllers.js +5 -0
  238. package/types/graphQL.d.ts +3 -0
  239. package/types/graphQL.js +3 -0
  240. package/types/i18n.d.ts +9 -0
  241. package/types/i18n.js +3 -0
  242. package/types/index.d.ts +9 -0
  243. package/types/index.js +25 -0
  244. package/types/services.d.ts +68 -0
  245. package/types/services.js +3 -0
  246. package/types/utils.d.ts +58 -0
  247. package/types/utils.js +26 -0
  248. package/utils/InvalidParamNavigationError.d.ts +4 -0
  249. package/utils/InvalidParamNavigationError.js +11 -0
  250. package/utils/NavigationError.d.ts +5 -0
  251. package/utils/NavigationError.js +7 -7
  252. package/__mocks__/pages.settings.json +0 -25
  253. package/__mocks__/strapi.js +0 -207
  254. package/jest.config.js +0 -14
  255. package/server/bootstrap.js +0 -52
  256. package/server/config.js +0 -9
  257. package/server/content-types/audience/lifecycle.js +0 -8
  258. package/server/content-types/audience/schema.json +0 -23
  259. package/server/content-types/navigation/schema.json +0 -45
  260. package/server/content-types/navigation-item/schema.json +0 -99
  261. package/server/content-types/navigations-items-related/schema.json +0 -47
  262. package/server/controllers/navigation.js +0 -105
  263. package/server/graphql/types/navigation-related.js +0 -25
  264. package/server/services/__tests__/functions.test.js +0 -48
  265. package/server/services/__tests__/navigation.test.js +0 -91
  266. package/server/services/navigation.js +0 -788
  267. package/server/services/utils/constant.js +0 -21
  268. package/server/services/utils/functions.js +0 -226
package/README.md CHANGED
@@ -36,6 +36,22 @@ Strapi Navigation Plugin provides a website navigation / menu builder feature fo
36
36
  - Tree (nested)
37
37
  - RFR (ready for handling by Redux First Router)
38
38
 
39
+ ### Table of Contents
40
+ 1. [✨ Features](#-features)
41
+ 2. [⏳ Installation](#-installation)
42
+ 3. [🖐 Requirements](#-requirements)
43
+ 4. [🔧 Basic Configuration](#-configuration)
44
+ - [Settings page](#in-v203-and-newer)
45
+ - [Plugin file](#in-v202-and-older--default-configuration-state-for-v203-and-newer)
46
+ 5. [🔧 GraphQL Configuration](#-gql-configuration)
47
+ 6. [🌍 i18n Internationalization](#-i18n-internationalization)
48
+ 7. [🕸️ Public API specification](#%EF%B8%8F-public-api-specification)
49
+ - [REST API](#rest-api)
50
+ - [GraphQL API](#graphql-api)
51
+ 8. [💬 FAQ](#-faq)
52
+ 10. [🤝 Contributing](#-contributing)
53
+ 11. [👨‍💻 Community support](#-community-support)
54
+
39
55
  ## ✨ Features
40
56
 
41
57
  - **Navigation Public API:** Simple and ready for use API endpoint for consuming the navigation structure you've created
@@ -43,6 +59,8 @@ Strapi Navigation Plugin provides a website navigation / menu builder feature fo
43
59
  - **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
60
  - **Different types of navigation items:** Create navigation with items linked to internal types, to external links or wrapper elements to keep structure clean
45
61
  - **Multiple navigations:** Create as many Navigation containers as you want, setup them and use in the consumer application
62
+ - **Light / Dark mode compatible:** By design we're supporting Strapi ☀️ Light / 🌙 Dark modes
63
+ - **Webhooks integration:** Changes to navigation will trigger 'entry.update' or 'entry.create' webhook events.
46
64
  - **Customizable:** Possibility to customize the options like: available Content Types, Maximum level for "attach to menu", Additional fields (audience)
47
65
  - **[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
48
66
 
@@ -53,13 +71,23 @@ Strapi Navigation Plugin provides a website navigation / menu builder feature fo
53
71
 
54
72
  ## ⏳ Installation
55
73
 
74
+ ### Via Strapi Markerplace
75
+
76
+ As a ✅ **verified** plugin by Strapi team we're available on the [**Strapi Marketplace**](https://market.strapi.io/plugins/strapi-plugin-navigation) as well as **In-App Marketplace** where you can follow the installation instructions.
77
+
78
+ <div style="margin: 20px 0" align="center">
79
+ <img style="width: 100%; height: auto;" src="public/assets/marketplace.png" alt="Strapi In-App Marketplace" />
80
+ </div>
81
+
82
+ ### Via command line
83
+
56
84
  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/).
57
85
 
58
86
  ```bash
59
87
  yarn add strapi-plugin-navigation@latest
60
88
  ```
61
89
 
62
- After successful installation you've to build a fresh package that includes plugin UI. To archive that simply use:
90
+ After successful installation you've to re-build your Strapi instance. To archive that simply use:
63
91
 
64
92
  ```bash
65
93
  yarn build
@@ -74,7 +102,9 @@ yarn develop --watch-admin
74
102
 
75
103
  The **UI Navigation** plugin should appear in the **Plugins** section of Strapi sidebar after you run app again.
76
104
 
77
- Enjoy 🎉
105
+ As a next step you must configure your the plugin by the way you want to. See [**Configuration**](#🔧-configuration) section.
106
+
107
+ All done. Enjoy 🎉
78
108
 
79
109
  ## 🖐 Requirements
80
110
 
@@ -82,7 +112,7 @@ Complete installation requirements are exact same as for Strapi itself and can b
82
112
 
83
113
  **Supported Strapi versions**:
84
114
 
85
- - Strapi v4.1.5 (recently tested)
115
+ - Strapi v4.1.8 (recently tested)
86
116
  - Strapi v4.x
87
117
 
88
118
  > This plugin is designed for **Strapi v4** and is not working with v3.x. To get version for **Strapi v3** install version [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/strapi-v3).
@@ -91,9 +121,17 @@ Complete installation requirements are exact same as for Strapi itself and can b
91
121
 
92
122
  ## 🔧 Configuration
93
123
 
124
+ To start your journey with **Navigation plugin** you must first setup it using the dedicated Settings page (`v2.0.3` and newer) or for any version, put your configuration in `config/plugins.js`. Anyway we're recommending the click-through option where your configuration is going to be properly validated.
125
+
94
126
  ### In `v2.0.3` and newer
95
127
 
96
- Version `2.0.3` introduces the intuitive **Settings** page which you can easily access via `Strapi Settings -> Section: Navigation Plugin -> Configuration`. On the dedicated page, you will be able to set up all crucial properties which drive the plugin and customize each individual collection for which **Navigation plugin** should be enabled.
128
+ Version `2.0.3` introduces the intuitive **Settings** page which you can easily access via `Strapi Settings -> Section: Navigation Plugin -> Configuration`.
129
+
130
+ On the dedicated page, you will be able to set up all crucial properties which drive the plugin and customize each individual collection for which **Navigation plugin** should be enabled.
131
+
132
+ <div style="margin: 20px 0" align="center">
133
+ <img style="width: 100%; height: auto;" src="public/assets/configuration.png" alt="Plugin configuration" />
134
+ </div>
97
135
 
98
136
  > *Note*
99
137
  > The default configuration for your plugin is fetched from `config/plugins.js` or, if the file is not there, directly from the plugin itself. If you would like to customize the default state to which you might revert, please follow the next section.
@@ -129,6 +167,7 @@ Config for this plugin is stored as a part of the `config/plugins.js` or `config
129
167
  - `contentTypes` - UIDs of related content types
130
168
  - `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`
131
169
  - `gql` - If you're using GraphQL that's the right place to put all necessary settings. More **[ here ](#gql-configuration)**
170
+ - `i18nEnabled` - should you want to manage multi-locale content via navigation set this value `Enabled`. More **[ here ](#i18n-internationalization)**
132
171
 
133
172
  ## 🔧 GQL Configuration
134
173
  Using navigation with GraphQL requires both plugins to be installed and working. You can find installation 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:
@@ -159,6 +198,38 @@ gql: {
159
198
  ```
160
199
  where `Page` and `UploadFile` are your type names for the **Content Types** you're referring by navigation items relations.
161
200
 
201
+ ## 🌍 i18n Internationalization
202
+
203
+ ### Settings
204
+
205
+ This feature is **opt-in**.
206
+
207
+ In order to use this functionality setting **default locale** is required. (See: Settings -> Internationalization)
208
+
209
+ Once feature is enabled a restart is required. On server startup missing navigations for other locales will be created. From then you can manage navigation's localizations just like before.
210
+
211
+ If you want go back to _pre-i18n_ way you can disable it in settings. Already created navigations will not be removed unless you make a choice for plugin to do so(this will require a restart).
212
+
213
+ If your newly created navigation localization is empty you can copy contents of one version's to the empty one. If related item is localized and locale version exists localization will be used as a related item. Otherwise plugin will fallback to an original item.
214
+
215
+ ### Rendering
216
+
217
+ Shape of the rendered navigation will not change. Querying stays almost the same. To query for specific locale version just add `locale` query param. For example:
218
+
219
+ ```https://yourdomain.cool/api/navigation/render/1?locale=fr```
220
+
221
+ or
222
+
223
+ ```https://yourdomain.cool/api/navigation/render/main-navigation?locale=fr```
224
+
225
+ If `locale` is not specified whatever version used to be at id `1` will be returned.
226
+
227
+ Of course if you know that `fr` version is present at id `2` you can just query for that.
228
+
229
+ ### GraphQL
230
+
231
+ If feature is enabled GQL render navigation query is expanded to handle `locale` param(it will work the same as regular requests). Checkout schema provided by GraphQL plugin.
232
+
162
233
  ## 👤 RBAC
163
234
  Plugin provides granular permissions based on Strapi RBAC functionality.
164
235
 
@@ -169,7 +240,7 @@ For any role different than **Super Admin**, to access the **Navigation panel**
169
240
  ## Base Navigation Item model
170
241
 
171
242
  ### Flat
172
- ```
243
+ ```json
173
244
  {
174
245
  "id": 1,
175
246
  "title": "News",
@@ -182,13 +253,13 @@ For any role different than **Super Admin**, to access the **Navigation panel**
182
253
  "master": 1, // Navigation 'id'
183
254
  "createdAt": "2020-09-29T13:29:19.086Z",
184
255
  "updatedAt": "2020-09-29T13:29:19.128Z",
185
- "related": [ <Content Type model > ],
256
+ "related": {/*<Content Type model >*/ },
186
257
  "audience": []
187
258
  }
188
259
  ```
189
260
 
190
261
  ### Tree
191
- ```
262
+ ```json
192
263
  {
193
264
  "title": "News",
194
265
  "menuAttached": true,
@@ -198,7 +269,7 @@ For any role different than **Super Admin**, to access the **Navigation panel**
198
269
  "slug": "benefits",
199
270
  "external": false,
200
271
  "related": {
201
- <Content Type model >
272
+ // <Content Type model >
202
273
  },
203
274
  "items": [
204
275
  {
@@ -209,13 +280,13 @@ For any role different than **Super Admin**, to access the **Navigation panel**
209
280
  "uiRouterKey": "generic",
210
281
  "external": true
211
282
  },
212
- < Tree Navigation Item models >
283
+ // < Tree Navigation Item models >
213
284
  ]
214
285
  }
215
286
  ```
216
287
 
217
288
  ### RFR
218
- ```
289
+ ```json
219
290
  {
220
291
  "id": "News",
221
292
  "title": "News",
@@ -234,33 +305,41 @@ For any role different than **Super Admin**, to access the **Navigation panel**
234
305
 
235
306
  ## 🕸️ Public API specification
236
307
 
237
- ### Query Params
308
+ Plugin supports both **REST API** and **GraphQL API** exposed by Strapi.
238
309
 
239
- - `type` - Enum value representing structure type of returned navigation
310
+ **Query Params**
240
311
 
241
- **Example URL**: `https://localhost:1337/api/navigation/render/1?type=FLAT`
312
+ - `navigationIdOrSlug` - ID or slug for which your navigation structure is generated like for REST API:
242
313
 
243
- - `menu` - Boolean value for querying only navigation items that are attached to menu should be rendered eg.
314
+ > `https://localhost:1337/api/navigation/render/1`
315
+ > `https://localhost:1337/api/navigation/render/main-menu`
244
316
 
245
- **Example URL**: `https://localhost:1337/api/navigation/render/1?menu=true`
317
+ - `type` - Enum value representing structure type of returned navigation:
318
+ > `https://localhost:1337/api/navigation/render/1?type=FLAT`
246
319
 
247
- - `path` - String value for querying navigation items by its path
320
+ - `menu` (`menuOnly` for GQL) - Boolean value for querying only navigation items that are attached to menu should be rendered eg.
321
+ > `https://localhost:1337/api/navigation/render/1?menu=true`
248
322
 
249
- **Example URL**: `https://localhost:1337/api/navigation/render/1?path=/home/about-us`
323
+ - `path` - String value for querying navigation items by its path:
324
+ > `https://localhost:1337/api/navigation/render/1?path=/home/about-us`
250
325
 
251
- ### Render
326
+ ### REST API
327
+
328
+ > **Important!**
329
+ > Version `v2.0.13` introduced breaking change!
330
+ > All responses have changed their structure. Related field will now be of type ContentType instead of Array\<ContentType\>
252
331
 
253
- `GET <host>/api/navigation/render/<idOrSlug>?type=<type>`
332
+ `GET <host>/api/navigation/render/<navigationIdOrSlug>?type=<type>`
254
333
 
255
- Return a rendered navigation structure depends on passed type (`tree`, `rfr` or nothing to render as `flat/raw`).
334
+ Return a rendered navigation structure depends on passed type (`TREE`, `RFR` or nothing to render as `FLAT`).
256
335
 
257
- *Note: The ID of navigation by default is `1`, that's for future extensions and multi-navigation feature.*
336
+ > The ID of navigation by default is `1`, if you've got defined multiple navigations you must work with their IDs or Slugs to fetch.
258
337
 
259
338
  **Example URL**: `https://localhost:1337/api/navigation/render/1`
260
339
 
261
340
  **Example response body**
262
341
 
263
- ```
342
+ ```json
264
343
  [
265
344
  {
266
345
  "id": 1,
@@ -274,22 +353,22 @@ Return a rendered navigation structure depends on passed type (`tree`, `rfr` or
274
353
  "master": 1,
275
354
  "created_at": "2020-09-29T13:29:19.086Z",
276
355
  "updated_at": "2020-09-29T13:29:19.128Z",
277
- "related": [{
356
+ "related": {
278
357
  "__contentType": "Page",
279
358
  "id": 1,
280
359
  "title": "News",
281
- ...
282
- }]
360
+ // ...
361
+ }
283
362
  },
284
- ...
363
+ // ...
285
364
  ]
286
365
  ```
287
366
 
288
- **Example URL**: `https://localhost:1337/api/navigation/render/1?type=tree`
367
+ **Example URL**: `https://localhost:1337/api/navigation/render/1?type=TREE`
289
368
 
290
369
  **Example response body**
291
370
 
292
- ```
371
+ ```json
293
372
  [
294
373
  {
295
374
  "title": "News",
@@ -303,7 +382,7 @@ Return a rendered navigation structure depends on passed type (`tree`, `rfr` or
303
382
  "__contentType": "Page",
304
383
  "id": 1,
305
384
  "title": "News",
306
- ...
385
+ // ...
307
386
  },
308
387
  "items": [
309
388
  {
@@ -314,18 +393,18 @@ Return a rendered navigation structure depends on passed type (`tree`, `rfr` or
314
393
  "uiRouterKey": "generic",
315
394
  "external": true
316
395
  },
317
- ...
396
+ // ...
318
397
  ]
319
398
  },
320
- ...
399
+ // ...
321
400
  ]
322
401
  ```
323
402
 
324
- **Example URL**: `https://localhost:1337/api/navigation/render/1?type=rfr`
403
+ **Example URL**: `https://localhost:1337/api/navigation/render/1?type=RFR`
325
404
 
326
405
  **Example response body**
327
406
 
328
- ```
407
+ ```json
329
408
  {
330
409
  "pages": {
331
410
  "News": {
@@ -370,7 +449,7 @@ Return a rendered navigation structure depends on passed type (`tree`, `rfr` or
370
449
  "parent": "Community",
371
450
  "menuAttached": false
372
451
  },
373
- ...
452
+ // ...
374
453
  },
375
454
  "nav": {
376
455
  "root": [
@@ -389,7 +468,7 @@ Return a rendered navigation structure depends on passed type (`tree`, `rfr` or
389
468
  "type": "external",
390
469
  "url": "http://example.com"
391
470
  },
392
- ...
471
+ // ...
393
472
  ],
394
473
  "Community": [
395
474
  {
@@ -397,13 +476,116 @@ Return a rendered navigation structure depends on passed type (`tree`, `rfr` or
397
476
  "type": "internal",
398
477
  "page": "Highlights"
399
478
  },
400
- ...
479
+ // ...
401
480
  ],
402
- ...
481
+ // ...
403
482
  }
404
483
  }
405
484
  ```
406
485
 
486
+ ### GraphQL API
487
+
488
+ Same as [**REST API**](#rest-api) returns a rendered navigation structure depends on passed type (`TREE`, `RFR` or nothing to render as `FLAT`).
489
+
490
+ **Example request**
491
+
492
+ ```graphql
493
+ query {
494
+ renderNavigation(
495
+ navigationIdOrSlug: "main-navigation"
496
+ type: TREE
497
+ menuOnly: false
498
+ ) {
499
+ id
500
+ title
501
+ path
502
+ related {
503
+ id
504
+ attributes {
505
+ __typename
506
+
507
+ ... on Page {
508
+ Title
509
+ }
510
+
511
+ ... on WithFlowType {
512
+ Name
513
+ }
514
+ }
515
+ }
516
+ items {
517
+ id
518
+ title
519
+ path
520
+ related {
521
+ id
522
+ attributes {
523
+ __typename
524
+
525
+ ... on Page {
526
+ Title
527
+ }
528
+
529
+ ... on WithFlowType {
530
+ Name
531
+ }
532
+ }
533
+ }
534
+ }
535
+ }
536
+ }
537
+ ```
538
+
539
+ **Example response**
540
+
541
+ ```json
542
+ {
543
+ "data": {
544
+ "renderNavigation": [
545
+ {
546
+ "id": 8,
547
+ "title": "Test page",
548
+ "path": "/test-path",
549
+ "related": {
550
+ "id": 3,
551
+ "attributes": {
552
+ "__typename": "WithFlowType",
553
+ "Name": "Test"
554
+ }
555
+ },
556
+ "items": [
557
+ {
558
+ "id": 11,
559
+ "title": "Nested",
560
+ "path": "/test-path/nested-one",
561
+ "related": {
562
+ "id": 1,
563
+ "attributes": {
564
+ "__typename": "Page",
565
+ "Title": "Eg. Page title"
566
+ }
567
+ }
568
+ }
569
+ ]
570
+ },
571
+ {
572
+ "id": 10,
573
+ "title": "Another page",
574
+ "path": "/another",
575
+ "related": {
576
+ "id": 2,
577
+ "attributes": {
578
+ "__typename": "Page",
579
+ "Title": "dfdfdf"
580
+ }
581
+ },
582
+ "items": []
583
+ }
584
+ ]
585
+ }
586
+ }
587
+ ```
588
+
407
589
  ### Template name
408
590
 
409
591
  Depending on a content type `templateName` will be resolved differently
@@ -416,13 +598,22 @@ For single types a global name of this content type will be used as a template n
416
598
 
417
599
  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.
418
600
 
419
- ## 💬 Q&A
601
+ ## 💬 FAQ
602
+
603
+ ### GraphQL tricks
604
+
605
+ **Q:** I would like to use GraphQL schemas but I'm not getting renderNavigation query or even proper types as Navigation, NavigationItem etc. What should I do?
420
606
 
421
- ### Content Types
607
+ **A:** **A:** There is a one trick you might try. Strapi by default is ordering plugins by the way which takes `strapi-plugin-graphql` to initialize earlier than other plugins so types might not be injected. If you don't have it yet, please create `config/plugins.js` file and put there following lines (put `graphql` at the end):
422
608
 
423
- **Q:** I've recognized **Navigation Item** and **Navigation** collection types in the Collections sidebar section, but they are not working properly. What should I do?
609
+ ```js
610
+ module.exports = {
611
+ 'navigation': { enabled: true },
612
+ 'graphql': { enabled: true },
613
+ };
614
+ ```
424
615
 
425
- **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.
616
+ If you already got it, make sure that `navigation` plugin is inserted before `graphql`. That should do the job.
426
617
 
427
618
  ## 🤝 Contributing
428
619
 
@@ -437,6 +628,28 @@ Live example of plugin usage can be found in the [VirtusLab Strapi Examples](htt
437
628
 
438
629
  Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!
439
630
 
631
+ - Clone repository
632
+
633
+ ```
634
+ git clone git@github.com:VirtusLab-Open-Source/strapi-plugin-navigation.git
635
+ ```
636
+
637
+ - Create a soft link in your strapi project to plugin build folder
638
+
639
+ ```sh
640
+ ln -s <...>/strapi-plugin-navigation/build <...>/strapi-project/src/plugins/navigation
641
+ ```
642
+
643
+ - Run build command
644
+
645
+ ```ts
646
+ // Watch for file changes
647
+ yarn develop
648
+
649
+ // or run build without nodemon
650
+ yarn build:dev
651
+ ```
652
+
440
653
  ## 👨‍💻 Community support
441
654
 
442
655
  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:
@@ -0,0 +1,2 @@
1
+ export const PermanentAlert: any;
2
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PermanentAlert = void 0;
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ const Alert_1 = require("@strapi/design-system/Alert");
9
+ exports.PermanentAlert = (0, styled_components_1.default)(Alert_1.Alert) `
10
+ button {
11
+ display: none;
12
+ }
13
+ `;
14
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1,7 @@
1
+ export default CollapseButton;
2
+ declare function CollapseButton({ toggle, collapsed, itemsCount }: {
3
+ toggle: any;
4
+ collapsed: any;
5
+ itemsCount: any;
6
+ }): JSX.Element;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,15 @@
1
- import React from 'react';
2
- import styled from 'styled-components'
3
- import { Flex } from '@strapi/design-system/Flex';
4
- import { Typography } from '@strapi/design-system/Typography';
5
- import { Icon } from '@strapi/design-system/Icon';
6
- import { CarretUp, CarretDown } from '@strapi/icons';
7
-
8
- const Wrapper = styled.div`
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ const Flex_1 = require("@strapi/design-system/Flex");
9
+ const Typography_1 = require("@strapi/design-system/Typography");
10
+ const Icon_1 = require("@strapi/design-system/Icon");
11
+ const icons_1 = require("@strapi/icons");
12
+ const Wrapper = styled_components_1.default.div `
9
13
  border-radius: 50%;
10
14
  background: #DCDCE4;
11
15
  width: 25px;
@@ -15,17 +19,12 @@ const Wrapper = styled.div`
15
19
  align-items: center;
16
20
  margin-right: 8px;
17
21
  `;
18
-
19
- const CollapseButton = ({ toggle, collapsed, itemsCount }) => (
20
- <Flex justifyContent='space-between' alignItems='center' onClick={toggle} cursor="pointer" style={{ marginRight: '16px' }}>
21
- <Wrapper>
22
- { collapsed ?
23
- <Icon as={CarretDown} width='7px' height='4px' /> :
24
- <Icon as={CarretUp} width='7px' height='4px' />
25
- }
26
- </Wrapper>
27
- <Typography variant="pi">{itemsCount} nested items</Typography>
28
- </Flex >
29
- );
30
-
31
- export default CollapseButton;
22
+ const CollapseButton = ({ toggle, collapsed, itemsCount }) => (react_1.default.createElement(Flex_1.Flex, { justifyContent: 'space-between', alignItems: 'center', onClick: toggle, cursor: "pointer", style: { marginRight: '16px' } },
23
+ react_1.default.createElement(Wrapper, null, collapsed ?
24
+ react_1.default.createElement(Icon_1.Icon, { as: icons_1.CarretDown, width: '7px', height: '4px' }) :
25
+ react_1.default.createElement(Icon_1.Icon, { as: icons_1.CarretUp, width: '7px', height: '4px' })),
26
+ react_1.default.createElement(Typography_1.Typography, { variant: "pi" },
27
+ itemsCount,
28
+ " nested items")));
29
+ exports.default = CollapseButton;
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,28 @@
1
+ export default ConfirmationDialog;
2
+ declare function ConfirmationDialog({ isVisible, isActionAsync, children, onConfirm, onCancel, header, labelCancel, labelConfirm, iconConfirm, mainIcon }: {
3
+ isVisible?: boolean | undefined;
4
+ isActionAsync?: boolean | undefined;
5
+ children: any;
6
+ onConfirm: any;
7
+ onCancel: any;
8
+ header: any;
9
+ labelCancel: any;
10
+ labelConfirm: any;
11
+ iconConfirm: any;
12
+ mainIcon?: JSX.Element | undefined;
13
+ }): JSX.Element;
14
+ declare namespace ConfirmationDialog {
15
+ namespace propTypes {
16
+ const isVisible: PropTypes.Requireable<boolean>;
17
+ const isActionAsync: PropTypes.Requireable<boolean>;
18
+ const children: PropTypes.Requireable<any>;
19
+ const header: PropTypes.Requireable<string>;
20
+ const labelCancel: PropTypes.Requireable<string>;
21
+ const labelConfirm: PropTypes.Requireable<string>;
22
+ const iconConfirm: PropTypes.Requireable<object>;
23
+ const onConfirm: PropTypes.Validator<(...args: any[]) => any>;
24
+ const onCancel: PropTypes.Validator<(...args: any[]) => any>;
25
+ }
26
+ }
27
+ import PropTypes from "prop-types";
28
+ //# sourceMappingURL=index.d.ts.map