@strapi/admin 4.11.4 → 4.11.6

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 (178) hide show
  1. package/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js +8 -5
  2. package/admin/src/content-manager/components/Inputs/index.js +3 -47
  3. package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +34 -37
  4. package/admin/src/content-manager/pages/EditSettingsView/components/DisplayedFields.js +23 -21
  5. package/admin/src/content-manager/pages/EditSettingsView/components/ModalForm.js +21 -50
  6. package/admin/src/content-manager/pages/EditView/Information/index.js +1 -1
  7. package/admin/src/content-manager/pages/EditView/InformationBox/InformationBoxCE.js +1 -2
  8. package/admin/src/content-manager/pages/EditView/InformationBox/index.js +1 -3
  9. package/admin/src/content-manager/pages/EditView/index.js +14 -2
  10. package/admin/src/content-manager/pages/ListSettingsView/components/SortDisplayedFields.js +24 -22
  11. package/admin/src/content-manager/pages/ListView/components/CellContent/RelationMultiple/index.js +61 -67
  12. package/admin/src/content-manager/pages/ListView/components/CellContent/RepeatableComponent/index.js +28 -21
  13. package/admin/src/content-manager/pages/ListView/components/TableRows/index.js +97 -14
  14. package/admin/src/content-manager/pages/ListView/index.js +65 -59
  15. package/admin/src/content-manager/pages/ListView/utils/buildValidGetParams.js +30 -0
  16. package/admin/src/content-manager/pages/ListView/utils/index.js +1 -1
  17. package/admin/src/hooks/useAdminUsers/useAdminUsers.js +3 -3
  18. package/admin/src/hooks/useEnterprise/useEnterprise.js +4 -4
  19. package/admin/src/hooks/useSettingsMenu/index.js +35 -21
  20. package/admin/src/layouts/UnauthenticatedLayout/LocaleToggle/index.js +7 -7
  21. package/admin/src/pages/App/index.js +0 -3
  22. package/admin/src/pages/AuthPage/components/Login/index.js +3 -5
  23. package/admin/src/pages/AuthPage/components/Register/index.js +5 -1
  24. package/admin/src/pages/AuthPage/constants.js +3 -2
  25. package/admin/src/pages/AuthPage/index.js +18 -1
  26. package/admin/src/pages/HomePage/index.js +19 -7
  27. package/admin/src/pages/ProfilePage/index.js +12 -12
  28. package/admin/src/pages/SettingsPage/components/SettingsNav/index.js +13 -11
  29. package/admin/src/pages/SettingsPage/components/Tokens/TokenBox/index.js +1 -1
  30. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/index.js +17 -1
  31. package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +16 -3
  32. package/admin/src/pages/SettingsPage/pages/Users/ListPage/CreateAction/index.js +2 -4
  33. package/admin/src/pages/SettingsPage/pages/Users/ListPage/ModalForm/index.js +15 -1
  34. package/admin/src/pages/SettingsPage/pages/Users/ListPage/index.js +36 -5
  35. package/admin/src/pages/SettingsPage/pages/Users/components/MagicLink/index.js +3 -5
  36. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventTable/index.js +1 -3
  37. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/WebhookForm/index.js +16 -1
  38. package/admin/src/translations/zh-Hans.json +1 -1
  39. package/build/1049.758a01f5.chunk.js +1 -0
  40. package/build/{3528.4845cf92.chunk.js → 1386.762d6eb8.chunk.js} +1 -1
  41. package/build/1727.b49f0713.chunk.js +1 -0
  42. package/build/{5563.86f9aa9c.chunk.js → 2225.15d1df72.chunk.js} +3 -3
  43. package/build/2379.3ba39b61.chunk.js +1 -0
  44. package/build/2395.c27eb585.chunk.js +26 -0
  45. package/build/2801.93343c11.chunk.js +1 -0
  46. package/build/{7394.423886bd.chunk.js → 3100.21c343fa.chunk.js} +1 -1
  47. package/build/311.cb0884bb.chunk.js +1 -0
  48. package/build/3483.642d2321.chunk.js +1 -0
  49. package/build/{970.89601f27.chunk.js → 3739.63e352f1.chunk.js} +52 -20
  50. package/build/3984.298bdb66.chunk.js +1 -0
  51. package/build/4546.5aac90fe.chunk.js +1 -0
  52. package/build/502.f6b78f85.chunk.js +1 -0
  53. package/build/{5542.c62d0daf.chunk.js → 5542.2415a393.chunk.js} +6 -6
  54. package/build/6158.f9d82db9.chunk.js +1 -0
  55. package/build/7030.b98dcedf.chunk.js +1 -0
  56. package/build/7464.fe31804b.chunk.js +1 -0
  57. package/build/8276.d03dc679.chunk.js +26 -0
  58. package/build/918.54414509.chunk.js +1 -0
  59. package/build/978.bab58f0a.chunk.js +1 -0
  60. package/build/{9932.7e2b71de.chunk.js → 9932.b5a3bb3a.chunk.js} +81 -81
  61. package/build/9944.7af075a5.chunk.js +26 -0
  62. package/build/{Admin-authenticatedApp.cb649fc1.chunk.js → Admin-authenticatedApp.b3060bbe.chunk.js} +5 -5
  63. package/build/Admin_InternalErrorPage.f45f2462.chunk.js +1 -0
  64. package/build/{Admin_homePage.be30ef4e.chunk.js → Admin_homePage.ac9dfb86.chunk.js} +23 -15
  65. package/build/{Admin_marketplace.74a58e20.chunk.js → Admin_marketplace.f0b87fce.chunk.js} +1 -1
  66. package/build/{Admin_pluginsPage.ce464189.chunk.js → Admin_pluginsPage.8728ff6e.chunk.js} +1 -1
  67. package/build/{Admin_profilePage.2131eb68.chunk.js → Admin_profilePage.a968035f.chunk.js} +2 -2
  68. package/build/Admin_settingsPage.8c600d1a.chunk.js +111 -0
  69. package/build/Upload_ConfigureTheView.345ac1e0.chunk.js +1 -0
  70. package/build/admin-app.1c3f7fd6.chunk.js +36 -0
  71. package/build/{admin-edit-roles-page.3fdd6b9d.chunk.js → admin-edit-roles-page.a49b9f4f.chunk.js} +4 -4
  72. package/build/admin-edit-users.67704088.chunk.js +10 -0
  73. package/build/{admin-roles-list.e17b00d7.chunk.js → admin-roles-list.0c129e98.chunk.js} +1 -1
  74. package/build/admin-users.3279ffb0.chunk.js +11 -0
  75. package/build/api-tokens-create-page.46c2ea84.chunk.js +1 -0
  76. package/build/{api-tokens-edit-page.9a1dd2fa.chunk.js → api-tokens-edit-page.58139df9.chunk.js} +1 -1
  77. package/build/{api-tokens-list-page.a103f526.chunk.js → api-tokens-list-page.505bf7e0.chunk.js} +2 -2
  78. package/build/audit-logs-settings-page.4b422831.chunk.js +1 -0
  79. package/build/content-manager.9f7f0cb8.chunk.js +1101 -0
  80. package/build/{content-type-builder-list-view.a200a358.chunk.js → content-type-builder-list-view.bf9be456.chunk.js} +9 -9
  81. package/build/{content-type-builder-translation-ar-json.56d8fcf4.chunk.js → content-type-builder-translation-ar-json.3e808e2f.chunk.js} +1 -1
  82. package/build/{content-type-builder-translation-cs-json.a5b299ca.chunk.js → content-type-builder-translation-cs-json.1ef9e106.chunk.js} +1 -1
  83. package/build/{content-type-builder-translation-de-json.393a76c0.chunk.js → content-type-builder-translation-de-json.63fcff7b.chunk.js} +1 -1
  84. package/build/{content-type-builder-translation-dk-json.fbd39bb7.chunk.js → content-type-builder-translation-dk-json.fd626b67.chunk.js} +1 -1
  85. package/build/{content-type-builder-translation-en-json.f592325b.chunk.js → content-type-builder-translation-en-json.9f2b9c49.chunk.js} +1 -1
  86. package/build/{content-type-builder-translation-es-json.9288474b.chunk.js → content-type-builder-translation-es-json.a4a361a9.chunk.js} +1 -1
  87. package/build/{content-type-builder-translation-fr-json.d35e269c.chunk.js → content-type-builder-translation-fr-json.499c3a46.chunk.js} +1 -1
  88. package/build/{content-type-builder-translation-id-json.f0513929.chunk.js → content-type-builder-translation-id-json.65255f93.chunk.js} +1 -1
  89. package/build/{content-type-builder-translation-it-json.aaf16753.chunk.js → content-type-builder-translation-it-json.e268ab74.chunk.js} +1 -1
  90. package/build/{content-type-builder-translation-ko-json.8fe21a7f.chunk.js → content-type-builder-translation-ko-json.04cb309d.chunk.js} +1 -1
  91. package/build/{content-type-builder-translation-ms-json.3b5d2d3e.chunk.js → content-type-builder-translation-ms-json.f6b743b9.chunk.js} +1 -1
  92. package/build/{content-type-builder-translation-nl-json.225ef5d3.chunk.js → content-type-builder-translation-nl-json.997fe8cc.chunk.js} +1 -1
  93. package/build/{content-type-builder-translation-pl-json.92f36be2.chunk.js → content-type-builder-translation-pl-json.634f638b.chunk.js} +1 -1
  94. package/build/{content-type-builder-translation-pt-BR-json.3bd10f89.chunk.js → content-type-builder-translation-pt-BR-json.6a95dc71.chunk.js} +1 -1
  95. package/build/{content-type-builder-translation-ru-json.9bfe47ce.chunk.js → content-type-builder-translation-ru-json.3af65503.chunk.js} +1 -1
  96. package/build/{content-type-builder-translation-sk-json.d03cc18a.chunk.js → content-type-builder-translation-sk-json.c6078082.chunk.js} +1 -1
  97. package/build/{content-type-builder-translation-sv-json.d23dcd32.chunk.js → content-type-builder-translation-sv-json.a6df2462.chunk.js} +1 -1
  98. package/build/{content-type-builder-translation-th-json.7ad256e2.chunk.js → content-type-builder-translation-th-json.122277cc.chunk.js} +1 -1
  99. package/build/{content-type-builder-translation-tr-json.926f6191.chunk.js → content-type-builder-translation-tr-json.41f44f77.chunk.js} +1 -1
  100. package/build/{content-type-builder-translation-uk-json.7bf19546.chunk.js → content-type-builder-translation-uk-json.e1315acd.chunk.js} +1 -1
  101. package/build/{content-type-builder-translation-zh-Hans-json.415577fb.chunk.js → content-type-builder-translation-zh-Hans-json.6ff57db6.chunk.js} +1 -1
  102. package/build/{content-type-builder-translation-zh-json.ad24dbeb.chunk.js → content-type-builder-translation-zh-json.3532b962.chunk.js} +1 -1
  103. package/build/content-type-builder.7a90cece.chunk.js +170 -0
  104. package/build/{email-settings-page.45695daa.chunk.js → email-settings-page.d494d1eb.chunk.js} +2 -2
  105. package/build/{i18n-settings-page.29308d0b.chunk.js → i18n-settings-page.47f78016.chunk.js} +1 -1
  106. package/build/index.html +1 -1
  107. package/build/main.22e2d4ec.js +2856 -0
  108. package/build/review-workflows-settings.f1104fb9.chunk.js +110 -0
  109. package/build/{runtime~main.efd966f6.js → runtime~main.437fdcbb.js} +2 -2
  110. package/build/sso-settings-page.ed6f3f15.chunk.js +1 -0
  111. package/build/transfer-tokens-create-page.1597e6ab.chunk.js +1 -0
  112. package/build/transfer-tokens-edit-page.8741529f.chunk.js +1 -0
  113. package/build/{transfer-tokens-list-page.7237443d.chunk.js → transfer-tokens-list-page.22147d2c.chunk.js} +2 -2
  114. package/build/upload-settings.cac210a0.chunk.js +14 -0
  115. package/build/upload.cbfeefa5.chunk.js +58 -0
  116. package/build/{users-advanced-settings-page.750b1f76.chunk.js → users-advanced-settings-page.18379a56.chunk.js} +1 -1
  117. package/build/users-email-settings-page.a87978e5.chunk.js +9 -0
  118. package/build/users-providers-settings-page.8876c1ee.chunk.js +14 -0
  119. package/build/{users-roles-settings-page.1f505119.chunk.js → users-roles-settings-page.0431f48c.chunk.js} +2 -2
  120. package/build/webhook-edit-page.a91f27a1.chunk.js +33 -0
  121. package/build/{webhook-list-page.940a40f1.chunk.js → webhook-list-page.65e1b5bb.chunk.js} +1 -1
  122. package/build/{zh-Hans-json.4cfef87d.chunk.js → zh-Hans-json.fada6f40.chunk.js} +1 -1
  123. package/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +1 -1
  124. package/ee/admin/content-manager/pages/EditView/InformationBox/index.js +1 -3
  125. package/ee/admin/content-manager/{components/DynamicTable/CellContent/ReviewWorkflowsStage → pages/ListView/ReviewWorkflowsColumn}/ReviewWorkflowsStageEE.js +7 -2
  126. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/constants.js +24 -0
  127. package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/index.js +1 -0
  128. package/ee/admin/hooks/useLicenseLimitNotification/index.js +17 -6
  129. package/ee/admin/hooks/useLicenseLimits/index.js +1 -32
  130. package/ee/admin/hooks/useLicenseLimits/useLicenseLimits.js +44 -0
  131. package/ee/admin/pages/AuthPage/components/Login/index.js +3 -5
  132. package/ee/admin/pages/HomePage/index.js +11 -0
  133. package/ee/admin/pages/SettingsPage/pages/ApplicationInfosPage/components/AdminSeatInfo/index.js +7 -7
  134. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/hooks/useAuditLogsData.js +6 -4
  135. package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/hooks/useReviewWorkflows.js +3 -5
  136. package/ee/admin/pages/SettingsPage/pages/Users/ListPage/CreateAction/index.js +11 -6
  137. package/ee/admin/pages/SettingsPage/pages/Users/ListPage/index.js +13 -0
  138. package/ee/admin/pages/SettingsPage/pages/Users/components/MagicLink/index.js +3 -5
  139. package/ee/admin/pages/SettingsPage/pages/Webhooks/EditView/components/EventTable/index.js +1 -3
  140. package/index.js +0 -14
  141. package/package.json +12 -21
  142. package/webpack.alias.js +0 -3
  143. package/webpack.config.js +1 -75
  144. package/admin/src/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/getTableColumn.js +0 -2
  145. package/admin/src/content-manager/pages/ListView/utils/buildQueryString.js +0 -36
  146. package/admin/src/content-manager/pages/ListView/utils/createPluginsFilter.js +0 -4
  147. package/admin/src/pages/App/utils/index.js +0 -3
  148. package/admin/src/pages/App/utils/unique-identifier.js +0 -12
  149. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/AdminSeatInfo/index.js +0 -5
  150. package/build/1386.3b2aa6a7.chunk.js +0 -3
  151. package/build/1799.44d2e264.chunk.js +0 -33
  152. package/build/1970.39a2d75e.chunk.js +0 -1
  153. package/build/3269.1ea0f5a6.chunk.js +0 -1
  154. package/build/5932.6a23b88c.chunk.js +0 -1
  155. package/build/7018.98feed67.chunk.js +0 -1
  156. package/build/7259.fb69d4bf.chunk.js +0 -1
  157. package/build/Admin_InternalErrorPage.8911cb49.chunk.js +0 -1
  158. package/build/Admin_settingsPage.4069bb8a.chunk.js +0 -79
  159. package/build/Upload_ConfigureTheView.7a1cb9c9.chunk.js +0 -1
  160. package/build/admin-app.fea867af.chunk.js +0 -61
  161. package/build/admin-edit-users.200551e3.chunk.js +0 -10
  162. package/build/admin-users.3b12dca2.chunk.js +0 -11
  163. package/build/api-tokens-create-page.3dd4e921.chunk.js +0 -1
  164. package/build/audit-logs-settings-page.f538490f.chunk.js +0 -1
  165. package/build/content-manager.c40f5ff9.chunk.js +0 -1088
  166. package/build/content-type-builder.bd1bbff1.chunk.js +0 -166
  167. package/build/main.ee36abd9.js +0 -2927
  168. package/build/review-workflows-settings.93808ae0.chunk.js +0 -110
  169. package/build/sso-settings-page.0cdb96a6.chunk.js +0 -1
  170. package/build/transfer-tokens-create-page.de14cad4.chunk.js +0 -1
  171. package/build/transfer-tokens-edit-page.4f5e39af.chunk.js +0 -1
  172. package/build/upload-settings.cb6c14c3.chunk.js +0 -14
  173. package/build/upload.7e629643.chunk.js +0 -26
  174. package/build/users-email-settings-page.e9bcd865.chunk.js +0 -9
  175. package/build/users-providers-settings-page.a94253e9.chunk.js +0 -14
  176. package/build/webhook-edit-page.77ef4f1a.chunk.js +0 -33
  177. package/ee/admin/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/getTableColumn.js +0 -58
  178. package/ee/admin/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/index.js +0 -3
