@strapi/plugin-users-permissions 0.0.0-next.e9bb5ccdc459f4c6b6717a2d5d86359b7a47d47d → 0.0.0-next.ec9b1b708d4d319f2b8b39d9397bd752d250d541

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 (228) hide show
  1. package/.eslintignore +1 -2
  2. package/.eslintrc +17 -0
  3. package/LICENSE +18 -3
  4. package/admin/src/components/BoundRoute/{index.js → index.jsx} +6 -4
  5. package/admin/src/components/FormModal/Input/{index.js → index.jsx} +37 -33
  6. package/admin/src/components/FormModal/index.jsx +115 -0
  7. package/admin/src/components/Permissions/PermissionRow/{CheckboxWrapper.js → CheckboxWrapper.jsx} +4 -3
  8. package/admin/src/components/Permissions/PermissionRow/{SubCategory.js → SubCategory.jsx} +27 -15
  9. package/admin/src/components/Permissions/PermissionRow/{index.js → index.jsx} +4 -2
  10. package/admin/src/components/Permissions/index.jsx +47 -0
  11. package/admin/src/components/Permissions/reducer.js +1 -1
  12. package/admin/src/components/Policies/{index.js → index.jsx} +9 -6
  13. package/admin/src/components/UsersPermissions/{index.js → index.jsx} +22 -11
  14. package/admin/src/components/UsersPermissions/reducer.js +1 -1
  15. package/admin/src/{permissions.js → constants.js} +1 -3
  16. package/admin/src/contexts/UsersPermissionsContext/{index.js → index.jsx} +1 -0
  17. package/admin/src/index.js +25 -51
  18. package/admin/src/pages/AdvancedSettings/index.jsx +214 -0
  19. package/admin/src/pages/AdvancedSettings/utils/layout.js +20 -35
  20. package/admin/src/pages/AdvancedSettings/utils/schema.js +5 -2
  21. package/admin/src/pages/EmailTemplates/components/EmailForm.jsx +156 -0
  22. package/admin/src/pages/EmailTemplates/components/{EmailTable.js → EmailTable.jsx} +27 -22
  23. package/admin/src/pages/EmailTemplates/index.jsx +148 -0
  24. package/admin/src/pages/EmailTemplates/utils/schema.js +18 -6
  25. package/admin/src/pages/Providers/index.jsx +262 -0
  26. package/admin/src/pages/Providers/utils/forms.js +23 -11
  27. package/admin/src/pages/Roles/constants.js +7 -0
  28. package/admin/src/pages/Roles/hooks/usePlugins.js +78 -0
  29. package/admin/src/pages/Roles/index.jsx +24 -0
  30. package/admin/src/pages/Roles/pages/CreatePage.jsx +194 -0
  31. package/admin/src/pages/Roles/pages/EditPage.jsx +215 -0
  32. package/admin/src/pages/Roles/pages/ListPage/components/TableBody.jsx +119 -0
  33. package/admin/src/pages/Roles/{ListPage/index.js → pages/ListPage/index.jsx} +108 -83
  34. package/admin/src/translations/en.json +1 -1
  35. package/admin/src/translations/zh-Hans.json +80 -80
  36. package/admin/src/utils/index.js +1 -2
  37. package/admin/src/utils/prefixPluginTranslations.js +13 -0
  38. package/dist/_chunks/ar-BguGUqwK.js +44 -0
  39. package/dist/_chunks/ar-BguGUqwK.js.map +1 -0
  40. package/dist/_chunks/ar-CK8BRRXB.mjs +44 -0
  41. package/dist/_chunks/ar-CK8BRRXB.mjs.map +1 -0
  42. package/dist/_chunks/cs-BVigMk0l.mjs +50 -0
  43. package/dist/_chunks/cs-BVigMk0l.mjs.map +1 -0
  44. package/dist/_chunks/cs-BW8-K_GY.js +50 -0
  45. package/dist/_chunks/cs-BW8-K_GY.js.map +1 -0
  46. package/dist/_chunks/de-BKUdRFI4.mjs +62 -0
  47. package/dist/_chunks/de-BKUdRFI4.mjs.map +1 -0
  48. package/dist/_chunks/de-owXpVluI.js +62 -0
  49. package/dist/_chunks/de-owXpVluI.js.map +1 -0
  50. package/dist/_chunks/dk-BQiTK50l.mjs +86 -0
  51. package/dist/_chunks/dk-BQiTK50l.mjs.map +1 -0
  52. package/dist/_chunks/dk-LXAnbuBk.js +86 -0
  53. package/dist/_chunks/dk-LXAnbuBk.js.map +1 -0
  54. package/dist/_chunks/en-DOHtPf-2.mjs +86 -0
  55. package/dist/_chunks/en-DOHtPf-2.mjs.map +1 -0
  56. package/dist/_chunks/en-MHo5mcsU.js +86 -0
  57. package/dist/_chunks/en-MHo5mcsU.js.map +1 -0
  58. package/dist/_chunks/es-BwLCLXAQ.js +86 -0
  59. package/dist/_chunks/es-BwLCLXAQ.js.map +1 -0
  60. package/dist/_chunks/es-DNgOVMjD.mjs +86 -0
  61. package/dist/_chunks/es-DNgOVMjD.mjs.map +1 -0
  62. package/dist/_chunks/fr-DkgRugiU.mjs +50 -0
  63. package/dist/_chunks/fr-DkgRugiU.mjs.map +1 -0
  64. package/dist/_chunks/fr-DkhpSjjm.js +50 -0
  65. package/dist/_chunks/fr-DkhpSjjm.js.map +1 -0
  66. package/dist/_chunks/id-BTemOeTZ.js +62 -0
  67. package/dist/_chunks/id-BTemOeTZ.js.map +1 -0
  68. package/dist/_chunks/id-BdEsvnaF.mjs +62 -0
  69. package/dist/_chunks/id-BdEsvnaF.mjs.map +1 -0
  70. package/dist/_chunks/index-BtapqMRC.js +640 -0
  71. package/dist/_chunks/index-BtapqMRC.js.map +1 -0
  72. package/dist/_chunks/index-C5MSODBR.mjs +248 -0
  73. package/dist/_chunks/index-C5MSODBR.mjs.map +1 -0
  74. package/dist/_chunks/index-CQ0jOkIC-C4oUQUND.js +12026 -0
  75. package/dist/_chunks/index-CQ0jOkIC-C4oUQUND.js.map +1 -0
  76. package/dist/_chunks/index-CQ0jOkIC-DAZ1lfuF.mjs +12002 -0
  77. package/dist/_chunks/index-CQ0jOkIC-DAZ1lfuF.mjs.map +1 -0
  78. package/dist/_chunks/index-Cl7wdD8l.js +366 -0
  79. package/dist/_chunks/index-Cl7wdD8l.js.map +1 -0
  80. package/dist/_chunks/index-Cyk9nN3J.mjs +262 -0
  81. package/dist/_chunks/index-Cyk9nN3J.mjs.map +1 -0
  82. package/dist/_chunks/index-DNKYHd4J.mjs +1142 -0
  83. package/dist/_chunks/index-DNKYHd4J.mjs.map +1 -0
  84. package/dist/_chunks/index-D_1N-X9K.js +1172 -0
  85. package/dist/_chunks/index-D_1N-X9K.js.map +1 -0
  86. package/dist/_chunks/index-ZbIIl-VI.js +281 -0
  87. package/dist/_chunks/index-ZbIIl-VI.js.map +1 -0
  88. package/dist/_chunks/index-kMqoQ8VX.mjs +344 -0
  89. package/dist/_chunks/index-kMqoQ8VX.mjs.map +1 -0
  90. package/dist/_chunks/index-pmesAsoW.js +247 -0
  91. package/dist/_chunks/index-pmesAsoW.js.map +1 -0
  92. package/dist/_chunks/index-zaVC_4Mw.mjs +617 -0
  93. package/dist/_chunks/index-zaVC_4Mw.mjs.map +1 -0
  94. package/dist/_chunks/it-B-rv0E24.mjs +62 -0
  95. package/dist/_chunks/it-B-rv0E24.mjs.map +1 -0
  96. package/dist/_chunks/it-D1rH6V6_.js +62 -0
  97. package/dist/_chunks/it-D1rH6V6_.js.map +1 -0
  98. package/dist/_chunks/ja-C8K-VBPD.mjs +48 -0
  99. package/dist/_chunks/ja-C8K-VBPD.mjs.map +1 -0
  100. package/dist/_chunks/ja-DqShgTMf.js +48 -0
  101. package/dist/_chunks/ja-DqShgTMf.js.map +1 -0
  102. package/dist/_chunks/ko-B9DGEPWH.js +86 -0
  103. package/dist/_chunks/ko-B9DGEPWH.js.map +1 -0
  104. package/dist/_chunks/ko-Busb0wIY.mjs +86 -0
  105. package/dist/_chunks/ko-Busb0wIY.mjs.map +1 -0
  106. package/dist/_chunks/ms-ByvsQjRt.mjs +49 -0
  107. package/dist/_chunks/ms-ByvsQjRt.mjs.map +1 -0
  108. package/dist/_chunks/ms-CPBU3LWf.js +49 -0
  109. package/dist/_chunks/ms-CPBU3LWf.js.map +1 -0
  110. package/dist/_chunks/nl-5qO8Rpcy.mjs +48 -0
  111. package/dist/_chunks/nl-5qO8Rpcy.mjs.map +1 -0
  112. package/dist/_chunks/nl-CwNB6YoO.js +48 -0
  113. package/dist/_chunks/nl-CwNB6YoO.js.map +1 -0
  114. package/dist/_chunks/pl-BdIzifBE.mjs +86 -0
  115. package/dist/_chunks/pl-BdIzifBE.mjs.map +1 -0
  116. package/dist/_chunks/pl-Do9UD69f.js +86 -0
  117. package/dist/_chunks/pl-Do9UD69f.js.map +1 -0
  118. package/dist/_chunks/pt-BIO24ioG.mjs +48 -0
  119. package/dist/_chunks/pt-BIO24ioG.mjs.map +1 -0
  120. package/dist/_chunks/pt-BR-D7dZhxuP.js +44 -0
  121. package/dist/_chunks/pt-BR-D7dZhxuP.js.map +1 -0
  122. package/dist/_chunks/pt-BR-f0p23AQZ.mjs +44 -0
  123. package/dist/_chunks/pt-BR-f0p23AQZ.mjs.map +1 -0
  124. package/dist/_chunks/pt-fdvyOnUp.js +48 -0
  125. package/dist/_chunks/pt-fdvyOnUp.js.map +1 -0
  126. package/dist/_chunks/ru-C94rjPGA.js +86 -0
  127. package/dist/_chunks/ru-C94rjPGA.js.map +1 -0
  128. package/dist/_chunks/ru-VWy-IB7K.mjs +86 -0
  129. package/dist/_chunks/ru-VWy-IB7K.mjs.map +1 -0
  130. package/dist/_chunks/sk-BABEhykl.js +50 -0
  131. package/dist/_chunks/sk-BABEhykl.js.map +1 -0
  132. package/dist/_chunks/sk-B_LIcepm.mjs +50 -0
  133. package/dist/_chunks/sk-B_LIcepm.mjs.map +1 -0
  134. package/dist/_chunks/sv-ABLKOokl.mjs +86 -0
  135. package/dist/_chunks/sv-ABLKOokl.mjs.map +1 -0
  136. package/dist/_chunks/sv-Be43LhA9.js +86 -0
  137. package/dist/_chunks/sv-Be43LhA9.js.map +1 -0
  138. package/dist/_chunks/th-DKyP7ueR.mjs +60 -0
  139. package/dist/_chunks/th-DKyP7ueR.mjs.map +1 -0
  140. package/dist/_chunks/th-DgVhVLhL.js +60 -0
  141. package/dist/_chunks/th-DgVhVLhL.js.map +1 -0
  142. package/dist/_chunks/tr-B_idhkEs.js +85 -0
  143. package/dist/_chunks/tr-B_idhkEs.js.map +1 -0
  144. package/dist/_chunks/tr-qa1Q5UjC.mjs +85 -0
  145. package/dist/_chunks/tr-qa1Q5UjC.mjs.map +1 -0
  146. package/dist/_chunks/uk-BmRqbeQc.mjs +49 -0
  147. package/dist/_chunks/uk-BmRqbeQc.mjs.map +1 -0
  148. package/dist/_chunks/uk-LHOivnhP.js +49 -0
  149. package/dist/_chunks/uk-LHOivnhP.js.map +1 -0
  150. package/dist/_chunks/vi-CdVRdKDw.js +50 -0
  151. package/dist/_chunks/vi-CdVRdKDw.js.map +1 -0
  152. package/dist/_chunks/vi-HW-EdMea.mjs +50 -0
  153. package/dist/_chunks/vi-HW-EdMea.mjs.map +1 -0
  154. package/dist/_chunks/zh-5hKkVPA4.mjs +86 -0
  155. package/dist/_chunks/zh-5hKkVPA4.mjs.map +1 -0
  156. package/dist/_chunks/zh-Cuq8gMnF.js +86 -0
  157. package/dist/_chunks/zh-Cuq8gMnF.js.map +1 -0
  158. package/dist/_chunks/zh-Hans-BHilK-yc.mjs +86 -0
  159. package/dist/_chunks/zh-Hans-BHilK-yc.mjs.map +1 -0
  160. package/dist/_chunks/zh-Hans-GQDMKtY4.js +86 -0
  161. package/dist/_chunks/zh-Hans-GQDMKtY4.js.map +1 -0
  162. package/dist/admin/index.js +4 -0
  163. package/dist/admin/index.js.map +1 -0
  164. package/dist/admin/index.mjs +5 -0
  165. package/dist/admin/index.mjs.map +1 -0
  166. package/documentation/content-api.yaml +1 -1
  167. package/jest.config.front.js +1 -0
  168. package/package.json +51 -35
  169. package/packup.config.ts +22 -0
  170. package/server/bootstrap/index.js +18 -15
  171. package/server/bootstrap/users-permissions-actions.js +6 -0
  172. package/server/config.js +29 -0
  173. package/server/content-types/user/index.js +0 -1
  174. package/server/controllers/auth.js +74 -38
  175. package/server/controllers/content-manager-user.js +28 -30
  176. package/server/controllers/role.js +17 -4
  177. package/server/controllers/user.js +18 -8
  178. package/server/controllers/validation/auth.js +81 -25
  179. package/server/middlewares/rateLimit.js +41 -21
  180. package/server/register.js +1 -1
  181. package/server/services/jwt.js +3 -3
  182. package/server/services/permission.js +3 -7
  183. package/server/services/providers-registry.js +469 -261
  184. package/server/services/providers.js +10 -5
  185. package/server/services/role.js +15 -13
  186. package/server/services/user.js +56 -19
  187. package/server/services/users-permissions.js +15 -13
  188. package/server/strategies/users-permissions.js +1 -8
  189. package/server/utils/index.d.ts +2 -1
  190. package/server/utils/sanitize/sanitizers.js +7 -3
  191. package/server/utils/sanitize/visitors/remove-user-relation-from-role-entities.js +2 -2
  192. package/.eslintrc.js +0 -14
  193. package/admin/src/components/FormModal/index.js +0 -123
  194. package/admin/src/components/Permissions/index.js +0 -54
  195. package/admin/src/hooks/index.js +0 -5
  196. package/admin/src/hooks/useFetchRole/index.js +0 -64
  197. package/admin/src/hooks/useFetchRole/reducer.js +0 -31
  198. package/admin/src/hooks/useForm/index.js +0 -67
  199. package/admin/src/hooks/useForm/reducer.js +0 -40
  200. package/admin/src/hooks/usePlugins/index.js +0 -67
  201. package/admin/src/hooks/usePlugins/init.js +0 -5
  202. package/admin/src/hooks/usePlugins/reducer.js +0 -34
  203. package/admin/src/hooks/useRolesList/index.js +0 -62
  204. package/admin/src/hooks/useRolesList/init.js +0 -5
  205. package/admin/src/hooks/useRolesList/reducer.js +0 -31
  206. package/admin/src/pages/AdvancedSettings/index.js +0 -243
  207. package/admin/src/pages/AdvancedSettings/utils/api.js +0 -17
  208. package/admin/src/pages/EmailTemplates/components/EmailForm.js +0 -175
  209. package/admin/src/pages/EmailTemplates/index.js +0 -160
  210. package/admin/src/pages/EmailTemplates/utils/api.js +0 -17
  211. package/admin/src/pages/Providers/index.js +0 -272
  212. package/admin/src/pages/Providers/reducer.js +0 -54
  213. package/admin/src/pages/Providers/utils/api.js +0 -25
  214. package/admin/src/pages/Providers/utils/createProvidersArray.js +0 -21
  215. package/admin/src/pages/Roles/CreatePage/index.js +0 -182
  216. package/admin/src/pages/Roles/CreatePage/utils/schema.js +0 -9
  217. package/admin/src/pages/Roles/EditPage/index.js +0 -194
  218. package/admin/src/pages/Roles/EditPage/utils/schema.js +0 -9
  219. package/admin/src/pages/Roles/ListPage/components/TableBody.js +0 -92
  220. package/admin/src/pages/Roles/ListPage/utils/api.js +0 -31
  221. package/admin/src/pages/Roles/ProtectedCreatePage/index.js +0 -12
  222. package/admin/src/pages/Roles/ProtectedEditPage/index.js +0 -12
  223. package/admin/src/pages/Roles/ProtectedListPage/index.js +0 -15
  224. package/admin/src/pages/Roles/index.js +0 -27
  225. package/admin/src/utils/getRequestURL.js +0 -5
  226. package/server/bootstrap/grant-config.js +0 -131
  227. package/strapi-admin.js +0 -3
  228. package/strapi-server.js +0 -3
