strapi-plugin-navigation 2.3.2 → 2.4.0

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 (376) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +844 -0
  3. package/admin/src/components/AdditionalFieldInput/index.d.ts +2 -2
  4. package/admin/src/components/AdditionalFieldInput/index.js +36 -8
  5. package/admin/src/components/AdditionalFieldInput/types.d.ts +1 -1
  6. package/admin/src/components/DragButton/index.d.ts +3 -1
  7. package/admin/src/components/DragButton/index.js +2 -1
  8. package/admin/src/components/Item/ItemCardHeader/index.d.ts +1 -0
  9. package/admin/src/components/Item/ItemCardHeader/index.js +10 -5
  10. package/admin/src/components/Item/index.js +24 -4
  11. package/admin/src/components/NavigationItemList/index.js +1 -1
  12. package/admin/src/components/Search/index.d.ts +10 -4
  13. package/admin/src/components/Search/index.js +45 -6
  14. package/admin/src/components/TextArrayInput/index.d.ts +2 -1
  15. package/admin/src/pages/SettingsPage/common/const.d.ts +2 -0
  16. package/admin/src/pages/SettingsPage/common/const.js +5 -0
  17. package/admin/src/pages/SettingsPage/common/index.d.ts +2 -0
  18. package/admin/src/pages/SettingsPage/common/index.js +18 -0
  19. package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.js +27 -12
  20. package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.js +1 -1
  21. package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.d.ts +2 -3
  22. package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.js +12 -14
  23. package/admin/src/pages/SettingsPage/index.js +3 -2
  24. package/admin/src/pages/SettingsPage/utils/form.js +2 -1
  25. package/admin/src/pages/View/components/NavigationItemForm/index.js +49 -19
  26. package/admin/src/pages/View/components/NavigationItemForm/types.d.ts +2 -1
  27. package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +2 -0
  28. package/admin/src/pages/View/index.js +20 -10
  29. package/admin/src/pages/View/utils/form.d.ts +1 -1
  30. package/admin/src/pages/View/utils/types.d.ts +3 -0
  31. package/admin/src/pages/View/utils/types.js +3 -0
  32. package/admin/src/translations/ca.json +1 -0
  33. package/admin/src/translations/en.json +3 -0
  34. package/admin/src/translations/fr.json +1 -0
  35. package/admin/src/utils/api.js +1 -1
  36. package/package.json +76 -101
  37. package/server/content-types/index.d.ts +2 -0
  38. package/server/content-types/navigation/index.d.ts +1 -0
  39. package/server/content-types/navigation/index.js +3 -1
  40. package/server/content-types/navigation/lifecycles.d.ts +3 -0
  41. package/server/content-types/navigation/lifecycles.js +7 -0
  42. package/server/content-types/navigation-item/index.d.ts +1 -0
  43. package/server/content-types/navigation-item/index.js +3 -1
  44. package/server/content-types/navigation-item/lifecycles.d.ts +3 -0
  45. package/server/content-types/navigation-item/lifecycles.js +7 -0
  46. package/server/controllers/admin.js +19 -16
  47. package/server/controllers/client.js +2 -2
  48. package/server/graphql/queries/render-navigation-child.d.ts +1 -1
  49. package/server/graphql/queries/render-navigation.d.ts +1 -1
  50. package/server/graphql/types/index.js +1 -0
  51. package/server/graphql/types/navigation-item-additional-field-media.d.ts +5 -0
  52. package/server/graphql/types/navigation-item-additional-field-media.js +13 -0
  53. package/server/graphql/types/navigation-item.js +3 -0
  54. package/server/i18n/utils.d.ts +1 -0
  55. package/server/i18n/utils.js +4 -0
  56. package/server/index.d.ts +2 -0
  57. package/server/services/admin.js +18 -8
  58. package/server/services/client.js +42 -11
  59. package/server/services/common.js +16 -0
  60. package/server/utils/constant.d.ts +3 -0
  61. package/server/utils/constant.js +21 -1
  62. package/server/utils/functions.d.ts +11 -3
  63. package/server/utils/functions.js +21 -3
  64. package/strapi-server.d.ts +2 -0
  65. package/tsconfig.tsbuildinfo +1 -1
  66. package/types/contentTypes.d.ts +7 -2
  67. package/types/controllers.d.ts +4 -3
  68. package/types/index.d.ts +1 -0
  69. package/types/index.js +1 -0
  70. package/types/lifecycle.d.ts +22 -0
  71. package/types/lifecycle.js +3 -0
  72. package/types/services.d.ts +13 -1
  73. package/__mocks__/strapi.d.ts +0 -3
  74. package/__mocks__/strapi.d.ts.map +0 -1
  75. package/__mocks__/strapi.js +0 -206
  76. package/__mocks__/strapi.js.map +0 -1
  77. package/admin/src/components/AdditionalFieldInput/index.d.ts.map +0 -1
  78. package/admin/src/components/AdditionalFieldInput/index.js.map +0 -1
  79. package/admin/src/components/AdditionalFieldInput/types.d.ts.map +0 -1
  80. package/admin/src/components/AdditionalFieldInput/types.js.map +0 -1
  81. package/admin/src/components/Alert/styles.d.ts.map +0 -1
  82. package/admin/src/components/Alert/styles.js.map +0 -1
  83. package/admin/src/components/CollapseButton/index.d.ts.map +0 -1
  84. package/admin/src/components/CollapseButton/index.js.map +0 -1
  85. package/admin/src/components/ConfirmationDialog/index.d.ts.map +0 -1
  86. package/admin/src/components/ConfirmationDialog/index.js.map +0 -1
  87. package/admin/src/components/DragButton/index.d.ts.map +0 -1
  88. package/admin/src/components/DragButton/index.js.map +0 -1
  89. package/admin/src/components/EmptyView/index.d.ts.map +0 -1
  90. package/admin/src/components/EmptyView/index.js.map +0 -1
  91. package/admin/src/components/Item/ItemCardBadge/index.d.ts.map +0 -1
  92. package/admin/src/components/Item/ItemCardBadge/index.js.map +0 -1
  93. package/admin/src/components/Item/ItemCardHeader/Wrapper.d.ts.map +0 -1
  94. package/admin/src/components/Item/ItemCardHeader/Wrapper.js.map +0 -1
  95. package/admin/src/components/Item/ItemCardHeader/icons.d.ts.map +0 -1
  96. package/admin/src/components/Item/ItemCardHeader/icons.js.map +0 -1
  97. package/admin/src/components/Item/ItemCardHeader/index.d.ts.map +0 -1
  98. package/admin/src/components/Item/ItemCardHeader/index.js.map +0 -1
  99. package/admin/src/components/Item/ItemCardRemovedOverlay/index.d.ts.map +0 -1
  100. package/admin/src/components/Item/ItemCardRemovedOverlay/index.js.map +0 -1
  101. package/admin/src/components/Item/Wrapper.d.ts.map +0 -1
  102. package/admin/src/components/Item/Wrapper.js.map +0 -1
  103. package/admin/src/components/Item/index.d.ts.map +0 -1
  104. package/admin/src/components/Item/index.js.map +0 -1
  105. package/admin/src/components/NavigationItemList/Wrapper.d.ts.map +0 -1
  106. package/admin/src/components/NavigationItemList/Wrapper.js.map +0 -1
  107. package/admin/src/components/NavigationItemList/index.d.ts.map +0 -1
  108. package/admin/src/components/NavigationItemList/index.js.map +0 -1
  109. package/admin/src/components/RestartAlert/index.d.ts.map +0 -1
  110. package/admin/src/components/RestartAlert/index.js.map +0 -1
  111. package/admin/src/components/Search/index.d.ts.map +0 -1
  112. package/admin/src/components/Search/index.js.map +0 -1
  113. package/admin/src/components/TextArrayInput/index.d.ts.map +0 -1
  114. package/admin/src/components/TextArrayInput/index.js.map +0 -1
  115. package/admin/src/components/icons/navigation.d.ts.map +0 -1
  116. package/admin/src/components/icons/navigation.js.map +0 -1
  117. package/admin/src/contexts/DataManagerContext.d.ts.map +0 -1
  118. package/admin/src/contexts/DataManagerContext.js.map +0 -1
  119. package/admin/src/hooks/useAllContentTypes.d.ts.map +0 -1
  120. package/admin/src/hooks/useAllContentTypes.js.map +0 -1
  121. package/admin/src/hooks/useDataManager.d.ts.map +0 -1
  122. package/admin/src/hooks/useDataManager.js.map +0 -1
  123. package/admin/src/hooks/useI18nCopyNavigationItemsModal.d.ts.map +0 -1
  124. package/admin/src/hooks/useI18nCopyNavigationItemsModal.js.map +0 -1
  125. package/admin/src/hooks/useNavigationConfig.d.ts.map +0 -1
  126. package/admin/src/hooks/useNavigationConfig.js.map +0 -1
  127. package/admin/src/hooks/useNavigationManager.d.ts.map +0 -1
  128. package/admin/src/hooks/useNavigationManager.js.map +0 -1
  129. package/admin/src/index.d.ts.map +0 -1
  130. package/admin/src/index.js.map +0 -1
  131. package/admin/src/pages/App/index.d.ts.map +0 -1
  132. package/admin/src/pages/App/index.js.map +0 -1
  133. package/admin/src/pages/DataManagerProvider/actions.d.ts.map +0 -1
  134. package/admin/src/pages/DataManagerProvider/actions.js.map +0 -1
  135. package/admin/src/pages/DataManagerProvider/index.d.ts.map +0 -1
  136. package/admin/src/pages/DataManagerProvider/index.js.map +0 -1
  137. package/admin/src/pages/DataManagerProvider/init.d.ts.map +0 -1
  138. package/admin/src/pages/DataManagerProvider/init.js.map +0 -1
  139. package/admin/src/pages/DataManagerProvider/reducer.d.ts.map +0 -1
  140. package/admin/src/pages/DataManagerProvider/reducer.js.map +0 -1
  141. package/admin/src/pages/NoAccessPage/index.d.ts.map +0 -1
  142. package/admin/src/pages/NoAccessPage/index.js.map +0 -1
  143. package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.d.ts.map +0 -1
  144. package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.js.map +0 -1
  145. package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.d.ts.map +0 -1
  146. package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.js.map +0 -1
  147. package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.d.ts.map +0 -1
  148. package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.js.map +0 -1
  149. package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.d.ts.map +0 -1
  150. package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.js.map +0 -1
  151. package/admin/src/pages/SettingsPage/index.d.ts.map +0 -1
  152. package/admin/src/pages/SettingsPage/index.js.map +0 -1
  153. package/admin/src/pages/SettingsPage/types.d.ts.map +0 -1
  154. package/admin/src/pages/SettingsPage/types.js.map +0 -1
  155. package/admin/src/pages/SettingsPage/utils/form.d.ts.map +0 -1
  156. package/admin/src/pages/SettingsPage/utils/form.js.map +0 -1
  157. package/admin/src/pages/SettingsPage/utils/functions.d.ts.map +0 -1
  158. package/admin/src/pages/SettingsPage/utils/functions.js.map +0 -1
  159. package/admin/src/pages/View/components/I18nCopyNavigationItems/index.d.ts.map +0 -1
  160. package/admin/src/pages/View/components/I18nCopyNavigationItems/index.js.map +0 -1
  161. package/admin/src/pages/View/components/NavigationContentHeader/index.d.ts.map +0 -1
  162. package/admin/src/pages/View/components/NavigationContentHeader/index.js.map +0 -1
  163. package/admin/src/pages/View/components/NavigationHeader/index.d.ts.map +0 -1
  164. package/admin/src/pages/View/components/NavigationHeader/index.js.map +0 -1
  165. package/admin/src/pages/View/components/NavigationHeader/styles.d.ts.map +0 -1
  166. package/admin/src/pages/View/components/NavigationHeader/styles.js.map +0 -1
  167. package/admin/src/pages/View/components/NavigationItemForm/index.d.ts.map +0 -1
  168. package/admin/src/pages/View/components/NavigationItemForm/index.js.map +0 -1
  169. package/admin/src/pages/View/components/NavigationItemForm/types.d.ts.map +0 -1
  170. package/admin/src/pages/View/components/NavigationItemForm/types.js.map +0 -1
  171. package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts.map +0 -1
  172. package/admin/src/pages/View/components/NavigationItemForm/utils/form.js.map +0 -1
  173. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.d.ts.map +0 -1
  174. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js.map +0 -1
  175. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.d.ts.map +0 -1
  176. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js.map +0 -1
  177. package/admin/src/pages/View/components/NavigationItemPopup/index.d.ts.map +0 -1
  178. package/admin/src/pages/View/components/NavigationItemPopup/index.js.map +0 -1
  179. package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.d.ts.map +0 -1
  180. package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.js.map +0 -1
  181. package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.d.ts.map +0 -1
  182. package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.js.map +0 -1
  183. package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.d.ts.map +0 -1
  184. package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.js.map +0 -1
  185. package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.d.ts.map +0 -1
  186. package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.js.map +0 -1
  187. package/admin/src/pages/View/components/NavigationManager/Footer/index.d.ts.map +0 -1
  188. package/admin/src/pages/View/components/NavigationManager/Footer/index.js.map +0 -1
  189. package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts.map +0 -1
  190. package/admin/src/pages/View/components/NavigationManager/Form/index.js.map +0 -1
  191. package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.d.ts.map +0 -1
  192. package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.js.map +0 -1
  193. package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.d.ts.map +0 -1
  194. package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.js.map +0 -1
  195. package/admin/src/pages/View/components/NavigationManager/index.d.ts.map +0 -1
  196. package/admin/src/pages/View/components/NavigationManager/index.js.map +0 -1
  197. package/admin/src/pages/View/components/NavigationManager/types.d.ts.map +0 -1
  198. package/admin/src/pages/View/components/NavigationManager/types.js.map +0 -1
  199. package/admin/src/pages/View/index.d.ts.map +0 -1
  200. package/admin/src/pages/View/index.js.map +0 -1
  201. package/admin/src/pages/View/utils/form.d.ts.map +0 -1
  202. package/admin/src/pages/View/utils/form.js.map +0 -1
  203. package/admin/src/pages/View/utils/index.d.ts.map +0 -1
  204. package/admin/src/pages/View/utils/index.js.map +0 -1
  205. package/admin/src/pages/View/utils/parsers.d.ts.map +0 -1
  206. package/admin/src/pages/View/utils/parsers.js.map +0 -1
  207. package/admin/src/permissions.d.ts.map +0 -1
  208. package/admin/src/permissions.js.map +0 -1
  209. package/admin/src/pluginId.d.ts.map +0 -1
  210. package/admin/src/pluginId.js.map +0 -1
  211. package/admin/src/translations/index.d.ts.map +0 -1
  212. package/admin/src/translations/index.js.map +0 -1
  213. package/admin/src/utils/api.d.ts.map +0 -1
  214. package/admin/src/utils/api.js.map +0 -1
  215. package/admin/src/utils/enums.d.ts.map +0 -1
  216. package/admin/src/utils/enums.js.map +0 -1
  217. package/admin/src/utils/functions.d.ts.map +0 -1
  218. package/admin/src/utils/functions.js.map +0 -1
  219. package/admin/src/utils/index.d.ts.map +0 -1
  220. package/admin/src/utils/index.js.map +0 -1
  221. package/permissions.d.ts.map +0 -1
  222. package/permissions.js.map +0 -1
  223. package/server/bootstrap/index.d.ts.map +0 -1
  224. package/server/bootstrap/index.js.map +0 -1
  225. package/server/config/index.d.ts.map +0 -1
  226. package/server/config/index.js.map +0 -1
  227. package/server/config/setupStrategy.d.ts.map +0 -1
  228. package/server/config/setupStrategy.js.map +0 -1
  229. package/server/content-types/audience/index.d.ts.map +0 -1
  230. package/server/content-types/audience/index.js.map +0 -1
  231. package/server/content-types/audience/schema.d.ts.map +0 -1
  232. package/server/content-types/audience/schema.js.map +0 -1
  233. package/server/content-types/index.d.ts.map +0 -1
  234. package/server/content-types/index.js.map +0 -1
  235. package/server/content-types/navigation/index.d.ts.map +0 -1
  236. package/server/content-types/navigation/index.js.map +0 -1
  237. package/server/content-types/navigation/schema.d.ts.map +0 -1
  238. package/server/content-types/navigation/schema.js.map +0 -1
  239. package/server/content-types/navigation-item/index.d.ts.map +0 -1
  240. package/server/content-types/navigation-item/index.js.map +0 -1
  241. package/server/content-types/navigation-item/schema.d.ts.map +0 -1
  242. package/server/content-types/navigation-item/schema.js.map +0 -1
  243. package/server/content-types/navigations-items-related/index.d.ts.map +0 -1
  244. package/server/content-types/navigations-items-related/index.js.map +0 -1
  245. package/server/content-types/navigations-items-related/schema.d.ts.map +0 -1
  246. package/server/content-types/navigations-items-related/schema.js.map +0 -1
  247. package/server/controllers/admin.d.ts.map +0 -1
  248. package/server/controllers/admin.js.map +0 -1
  249. package/server/controllers/client.d.ts.map +0 -1
  250. package/server/controllers/client.js.map +0 -1
  251. package/server/controllers/index.d.ts.map +0 -1
  252. package/server/controllers/index.js.map +0 -1
  253. package/server/destroy.d.ts.map +0 -1
  254. package/server/destroy.js.map +0 -1
  255. package/server/graphql/config.d.ts.map +0 -1
  256. package/server/graphql/config.js.map +0 -1
  257. package/server/graphql/index.d.ts.map +0 -1
  258. package/server/graphql/index.js.map +0 -1
  259. package/server/graphql/queries/index.d.ts.map +0 -1
  260. package/server/graphql/queries/index.js.map +0 -1
  261. package/server/graphql/queries/render-navigation-child.d.ts.map +0 -1
  262. package/server/graphql/queries/render-navigation-child.js.map +0 -1
  263. package/server/graphql/queries/render-navigation.d.ts.map +0 -1
  264. package/server/graphql/queries/render-navigation.js.map +0 -1
  265. package/server/graphql/resolvers-config.d.ts.map +0 -1
  266. package/server/graphql/resolvers-config.js.map +0 -1
  267. package/server/graphql/setupStrategy.d.ts.map +0 -1
  268. package/server/graphql/setupStrategy.js.map +0 -1
  269. package/server/graphql/types/content-types-name-fields.d.ts.map +0 -1
  270. package/server/graphql/types/content-types-name-fields.js.map +0 -1
  271. package/server/graphql/types/content-types.d.ts.map +0 -1
  272. package/server/graphql/types/content-types.js.map +0 -1
  273. package/server/graphql/types/create-navigation-item.d.ts.map +0 -1
  274. package/server/graphql/types/create-navigation-item.js.map +0 -1
  275. package/server/graphql/types/create-navigation-related.d.ts.map +0 -1
  276. package/server/graphql/types/create-navigation-related.js.map +0 -1
  277. package/server/graphql/types/create-navigation.d.ts.map +0 -1
  278. package/server/graphql/types/create-navigation.js.map +0 -1
  279. package/server/graphql/types/index.d.ts.map +0 -1
  280. package/server/graphql/types/index.js.map +0 -1
  281. package/server/graphql/types/navigation-config.d.ts.map +0 -1
  282. package/server/graphql/types/navigation-config.js.map +0 -1
  283. package/server/graphql/types/navigation-details.d.ts.map +0 -1
  284. package/server/graphql/types/navigation-details.js.map +0 -1
  285. package/server/graphql/types/navigation-item-related-data.d.ts.map +0 -1
  286. package/server/graphql/types/navigation-item-related-data.js.map +0 -1
  287. package/server/graphql/types/navigation-item-related.d.ts.map +0 -1
  288. package/server/graphql/types/navigation-item-related.js.map +0 -1
  289. package/server/graphql/types/navigation-item.d.ts.map +0 -1
  290. package/server/graphql/types/navigation-item.js.map +0 -1
  291. package/server/graphql/types/navigation-render-type.d.ts.map +0 -1
  292. package/server/graphql/types/navigation-render-type.js.map +0 -1
  293. package/server/graphql/types/navigation.d.ts.map +0 -1
  294. package/server/graphql/types/navigation.js.map +0 -1
  295. package/server/i18n/constant.d.ts.map +0 -1
  296. package/server/i18n/constant.js.map +0 -1
  297. package/server/i18n/errors.d.ts.map +0 -1
  298. package/server/i18n/errors.js.map +0 -1
  299. package/server/i18n/graphQLEnhancers.d.ts.map +0 -1
  300. package/server/i18n/graphQLEnhancers.js.map +0 -1
  301. package/server/i18n/index.d.ts.map +0 -1
  302. package/server/i18n/index.js.map +0 -1
  303. package/server/i18n/navigationSetupStrategy.d.ts.map +0 -1
  304. package/server/i18n/navigationSetupStrategy.js.map +0 -1
  305. package/server/i18n/serviceEnhancers.d.ts.map +0 -1
  306. package/server/i18n/serviceEnhancers.js.map +0 -1
  307. package/server/i18n/types.d.ts.map +0 -1
  308. package/server/i18n/types.js.map +0 -1
  309. package/server/i18n/utils.d.ts.map +0 -1
  310. package/server/i18n/utils.js.map +0 -1
  311. package/server/index.d.ts.map +0 -1
  312. package/server/index.js.map +0 -1
  313. package/server/navigation/index.d.ts.map +0 -1
  314. package/server/navigation/index.js.map +0 -1
  315. package/server/navigation/setupStrategy.d.ts.map +0 -1
  316. package/server/navigation/setupStrategy.js.map +0 -1
  317. package/server/register/index.d.ts.map +0 -1
  318. package/server/register/index.js.map +0 -1
  319. package/server/routes/admin.d.ts.map +0 -1
  320. package/server/routes/admin.js.map +0 -1
  321. package/server/routes/client.d.ts.map +0 -1
  322. package/server/routes/client.js.map +0 -1
  323. package/server/routes/index.d.ts.map +0 -1
  324. package/server/routes/index.js.map +0 -1
  325. package/server/services/__tests__/service.test.d.ts +0 -2
  326. package/server/services/__tests__/service.test.d.ts.map +0 -1
  327. package/server/services/__tests__/service.test.js +0 -131
  328. package/server/services/__tests__/service.test.js.map +0 -1
  329. package/server/services/admin.d.ts.map +0 -1
  330. package/server/services/admin.js.map +0 -1
  331. package/server/services/client.d.ts.map +0 -1
  332. package/server/services/client.js.map +0 -1
  333. package/server/services/common.d.ts.map +0 -1
  334. package/server/services/common.js.map +0 -1
  335. package/server/services/index.d.ts.map +0 -1
  336. package/server/services/index.js.map +0 -1
  337. package/server/utils/__tests__/functions.test.d.ts +0 -2
  338. package/server/utils/__tests__/functions.test.d.ts.map +0 -1
  339. package/server/utils/__tests__/functions.test.js +0 -153
  340. package/server/utils/__tests__/functions.test.js.map +0 -1
  341. package/server/utils/constant.d.ts.map +0 -1
  342. package/server/utils/constant.js.map +0 -1
  343. package/server/utils/functions.d.ts.map +0 -1
  344. package/server/utils/functions.js.map +0 -1
  345. package/server/utils/index.d.ts.map +0 -1
  346. package/server/utils/index.js.map +0 -1
  347. package/setup-package.d.ts +0 -2
  348. package/setup-package.d.ts.map +0 -1
  349. package/setup-package.js +0 -19
  350. package/setup-package.js.map +0 -1
  351. package/strapi-admin.d.ts.map +0 -1
  352. package/strapi-admin.js.map +0 -1
  353. package/strapi-server.d.ts.map +0 -1
  354. package/strapi-server.js.map +0 -1
  355. package/types/bootstrap.d.ts.map +0 -1
  356. package/types/bootstrap.js.map +0 -1
  357. package/types/config.d.ts.map +0 -1
  358. package/types/config.js.map +0 -1
  359. package/types/contentTypes.d.ts.map +0 -1
  360. package/types/contentTypes.js.map +0 -1
  361. package/types/controllers.d.ts.map +0 -1
  362. package/types/controllers.js.map +0 -1
  363. package/types/graphQL.d.ts.map +0 -1
  364. package/types/graphQL.js.map +0 -1
  365. package/types/i18n.d.ts.map +0 -1
  366. package/types/i18n.js.map +0 -1
  367. package/types/index.d.ts.map +0 -1
  368. package/types/index.js.map +0 -1
  369. package/types/services.d.ts.map +0 -1
  370. package/types/services.js.map +0 -1
  371. package/types/utils.d.ts.map +0 -1
  372. package/types/utils.js.map +0 -1
  373. package/utils/InvalidParamNavigationError.d.ts.map +0 -1
  374. package/utils/InvalidParamNavigationError.js.map +0 -1
  375. package/utils/NavigationError.d.ts.map +0 -1
  376. package/utils/NavigationError.js.map +0 -1
