@strapi/admin 4.11.0-beta.0 → 4.11.0-exp.9xg4-3qfm-9w8f

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 (74) hide show
  1. package/admin/src/content-manager/components/DynamicTable/ConfirmDialogDeleteAll/index.js +73 -0
  2. package/admin/src/content-manager/components/DynamicTable/index.js +4 -20
  3. package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +2 -3
  4. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/index.js +1 -0
  5. package/admin/src/content-manager/{utils → components/EditViewDataManagerProvider/utils}/schema.js +1 -1
  6. package/admin/src/content-manager/pages/ListView/index.js +2 -118
  7. package/admin/src/content-manager/utils/index.js +0 -2
  8. package/admin/src/hooks/useContentTypes/useContentTypes.js +0 -2
  9. package/admin/src/injectionZones.js +1 -6
  10. package/admin/src/translations/ar.json +684 -1
  11. package/admin/src/translations/en.json +2 -5
  12. package/build/{1657.ca8562dd.chunk.js → 1657.3f2b2c11.chunk.js} +1 -9
  13. package/build/3081.7e9329cb.chunk.js +105 -0
  14. package/build/462.6f8cbd19.chunk.js +71 -0
  15. package/build/5542.64b623c9.chunk.js +63 -0
  16. package/build/617.1591eeb0.chunk.js +155 -0
  17. package/build/6858.85d76858.chunk.js +50 -0
  18. package/build/6970.6a329e15.chunk.js +1 -0
  19. package/build/9036.f7ce35cc.chunk.js +211 -0
  20. package/build/{Admin-authenticatedApp.65172a0c.chunk.js → Admin-authenticatedApp.0f366684.chunk.js} +2 -2
  21. package/build/{Admin_homePage.107a9fe0.chunk.js → Admin_homePage.94dc81b1.chunk.js} +16 -16
  22. package/build/Admin_marketplace.1b0c3d3b.chunk.js +55 -0
  23. package/build/Admin_pluginsPage.a28b96d5.chunk.js +6 -0
  24. package/build/Admin_settingsPage.ee76d19e.chunk.js +79 -0
  25. package/build/admin-app.bd209f08.chunk.js +63 -0
  26. package/build/admin-roles-list.af53b372.chunk.js +23 -0
  27. package/build/admin-users.004d5c68.chunk.js +26 -0
  28. package/build/ar-json.f530bc3f.chunk.js +1 -0
  29. package/build/audit-logs-settings-page.dc07596e.chunk.js +121 -0
  30. package/build/content-manager.70548048.chunk.js +1123 -0
  31. package/build/content-type-builder-list-view.26aab6f3.chunk.js +215 -0
  32. package/build/email-settings-page.63f269ff.chunk.js +11 -0
  33. package/build/{en-json.19e9ff9b.chunk.js → en-json.ba3290b8.chunk.js} +1 -1
  34. package/build/i18n-settings-page.f84c4782.chunk.js +114 -0
  35. package/build/i18n-translation-en-json.60af6722.chunk.js +1 -0
  36. package/build/index.html +1 -1
  37. package/build/main.4016f4ad.js +2630 -0
  38. package/build/{review-workflows-settings.4b39b837.chunk.js → review-workflows-settings.56cab253.chunk.js} +1 -1
  39. package/build/{runtime~main.96d92f16.js → runtime~main.b22be595.js} +2 -2
  40. package/build/upload-settings.1d187578.chunk.js +14 -0
  41. package/build/upload.bc340679.chunk.js +26 -0
  42. package/build/users-advanced-settings-page.7b4bf63a.chunk.js +9 -0
  43. package/build/users-email-settings-page.035a026c.chunk.js +24 -0
  44. package/build/users-providers-settings-page.6873dce9.chunk.js +29 -0
  45. package/build/webhook-list-page.0861d3e9.chunk.js +63 -0
  46. package/package.json +15 -15
  47. package/admin/src/content-manager/components/DynamicTable/BulkActionsBar/index.js +0 -307
  48. package/build/3081.c2cdfac8.chunk.js +0 -108
  49. package/build/3562.e0b1a0b3.chunk.js +0 -50
  50. package/build/3816.60f858cf.chunk.js +0 -211
  51. package/build/462.a073ff1f.chunk.js +0 -71
  52. package/build/5542.002522eb.chunk.js +0 -71
  53. package/build/617.87b2fe96.chunk.js +0 -155
  54. package/build/6970.7ea35fbd.chunk.js +0 -1
  55. package/build/Admin_marketplace.717bd7ca.chunk.js +0 -55
  56. package/build/Admin_pluginsPage.7df6b5a9.chunk.js +0 -6
  57. package/build/Admin_settingsPage.bd715ed3.chunk.js +0 -79
  58. package/build/admin-app.9c79b484.chunk.js +0 -63
  59. package/build/admin-roles-list.e8bf9685.chunk.js +0 -31
  60. package/build/admin-users.751b28b2.chunk.js +0 -34
  61. package/build/ar-json.39e54aba.chunk.js +0 -1
  62. package/build/audit-logs-settings-page.3c6cea81.chunk.js +0 -129
  63. package/build/content-manager.bf060d8e.chunk.js +0 -1123
  64. package/build/content-type-builder-list-view.1e821eb9.chunk.js +0 -215
  65. package/build/email-settings-page.dba83275.chunk.js +0 -11
  66. package/build/i18n-settings-page.55628f74.chunk.js +0 -114
  67. package/build/i18n-translation-en-json.1ec7becf.chunk.js +0 -1
  68. package/build/main.576a9d22.js +0 -2630
  69. package/build/upload-settings.63d99bf5.chunk.js +0 -14
  70. package/build/upload.c50d8c7a.chunk.js +0 -34
  71. package/build/users-advanced-settings-page.4f49ca57.chunk.js +0 -9
  72. package/build/users-email-settings-page.d2429d0a.chunk.js +0 -24
  73. package/build/users-providers-settings-page.50c5ba27.chunk.js +0 -29
  74. package/build/webhook-list-page.e2fca9f8.chunk.js +0 -71
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useIntl } from 'react-intl';
4
+ import { Dialog, DialogBody, DialogFooter, Flex, Typography, Button } from '@strapi/design-system';
5
+ import { ExclamationMarkCircle, Trash } from '@strapi/icons';
6
+ import InjectionZoneList from '../../InjectionZoneList';
7
+ import { getTrad } from '../../../utils';
8
+
9
+ const ConfirmDialogDeleteAll = ({ isConfirmButtonLoading, isOpen, onToggleDialog, onConfirm }) => {
10
+ const { formatMessage } = useIntl();
11
+
12
+ return (
13
+ <Dialog
14
+ onClose={onToggleDialog}
15
+ title={formatMessage({
16
+ id: 'app.components.ConfirmDialog.title',
17
+ defaultMessage: 'Confirmation',
18
+ })}
19
+ labelledBy="confirmation"
20
+ describedBy="confirm-description"
21
+ isOpen={isOpen}
22
+ >
23
+ <DialogBody icon={<ExclamationMarkCircle />}>
24
+ <Flex direction="column" alignItems="stretch" gap={2}>
25
+ <Flex justifyContent="center">
26
+ <Typography id="confirm-description">
27
+ {formatMessage({
28
+ id: getTrad('popUpWarning.bodyMessage.contentType.delete.all'),
29
+ defaultMessage: 'Are you sure you want to delete these entries?',
30
+ })}
31
+ </Typography>
32
+ </Flex>
33
+ <Flex>
34
+ <InjectionZoneList area="contentManager.listView.deleteModalAdditionalInfos" />
35
+ </Flex>
36
+ </Flex>
37
+ </DialogBody>
38
+ <DialogFooter
39
+ startAction={
40
+ <Button onClick={onToggleDialog} variant="tertiary">
41
+ {formatMessage({
42
+ id: 'app.components.Button.cancel',
43
+ defaultMessage: 'Cancel',
44
+ })}
45
+ </Button>
46
+ }
47
+ endAction={
48
+ <Button
49
+ onClick={onConfirm}
50
+ variant="danger-light"
51
+ startIcon={<Trash />}
52
+ id="confirm-delete"
53
+ loading={isConfirmButtonLoading}
54
+ >
55
+ {formatMessage({
56
+ id: 'app.components.Button.confirm',
57
+ defaultMessage: 'Confirm',
58
+ })}
59
+ </Button>
60
+ }
61
+ />
62
+ </Dialog>
63
+ );
64
+ };
65
+
66
+ ConfirmDialogDeleteAll.propTypes = {
67
+ isConfirmButtonLoading: PropTypes.bool.isRequired,
68
+ isOpen: PropTypes.bool.isRequired,
69
+ onConfirm: PropTypes.func.isRequired,
70
+ onToggleDialog: PropTypes.func.isRequired,
71
+ };
72
+
73
+ export default ConfirmDialogDeleteAll;
@@ -9,22 +9,19 @@ import { INJECT_COLUMN_IN_TABLE } from '../../../exposedHooks';
9
9
  import { selectDisplayedHeaders } from '../../pages/ListView/selectors';