@@ -1,16 +1,8 @@
1
- import React, { useMemo, useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
 
3
- import {
4
- Badge,
5
- Box,
6
- Flex,
7
- Loader,
8
- MenuItem,
9
- SimpleMenu,
10
- Typography,
11
- useNotifyAT,
12
- } from '@strapi/design-system';
13
- import { stopPropagation, useFetchClient } from '@strapi/helper-plugin';
3
+ import { Badge, Flex, Loader, Typography, useNotifyAT } from '@strapi/design-system';
4
+ import { Menu } from '@strapi/design-system/v2';
5
+ import { useFetchClient } from '@strapi/helper-plugin';
14
6
  import PropTypes from 'prop-types';
15
7
  import { useIntl } from 'react-intl';
16
8
  import { useQuery } from 'react-query';
@@ -19,54 +11,24 @@ import styled from 'styled-components';
19
11
  import { getRequestUrl, getTrad } from '../../../../../utils';
20
12
  import CellValue from '../CellValue';
21
13
 
22
- const TypographyMaxWidth = styled(Typography)`
23
- max-width: 500px;
24
- `;
25
-
26
- const fetchRelation = async (endPoint, notifyStatus, get) => {
27
- const {
28
- data: { results, pagination },
29
- } = await get(endPoint);
30
-
31
- notifyStatus();
32
-
33
- return { results, pagination };
34
- };
35
-
36
14
  const RelationMultiple = ({ fieldSchema, metadatas, name, entityId, value, contentType }) => {
37
15
  const { formatMessage } = useIntl();
38
16
  const { notifyStatus } = useNotifyAT();
39
- const relationFetchEndpoint = useMemo(
40
- () => getRequestUrl(`relations/${contentType.uid}/${entityId}/${name.split('.')[0]}`),
41
- [entityId, name, contentType]
42
- );
43
17
  const [isOpen, setIsOpen] = useState(false);
44
- const { get } = useFetchClient();
45
-
46
- const Label = (
47
- <Flex gap={1} wrap="nowrap">
48
- <Badge>{value.count}</Badge>
49
- {formatMessage(
50
- {
51
- id: 'content-manager.containers.ListPage.items',
52
- defaultMessage: '{number, plural, =0 {items} one {item} other {items}}',
53
- },
54
- { number: value.count }
55
- )}
56
- </Flex>
57
- );
58
18
 
59
- const notify = () => {
60
- const message = formatMessage({
61
- id: getTrad('DynamicTable.relation-loaded'),
62
- defaultMessage: 'Relations have been loaded',
63
- });
64
- notifyStatus(message);
65
- };
19
+ const { get } = useFetchClient();
66
20
 
67
21
  const { data, status } = useQuery(
68
22
  [fieldSchema.targetModel, entityId],
69
- () => fetchRelation(relationFetchEndpoint, notify, get),
23
+ async () => {
24
+ const {
25
+ data: { results, pagination },
26
+ } = await get(
27
+ getRequestUrl(`relations/${contentType.uid}/${entityId}/${name.split('.')[0]}`)
28
+ );
29
+
30
+ return { results, pagination };
31
+ },
70
32
  {
71
33
  enabled: isOpen,
72
34
  staleTime: 0,
@@ -77,40 +39,58 @@ const RelationMultiple = ({ fieldSchema, metadatas, name, entityId, value, conte
77
39
  }
78
40
  );
79
41
 
42
+ useEffect(() => {
43
+ if (data) {
44
+ notifyStatus(
45
+ formatMessage({
46
+ id: getTrad('DynamicTable.relation-loaded'),
47
+ defaultMessage: 'Relations have been loaded',
48
+ })
49
+ );
50
+ }
51
+ }, [data, formatMessage, notifyStatus]);
52
+
80
53
  return (
81
- <Box {...stopPropagation}>
82
- <SimpleMenu
83
- label={Label}
84
- size="S"
85
- onOpen={() => setIsOpen(true)}
86
- onClose={() => setIsOpen(false)}
87
- >
54
+ <Menu.Root onOpenChange={(isOpen) => setIsOpen(isOpen)}>
55
+ <MenuTrigger onClick={(e) => e.stopPropagation()}>
56
+ <Flex gap={1} wrap="nowrap">
57
+ <Badge>{value.count}</Badge>
58
+ {formatMessage(
59
+ {
60
+ id: 'content-manager.containers.ListPage.items',
61
+ defaultMessage: '{number, plural, =0 {items} one {item} other {items}}',
62
+ },
63
+ { number: value.count }
64
+ )}
65
+ </Flex>
66
+ </MenuTrigger>
67
+ <Menu.Content>
88
68
  {status !== 'success' && (
89
- <MenuItem aria-disabled>
69
+ <Menu.Item disabled>
90
70
  <Loader small>
91
71
  {formatMessage({
92
72
  id: getTrad('DynamicTable.relation-loading'),
93
73
  defaultMessage: 'Relations are loading',
94
74
  })}
95
75
  </Loader>
96
- </MenuItem>
76
+ </Menu.Item>
97
77
  )}
98
78
 
99
79
  {status === 'success' && (
100
80
  <>
101
81
  {data?.results.map((entry) => (
102
- <MenuItem key={entry.id} aria-disabled>
82
+ <Menu.Item key={entry.id} disabled>
103
83
  <TypographyMaxWidth ellipsis>
104
84
  <CellValue
105
85
  type={metadatas.mainField.schema.type}
106
86
  value={entry[metadatas.mainField.name] || entry.id}
107
87
  />
108
88
  </TypographyMaxWidth>
109
- </MenuItem>
89
+ </Menu.Item>
110
90
  ))}
111
91
 
112
92
  {data?.pagination.total > 10 && (
113
- <MenuItem
93
+ <Menu.Item
114
94
  aria-disabled
115
95
  aria-label={formatMessage({
116
96
  id: getTrad('DynamicTable.relation-more'),
@@ -118,12 +98,12 @@ const RelationMultiple = ({ fieldSchema, metadatas, name, entityId, value, conte
118
98
  })}
119
99
  >
120
100
  <Typography>…</Typography>
121
- </MenuItem>
101
+ </Menu.Item>
122
102
  )}
123
103
  </>
124
104
  )}
125
- </SimpleMenu>
126
- </Box>
105
+ </Menu.Content>
106
+ </Menu.Root>
127
107
  );
128
108
  };
129
109
 
@@ -147,4 +127,18 @@ RelationMultiple.propTypes = {
147
127
  value: PropTypes.object.isRequired,
148
128
  };
149
129
 
130
+ const TypographyMaxWidth = styled(Typography)`
131
+ max-width: 500px;
132
+ `;
133
+
134
+ /**
135
+ * TODO: this needs to be solved in the Design-System
136
+ */
137
+ const MenuTrigger = styled(Menu.Trigger)`
138
+ svg {
139
+ width: ${6 / 16}rem;
140
+ height: ${4 / 16}rem;
141
+ }
142
+ `;
143
+
150
144
  export default RelationMultiple;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
- import { Badge, Box, MenuItem, SimpleMenu, Typography } from '@strapi/design-system';
4
- import { stopPropagation } from '@strapi/helper-plugin';
3
+ import { Badge, Typography } from '@strapi/design-system';
4
+ import { Menu } from '@strapi/design-system/v2';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useIntl } from 'react-intl';
7
7
  import styled from 'styled-components';
@@ -18,31 +18,28 @@ const RepeatableComponentCell = ({ value, metadatas }) => {
18
18
  mainField: { type: mainFieldType, name: mainFieldName },
19
19
  } = metadatas;
20
20
 
21
- const Label = (
22
- <>
23
- <Badge>{value.length}</Badge>{' '}
24
- {formatMessage(
25
- {
26
- id: 'content-manager.containers.ListPage.items',
27
- defaultMessage: '{number, plural, =0 {items} one {item} other {items}}',
28
- },
29
- { number: value.length }
30
- )}
31
- </>
32
- );
33
-
34
21
  return (
35
- <Box {...stopPropagation}>
36
- <SimpleMenu label={Label} size="S">
22
+ <Menu.Root>
23
+ <MenuTrigger onClick={(e) => e.stopPropagation()}>
24
+ <Badge>{value.length}</Badge>{' '}
25
+ {formatMessage(
26
+ {
27
+ id: 'content-manager.containers.ListPage.items',
28
+ defaultMessage: '{number, plural, =0 {items} one {item} other {items}}',
29
+ },
30
+ { number: value.length }
31
+ )}
32
+ </MenuTrigger>
33
+ <Menu.Content>
37
34
  {value.map((item) => (
38
- <MenuItem key={item.id} aria-disabled>
35
+ <Menu.Item key={item.id} disabled>
39
36
  <TypographyMaxWidth ellipsis>
40
37
  <CellValue type={mainFieldType} value={item[mainFieldName] || item.id} />
41
38
  </TypographyMaxWidth>
42
- </MenuItem>
39
+ </Menu.Item>
43
40
  ))}
44
- </SimpleMenu>
45
- </Box>
41
+ </Menu.Content>
42
+ </Menu.Root>
46
43
  );
47
44
  };
48
45
 
@@ -57,4 +54,14 @@ RepeatableComponentCell.propTypes = {
57
54
  value: PropTypes.array.isRequired,
58
55
  };
59
56
 
57
+ /**
58
+ * TODO: this needs to be solved in the Design-System
59
+ */
60
+ const MenuTrigger = styled(Menu.Trigger)`
61
+ svg {
62
+ width: ${6 / 16}rem;
63
+ height: ${4 / 16}rem;
64
+ }
65
+ `;
66
+
60
67
  export default RepeatableComponentCell;
@@ -1,22 +1,40 @@
1
1
  import React from 'react';
2
2
 
3
- import { BaseCheckbox, IconButton, Tbody, Td, Tr, Flex } from '@strapi/design-system';
4
- import { useTracking, useFetchClient, useAPIErrorHandler } from '@strapi/helper-plugin';
3
+ import {
4
+ BaseCheckbox,
5
+ IconButton,
6
+ Tbody,
7
+ Td,
8
+ Tr,
9
+ Flex,
10
+ Status,
11
+ Typography,
12
+ } from '@strapi/design-system';
13
+ import {
14
+ useTracking,
15
+ useFetchClient,
16
+ useAPIErrorHandler,
17
+ useQueryParams,
18
+ } from '@strapi/helper-plugin';
5
19
  import { Trash, Duplicate, Pencil } from '@strapi/icons';
6
20
  import { AxiosError } from 'axios';
7
21
  import PropTypes from 'prop-types';
8
22
  import { useIntl } from 'react-intl';
9
23
  import { Link, useHistory } from 'react-router-dom';
10
24
 
25
+ import { useEnterprise } from '../../../../../hooks/useEnterprise';
11
26
  import { getFullName } from '../../../../../utils';
12
27
  import { usePluginsQueryParams } from '../../../../hooks';
13
28
  import { getTrad } from '../../../../utils';
14
29
  import CellContent from '../CellContent';
15
30
 
31
+ const REVIEW_WORKFLOW_COLUMNS_CE = () => null;
32
+
16
33
  export const TableRows = ({
17
34
  canCreate,
18
35
  canDelete,
19
36
  contentType,
37
+ features: { hasDraftAndPublish, hasReviewWorkflows },
20
38
  headers,
21
39
  entriesToDelete,
22
40
  onClickDelete,
@@ -32,7 +50,20 @@ export const TableRows = ({
32
50
 
33
51
  const { trackUsage } = useTracking();
34
52
  const pluginsQueryParams = usePluginsQueryParams();
53
+ const [{ query }] = useQueryParams();
35
54
  const { formatAPIError } = useAPIErrorHandler(getTrad);
55
+ const ReviewWorkflowsStage = useEnterprise(
56
+ REVIEW_WORKFLOW_COLUMNS_CE,
57
+ async () =>
58
+ (
59
+ await import(
60
+ '../../../../../../../ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn'
61
+ )
62
+ ).ReviewWorkflowsStageEE,
63
+ {
64
+ enabled: hasReviewWorkflows,
65
+ }
66
+ );
36
67
 
37
68
  /**
38
69
  *
@@ -53,7 +84,9 @@ export const TableRows = ({
53
84
  const handleCloneClick = (id) => async () => {
54
85
  try {
55
86
  const { data } = await post(
56
- `/content-manager/collection-types/${contentType.uid}/auto-clone/${id}?${pluginsQueryParams}`
87
+ `/content-manager/collection-types/${contentType.uid}/auto-clone/${id}`,
88
+ {},
89
+ { params: { plugins: query?.plugins } }
57
90
  );
58
91
 
59
92
  if ('id' in data) {
@@ -74,6 +107,11 @@ export const TableRows = ({
74
107
  }
75
108
  };
76
109
 
110
+ // block rendering until the review stage component is fully loaded in EE
111
+ if (!ReviewWorkflowsStage) {
112
+ return null;
113
+ }
114
+
77
115
  /**
78
116
  * Table Cells with actions e.g edit, delete, duplicate have `stopPropagation`
79
117
  * to prevent the row from being selected.
@@ -113,20 +151,61 @@ export const TableRows = ({
113
151
  />
114
152
  </Td>
115
153
  )}
154
+
116
155
  {headers.map(({ key, cellFormatter, name, ...rest }) => {
156
+ if (hasDraftAndPublish && name === 'publishedAt') {
157
+ return (
158
+ <Td key={key}>
159
+ <Status
160
+ width="min-content"
161
+ showBullet={false}
162
+ variant={data.publishedAt ? 'success' : 'secondary'}
163
+ size="S"
164
+ >
165
+ <Typography
166
+ fontWeight="bold"
167
+ textColor={`${data.publishedAt ? 'success' : 'secondary'}700`}
168
+ >
169
+ {formatMessage({
170
+ id: getTrad(
171
+ `containers.List.${data.publishedAt ? 'published' : 'draft'}`
172
+ ),
173
+ defaultMessage: data.publishedAt ? 'Published' : 'Draft',
174
+ })}
175
+ </Typography>
176
+ </Status>
177
+ </Td>
178
+ );
179
+ }
180
+
181
+ if (hasReviewWorkflows && name === 'strapi_reviewWorkflows_stage') {
182
+ return (
183
+ <Td key={key}>
184
+ {data.strapi_reviewWorkflows_stage ? (
185
+ <ReviewWorkflowsStage
186
+ color={data.strapi_reviewWorkflows_stage.color}
187
+ name={data.strapi_reviewWorkflows_stage.name}
188
+ />
189
+ ) : (
190
+ <Typography textColor="neutral800">-</Typography>
191
+ )}
192
+ </Td>
193
+ );
194
+ }
195
+
196
+ if (typeof cellFormatter === 'function') {
197
+ return <Td key={key}>{cellFormatter(data, { key, name, ...rest })}</Td>;
198
+ }
199
+
117
200
  return (
118
201
  <Td key={key}>
119
- {typeof cellFormatter === 'function' ? (
120
- cellFormatter(data, { key, name, ...rest })
121
- ) : (
122
- <CellContent
123
- content={data[name.split('.')[0]]}
124
- name={name}
125
- contentType={contentType}
126
- {...rest}
127
- rowId={data.id}
128
- />
129
- )}
202
+ <CellContent
203
+ content={data[name.split('.')[0]]}
204
+ name={name}
205
+ contentType={contentType}
206
+ {...rest}
207
+ rowId={data.id}
208
+ />
130
209
  </Td>
131
210
  );
132
211
  })}
@@ -212,6 +291,10 @@ TableRows.propTypes = {
212
291
  uid: PropTypes.string.isRequired,
213
292
  }).isRequired,
214
293
  entriesToDelete: PropTypes.array,
294
+ features: PropTypes.shape({
295
+ hasDraftAndPublish: PropTypes.bool.isRequired,
296
+ hasReviewWorkflows: PropTypes.bool.isRequired,
297
+ }).isRequired,
215
298
  headers: PropTypes.array.isRequired,
216
299
  onClickDelete: PropTypes.func,
217
300
  onSelectRow: PropTypes.func,
@@ -10,8 +10,6 @@ import {
10
10
  HeaderLayout,
11
11
  useNotifyAT,
12
12
  Flex,
13
- Typography,
14
- Status,
15
13
  } from '@strapi/design-system';
16
14
  import {
17
15
  NoPermissions,
@@ -33,7 +31,6 @@ import {
33
31
  } from '@strapi/helper-plugin';
34
32
  import { ArrowLeft, Cog, Plus } from '@strapi/icons';
35
33
  import axios from 'axios';
36
- import getReviewWorkflowsColumn from 'ee_else_ce/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/getTableColumn';
37
34
  import isEqual from 'lodash/isEqual';
38
35
  import PropTypes from 'prop-types';
39
36
  import { stringify } from 'qs';
@@ -45,6 +42,7 @@ import { bindActionCreators, compose } from 'redux';
45
42
  import styled from 'styled-components';
46
43
 
47
44
  import { INJECT_COLUMN_IN_TABLE } from '../../../exposedHooks';
45
+ import { useEnterprise } from '../../../hooks/useEnterprise';
48
46
  import { selectAdminPermissions } from '../../../pages/App/selectors';
49
47
  import { InjectionZone } from '../../../shared/components';
50
48
  import AttributeFilter from '../../components/AttributeFilter';
@@ -57,7 +55,7 @@ import { ConfirmDialogDeleteAll } from './components/ConfirmDialogDeleteAll';
57
55
  import { FieldPicker } from './components/FieldPicker';
58
56
  import { TableRows } from './components/TableRows';
59
57
  import makeSelectListView, { selectDisplayedHeaders } from './selectors';
60
- import { buildQueryString } from './utils';
58
+ import { buildValidGetParams } from './utils';
61
59
 
62
60
  const ConfigureLayoutBox = styled(Box)`
63
61
  svg {
@@ -67,6 +65,8 @@ const ConfigureLayoutBox = styled(Box)`
67
65
  }
68
66
  `;
69
67
 
68
+ const REVIEW_WORKFLOW_COLUMNS_CE = null;
69
+
70
70
  function ListView({
71
71
  canCreate,
72
72
  canDelete,
@@ -101,14 +101,30 @@ function ListView({
101
101
  useFocusWhenNavigate();
102
102
 
103
103
  const [{ query }] = useQueryParams();
104
- const params = buildQueryString(query);
104
+ const params = React.useMemo(() => buildValidGetParams(query), [query]);
105
105
  const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
106
106
 
107
107
  const { pathname } = useLocation();
108
108
  const { push } = useHistory();
109
109
  const { formatMessage } = useIntl();
110
- const hasDraftAndPublish = options?.draftAndPublish || false;
111
110
  const fetchClient = useFetchClient();
111
+
112
+ const hasDraftAndPublish = options?.draftAndPublish ?? false;
113
+ const hasReviewWorkflows = options?.reviewWorkflows ?? false;
114
+
115
+ const reviewWorkflowColumns = useEnterprise(
116
+ REVIEW_WORKFLOW_COLUMNS_CE,
117
+ async () =>
118
+ (
119
+ await import(
120
+ '../../../../../ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/constants'
121
+ )
122
+ ).REVIEW_WORKFLOW_COLUMNS_EE,
123
+ {
124
+ enabled: !!options?.reviewWorkflows,
125
+ }
126
+ );
127
+
112
128
  const { post, del } = fetchClient;
113
129
 
114
130
  const bulkPublishMutation = useMutation(
@@ -121,7 +137,7 @@ function ListView({
121
137
  message: { id: 'content-manager.success.record.publish', defaultMessage: 'Published' },
122
138
  });
123
139
 
124
- fetchData(`/content-manager/collection-types/${slug}${params}`);
140
+ fetchData(`/content-manager/collection-types/${slug}`, { params });
125
141
  },
126
142
  onError(error) {
127
143
  toggleNotification({
@@ -144,7 +160,7 @@ function ListView({
144
160
  },
145
161
  });
146
162
 
147
- fetchData(`/content-manager/collection-types/${slug}${params}`);
163
+ fetchData(`/content-manager/collection-types/${slug}`, { params });
148
164
  },
149
165
  onError(error) {
150
166
  toggleNotification({
@@ -159,19 +175,17 @@ function ListView({
159
175
  // Using a ref to avoid requests being fired multiple times on slug on change
160
176
  // We need it because the hook as mulitple dependencies so it may run before the permissions have checked
161
177
  const requestUrlRef = React.useRef('');
162
-
163
178
  /**
164
179
  * TODO: re-write all of this, it's a mess.
165
180
  */
166
181
  const fetchData = React.useCallback(
167
- async (endPoint, source) => {
182
+ async (endPoint, options) => {
168
183
  getData();
169
184
 
170
185
  try {
171
- const opts = source ? { cancelToken: source.token } : null;
172
186
  const {
173
187
  data: { results, pagination: paginationResult },
174
- } = await fetchClient.get(endPoint, opts);
188
+ } = await fetchClient.get(endPoint, options);
175
189
 
176
190
  notifyStatus(
177
191
  formatMessage(
@@ -218,12 +232,12 @@ function ListView({
218
232
  const handleConfirmDeleteAllData = React.useCallback(
219
233
  async (ids) => {
220
234
  try {
221
- await post(getRequestUrl(`collection-types/${slug}/actions/bulkDelete`), {
235
+ await post(`/content-manager/collection-types/${slug}/actions/bulkDelete`, {
222
236
  ids,
223
237
  });
224
238
 
225
- const requestUrl = getRequestUrl(`collection-types/${slug}${params}`);
226
- fetchData(requestUrl);
239
+ fetchData(`/content-manager/collection-types/${slug}`, { params });
240
+
227
241
  trackUsageRef.current('didBulkDeleteEntries');
228
242
  } catch (err) {
229
243
  toggleNotification({
@@ -232,16 +246,16 @@ function ListView({
232
246
  });
233
247
  }
234
248
  },
235
- [fetchData, params, slug, toggleNotification, formatAPIError, post]
249
+ [slug, toggleNotification, formatAPIError, post, fetchData, params]
236
250
  );
237
251
 
238
252
  const handleConfirmDeleteData = React.useCallback(
239
253
  async (idToDelete) => {
240
254
  try {
241
- await del(getRequestUrl(`collection-types/${slug}/${idToDelete}`));
255
+ await del(`/content-manager/collection-types/${slug}/${idToDelete}`);
242
256
 
243
- const requestUrl = getRequestUrl(`collection-types/${slug}${params}`);
244
- fetchData(requestUrl);
257
+ const requestUrl = getRequestUrl(`collection-types/${slug}`);
258
+ fetchData(requestUrl, { params });
245
259
 
246
260
  toggleNotification({
247
261
  type: 'success',
@@ -254,7 +268,7 @@ function ListView({
254
268
  });
255
269
  }
256
270
  },
257
- [slug, params, fetchData, toggleNotification, formatAPIError, del]
271
+ [slug, toggleNotification, formatAPIError, del, fetchData, params]
258
272
  );
259
273
 
260
274
  /**
@@ -326,10 +340,10 @@ function ListView({
326
340
  const source = CancelToken.source();
327
341
 
328
342
  const shouldSendRequest = canRead;
329
- const requestUrl = getRequestUrl(`collection-types/${slug}${params}`);
343
+ const requestUrl = getRequestUrl(`collection-types/${slug}`);
330
344
 
331
345
  if (shouldSendRequest && requestUrl.includes(requestUrlRef.current)) {
332
- fetchData(requestUrl, source);
346
+ fetchData(requestUrl, { cancelToken: source.token, params });
333
347
  }
334
348
 
335
349
  return () => {
@@ -388,24 +402,8 @@ function ListView({
388
402
  };
389
403
  });
390
404
 
391
- if (!hasDraftAndPublish) {
392
- return formattedHeaders;
393
- }
394
-
395
- // this should not exist. Ideally we would use registerHook() similar to what has been done
396
- // in the i18n plugin. In order to do that review-workflows should have been a plugin. In
397
- // a future iteration we need to find a better pattern.
398
-
399
- // In CE this will return null - in EE a column definition including the custom formatting component.
400
- const reviewWorkflowColumn = getReviewWorkflowsColumn(layout);
401
-
402
- if (reviewWorkflowColumn) {
403
- formattedHeaders.push(reviewWorkflowColumn);
404
- }
405
-
406
- return [
407
- ...formattedHeaders,
408
- {
405
+ if (hasDraftAndPublish) {
406
+ formattedHeaders.push({
409
407
  key: '__published_at_temp_key__',
410
408
  name: 'publishedAt',
411
409
  fieldSchema: {
@@ -419,25 +417,29 @@ function ListView({
419
417
  searchable: false,
420
418
  sortable: true,
421
419
  },
422
- // eslint-disable-next-line react/no-unstable-nested-components
423
- cellFormatter(cellData) {
424
- const isPublished = cellData.publishedAt;
425
- const variant = isPublished ? 'success' : 'secondary';
426
-
427
- return (
428
- <Status width="min-content" showBullet={false} variant={variant} size="S">
429
- <Typography fontWeight="bold" textColor={`${variant}700`}>
430
- {formatMessage({
431
- id: getTrad(`containers.List.${isPublished ? 'published' : 'draft'}`),
432
- defaultMessage: isPublished ? 'Published' : 'Draft',
433
- })}
434
- </Typography>
435
- </Status>
436
- );
437
- },
438
- },
439
- ];
440
- }, [runHookWaterfall, displayedHeaders, layout, hasDraftAndPublish, formatMessage]);
420
+ });
421
+ }
422
+
423
+ if (reviewWorkflowColumns) {
424
+ // Make sure the column header label is translated
425
+ if (typeof reviewWorkflowColumns.metadatas.label !== 'string') {
426
+ reviewWorkflowColumns.metadatas.label = formatMessage(
427
+ reviewWorkflowColumns.metadatas.label
428
+ );
429
+ }
430
+
431
+ formattedHeaders.push(reviewWorkflowColumns);
432
+ }
433
+
434
+ return formattedHeaders;
435
+ }, [
436
+ runHookWaterfall,
437
+ displayedHeaders,
438
+ layout,
439
+ reviewWorkflowColumns,
440
+ hasDraftAndPublish,
441
+ formatMessage,
442
+ ]);
441
443
 
442
444
  const subtitle = canRead
443
445
  ? formatMessage(
@@ -580,6 +582,10 @@ function ListView({
580
582
  canCreate={canCreate}
581
583
  canDelete={canDelete}
582
584
  contentType={contentType}
585
+ features={{
586
+ hasDraftAndPublish,
587
+ hasReviewWorkflows,
588
+ }}
583
589
  headers={tableHeaders}
584
590
  rows={data}
585
591
  withBulkActions