package/README.md ADDED
@@ -0,0 +1,844 @@
1
+ <div align="center" width="150px">
2
+ <img style="width: 150px; height: auto;" src="public/assets/logo.png" alt="Logo - Strapi Navigation plugin" />
3
+ </div>
4
+ <div align="center">
5
+ <h1>Strapi v4 - Navigation plugin</h1>
6
+ <p>Create consumable navigation with a simple and straightforward visual builder</p>
7
+ <a href="https://www.npmjs.org/package/strapi-plugin-navigation">
8
+ <img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/VirtusLab-Open-Source/strapi-plugin-navigation?label=npm&logo=npm">
9
+ </a>
10
+ <a href="https://www.npmjs.org/package/strapi-plugin-navigation">
11
+ <img src="https://img.shields.io/npm/dm/strapi-plugin-navigation.svg" alt="Monthly download on NPM" />
12
+ </a>
13
+ <a href="https://circleci.com/gh/VirtusLab/strapi-plugin-navigation">
14
+ <img src="https://circleci.com/gh/VirtusLab-Open-Source/strapi-plugin-navigation.svg?style=shield" alt="CircleCI" />
15
+ </a>
16
+ <a href="https://codecov.io/gh/VirtusLab/strapi-plugin-navigation">
17
+ <img src="https://codecov.io/gh/VirtusLab/strapi-plugin-navigation/coverage.svg?branch=master" alt="codecov.io" />
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>
25
+ </div>
26
+
27
+ ---
28
+
29
+ <div style="margin: 20px 0" align="center">
30
+ <img style="width: 100%; height: auto;" src="public/assets/preview.png" alt="UI preview" />
31
+ </div>
32
+
33
+ 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:
34
+
35
+ - Flat
36
+ - Tree (nested)
37
+ - RFR (ready for handling by Redux First Router)
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. [👤 RBAC](#-rbac)
49
+ 8. [🔐 Authorization strategy](#-authorization-strategy)
50
+ 9. [🕸️ Public API specification](#%EF%B8%8F-public-api-specification)
51
+ - [REST API](#rest-api)
52
+ - [GraphQL API](#graphql-api)
53
+ 10. [🔌 Extensions](#-extensions)
54
+ 11. [🌿 Model lifecycle hooks](#model-life-cycle-hooks)
55
+ 12. [🧩 Examples](#-examples)
56
+ 13. [💬 FAQ](#-faq)
57
+ 14. [🤝 Contributing](#-contributing)
58
+ 15. [👨‍💻 Community support](#-community-support)
59
+
60
+ ## ✨ Features
61
+
62
+ - **Navigation Public API:** Simple and ready for use API endpoint for consuming the navigation structure you've created
63
+ - **Visual builder:** Elegant and easy to use visual builder
64
+ - **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
65
+ - **Different types of navigation items:** Create navigation with items linked to internal types, to external links or wrapper elements to keep structure clean
66
+ - **Multiple navigations:** Create as many Navigation containers as you want, setup them and use in the consumer application
67
+ - **Light / Dark mode compatible:** By design we're supporting Strapi ☀️ Light / 🌙 Dark modes
68
+ - **Webhooks integration:** Changes to navigation will trigger 'entry.update' or 'entry.create' webhook events.
69
+ - **Customizable:** Possibility to customize the options like: available Content Types, Maximum level for "attach to menu", Additional fields (audience)
70
+ - **[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
+
72
+ ## ⚙️ Versions
73
+
74
+ - **Strapi v4** - (current) - [v2.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation)
75
+ - **Strapi v3** - [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/strapi-v3)
76
+
77
+ ## ⏳ Installation
78
+
79
+ ### Via Strapi Markerplace
80
+
81
+ 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.
82
+
83
+ <div style="margin: 20px 0" align="center">
84
+ <img style="width: 100%; height: auto;" src="public/assets/marketplace.png" alt="Strapi In-App Marketplace" />
85
+ </div>
86
+
87
+ ### Via command line
88
+
89
+ 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/).
90
+
91
+ ```bash
92
+ yarn add strapi-plugin-navigation@latest
93
+ ```
94
+
95
+ After successful installation you've to re-build your Strapi instance. To archive that simply use:
96
+
97
+ ```bash
98
+ yarn build
99
+ yarn develop
100
+ ```
101
+
102
+ or just run Strapi in the development mode with `--watch-admin` option:
103
+
104
+ ```bash
105
+ yarn develop --watch-admin
106
+ ```
107
+
108
+ The **UI Navigation** plugin should appear in the **Plugins** section of Strapi sidebar after you run app again.
109
+
110
+ You can manage your multiple navigation containers by going to the **Navigation** manage view by clicking "Manage" button.
111
+
112
+ <div style="margin: 20px 0" align="center">
113
+ <img style="width: 100%; height: auto;" src="public/assets/manager-view.png" alt="Navigation Manager View" />
114
+ </div>
115
+
116
+ As a next step you must configure your the plugin by the way you want to. See [**Configuration**](#🔧-configuration) section.
117
+
118
+ All done. Enjoy 🎉
119
+
120
+ ## 🖐 Requirements
121
+
122
+ 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>.
123
+
124
+ **Supported Strapi versions**:
125
+
126
+ - Strapi v4.20.x (recently tested)
127
+ - Strapi v4.x
128
+
129
+ > 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).
130
+
131
+ **We recommend always using the latest version of Strapi to start your new projects**.
132
+
133
+ ## 🔧 Configuration
134
+
135
+ 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.
136
+
137
+ ### In `v2.0.3` and newer
138
+
139
+ Version `2.0.3` introduces the intuitive **Settings** page which you can easily access via `Strapi Settings -> Section: Navigation Plugin -> Configuration`.
140
+
141
+ 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.
142
+
143
+ <div style="margin: 20px 0" align="center">
144
+ <img style="width: 100%; height: auto;" src="public/assets/configuration.png" alt="Plugin configuration" />
145
+ </div>
146
+
147
+ > *Note*
148
+ > 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.
149
+
150
+ ### In `v2.0.2` and older + default configuration state for `v2.0.3` and newer
151
+
152
+ Config for this plugin is stored as a part of the `config/plugins.js` or `config/<env>/plugins.js` file. You can use the 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.
153
+
154
+ > *Note v2.0.3 and newer only*
155
+ > Changing this file will not automatically change plugin configuration. To synchronize plugin's config with plugins.js file, it is necessary to restore configuration through the settings page
156
+
157
+ > *Note for newer than v2.2.0*
158
+ > `slugify` as been removed. **THIS A BREAKING CHANGE**
159
+
160
+ ```js
161
+ module.exports = ({ env }) => ({
162
+ // ...
163
+ navigation: {
164
+ enabled: true,
165
+ config: {
166
+ additionalFields: ['audience', { name: 'my_custom_field', type: 'boolean', label: 'My custom field' }],
167
+ contentTypes: ['api::page.page'],
168
+ contentTypesNameFields: {
169
+ 'api::page.page': ['title']
170
+ },
171
+ pathDefaultFields: {
172
+ 'api::page.page': ['slug']
173
+ },
174
+ allowedLevels: 2,
175
+ gql: {...},
176
+ }
177
+ }
178
+ });
179
+ ```
180
+
181
+ ### Properties
182
+ - `additionalFields` - Additional fields for navigation items. More **[ here ](#additional-fields)**
183
+ - `allowedLevels` - Maximum level for which you're able to mark item as "Menu attached"
184
+ - `contentTypes` - UIDs of related content types
185
+ - `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`
186
+ - `pathDefaultFields` - The attribute to copy the default path from per content type. Syntax: `'api::<collection name>.<content type name>': ['url_slug', 'path']`
187
+ - `gql` - If you're using GraphQL that's the right place to put all necessary settings. More **[ here ](#gql-configuration)**
188
+ - `i18nEnabled` - should you want to manage multi-locale content via navigation set this value `Enabled`. More **[ here ](#i18n-internationalization)**
189
+ - `cascadeMenuAttached` - If you don't want "Menu attached" to cascade on child items set this value `Disabled`.
190
+
191
+ ### Properties
192
+
193
+ ### Additional Fields
194
+ It is advised to configure additional fields through the plugin's Settings Page. There you can find the table of custom fields and toggle input for the audience field. When enabled, the audience field can be customized through the content manager. Custom fields can be added, edited, toggled, and removed with the use of the table provided on the Settings Page. When removing custom fields be advised that their values in navigation items will be lost. Disabling the custom fields will not affect the data and can be done with no consequence of loosing information.
195
+
196
+ Creating configuration for additional fields with the `config.js` file should be done with caution. Config object contains the `additionalFields` property of type `Array<CustomField | 'audience'>`, where CustomField is of type `{ type: 'string' | 'boolean' | { "name": string, "url": string, "mime": string, "width": number, "height": number, "previewUrl": string }, name: string, label: string }`. When creating custom fields be advised that the `name` property has to be unique. When editing a custom field it is advised not to edit its `name` and `type` properties. After config has been restored the custom fields that are not present in `config.js` file will be deleted and their values in navigation items will be lost.
197
+
198
+ ## 🔧 GQL Configuration
199
+ 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:
200
+
201
+ > **Important!**
202
+ > If you're using `config/plugins.js` to configure your plugins , please put `navigation` property before `graphql`. Otherwise types are not going to be properly added to GraphQL Schema. That's because of dynamic types which base on plugin configuration which are added on `bootstrap` stage, not `register`. This is not valid if you're using `graphql` plugin without any custom configuration, so most of cases in real.
203
+
204
+ ```gql
205
+ master: Int
206
+ items: [NavigationItem]
207
+ related: NavigationRelated
208
+ ```
209
+
210
+ This prop should look as follows:
211
+
212
+ ```js
213
+ gql: {
214
+ navigationItemRelated: ['<your GQL related content types>'],
215
+ },
216
+ ```
217
+
218
+ for example:
219
+
220
+ ```js
221
+ gql: {
222
+ navigationItemRelated: ['Page', 'UploadFile'],
223
+ },
224
+ ```
225
+ where `Page` and `UploadFile` are your type names for the **Content Types** you're referring by navigation items relations.
226
+
227
+ ## 🌍 i18n Internationalization
228
+
229
+ ### Settings
230
+
231
+ This feature is **opt-in**.
232
+
233
+ In order to use this functionality setting **default locale** is required. (See: Settings -> Internationalization)
234
+
235
+ 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.
236
+
237
+ 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).
238
+
239
+ 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.
240
+
241
+ ### Rendering
242
+
243
+ 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:
244
+
245
+ ```https://yourdomain.cool/api/navigation/render/1?locale=fr```
246
+
247
+ or
248
+
249
+ ```https://yourdomain.cool/api/navigation/render/main-navigation?locale=fr```
250
+
251
+ If `locale` is not specified whatever version used to be at id `1` will be returned.
252
+
253
+ Of course if you know that `fr` version is present at id `2` you can just query for that.
254
+
255
+ ### GraphQL
256
+
257
+ 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.
258
+
259
+ ## 👤 RBAC
260
+ Plugin provides granular permissions based on **Strapi RBAC** functionality within the editorial interface &amp; **Admin API**. Those settings are editable via the _Setings_ -> _Administration Panel_ -> _Roles_.
261
+
262
+ For any role different than **Super Admin**, to access the **Navigation panel** you must set following permissions:
263
+
264
+ ### Mandatory permissions
265
+ - _Plugins_ -> _Navigation_ -> _Read_ - gives you the access to **Navigation Panel**
266
+
267
+ ### Other permissions
268
+ - _Plugins_ -> _Navigation_ -> _Update_ - with this permission user is able to change Navigation structure
269
+ - _Plugins_ -> _Navigation_ -> _Settings_ - special permission for users that should be able to change plugin settings
270
+
271
+ ## 🔐 Authorization strategy
272
+ Is applied for **Public API** both for REST and GraphQL. You can manage is by two different ways. Those settings are editable via the _Setings_ -> _Users &amp; Permissions Plugin_ -> _Roles_.
273
+
274
+ ## User based
275
+ - _Public_ - as per description it's default role for any not authenticated user. By enabling **Public API** of the plugin here you're making it **fully public**, without **any permissions check**.
276
+ - _Authenticated_ - as per description this is default role for Strapi Users. If you enable **Public API** here, for any call made you must use the User authentication token as `Bearer <token>`.
277
+
278
+ ## Token based
279
+ - _Full Access_ - gives full access to every Strapi Content API including our plugin endpoints as well.
280
+ - _Custom_ - granural access management to every Strapi Content API endpoints as well as plugin **Public API** - _(recomended approach)_
281
+
282
+ > _Note: Token usage &amp Read-Only tokens_
283
+ > If you're aiming to use token based approach, for every call you must provide proper token in headers as `Bearer <token>`.
284
+ >
285
+ > Important: As the Read-Only tokens are dedicated to support just `find` and `findAll` endpoints from Strapi Content API, they are not covering access to plugin **Public API** `render` and `renderChild` endpoints. We recommend to use the `Custom` token type for fully granural and secured approach instead of `Full Access` ones.
286
+ >
287
+ > Reference: [Strapi - API Tokens](https://docs.strapi.io/dev-docs/configurations/api-tokens#usage)
288
+
289
+ ## Base Navigation Item model
290
+
291
+ ### Flat
292
+ ```json
293
+ {
294
+ "id": 1,
295
+ "title": "News",
296
+ "type": "INTERNAL",
297
+ "path": "news",
298
+ "externalPath": null,
299
+ "uiRouterKey": "News",
300
+ "menuAttached": false,
301
+ "parent": 8, // Parent Navigation Item 'id', null in case of root level
302
+ "master": 1, // Navigation 'id'
303
+ "createdAt": "2020-09-29T13:29:19.086Z",
304
+ "updatedAt": "2020-09-29T13:29:19.128Z",
305
+ "related": {/*<Content Type model >*/ },
306
+ "audience": []
307
+ }
308
+ ```
309
+
310
+ ### Tree
311
+ ```json
312
+ {
313
+ "title": "News",
314
+ "menuAttached": true,
315
+ "path": "/news",
316
+ "type": "INTERNAL",
317
+ "uiRouterKey": "news",
318
+ "slug": "benefits",
319
+ "external": false,
320
+ "related": {
321
+ // <Content Type model >
322
+ },
323
+ "items": [
324
+ {
325
+ "title": "External url",
326
+ "menuAttached": true,
327
+ "path": "http://example.com",
328
+ "type": "EXTERNAL",
329
+ "uiRouterKey": "generic",
330
+ "external": true
331
+ },
332
+ // < Tree Navigation Item models >
333
+ ]
334
+ }
335
+ ```
336
+
337
+ ### RFR
338
+ ```json
339
+ {
340
+ "id": "News",
341
+ "title": "News",
342
+ "templateName": "pages:1",
343
+ "related": {
344
+ "contentType": "page",
345
+ "collectionName": "pages",
346
+ "id": 1
347
+ },
348
+ "path": "/news",
349
+ "slug": "news",
350
+ "parent": null, // Parent Navigation Item 'id', null in case of root level
351
+ "menuAttached": true
352
+ }
353
+ ```
354
+
355
+ ## 🕸️ Public API specification
356
+
357
+ Plugin supports both **REST API** and **GraphQL API** exposed by Strapi.
358
+
359
+ **Query Params**
360
+
361
+ - `navigationIdOrSlug` - ID or slug for which your navigation structure is generated like for REST API:
362
+
363
+ > `https://localhost:1337/api/navigation/render/1`
364
+ > `https://localhost:1337/api/navigation/render/main-menu`
365
+
366
+ - `type` - Enum value representing structure type of returned navigation:
367
+ > `https://localhost:1337/api/navigation/render/1?type=FLAT`
368
+
369
+ - `menu` (`menuOnly` for GQL) - Boolean value for querying only navigation items that are attached to menu should be rendered eg.
370
+ > `https://localhost:1337/api/navigation/render/1?menu=true`
371
+
372
+ - `path` - String value for querying navigation items by its path:
373
+ > `https://localhost:1337/api/navigation/render/1?path=/home/about-us`
374
+
375
+ ### REST API
376
+
377
+ > **Important!**
378
+ > Version `v2.0.13` introduced breaking change!
379
+ > All responses have changed their structure. Related field will now be of type ContentType instead of Array\<ContentType\>
380
+
381
+ `GET <host>/api/navigation/?locale=<locale>&orderBy=<orderBy>&orderDirection=<orderDirection>`
382
+
383
+ NOTE: All params are optional
384
+
385
+ **Example URL**: `https://localhost:1337/api/navigation?locale=en`
386
+
387
+ **Example response body**
388
+
389
+ ```json
390
+ [
391
+ {
392
+ "id": 383,
393
+ "name": "Floor",
394
+ "slug": "floor-pl",
395
+ "visible": true,
396
+ "createdAt": "2023-09-29T12:45:54.399Z",
397
+ "updatedAt": "2023-09-29T13:44:08.702Z",
398
+ "localeCode": "pl"
399
+ },
400
+ {
401
+ "id": 384,
402
+ "name": "Floor",
403
+ "slug": "floor-fr",
404
+ "visible": true,
405
+ "createdAt": "2023-09-29T12:45:54.399Z",
406
+ "updatedAt": "2023-09-29T13:44:08.725Z",
407
+ "localeCode": "fr"
408
+ },
409
+ {
410
+ "id": 382,
411
+ "name": "Floor",
412
+ "slug": "floor",
413
+ "visible": true,
414
+ "createdAt": "2023-09-29T12:45:54.173Z",
415
+ "updatedAt": "2023-09-29T13:44:08.747Z",
416
+ "localeCode": "en"
417
+ },
418
+ {
419
+ "id": 374,
420
+ "name": "Main navigation",
421
+ "slug": "main-navigation-pl",
422
+ "visible": true,
423
+ "createdAt": "2023-09-29T12:22:30.373Z",
424
+ "updatedAt": "2023-09-29T13:44:08.631Z",
425
+ "localeCode": "pl"
426
+ },
427
+ {
428
+ "id": 375,
429
+ "name": "Main navigation",
430
+ "slug": "main-navigation-fr",
431
+ "visible": true,
432
+ "createdAt": "2023-09-29T12:22:30.373Z",
433
+ "updatedAt": "2023-09-29T13:44:08.658Z",
434
+ "localeCode": "fr"
435
+ },
436
+ {
437
+ "id": 373,
438
+ "name": "Main navigation",
439
+ "slug": "main-navigation",
440
+ "visible": true,
441
+ "createdAt": "2023-09-29T12:22:30.356Z",
442
+ "updatedAt": "2023-09-29T13:44:08.680Z",
443
+ "localeCode": "en"
444
+ }
445
+ ]
446
+ ```
447
+
448
+ `GET <host>/api/navigation/render/<navigationIdOrSlug>?type=<type>`
449
+
450
+ Return a rendered navigation structure depends on passed type (`TREE`, `RFR` or nothing to render as `FLAT`).
451
+
452
+ > 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.
453
+
454
+ **Example URL**: `https://localhost:1337/api/navigation/render/1`
455
+
456
+ **Example response body**
457
+
458
+ ```json
459
+ [
460
+ {
461
+ "id": 1,
462
+ "title": "News",
463
+ "type": "INTERNAL",
464
+ "path": "news",
465
+ "externalPath": null,
466
+ "uiRouterKey": "News",
467
+ "menuAttached": false,
468
+ "parent": null,
469
+ "master": 1,
470
+ "created_at": "2020-09-29T13:29:19.086Z",
471
+ "updated_at": "2020-09-29T13:29:19.128Z",
472
+ "related": {
473
+ "__contentType": "Page",
474
+ "id": 1,
475
+ "title": "News",
476
+ // ...
477
+ }
478
+ },
479
+ // ...
480
+ ]
481
+ ```
482
+
483
+ **Example URL**: `https://localhost:1337/api/navigation/render/1?type=TREE`
484
+
485
+ **Example response body**
486
+
487
+ ```json
488
+ [
489
+ {
490
+ "title": "News",
491
+ "menuAttached": true,
492
+ "path": "/news",
493
+ "type": "INTERNAL",
494
+ "uiRouterKey": "news",
495
+ "slug": "benefits",
496
+ "external": false,
497
+ "related": {
498
+ "__contentType": "Page",
499
+ "id": 1,
500
+ "title": "News",
501
+ // ...
502
+ },
503
+ "items": [
504
+ {
505
+ "title": "External url",
506
+ "menuAttached": true,
507
+ "path": "http://example.com",
508
+ "type": "EXTERNAL",
509
+ "uiRouterKey": "generic",
510
+ "external": true
511
+ },
512
+ // ...
513
+ ]
514
+ },
515
+ // ...
516
+ ]
517
+ ```
518
+
519
+ **Example URL**: `https://localhost:1337/api/navigation/render/1?type=RFR`
520
+
521
+ **Example response body**
522
+
523
+ ```json
524
+ {
525
+ "pages": {
526
+ "News": {
527
+ "id": "News",
528
+ "title": "News",
529
+ "templateName": "pages:1",
530
+ "related": {
531
+ "contentType": "page",
532
+ "collectionName": "pages",
533
+ "id": 1
534
+ },
535
+ "path": "/news",
536
+ "slug": "news",
537
+ "parent": null,
538
+ "menuAttached": true
539
+ },
540
+ "Community": {
541
+ "id": "Community",
542
+ "title": "Community",
543
+ "templateName": "pages:2",
544
+ "related": {
545
+ "contentType": "page",
546
+ "collectionName": "pages",
547
+ "id": 2
548
+ },
549
+ "path": "/community",
550
+ "slug": "community",
551
+ "parent": null,
552
+ "menuAttached": true
553
+ },
554
+ "Highlights": {
555
+ "id": "Highlights",
556
+ "title": "Highlights",
557
+ "templateName": "pages:3",
558
+ "related": {
559
+ "contentType": "page",
560
+ "collectionName": "pages",
561
+ "id": 3
562
+ },
563
+ "path": "/community/highlights",
564
+ "slug": "community-highlights",
565
+ "parent": "Community",
566
+ "menuAttached": false
567
+ },
568
+ // ...
569
+ },
570
+ "nav": {
571
+ "root": [
572
+ {
573
+ "label": "News",
574
+ "type": "internal",
575
+ "page": "News"
576
+ },
577
+ {
578
+ "label": "Community",
579
+ "type": "internal",
580
+ "page": "Community"
581
+ },
582
+ {
583
+ "label": "External url",
584
+ "type": "external",
585
+ "url": "http://example.com"
586
+ },
587
+ // ...
588
+ ],
589
+ "Community": [
590
+ {
591
+ "label": "Highlights",
592
+ "type": "internal",
593
+ "page": "Highlights"
594
+ },
595
+ // ...
596
+ ],
597
+ // ...
598
+ }
599
+ }
600
+ ```
601
+
602
+ ### GraphQL API
603
+
604
+ Same as [**REST API**](#rest-api) returns a rendered navigation structure depends on passed type (`TREE`, `RFR` or nothing to render as `FLAT`).
605
+
606
+ **Example request**
607
+
608
+ ```graphql
609
+ query {
610
+ renderNavigation(
611
+ navigationIdOrSlug: "main-navigation"
612
+ type: TREE
613
+ menuOnly: false
614
+ ) {
615
+ id
616
+ title
617
+ path
618
+ related {
619
+ id
620
+ attributes {
621
+ __typename
622
+
623
+ ... on Page {
624
+ Title
625
+ }
626
+
627
+ ... on WithFlowType {
628
+ Name
629
+ }
630
+ }
631
+ }
632
+ items {
633
+ id
634
+ title
635
+ path
636
+ related {
637
+ id
638
+ attributes {
639
+ __typename
640
+
641
+ ... on Page {
642
+ Title
643
+ }
644
+
645
+ ... on WithFlowType {
646
+ Name
647
+ }
648
+ }
649
+ }
650
+ }
651
+ }
652
+ }
653
+ ```
654
+
655
+ **Example response**
656
+
657
+ ```json
658
+ {
659
+ "data": {
660
+ "renderNavigation": [
661
+ {
662
+ "id": 8,
663
+ "title": "Test page",
664
+ "path": "/test-path",
665
+ "related": {
666
+ "id": 3,
667
+ "attributes": {
668
+ "__typename": "WithFlowType",
669
+ "Name": "Test"
670
+ }
671
+ },
672
+ "items": [
673
+ {
674
+ "id": 11,
675
+ "title": "Nested",
676
+ "path": "/test-path/nested-one",
677
+ "related": {
678
+ "id": 1,
679
+ "attributes": {
680
+ "__typename": "Page",
681
+ "Title": "Eg. Page title"
682
+ }
683
+ }
684
+ }
685
+ ]
686
+ },
687
+ {
688
+ "id": 10,
689
+ "title": "Another page",
690
+ "path": "/another",
691
+ "related": {
692
+ "__typename": "Page",
693
+ "Title": "Eg. Page title"
694
+ },
695
+ "items": []
696
+ }
697
+ ]
698
+ }
699
+ }
700
+ ```
701
+
702
+ ### Template name
703
+
704
+ Depending on a content type `templateName` will be resolved differently
705
+
706
+ For collection types it will be read from content type's attribute name `template` holding a component which definition has option named `templateName`.
707
+
708
+ 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`.
709
+
710
+ ## 🔌 Extensions
711
+
712
+ ### Slug generation
713
+
714
+ Slug generation is available as a controller and service. If you have custom requirements outside of what this plugin provides you can add your own logic with [plugins extensions](https://docs.strapi.io/developer-docs/latest/development/plugins-extension.html).
715
+
716
+ For example:
717
+
718
+ ```ts
719
+ // path: /admin/src/index.js
720
+
721
+ module.exports = {
722
+ // ...
723
+ bootstrap({ strapi }) {
724
+ const navigationCommonService = strapi.plugin("navigation").service("common");
725
+ const originalGetSlug = navigationCommonService.getSlug;
726
+ const preprocess = (q) => {
727
+ return q + "suffix";
728
+ };
729
+
730
+ navigationCommonService.getSlug = (query) => {
731
+ return originalGetSlug(preprocess(query));
732
+ };
733
+ },
734
+ };
735
+ ```
736
+
737
+ ## Model lifecycle hooks
738
+
739
+ Navigation plugin allows to register lifecycle hooks for `Navigation` and `NavigationItem` content types.
740
+
741
+ You can read more about lifecycle hooks [here](https://docs.strapi.io/dev-docs/backend-customization/models#lifecycle-hooks). (You can set a listener for all of the hooks).
742
+
743
+ Lifecycle hooks can be register either in `register()` or `bootstrap()` methods of your server. You can register more than one listener for a specified lifecycle hook. For example: you want to do three things on navigation item creation and do not want to handle all of these actions in one big function. You can split logic in as many listeners as you want.
744
+
745
+ Listeners can by sync and `async`.
746
+
747
+ >Be aware that lifecycle hooks registered in `register()` may be fired by plugin's bootstrapping. If you want listen to events triggered after server's startup use `bootstrap()`.
748
+
749
+ Example:
750
+
751
+ ```ts
752
+ const navigationCommonService = strapi
753
+ .plugin("navigation")
754
+ .service("common");
755
+
756
+ navigationCommonService.registerLifecycleHook({
757
+ callback: async ({ action, result }) => {
758
+ const saveResult = await logIntoSystem(action, result);
759
+
760
+ console.log(saveResult);
761
+ },
762
+ contentTypeName: "navigation",
763
+ hookName: "afterCreate",
764
+ });
765
+
766
+ navigationCommonService.registerLifecycleHook({
767
+ callback: async ({ action, result }) => {
768
+ const saveResult = await logIntoSystem(action, result);
769
+
770
+ console.log(saveResult);
771
+ },
772
+ contentTypeName: "navigation-item",
773
+ hookName: "afterCreate",
774
+ });
775
+ ```
776
+
777
+ ## 🧩 Examples
778
+
779
+ 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.
780
+
781
+ ## 💬 FAQ
782
+
783
+ ### GraphQL tricks
784
+
785
+ **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?
786
+
787
+ **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):
788
+
789
+ ```js
790
+ module.exports = {
791
+ 'navigation': { enabled: true },
792
+ 'graphql': { enabled: true },
793
+ };
794
+ ```
795
+
796
+ If you already got it, make sure that `navigation` plugin is inserted before `graphql`. That should do the job.
797
+
798
+ ## 🤝 Contributing
799
+
800
+ <div>
801
+ <a href="https://sharing.clickup.com/tl/xhcmx-43/strapiv-4-navigation-roadmap">
802
+ <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" />
803
+ </a>
804
+ <a href="https://sharing.clickup.com/b/6-169004201-2/strapiv-4-navigation-board">
805
+ <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" />
806
+ </a>
807
+ </div>
808
+
809
+ Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!
810
+
811
+ - Clone repository
812
+
813
+ ```
814
+ git clone git@github.com:VirtusLab-Open-Source/strapi-plugin-navigation.git
815
+ ```
816
+
817
+ - Create a soft link in your strapi project to plugin build folder
818
+
819
+ ```sh
820
+ ln -s <...>/strapi-plugin-navigation/build <...>/strapi-project/src/plugins/navigation
821
+ ```
822
+
823
+ - Run build command
824
+
825
+ ```ts
826
+ // Watch for file changes
827
+ yarn develop
828
+
829
+ // or run build without nodemon
830
+ yarn build:dev
831
+ ```
832
+
833
+ ## 👨‍💻 Community support
834
+
835
+ 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:
836
+
837
+ - [Discord](https://discord.strapi.io/) We're present on official Strapi Discord workspace. Find us by `[VirtusLab]` prefix and DM.
838
+ - [Slack - VirtusLab Open Source](https://virtuslab-oss.slack.com) We're present on a public channel #strapi-molecules
839
+ - [GitHub](https://github.com/VirtusLab/strapi-plugin-navigation/issues) (Bug reports, Contributions, Questions and Discussions)
840
+ - [E-mail](mailto:strapi@virtuslab.com) - we will respond back as soon as possible
841
+
842
+ ## 📝 License
843
+
844
+ [MIT License](LICENSE.md) Copyright (c) [VirtusLab Sp. z o.o.](https://virtuslab.com/) &amp; [Strapi Solutions](https://strapi.io/).