@strapi/admin 4.6.0-alpha.1 → 4.6.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 (248) hide show
  1. package/admin/src/components/AuthenticatedApp/index.js +13 -2
  2. package/admin/src/components/GlobalStyle/index.js +0 -5
  3. package/admin/src/content-manager/components/ComponentIcon/ComponentIcon.js +49 -0
  4. package/admin/src/content-manager/components/ComponentIcon/index.js +1 -0
  5. package/admin/src/content-manager/components/ComponentInitializer/index.js +1 -7
  6. package/admin/src/content-manager/components/{RepeatableComponent/DragPreview.js → DragLayer/ComponentDragPreview.js} +10 -11
  7. package/admin/src/content-manager/components/DragLayer/RelationDragPreview.js +75 -0
  8. package/admin/src/content-manager/components/DragLayer/index.js +23 -7
  9. package/admin/src/content-manager/components/DynamicZone/components/ComponentCard.js +17 -31
  10. package/admin/src/content-manager/components/DynamicZone/components/ComponentCategory.js +2 -2
  11. package/admin/src/content-manager/components/DynamicZone/components/DynamicComponent.js +129 -85
  12. package/admin/src/content-manager/components/DynamicZone/index.js +99 -24
  13. package/admin/src/content-manager/components/DynamicZone/utils/select.js +9 -5
  14. package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +76 -14
  15. package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +42 -25
  16. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/cleanData.js +24 -5
  17. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/recursivelyFindPathsBasedOnCondition.js +8 -1
  18. package/admin/src/content-manager/components/InputJSON/FieldWrapper.js +10 -2
  19. package/admin/src/content-manager/components/InputJSON/Label.js +2 -18
  20. package/admin/src/content-manager/components/InputJSON/index.js +7 -3
  21. package/admin/src/content-manager/components/NonRepeatableComponent/index.js +4 -0
  22. package/admin/src/content-manager/components/RelationInput/RelationInput.js +205 -74
  23. package/admin/src/content-manager/components/RelationInput/components/RelationItem.js +136 -21
  24. package/admin/src/content-manager/components/RelationInput/components/RelationList.js +1 -2
  25. package/admin/src/content-manager/components/RelationInput/constants.js +1 -0
  26. package/admin/src/content-manager/components/RelationInput/index.js +1 -0
  27. package/admin/src/content-manager/components/RelationInputDataManager/RelationInputDataManager.js +132 -10
  28. package/admin/src/content-manager/components/RepeatableComponent/components/Accordion.js +77 -0
  29. package/admin/src/content-manager/components/RepeatableComponent/components/Component.js +262 -0
  30. package/admin/src/content-manager/components/RepeatableComponent/{DraggedItem → components}/Preview.js +0 -0
  31. package/admin/src/content-manager/components/RepeatableComponent/index.js +148 -90
  32. package/admin/src/content-manager/components/RepeatableComponent/utils/getComponentErrorKeys.js +1 -1
  33. package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +1 -1
  34. package/admin/src/content-manager/components/Wysiwyg/Editor.js +1 -1
  35. package/admin/src/content-manager/hooks/index.js +2 -0
  36. package/admin/src/content-manager/hooks/useDragAndDrop.js +134 -0
  37. package/admin/src/content-manager/hooks/useKeyboardDragAndDrop.js +98 -0
  38. package/admin/src/content-manager/hooks/useLazyComponents/index.js +40 -15
  39. package/admin/src/content-manager/pages/EditSettingsView/components/DynamicZoneList.js +18 -38
  40. package/admin/src/content-manager/sharedReducers/crudReducer/actions.js +5 -0
  41. package/admin/src/content-manager/sharedReducers/crudReducer/constants.js +2 -0
  42. package/admin/src/content-manager/sharedReducers/crudReducer/reducer.js +7 -0
  43. package/admin/src/content-manager/utils/ItemTypes.js +1 -1
  44. package/admin/src/content-manager/utils/composeRefs.js +28 -0
  45. package/admin/src/content-manager/utils/getMaxTempKey.js +1 -1
  46. package/admin/src/content-manager/utils/index.js +7 -0
  47. package/admin/src/core/utils/axiosInstance.js +4 -2
  48. package/admin/src/hooks/index.js +1 -0
  49. package/admin/src/hooks/useFetchClient/index.js +23 -0
  50. package/admin/src/hooks/useSettingsMenu/init.js +0 -7
  51. package/admin/src/pages/Admin/Onboarding/index.js +42 -44
  52. package/admin/src/pages/App/index.js +20 -13
  53. package/admin/src/pages/AuthPage/components/Register/index.js +1 -1
  54. package/admin/src/pages/AuthPage/components/ResetPassword/index.js +1 -1
  55. package/admin/src/pages/HomePage/SocialLinks.js +4 -4
  56. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +2 -3
  57. package/admin/src/pages/SettingsPage/pages/Users/ListPage/ModalForm/index.js +23 -18
  58. package/admin/src/pages/SettingsPage/utils/defaultRoutes.js +0 -11
  59. package/admin/src/permissions/defaultPermissions.js +0 -4
  60. package/admin/src/translations/en.json +8 -8
  61. package/admin/src/translations/sk.json +274 -52
  62. package/admin/src/translations/tr.json +485 -5
  63. package/admin/src/utils/fetchClient.js +45 -0
  64. package/admin/src/utils/getFetchClient.js +10 -0
  65. package/admin/src/utils/index.js +1 -0
  66. package/admin/src/utils/uniqueAdminHash.js +22 -0
  67. package/build/2235.06c13219.chunk.js +106 -0
  68. package/build/2598.962797b2.chunk.js +159 -0
  69. package/build/4318.0bbd3f4b.chunk.js +30 -0
  70. package/build/4958.7c118f5e.chunk.js +276 -0
  71. package/build/5052.712419ea.chunk.js +65 -0
  72. package/build/7295.04ac49dc.chunk.js +114 -0
  73. package/build/805.ddcead70.chunk.js +138 -0
  74. package/build/{8633.8da5488a.chunk.js → 8633.59223842.chunk.js} +1 -1
  75. package/build/874.bde3ea04.chunk.js +104 -0
  76. package/build/{1233.80b05d66.chunk.js → 9159.ac968e72.chunk.js} +67 -67
  77. package/build/9707.77e475ee.chunk.js +101 -0
  78. package/build/Admin-authenticatedApp.9dd415b8.chunk.js +72 -0
  79. package/build/{Admin_homePage.54e33c2d.chunk.js → Admin_homePage.8945f71a.chunk.js} +5 -5
  80. package/build/{Admin_marketplace.8219fda6.chunk.js → Admin_marketplace.ed754a4a.chunk.js} +1 -1
  81. package/build/Admin_pluginsPage.67728975.chunk.js +6 -0
  82. package/build/{Admin_profilePage.e9fcce92.chunk.js → Admin_profilePage.60ab80bb.chunk.js} +1 -1
  83. package/build/{Admin_settingsPage.d3f48e9e.chunk.js → Admin_settingsPage.9ce40fed.chunk.js} +15 -15
  84. package/build/Upload_ConfigureTheView.7cb2a3fd.chunk.js +1 -0
  85. package/build/admin-app.d8fc7c4d.chunk.js +112 -0
  86. package/build/admin-edit-roles-page.f407538c.chunk.js +1 -0
  87. package/build/admin-edit-users.5547b126.chunk.js +10 -0
  88. package/build/{admin-users.a0748674.chunk.js → admin-users.4b6b47f8.chunk.js} +2 -2
  89. package/build/api-tokens-create-page.dd4ddfcb.chunk.js +1 -0
  90. package/build/api-tokens-edit-page.821c5a6c.chunk.js +1 -0
  91. package/build/{api-tokens-list-page.700e575f.chunk.js → api-tokens-list-page.50519ed7.chunk.js} +1 -1
  92. package/build/content-manager.f2214e32.chunk.js +1166 -0
  93. package/build/content-type-builder-list-view.4aea46fa.chunk.js +198 -0
  94. package/build/content-type-builder-translation-de-json.a52482c7.chunk.js +1 -0
  95. package/build/content-type-builder-translation-dk-json.a8616510.chunk.js +1 -0
  96. package/build/content-type-builder-translation-en-json.1d9a3c14.chunk.js +1 -0
  97. package/build/content-type-builder-translation-es-json.c3ea46fb.chunk.js +1 -0
  98. package/build/content-type-builder-translation-ko-json.3fb7ddc8.chunk.js +1 -0
  99. package/build/content-type-builder-translation-pl-json.9b2993b2.chunk.js +1 -0
  100. package/build/content-type-builder-translation-pt-BR-json.6d255441.chunk.js +1 -0
  101. package/build/content-type-builder-translation-sv-json.c608b9ca.chunk.js +1 -0
  102. package/build/content-type-builder-translation-tr-json.949e22eb.chunk.js +1 -0
  103. package/build/content-type-builder-translation-zh-json.b79513e4.chunk.js +1 -0
  104. package/build/content-type-builder.8a9a77f9.chunk.js +127 -0
  105. package/build/email-settings-page.c6e62f6b.chunk.js +15 -0
  106. package/build/email-translation-tr-json.8aa034bb.chunk.js +1 -0
  107. package/build/en-json.1abdade9.chunk.js +1 -0
  108. package/build/{i18n-settings-page.195d42fe.chunk.js → i18n-settings-page.ee572037.chunk.js} +1 -1
  109. package/build/i18n-translation-tr-json.34ca9d61.chunk.js +1 -0
  110. package/build/index.html +1 -1
  111. package/build/main.91f6e21e.js +4099 -0
  112. package/build/runtime~main.447b0382.js +2 -0
  113. package/build/sk-json.2af48064.chunk.js +1 -0
  114. package/build/sso-settings-page.91924df1.chunk.js +41 -0
  115. package/build/tr-json.eac8bd79.chunk.js +1 -0
  116. package/build/upload-settings.326cd9fd.chunk.js +89 -0
  117. package/build/upload-translation-en-json.32cf9aff.chunk.js +1 -0
  118. package/build/upload-translation-sk-json.fe86c53b.chunk.js +1 -0
  119. package/build/upload-translation-tr-json.b173223a.chunk.js +1 -0
  120. package/build/upload.2977cb13.chunk.js +38 -0
  121. package/build/users-advanced-settings-page.0c0b8230.chunk.js +13 -0
  122. package/build/users-email-settings-page.18d4a475.chunk.js +28 -0
  123. package/build/{users-permissions-translation-dk-json.fe39c74b.chunk.js → users-permissions-translation-dk-json.bad0b786.chunk.js} +1 -1
  124. package/build/{users-permissions-translation-en-json.765abf48.chunk.js → users-permissions-translation-en-json.aeab388a.chunk.js} +1 -1
  125. package/build/{users-permissions-translation-es-json.1bb9cde2.chunk.js → users-permissions-translation-es-json.152a923f.chunk.js} +1 -1
  126. package/build/{users-permissions-translation-ko-json.3be77775.chunk.js → users-permissions-translation-ko-json.6bd0ae22.chunk.js} +1 -1
  127. package/build/{users-permissions-translation-pl-json.1dbdd4a1.chunk.js → users-permissions-translation-pl-json.c6a02992.chunk.js} +1 -1
  128. package/build/{users-permissions-translation-sv-json.d5d11648.chunk.js → users-permissions-translation-sv-json.370d6eee.chunk.js} +1 -1
  129. package/build/users-permissions-translation-tr-json.9bebc250.chunk.js +1 -0
  130. package/build/{users-permissions-translation-zh-json.92f406f9.chunk.js → users-permissions-translation-zh-json.1fea833f.chunk.js} +1 -1
  131. package/build/users-providers-settings-page.25dd858e.chunk.js +1 -0
  132. package/build/users-roles-settings-page.8482a999.chunk.js +30 -0
  133. package/build/{webhook-edit-page.14ad1e6e.chunk.js → webhook-edit-page.dcc3d145.chunk.js} +4 -4
  134. package/build/{webhook-list-page.b87821f2.chunk.js → webhook-list-page.894e6959.chunk.js} +1 -1
  135. package/ee/server/services/passport/provider-registry.js +1 -1
  136. package/package.json +16 -22
  137. package/server/controllers/admin.js +2 -0
  138. package/server/routes/admin.js +1 -1
  139. package/server/services/metrics.js +5 -2
  140. package/server/services/role.js +1 -0
  141. package/utils/get-plugins-path.js +17 -3
  142. package/webpack.alias.js +0 -2
  143. package/admin/src/content-manager/components/BackHeader/index.js +0 -8
  144. package/admin/src/content-manager/components/Block/components.js +0 -28
  145. package/admin/src/content-manager/components/Block/index.js +0 -43
  146. package/admin/src/content-manager/components/Container/index.js +0 -7
  147. package/admin/src/content-manager/components/CustomInputCheckbox/components.js +0 -77
  148. package/admin/src/content-manager/components/CustomInputCheckbox/index.js +0 -53
  149. package/admin/src/content-manager/components/DynamicComponentCard/Wrapper.js +0 -63
  150. package/admin/src/content-manager/components/FilterOptionsCTA/index.js +0 -14
  151. package/admin/src/content-manager/components/FormTitle/index.js +0 -22
  152. package/admin/src/content-manager/components/FormWrapper/index.js +0 -20
  153. package/admin/src/content-manager/components/InputJSON/FieldError.js +0 -38
  154. package/admin/src/content-manager/components/LayoutTitle/index.js +0 -19
  155. package/admin/src/content-manager/components/PlusButton/index.js +0 -52
  156. package/admin/src/content-manager/components/PreviewCarret/components.js +0 -27
  157. package/admin/src/content-manager/components/PreviewCarret/index.js +0 -22
  158. package/admin/src/content-manager/components/RepeatableComponent/AccordionGroupCustom/index.js +0 -122
  159. package/admin/src/content-manager/components/RepeatableComponent/AddFieldButton.js +0 -58
  160. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/DraggingSibling.js +0 -72
  161. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/IconButtonCustoms.js +0 -32
  162. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/index.js +0 -322
  163. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/utils/connect.js +0 -11
  164. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/utils/index.js +0 -2
  165. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/utils/select.js +0 -30
  166. package/admin/src/content-manager/components/RepeatableComponent/utils/connect.js +0 -11
  167. package/admin/src/content-manager/components/RepeatableComponent/utils/select.js +0 -12
  168. package/admin/src/content-manager/components/SectionTitle/Title.js +0 -11
  169. package/admin/src/content-manager/components/SectionTitle/index.js +0 -26
  170. package/admin/src/content-manager/hooks/__test__/usePrev.test.js +0 -26
  171. package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/DynamicTable/TableRows/CellValue.js +0 -19
  172. package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/DynamicTable/TableRows/index.js +0 -65
  173. package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/ModalDialog/ActionItem.js +0 -25
  174. package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/ModalDialog/index.js +0 -76
  175. package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/hooks/useFormatTimeStamp.js +0 -24
  176. package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/index.js +0 -84
  177. package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/utils/tableHeaders.js +0 -37
  178. package/admin/src/pages/SettingsPage/pages/AuditLogs/ProtectedListPage/index.js +0 -12
  179. package/build/1551f4f60c37af51121f.woff2 +0 -0
  180. package/build/1920.74a262e7.chunk.js +0 -245
  181. package/build/1e59d2330b4c6deb84b3.ttf +0 -0
  182. package/build/20fd1704ea223900efa9.woff2 +0 -0
  183. package/build/2285773e6b4b172f07d9.woff +0 -0
  184. package/build/23f19bb08961f37aaf69.eot +0 -0
  185. package/build/2438.61291207.chunk.js +0 -2183
  186. package/build/2517.9b4940f3.chunk.js +0 -117
  187. package/build/2f517e09eb2ca6650ff5.svg +0 -3717
  188. package/build/4306.f03c2b46.chunk.js +0 -98
  189. package/build/4318.7931eee7.chunk.js +0 -30
  190. package/build/4689f52cc96215721344.svg +0 -801
  191. package/build/491974d108fe4002b2aa.ttf +0 -0
  192. package/build/4986.3820d11d.chunk.js +0 -145
  193. package/build/504.9aeff724.chunk.js +0 -758
  194. package/build/527940b104eb2ea366c8.ttf +0 -0
  195. package/build/77206a6bb316fa0aded5.eot +0 -0
  196. package/build/7a3337626410ca2f4071.woff2 +0 -0
  197. package/build/7a8b4f130182d19a2d7c.svg +0 -5034
  198. package/build/805.e991a370.chunk.js +0 -138
  199. package/build/8b43027f47b20503057d.eot +0 -0
  200. package/build/9707.a0cc4ad8.chunk.js +0 -70
  201. package/build/9bbb245e67a133f6e486.eot +0 -0
  202. package/build/Admin-authenticatedApp.ac85652e.chunk.js +0 -80
  203. package/build/Admin_pluginsPage.3c872de7.chunk.js +0 -6
  204. package/build/admin-app.77179e07.chunk.js +0 -112
  205. package/build/admin-audit-logs.334ee871.chunk.js +0 -1
  206. package/build/admin-edit-roles-page.23f15909.chunk.js +0 -1
  207. package/build/admin-edit-users.283b49ed.chunk.js +0 -10
  208. package/build/api-tokens-create-page.93dd0689.chunk.js +0 -1
  209. package/build/api-tokens-edit-page.b0adac81.chunk.js +0 -1
  210. package/build/bb58e57c48a3e911f15f.woff +0 -0
  211. package/build/be9ee23c0c6390141475.ttf +0 -0
  212. package/build/c1e38fd9e0e74ba58f7a.svg +0 -2671
  213. package/build/content-manager.01e04e11.chunk.js +0 -1200
  214. package/build/content-type-builder-list-view.4412efc3.chunk.js +0 -201
  215. package/build/content-type-builder-translation-de-json.0d7696b9.chunk.js +0 -1
  216. package/build/content-type-builder-translation-dk-json.4729f055.chunk.js +0 -1
  217. package/build/content-type-builder-translation-en-json.f985c9c4.chunk.js +0 -1
  218. package/build/content-type-builder-translation-es-json.333cf47f.chunk.js +0 -1
  219. package/build/content-type-builder-translation-ko-json.51201b12.chunk.js +0 -1
  220. package/build/content-type-builder-translation-pl-json.4a42349b.chunk.js +0 -1
  221. package/build/content-type-builder-translation-pt-BR-json.6fe3b8d1.chunk.js +0 -1
  222. package/build/content-type-builder-translation-sv-json.6deff030.chunk.js +0 -1
  223. package/build/content-type-builder-translation-tr-json.2e52bc60.chunk.js +0 -1
  224. package/build/content-type-builder-translation-zh-json.3b0afd31.chunk.js +0 -1
  225. package/build/content-type-builder.aa4ec633.chunk.js +0 -145
  226. package/build/d878b0a6a1144760244f.woff2 +0 -0
  227. package/build/eeccf4f66002c6f2ba24.woff +0 -0
  228. package/build/email-settings-page.d44a57cb.chunk.js +0 -15
  229. package/build/email-translation-tr-json.87f2feb3.chunk.js +0 -1
  230. package/build/en-json.57917cb1.chunk.js +0 -1
  231. package/build/f691f37e57f04c152e23.woff +0 -0
  232. package/build/fontawesome-css-all.15068c6e.chunk.js +0 -4618
  233. package/build/fontawesome-css.418f40da.chunk.js +0 -6
  234. package/build/fontawesome-js.252cc5f3.chunk.js +0 -7
  235. package/build/main.f31112a5.js +0 -2034
  236. package/build/runtime~main.81f05721.js +0 -2
  237. package/build/sk-json.7ba4b330.chunk.js +0 -1
  238. package/build/sso-settings-page.9f091262.chunk.js +0 -1
  239. package/build/tr-json.9c44ea0c.chunk.js +0 -1
  240. package/build/upload-settings.450cab1a.chunk.js +0 -18
  241. package/build/upload-translation-en-json.86da7b0a.chunk.js +0 -1
  242. package/build/upload-translation-sk-json.b03d4904.chunk.js +0 -1
  243. package/build/upload.a73936d9.chunk.js +0 -64
  244. package/build/users-advanced-settings-page.dc23bc56.chunk.js +0 -13
  245. package/build/users-email-settings-page.6541d372.chunk.js +0 -28
  246. package/build/users-permissions-translation-tr-json.cdc49a3c.chunk.js +0 -1
  247. package/build/users-providers-settings-page.e11a2f64.chunk.js +0 -33
  248. package/build/users-roles-settings-page.445e5e16.chunk.js +0 -30
