@strapi/admin 4.9.0-exp.90df253ba90fd6879eb56a720a1f80d04ff745b8 → 4.10.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/admin/src/content-manager/components/DynamicTable/CellContent/PublicationState/PublicationState.js +26 -0
  2. package/admin/src/content-manager/components/DynamicTable/CellContent/PublicationState/index.js +1 -0
  3. package/admin/src/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/ReviewWorkflowsStage.js +15 -0
  4. package/admin/src/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/index.js +1 -0
  5. package/admin/src/content-manager/components/DynamicTable/index.js +43 -49
  6. package/admin/src/content-manager/components/DynamicZone/components/DynamicComponent.js +2 -0
  7. package/admin/src/content-manager/components/DynamicZone/utils/select.js +1 -1
  8. package/admin/src/content-manager/components/FieldComponent/utils/select.js +2 -1
  9. package/admin/src/content-manager/components/Inputs/utils/getInputType.js +1 -1
  10. package/admin/src/content-manager/components/Inputs/utils/select.js +1 -1
  11. package/admin/src/content-manager/hooks/useContentTypeLayout/index.js +1 -2
  12. package/admin/src/content-manager/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +4 -1
  13. package/admin/src/content-manager/pages/CollectionTypeRecursivePath/index.js +1 -2
  14. package/admin/src/content-manager/pages/EditSettingsView/init.js +3 -1
  15. package/admin/src/content-manager/pages/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +2 -4
  16. package/admin/src/content-manager/pages/EditView/DeleteLink/utils/select.js +1 -1
  17. package/admin/src/content-manager/pages/EditView/Information/index.js +77 -53
  18. package/admin/src/content-manager/pages/EditView/InformationBox/InformationBoxCE.js +13 -0
  19. package/admin/src/content-manager/pages/EditView/InformationBox/index.js +3 -0
  20. package/admin/src/content-manager/pages/EditView/index.js +3 -4
  21. package/admin/src/content-manager/pages/EditView/utils/createAttributesLayout.js +2 -1
  22. package/admin/src/content-manager/pages/EditView/utils/getFieldsActionMatchingPermissions.js +2 -1
  23. package/admin/src/content-manager/pages/ListView/index.js +6 -9
  24. package/admin/src/content-manager/utils/checkIfAttributeIsDisplayable.js +1 -1
  25. package/admin/src/content-manager/utils/createDefaultForm.js +2 -2
  26. package/admin/src/content-manager/utils/formatLayoutToApi.js +2 -1
  27. package/admin/src/content-manager/utils/getFieldName.js +1 -1
  28. package/admin/src/content-manager/utils/mergeMetasWithSchema.js +1 -1
  29. package/admin/src/content-manager/utils/paths.js +1 -1
  30. package/admin/src/content-manager/utils/removePasswordFieldsFromData.js +1 -1
  31. package/admin/src/hooks/useRegenerate/index.js +1 -1
  32. package/admin/src/hooks/useSettingsForm/index.js +3 -3
  33. package/admin/src/hooks/useSettingsForm/reducer.js +3 -1
  34. package/admin/src/hooks/useSettingsMenu/reducer.js +1 -1
  35. package/admin/src/index.js +1 -0
  36. package/admin/src/pages/AuthPage/reducer.js +1 -1
  37. package/admin/src/pages/SettingsPage/components/Tokens/TokenTypeSelect/index.js +5 -7
  38. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/CollapsableContentType/index.js +1 -1
  39. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/reducer.js +1 -1
  40. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/transformPermissionsData.js +6 -8
  41. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ConditionsModal/utils/createDefaultConditionsForm.js +1 -1
  42. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ContentTypeCollapse/Collapse/utils/generateCheckboxesActions.js +2 -1
  43. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/utils/getRowLabelCheckboxeState.js +2 -1
  44. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/GlobalActions/utils/getRowLabelCheckboxesState.js +1 -1
  45. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/reducer.js +6 -1
  46. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/createDefaultCTFormFromLayout.js +5 -1
  47. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/createDefaultPluginsFormFromLayout.js +1 -2
  48. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/formatContentTypesPermissionToAPI.js +2 -2
  49. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/updateConditionsToFalse.js +4 -1
  50. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/updateValues.js +1 -1
  51. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/PluginsAndSettings/SubCategory/utils/formatActions.js +1 -1
  52. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/utils/createArrayOfValues.js +2 -1
  53. package/admin/src/pages/SettingsPage/pages/Roles/ListPage/index.js +1 -1
  54. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/components/FormTransferTokenContainer/index.js +0 -41
  55. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +4 -6
  56. package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/utils/schema.js +0 -1
  57. package/admin/src/pages/SettingsPage/pages/Users/ProtectedEditPage/index.js +2 -2
  58. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/utils/formatData.js +1 -7
  59. package/admin/src/permissions/index.js +1 -1
  60. package/admin/src/translations/en.json +6 -0
  61. package/admin/src/utils/getAttributesToDisplay.js +2 -4
  62. package/admin/src/utils/getExistingActions.js +1 -3
  63. package/admin/src/utils/sortLinks.js +1 -1
  64. package/build/{8580.b0dcf37c.chunk.js → 2263.4c5916f9.chunk.js} +61 -61
  65. package/build/4649.213b8a3b.chunk.js +30 -0
  66. package/build/6985.66cca29c.chunk.js +1 -0
  67. package/build/7259.aefb51e8.chunk.js +1 -0
  68. package/build/{7112.2bf13da3.chunk.js → 9505.dbe702ab.chunk.js} +6 -6
  69. package/build/{Admin-authenticatedApp.5aa08bf5.chunk.js → Admin-authenticatedApp.f50ad423.chunk.js} +3 -3
  70. package/build/{Admin_marketplace.0f6c8ee2.chunk.js → Admin_marketplace.02608d56.chunk.js} +1 -1
  71. package/build/{Admin_profilePage.d2a8f9ab.chunk.js → Admin_profilePage.76afeca0.chunk.js} +1 -1
  72. package/build/Admin_settingsPage.147755cd.chunk.js +9 -0
  73. package/build/admin-app.55dd7921.chunk.js +112 -0
  74. package/build/admin-edit-roles-page.cf543488.chunk.js +216 -0
  75. package/build/admin-edit-users.31c20712.chunk.js +10 -0
  76. package/build/admin-roles-list.489c501f.chunk.js +2 -0
  77. package/build/{admin-users.af8c3123.chunk.js → admin-users.3e111a7d.chunk.js} +1 -1
  78. package/build/{api-tokens-create-page.2a6e22bd.chunk.js → api-tokens-create-page.4328b852.chunk.js} +1 -1
  79. package/build/{api-tokens-edit-page.fa38cd63.chunk.js → api-tokens-edit-page.bce5050f.chunk.js} +1 -1
  80. package/build/content-manager.4480ae88.chunk.js +1137 -0
  81. package/build/content-type-builder-translation-en-json.7961593e.chunk.js +1 -0
  82. package/build/content-type-builder.af9abf1e.chunk.js +126 -0
  83. package/build/en-json.697b4bcf.chunk.js +1 -0
  84. package/build/index.html +1 -1
  85. package/build/main.af8c0f31.js +3790 -0
  86. package/build/review-workflows-settings.7a7dc773.chunk.js +57 -0
  87. package/build/runtime~main.5a95bee6.js +2 -0
  88. package/build/sso-settings-page.272b87c8.chunk.js +1 -0
  89. package/build/{upload-settings.0200561d.chunk.js → upload-settings.0875e973.chunk.js} +1 -1
  90. package/build/upload-translation-fr-json.baab9911.chunk.js +1 -0
  91. package/build/users-advanced-settings-page.1d3c14c7.chunk.js +1 -0
  92. package/build/{users-email-settings-page.a3c80419.chunk.js → users-email-settings-page.e8db68c4.chunk.js} +1 -1
  93. package/build/users-providers-settings-page.14cac425.chunk.js +1 -0
  94. package/build/users-roles-settings-page.2ea4de84.chunk.js +30 -0
  95. package/build/{webhook-edit-page.a2a2b7bb.chunk.js → webhook-edit-page.329141a5.chunk.js} +3 -3
  96. package/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +92 -0
  97. package/ee/admin/content-manager/pages/EditView/InformationBox/index.js +3 -0
  98. package/ee/admin/hooks/useSettingsMenu/utils/customAdminLinks.js +12 -12
  99. package/ee/admin/hooks/useSettingsMenu/utils/customGlobalLinks.js +21 -13
  100. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/ReviewWorkflows.js +195 -0
  101. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/actions/index.js +42 -0
  102. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/AddStage/AddStage.js +87 -0
  103. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/AddStage/index.js +1 -0
  104. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stage/Stage.js +90 -0
  105. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stage/index.js +1 -0
  106. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stages.js +92 -0
  107. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/index.js +1 -0
  108. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/constants.js +6 -0
  109. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/hooks/useReviewWorkflows.js +35 -0
  110. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/index.js +3 -0
  111. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/reducer/index.js +121 -0
  112. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/utils/getWorkflowValidationSchema.js +25 -0
  113. package/ee/admin/pages/SettingsPage/utils/customRoutes.js +16 -2
  114. package/ee/admin/permissions/customPermissions.js +3 -0
  115. package/ee/server/bootstrap.js +16 -0
  116. package/ee/server/config/admin-actions.js +10 -0
  117. package/ee/server/constants/default-stages.json +14 -0
  118. package/ee/server/constants/default-workflow.json +1 -0
  119. package/ee/server/constants/workflows.js +8 -0
  120. package/ee/server/content-types/index.js +9 -0
  121. package/ee/server/content-types/workflow/index.js +34 -0
  122. package/ee/server/content-types/workflow-stage/index.js +41 -0
  123. package/ee/server/controllers/index.js +2 -0
  124. package/ee/server/controllers/workflows/index.js +36 -0
  125. package/ee/server/controllers/workflows/stages/index.js +95 -0
  126. package/ee/server/index.js +1 -0
  127. package/ee/server/middlewares/review-workflows.js +40 -0
  128. package/ee/server/migrations/review-workflows.js +39 -0
  129. package/ee/server/register.js +7 -0
  130. package/ee/server/routes/index.js +104 -0
  131. package/ee/server/services/index.js +4 -0
  132. package/ee/server/services/review-workflows/entity-service-decorator.js +42 -0
  133. package/ee/server/services/review-workflows/review-workflows.js +175 -0
  134. package/ee/server/services/review-workflows/stages.js +148 -0
  135. package/ee/server/services/review-workflows/workflows.js +25 -0
  136. package/ee/server/utils/index.js +8 -0
  137. package/ee/server/utils/persisted-tables.js +49 -0
  138. package/ee/server/utils/review-workflows.js +25 -0
  139. package/ee/server/utils/test.js +11 -0
  140. package/ee/server/validation/review-workflows.js +24 -0
  141. package/package.json +13 -13
  142. package/server/controllers/transfer/runner.js +2 -4
  143. package/server/routes/transfer.js +4 -13
  144. package/server/services/constants.js +0 -4
  145. package/server/services/permission/permissions-manager/sanitize.js +2 -0
  146. package/server/services/transfer/permission.js +1 -1
  147. package/server/services/transfer/token.js +31 -33
  148. package/server/validation/transfer/token.js +2 -10
  149. package/build/2637.679b590b.chunk.js +0 -1
  150. package/build/5563.451e91ee.chunk.js +0 -30
  151. package/build/7259.7744297b.chunk.js +0 -1
  152. package/build/Admin_settingsPage.489ec4eb.chunk.js +0 -9
  153. package/build/admin-app.4b313104.chunk.js +0 -112
  154. package/build/admin-edit-roles-page.3b196317.chunk.js +0 -216
  155. package/build/admin-edit-users.af3b0f15.chunk.js +0 -10
  156. package/build/admin-roles-list.0ad504a7.chunk.js +0 -2
  157. package/build/content-manager.f530e141.chunk.js +0 -1139
  158. package/build/content-type-builder-translation-en-json.e577d595.chunk.js +0 -1
  159. package/build/content-type-builder.6ecd201d.chunk.js +0 -126
  160. package/build/en-json.01a88a30.chunk.js +0 -1
  161. package/build/main.43b93ff3.js +0 -3843
  162. package/build/runtime~main.a40b1b57.js +0 -2
  163. package/build/sso-settings-page.5a8588ef.chunk.js +0 -1
  164. package/build/upload-translation-fr-json.84429734.chunk.js +0 -1
  165. package/build/users-advanced-settings-page.c0cae03a.chunk.js +0 -1
  166. package/build/users-providers-settings-page.5f86e45c.chunk.js +0 -1
  167. package/build/users-roles-settings-page.b02986df.chunk.js +0 -30
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useIntl } from 'react-intl';
4
+ import { Status, Typography } from '@strapi/design-system';
5
+
6
+ import { getTrad } from '../../../../utils';
7
+
8
+ export function PublicationState({ isPublished }) {
9
+ const { formatMessage } = useIntl();
10
+ const variant = isPublished ? 'success' : 'secondary';
11
+
12
+ return (
13
+ <Status showBullet={false} variant={variant} size="S" width="min-content">
14
+ <Typography fontWeight="bold" textColor={`${variant}700`}>
15
+ {formatMessage({
16
+ id: getTrad(`containers.List.${isPublished ? 'published' : 'draft'}`),
17
+ defaultMessage: isPublished ? 'Published' : 'Draft',
18
+ })}
19
+ </Typography>
20
+ </Status>
21
+ );
22
+ }
23
+
24
+ PublicationState.propTypes = {
25
+ isPublished: PropTypes.bool.isRequired,
26
+ };
@@ -0,0 +1 @@
1
+ export * from './PublicationState';
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Typography } from '@strapi/design-system';
4
+
5
+ export function ReviewWorkflowsStage({ name }) {
6
+ return (
7
+ <Typography fontWeight="regular" textColor="neutral700">
8
+ {name}
9
+ </Typography>
10
+ );
11
+ }
12
+
13
+ ReviewWorkflowsStage.propTypes = {
14
+ name: PropTypes.string.isRequired,
15
+ };
@@ -0,0 +1 @@
1
+ export * from './ReviewWorkflowsStage';
@@ -3,9 +3,6 @@ import PropTypes from 'prop-types';
3
3
  import { useIntl } from 'react-intl';