10
10
  import { getTrad } from '../../utils';
11
11
  import TableRows from './TableRows';
12
+ import ConfirmDialogDeleteAll from './ConfirmDialogDeleteAll';
12
13
  import ConfirmDialogDelete from './ConfirmDialogDelete';
13
14
  import { PublicationState } from './CellContent/PublicationState/PublicationState';
14
- import BulkActionsBar from './BulkActionsBar';
15
15
 
16
16
  const DynamicTable = ({
17
17
  canCreate,
18
18
  canDelete,
19
- canPublish,
20
19
  contentTypeName,
21
20
  action,
22
21
  isBulkable,
23
22
  isLoading,
24
23
  onConfirmDelete,
25
24
  onConfirmDeleteAll,
26
- onConfirmPublishAll,
27
- onConfirmUnpublishAll,
28
25
  layout,
29
26
  rows,
30
27
  }) => {
@@ -92,27 +89,17 @@ const DynamicTable = ({
92
89
 
93
90
  return (
94
91
  <Table
95
- components={{ ConfirmDialogDelete }}
92
+ components={{ ConfirmDialogDelete, ConfirmDialogDeleteAll }}
96
93
  contentType={contentTypeName}
97
94
  action={action}
98
95
  isLoading={isLoading}
99
96
  headers={tableHeaders}
100
97
  onConfirmDelete={onConfirmDelete}
98
+ onConfirmDeleteAll={onConfirmDeleteAll}
101
99
  onOpenDeleteAllModalTrackedEvent="willBulkDeleteEntries"
102
100
  rows={rows}
103
101
  withBulkActions
104
- withMainAction={(canDelete || canPublish) && isBulkable}
105
- renderBulkActionsBar={({ selectedEntries, clearSelectedEntries }) => (
106
- <BulkActionsBar
107
- showPublish={canPublish && hasDraftAndPublish}
108
- showDelete={canDelete}
109
- onConfirmDeleteAll={onConfirmDeleteAll}
110
- onConfirmPublishAll={onConfirmPublishAll}
111
- onConfirmUnpublishAll={onConfirmUnpublishAll}
112
- selectedEntries={selectedEntries}
113
- clearSelectedEntries={clearSelectedEntries}
114
- />
115
- )}
102
+ withMainAction={canDelete && isBulkable}
116
103
  >
117
104
  <TableRows
118
105
  canCreate={canCreate}
@@ -134,7 +121,6 @@ DynamicTable.defaultProps = {
134
121
  DynamicTable.propTypes = {
135
122
  canCreate: PropTypes.bool.isRequired,
136
123
  canDelete: PropTypes.bool.isRequired,
137
- canPublish: PropTypes.bool.isRequired,
138
124
  contentTypeName: PropTypes.string.isRequired,
139
125
  action: PropTypes.node,
140
126
  isBulkable: PropTypes.bool.isRequired,
@@ -153,8 +139,6 @@ DynamicTable.propTypes = {
153
139
  }).isRequired,
154
140
  onConfirmDelete: PropTypes.func.isRequired,
155
141
  onConfirmDeleteAll: PropTypes.func.isRequired,
156
- onConfirmPublishAll: PropTypes.func.isRequired,
157
- onConfirmUnpublishAll: PropTypes.func.isRequired,
158
142
  rows: PropTypes.array.isRequired,
159
143
  };
160
144
 
@@ -21,13 +21,12 @@ import {
21
21
  getAPIInnerErrors,
22
22
  } from '@strapi/helper-plugin';
23
23
 
24
- import { createYupSchema, getTrad } from '../../utils';
24
+ import { getTrad } from '../../utils';
25
25
 
26
26
  import selectCrudReducer from '../../sharedReducers/crudReducer/selectors';
27
27
 
28
28
  import reducer, { initialState } from './reducer';
29
- import { cleanData } from './utils';
30
-
29
+ import { cleanData, createYupSchema } from './utils';
31
30
  import { clearSetModifiedDataOnly } from '../../sharedReducers/crudReducer/actions';
32
31
  import { usePrev } from '../../hooks';
33
32
 
@@ -1,3 +1,4 @@
1
1
  export { default as moveFields } from './moveFields';
2
2
  export { default as cleanData } from './cleanData';
3
+ export { default as createYupSchema } from './schema';
3
4
  export { findAllAndReplace } from './findAllAndReplace';
@@ -7,7 +7,7 @@ import toNumber from 'lodash/toNumber';
7
7
  import * as yup from 'yup';
8
8
  import { translatedErrors as errorsTrads } from '@strapi/helper-plugin';
9
9
 
10
- import isFieldTypeNumber from './isFieldTypeNumber';
10
+ import isFieldTypeNumber from '../../../utils/isFieldTypeNumber';
11
11
 
12
12
  yup.addMethod(yup.mixed, 'defined', function () {
13
13
  return this.test('defined', errorsTrads.required, (value) => value !== undefined);
@@ -21,7 +21,6 @@ import {
21
21
  useTracking,
22
22
  Link,
23
23
  useAPIErrorHandler,
24
- getYupInnerErrors,
25
24
  } from '@strapi/helper-plugin';
26
25
 
27
26
  import {
@@ -36,7 +35,6 @@ import {
36
35
  } from '@strapi/design-system';
37
36
 
38
37
  import { ArrowLeft, Plus, Cog } from '@strapi/icons';
39
- import { useMutation } from 'react-query';
40
38
 
41
39
  import DynamicTable from '../../components/DynamicTable';
42
40
  import AttributeFilter from '../../components/AttributeFilter';
@@ -44,7 +42,7 @@ import { InjectionZone } from '../../../shared/components';
44
42
 
45
43
  import permissions from '../../../permissions';
46
44
 
47
- import { createYupSchema, getRequestUrl, getTrad } from '../../utils';
45
+ import { getRequestUrl, getTrad } from '../../utils';
48
46
 
49
47
  import FieldPicker from './FieldPicker';
50
48
  import PaginationFooter from './PaginationFooter';
@@ -66,7 +64,6 @@ function ListView({
66
64
  canCreate,
67
65
  canDelete,
68
66
  canRead,
69
- canPublish,
70
67
  data,
71
68
  getData,
72
69
  getDataSucceeded,
@@ -103,50 +100,6 @@ function ListView({
103
100
  const fetchClient = useFetchClient();
104
101
  const { post, del } = fetchClient;
105
102
 
106
- const bulkPublishMutation = useMutation(
107
- (data) =>
108
- post(`/content-manager/collection-types/${contentType.uid}/actions/bulkPublish`, data),
109
- {
110
- onSuccess() {
111
- toggleNotification({
112
- type: 'success',
113
- message: { id: 'content-manager.success.record.publish', defaultMessage: 'Published' },
114
- });
115
-
116
- fetchData(`/content-manager/collection-types/${slug}${params}`);
117
- },
118
- onError(error) {
119
- toggleNotification({
120
- type: 'warning',
121
- message: formatAPIError(error),
122
- });
123
- },
124
- }
125
- );
126
- const bulkUnpublishMutation = useMutation(
127
- (data) =>
128
- post(`/content-manager/collection-types/${contentType.uid}/actions/bulkUnpublish`, data),
129
- {
130
- onSuccess() {
131
- toggleNotification({
132
- type: 'success',
133
- message: {
134
- id: 'content-manager.success.record.unpublish',
135
- defaultMessage: 'Unpublished',
136
- },
137
- });
138
-
139
- fetchData(`/content-manager/collection-types/${slug}${params}`);
140
- },
141
- onError(error) {
142
- toggleNotification({
143
- type: 'warning',
144
- message: formatAPIError(error),
145
- });
146
- },
147
- }
148
- );
149
-
150
103
  // FIXME
151
104
  // Using a ref to avoid requests being fired multiple times on slug on change
152
105
  // We need it because the hook as mulitple dependencies so it may run before the permissions have checked
@@ -246,70 +199,6 @@ function ListView({
246
199
  [slug, params, fetchData, toggleNotification, formatAPIError, del]
247
200
  );
248
201
 
249
- /**
250
- * @param {number[]} selectedEntries - Array of ids to publish
251
- * @returns {{validIds: number[], errors: Object.<number, string>}} - Returns an object with the valid ids and the errors
252
- */
253
- const validateEntriesToPublish = async (selectedEntries) => {
254
- const validations = { validIds: [], errors: {} };
255
- // Create the validation schema based on the contentType
256
- const schema = createYupSchema(
257
- contentType,
258
- { components: layout.components },
259
- { isDraft: false }
260
- );
261
- // Get the selected entries
262
- const entries = data.filter((entry) => {
263
- return selectedEntries.includes(entry.id);
264
- });
265
- // Validate each entry and map the unresolved promises
266
- const validationPromises = entries.map((entry) =>
267
- schema.validate(entry, { abortEarly: false })
268
- );
269
- // Resolve all the promises in one go
270
- const resolvedPromises = await Promise.allSettled(validationPromises);
271
- // Set the validations
272
- resolvedPromises.forEach((promise) => {
273
- if (promise.status === 'rejected') {
274
- const entityId = promise.reason.value.id;
275
- validations.errors[entityId] = getYupInnerErrors(promise.reason);
276
- }
277
-
278
- if (promise.status === 'fulfilled') {
279
- validations.validIds.push(promise.value.id);
280
- }
281
- });
282
-
283
- return validations;
284
- };
285
-
286
- const handleConfirmPublishAllData = async (selectedEntries) => {
287
- const validations = await validateEntriesToPublish(selectedEntries);
288
-
289
- if (Object.values(validations.errors).length) {
290
- toggleNotification({
291
- type: 'warning',
292
- title: {
293
- id: 'content-manager.listView.validation.errors.title',
294
- defaultMessage: 'Action required',
295
- },
296
- message: {
297
- id: 'content-manager.listView.validation.errors.message',
298
- defaultMessage:
299
- 'Please make sure all fields are valid before publishing (required field, min/max character limit, etc.)',
300
- },
301
- });
302
-
303
- throw new Error('Validation error');
304
- }
305
-
306
- return bulkPublishMutation.mutateAsync({ ids: selectedEntries });
307
- };
308
-
309
- const handleConfirmUnpublishAllData = (selectedEntries) => {
310
- return bulkUnpublishMutation.mutateAsync({ ids: selectedEntries });
311
- };
312
-
313
202
  useEffect(() => {
314
203
  const CancelToken = axios.CancelToken;
315
204
  const source = CancelToken.source();
@@ -441,12 +330,9 @@ function ListView({
441
330
  <DynamicTable
442
331
  canCreate={canCreate}
443
332
  canDelete={canDelete}
444
- canPublish={canPublish}
445
333
  contentTypeName={headerLayoutTitle}
446
- onConfirmDelete={handleConfirmDeleteData}
447
334
  onConfirmDeleteAll={handleConfirmDeleteAllData}
448
- onConfirmPublishAll={handleConfirmPublishAllData}
449
- onConfirmUnpublishAll={handleConfirmUnpublishAllData}
335
+ onConfirmDelete={handleConfirmDeleteData}
450
336
  isBulkable={isBulkable}
451
337
  isLoading={isLoading}
452
338
  // FIXME: remove the layout props drilling
@@ -468,12 +354,10 @@ ListView.propTypes = {
468
354
  canCreate: PropTypes.bool.isRequired,
469
355
  canDelete: PropTypes.bool.isRequired,
470
356
  canRead: PropTypes.bool.isRequired,
471
- canPublish: PropTypes.bool.isRequired,
472
357
  data: PropTypes.array.isRequired,
473
358
  layout: PropTypes.exact({
474
359
  components: PropTypes.object.isRequired,
475
360
  contentType: PropTypes.shape({
476
- uid: PropTypes.string.isRequired,
477
361
  attributes: PropTypes.object.isRequired,
478
362
  metadatas: PropTypes.object.isRequired,
479
363
  info: PropTypes.shape({ displayName: PropTypes.string.isRequired }).isRequired,
@@ -18,5 +18,3 @@ export { default as mergeMetasWithSchema } from './mergeMetasWithSchema';
18
18
 
19
19
  export { default as removeKeyInObject } from './removeKeyInObject';
20
20
  export { default as removePasswordFieldsFromData } from './removePasswordFieldsFromData';
21
-
22
- export { default as createYupSchema } from './schema';
@@ -2,8 +2,6 @@ import { useAPIErrorHandler, useFetchClient, useNotification } from '@strapi/hel
2
2
  import { useQueries } from 'react-query';
3
3
 
4
4
  export function useContentTypes() {
5
- console.log('----> read');
6
-
7
5
  const { get } = useFetchClient();
8
6
  const { formatAPIError } = useAPIErrorHandler();
9
7
  const toggleNotification = useNotification();
@@ -13,12 +13,7 @@ const injectionZones = {
13
13
  },
14
14
  contentManager: {
15
15
  editView: { informations: [], 'right-links': [] },
16
- listView: {
17
- actions: [],
18
- deleteModalAdditionalInfos: [],
19
- publishModalAdditionalInfos: [],
20
- unpublishModalAdditionalInfos: [],
21
- },
16
+ listView: { actions: [], deleteModalAdditionalInfos: [] },
22
17
  },
23
18
  };
24
19