@strapi/admin 4.11.0-exp.9xg4-3qfm-9w8f.1 → 4.11.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 (112) hide show
  1. package/admin/src/components/Providers/index.js +32 -32
  2. package/admin/src/components/Theme/index.js +5 -3
  3. package/admin/src/content-manager/components/ComponentIcon/ComponentIcon.js +16 -26
  4. package/admin/src/content-manager/components/ComponentIcon/constants.js +133 -0
  5. package/admin/src/content-manager/components/DynamicTable/BulkActionsBar/index.js +307 -0
  6. package/admin/src/content-manager/components/DynamicTable/index.js +20 -4
  7. package/admin/src/content-manager/components/DynamicZone/components/AddComponentButton.js +32 -95
  8. package/admin/src/content-manager/components/DynamicZone/components/ComponentCard.js +10 -2
  9. package/admin/src/content-manager/components/DynamicZone/components/ComponentCategory.js +63 -15
  10. package/admin/src/content-manager/components/DynamicZone/components/ComponentPicker.js +50 -63
  11. package/admin/src/content-manager/components/DynamicZone/components/DynamicComponent.js +132 -58
  12. package/admin/src/content-manager/components/DynamicZone/components/DynamicZoneLabel.js +29 -37
  13. package/admin/src/content-manager/components/DynamicZone/index.js +131 -83
  14. package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +12 -4
  15. package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +18 -6
  16. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/index.js +0 -1
  17. package/admin/src/content-manager/components/Inputs/index.js +18 -11
  18. package/admin/src/content-manager/components/Inputs/utils/index.js +0 -1
  19. package/admin/src/content-manager/pages/EditSettingsView/components/DynamicZoneList.js +7 -1
  20. package/admin/src/content-manager/pages/EditView/index.js +1 -1
  21. package/admin/src/content-manager/pages/ListView/index.js +118 -2
  22. package/admin/src/content-manager/utils/index.js +2 -0
  23. package/admin/src/content-manager/{components/EditViewDataManagerProvider/utils → utils}/schema.js +1 -1
  24. package/admin/src/injectionZones.js +6 -1
  25. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventTable/EventTableCE.js +13 -0
  26. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventTable/index.js +3 -0
  27. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/Events/index.js +331 -0
  28. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/Combobox.js +54 -4
  29. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js +12 -23
  30. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/WebhookForm/index.js +129 -116
  31. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/WebhookForm/utils/makeWebhookValidationSchema.js +62 -0
  32. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/index.js +59 -64
  33. package/admin/src/translations/en.json +11 -1
  34. package/build/3562.e0b1a0b3.chunk.js +50 -0
  35. package/build/371.6e4e2c1f.chunk.js +71 -0
  36. package/build/5297.31c9ffdc.chunk.js +39 -0
  37. package/build/{5563.79950369.chunk.js → 5563.badbffde.chunk.js} +2 -2
  38. package/build/{3081.7e9329cb.chunk.js → 6691.f7a3b5ac.chunk.js} +2 -2
  39. package/build/6970.d456705f.chunk.js +1 -0
  40. package/build/{7259.5cc67413.chunk.js → 7259.5d0de931.chunk.js} +1 -1
  41. package/build/8976.0022f5a3.chunk.js +50 -0
  42. package/build/{1657.3f2b2c11.chunk.js → 9932.5ef475c5.chunk.js} +54 -54
  43. package/build/Admin-authenticatedApp.ab2b5910.chunk.js +79 -0
  44. package/build/{Admin_InternalErrorPage.96ceaae1.chunk.js → Admin_InternalErrorPage.f25f04f3.chunk.js} +1 -1
  45. package/build/{Admin_homePage.94dc81b1.chunk.js → Admin_homePage.05063e43.chunk.js} +16 -16
  46. package/build/{Admin_marketplace.1b0c3d3b.chunk.js → Admin_marketplace.005d2d5b.chunk.js} +11 -11
  47. package/build/{Admin_pluginsPage.a28b96d5.chunk.js → Admin_pluginsPage.5d9d4060.chunk.js} +1 -1
  48. package/build/{Admin_profilePage.a8fa3a56.chunk.js → Admin_profilePage.ab7b94d7.chunk.js} +2 -2
  49. package/build/{Admin_settingsPage.ee76d19e.chunk.js → Admin_settingsPage.07a6a5f0.chunk.js} +2 -2
  50. package/build/{Upload_ConfigureTheView.aa64ed9a.chunk.js → Upload_ConfigureTheView.121deffb.chunk.js} +1 -1
  51. package/build/{admin-app.bd209f08.chunk.js → admin-app.7cc667be.chunk.js} +10 -10
  52. package/build/{admin-edit-roles-page.0d12b741.chunk.js → admin-edit-roles-page.bfe3304d.chunk.js} +3 -3
  53. package/build/{admin-edit-users.f9ce7844.chunk.js → admin-edit-users.6efe0382.chunk.js} +2 -2
  54. package/build/{admin-roles-list.af53b372.chunk.js → admin-roles-list.b2577370.chunk.js} +1 -1
  55. package/build/{admin-users.0fc77b35.chunk.js → admin-users.4af49ccf.chunk.js} +2 -2
  56. package/build/{api-tokens-create-page.973d2816.chunk.js → api-tokens-create-page.65411a36.chunk.js} +1 -1
  57. package/build/{api-tokens-edit-page.29725c5e.chunk.js → api-tokens-edit-page.60312cb6.chunk.js} +1 -1
  58. package/build/{api-tokens-list-page.66c4fbdd.chunk.js → api-tokens-list-page.01a4d5cd.chunk.js} +2 -2
  59. package/build/audit-logs-settings-page.b165679b.chunk.js +16 -0
  60. package/build/content-manager.8cc6c3f9.chunk.js +1094 -0
  61. package/build/content-type-builder-list-view.58f9ed20.chunk.js +211 -0
  62. package/build/{content-type-builder-translation-en-json.af293c9e.chunk.js → content-type-builder-translation-en-json.f592325b.chunk.js} +1 -1
  63. package/build/content-type-builder.baeb0413.chunk.js +132 -0
  64. package/build/{email-settings-page.63f269ff.chunk.js → email-settings-page.8caad83f.chunk.js} +1 -1
  65. package/build/en-json.a8f34002.chunk.js +1 -0
  66. package/build/i18n-settings-page.579d5eab.chunk.js +9 -0
  67. package/build/i18n-translation-en-json.1ec7becf.chunk.js +1 -0
  68. package/build/index.html +1 -1
  69. package/build/main.1d678f7b.js +2926 -0
  70. package/build/{review-workflows-settings.56cab253.chunk.js → review-workflows-settings.3a7bae25.chunk.js} +2 -2
  71. package/build/{runtime~main.0dfc909e.js → runtime~main.9dbd4553.js} +2 -2
  72. package/build/{sso-settings-page.265e3d72.chunk.js → sso-settings-page.4bb073e0.chunk.js} +1 -1
  73. package/build/{transfer-tokens-create-page.170acee6.chunk.js → transfer-tokens-create-page.9ec277d7.chunk.js} +1 -1
  74. package/build/{transfer-tokens-edit-page.6cf23295.chunk.js → transfer-tokens-edit-page.fa5ade14.chunk.js} +1 -1
  75. package/build/{transfer-tokens-list-page.c3fec4c1.chunk.js → transfer-tokens-list-page.5d68d590.chunk.js} +2 -2
  76. package/build/{upload-settings.1d187578.chunk.js → upload-settings.2c1565d6.chunk.js} +1 -1
  77. package/build/{upload.bc340679.chunk.js → upload.257b2aef.chunk.js} +1 -1
  78. package/build/{users-advanced-settings-page.7b4bf63a.chunk.js → users-advanced-settings-page.ddd29040.chunk.js} +1 -1
  79. package/build/{users-email-settings-page.035a026c.chunk.js → users-email-settings-page.717e2a51.chunk.js} +1 -1
  80. package/build/{users-providers-settings-page.6873dce9.chunk.js → users-providers-settings-page.c7eae829.chunk.js} +1 -1
  81. package/build/{users-roles-settings-page.2549794b.chunk.js → users-roles-settings-page.63cf2838.chunk.js} +1 -1
  82. package/build/webhook-edit-page.8576742e.chunk.js +31 -0
  83. package/build/{webhook-list-page.0861d3e9.chunk.js → webhook-list-page.abf5747c.chunk.js} +1 -1
  84. package/ee/admin/pages/SettingsPage/pages/Webhooks/EditView/components/EventTable/EventTableEE.js +23 -0
  85. package/ee/admin/pages/SettingsPage/pages/Webhooks/EditView/components/EventTable/index.js +3 -0
  86. package/package.json +13 -13
  87. package/admin/src/content-manager/components/DynamicTable/ConfirmDialogDeleteAll/index.js +0 -73
  88. package/admin/src/content-manager/components/DynamicZone/utils/connect.js +0 -12
  89. package/admin/src/content-manager/components/DynamicZone/utils/select.js +0 -53
  90. package/admin/src/content-manager/components/Inputs/utils/getStep.js +0 -13
  91. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventInput/EventRow.js +0 -70
  92. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventInput/index.js +0 -174
  93. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/keys.js +0 -39
  94. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/utils/fieldsRegex.js +0 -4
  95. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/utils/schema.js +0 -35
  96. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/reducer.js +0 -100
  97. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/utils/formatData.js +0 -20
  98. package/build/462.6f8cbd19.chunk.js +0 -71
  99. package/build/617.0518c0ba.chunk.js +0 -155
  100. package/build/6858.85d76858.chunk.js +0 -50
  101. package/build/6970.6a329e15.chunk.js +0 -1
  102. package/build/9036.f7ce35cc.chunk.js +0 -211
  103. package/build/Admin-authenticatedApp.e7ca2959.chunk.js +0 -79
  104. package/build/audit-logs-settings-page.6bc76e7d.chunk.js +0 -121
  105. package/build/content-manager.8bfce7f0.chunk.js +0 -1123
  106. package/build/content-type-builder-list-view.26aab6f3.chunk.js +0 -215
  107. package/build/content-type-builder.b10576e7.chunk.js +0 -126
  108. package/build/en-json.ba3290b8.chunk.js +0 -1
  109. package/build/i18n-settings-page.2ac4ca58.chunk.js +0 -114
  110. package/build/i18n-translation-en-json.60af6722.chunk.js +0 -1
  111. package/build/main.aca47de6.js +0 -2633
  112. package/build/webhook-edit-page.0bc97587.chunk.js +0 -128