@@ -1,322 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import React, { memo, useEffect, useRef, useState } from 'react';
3
- import PropTypes from 'prop-types';
4
- import { useDrag, useDrop } from 'react-dnd';
5
- import { getEmptyImage } from 'react-dnd-html5-backend';
6
- import styled from 'styled-components';
7
- import { useIntl } from 'react-intl';
8
- import toString from 'lodash/toString';
9
- import { Accordion, AccordionToggle, AccordionContent } from '@strapi/design-system/Accordion';
10
- import { Grid, GridItem } from '@strapi/design-system/Grid';
11
- import { Stack } from '@strapi/design-system/Stack';
12
- import { Box } from '@strapi/design-system/Box';
13
- import { Tooltip } from '@strapi/design-system/Tooltip';
14
- import Trash from '@strapi/icons/Trash';
15
- import Drag from '@strapi/icons/Drag';
16
- import ItemTypes from '../../../utils/ItemTypes';
17
- import getTrad from '../../../utils/getTrad';
18
- import Inputs from '../../Inputs';
19
- import FieldComponent from '../../FieldComponent';
20
- import Preview from './Preview';
21
- import DraggingSibling from './DraggingSibling';
22
- import { CustomIconButton } from './IconButtonCustoms';
23
- import { connect, select } from './utils';
24
-
25
- const DragButton = styled.span`
26
- display: flex;
27
- align-items: center;
28
- height: ${({ theme }) => theme.spaces[7]};
29
-
30
- padding: 0 ${({ theme }) => theme.spaces[3]};
31
- cursor: all-scroll;
32
-
33
- svg {
34
- width: ${12 / 16}rem;
35
- height: ${12 / 16}rem;
36
- }
37
- `;
38
-
39
- /* eslint-disable react/no-array-index-key */
40
-
41
- // Issues:
42
- // https://github.com/react-dnd/react-dnd/issues/1368
43
- // https://github.com/frontend-collective/react-sortable-tree/issues/490
44
-
45
- const DraggedItem = ({
46
- componentFieldName,
47
- componentUid,
48
- // Errors are retrieved from the AccordionGroupCustom cloneElement
49
- hasErrorMessage,
50
- hasErrors,
51
- isDraggingSibling,
52
- isOpen,
53
- isReadOnly,
54
- onClickToggle,
55
- schema,
56
- toggleCollapses,
57
- // Retrieved from the select function
58
- moveComponentField,
59
- removeRepeatableField,
60
- setIsDraggingSibling,
61
- triggerFormValidation,
62
- // checkFormErrors,
63
- displayedValue,
64
- }) => {
65
- const dragRef = useRef(null);
66
- const dropRef = useRef(null);
67
- const [, forceRerenderAfterDnd] = useState(false);
68
- const { formatMessage } = useIntl();
69
-
70
- const fields = schema.layouts.edit;
71
-
72
- const [, drop] = useDrop({
73
- accept: ItemTypes.COMPONENT,
74
- canDrop() {
75
- return false;
76
- },
77
- hover(item, monitor) {
78
- if (!dropRef.current) {
79
- return;
80
- }
81
-
82
- const dragPath = item.originalPath;
83
- const hoverPath = componentFieldName;
84
- const fullPathToComponentArray = dragPath.split('.');
85
- const dragIndexString = fullPathToComponentArray.slice().splice(-1).join('');
86
- const hoverIndexString = hoverPath.split('.').splice(-1).join('');
87
- const pathToComponentArray = fullPathToComponentArray.slice(
88
- 0,
89
- fullPathToComponentArray.length - 1
90
- );
91
- const dragIndex = parseInt(dragIndexString, 10);
92
- const hoverIndex = parseInt(hoverIndexString, 10);
93
-
94
- // Don't replace items with themselves
95
- if (dragIndex === hoverIndex) {
96
- return;
97
- }
98
-
99
- // Determine rectangle on screen
100
- const hoverBoundingRect = dropRef.current.getBoundingClientRect();
101
- // Get vertical middle
102
- const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
103
- // Determine mouse position
104
- const clientOffset = monitor.getClientOffset();
105
- // Get pixels to the top
106
- const hoverClientY = clientOffset.y - hoverBoundingRect.top;
107
-
108
- // Only perform the move when the mouse has crossed half of the items height
109
- // When dragging downwards, only move when the cursor is below 50%
110
- // When dragging upwards, only move when the cursor is above 50%
111
- // Dragging downwards
112
- if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {
113
- return;
114
- }
115
- // Dragging upwards
116
- if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {
117
- return;
118
- }
119
- // If They are not in the same level, should not move
120
- if (dragPath.split('.').length !== hoverPath.split('.').length) {
121
- return;
122
- }
123
- // Time to actually perform the action in the data
124
- moveComponentField(pathToComponentArray, dragIndex, hoverIndex);
125
-
126
- item.originalPath = hoverPath;
127
- },
128
- });
129
- const [{ isDragging }, drag, preview] = useDrag({
130
- type: ItemTypes.COMPONENT,
131
- item() {
132
- // Close all collapses
133
- toggleCollapses(-1);
134
-
135
- return {
136
- displayedValue,
137
- originalPath: componentFieldName,
138
- };
139
- },
140
- end() {
141
- // Update the errors
142
- triggerFormValidation();
143
- setIsDraggingSibling(false);
144
- },
145
- collect: (monitor) => ({
146
- isDragging: monitor.isDragging(),
147
- }),
148
- });
149
-
150
- useEffect(() => {
151
- preview(getEmptyImage(), { captureDraggingState: false });
152
- }, [preview]);
153
-
154
- useEffect(() => {
155
- if (isDragging) {
156
- setIsDraggingSibling(true);
157
- }
158
- }, [isDragging, setIsDraggingSibling]);
159
-
160
- // Effect in order to force a rerender after reordering the components
161
- // Since we are removing the Accordion when doing the DnD we are losing the dragRef, therefore the replaced element cannot be dragged
162
- // anymore, this hack forces a rerender in order to apply the dragRef
163
- useEffect(() => {
164
- if (!isDraggingSibling) {
165
- forceRerenderAfterDnd((prev) => !prev);
166
- }
167
- }, [isDraggingSibling]);
168
-
169
- // Create the refs
170
- // We need 1 for the drop target
171
- // 1 for the drag target
172
- const refs = {
173
- dragRef: drag(dragRef),
174
- dropRef: drop(dropRef),
175
- };
176
-
177
- const accordionTitle = toString(displayedValue);
178
- const accordionHasError = hasErrors ? 'error' : undefined;
179
-
180
- return (
181
- <Box ref={refs ? refs.dropRef : null}>
182
- {isDragging && <Preview />}
183
- {!isDragging && isDraggingSibling && (
184
- <DraggingSibling displayedValue={accordionTitle} componentFieldName={componentFieldName} />
185
- )}
186
-
187
- {!isDragging && !isDraggingSibling && (
188
- <Accordion
189
- error={accordionHasError}
190
- hasErrorMessage={hasErrorMessage}
191
- expanded={isOpen}
192
- onToggle={onClickToggle}
193
- id={componentFieldName}
194
- size="S"
195
- >
196
- <AccordionToggle
197
- action={
198
- isReadOnly ? null : (
199
- <Stack horizontal spacing={0}>
200
- <CustomIconButton
201
- expanded={isOpen}
202
- noBorder
203
- onClick={() => {
204
- removeRepeatableField(componentFieldName);
205
- toggleCollapses();
206
- }}
207
- label={formatMessage({
208
- id: getTrad('containers.Edit.delete'),
209
- defaultMessage: 'Delete',
210
- })}
211
- icon={<Trash />}
212
- />
213
- {/* react-dnd is broken in firefox with our IconButton, maybe a ref issue */}
214
- <Tooltip
215
- description={formatMessage({
216
- id: getTrad('components.DragHandle-label'),
217
- defaultMessage: 'Drag',
218
- })}
219
- >
220
- <DragButton
221
- role="button"
222
- tabIndex={-1}
223
- ref={refs.dragRef}
224
- onClick={(e) => e.stopPropagation()}
225
- >
226
- <Drag />
227
- </DragButton>
228
- </Tooltip>
229
- </Stack>
230
- )
231
- }
232
- title={accordionTitle}
233
- togglePosition="left"
234
- />
235
- <AccordionContent>
236
- <Stack background="neutral100" padding={6} spacing={6}>
237
- {fields.map((fieldRow, key) => {
238
- return (
239
- <Grid gap={4} key={key}>
240
- {fieldRow.map(({ name, fieldSchema, metadatas, queryInfos, size }) => {
241
- const isComponent = fieldSchema.type === 'component';
242
- const keys = `${componentFieldName}.${name}`;
243
-
244
- if (isComponent) {
245
- const componentUid = fieldSchema.component;
246
-
247
- return (
248
- <GridItem col={size} s={12} xs={12} key={name}>
249
- <FieldComponent
250
- componentUid={componentUid}
251
- intlLabel={{
252
- id: metadatas.label,
253
- defaultMessage: metadatas.label,
254
- }}
255
- isRepeatable={fieldSchema.repeatable}
256
- isNested
257
- name={keys}
258
- max={fieldSchema.max}
259
- min={fieldSchema.min}
260
- required={fieldSchema.required}
261
- />
262
- </GridItem>
263
- );
264
- }
265
-
266
- return (
267
- <GridItem key={keys} col={size} s={12} xs={12}>
268
- <Inputs
269
- componentUid={componentUid}
270
- fieldSchema={fieldSchema}
271
- keys={keys}
272
- metadatas={metadatas}
273
- // onBlur={hasErrors ? checkFormErrors : null}
274
- queryInfos={queryInfos}
275
- size={size}
276
- />
277
- </GridItem>
278
- );
279
- })}
280
- </Grid>
281
- );
282
- })}
283
- </Stack>
284
- </AccordionContent>
285
- </Accordion>
286
- )}
287
- </Box>
288
- );
289
- };
290
-
291
- DraggedItem.defaultProps = {
292
- componentUid: undefined,
293
- isDraggingSibling: false,
294
- isOpen: false,
295
- setIsDraggingSibling() {},
296
- toggleCollapses() {},
297
- };
298
-
299
- DraggedItem.propTypes = {
300
- componentFieldName: PropTypes.string.isRequired,
301
- componentUid: PropTypes.string,
302
- hasErrorMessage: PropTypes.bool.isRequired,
303
- hasErrors: PropTypes.bool.isRequired,
304
- isDraggingSibling: PropTypes.bool,
305
- isOpen: PropTypes.bool,
306
- isReadOnly: PropTypes.bool.isRequired,
307
- onClickToggle: PropTypes.func.isRequired,
308
- schema: PropTypes.object.isRequired,
309
- toggleCollapses: PropTypes.func,
310
- moveComponentField: PropTypes.func.isRequired,
311
- removeRepeatableField: PropTypes.func.isRequired,
312
- setIsDraggingSibling: PropTypes.func,
313
- triggerFormValidation: PropTypes.func.isRequired,
314
- // checkFormErrors: PropTypes.func.isRequired,
315
- displayedValue: PropTypes.string.isRequired,
316
- };
317
-
318
- const Memoized = memo(DraggedItem);
319
-
320
- export default connect(Memoized, select);
321
-
322
- export { DraggedItem };
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
-
3
- function connect(WrappedComponent, select) {
4
- return (props) => {
5
- const selectors = select(props);
6
-
7
- return <WrappedComponent {...props} {...selectors} />;
8
- };
9
- }
10
-
11
- export default connect;
@@ -1,2 +0,0 @@
1
- export { default as connect } from './connect';
2
- export { default as select } from './select';
@@ -1,30 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { get, toString } from 'lodash';
3
- import { useCMEditViewDataManager } from '@strapi/helper-plugin';
4
-
5
- function useSelect({ schema, componentFieldName }) {
6
- const {
7
- checkFormErrors,
8
- modifiedData,
9
- moveComponentField,
10
- removeRepeatableField,
11
- triggerFormValidation,
12
- } = useCMEditViewDataManager();
13
-
14
- const mainField = useMemo(() => get(schema, ['settings', 'mainField'], 'id'), [schema]);
15
- const displayedValue = toString(
16
- get(modifiedData, [...componentFieldName.split('.'), mainField], '')
17
- );
18
-
19
- return {
20
- displayedValue,
21
- mainField,
22
- checkFormErrors,
23
- moveComponentField,
24
- removeRepeatableField,
25
- schema,
26
- triggerFormValidation,
27
- };
28
- }
29
-
30
- export default useSelect;
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
-
3
- function connect(WrappedComponent, select) {
4
- return (props) => {
5
- const selectors = select(props);
6
-
7
- return <WrappedComponent {...props} {...selectors} />;
8
- };
9
- }
10
-
11
- export default connect;
@@ -1,12 +0,0 @@
1
- import { useCMEditViewDataManager } from '@strapi/helper-plugin';
2
-
3
- function useSelect() {
4
- const { addRepeatableComponentToField, formErrors } = useCMEditViewDataManager();
5
-
6
- return {
7
- addRepeatableComponentToField,
8
- formErrors,
9
- };
10
- }
11
-
12
- export default useSelect;
@@ -1,11 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- const Title = styled.div`
4
- color: #787e8f;
5
- font-size: 11px;
6
- font-weight: 700;
7
- letter-spacing: 0.77px;
8
- text-transform: uppercase;
9
- `;
10
-
11
- export default Title;
@@ -1,26 +0,0 @@
1
- import React, { memo } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { FormattedMessage } from 'react-intl';
4
- import { getTrad } from '../../utils';
5
- import Title from './Title';
6
-
7
- const SectionTitle = ({ isSettings }) => {
8
- const suffix = isSettings ? 'settings' : 'view';
9
- const msgId = getTrad(`containers.SettingPage.${suffix}`);
10
-
11
- return (
12
- <div style={{ marginBottom: '18px' }}>
13
- <FormattedMessage id={msgId}>{(msg) => <Title>{msg}</Title>}</FormattedMessage>
14
- </div>
15
- );
16
- };
17
-
18
- SectionTitle.propTypes = {
19
- isSettings: PropTypes.bool,
20
- };
21
-
22
- SectionTitle.defaultProps = {
23
- isSettings: false,
24
- };
25
-
26
- export default memo(SectionTitle);
@@ -1,26 +0,0 @@
1
- import { renderHook } from '@testing-library/react-hooks';
2
-
3
- import { usePrev } from '../usePrev';
4
-
5
- describe('usePrev', () => {
6
- const setup = () => renderHook(({ state }) => usePrev(state), { initialProps: { state: 0 } });
7
-
8
- it('should return undefined on initial render', () => {
9
- const { result } = setup();
10
-
11
- expect(result.current).toBeUndefined();
12
- });
13
-
14
- it('should always return previous state after each update', () => {
15
- const { result, rerender } = setup();
16
-
17
- rerender({ state: 2 });
18
- expect(result.current).toBe(0);
19
-
20
- rerender({ state: 4 });
21
- expect(result.current).toBe(2);
22
-
23
- rerender({ state: 6 });
24
- expect(result.current).toBe(4);
25
- });
26
- });
@@ -1,19 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import useFormatTimeStamp from '../../hooks/useFormatTimeStamp';
3
-
4
- const CellValue = ({ type, value }) => {
5
- const formatTimeStamp = useFormatTimeStamp();
6
-
7
- if (type === 'date') {
8
- return formatTimeStamp(value);
9
- }
10
-
11
- return value || '-';
12
- };
13
-
14
- CellValue.propTypes = {
15
- type: PropTypes.string.isRequired,
16
- value: PropTypes.any.isRequired,
17
- };
18
-
19
- export default CellValue;
@@ -1,65 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { useIntl } from 'react-intl';
4
- import { IconButton } from '@strapi/design-system/IconButton';
5
- import { Flex } from '@strapi/design-system/Flex';
6
- import { Typography } from '@strapi/design-system/Typography';
7
- import { Tbody, Td, Tr } from '@strapi/design-system/Table';
8
- import Eye from '@strapi/icons/Eye';
9
- import { onRowClick, stopPropagation } from '@strapi/helper-plugin';
10
- import CellValue from './CellValue';
11
-
12
- const TableRows = ({ headers, rows, onModalToggle }) => {
13
- const { formatMessage } = useIntl();
14
-
15
- return (
16
- <Tbody>
17
- {rows.map((data) => {
18
- return (
19
- <Tr
20
- key={data.id}
21
- {...onRowClick({
22
- fn: () => onModalToggle(data.id),
23
- })}
24
- >
25
- {headers.map(({ key, name }) => {
26
- return (
27
- <Td key={key}>
28
- <Typography textColor="neutral800">
29
- <CellValue type={key} value={data[name]} />
30
- </Typography>
31
- </Td>
32
- );
33
- })}
34
-
35
- <Td {...stopPropagation}>
36
- <Flex justifyContent="end">
37
- <IconButton
38
- onClick={() => onModalToggle(data.id)}
39
- aria-label={formatMessage(
40
- { id: 'app.component.table.view', defaultMessage: '{target} details' },
41
- { target: `${data.action} action` }
42
- )}
43
- noBorder
44
- icon={<Eye />}
45
- />
46
- </Flex>
47
- </Td>
48
- </Tr>
49
- );
50
- })}
51
- </Tbody>
52
- );
53
- };
54
-
55
- TableRows.defaultProps = {
56
- rows: [],
57
- };
58
-
59
- TableRows.propTypes = {
60
- headers: PropTypes.array.isRequired,
61
- rows: PropTypes.array,
62
- onModalToggle: PropTypes.func.isRequired,
63
- };
64
-
65
- export default TableRows;
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { useIntl } from 'react-intl';
4
- import { Flex } from '@strapi/design-system/Flex';
5
- import { Typography } from '@strapi/design-system/Typography';
6
-
7
- const ActionItem = ({ actionLabel, actionName }) => {
8
- const { formatMessage } = useIntl();
9
-
10
- return (
11
- <Flex direction="column" alignItems="baseline" gap={1}>
12
- <Typography textColor="neutral600" variant="sigma">
13
- {formatMessage(actionLabel)}
14
- </Typography>
15
- <Typography textColor="neutral600">{actionName}</Typography>
16
- </Flex>
17
- );
18
- };
19
-
20
- ActionItem.propTypes = {
21
- actionLabel: PropTypes.object.isRequired,
22
- actionName: PropTypes.string.isRequired,
23
- };
24
-
25
- export default ActionItem;
@@ -1,76 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { useIntl } from 'react-intl';
4
- import { ModalLayout, ModalHeader, ModalBody } from '@strapi/design-system/ModalLayout';
5
- import { Breadcrumbs, Crumb } from '@strapi/design-system/Breadcrumbs';
6
- import { Grid } from '@strapi/design-system/Grid';
7
- import { Box } from '@strapi/design-system/Box';
8
- import { Typography } from '@strapi/design-system/Typography';
9
- import { pxToRem } from '@strapi/helper-plugin';
10
- import useFormatTimeStamp from '../hooks/useFormatTimeStamp';
11
- import ActionItem from './ActionItem';
12
-
13
- const ModalDialog = ({ onToggle, data: { date, user, action } }) => {
14
- const { formatMessage } = useIntl();
15
- const formatTimeStamp = useFormatTimeStamp();
16
- const formattedDate = formatTimeStamp(date);
17
-
18
- return (
19
- <ModalLayout onClose={onToggle} labelledBy="title">
20
- <ModalHeader>
21
- <Breadcrumbs label={formattedDate}>
22
- <Crumb>{formattedDate}</Crumb>
23
- </Breadcrumbs>
24
- </ModalHeader>
25
- <ModalBody>
26
- <Box marginBottom={pxToRem(12)}>
27
- <Typography variant="delta" id="title">
28
- {formatMessage({
29
- id: 'Settings.permissions.auditLogs.details',
30
- defaultMessage: 'Log Details',
31
- })}
32
- </Typography>
33
- </Box>
34
- <Grid
35
- gap={4}
36
- gridCols={2}
37
- paddingTop={4}
38
- paddingBottom={4}
39
- paddingLeft={6}
40
- paddingRight={6}
41
- background="neutral100"
42
- hasRadius
43
- >
44
- <ActionItem
45
- actionLabel={{
46
- id: 'Settings.permissions.auditLogs.action',
47
- defaultMessage: 'Action',
48
- }}
49
- actionName={action}
50
- />
51
- <ActionItem
52
- actionLabel={{
53
- id: 'Settings.permissions.auditLogs.date',
54
- defaultMessage: 'Date',
55
- }}
56
- actionName={formattedDate}
57
- />
58
- <ActionItem
59
- actionLabel={{
60
- id: 'Settings.permissions.auditLogs.user',
61
- defaultMessage: 'User',
62
- }}
63
- actionName={user}
64
- />
65
- </Grid>
66
- </ModalBody>
67
- </ModalLayout>
68
- );
69
- };
70
-
71
- ModalDialog.propTypes = {
72
- onToggle: PropTypes.func.isRequired,
73
- data: PropTypes.object.isRequired,
74
- };
75
-
76
- export default ModalDialog;
@@ -1,24 +0,0 @@
1
- import { useIntl } from 'react-intl';
2
- import parseISO from 'date-fns/parseISO';
3
-
4
- const useFormatTimeStamp = () => {
5
- const { formatDate } = useIntl();
6
-
7
- const formatTimeStamp = (value) => {
8
- const date = parseISO(value);
9
-
10
- const formattedDate = formatDate(date, {
11
- dateStyle: 'long',
12
- });
13
- const formattedTime = formatDate(date, {
14
- timeStyle: 'medium',
15
- hourCycle: 'h24',
16
- });
17
-
18
- return `${formattedDate}, ${formattedTime}`;
19
- };
20
-
21
- return formatTimeStamp;
22
- };
23
-
24
- export default useFormatTimeStamp;