package/.eslintignore CHANGED
@@ -1,2 +1 @@
1
- node_modules/
2
- .eslintrc.js
1
+ dist
package/.eslintrc ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "root": true,
3
+ "overrides": [
4
+ {
5
+ "files": ["admin/**/*"],
6
+ "extends": ["custom/front"],
7
+ "rules": {
8
+ "import/extensions": "off"
9
+ }
10
+ },
11
+ {
12
+ "files": ["**/*"],
13
+ "excludedFiles": ["admin/**/*"],
14
+ "extends": ["custom/back"]
15
+ }
16
+ ]
17
+ }
package/LICENSE CHANGED
@@ -2,7 +2,21 @@ Copyright (c) 2015-present Strapi Solutions SAS
2
2
 
3
3
  Portions of the Strapi software are licensed as follows:
4
4
 
5
- * All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE".
5
+ * All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined below.
6
+
7
+ Enterprise License
8
+
9
+ If you or the company you represent has entered into a written agreement referencing the Enterprise Edition of the Strapi source code available at
10
+ https://github.com/strapi/strapi, then such agreement applies to your use of the Enterprise Edition of the Strapi Software. If you or the company you
11
+ represent is using the Enterprise Edition of the Strapi Software in connection with a subscription to our cloud offering, then the agreement you have
12
+ agreed to with respect to our cloud offering and the licenses included in such agreement apply to your use of the Enterprise Edition of the Strapi Software.
13
+ Otherwise, the Strapi Enterprise Software License Agreement (found here https://strapi.io/enterprise-terms) applies to your use of the Enterprise Edition of the Strapi Software.
14
+
15
+ BY ACCESSING OR USING THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE RELEVANT REFERENCED AGREEMENT.
16
+ IF YOU ARE NOT AUTHORIZED TO ACCEPT THESE TERMS ON BEHALF OF THE COMPANY YOU REPRESENT OR IF YOU DO NOT AGREE TO ALL OF THE RELEVANT TERMS AND CONDITIONS REFERENCED AND YOU
17
+ HAVE NOT OTHERWISE EXECUTED A WRITTEN AGREEMENT WITH STRAPI, YOU ARE NOT AUTHORIZED TO ACCESS OR USE OR ALLOW ANY USER TO ACCESS OR USE ANY PART OF
18
+ THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE. YOUR ACCESS RIGHTS ARE CONDITIONAL ON YOUR CONSENT TO THE RELEVANT REFERENCED TERMS TO THE EXCLUSION OF ALL OTHER TERMS;
19
+ IF THE RELEVANT REFERENCED TERMS ARE CONSIDERED AN OFFER BY YOU, ACCEPTANCE IS EXPRESSLY LIMITED TO THE RELEVANT REFERENCED TERMS.
6
20
 
7
21
  * All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
8
22
 
@@ -18,5 +32,6 @@ furnished to do so, subject to the following conditions:
18
32
  The above copyright notice and this permission notice shall be included in all
19
33
  copies or substantial portions of the Software.
20
34
 
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
37
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
- import styled from 'styled-components';
3
- import { Flex, Box, Typography } from '@strapi/design-system';
2
+
3
+ import { Box, Flex, Typography } from '@strapi/design-system';
4
4
  import map from 'lodash/map';
5
5
  import tail from 'lodash/tail';
6
- import { useIntl } from 'react-intl';
7
6
  import PropTypes from 'prop-types';
7
+ import { useIntl } from 'react-intl';
8
+ import { styled } from 'styled-components';
9
+
8
10
  import getMethodColor from './getMethodColor';
9
11
 
10
12
  const MethodBox = styled(Box)`
@@ -22,7 +24,7 @@ function BoundRoute({ route }) {
22
24
 
23
25
  return (
24
26
  <Flex direction="column" alignItems="stretch" gap={2}>
25
- <Typography variant="delta" as="h3">
27
+ <Typography variant="delta" tag="h3">
26
28
  {formatMessage({
27
29
  id: 'users-permissions.BoundRoute.title',
28
30
  defaultMessage: 'Bound route to',
@@ -5,9 +5,10 @@
5
5
  */
6
6
 
7
7
  import React from 'react';
8
- import { useIntl } from 'react-intl';
9
- import { ToggleInput, TextInput } from '@strapi/design-system';
8
+
9
+ import { TextInput, Toggle, Field } from '@strapi/design-system';
10
10
  import PropTypes from 'prop-types';
11
+ import { useIntl } from 'react-intl';
11
12
 
12
13
  const Input = ({
13
14
  description,
@@ -23,7 +24,9 @@ const Input = ({
23
24
  }) => {
24
25
  const { formatMessage } = useIntl();
25
26
  const inputValue =
26
- name === 'noName' ? `${strapi.backendURL}/api/connect/${providerToEditName}/callback` : value;
27
+ name === 'noName'
28
+ ? `${window.strapi.backendURL}/api/connect/${providerToEditName}/callback`
29
+ : value;
27
30
 
28
31
  const label = formatMessage(
29
32
  { id: intlLabel.id, defaultMessage: intlLabel.defaultMessage },
@@ -38,25 +41,26 @@ const Input = ({
38
41
 
39
42
  if (type === 'bool') {
40
43
  return (
41
- <ToggleInput
42
- aria-label={name}
43
- checked={value}
44
- disabled={disabled}
45
- hint={hint}
46
- label={label}
47
- name={name}
48
- offLabel={formatMessage({
49
- id: 'app.components.ToggleCheckbox.off-label',
50
- defaultMessage: 'Off',
51
- })}
52
- onLabel={formatMessage({
53
- id: 'app.components.ToggleCheckbox.on-label',
54
- defaultMessage: 'On',
55
- })}
56
- onChange={(e) => {
57
- onChange({ target: { name, value: e.target.checked } });
58
- }}
59
- />
44
+ <Field.Root hint={hint} name={name}>
45
+ <Field.Label>{label}</Field.Label>
46
+ <Toggle
47
+ aria-label={name}
48
+ checked={value}
49
+ disabled={disabled}
50
+ offLabel={formatMessage({
51
+ id: 'app.components.ToggleCheckbox.off-label',
52
+ defaultMessage: 'Off',
53
+ })}
54
+ onLabel={formatMessage({
55
+ id: 'app.components.ToggleCheckbox.on-label',
56
+ defaultMessage: 'On',
57
+ })}
58
+ onChange={(e) => {
59
+ onChange({ target: { name, value: e.target.checked } });
60
+ }}
61
+ />
62
+ <Field.Hint />
63
+ </Field.Root>
60
64
  );
61
65
  }
62
66
 
@@ -70,17 +74,17 @@ const Input = ({
70
74
  const errorMessage = error ? formatMessage({ id: error, defaultMessage: error }) : '';
71
75
 
72
76
  return (
73
- <TextInput
74
- aria-label={name}
75
- disabled={disabled}
76
- error={errorMessage}
77
- label={label}
78
- name={name}
79
- onChange={onChange}
80
- placeholder={formattedPlaceholder}
81
- type={type}
82
- value={inputValue}
83
- />
77
+ <Field.Root error={errorMessage} name={name}>
78
+ <Field.Label>{label}</Field.Label>
79
+ <TextInput
80
+ disabled={disabled}
81
+ onChange={onChange}
82
+ placeholder={formattedPlaceholder}
83
+ type={type}
84
+ value={inputValue}
85
+ />
86
+ <Field.Error />
87
+ </Field.Root>
84
88
  );
85
89
  };
86
90
 
@@ -0,0 +1,115 @@
1
+ /**
2
+ *
3
+ * FormModal
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+
9
+ import { Button, Flex, Grid, Modal, Breadcrumbs, Crumb } from '@strapi/design-system';
10
+ import { Form, Formik } from 'formik';
11
+ import PropTypes from 'prop-types';
12
+ import { useIntl } from 'react-intl';
13
+
14
+ import Input from './Input';
15
+
16
+ const FormModal = ({
17
+ headerBreadcrumbs,
18
+ initialData,
19
+ isSubmiting,
20
+ layout,
21
+ isOpen,
22
+ onSubmit,
23
+ onToggle,
24
+ providerToEditName,
25
+ }) => {
26
+ const { formatMessage } = useIntl();
27
+
28
+ return (
29
+ <Modal.Root open={isOpen} onOpenChange={onToggle}>
30
+ <Modal.Content>
31
+ <Modal.Header>
32
+ <Breadcrumbs label={headerBreadcrumbs.join(', ')}>
33
+ {headerBreadcrumbs.map((crumb, index, arr) => (
34
+ <Crumb isCurrent={index === arr.length - 1} key={crumb}>
35
+ {crumb}
36
+ </Crumb>
37
+ ))}
38
+ </Breadcrumbs>
39
+ </Modal.Header>
40
+ <Formik
41
+ onSubmit={(values) => onSubmit(values)}
42
+ initialValues={initialData}
43
+ validationSchema={layout.schema}
44
+ validateOnChange={false}
45
+ >
46
+ {({ errors, handleChange, values }) => {
47
+ return (
48
+ <Form>
49
+ <Modal.Body>
50
+ <Flex direction="column" alignItems="stretch" gap={1}>
51
+ <Grid.Root gap={5}>
52
+ {layout.form.map((row) => {
53
+ return row.map((input) => {
54
+ return (
55
+ <Grid.Item
56
+ key={input.name}
57
+ col={input.size}
58
+ xs={12}
59
+ direction="column"
60
+ alignItems="stretch"
61
+ >
62
+ <Input
63
+ {...input}
64
+ error={errors[input.name]}
65
+ onChange={handleChange}
66
+ value={values[input.name]}
67
+ providerToEditName={providerToEditName}
68
+ />
69
+ </Grid.Item>
70
+ );
71
+ });
72
+ })}
73
+ </Grid.Root>
74
+ </Flex>
75
+ </Modal.Body>
76
+ <Modal.Footer>
77
+ <Button variant="tertiary" onClick={onToggle} type="button">
78
+ {formatMessage({
79
+ id: 'app.components.Button.cancel',
80
+ defaultMessage: 'Cancel',
81
+ })}
82
+ </Button>
83
+ <Button type="submit" loading={isSubmiting}>
84
+ {formatMessage({ id: 'global.save', defaultMessage: 'Save' })}
85
+ </Button>
86
+ </Modal.Footer>
87
+ </Form>
88
+ );
89
+ }}
90
+ </Formik>
91
+ </Modal.Content>
92
+ </Modal.Root>
93
+ );
94
+ };
95
+
96
+ FormModal.defaultProps = {
97
+ initialData: null,
98
+ providerToEditName: null,
99
+ };
100
+
101
+ FormModal.propTypes = {
102
+ headerBreadcrumbs: PropTypes.arrayOf(PropTypes.string).isRequired,
103
+ initialData: PropTypes.object,
104
+ layout: PropTypes.shape({
105
+ form: PropTypes.arrayOf(PropTypes.array),
106
+ schema: PropTypes.object,
107
+ }).isRequired,
108
+ isOpen: PropTypes.bool.isRequired,
109
+ isSubmiting: PropTypes.bool.isRequired,
110
+ onSubmit: PropTypes.func.isRequired,
111
+ onToggle: PropTypes.func.isRequired,
112
+ providerToEditName: PropTypes.string,
113
+ };
114
+
115
+ export default FormModal;
@@ -1,9 +1,10 @@
1
- import styled, { css } from 'styled-components';
2
1
  import { Box } from '@strapi/design-system';
2
+ import { styled, css } from 'styled-components';
3
3
 
4
4
  const activeCheckboxWrapperStyles = css`
5
5
  background: ${(props) => props.theme.colors.primary100};
6
- svg {
6
+
7
+ #cog {
7
8
  opacity: 1;
8
9
  }
9
10
  `;
@@ -13,7 +14,7 @@ const CheckboxWrapper = styled(Box)`
13
14
  justify-content: space-between;
14
15
  align-items: center;
15
16
 
16
- svg {
17
+ #cog {
17
18
  opacity: 0;
18
19
  path {
19
20
  fill: ${(props) => props.theme.colors.primary600};
@@ -1,13 +1,16 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
+
3
+ import { Box, Checkbox, Flex, Typography, Grid, VisuallyHidden } from '@strapi/design-system';
4
+ import { Cog } from '@strapi/icons';
2
5
  import get from 'lodash/get';
3
- import styled from 'styled-components';
4
6
  import PropTypes from 'prop-types';
5
- import { Box, Checkbox, Flex, Typography, Grid, GridItem } from '@strapi/design-system';
6
- import { Cog as CogIcon } from '@strapi/icons';
7
7
  import { useIntl } from 'react-intl';
8
- import CheckboxWrapper from './CheckboxWrapper';
8
+ import { styled } from 'styled-components';
9
+
9
10
  import { useUsersPermissions } from '../../../contexts/UsersPermissionsContext';
10
11
 
12
+ import CheckboxWrapper from './CheckboxWrapper';
13
+
11
14
  const Border = styled.div`
12
15
  flex: 1;
13
16
  align-self: center;
@@ -60,44 +63,53 @@ const SubCategory = ({ subCategory }) => {
60
63
  <Box paddingLeft={4}>
61
64
  <Checkbox
62
65
  name={subCategory.name}
63
- value={hasAllActionsSelected}
64
- onValueChange={(value) =>
66
+ checked={hasSomeActionsSelected ? 'indeterminate' : hasAllActionsSelected}
67
+ onCheckedChange={(value) =>
65
68
  handleChangeSelectAll({ target: { name: subCategory.name, value } })
66
69
  }
67
- indeterminate={hasSomeActionsSelected}
68
70
  >
69
71
  {formatMessage({ id: 'app.utils.select-all', defaultMessage: 'Select all' })}
70
72
  </Checkbox>
71
73
  </Box>
72
74
  </Flex>
73
75
  <Flex paddingTop={6} paddingBottom={6}>
74
- <Grid gap={2} style={{ flex: 1 }}>
76
+ <Grid.Root gap={2} style={{ flex: 1 }}>
75
77
  {subCategory.actions.map((action) => {
76
78
  const name = `${action.name}.enabled`;
77
79
 
78
80
  return (
79
- <GridItem col={6} key={action.name}>
81
+ <Grid.Item col={6} key={action.name} direction="column" alignItems="stretch">
80
82
  <CheckboxWrapper isActive={isActionSelected(action.name)} padding={2} hasRadius>
81
83
  <Checkbox
82
- value={get(modifiedData, name, false)}
84
+ checked={get(modifiedData, name, false)}
83
85
  name={name}
84
- onValueChange={(value) => onChange({ target: { name, value } })}
86
+ onCheckedChange={(value) => onChange({ target: { name, value } })}
85
87
  >
86
88
  {action.label}
87
89
  </Checkbox>
88
90
  <button
89
91
  type="button"
90
- data-testid="action-cog"
91
92
  onClick={() => onSelectedAction(action.name)}
92
93
  style={{ display: 'inline-flex', alignItems: 'center' }}
93
94
  >
94
- <CogIcon />
95
+ <VisuallyHidden tag="span">
96
+ {formatMessage(
97
+ {
98
+ id: 'app.utils.show-bound-route',
99
+ defaultMessage: 'Show bound route for {route}',
100
+ },
101
+ {
102
+ route: action.name,
103
+ }
104
+ )}
105
+ </VisuallyHidden>
106
+ <Cog id="cog" />
95
107
  </button>
96
108
  </CheckboxWrapper>
97
- </GridItem>
109
+ </Grid.Item>
98
110
  );
99
111
  })}
100
- </Grid>
112
+ </Grid.Root>
101
113
  </Flex>
102
114
  </Box>
103
115
  );
@@ -1,7 +1,9 @@
1
1
  import React, { useMemo } from 'react';
2
- import PropTypes from 'prop-types';
3
- import sortBy from 'lodash/sortBy';
2
+
4
3
  import { Box } from '@strapi/design-system';
4
+ import sortBy from 'lodash/sortBy';
5
+ import PropTypes from 'prop-types';
6
+
5
7
  import SubCategory from './SubCategory';
6
8
 
7
9
  const PermissionRow = ({ name, permissions }) => {
@@ -0,0 +1,47 @@
1
+ import React, { useReducer } from 'react';
2
+
3
+ import { Accordion, Flex } from '@strapi/design-system';
4
+ import { useIntl } from 'react-intl';
5
+
6
+ import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
7
+ import formatPluginName from '../../utils/formatPluginName';
8
+
9
+ import init from './init';
10
+ import PermissionRow from './PermissionRow';
11
+ import { initialState, reducer } from './reducer';
12
+
13
+ const Permissions = () => {
14
+ const { modifiedData } = useUsersPermissions();
15
+ const { formatMessage } = useIntl();
16
+ const [{ collapses }] = useReducer(reducer, initialState, (state) => init(state, modifiedData));
17
+
18
+ return (
19
+ <Accordion.Root size="M">
20
+ <Flex direction="column" alignItems="stretch" gap={1}>
21
+ {collapses.map((collapse, index) => (
22
+ <Accordion.Item key={collapse.name} value={collapse.name}>
23
+ <Accordion.Header variant={index % 2 === 0 ? 'secondary' : undefined}>
24
+ <Accordion.Trigger
25
+ caretPosition="right"
26
+ description={formatMessage(
27
+ {
28
+ id: 'users-permissions.Plugin.permissions.plugins.description',
29
+ defaultMessage: 'Define all allowed actions for the {name} plugin.',
30
+ },
31
+ { name: collapse.name }
32
+ )}
33
+ >
34
+ {formatPluginName(collapse.name)}
35
+ </Accordion.Trigger>
36
+ </Accordion.Header>
37
+ <Accordion.Content>
38
+ <PermissionRow permissions={modifiedData[collapse.name]} name={collapse.name} />
39
+ </Accordion.Content>
40
+ </Accordion.Item>
41
+ ))}
42
+ </Flex>
43
+ </Accordion.Root>
44
+ );
45
+ };
46
+
47
+ export default Permissions;
@@ -1,4 +1,4 @@
1
- import produce from 'immer';
1
+ import { produce } from 'immer';
2
2
 
3
3
  const initialState = {
4
4
  collapses: [],
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
- import { useIntl } from 'react-intl';
3
- import { Typography, Flex, GridItem } from '@strapi/design-system';
2
+
3
+ import { Flex, Grid, Typography } from '@strapi/design-system';
4
4
  import get from 'lodash/get';
5
5
  import isEmpty from 'lodash/isEmpty';
6
6
  import without from 'lodash/without';
7
+ import { useIntl } from 'react-intl';
7
8
 
8
9
  import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
9
10
  import BoundRoute from '../BoundRoute';
@@ -21,7 +22,7 @@ const Policies = () => {
21
22
  : controllerRoutes.filter((o) => o.handler.endsWith(pathResolved));
22
23
 
23
24
  return (
24
- <GridItem
25
+ <Grid.Item
25
26
  col={5}
26
27
  background="neutral150"
27
28
  paddingTop={6}
@@ -29,6 +30,8 @@ const Policies = () => {
29
30
  paddingLeft={7}
30
31
  paddingRight={7}
31
32
  style={{ minHeight: '100%' }}
33
+ direction="column"
34
+ alignItems="stretch"
32
35
  >
33
36
  {selectedAction ? (
34
37
  <Flex direction="column" alignItems="stretch" gap={2}>
@@ -39,13 +42,13 @@ const Policies = () => {
39
42
  </Flex>
40
43
  ) : (
41
44
  <Flex direction="column" alignItems="stretch" gap={2}>
42
- <Typography variant="delta" as="h3">
45
+ <Typography variant="delta" tag="h3">
43
46
  {formatMessage({
44
47
  id: 'users-permissions.Policies.header.title',
45
48
  defaultMessage: 'Advanced settings',
46
49
  })}
47
50
  </Typography>
48
- <Typography as="p" textColor="neutral600">
51
+ <Typography tag="p" textColor="neutral600">
49
52
  {formatMessage({
50
53
  id: 'users-permissions.Policies.header.hint',
51
54
  defaultMessage:
@@ -54,7 +57,7 @@ const Policies = () => {
54
57
  </Typography>
55
58
  </Flex>
56
59
  )}
57
- </GridItem>
60
+ </Grid.Item>
58
61
  );
59
62
  };
60
63
 
@@ -1,13 +1,16 @@
1
- import React, { memo, useReducer, forwardRef, useImperativeHandle } from 'react';
1
+ import React, { forwardRef, memo, useImperativeHandle, useReducer } from 'react';
2
+
3
+ import { Flex, Grid, Typography } from '@strapi/design-system';
2
4
  import PropTypes from 'prop-types';
3
- import { Typography, Flex, Grid, GridItem } from '@strapi/design-system';
4
5
  import { useIntl } from 'react-intl';
6
+
7
+ import { UsersPermissionsProvider } from '../../contexts/UsersPermissionsContext';
5
8
  import getTrad from '../../utils/getTrad';
6
- import Policies from '../Policies';
7
9
  import Permissions from '../Permissions';
8
- import reducer, { initialState } from './reducer';
9
- import { UsersPermissionsProvider } from '../../contexts/UsersPermissionsContext';
10
+ import Policies from '../Policies';
11
+
10
12
  import init from './init';
13
+ import reducer, { initialState } from './reducer';
11
14
 
12
15
  const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
13
16
  const { formatMessage } = useIntl();
@@ -58,17 +61,25 @@ const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
58
61
 
59
62
  return (
60
63
  <UsersPermissionsProvider value={providerValue}>
61
- <Grid gap={0} shadow="filterShadow" hasRadius background="neutral0">
62
- <GridItem col={7} paddingTop={6} paddingBottom={6} paddingLeft={7} paddingRight={7}>
64
+ <Grid.Root gap={0} shadow="filterShadow" hasRadius background="neutral0">
65
+ <Grid.Item
66
+ col={7}
67
+ paddingTop={6}
68
+ paddingBottom={6}
69
+ paddingLeft={7}
70
+ paddingRight={7}
71
+ direction="column"
72
+ alignItems="stretch"
73
+ >
63
74
  <Flex direction="column" alignItems="stretch" gap={6}>
64
75
  <Flex direction="column" alignItems="stretch" gap={2}>
65
- <Typography variant="delta" as="h2">
76
+ <Typography variant="delta" tag="h2">
66
77
  {formatMessage({
67
78
  id: getTrad('Plugins.header.title'),
68
79
  defaultMessage: 'Permissions',
69
80
  })}
70
81
  </Typography>
71
- <Typography as="p" textColor="neutral600">
82
+ <Typography tag="p" textColor="neutral600">
72
83
  {formatMessage({
73
84
  id: getTrad('Plugins.header.description'),
74
85
  defaultMessage: 'Only actions bound by a route are listed below.',
@@ -77,9 +88,9 @@ const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
77
88
  </Flex>
78
89
  <Permissions />
79
90
  </Flex>
80
- </GridItem>
91
+ </Grid.Item>
81
92
  <Policies />
82
- </Grid>
93
+ </Grid.Root>
83
94
  </UsersPermissionsProvider>
84
95
  );
85
96
  });
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable consistent-return */
2
- import produce from 'immer';
2
+ import { produce } from 'immer';
3
3
  import get from 'lodash/get';
4
4
  import set from 'lodash/set';
5
5
  import take from 'lodash/take';
@@ -1,4 +1,4 @@
1
- const pluginPermissions = {
1
+ export const PERMISSIONS = {
2
2
  // Roles
3
3
  accessRoles: [
4
4
  { action: 'plugin::users-permissions.roles.create', subject: null },
@@ -27,5 +27,3 @@ const pluginPermissions = {
27
27
  readProviders: [{ action: 'plugin::users-permissions.providers.read', subject: null }],
28
28
  updateProviders: [{ action: 'plugin::users-permissions.providers.update', subject: null }],
29
29
  };
30
-
31
- export default pluginPermissions;
@@ -1,4 +1,5 @@
1
1
  import React, { createContext, useContext } from 'react';
2
+
2
3
  import PropTypes from 'prop-types';
3
4
 
4
5
  const UsersPermissions = createContext({});