@@ -1,4 +1,4 @@
1
- "use strict";(self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[4121],{32393:function(R,E,t){t.r(E),t.d(E,{default:function(){return ce}});var e=t(32735),s=t(24989),c=t(83983),h=t(53038),f=t(67879),p=t(20108),T=t(94638),D=t(96709),S=t(27649),i=t(82055),P=t(99223),m=t(49372),I=t(41415),q=t(17e3),U=t(72850),_=t(56755),ee=t(73269),te=t(33827),K=t(94547),r=t(19786),V=t(82884),ne=t(3685),ae=t(35658),k=t(87933),b=t(74512),F=t(8471);const j=F.ZP.div`
1
+ "use strict";(self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[4121],{32393:function(R,E,t){t.r(E),t.d(E,{default:function(){return ce}});var e=t(32735),s=t(69262),c=t(83983),h=t(53038),f=t(67879),p=t(20108),T=t(94638),D=t(96709),S=t(27649),i=t(82055),P=t(99223),m=t(49372),I=t(41415),q=t(17e3),U=t(72850),_=t(56755),ee=t(73269),te=t(33827),K=t(94547),r=t(19786),V=t(82884),ne=t(3685),ae=t(35658),k=t(87933),b=t(74512),F=t(8471);const j=F.ZP.div`
2
2
  background: ${({theme:o})=>o.colors.danger500};
3
3
  border: none;
4
4
  border-radius: 16px;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+
3
+ import EventTable from '../../../../../../../../../admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/Events';
4
+
5
+ // const events = {
6
+ // 'review-workflows': ['workflows.updateEntryStage'],
7
+ // };
8
+
9
+ // TODO: extend this to support review workflow events once the BE logic is ready
10
+ // const getHeaders = () => {
11
+ // return [{ id: 'review-workflows.updateEntryStage', defaultMessage: 'Stage Change' }];
12
+ // };
13
+
14
+ export function EventTableEE() {
15
+ return (
16
+ <EventTable.Root>
17
+ <EventTable.Headers />
18
+ <EventTable.Body />
19
+ {/* <EventTable.Headers getHeaders={getHeaders} />
20
+ <EventTable.Body providedEvents={events} /> */}
21
+ </EventTable.Root>
22
+ );
23
+ }
@@ -0,0 +1,3 @@
1
+ import { EventTableEE } from './EventTableEE';
2
+
3
+ export default EventTableEE;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/admin",
3
- "version": "4.11.0-exp.9xg4-3qfm-9w8f.1",
3
+ "version": "4.11.0",
4
4
  "description": "Strapi Admin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,15 +48,15 @@
48
48
  "@casl/ability": "^5.4.3",
49
49
  "@fingerprintjs/fingerprintjs": "3.4.1",
50
50
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
51
- "@strapi/babel-plugin-switch-ee-ce": "4.11.0-exp.9xg4-3qfm-9w8f.1",
52
- "@strapi/data-transfer": "4.11.0-exp.9xg4-3qfm-9w8f.1",
53
- "@strapi/design-system": "1.7.10",
54
- "@strapi/helper-plugin": "4.11.0-exp.9xg4-3qfm-9w8f.1",
55
- "@strapi/icons": "1.7.10",
56
- "@strapi/permissions": "4.11.0-exp.9xg4-3qfm-9w8f.1",
57
- "@strapi/provider-audit-logs-local": "4.11.0-exp.9xg4-3qfm-9w8f.1",
58
- "@strapi/typescript-utils": "4.11.0-exp.9xg4-3qfm-9w8f.1",
59
- "@strapi/utils": "4.11.0-exp.9xg4-3qfm-9w8f.1",
51
+ "@strapi/babel-plugin-switch-ee-ce": "4.11.0",
52
+ "@strapi/data-transfer": "4.11.0",
53
+ "@strapi/design-system": "1.8.0",
54
+ "@strapi/helper-plugin": "4.11.0",
55
+ "@strapi/icons": "1.8.0",
56
+ "@strapi/permissions": "4.11.0",
57
+ "@strapi/provider-audit-logs-local": "4.11.0",
58
+ "@strapi/typescript-utils": "4.11.0",
59
+ "@strapi/utils": "4.11.0",
60
60
  "axios": "1.4.0",
61
61
  "babel-loader": "^9.1.2",
62
62
  "babel-plugin-styled-components": "2.1.1",
@@ -67,7 +67,7 @@
67
67
  "chokidar": "^3.5.1",
68
68
  "codemirror5": "npm:codemirror@^5.65.11",
69
69
  "cross-env": "^7.0.3",
70
- "css-loader": "^6.7.3",
70
+ "css-loader": "^6.8.1",
71
71
  "date-fns": "2.30.0",
72
72
  "dotenv": "8.5.1",
73
73
  "esbuild-loader": "^2.21.0",
@@ -130,7 +130,7 @@
130
130
  "sift": "16.0.1",
131
131
  "style-loader": "3.3.1",
132
132
  "styled-components": "5.3.3",
133
- "typescript": "5.0.4",
133
+ "typescript": "5.1.3",
134
134
  "webpack": "^5.82.0",
135
135
  "webpack-cli": "^5.1.0",
136
136
  "webpack-dev-server": "^4.15.0",
@@ -163,5 +163,5 @@
163
163
  }
164
164
  }
165
165
  },
