@strapi/admin 4.8.2 → 4.9.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 (109) hide show
  1. package/admin/src/content-manager/components/DynamicZone/utils/select.js +1 -1
  2. package/admin/src/content-manager/components/FieldComponent/utils/select.js +2 -1
  3. package/admin/src/content-manager/components/Inputs/utils/getInputType.js +1 -1
  4. package/admin/src/content-manager/components/Inputs/utils/select.js +1 -1
  5. package/admin/src/content-manager/hooks/useContentTypeLayout/index.js +1 -2
  6. package/admin/src/content-manager/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +4 -1
  7. package/admin/src/content-manager/pages/CollectionTypeRecursivePath/index.js +1 -2
  8. package/admin/src/content-manager/pages/EditSettingsView/init.js +3 -1
  9. package/admin/src/content-manager/pages/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +2 -4
  10. package/admin/src/content-manager/pages/EditView/DeleteLink/utils/select.js +1 -1
  11. package/admin/src/content-manager/pages/EditView/utils/createAttributesLayout.js +2 -1
  12. package/admin/src/content-manager/pages/EditView/utils/getFieldsActionMatchingPermissions.js +2 -1
  13. package/admin/src/content-manager/utils/checkIfAttributeIsDisplayable.js +1 -1
  14. package/admin/src/content-manager/utils/createDefaultForm.js +2 -2
  15. package/admin/src/content-manager/utils/formatLayoutToApi.js +2 -1
  16. package/admin/src/content-manager/utils/getFieldName.js +1 -1
  17. package/admin/src/content-manager/utils/mergeMetasWithSchema.js +1 -1
  18. package/admin/src/content-manager/utils/paths.js +1 -1
  19. package/admin/src/content-manager/utils/removePasswordFieldsFromData.js +1 -1
  20. package/admin/src/hooks/useRegenerate/index.js +12 -7
  21. package/admin/src/hooks/useSettingsForm/index.js +3 -3
  22. package/admin/src/hooks/useSettingsForm/reducer.js +3 -1
  23. package/admin/src/hooks/useSettingsMenu/reducer.js +1 -1
  24. package/admin/src/pages/AuthPage/reducer.js +1 -1
  25. package/admin/src/pages/SettingsPage/components/Tokens/FormHead/index.js +4 -0
  26. package/admin/src/pages/SettingsPage/components/Tokens/Regenerate/index.js +5 -3
  27. package/admin/src/pages/SettingsPage/components/Tokens/TokenTypeSelect/index.js +7 -5
  28. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/CollapsableContentType/index.js +1 -1
  29. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/reducer.js +1 -1
  30. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/transformPermissionsData.js +6 -8
  31. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ConditionsModal/utils/createDefaultConditionsForm.js +1 -1
  32. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ContentTypeCollapse/Collapse/utils/generateCheckboxesActions.js +2 -1
  33. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/utils/getRowLabelCheckboxeState.js +2 -1
  34. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/GlobalActions/utils/getRowLabelCheckboxesState.js +1 -1
  35. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/reducer.js +6 -1
  36. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/createDefaultCTFormFromLayout.js +5 -1
  37. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/createDefaultPluginsFormFromLayout.js +1 -2
  38. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/formatContentTypesPermissionToAPI.js +2 -2
  39. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/updateConditionsToFalse.js +4 -1
  40. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/updateValues.js +1 -1
  41. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/PluginsAndSettings/SubCategory/utils/formatActions.js +1 -1
  42. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/utils/createArrayOfValues.js +2 -1
  43. package/admin/src/pages/SettingsPage/pages/Roles/ListPage/index.js +1 -1
  44. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/components/FormTransferTokenContainer/index.js +41 -0
  45. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +53 -9
  46. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/utils/schema.js +1 -0
  47. package/admin/src/pages/SettingsPage/pages/TransferTokens/ListView/index.js +27 -5
  48. package/admin/src/pages/SettingsPage/pages/Users/ProtectedEditPage/index.js +2 -2
  49. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/utils/formatData.js +1 -7
  50. package/admin/src/permissions/index.js +1 -1
  51. package/admin/src/translations/en.json +1 -0
  52. package/admin/src/utils/getAttributesToDisplay.js +2 -4
  53. package/admin/src/utils/getExistingActions.js +1 -3
  54. package/admin/src/utils/sortLinks.js +1 -1
  55. package/build/{8580.0aa21940.chunk.js → 2263.4c5916f9.chunk.js} +61 -61
  56. package/build/5563.aa832e5f.chunk.js +30 -0
  57. package/build/6985.66cca29c.chunk.js +1 -0
  58. package/build/7259.e6ef3b8e.chunk.js +1 -0
  59. package/build/{7112.2bf13da3.chunk.js → 9505.dbe702ab.chunk.js} +6 -6
  60. package/build/Admin-authenticatedApp.cb754f73.chunk.js +79 -0
  61. package/build/{Admin_profilePage.d2a8f9ab.chunk.js → Admin_profilePage.76afeca0.chunk.js} +1 -1
  62. package/build/{Admin_settingsPage.7450acfc.chunk.js → Admin_settingsPage.0aa4fcdc.chunk.js} +2 -2
  63. package/build/admin-app.50584489.chunk.js +112 -0
  64. package/build/admin-edit-roles-page.cf543488.chunk.js +216 -0
  65. package/build/admin-edit-users.31c20712.chunk.js +10 -0
  66. package/build/admin-roles-list.489c501f.chunk.js +2 -0
  67. package/build/{admin-users.af8c3123.chunk.js → admin-users.3e111a7d.chunk.js} +1 -1
  68. package/build/{api-tokens-create-page.4328b852.chunk.js → api-tokens-create-page.2a6e22bd.chunk.js} +1 -1
  69. package/build/{api-tokens-edit-page.bce5050f.chunk.js → api-tokens-edit-page.fa38cd63.chunk.js} +1 -1
  70. package/build/content-manager.f8b9710b.chunk.js +1139 -0
  71. package/build/content-type-builder.0f5dbcf1.chunk.js +126 -0
  72. package/build/{en-json.01a88a30.chunk.js → en-json.b052667a.chunk.js} +1 -1
  73. package/build/index.html +1 -1
  74. package/build/main.7fa3d343.js +3783 -0
  75. package/build/{runtime~main.05f8f4a1.js → runtime~main.03d11c09.js} +2 -2
  76. package/build/sso-settings-page.272b87c8.chunk.js +1 -0
  77. package/build/transfer-tokens-list-page.3c9b0280.chunk.js +16 -0
  78. package/build/users-advanced-settings-page.1d3c14c7.chunk.js +1 -0
  79. package/build/{users-email-settings-page.a3c80419.chunk.js → users-email-settings-page.e8db68c4.chunk.js} +1 -1
  80. package/build/users-providers-settings-page.14cac425.chunk.js +1 -0
  81. package/build/users-roles-settings-page.2ea4de84.chunk.js +30 -0
  82. package/build/{webhook-edit-page.a2a2b7bb.chunk.js → webhook-edit-page.329141a5.chunk.js} +3 -3
  83. package/ee/server/bootstrap.js +3 -0
  84. package/ee/server/utils/persisted-tables.js +49 -0
  85. package/package.json +11 -11
  86. package/server/controllers/transfer/runner.js +4 -2
  87. package/server/middlewares/data-transfer.js +4 -1
  88. package/server/routes/transfer.js +13 -4
  89. package/server/services/constants.js +4 -0
  90. package/server/services/permission/permissions-manager/sanitize.js +2 -0
  91. package/server/services/transfer/permission.js +1 -1
  92. package/server/services/transfer/token.js +33 -31
  93. package/server/validation/transfer/token.js +10 -2
  94. package/build/2637.679b590b.chunk.js +0 -1
  95. package/build/4649.33220ac3.chunk.js +0 -30
  96. package/build/7259.3675c199.chunk.js +0 -1
  97. package/build/Admin-authenticatedApp.26f0eff6.chunk.js +0 -79
  98. package/build/admin-app.c0729915.chunk.js +0 -112
  99. package/build/admin-edit-roles-page.3b196317.chunk.js +0 -216
  100. package/build/admin-edit-users.af3b0f15.chunk.js +0 -10
  101. package/build/admin-roles-list.0ad504a7.chunk.js +0 -2
  102. package/build/content-manager.b2578b87.chunk.js +0 -1139
  103. package/build/content-type-builder.a93f97ba.chunk.js +0 -126
  104. package/build/main.ed856941.js +0 -3809
  105. package/build/sso-settings-page.5a8588ef.chunk.js +0 -1
  106. package/build/transfer-tokens-list-page.ce37354b.chunk.js +0 -16
  107. package/build/users-advanced-settings-page.c0cae03a.chunk.js +0 -1
  108. package/build/users-providers-settings-page.5f86e45c.chunk.js +0 -1
  109. package/build/users-roles-settings-page.b02986df.chunk.js +0 -30
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from 'react';
2
- import { get } from 'lodash';
2
+ import get from 'lodash/get';
3
3
  import { useCMEditViewDataManager } from '@strapi/helper-plugin';