4
4
  import { DynamicTable as Table, useStrapiApp } from '@strapi/helper-plugin';
5
5
  import { useSelector } from 'react-redux';
6
- import styled from 'styled-components';
7
-
8
- import { Status, Typography } from '@strapi/design-system';
9
6
 
10
7
  import { INJECT_COLUMN_IN_TABLE } from '../../../exposedHooks';
11
8
  import { selectDisplayedHeaders } from '../../pages/ListView/selectors';
@@ -13,10 +10,8 @@ import { getTrad } from '../../utils';
13
10
  import TableRows from './TableRows';
14
11
  import ConfirmDialogDeleteAll from './ConfirmDialogDeleteAll';
15
12
  import ConfirmDialogDelete from './ConfirmDialogDelete';
16
-
17
- const StyledStatus = styled(Status)`
18
- width: min-content;
19
- `;
13
+ import { PublicationState } from './CellContent/PublicationState/PublicationState';
14
+ import { ReviewWorkflowsStage } from './CellContent/ReviewWorkflowsStage';
20
15
 
21
16
  const DynamicTable = ({
22
17
  canCreate,
@@ -31,7 +26,8 @@ const DynamicTable = ({
31
26
  rows,
32
27
  }) => {
33
28
  const { runHookWaterfall } = useStrapiApp();
34
- const hasDraftAndPublish = layout.contentType.options.draftAndPublish || false;
29
+ const hasDraftAndPublish = layout.contentType.options?.draftAndPublish ?? false;
30
+ const hasReviewWorkflows = layout.contentType.options?.reviewWorkflows ?? false;
35
31
  const { formatMessage } = useIntl();
36
32
  const displayedHeaders = useSelector(selectDisplayedHeaders);
37
33
 
@@ -42,43 +38,23 @@ const DynamicTable = ({
42
38
  });
43
39
 
44
40
  const formattedHeaders = headers.displayedHeaders.map((header) => {
45
- const { metadatas } = header;
46
-
47
- if (header.fieldSchema.type === 'relation') {
48
- const sortFieldValue = `${header.name}.${header.metadatas.mainField.name}`;
49
-
50
- return {
51
- ...header,
52
- metadatas: {
53
- ...metadatas,
54
- label: formatMessage({
55
- id: getTrad(`containers.ListPage.table-headers.${header.name}`),
56
- defaultMessage: metadatas.label,
57
- }),
58
- },
59
- name: sortFieldValue,
60
- };
61
- }
41
+ const { fieldSchema, metadatas, name } = header;
62
42
 
63
43
  return {
64
44
  ...header,
65
45
  metadatas: {
66
46
  ...metadatas,
67
47
  label: formatMessage({
68
- id: getTrad(`containers.ListPage.table-headers.${header.name}`),
48
+ id: getTrad(`containers.ListPage.table-headers.${name}`),
69
49
  defaultMessage: metadatas.label,
70
50
  }),
71
51
  },
52
+ name: fieldSchema.type === 'relation' ? `${name}.${metadatas.mainField.name}` : name,
72
53
  };
73
54
  });
74
55
 
75
- if (!hasDraftAndPublish) {
76
- return formattedHeaders;
77
- }
78
-
79
- return [
80
- ...formattedHeaders,
81
- {
56
+ if (hasDraftAndPublish) {
57
+ formattedHeaders.push({
82
58
  key: '__published_at_temp_key__',
83
59
  name: 'publishedAt',
84
60
  fieldSchema: {
@@ -92,24 +68,42 @@ const DynamicTable = ({
92
68
  searchable: false,
93
69
  sortable: true,
94
70
  },
95
- cellFormatter(cellData) {
96
- const isPublished = cellData.publishedAt;
97
- const variant = isPublished ? 'success' : 'secondary';
71
+ cellFormatter({ publishedAt }) {
72
+ return <PublicationState isPublished={!!publishedAt} />;
73
+ },
74
+ });
75
+ }
98
76
 
99
- return (
100
- <StyledStatus showBullet={false} variant={variant} size="S">
101
- <Typography fontWeight="bold" textColor={`${variant}700`}>
102
- {formatMessage({
103
- id: getTrad(`containers.List.${isPublished ? 'published' : 'draft'}`),
104
- defaultMessage: isPublished ? 'Published' : 'Draft',
105
- })}
106
- </Typography>
107
- </StyledStatus>
108
- );
77
+ if (hasReviewWorkflows) {
78
+ formattedHeaders.push({
79
+ key: '__strapi_reviewWorkflows_stage_temp_key__',
80
+ name: 'strapi_reviewWorkflows_stage',
81
+ fieldSchema: {
82
+ type: 'custom',
109
83
  },
110
- },
111
- ];
112
- }, [runHookWaterfall, displayedHeaders, layout, hasDraftAndPublish, formatMessage]);
84
+ metadatas: {
85
+ label: formatMessage({
86
+ id: getTrad(`containers.ListPage.table-headers.reviewWorkflows.stage`),
87
+ defaultMessage: 'Review stage',
88
+ }),
89
+ searchable: false,
90
+ sortable: false,
91
+ },
92
+ cellFormatter({ strapi_reviewWorkflows_stage }) {
93
+ return <ReviewWorkflowsStage name={strapi_reviewWorkflows_stage.name} />;
94
+ },
95
+ });
96
+ }
97
+
98
+ return formattedHeaders;
99
+ }, [
100
+ runHookWaterfall,
101
+ displayedHeaders,
102
+ layout,
103
+ hasDraftAndPublish,
104
+ hasReviewWorkflows,
105
+ formatMessage,
106
+ ]);
113
107
 
114
108
  return (
115
109
  <Table
@@ -41,6 +41,8 @@ const IconButtonCustom = styled(IconButton)`
41
41
  }
42
42
  `;
43
43
 
44
+ // TODO: Delete once https://github.com/strapi/design-system/pull/858
45
+ // is merged and released.
44
46
  const StyledBox = styled(Box)`
45
47
  > div:first-child {
46
48
  box-shadow: ${({ theme }) => theme.shadows.tableShadow};
@@ -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,5 +1,5 @@
1
1
  import React, { useRef } from 'react';
2
- import propTypes from 'prop-types';
2
+ import PropTypes from 'prop-types';
3
3
  import { useIntl } from 'react-intl';
4
4
  import { useCMEditViewDataManager } from '@strapi/helper-plugin';
5
5
  import { Box, Divider, Flex, Typography } from '@strapi/design-system';
@@ -8,23 +8,44 @@ import { getTrad } from '../../../utils';
8
8
  import getUnits from './utils/getUnits';
9
9
  import { getFullName } from '../../../../utils';
10
10
 
11
+ const Title = () => {
12
+ const { formatMessage } = useIntl();
13
+
14
+ return (
15
+ <Flex direction="column" alignItems="stretch" gap={2}>
16
+ <Typography variant="sigma" textColor="neutral600" id="additional-information">
17
+ {formatMessage({
18
+ id: getTrad('containers.Edit.information'),
19
+ defaultMessage: 'Information',
20
+ })}
21
+ </Typography>
22
+
23
+ <Box>
24
+ <Divider />
25
+ </Box>
26
+ </Flex>
27
+ );
28
+ };
29
+
11
30
  const KeyValuePair = ({ label, value }) => {
12
31
  return (
13
32
  <Flex justifyContent="space-between">
14
- <Typography as="dt" fontWeight="bold" textColor="neutral600">
33
+ <Typography as="dt" fontWeight="bold" textColor="neutral800" variant="pi">
15
34
  {label}
16
35
  </Typography>
17
- <Typography as="dd">{value}</Typography>
36
+ <Typography as="dd" variant="pi" textColor="neutral600">
37
+ {value}
38
+ </Typography>
18
39
  </Flex>
19
40
  );
20
41
  };
21
42
 
22
43
  KeyValuePair.propTypes = {
23
- label: propTypes.string.isRequired,
24
- value: propTypes.string.isRequired,
44
+ label: PropTypes.string.isRequired,
45
+ value: PropTypes.string.isRequired,
25
46
  };
26
47
 
27
- const Information = () => {
48
+ const Body = () => {
28
49
  const { formatMessage, formatRelativeTime } = useIntl();
29
50
  const { initialData, isCreatingEntry } = useCMEditViewDataManager();
30
51
  const currentTime = useRef(Date.now());
@@ -49,57 +70,60 @@ const Information = () => {
49
70
  const created = getFieldInfo('createdAt', 'createdBy');
50
71
 
51
72
  return (
52
- <Flex direction="column" alignItems="stretch" gap={2}>
53
- <Typography variant="sigma" textColor="neutral600" id="additional-information">
54
- {formatMessage({
55
- id: getTrad('containers.Edit.information'),
56
- defaultMessage: 'Information',
57
- })}
58
- </Typography>
73
+ <Flex direction="column" alignItems="stretch" gap={4}>
74
+ <Flex direction="column" alignItems="stretch" gap={2} as="dl">
75
+ <KeyValuePair
76
+ label={formatMessage({
77
+ id: getTrad('containers.Edit.information.created'),
78
+ defaultMessage: 'Created',
79
+ })}
80
+ value={created.at}
81
+ />
59
82
 
60
- <Box paddingBottom={4}>
61
- <Divider />
62
- </Box>
83
+ <KeyValuePair
84
+ label={formatMessage({
85
+ id: getTrad('containers.Edit.information.by'),
86
+ defaultMessage: 'By',
87
+ })}
88
+ value={created.by}
89
+ />
90
+ </Flex>
63
91
 
64
- <Flex direction="column" alignItems="stretch" gap={4}>
65
- <Flex direction="column" alignItems="stretch" gap={2} as="dl">
66
- <KeyValuePair
67
- label={formatMessage({
68
- id: getTrad('containers.Edit.information.created'),
69
- defaultMessage: 'Created',
70
- })}
71
- value={created.at}
72
- />
73
-
74
- <KeyValuePair
75
- label={formatMessage({
76
- id: getTrad('containers.Edit.information.by'),
77
- defaultMessage: 'By',
78
- })}
79
- value={created.by}
80
- />
81
- </Flex>
82
-
83
- <Flex direction="column" alignItems="stretch" gap={2} as="dl">
84
- <KeyValuePair
85
- label={formatMessage({
86
- id: getTrad('containers.Edit.information.lastUpdate'),
87
- defaultMessage: 'Last update',
88
- })}
89
- value={updated.at}
90
- />
91
-
92
- <KeyValuePair
93
- label={formatMessage({
94
- id: getTrad('containers.Edit.information.by'),
95
- defaultMessage: 'By',
96
- })}
97
- value={updated.by}
98
- />
99
- </Flex>
92
+ <Flex direction="column" alignItems="stretch" gap={2} as="dl">
93
+ <KeyValuePair
94
+ label={formatMessage({
95
+ id: getTrad('containers.Edit.information.lastUpdate'),
96
+ defaultMessage: 'Last update',
97
+ })}
98
+ value={updated.at}
99
+ />
100
+
101
+ <KeyValuePair
102
+ label={formatMessage({
103
+ id: getTrad('containers.Edit.information.by'),
104
+ defaultMessage: 'By',
105
+ })}
106
+ value={updated.by}
107
+ />
100
108
  </Flex>
101
109
  </Flex>
102
110
  );
103
111
  };
104
112
 
105
- export default Information;
113
+ const Root = ({ children }) => {
114
+ return (
115
+ <Flex direction="column" alignItems="stretch" gap={4}>
116
+ {children}
117
+ </Flex>
118
+ );
119
+ };
120
+
121
+ Root.propTypes = {
122
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
123
+ };
124
+
125
+ export default {
126
+ Root,
127
+ Title,
128
+ Body,
129
+ };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+
3
+ import Information from '../Information';
4
+
5
+ // This component is overwritten by the EE counterpart
6
+ export function InformationBoxCE() {
7
+ return (
8
+ <Information.Root>
9
+ <Information.Title />
10
+ <Information.Body />
11
+ </Information.Root>
12
+ );
13
+ }
@@ -0,0 +1,3 @@
1
+ import { InformationBoxCE } from './InformationBoxCE';
2
+
3
+ export default InformationBoxCE;
@@ -8,19 +8,18 @@ import {
8
8
  LoadingIndicatorPage,
9
9
  } from '@strapi/helper-plugin';
10
10
  import { useIntl } from 'react-intl';
11
- import { ContentLayout, Box, Grid, GridItem, Main, Flex } from '@strapi/design-system';
11
+ import { ContentLayout, Box, Flex, Grid, GridItem, Main } from '@strapi/design-system';
12
12
  import { Pencil, Layer } from '@strapi/icons';
13
+ import InformationBox from 'ee_else_ce/content-manager/pages/EditView/InformationBox';
13
14
  import { InjectionZone } from '../../../shared/components';
14
15
  import permissions from '../../../permissions';
15
16
  import DynamicZone from '../../components/DynamicZone';
16
-
17
17
  import CollectionTypeFormWrapper from '../../components/CollectionTypeFormWrapper';
18
18
  import EditViewDataManagerProvider from '../../components/EditViewDataManagerProvider';
19
19
  import SingleTypeFormWrapper from '../../components/SingleTypeFormWrapper';
20
20
  import { getTrad } from '../../utils';
21
21
  import useLazyComponents from '../../hooks/useLazyComponents';
22
22
  import DraftAndPublishBadge from './DraftAndPublishBadge';
23
- import Information from './Information';
24
23
  import Header from './Header';
25
24
  import { getFieldsActionMatchingPermissions } from './utils';
26
25
  import DeleteLink from './DeleteLink';
@@ -180,7 +179,7 @@ const EditView = ({ allowedActions, isSingleType, goBack, slug, id, origin, user
180
179
  paddingTop={6}
181
180
  shadow="tableShadow"
182
181
  >
183
- <Information />
182
+ <InformationBox />
184
183
  <InjectionZone area="contentManager.editView.informations" />
185
184
  </Box>
186
185
  <Box as="aside" aria-labelledby="links">
@@ -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) => {
@@ -6,7 +6,6 @@ import isEqual from 'react-fast-compare';
6
6
  import { bindActionCreators, compose } from 'redux';
7
7
  import { useIntl } from 'react-intl';
8
8
  import { useHistory, useLocation, Link as ReactRouterLink } from 'react-router-dom';
9
- import get from 'lodash/get';
10
9
  import { stringify } from 'qs';
11
10
  import axios from 'axios';
12
11
 
@@ -74,12 +73,11 @@ function ListView({
74
73
  slug,
75
74
  }) {
76
75
  const { total } = pagination;
76
+ const { contentType } = layout;
77
77
  const {
78
- contentType: {
79
- metadatas,
80
- settings: { bulkable: isBulkable, filterable: isFilterable, searchable: isSearchable },
81
- },
82
- } = layout;
78
+ metadatas,
79
+ settings: { bulkable: isBulkable, filterable: isFilterable, searchable: isSearchable },
80
+ } = contentType;
83
81
 
84
82
  const toggleNotification = useNotification();
85
83
  const { trackUsage } = useTracking();
@@ -98,8 +96,7 @@ function ListView({
98
96
  const { pathname } = useLocation();
99
97
  const { push } = useHistory();
100
98
  const { formatMessage } = useIntl();
101
- const contentType = layout.contentType;
102
- const hasDraftAndPublish = get(contentType, 'options.draftAndPublish', false);
99
+ const hasDraftAndPublish = contentType.options?.draftAndPublish ?? false;
103
100
  const fetchClient = useFetchClient();
104
101
  const { post, del } = fetchClient;
105
102
 
@@ -137,7 +134,7 @@ function ListView({
137
134
  return;
138
135
  }
139
136
 
140
- const resStatus = get(err, 'response.status', null);
137
+ const resStatus = err?.response?.status ?? null;
141
138
 
142
139
  if (resStatus === 403) {
143
140
  await fetchPermissionsRef.current();
@@ -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) => {