166
- "gitHead": "54c4fa25b2706612f85aaf103f54c071c281f23b"
166
+ "gitHead": "0de06a008d1dfbe67ebfee3562cc8ca0603d2255"
167
167
  }
@@ -1,73 +0,0 @@
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;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
-
3
- function connect(WrappedComponent, select) {
4
- return (props) => {
5
- // eslint-disable-next-line react/prop-types
6
- const selectors = select(props.name);
7
-
8
- return <WrappedComponent {...props} {...selectors} />;
9
- };
10
- }
11
-
12
- export default connect;
@@ -1,53 +0,0 @@
1
- import { useMemo } from 'react';
2
- import get from 'lodash/get';
3
- import { useCMEditViewDataManager } from '@strapi/helper-plugin';
4
-
5
- function useSelect(name) {
6
- const {
7
- addComponentToDynamicZone,
8
- createActionAllowedFields,
9
- isCreatingEntry,
10
- formErrors,
11
- modifiedData,
12
- moveComponentField,
13
- removeComponentFromDynamicZone,
14
- readActionAllowedFields,
15
- updateActionAllowedFields,
16
- } = useCMEditViewDataManager();
17
-
18
- const dynamicDisplayedComponents = useMemo(
19
- () =>
20
- get(modifiedData, [name], []).map((data) => {
21
- return {
22
- componentUid: data.__component,
23
- id: data.id ?? data.__temp_key__,
24
- };
25
- }),
26
- [modifiedData, name]
27
- );
28
-
29
- const isFieldAllowed = useMemo(() => {
30
- const allowedFields = isCreatingEntry ? createActionAllowedFields : updateActionAllowedFields;
31
-
32
- return allowedFields.includes(name);
33
- }, [name, isCreatingEntry, createActionAllowedFields, updateActionAllowedFields]);
34
-
35
- const isFieldReadable = useMemo(() => {
36
- const allowedFields = isCreatingEntry ? [] : readActionAllowedFields;
37
-
38
- return allowedFields.includes(name);
39
- }, [name, isCreatingEntry, readActionAllowedFields]);
40
-
41
- return {
42
- addComponentToDynamicZone,
43
- formErrors,
44
- isCreatingEntry,
45
- isFieldAllowed,
46
- isFieldReadable,
47
- moveComponentField,
48
- removeComponentFromDynamicZone,
49
- dynamicDisplayedComponents,
50
- };
51
- }
52
-
53
- export default useSelect;
@@ -1,13 +0,0 @@
1
- const getStep = (type) => {
2
- let step;
3
-
4
- if (type === 'float' || type === 'decimal') {
5
- step = 0.01;
6
- } else {
7
- step = 1;
8
- }
9
-
10
- return step;
11
- };
12
-
13
- export default getStep;
@@ -1,70 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { BaseCheckbox, Checkbox } from '@strapi/design-system';
4
- import upperFirst from 'lodash/upperFirst';
5
-
6
- const EventRow = ({ disabledEvents, name, events, inputValue, handleChange, handleChangeAll }) => {
7
- const enabledCheckboxes = events.filter((event) => {
8
- return !disabledEvents.includes(event);
9
- });
10
-
11
- const areAllCheckboxesSelected = inputValue.length === enabledCheckboxes.length;
12
- const hasSomeCheckboxSelected = inputValue.length > 0;
13
-
14
- const onChangeAll = ({ target: { name } }) => {
15
- const valueToSet = !areAllCheckboxesSelected;
16
-
17
- handleChangeAll({
18
- target: { name, value: valueToSet },
19
- });
20
- };
21
-
22
- return (
23
- <tr>
24
- <td>
25
- <Checkbox
26
- indeterminate={hasSomeCheckboxSelected && !areAllCheckboxesSelected}
27
- aria-label="Select all entries"
28
- name={name}
29
- onChange={onChangeAll}
30
- value={areAllCheckboxesSelected}
31
- >
32
- {upperFirst(name)}
33
- </Checkbox>
34
- </td>
35
-
36
- {events.map((event) => {
37
- return (
38
- <td key={event}>
39
- <BaseCheckbox
40
- disabled={disabledEvents.includes(event)}
41
- aria-label={event}
42
- name={event}
43
- value={inputValue.includes(event)}
44
- onValueChange={(value) => handleChange({ target: { name: event, value } })}
45
- />
46
- </td>
47
- );
48
- })}
49
- </tr>
50
- );
51
- };
52
-
53
- EventRow.defaultProps = {
54
- disabledEvents: [],
55
- events: [],
56
- inputValue: [],
57
- handleChange() {},
58
- handleChangeAll() {},
59
- };
60
-
61
- EventRow.propTypes = {
62
- disabledEvents: PropTypes.array,
63
- events: PropTypes.array,
64
- inputValue: PropTypes.array,
65
- handleChange: PropTypes.func,
66
- handleChangeAll: PropTypes.func,
67
- name: PropTypes.string.isRequired,
68
- };
69
-
70
- export default EventRow;
@@ -1,174 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { FieldLabel, Flex, Typography } from '@strapi/design-system';
4
- import { useFormikContext } from 'formik';
5
- import { useIntl } from 'react-intl';
6
- import styled from 'styled-components';
7
- import EventRow from './EventRow';
8
-
9
- export const formatValue = (value) =>
10
- value.reduce((acc, curr) => {
11
- const key = curr.split('.')[0];
12
-
13
- if (!acc[key]) {
14
- acc[key] = [];
15
- }
16
- acc[key].push(curr);
17
-
18
- return acc;
19
- }, {});
20
-
21
- const StyledTable = styled.table`
22
- td {
23
- height: ${52 / 16}rem;
24
- width: 10%;
25
- vertical-align: middle;
26
- text-align: center;
27
- }
28
-
29
- tbody tr:nth-child(odd) {
30
- background: ${({ theme }) => theme.colors.neutral100};
31
- }
32
-
33
- tbody tr td:first-child {
34
- padding-left: ${({ theme }) => theme.spaces[7]};
35
- }
36
- `;
37
-
38
- const displayedData = {
39
- headers: {
40
- default: [
41
- { id: 'Settings.webhooks.events.create', defaultMessage: 'Create' },
42
- { id: 'Settings.webhooks.events.update', defaultMessage: 'Update' },
43
- { id: 'app.utils.delete', defaultMessage: 'Delete' },
44
- ],
45
- draftAndPublish: [
46
- { id: 'Settings.webhooks.events.create', defaultMessage: 'Create' },
47
- { id: 'Settings.webhooks.events.update', defaultMessage: 'Update' },
48
- { id: 'app.utils.delete', defaultMessage: 'Delete' },
49
- { id: 'app.utils.publish', defaultMessage: 'Publish' },
50
- { id: 'app.utils.unpublish', defaultMessage: 'Unpublish' },
51
- ],
52
- },
53
- events: {
54
- default: {
55
- entry: ['entry.create', 'entry.update', 'entry.delete'],
56
- media: ['media.create', 'media.update', 'media.delete'],
57
- },
58
- draftAndPublish: {
59
- entry: ['entry.create', 'entry.update', 'entry.delete', 'entry.publish', 'entry.unpublish'],
60
- media: ['media.create', 'media.update', 'media.delete'],
61
- },
62
- },
63
- };
64
-
65
- const EventInput = ({ isDraftAndPublish }) => {
66
- const headersName = isDraftAndPublish
67
- ? displayedData.headers.draftAndPublish
68
- : displayedData.headers.default;
69
-
70
- const events = isDraftAndPublish
71
- ? displayedData.events.draftAndPublish
72
- : displayedData.events.default;
73
-
74
- const { formatMessage } = useIntl();
75
- const { values, handleChange: onChange } = useFormikContext();
76
-
77
- const inputName = 'events';
78
- const inputValue = values.events;
79
-
80
- const disabledEvents = [];
81
-
82
- const formattedValue = formatValue(inputValue);
83
-
84
- const handleChange = ({ target: { name, value } }) => {
85
- let set = new Set(inputValue);
86
-
87
- if (value) {
88
- set.add(name);
89
- } else {
90
- set.delete(name);
91
- }
92
- onChange({ target: { name: inputName, value: Array.from(set) } });
93
- };
94
-
95
- const handleChangeAll = ({ target: { name, value } }) => {
96
- let set = new Set(inputValue);
97
-
98
- if (value) {
99
- events[name].forEach((event) => {
100
- if (!disabledEvents.includes(event)) {
101
- set.add(event);
102
- }
103
- });
104
- } else {
105
- events[name].forEach((event) => set.delete(event));
106
- }
107
- onChange({ target: { name: inputName, value: Array.from(set) } });
108
- };
109
-
110
- return (
111
- <Flex direction="column" alignItems="stretch" gap={1}>
112
- <FieldLabel>
113
- {formatMessage({
114
- id: 'Settings.webhooks.form.events',
115
- defaultMessage: 'Events',
116
- })}
117
- </FieldLabel>
118
- <StyledTable>
119
- <thead>
120
- <tr>
121
- <td />
122
- {headersName.map((header) => {
123
- if (header === 'app.utils.publish' || header === 'app.utils.unpublish') {
124
- return (
125
- <td
126
- key={header.id}
127
- title={formatMessage({
128
- id: 'Settings.webhooks.event.publish-tooltip',
129
- defaultMessage:
130
- 'This event only exists for content with draft & publish enabled',
131
- })}
132
- >
133
- <Typography variant="sigma" textColor="neutral600">
134
- {formatMessage(header)}
135
- </Typography>
136
- </td>
137
- );
138
- }
139
-
140
- return (
141
- <td key={header.id}>
142
- <Typography variant="sigma" textColor="neutral600">
143
- {formatMessage(header)}
144
- </Typography>
145
- </td>
146
- );
147
- })}
148
- </tr>
149
- </thead>
150
- <tbody>
151
- {Object.keys(events).map((event) => {
152
- return (
153
- <EventRow
154
- disabledEvents={disabledEvents}
155
- key={event}
156
- name={event}
157
- events={events[event]}
158
- inputValue={formattedValue[event]}
159
- handleChange={handleChange}
160
- handleChangeAll={handleChangeAll}
161
- />
162
- );
163
- })}
164
- </tbody>
165
- </StyledTable>
166
- </Flex>
167
- );
168
- };
169
-
170
- EventInput.propTypes = {
171
- isDraftAndPublish: PropTypes.bool.isRequired,
172
- };
173
-
174
- export default EventInput;
@@ -1,39 +0,0 @@
1
- const keys = [
2
- 'A-IM',
3
- 'Accept',
4
- 'Accept-Charset',
5
- 'Accept-Encoding',
6
- 'Accept-Language',
7
- 'Accept-Datetime',
8
- 'Access-Control-Request-Method',
9
- 'Access-Control-Request-Headers',
10
- 'Authorization',
11
- 'Cache-Control',
12
- 'Connection',
13
- 'Content-Length',
14
- 'Content-Type',
15
- 'Cookie',
16
- 'Date',
17
- 'Expect',
18
- 'Forwarded',
19
- 'From',
20
- 'Host',
21
- 'If-Match',
22
- 'If-Modified-Since',
23
- 'If-None-Match',
24
- 'If-Range',
25
- 'If-Unmodified-Since',
26
- 'Max-Forwards',
27
- 'Origin',
28
- 'Pragma',
29
- 'Proxy-Authorization',
30
- 'Range',
31
- 'Referer',
32
- 'TE',
33
- 'User-Agent',
34
- 'Upgrade',
35
- 'Via',
36
- 'Warning',
37
- ];
38
-
39
- export default keys;
@@ -1,4 +0,0 @@
1
- const NAME_REGEX = /(^$)|(^[A-Za-z][_0-9A-Za-z ]*$)/;
2
- const URL_REGEX = /(^$)|((https?:\/\/.*)(d*)\/?(.*))/;
3
-
4
- export { NAME_REGEX, URL_REGEX };
@@ -1,35 +0,0 @@
1
- import * as yup from 'yup';
2
- import { translatedErrors } from '@strapi/helper-plugin';
3
- import { NAME_REGEX, URL_REGEX } from './fieldsRegex';
4
-
5
- const schema = yup.object().shape({
6
- name: yup
7
- .string(translatedErrors.string)
8
- .required(translatedErrors.required)
9
- .matches(NAME_REGEX, translatedErrors.regex),
10
- url: yup
11
- .string(translatedErrors.string)
12
- .required(translatedErrors.required)
13
- .matches(URL_REGEX, translatedErrors.regex),
14
- headers: yup.lazy((array) => {
15
- let baseSchema = yup.array();
16
-
17
- if (array.length === 1) {
18
- const { key, value } = array[0];
19
-
20
- if (!key && !value) {
21
- return baseSchema;
22
- }
23
- }
24
-
25
- return baseSchema.of(
26
- yup.object().shape({
27
- key: yup.string().required(translatedErrors.required),
28
- value: yup.string().required(translatedErrors.required),
29
- })
30
- );
31
- }),
32
- events: yup.array(),
33
- });
34
-
35
- export default schema;
@@ -1,100 +0,0 @@
1
- import produce from 'immer';
2
- import get from 'lodash/get';
3
- import set from 'lodash/set';
4
-
5
- const header = { key: '', value: '' };
6
-
7
- const initialWebhook = {
8
- events: [],
9
- headers: [header],
10
- name: '',
11
- url: '',
12
- };
13
-
14
- const initialState = {
15
- formErrors: {},
16
- initialData: initialWebhook,
17
- isTriggering: false,
18
- modifiedData: initialWebhook,
19
- isLoading: true,
20
- triggerResponse: {},
21
- };
22
-
23
- const reducer = (state, action) =>
24
- // eslint-disable-next-line consistent-return
25
- produce(state, (draftState) => {
26
- switch (action.type) {
27
- case 'ADD_NEW_HEADER': {
28
- draftState.modifiedData.headers.push(header);
29
- break;
30
- }
31
- case 'GET_DATA_SUCCEEDED': {
32
- const headers = get(action, ['data', 'headers'], {});
33
- let formattedHeaders = [header];
34
-
35
- if (Object.keys(headers).length > 0) {
36
- formattedHeaders = Object.keys(headers).map((key) => {
37
- return { key, value: headers[key] };
38
- });
39
- }
40
-
41
- const data = { ...action.data, headers: formattedHeaders };
42
-
43
- draftState.isLoading = false;
44
- draftState.initialData = data;
45
- draftState.modifiedData = data;
46
-
47
- break;
48
- }
49
- case 'ON_CHANGE': {
50
- set(draftState, ['modifiedData', ...action.keys], action.value);
51
- break;
52
- }
53
- case 'ON_HEADER_REMOVE': {
54
- const nextHeaders = state.modifiedData.headers.filter((_, index) => index !== action.index);
55
-
56
- if (!nextHeaders.length) {
57
- nextHeaders.push(header);
58
- }
59
-
60
- draftState.modifiedData.headers = nextHeaders;
61
- break;
62
- }
63
- case 'ON_TRIGGER_CANCELED': {
64
- draftState.isTriggering = false;
65
- draftState.triggerResponse = {};
66
-
67
- break;
68
- }
69
- case 'RESET_FORM': {
70
- draftState.modifiedData = state.initialData;
71
- break;
72
- }
73
- case 'SET_ERRORS': {
74
- draftState.formErrors = action.errors;
75
- break;
76
- }
77
- case 'SET_IS_TRIGGERING': {
78
- draftState.isTriggering = !state.isTriggering;
79
- break;
80
- }
81
- case 'SUBMIT_SUCCEEDED': {
82
- draftState.initialData = state.modifiedData;
83
- break;
84
- }
85
- case 'TRIGGER_SUCCEEDED': {
86
- draftState.triggerResponse = action.response;
87
- draftState.isTriggering = false;
88
- break;
89
- }
90
- case 'UNSET_LOADER': {
91
- draftState.isLoading = false;
92
- break;
93
- }
94
- default:
95
- return draftState;
96
- }
97
- });
98
-
99
- export default reducer;
100
- export { initialState };