4
4
 
5
5
  function useSelect(name) {
@@ -1,5 +1,6 @@
1
1
  import { useMemo } from 'react';
2
- import { get, take } from 'lodash';
2
+ import get from 'lodash/get';
3
+ import take from 'lodash/take';
3
4
  import { useCMEditViewDataManager } from '@strapi/helper-plugin';
4
5
 
5
6
  import { getFieldName } from '../../../utils';
@@ -1,4 +1,4 @@
1
- import { toLower } from 'lodash';
1
+ import toLower from 'lodash/toLower';
2
2
 
3
3
  const getInputType = (type = '') => {
4
4
  switch (toLower(type)) {
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from 'react';
2
- import { get } from 'lodash';
2
+ import get from 'lodash/get';
3
3
  import { useCMEditViewDataManager } from '@strapi/helper-plugin';
4
4
 
5
5
  function useSelect(keys) {
@@ -1,5 +1,4 @@
1
1
  import { useCallback } from 'react';
2
- import { get } from 'lodash';
3
2
  import { useSelector } from 'react-redux';
4
3
  import selectLayout from '../../pages/EditViewLayoutManager/selectors';
5
4
 
@@ -8,7 +7,7 @@ const useContentTypeLayout = () => {
8
7
 
9
8
  const getComponentLayout = useCallback(
10
9
  (componentUid) => {
11
- return get(currentLayout, ['components', componentUid], {});
10
+ return currentLayout?.components?.[componentUid] ?? {};
12
11
  },
13
12
  [currentLayout]
14
13
  );
@@ -1,4 +1,7 @@
1
- import { cloneDeep, get, set } from 'lodash';
1
+ import cloneDeep from 'lodash/cloneDeep';
2
+ import get from 'lodash/get';
3
+ import set from 'lodash/set';
4
+
2
5
  import { mergeMetasWithSchema } from '../../../utils';
3
6
 
4
7
  const getRelationModel = (targetModel, models) => models.find((model) => model.uid === targetModel);
@@ -1,7 +1,6 @@
1
1
  import React, { memo, useMemo } from 'react';
2
2
  import { Switch, Route } from 'react-router-dom';
3
3
  import { ErrorBoundary } from 'react-error-boundary';
4
- import { get } from 'lodash';
5
4
  import PropTypes from 'prop-types';
6
5
  import { LoadingIndicatorPage, CheckPagePermissions } from '@strapi/helper-plugin';
7
6
  import permissions from '../../../permissions';
@@ -43,7 +42,7 @@ const CollectionTypeRecursivePath = ({
43
42
  return { rawContentTypeLayout, rawComponentsLayouts };
44
43
  }, [layout]);
45
44
 
46
- const uid = get(layout, ['contentType', 'uid'], null);
45
+ const uid = layout?.contentType?.uid ?? null;
47
46
 
48
47
  // This statement is needed in order to prevent the CollectionTypeFormWrapper effects clean up phase to be run twice.
49
48
  // What can happen is that when navigating from one entry to another the cleanup phase of the fetch data effect is run twice : once when
@@ -1,4 +1,6 @@
1
- import { cloneDeep, set } from 'lodash';
1
+ import cloneDeep from 'lodash/cloneDeep';
2
+ import set from 'lodash/set';
3
+
2
4
  import { createLayout, formatLayout } from './utils/layout';
3
5
 
4
6
  const init = (initialState, mainLayout, components) => {
@@ -1,8 +1,6 @@
1
- import { get } from 'lodash';
2
-
3
1
  const createPossibleMainFieldsForModelsAndComponents = (array) => {
4
2
  return array.reduce((acc, current) => {
5
- const attributes = get(current, ['attributes'], {});
3
+ const attributes = current?.attributes ?? {};
6
4
  const possibleMainFields = Object.keys(attributes).filter((attr) => {
7
5
  return ![
8
6
  'boolean',
@@ -14,7 +12,7 @@ const createPossibleMainFieldsForModelsAndComponents = (array) => {
14
12
  'relation',
15
13
  'text',
16
14
  'richtext',
17
- ].includes(get(attributes, [attr, 'type'], ''));
15
+ ].includes(attributes?.[attr]?.type ?? '');
18
16
  });
19
17
 
20
18
  acc[current.uid] = possibleMainFields;
@@ -1,4 +1,4 @@
1
- import { isEmpty } from 'lodash';
1
+ import isEmpty from 'lodash/isEmpty';
2
2
  import { useCMEditViewDataManager } from '@strapi/helper-plugin';
3
3
 
4
4
  function useSelect() {
@@ -1,4 +1,5 @@
1
- import { get, isEmpty } from 'lodash';
1
+ import get from 'lodash/get';
2
+ import isEmpty from 'lodash/isEmpty';
2
3
 
3
4
  const createAttributesLayout = (currentContentTypeLayoutData) => {
4
5
  if (!currentContentTypeLayoutData.layouts) {
@@ -1,4 +1,5 @@
1
- import { uniq, flatMap } from 'lodash';
1
+ import uniq from 'lodash/uniq';
2
+ import flatMap from 'lodash/flatMap';
2
3
  import { findMatchingPermissions } from '@strapi/helper-plugin';
3
4
 
4
5
  const getFieldsActionMatchingPermissions = (userPermissions, slug) => {
@@ -1,4 +1,4 @@
1
- import { toLower } from 'lodash';
1
+ import toLower from 'lodash/toLower';
2
2
 
3
3
  const checkIfAttributeIsDisplayable = (attribute) => {
4
4
  const type = attribute.type;
@@ -1,4 +1,4 @@
1
- import { get } from 'lodash';
1
+ import get from 'lodash/get';
2
2
 
3
3
  const createDefaultForm = (attributes, allComponentsSchema) => {
4
4
  return Object.keys(attributes).reduce((acc, current) => {
@@ -10,7 +10,7 @@ const createDefaultForm = (attributes, allComponentsSchema) => {
10
10
  }
11
11
 
12
12
  if (type === 'component') {
13
- const currentComponentSchema = get(allComponentsSchema, [component, 'attributes'], {});
13
+ const currentComponentSchema = allComponentsSchema?.[component]?.attributes ?? {};
14
14
  const currentComponentDefaultForm = createDefaultForm(
15
15
  currentComponentSchema,
16
16
  allComponentsSchema
@@ -1,4 +1,5 @@
1
- import { omit, get } from 'lodash';
1
+ import get from 'lodash/get';
2
+ import omit from 'lodash/omit';
2
3
 
3
4
  const formatLayoutToApi = ({ layouts, metadatas, ...rest }) => {
4
5
  const list = layouts.list.map((obj) => {
@@ -1,4 +1,4 @@
1
- import { isNaN } from 'lodash';
1
+ import isNaN from 'lodash/isNaN';
2
2
 
3
3
  const getFieldName = (stringName) =>
4
4
  stringName.split('.').filter((string) => isNaN(parseInt(string, 10)));
@@ -1,4 +1,4 @@
1
- import { set } from 'lodash';
1
+ import set from 'lodash/set';
2
2
 
3
3
  const mergeMetasWithSchema = (data, schemas, mainSchemaKey) => {
4
4
  const findSchema = (refUid) => schemas.find((obj) => obj.uid === refUid);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file is for all helpers related to `paths` in the CM.
3
3
  */
4
- import { get } from 'lodash';
4
+ import get from 'lodash/get';
5
5
 
6
6
  /**
7
7
  * This is typically used in circumstances where there are re-orderable pieces e.g. Dynamic Zones
@@ -1,4 +1,4 @@
1
- import { get } from 'lodash';
1
+ import get from 'lodash/get';
2
2
  import { getType, getOtherInfos } from '@strapi/helper-plugin';
3
3
 
4
4
  const removePasswordFieldsFromData = (data, contentTypeSchema, componentSchema) => {
@@ -1,11 +1,11 @@
1
1
  import { useState } from 'react';
2
- import { get } from 'lodash';
3
- import { useFetchClient, useNotification } from '@strapi/helper-plugin';
2
+ import { useFetchClient, useNotification, useAPIErrorHandler } from '@strapi/helper-plugin';
4
3
 
5
- const useRegenerate = (url, id, onRegenerate) => {
4
+ const useRegenerate = (url, id, onRegenerate, onError) => {
6
5
  const [isLoadingConfirmation, setIsLoadingConfirmation] = useState(false);
7
6
  const toggleNotification = useNotification();
8
7
  const { post } = useFetchClient();
8
+ const { formatAPIError } = useAPIErrorHandler();
9
9
 
10
10
  const regenerateData = async () => {
11
11
  try {
@@ -18,10 +18,15 @@ const useRegenerate = (url, id, onRegenerate) => {
18
18
  onRegenerate(accessKey);
19
19
  } catch (error) {
20
20
  setIsLoadingConfirmation(false);
21
- toggleNotification({
22
- type: 'warning',
23
- message: get(error, 'response.data.message', 'notification.error'),
24
- });
21
+
22
+ if (onError) {
23
+ onError(error);
24
+ } else {
25
+ toggleNotification({
26
+ type: 'warning',
27
+ message: formatAPIError(error),
28
+ });
29
+ }
25
30
  }
26
31
  };
27
32
 
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useReducer } from 'react';
2
2
  import { request, useNotification, useOverlayBlocker } from '@strapi/helper-plugin';
3
- import { get, has, omit } from 'lodash';
3
+ import omit from 'lodash/omit';
4
4
  import { checkFormValidity, formatAPIErrors } from '../../utils';
5
5
  import { initialState, reducer } from './reducer';
6
6
  import init from './init';
@@ -102,9 +102,9 @@ const useSettingsForm = (endPoint, schema, cbSuccess, fieldsToPick) => {
102
102
  message: { id: 'notification.success.saved' },
103
103
  });
104
104
  } catch (err) {
105
- const data = get(err, 'response.payload', { data: {} });
105
+ const data = err?.response?.payload ?? { data: {} };
106
106
 
107
- if (has(data, 'data') && typeof data.data === 'string') {
107
+ if (!!data?.data && typeof data.data === 'string') {
108
108
  toggleNotification({
109
109
  type: 'warning',
110
110
  message: data.data,
@@ -1,6 +1,8 @@
1
1
  /* eslint-disable consistent-return */
2
2
  import produce from 'immer';
3
- import { pick, set, unset } from 'lodash';
3
+ import pick from 'lodash/pick';
4
+ import set from 'lodash/set';
5
+ import unset from 'lodash/unset';
4
6
 
5
7
  const initialState = {
6
8
  fieldsToPick: [],
@@ -1,5 +1,5 @@
1
1
  import produce from 'immer';
2
- import { set } from 'lodash';
2
+ import set from 'lodash/set';
3
3
 
4
4
  const initialState = {
5
5
  menu: [],
@@ -1,5 +1,5 @@
1
1
  import produce from 'immer';
2
- import { set } from 'lodash';
2
+ import set from 'lodash/set';
3
3
  /* eslint-disable consistent-return */
4
4
 
5
5
  const initialState = {
@@ -15,6 +15,7 @@ const FormHead = ({
15
15
  isSubmitting,
16
16
  backUrl,
17
17
  regenerateUrl,
18
+ onErrorRegenerate,
18
19
  }) => {
19
20
  const { formatMessage } = useIntl();
20
21
  const handleRegenerate = (newKey) => {
@@ -35,6 +36,7 @@ const FormHead = ({
35
36
  backUrl={regenerateUrl}
36
37
  onRegenerate={handleRegenerate}
37
38
  idToRegenerate={token?.id}
39
+ onError={onErrorRegenerate}
38
40
  />
39
41
  )}
40
42
  <Button
@@ -95,10 +97,12 @@ FormHead.propTypes = {
95
97
  label: PropTypes.string,
96
98
  }).isRequired,
97
99
  regenerateUrl: PropTypes.string.isRequired,
100
+ onErrorRegenerate: PropTypes.func,
98
101
  };
99
102
 
100
103
  FormHead.defaultProps = {
101
104
  token: undefined,
105
+ onErrorRegenerate: undefined,
102
106
  };
103
107
 
104
108
  export default FormHead;
@@ -6,13 +6,14 @@ import { Refresh } from '@strapi/icons';
6
6
  import { ConfirmDialog } from '@strapi/helper-plugin';
7
7
  import { useRegenerate } from '../../../../../hooks';
8
8
 
9
- export const Regenerate = ({ onRegenerate, idToRegenerate, backUrl }) => {
9
+ export const Regenerate = ({ onRegenerate, idToRegenerate, backUrl, onError }) => {
10
10
  const { formatMessage } = useIntl();
11
11
  const [showConfirmDialog, setShowConfirmDialog] = useState(false);
12
12
  const { regenerateData, isLoadingConfirmation } = useRegenerate(
13
13
  backUrl,
14
14
  idToRegenerate,
15
- onRegenerate
15
+ onRegenerate,
16
+ onError
16
17
  );
17
18
  const handleConfirmRegeneration = async () => {
18
19
  regenerateData();
@@ -62,12 +63,13 @@ export const Regenerate = ({ onRegenerate, idToRegenerate, backUrl }) => {
62
63
  );
63
64
  };
64
65
 
65
- Regenerate.defaultProps = { onRegenerate() {} };
66
+ Regenerate.defaultProps = { onRegenerate() {}, onError: undefined };
66
67
 
67
68
  Regenerate.propTypes = {
68
69
  onRegenerate: PropTypes.func,
69
70
  idToRegenerate: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
70
71
  backUrl: PropTypes.string.isRequired,
72
+ onError: PropTypes.func,
71
73
  };
72
74
 
73
75
  export default Regenerate;
@@ -4,21 +4,21 @@ import { useIntl } from 'react-intl';
4
4
 
5
5
  import { Select, Option } from '@strapi/design-system';
6
6
 
7
- const TokenTypeSelect = ({ errors, values, onChange, canEditInputs, options, label }) => {
7
+ const TokenTypeSelect = ({ name, errors, values, onChange, canEditInputs, options, label }) => {
8
8
  const { formatMessage } = useIntl();
9
9
 
10
10
  return (
11
11
  <Select
12
- name="type"
12
+ name={name}
13
13
  label={formatMessage({
14
14
  id: label.id,
15
15
  defaultMessage: label.defaultMessage,
16
16
  })}
17
- value={values?.type}
17
+ value={values && values[name]}
18
18
  error={
19
- errors.type
19
+ errors[name]
20
20
  ? formatMessage(
21
- errors.type?.id ? errors.type : { id: errors.type, defaultMessage: errors.type }
21
+ errors[name]?.id ? errors[name] : { id: errors[name], defaultMessage: errors[name] }
22
22
  )
23
23
  : null
24
24
  }
@@ -38,6 +38,7 @@ const TokenTypeSelect = ({ errors, values, onChange, canEditInputs, options, lab
38
38
  };
39
39
 
40
40
  TokenTypeSelect.propTypes = {
41
+ name: PropTypes.string,
41
42
  options: PropTypes.arrayOf(
42
43
  PropTypes.shape({
43
44
  label: PropTypes.shape({
@@ -62,6 +63,7 @@ TokenTypeSelect.propTypes = {
62
63
  };
63
64
 
64
65
  TokenTypeSelect.defaultProps = {
66
+ name: 'type',
65
67
  errors: {},
66
68
  options: [],
67
69
  };
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { capitalize } from 'lodash';
2
+ import capitalize from 'lodash/capitalize';
3
3
  import { useIntl } from 'react-intl';
4
4
  import {
5
5
  Accordion,
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable consistent-return */
2
2
  import produce from 'immer';
3
- import { pull } from 'lodash';
3
+ import pull from 'lodash/pull';
4
4
  import { transformPermissionsData } from './utils';
5
5
 
6
6
  export const initialState = {
@@ -1,5 +1,3 @@
1
- import { flatten } from 'lodash';
2
-
3
1
  const transformPermissionsData = (data) => {
4
2
  const layout = {
5
3
  allActionsIds: [],
@@ -9,11 +7,11 @@ const transformPermissionsData = (data) => {
9
7
  layout.permissions = Object.keys(data).map((apiId) => ({
10
8
  apiId,
11
9
  label: apiId.split('::')[1],
12
- controllers: flatten(
13
- Object.keys(data[apiId].controllers).map((controller) => ({
10
+ controllers: Object.keys(data[apiId].controllers)
11
+ .map((controller) => ({
14
12
  controller,
15
- actions: flatten(
16
- data[apiId].controllers[controller].map((action) => {
13
+ actions: data[apiId].controllers[controller]
14
+ .map((action) => {
17
15
  const actionId = `${apiId}.${controller}.${action}`;
18
16
 
19
17
  if (apiId.includes('api::')) {
@@ -25,9 +23,9 @@ const transformPermissionsData = (data) => {
25
23
  actionId,
26
24
  };
27
25
  })
28
- ),
26
+ .flat(),
29
27
  }))
30
- ),
28
+ .flat(),
31
29
  }));
32
30
 
33
31
  return layout;
@@ -1,4 +1,4 @@
1
- import { get } from 'lodash';
1
+ import get from 'lodash/get';
2
2
 
3
3
  const createConditionsForm = (conditions, valueObject) => {
4
4
  return conditions.reduce((acc, current) => {
@@ -1,4 +1,5 @@
1
- import { get, isEmpty } from 'lodash';
1
+ import get from 'lodash/get';
2
+ import isEmpty from 'lodash/isEmpty';
2
3
  import { createArrayOfValues, getCheckboxState } from '../../../utils';
3
4
 
4
5
  const generateCheckboxesActions = (availableActions, modifiedData, pathToData) => {
@@ -1,4 +1,5 @@
1
- import { get } from 'lodash';
1
+ import get from 'lodash/get';
2
+
2
3
  import { getCheckboxState } from '../../../../utils';
3
4
 
4
5
  /**
@@ -1,4 +1,4 @@
1
- import { get } from 'lodash';
1
+ import get from 'lodash/get';
2
2
  import { getCheckboxState, removeConditionKeyFromData } from '../../utils';
3
3
 
4
4
  const getActionsIds = (array) => array.map(({ actionId }) => actionId);
@@ -1,5 +1,10 @@
1
1
  import produce from 'immer';
2
- import { cloneDeep, has, isObject, get, set } from 'lodash';
2
+ import cloneDeep from 'lodash/cloneDeep';
3
+ import has from 'lodash/has';
4
+ import isObject from 'lodash/isObject';
5
+ import get from 'lodash/get';
6
+ import set from 'lodash/set';
7
+
3
8
  import updateConditionsToFalse from './utils/updateConditionsToFalse';
4
9
  import updateValues from './utils/updateValues';
5
10
 
@@ -1,4 +1,8 @@
1
- import { merge, get, isEmpty, set } from 'lodash';
1
+ import get from 'lodash/get';
2
+ import isEmpty from 'lodash/isEmpty';
3
+ import merge from 'lodash/merge';
4
+ import set from 'lodash/set';
5
+
2
6
  import findMatchingPermission from './findMatchingPermissions';
3
7
  /**
4
8
  * Creates the default condition form: { [conditionId]: false }
@@ -1,4 +1,3 @@
1
- import { get } from 'lodash';
2
1
  import { createDefaultConditionsForm } from './createDefaultCTFormFromLayout';
3
2
  import findMatchingPermission from './findMatchingPermissions';
4
3
 
@@ -12,7 +11,7 @@ const createSubCategoryForm = (actions, conditions, permissions) => {
12
11
  },
13
12
  conditions: createDefaultConditionsForm(
14
13
  conditions,
15
- get(foundMatchingPermission, 'conditions', [])
14
+ foundMatchingPermission?.conditions ?? []
16
15
  ),
17
16
  };
18
17
 
@@ -1,4 +1,4 @@
1
- import { has, isObject } from 'lodash';
1
+ import isObject from 'lodash/isObject';
2
2
  import { createArrayOfValues } from '../../utils';
3
3
  import { createConditionsArray } from './formatSettingsPermissionsToAPI';
4
4
 
@@ -77,7 +77,7 @@ const createSubjectPermissions = (subject, actions) => {
77
77
  return acc;
78
78
  }
79
79
 
80
- if (!has(permissions, 'properties.enabled')) {
80
+ if (!permissions?.properties?.enabled) {
81
81
  const createdPermissionsArray = createPermissionWithProperties(
82
82
  actionName,
83
83
  subject,
@@ -1,4 +1,7 @@
1
- import { isObject, has, omit } from 'lodash';
1
+ import isObject from 'lodash/isObject';
2
+ import has from 'lodash/has';
3
+ import omit from 'lodash/omit';
4
+
2
5
  import { createArrayOfValues } from '../../utils';
3
6
 
4
7
  /**
@@ -1,4 +1,4 @@
1
- import { isObject } from 'lodash';
1
+ import isObject from 'lodash/isObject';
2
2
 
3
3
  /**
4
4
  * Sets all the none object values of an object to the given one
@@ -1,4 +1,4 @@
1
- import { get } from 'lodash';
1
+ import get from 'lodash/get';
2
2
  import { createArrayOfValues } from '../../../utils';
3
3
 
4
4
  /**
@@ -1,4 +1,5 @@
1
- import { flattenDeep, isObject } from 'lodash';
1
+ import flattenDeep from 'lodash/flattenDeep';
2
+ import isObject from 'lodash/isObject';
2
3
 
3
4
  const createArrayOfValues = (obj) => {
4
5
  if (!isObject(obj)) {
@@ -26,7 +26,7 @@ import {
26
26
  Typography,
27
27
  VisuallyHidden,
28
28
  } from '@strapi/design-system';
29
- import { get } from 'lodash';
29
+ import get from 'lodash/get';
30
30
  import matchSorter from 'match-sorter';
31
31
  import { useIntl } from 'react-intl';
32
32
  import { useHistory } from 'react-router-dom';
@@ -5,6 +5,7 @@ import { Box, Grid, GridItem, Flex, Typography } from '@strapi/design-system';
5
5
  import LifeSpanInput from '../../../../../components/Tokens/LifeSpanInput';
6
6
  import TokenName from '../../../../../components/Tokens/TokenName';
7
7
  import TokenDescription from '../../../../../components/Tokens/TokenDescription';
8
+ import TokenTypeSelect from '../../../../../components/Tokens/TokenTypeSelect';
8
9
 
9
10
  const FormTransferTokenContainer = ({
10
11
  errors,
@@ -16,6 +17,30 @@ const FormTransferTokenContainer = ({
16
17
  }) => {
17
18
  const { formatMessage } = useIntl();
18
19
 
20
+ const typeOptions = [
21
+ {
22
+ value: 'push',
23
+ label: {
24
+ id: 'Settings.transferTokens.types.push',
25
+ defaultMessage: 'Push',
26
+ },
27
+ },
28
+ {
29
+ value: 'pull',
30
+ label: {
31
+ id: 'Settings.transferTokens.types.pull',
32
+ defaultMessage: 'Pull',
33
+ },
34
+ },
35
+ {
36
+ value: 'push-pull',
37
+ label: {
38
+ id: 'Settings.transferTokens.types.push-pull',
39
+ defaultMessage: 'Full Access',
40
+ },
41
+ },
42
+ ];
43
+
19
44
  return (
20
45
  <Box
21
46
  background="neutral0"
@@ -59,6 +84,22 @@ const FormTransferTokenContainer = ({
59
84
  token={transferToken}
60
85
  />
61
86
  </GridItem>
87
+ <GridItem key="permissions" col={6} xs={12}>
88
+ <TokenTypeSelect
89
+ name="permissions"
90
+ values={values}
91
+ errors={errors}
92
+ label={{
93
+ id: 'Settings.tokens.form.type',
94
+ defaultMessage: 'Token type',
95
+ }}
96
+ onChange={(value) => {
97
+ onChange({ target: { name: 'permissions', value } });
98
+ }}
99
+ options={typeOptions}
100
+ canEditInputs={canEditInputs}
101
+ />
102
+ </GridItem>
62
103
  </Grid>
63
104
  </Flex>
64
105
  </Box>