@strapi/admin 4.11.0-exp.push-transfer-push-stuck → 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.
- package/admin/src/components/Providers/index.js +32 -32
- package/admin/src/components/Theme/index.js +5 -3
- package/admin/src/content-manager/components/ComponentIcon/ComponentIcon.js +16 -26
- package/admin/src/content-manager/components/ComponentIcon/constants.js +133 -0
- package/admin/src/content-manager/components/DynamicTable/BulkActionsBar/index.js +307 -0
- package/admin/src/content-manager/components/DynamicTable/index.js +20 -4
- package/admin/src/content-manager/components/DynamicZone/components/AddComponentButton.js +32 -95
- package/admin/src/content-manager/components/DynamicZone/components/ComponentCard.js +10 -2
- package/admin/src/content-manager/components/DynamicZone/components/ComponentCategory.js +63 -15
- package/admin/src/content-manager/components/DynamicZone/components/ComponentPicker.js +50 -63
- package/admin/src/content-manager/components/DynamicZone/components/DynamicComponent.js +132 -58
- package/admin/src/content-manager/components/DynamicZone/components/DynamicZoneLabel.js +29 -37
- package/admin/src/content-manager/components/DynamicZone/index.js +131 -83
- package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +31 -8
- package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +18 -6
- package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/index.js +0 -1
- package/admin/src/content-manager/components/Inputs/index.js +18 -11
- package/admin/src/content-manager/components/Inputs/utils/index.js +0 -1
- package/admin/src/content-manager/pages/EditSettingsView/components/DynamicZoneList.js +7 -1
- package/admin/src/content-manager/pages/EditView/index.js +1 -1
- package/admin/src/content-manager/pages/ListView/index.js +118 -2
- package/admin/src/content-manager/utils/index.js +2 -0
- package/admin/src/content-manager/{components/EditViewDataManagerProvider/utils → utils}/schema.js +1 -1
- package/admin/src/hooks/useContentTypes/useContentTypes.js +0 -2
- package/admin/src/index.js +4 -3
- package/admin/src/injectionZones.js +6 -1
- package/admin/src/pages/SettingsPage/pages/Users/ListPage/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventTable/EventTableCE.js +13 -0
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventTable/index.js +3 -0
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/Events/index.js +331 -0
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/Combobox.js +54 -4
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js +12 -23
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/WebhookForm/index.js +129 -116
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/WebhookForm/utils/makeWebhookValidationSchema.js +62 -0
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/index.js +59 -64
- package/admin/src/translations/ar.json +684 -1
- package/admin/src/translations/en.json +12 -1
- package/build/3562.e0b1a0b3.chunk.js +50 -0
- package/build/371.6e4e2c1f.chunk.js +71 -0
- package/build/5297.31c9ffdc.chunk.js +39 -0
- package/build/5542.64b623c9.chunk.js +63 -0
- package/build/{5563.79950369.chunk.js → 5563.badbffde.chunk.js} +2 -2
- package/build/6691.f7a3b5ac.chunk.js +105 -0
- package/build/6970.d456705f.chunk.js +1 -0
- package/build/{7259.5cc67413.chunk.js → 7259.5d0de931.chunk.js} +1 -1
- package/build/8976.0022f5a3.chunk.js +50 -0
- package/build/{1657.ca8562dd.chunk.js → 9932.5ef475c5.chunk.js} +54 -62
- package/build/Admin-authenticatedApp.ab2b5910.chunk.js +79 -0
- package/build/{Admin_InternalErrorPage.96ceaae1.chunk.js → Admin_InternalErrorPage.f25f04f3.chunk.js} +1 -1
- package/build/Admin_homePage.05063e43.chunk.js +73 -0
- package/build/Admin_marketplace.005d2d5b.chunk.js +55 -0
- package/build/Admin_pluginsPage.5d9d4060.chunk.js +6 -0
- package/build/{Admin_profilePage.a8fa3a56.chunk.js → Admin_profilePage.ab7b94d7.chunk.js} +2 -2
- package/build/Admin_settingsPage.07a6a5f0.chunk.js +79 -0
- package/build/{Upload_ConfigureTheView.aa64ed9a.chunk.js → Upload_ConfigureTheView.121deffb.chunk.js} +1 -1
- package/build/admin-app.7cc667be.chunk.js +63 -0
- package/build/{admin-edit-roles-page.0d12b741.chunk.js → admin-edit-roles-page.bfe3304d.chunk.js} +3 -3
- package/build/{admin-edit-users.f9ce7844.chunk.js → admin-edit-users.6efe0382.chunk.js} +2 -2
- package/build/admin-roles-list.b2577370.chunk.js +23 -0
- package/build/admin-users.4af49ccf.chunk.js +26 -0
- package/build/{api-tokens-create-page.973d2816.chunk.js → api-tokens-create-page.65411a36.chunk.js} +1 -1
- package/build/{api-tokens-edit-page.29725c5e.chunk.js → api-tokens-edit-page.60312cb6.chunk.js} +1 -1
- package/build/{api-tokens-list-page.66c4fbdd.chunk.js → api-tokens-list-page.01a4d5cd.chunk.js} +2 -2
- package/build/ar-json.f530bc3f.chunk.js +1 -0
- package/build/audit-logs-settings-page.b165679b.chunk.js +16 -0
- package/build/content-manager.8cc6c3f9.chunk.js +1094 -0
- package/build/content-type-builder-list-view.58f9ed20.chunk.js +211 -0
- package/build/{content-type-builder-translation-en-json.af293c9e.chunk.js → content-type-builder-translation-en-json.f592325b.chunk.js} +1 -1
- package/build/content-type-builder.baeb0413.chunk.js +132 -0
- package/build/email-settings-page.8caad83f.chunk.js +11 -0
- package/build/en-json.a8f34002.chunk.js +1 -0
- package/build/i18n-settings-page.579d5eab.chunk.js +9 -0
- package/build/i18n-translation-en-json.1ec7becf.chunk.js +1 -0
- package/build/index.html +1 -1
- package/build/main.1d678f7b.js +2926 -0
- package/build/{review-workflows-settings.56cab253.chunk.js → review-workflows-settings.3a7bae25.chunk.js} +2 -2
- package/build/{runtime~main.adbe36a4.js → runtime~main.9dbd4553.js} +2 -2
- package/build/{sso-settings-page.265e3d72.chunk.js → sso-settings-page.4bb073e0.chunk.js} +1 -1
- package/build/{transfer-tokens-create-page.170acee6.chunk.js → transfer-tokens-create-page.9ec277d7.chunk.js} +1 -1
- package/build/{transfer-tokens-edit-page.6cf23295.chunk.js → transfer-tokens-edit-page.fa5ade14.chunk.js} +1 -1
- package/build/{transfer-tokens-list-page.c3fec4c1.chunk.js → transfer-tokens-list-page.5d68d590.chunk.js} +2 -2
- package/build/upload-settings.2c1565d6.chunk.js +14 -0
- package/build/upload.257b2aef.chunk.js +26 -0
- package/build/users-advanced-settings-page.ddd29040.chunk.js +9 -0
- package/build/users-email-settings-page.717e2a51.chunk.js +24 -0
- package/build/users-providers-settings-page.c7eae829.chunk.js +29 -0
- package/build/{users-roles-settings-page.2549794b.chunk.js → users-roles-settings-page.63cf2838.chunk.js} +1 -1
- package/build/webhook-edit-page.8576742e.chunk.js +31 -0
- package/build/webhook-list-page.abf5747c.chunk.js +63 -0
- package/ee/admin/pages/SettingsPage/pages/Webhooks/EditView/components/EventTable/EventTableEE.js +23 -0
- package/ee/admin/pages/SettingsPage/pages/Webhooks/EditView/components/EventTable/index.js +3 -0
- package/ee/server/services/review-workflows/review-workflows.js +4 -0
- package/package.json +22 -24
- package/server/controllers/webhooks.js +6 -6
- package/admin/src/content-manager/components/DynamicTable/ConfirmDialogDeleteAll/index.js +0 -73
- package/admin/src/content-manager/components/DynamicZone/utils/connect.js +0 -12
- package/admin/src/content-manager/components/DynamicZone/utils/select.js +0 -53
- package/admin/src/content-manager/components/Inputs/utils/getStep.js +0 -13
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventInput/EventRow.js +0 -70
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventInput/index.js +0 -174
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/keys.js +0 -39
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/utils/fieldsRegex.js +0 -4
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/utils/schema.js +0 -35
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/reducer.js +0 -100
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/utils/formatData.js +0 -20
- package/build/3081.c2cdfac8.chunk.js +0 -108
- package/build/3816.60f858cf.chunk.js +0 -211
- package/build/462.a073ff1f.chunk.js +0 -71
- package/build/5542.002522eb.chunk.js +0 -71
- package/build/617.87b2fe96.chunk.js +0 -155
- package/build/6858.85d76858.chunk.js +0 -50
- package/build/6970.6a329e15.chunk.js +0 -1
- package/build/Admin-authenticatedApp.d425b485.chunk.js +0 -79
- package/build/Admin_homePage.107a9fe0.chunk.js +0 -73
- package/build/Admin_marketplace.717bd7ca.chunk.js +0 -55
- package/build/Admin_pluginsPage.7df6b5a9.chunk.js +0 -6
- package/build/Admin_settingsPage.1394aaf2.chunk.js +0 -79
- package/build/admin-app.ac5b1f59.chunk.js +0 -63
- package/build/admin-roles-list.e8bf9685.chunk.js +0 -31
- package/build/admin-users.751b28b2.chunk.js +0 -34
- package/build/ar-json.39e54aba.chunk.js +0 -1
- package/build/audit-logs-settings-page.3c6cea81.chunk.js +0 -129
- package/build/content-manager.70548048.chunk.js +0 -1123
- package/build/content-type-builder-list-view.1e821eb9.chunk.js +0 -215
- package/build/content-type-builder.b10576e7.chunk.js +0 -126
- package/build/email-settings-page.dba83275.chunk.js +0 -11
- package/build/en-json.d965e364.chunk.js +0 -1
- package/build/i18n-settings-page.55628f74.chunk.js +0 -114
- package/build/i18n-translation-en-json.60af6722.chunk.js +0 -1
- package/build/main.d9d9ed10.js +0 -2630
- package/build/upload-settings.63d99bf5.chunk.js +0 -14
- package/build/upload.c50d8c7a.chunk.js +0 -34
- package/build/users-advanced-settings-page.4f49ca57.chunk.js +0 -9
- package/build/users-email-settings-page.d2429d0a.chunk.js +0 -24
- package/build/users-providers-settings-page.50c5ba27.chunk.js +0 -29
- package/build/webhook-edit-page.ddd5963d.chunk.js +0 -128
- package/build/webhook-list-page.e2fca9f8.chunk.js +0 -71
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useFormikContext } from 'formik';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import {
|
|
8
|
+
FieldLabel,
|
|
9
|
+
Flex,
|
|
10
|
+
Typography,
|
|
11
|
+
BaseCheckbox,
|
|
12
|
+
Checkbox,
|
|
13
|
+
Loader,
|
|
14
|
+
RawTable as Table,
|
|
15
|
+
RawTh as Th,
|
|
16
|
+
RawTd as Td,
|
|
17
|
+
RawTr as Tr,
|
|
18
|
+
RawThead as Thead,
|
|
19
|
+
RawTbody as Tbody,
|
|
20
|
+
VisuallyHidden,
|
|
21
|
+
} from '@strapi/design-system';
|
|
22
|
+
|
|
23
|
+
import { useContentTypes } from '../../../../../../../hooks/useContentTypes';
|
|
24
|
+
|
|
25
|
+
export const formatValue = (value) =>
|
|
26
|
+
value.reduce((acc, curr) => {
|
|
27
|
+
const key = curr.split('.')[0];
|
|
28
|
+
|
|
29
|
+
if (!acc[key]) {
|
|
30
|
+
acc[key] = [];
|
|
31
|
+
}
|
|
32
|
+
acc[key].push(curr);
|
|
33
|
+
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
|
|
37
|
+
// TODO check whether we want to move alternating background colour tables to the design system
|
|
38
|
+
const StyledTable = styled(Table)`
|
|
39
|
+
tbody tr:nth-child(odd) {
|
|
40
|
+
background: ${({ theme }) => theme.colors.neutral100};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
thead th span {
|
|
44
|
+
color: ${({ theme }) => theme.colors.neutral500};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
td,
|
|
48
|
+
th {
|
|
49
|
+
padding-block-start: ${({ theme }) => theme.spaces[3]};
|
|
50
|
+
padding-block-end: ${({ theme }) => theme.spaces[3]};
|
|
51
|
+
width: 10%;
|
|
52
|
+
vertical-align: middle;
|
|
53
|
+
text-align: center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
tbody tr td:first-child {
|
|
57
|
+
// Add padding to the start of the first column to avoid the checkbox appearing
|
|
58
|
+
// too close to the edge of the table
|
|
59
|
+
padding-inline-start: ${({ theme }) => theme.spaces[2]};
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const getCEHeaders = (isDraftAndPublish) => {
|
|
64
|
+
const headers = [
|
|
65
|
+
{ id: 'Settings.webhooks.events.create', defaultMessage: 'Create' },
|
|
66
|
+
{ id: 'Settings.webhooks.events.update', defaultMessage: 'Update' },
|
|
67
|
+
{ id: 'app.utils.delete', defaultMessage: 'Delete' },
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
if (isDraftAndPublish) {
|
|
71
|
+
headers.push({ id: 'app.utils.publish', defaultMessage: 'Publish' });
|
|
72
|
+
headers.push({ id: 'app.utils.unpublish', defaultMessage: 'Unpublish' });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return headers;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const getCEEvents = (isDraftAndPublish) => {
|
|
79
|
+
const entryEvents = ['entry.create', 'entry.update', 'entry.delete'];
|
|
80
|
+
|
|
81
|
+
if (isDraftAndPublish) {
|
|
82
|
+
entryEvents.push('entry.publish', 'entry.unpublish');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
entry: entryEvents,
|
|
87
|
+
media: ['media.create', 'media.update', 'media.delete'],
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const WebhookEventContext = React.createContext();
|
|
92
|
+
|
|
93
|
+
const Root = ({ children }) => {
|
|
94
|
+
const { formatMessage } = useIntl();
|
|
95
|
+
const { collectionTypes, isLoading } = useContentTypes();
|
|
96
|
+
|
|
97
|
+
const isDraftAndPublish = React.useMemo(
|
|
98
|
+
() => collectionTypes.some((ct) => ct.options.draftAndPublish === true),
|
|
99
|
+
[collectionTypes]
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const label = formatMessage({
|
|
103
|
+
id: 'Settings.webhooks.form.events',
|
|
104
|
+
defaultMessage: 'Events',
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<WebhookEventContext.Provider value={{ isDraftAndPublish }}>
|
|
109
|
+
<Flex direction="column" alignItems="stretch" gap={1}>
|
|
110
|
+
<FieldLabel aria-hidden>{label}</FieldLabel>
|
|
111
|
+
{isLoading && (
|
|
112
|
+
<Loader>
|
|
113
|
+
{formatMessage({
|
|
114
|
+
id: 'Settings.webhooks.events.isLoading',
|
|
115
|
+
defaultMessage: 'Events loading',
|
|
116
|
+
})}
|
|
117
|
+
</Loader>
|
|
118
|
+
)}
|
|
119
|
+
<StyledTable aria-label={label}>{children}</StyledTable>
|
|
120
|
+
</Flex>
|
|
121
|
+
</WebhookEventContext.Provider>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
Root.propTypes = {
|
|
126
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const Headers = ({ getHeaders = getCEHeaders }) => {
|
|
130
|
+
const { isDraftAndPublish } = React.useContext(WebhookEventContext);
|
|
131
|
+
|
|
132
|
+
const { formatMessage } = useIntl();
|
|
133
|
+
const headers = getHeaders(isDraftAndPublish);
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<Thead>
|
|
137
|
+
<Tr>
|
|
138
|
+
<Th>
|
|
139
|
+
<VisuallyHidden>
|
|
140
|
+
{formatMessage({
|
|
141
|
+
id: 'Settings.webhooks.event.select',
|
|
142
|
+
defaultMessage: 'Select event',
|
|
143
|
+
})}
|
|
144
|
+
</VisuallyHidden>
|
|
145
|
+
</Th>
|
|
146
|
+
{headers.map((header) => {
|
|
147
|
+
if (['app.utils.publish', 'app.utils.unpublish'].includes(header.id)) {
|
|
148
|
+
return (
|
|
149
|
+
<Th
|
|
150
|
+
key={header.id}
|
|
151
|
+
title={formatMessage({
|
|
152
|
+
id: 'Settings.webhooks.event.publish-tooltip',
|
|
153
|
+
defaultMessage: 'This event only exists for content with draft & publish enabled',
|
|
154
|
+
})}
|
|
155
|
+
>
|
|
156
|
+
<Typography variant="sigma" textColor="neutral600">
|
|
157
|
+
{formatMessage(header)}
|
|
158
|
+
</Typography>
|
|
159
|
+
</Th>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<Th key={header.id}>
|
|
165
|
+
<Typography variant="sigma" textColor="neutral600">
|
|
166
|
+
{formatMessage(header)}
|
|
167
|
+
</Typography>
|
|
168
|
+
</Th>
|
|
169
|
+
);
|
|
170
|
+
})}
|
|
171
|
+
</Tr>
|
|
172
|
+
</Thead>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
Headers.defaultProps = {
|
|
177
|
+
getHeaders: getCEHeaders,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
Headers.propTypes = {
|
|
181
|
+
getHeaders: PropTypes.func,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const Body = ({ providedEvents }) => {
|
|
185
|
+
const { isDraftAndPublish } = React.useContext(WebhookEventContext);
|
|
186
|
+
|
|
187
|
+
const events = providedEvents || getCEEvents(isDraftAndPublish);
|
|
188
|
+
const { values, handleChange: onChange } = useFormikContext();
|
|
189
|
+
|
|
190
|
+
const inputName = 'events';
|
|
191
|
+
const inputValue = values.events;
|
|
192
|
+
const disabledEvents = [];
|
|
193
|
+
|
|
194
|
+
const formattedValue = formatValue(inputValue);
|
|
195
|
+
|
|
196
|
+
const handleSelect = ({ target: { name, value } }) => {
|
|
197
|
+
let set = new Set(inputValue);
|
|
198
|
+
|
|
199
|
+
if (value) {
|
|
200
|
+
set.add(name);
|
|
201
|
+
} else {
|
|
202
|
+
set.delete(name);
|
|
203
|
+
}
|
|
204
|
+
onChange({ target: { name: inputName, value: Array.from(set) } });
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const handleSelectAll = ({ target: { name, value } }) => {
|
|
208
|
+
let set = new Set(inputValue);
|
|
209
|
+
|
|
210
|
+
if (value) {
|
|
211
|
+
events[name].forEach((event) => {
|
|
212
|
+
if (!disabledEvents.includes(event)) {
|
|
213
|
+
set.add(event);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
} else {
|
|
217
|
+
events[name].forEach((event) => set.delete(event));
|
|
218
|
+
}
|
|
219
|
+
onChange({ target: { name: inputName, value: Array.from(set) } });
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<Tbody>
|
|
224
|
+
{Object.entries(events).map(([event, value]) => {
|
|
225
|
+
return (
|
|
226
|
+
<EventRow
|
|
227
|
+
disabledEvents={disabledEvents}
|
|
228
|
+
key={event}
|
|
229
|
+
name={event}
|
|
230
|
+
events={value}
|
|
231
|
+
inputValue={formattedValue[event]}
|
|
232
|
+
handleSelect={handleSelect}
|
|
233
|
+
handleSelectAll={handleSelectAll}
|
|
234
|
+
/>
|
|
235
|
+
);
|
|
236
|
+
})}
|
|
237
|
+
</Tbody>
|
|
238
|
+
);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
Body.defaultProps = {
|
|
242
|
+
providedEvents: null,
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
Body.propTypes = {
|
|
246
|
+
providedEvents: PropTypes.object,
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Converts a string to title case and removes hyphens.
|
|
251
|
+
*
|
|
252
|
+
* @param {string} str - The string to convert.
|
|
253
|
+
* @returns {string} The converted string.
|
|
254
|
+
*/
|
|
255
|
+
const removeHyphensAndTitleCase = (str) =>
|
|
256
|
+
str
|
|
257
|
+
.replace(/-/g, ' ')
|
|
258
|
+
.split(' ')
|
|
259
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
260
|
+
.join(' ');
|
|
261
|
+
|
|
262
|
+
const EventRow = ({ disabledEvents, name, events, inputValue, handleSelect, handleSelectAll }) => {
|
|
263
|
+
const { formatMessage } = useIntl();
|
|
264
|
+
const enabledCheckboxes = events.filter((event) => !disabledEvents.includes(event));
|
|
265
|
+
|
|
266
|
+
const hasSomeCheckboxSelected = inputValue.length > 0;
|
|
267
|
+
const areAllCheckboxesSelected = inputValue.length === enabledCheckboxes.length;
|
|
268
|
+
|
|
269
|
+
const onChangeAll = ({ target: { name } }) => {
|
|
270
|
+
const valueToSet = !areAllCheckboxesSelected;
|
|
271
|
+
|
|
272
|
+
handleSelectAll({
|
|
273
|
+
target: { name, value: valueToSet },
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const targetColumns = 5;
|
|
278
|
+
|
|
279
|
+
return (
|
|
280
|
+
<Tr>
|
|
281
|
+
<Td>
|
|
282
|
+
<Checkbox
|
|
283
|
+
indeterminate={hasSomeCheckboxSelected && !areAllCheckboxesSelected}
|
|
284
|
+
aria-label={formatMessage({
|
|
285
|
+
id: 'global.select-all-entries',
|
|
286
|
+
defaultMessage: 'Select all entries',
|
|
287
|
+
})}
|
|
288
|
+
name={name}
|
|
289
|
+
onChange={onChangeAll}
|
|
290
|
+
value={areAllCheckboxesSelected}
|
|
291
|
+
>
|
|
292
|
+
{removeHyphensAndTitleCase(name)}
|
|
293
|
+
</Checkbox>
|
|
294
|
+
</Td>
|
|
295
|
+
|
|
296
|
+
{events.map((event) => {
|
|
297
|
+
return (
|
|
298
|
+
<Td key={event}>
|
|
299
|
+
<BaseCheckbox
|
|
300
|
+
disabled={disabledEvents.includes(event)}
|
|
301
|
+
aria-label={event}
|
|
302
|
+
name={event}
|
|
303
|
+
value={inputValue.includes(event)}
|
|
304
|
+
onValueChange={(value) => handleSelect({ target: { name: event, value } })}
|
|
305
|
+
/>
|
|
306
|
+
</Td>
|
|
307
|
+
);
|
|
308
|
+
})}
|
|
309
|
+
{events.length < targetColumns && <Td colSpan={`${targetColumns - events.length}`} />}
|
|
310
|
+
</Tr>
|
|
311
|
+
);
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
EventRow.defaultProps = {
|
|
315
|
+
disabledEvents: [],
|
|
316
|
+
events: [],
|
|
317
|
+
inputValue: [],
|
|
318
|
+
handleSelect() {},
|
|
319
|
+
handleSelectAll() {},
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
EventRow.propTypes = {
|
|
323
|
+
disabledEvents: PropTypes.array,
|
|
324
|
+
events: PropTypes.array,
|
|
325
|
+
inputValue: PropTypes.array,
|
|
326
|
+
handleSelect: PropTypes.func,
|
|
327
|
+
handleSelectAll: PropTypes.func,
|
|
328
|
+
name: PropTypes.string.isRequired,
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
export default { Root, Headers, Body, EventRow };
|
package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/Combobox.js
CHANGED
|
@@ -1,10 +1,59 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import { useFormikContext } from 'formik';
|
|
3
4
|
import { ComboboxOption, CreatableCombobox } from '@strapi/design-system';
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
const HTTP_HEADERS = [
|
|
7
|
+
'A-IM',
|
|
8
|
+
'Accept',
|
|
9
|
+
'Accept-Charset',
|
|
10
|
+
'Accept-Encoding',
|
|
11
|
+
'Accept-Language',
|
|
12
|
+
'Accept-Datetime',
|
|
13
|
+
'Access-Control-Request-Method',
|
|
14
|
+
'Access-Control-Request-Headers',
|
|
15
|
+
'Authorization',
|
|
16
|
+
'Cache-Control',
|
|
17
|
+
'Connection',
|
|
18
|
+
'Content-Length',
|
|
19
|
+
'Content-Type',
|
|
20
|
+
'Cookie',
|
|
21
|
+
'Date',
|
|
22
|
+
'Expect',
|
|
23
|
+
'Forwarded',
|
|
24
|
+
'From',
|
|
25
|
+
'Host',
|
|
26
|
+
'If-Match',
|
|
27
|
+
'If-Modified-Since',
|
|
28
|
+
'If-None-Match',
|
|
29
|
+
'If-Range',
|
|
30
|
+
'If-Unmodified-Since',
|
|
31
|
+
'Max-Forwards',
|
|
32
|
+
'Origin',
|
|
33
|
+
'Pragma',
|
|
34
|
+
'Proxy-Authorization',
|
|
35
|
+
'Range',
|
|
36
|
+
'Referer',
|
|
37
|
+
'TE',
|
|
38
|
+
'User-Agent',
|
|
39
|
+
'Upgrade',
|
|
40
|
+
'Via',
|
|
41
|
+
'Warning',
|
|
42
|
+
];
|
|
5
43
|
|
|
6
44
|
const Combobox = ({ name, onChange, value, ...props }) => {
|
|
7
|
-
const
|
|
45
|
+
const {
|
|
46
|
+
values: { headers },
|
|
47
|
+
} = useFormikContext();
|
|
48
|
+
const [options, setOptions] = useState(HTTP_HEADERS);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
setOptions(
|
|
52
|
+
HTTP_HEADERS.filter(
|
|
53
|
+
(key) => !headers?.some((header) => header.key !== value && header.key === key)
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
}, [headers, value]);
|
|
8
57
|
|
|
9
58
|
const handleChange = (value) => {
|
|
10
59
|
onChange({ target: { name, value } });
|
|
@@ -13,12 +62,13 @@ const Combobox = ({ name, onChange, value, ...props }) => {
|
|
|
13
62
|
const handleCreateOption = (value) => {
|
|
14
63
|
setOptions((prev) => [...prev, value]);
|
|
15
64
|
|
|
16
|
-
|
|
65
|
+
handleChange(value);
|
|
17
66
|
};
|
|
18
67
|
|
|
19
68
|
return (
|
|
20
69
|
<CreatableCombobox
|
|
21
70
|
{...props}
|
|
71
|
+
onClear={() => handleChange('')}
|
|
22
72
|
onChange={handleChange}
|
|
23
73
|
onCreateOption={handleCreateOption}
|
|
24
74
|
placeholder=""
|
package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js
CHANGED
|
@@ -32,25 +32,19 @@ const HeadersInput = () => {
|
|
|
32
32
|
name="headers"
|
|
33
33
|
render={({ push, remove }) => (
|
|
34
34
|
<Grid gap={4}>
|
|
35
|
-
{values.headers
|
|
35
|
+
{values.headers.map((header, index) => (
|
|
36
36
|
// eslint-disable-next-line
|
|
37
|
-
<React.Fragment key={
|
|
37
|
+
<React.Fragment key={`${index}.${header.key}`}>
|
|
38
38
|
<GridItem col={6}>
|
|
39
39
|
<Field
|
|
40
40
|
as={Combobox}
|
|
41
|
-
name={`headers.${
|
|
42
|
-
aria-label={`row ${
|
|
41
|
+
name={`headers.${index}.key`}
|
|
42
|
+
aria-label={`row ${index + 1} key`}
|
|
43
43
|
label={formatMessage({
|
|
44
44
|
id: 'Settings.webhooks.key',
|
|
45
45
|
defaultMessage: 'Key',
|
|
46
46
|
})}
|
|
47
|
-
error={
|
|
48
|
-
errors.headers?.[i]?.key &&
|
|
49
|
-
formatMessage({
|
|
50
|
-
id: errors.headers[i]?.key,
|
|
51
|
-
defaultMessage: errors.headers[i]?.key,
|
|
52
|
-
})
|
|
53
|
-
}
|
|
47
|
+
error={errors.headers?.[index]?.key && errors.headers[index].key}
|
|
54
48
|
/>
|
|
55
49
|
</GridItem>
|
|
56
50
|
<GridItem col={6}>
|
|
@@ -58,34 +52,29 @@ const HeadersInput = () => {
|
|
|
58
52
|
<Box style={{ flex: 1 }}>
|
|
59
53
|
<Field
|
|
60
54
|
as={TextInput}
|
|
61
|
-
|
|
55
|
+
name={`headers.${index}.value`}
|
|
56
|
+
aria-label={`row ${index + 1} value`}
|
|
62
57
|
label={formatMessage({
|
|
63
58
|
id: 'Settings.webhooks.value',
|
|
64
59
|
defaultMessage: 'Value',
|
|
65
60
|
})}
|
|
66
|
-
|
|
67
|
-
error={
|
|
68
|
-
errors.headers?.[i]?.value &&
|
|
69
|
-
formatMessage({
|
|
70
|
-
id: errors.headers[i]?.value,
|
|
71
|
-
defaultMessage: errors.headers[i]?.value,
|
|
72
|
-
})
|
|
73
|
-
}
|
|
61
|
+
error={errors.headers?.[index]?.value && errors.headers[index].value}
|
|
74
62
|
/>
|
|
75
63
|
</Box>
|
|
76
64
|
<Flex
|
|
77
65
|
paddingLeft={2}
|
|
78
66
|
style={{ alignSelf: 'center' }}
|
|
79
|
-
paddingTop={errors.headers?.[
|
|
67
|
+
paddingTop={errors.headers?.[index]?.value ? 0 : 5}
|
|
80
68
|
>
|
|
81
69
|
<RemoveRoundedButton
|
|
82
|
-
|
|
70
|
+
disabled={values.headers.length === 1}
|
|
71
|
+
onClick={() => remove(index)}
|
|
83
72
|
label={formatMessage(
|
|
84
73
|
{
|
|
85
74
|
id: 'Settings.webhooks.headers.remove',
|
|
86
75
|
defaultMessage: 'Remove header row {number}',
|
|
87
76
|
},
|
|
88
|
-
{ number:
|
|
77
|
+
{ number: index + 1 }
|
|
89
78
|
)}
|
|
90
79
|
/>
|
|
91
80
|
</Flex>
|