@strapi/admin 4.11.0-alpha.0 → 4.11.0-beta.1
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/AuthenticatedApp/utils/api.js +5 -4
- package/admin/src/components/Providers/index.js +32 -32
- package/admin/src/components/Theme/index.js +5 -3
- package/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js +1 -2
- package/admin/src/content-manager/components/DynamicZone/index.js +1 -1
- package/admin/src/content-manager/components/FieldComponent/index.js +1 -1
- package/admin/src/content-manager/components/Inputs/index.js +19 -12
- package/admin/src/content-manager/components/Inputs/utils/index.js +0 -1
- package/admin/src/content-manager/components/Wysiwyg/WysiwygNav.js +67 -71
- package/admin/src/content-manager/hooks/useFetchContentTypeLayout/index.js +3 -5
- package/admin/src/content-manager/pages/App/useContentManagerInitData.js +2 -3
- package/admin/src/content-manager/pages/ComponentSetttingsView/index.js +2 -5
- package/admin/src/content-manager/pages/EditView/DeleteLink/index.js +1 -1
- package/admin/src/content-manager/pages/EditView/Header/index.js +1 -1
- package/admin/src/content-manager/pages/EditViewLayoutManager/Permissions.js +1 -1
- package/admin/src/content-manager/pages/ListView/index.js +1 -2
- package/admin/src/hooks/index.js +1 -1
- package/admin/src/hooks/marketplace/constants.js +1 -0
- package/admin/src/hooks/{useFetchMarketplacePlugins → marketplace/useFetchMarketplacePlugins}/index.js +21 -1
- package/admin/src/hooks/{useFetchMarketplaceProviders → marketplace/useFetchMarketplaceProviders}/index.js +21 -1
- package/admin/src/hooks/useAdminUsers/__mocks__/index.js +5 -0
- package/admin/src/hooks/useAdminUsers/index.js +1 -0
- package/admin/src/hooks/useAdminUsers/useAdminUsers.js +38 -0
- package/admin/src/hooks/useContentTypes/__mocks__/index.js +6 -0
- package/admin/src/hooks/useContentTypes/index.js +1 -0
- package/admin/src/hooks/useContentTypes/useContentTypes.js +47 -0
- package/admin/src/hooks/useReleaseNotification/utils/api.js +6 -5
- package/admin/src/pages/Admin/Onboarding/index.js +89 -91
- package/admin/src/pages/App/index.js +1 -5
- package/admin/src/pages/AuthPage/components/Register/index.js +3 -4
- package/admin/src/pages/AuthPage/index.js +11 -26
- package/admin/src/pages/HomePage/index.js +3 -2
- package/admin/src/pages/MarketplacePage/components/NpmPackageCard/InstallPluginButton.js +12 -8
- package/admin/src/pages/MarketplacePage/components/NpmPackagesFilters/FiltersPopover.js +39 -41
- package/admin/src/pages/MarketplacePage/utils/useMarketplaceData.js +2 -2
- package/admin/src/pages/SettingsPage/components/Tokens/TokenBox/index.js +28 -26
- package/admin/src/pages/SettingsPage/components/Tokens/TokenDescription/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/urlToFile.js +3 -2
- package/admin/src/pages/SettingsPage/pages/Roles/CreatePage/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/RoleForm/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +36 -26
- package/admin/src/pages/SettingsPage/pages/Users/EditPage/utils/api.js +1 -8
- package/admin/src/pages/SettingsPage/pages/Users/ListPage/ModalForm/index.js +6 -7
- package/admin/src/pages/SettingsPage/pages/Users/ListPage/index.js +54 -63
- package/admin/src/pages/SettingsPage/pages/Users/components/MagicLink/MagicLinkWrapper.js +11 -9
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventInput/index.js +12 -1
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/index.js +2 -2
- package/admin/src/pages/SettingsPage/pages/Webhooks/ListView/index.js +120 -205
- package/admin/src/pages/UseCasePage/index.js +13 -15
- package/admin/src/translations/ar.json +684 -1
- package/admin/src/translations/en.json +12 -9
- package/build/1387.a86ac314.chunk.js +1 -0
- package/build/{1657.45231968.chunk.js → 1657.ca8562dd.chunk.js} +17 -17
- package/build/3081.c2cdfac8.chunk.js +108 -0
- package/build/{3562.57745ccd.chunk.js → 3562.e0b1a0b3.chunk.js} +6 -6
- package/build/456.9b85d4c6.chunk.js +39 -0
- package/build/462.a073ff1f.chunk.js +71 -0
- package/build/{4628.20631dd1.chunk.js → 4628.9cbb6df5.chunk.js} +1 -1
- package/build/5542.002522eb.chunk.js +71 -0
- package/build/5563.79950369.chunk.js +79 -0
- package/build/617.87b2fe96.chunk.js +155 -0
- package/build/6970.7ea35fbd.chunk.js +1 -0
- package/build/7259.5cc67413.chunk.js +1 -0
- package/build/Admin-authenticatedApp.990df65d.chunk.js +79 -0
- package/build/Admin_homePage.107a9fe0.chunk.js +73 -0
- package/build/Admin_marketplace.1436fc2b.chunk.js +55 -0
- package/build/Admin_pluginsPage.e1afd5ed.chunk.js +6 -0
- package/build/{Admin_profilePage.1b337b73.chunk.js → Admin_profilePage.75bc083a.chunk.js} +1 -1
- package/build/Admin_settingsPage.bd715ed3.chunk.js +79 -0
- package/build/{Upload_ConfigureTheView.d429a7fc.chunk.js → Upload_ConfigureTheView.aa64ed9a.chunk.js} +1 -1
- package/build/admin-app.8b102fe2.chunk.js +63 -0
- package/build/{admin-edit-roles-page.d0c9497b.chunk.js → admin-edit-roles-page.0d12b741.chunk.js} +43 -41
- package/build/admin-edit-users.f9ce7844.chunk.js +10 -0
- package/build/admin-roles-list.e8bf9685.chunk.js +31 -0
- package/build/admin-users.751b28b2.chunk.js +34 -0
- package/build/ar-json.f530bc3f.chunk.js +1 -0
- package/build/audit-logs-settings-page.3c6cea81.chunk.js +129 -0
- package/build/content-manager.89099707.chunk.js +1123 -0
- package/build/content-type-builder-list-view.1e821eb9.chunk.js +215 -0
- package/build/content-type-builder-translation-en-json.af293c9e.chunk.js +1 -0
- package/build/content-type-builder.b10576e7.chunk.js +126 -0
- package/build/email-settings-page.4368689f.chunk.js +11 -0
- package/build/en-json.0f5cc115.chunk.js +1 -0
- package/build/i18n-settings-page.7988d872.chunk.js +114 -0
- package/build/index.html +1 -1
- package/build/main.5a232c3d.js +2630 -0
- package/build/review-workflows-settings.4b39b837.chunk.js +61 -0
- package/build/{runtime~main.1074f2bb.js → runtime~main.55d43bd7.js} +2 -2
- package/build/{sso-settings-page.f44d95d8.chunk.js → sso-settings-page.265e3d72.chunk.js} +1 -1
- package/build/upload-settings.63d99bf5.chunk.js +14 -0
- package/build/upload.c50d8c7a.chunk.js +34 -0
- package/build/users-advanced-settings-page.2cfb5d24.chunk.js +9 -0
- package/build/users-email-settings-page.bd6c774a.chunk.js +24 -0
- package/build/users-providers-settings-page.528f0036.chunk.js +29 -0
- package/build/{users-roles-settings-page.eeb3a339.chunk.js → users-roles-settings-page.c773086b.chunk.js} +2 -2
- package/build/webhook-edit-page.ddd5963d.chunk.js +128 -0
- package/build/webhook-list-page.b0f5a02c.chunk.js +71 -0
- package/ee/LICENSE +1 -21
- package/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +1 -2
- package/ee/admin/pages/AuthPage/components/Login/index.js +1 -1
- package/ee/admin/pages/AuthPage/components/Providers/SSOProviders.js +1 -1
- package/ee/admin/pages/AuthPage/components/Providers/index.js +1 -1
- package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/hooks/useAuditLogsData.js +36 -28
- package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/utils/getDisplayedFilters.js +1 -1
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/ReviewWorkflows.js +3 -3
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/hooks/useReviewWorkflows.js +32 -21
- package/ee/admin/pages/SettingsPage/pages/Users/ListPage/ModalForm/utils/formDataModel.js +1 -1
- package/ee/admin/pages/SettingsPage/pages/Users/ListPage/ModalForm/utils/roleSettingsForm.js +1 -1
- package/ee/server/services/audit-logs.js +5 -1
- package/package.json +18 -21
- package/webpack.alias.js +0 -2
- package/admin/src/content-manager/components/Inputs/utils/getStep.js +0 -13
- package/admin/src/hooks/useFetchMarketplacePlugins/utils/api.js +0 -18
- package/admin/src/hooks/useFetchMarketplaceProviders/utils/api.js +0 -18
- package/admin/src/hooks/useModels/index.js +0 -58
- package/admin/src/hooks/useModels/reducer.js +0 -45
- package/admin/src/pages/SettingsPage/pages/Users/ListPage/utils/api.js +0 -20
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventInput/utils/formatValue.js +0 -13
- package/admin/src/pages/SettingsPage/pages/Webhooks/ListView/reducer.js +0 -72
- package/build/1387.84b454d3.chunk.js +0 -1
- package/build/3081.bcf9a12f.chunk.js +0 -108
- package/build/462.8fff7f3b.chunk.js +0 -71
- package/build/5542.b8240e3f.chunk.js +0 -70
- package/build/5563.986609ed.chunk.js +0 -79
- package/build/6404.68405699.chunk.js +0 -100
- package/build/6970.5159b068.chunk.js +0 -1
- package/build/7259.7a48aa2f.chunk.js +0 -1
- package/build/7725.1633e06f.chunk.js +0 -213
- package/build/Admin-authenticatedApp.27a2329f.chunk.js +0 -79
- package/build/Admin_homePage.9f7c0bb1.chunk.js +0 -73
- package/build/Admin_marketplace.5f7b89e5.chunk.js +0 -55
- package/build/Admin_pluginsPage.9e6fa51c.chunk.js +0 -6
- package/build/Admin_settingsPage.9d0419bc.chunk.js +0 -79
- package/build/admin-app.8e1f56bc.chunk.js +0 -63
- package/build/admin-edit-users.2aae89f5.chunk.js +0 -10
- package/build/admin-roles-list.c759daa3.chunk.js +0 -31
- package/build/admin-users.04a823ca.chunk.js +0 -34
- package/build/ar-json.39e54aba.chunk.js +0 -1
- package/build/audit-logs-settings-page.45cb4fb5.chunk.js +0 -76
- package/build/content-manager.cf467ecc.chunk.js +0 -1123
- package/build/content-type-builder-list-view.5ff685ec.chunk.js +0 -214
- package/build/content-type-builder-translation-en-json.5e5f8607.chunk.js +0 -1
- package/build/content-type-builder.4737a30c.chunk.js +0 -126
- package/build/email-settings-page.dc07d518.chunk.js +0 -10
- package/build/en-json.7edb00f6.chunk.js +0 -1
- package/build/i18n-settings-page.8219dd99.chunk.js +0 -60
- package/build/main.14dca275.js +0 -2592
- package/build/review-workflows-settings.6a662ebd.chunk.js +0 -61
- package/build/upload-settings.dd2d987c.chunk.js +0 -13
- package/build/upload.c8479232.chunk.js +0 -33
- package/build/users-advanced-settings-page.c36cfd59.chunk.js +0 -8
- package/build/users-email-settings-page.2716ce8e.chunk.js +0 -23
- package/build/users-providers-settings-page.0d6304a5.chunk.js +0 -28
- package/build/webhook-edit-page.f4db86f3.chunk.js +0 -75
- package/build/webhook-list-page.30d73114.chunk.js +0 -71
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* ListView
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React, { useEffect, useReducer, useRef, useState } from 'react';
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
9
3
|
import { useHistory, useLocation } from 'react-router-dom';
|
|
10
4
|
import { useIntl } from 'react-intl';
|
|
5
|
+
import { useQuery, useMutation } from 'react-query';
|
|
6
|
+
|
|
11
7
|
import {
|
|
12
8
|
useFetchClient,
|
|
13
9
|
useRBAC,
|
|
@@ -19,6 +15,7 @@ import {
|
|
|
19
15
|
onRowClick,
|
|
20
16
|
stopPropagation,
|
|
21
17
|
LinkButton,
|
|
18
|
+
useAPIErrorHandler,
|
|
22
19
|
} from '@strapi/helper-plugin';
|
|
23
20
|
import {
|
|
24
21
|
HeaderLayout,
|
|
@@ -45,212 +42,124 @@ import {
|
|
|
45
42
|
VisuallyHidden,
|
|
46
43
|
} from '@strapi/design-system';
|
|
47
44
|
import { Plus, Pencil, Trash, EmptyDocuments } from '@strapi/icons';
|
|
48
|
-
import reducer, { initialState } from './reducer';
|
|
49
45
|
import adminPermissions from '../../../../../permissions';
|
|
50
46
|
|
|
51
47
|
const ListView = () => {
|
|
52
|
-
const {
|
|
53
|
-
isLoading,
|
|
54
|
-
allowedActions: { canCreate, canRead, canUpdate, canDelete },
|
|
55
|
-
} = useRBAC(adminPermissions.settings.webhooks);
|
|
56
|
-
const toggleNotification = useNotification();
|
|
57
|
-
const isMounted = useRef(true);
|
|
58
|
-
const { formatMessage } = useIntl();
|
|
59
48
|
const [showModal, setShowModal] = useState(false);
|
|
60
|
-
const [
|
|
61
|
-
reducer,
|
|
62
|
-
initialState
|
|
63
|
-
);
|
|
64
|
-
const { notifyStatus } = useNotifyAT();
|
|
65
|
-
|
|
66
|
-
const { get, del, post, put } = useFetchClient();
|
|
49
|
+
const [webhooksToDelete, setWebhooksToDelete] = useState([]);
|
|
67
50
|
|
|
51
|
+
const { formatMessage } = useIntl();
|
|
52
|
+
const { formatAPIError } = useAPIErrorHandler();
|
|
53
|
+
const toggleNotification = useNotification();
|
|
68
54
|
useFocusWhenNavigate();
|
|
69
55
|
const { push } = useHistory();
|
|
70
56
|
const { pathname } = useLocation();
|
|
71
|
-
const rowsCount = webhooks.length;
|
|
72
|
-
const webhooksToDeleteLength = webhooksToDelete.length;
|
|
73
|
-
const getWebhookIndex = (id) => webhooks.findIndex((webhook) => webhook.id === id);
|
|
74
57
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, []);
|
|
58
|
+
const {
|
|
59
|
+
isLoading: isRBACLoading,
|
|
60
|
+
allowedActions: { canCreate, canUpdate, canDelete },
|
|
61
|
+
} = useRBAC(adminPermissions.settings.webhooks);
|
|
62
|
+
const { get, post, put } = useFetchClient();
|
|
63
|
+
const { notifyStatus } = useNotifyAT();
|
|
82
64
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
65
|
+
const QUERY_KEY = 'webhooks';
|
|
66
|
+
const {
|
|
67
|
+
isLoading: isWebhooksLoading,
|
|
68
|
+
data: webhooks,
|
|
69
|
+
error: webhooksError,
|
|
70
|
+
refetch: refetchWebhooks,
|
|
71
|
+
} = useQuery(QUERY_KEY, async () => {
|
|
72
|
+
const {
|
|
73
|
+
data: { data },
|
|
74
|
+
} = await get('/admin/webhooks');
|
|
93
75
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
type: 'GET_DATA_SUCCEEDED',
|
|
97
|
-
data,
|
|
98
|
-
});
|
|
99
|
-
notifyStatus('webhooks have been loaded');
|
|
100
|
-
}
|
|
101
|
-
} catch (err) {
|
|
102
|
-
console.log(err);
|
|
76
|
+
return data;
|
|
77
|
+
});
|
|
103
78
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
dispatch({
|
|
112
|
-
type: 'TOGGLE_LOADING',
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (webhooksError) {
|
|
81
|
+
toggleNotification({
|
|
82
|
+
type: 'warning',
|
|
83
|
+
message: formatAPIError(webhooksError),
|
|
84
|
+
});
|
|
117
85
|
|
|
118
|
-
|
|
119
|
-
fetchWebHooks();
|
|
86
|
+
return;
|
|
120
87
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (webhookToDelete) {
|
|
129
|
-
handleConfirmDeleteOne();
|
|
130
|
-
} else {
|
|
131
|
-
handleConfirmDeleteAll();
|
|
88
|
+
if (webhooks) {
|
|
89
|
+
notifyStatus(
|
|
90
|
+
formatMessage({
|
|
91
|
+
id: 'Settings.webhooks.list.loading.success',
|
|
92
|
+
defaultMessage: 'Webhooks have been loaded',
|
|
93
|
+
})
|
|
94
|
+
);
|
|
132
95
|
}
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const handleConfirmDeleteOne = async () => {
|
|
136
|
-
try {
|
|
137
|
-
await del(`/admin/webhooks/${webhookToDelete}`);
|
|
96
|
+
}, [webhooks, webhooksError, toggleNotification, formatMessage, notifyStatus, formatAPIError]);
|
|
138
97
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
98
|
+
const deleteMutation = useMutation(
|
|
99
|
+
async () => {
|
|
100
|
+
await post('/admin/webhooks/batch-delete', {
|
|
101
|
+
ids: webhooksToDelete,
|
|
142
102
|
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
*/
|
|
147
|
-
if (err.code !== 20) {
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
onError(error) {
|
|
148
106
|
toggleNotification({
|
|
149
107
|
type: 'warning',
|
|
150
|
-
message:
|
|
108
|
+
message: formatAPIError(error),
|
|
151
109
|
});
|
|
152
|
-
|
|
110
|
+
setShowModal(false);
|
|
111
|
+
},
|
|
112
|
+
onSuccess() {
|
|
113
|
+
setWebhooksToDelete([]);
|
|
114
|
+
setShowModal(false);
|
|
115
|
+
refetchWebhooks();
|
|
116
|
+
},
|
|
153
117
|
}
|
|
154
|
-
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const handleConfirmDeleteAll = async () => {
|
|
158
|
-
const body = {
|
|
159
|
-
ids: webhooksToDelete,
|
|
160
|
-
};
|
|
118
|
+
);
|
|
161
119
|
|
|
162
|
-
|
|
163
|
-
|
|
120
|
+
const enabledMutation = useMutation(
|
|
121
|
+
async ({ isEnabled, id }) => {
|
|
122
|
+
const { id: _, ...webhook } = webhooks.find((webhook) => webhook.id === id) ?? {};
|
|
123
|
+
const body = {
|
|
124
|
+
...webhook,
|
|
125
|
+
isEnabled,
|
|
126
|
+
};
|
|
164
127
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
128
|
+
await put(`/admin/webhooks/${id}`, body);
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
onError(error) {
|
|
132
|
+
toggleNotification({
|
|
133
|
+
type: 'warning',
|
|
134
|
+
message: formatAPIError(error),
|
|
168
135
|
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
toggleNotification({
|
|
174
|
-
type: 'warning',
|
|
175
|
-
message: { id: 'notification.error' },
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
setShowModal(false);
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const handleDeleteClick = (id) => {
|
|
184
|
-
setShowModal(true);
|
|
185
|
-
|
|
186
|
-
if (id !== 'all') {
|
|
187
|
-
dispatch({
|
|
188
|
-
type: 'SET_WEBHOOK_TO_DELETE',
|
|
189
|
-
id,
|
|
190
|
-
});
|
|
136
|
+
},
|
|
137
|
+
onSuccess() {
|
|
138
|
+
refetchWebhooks();
|
|
139
|
+
},
|
|
191
140
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const handleEnabledChange = async (value, id) => {
|
|
195
|
-
const webhookIndex = getWebhookIndex(id);
|
|
196
|
-
const initialWebhookProps = webhooks[webhookIndex];
|
|
197
|
-
const keys = [webhookIndex, 'isEnabled'];
|
|
198
|
-
|
|
199
|
-
const body = {
|
|
200
|
-
...initialWebhookProps,
|
|
201
|
-
isEnabled: value,
|
|
202
|
-
};
|
|
141
|
+
);
|
|
203
142
|
|
|
204
|
-
|
|
143
|
+
const confirmDelete = () => deleteMutation.mutate();
|
|
205
144
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
type: 'SET_WEBHOOK_ENABLED',
|
|
209
|
-
keys,
|
|
210
|
-
value,
|
|
211
|
-
});
|
|
145
|
+
const selectAllCheckbox = (selected) =>
|
|
146
|
+
selected ? setWebhooksToDelete(webhooks.map((webhook) => webhook.id)) : setWebhooksToDelete([]);
|
|
212
147
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
type: 'SET_WEBHOOK_ENABLED',
|
|
218
|
-
keys,
|
|
219
|
-
value: !value,
|
|
220
|
-
});
|
|
148
|
+
const selectOneCheckbox = (selected, id) =>
|
|
149
|
+
selected
|
|
150
|
+
? setWebhooksToDelete((prev) => [...prev, id])
|
|
151
|
+
: setWebhooksToDelete((prev) => prev.filter((webhookId) => webhookId !== id));
|
|
221
152
|
|
|
222
|
-
|
|
223
|
-
toggleNotification({
|
|
224
|
-
type: 'warning',
|
|
225
|
-
message: { id: 'notification.error' },
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
};
|
|
153
|
+
const goTo = (to) => push(`${pathname}/${to}`);
|
|
231
154
|
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
});
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
const handleSelectOneCheckbox = (value, id) => {
|
|
239
|
-
dispatch({
|
|
240
|
-
type: 'SET_WEBHOOKS_TO_DELETE',
|
|
241
|
-
value,
|
|
242
|
-
id,
|
|
243
|
-
});
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
const handleGoTo = (to) => {
|
|
247
|
-
push(`${pathname}/${to}`);
|
|
248
|
-
};
|
|
155
|
+
const isLoading = isRBACLoading || isWebhooksLoading;
|
|
156
|
+
const numberOfWebhooks = webhooks?.length ?? 0;
|
|
157
|
+
const webhooksToDeleteLength = webhooksToDelete.length;
|
|
249
158
|
|
|
250
159
|
return (
|
|
251
160
|
<Layout>
|
|
252
161
|
<SettingsPageTitle name="Webhooks" />
|
|
253
|
-
<Main aria-busy={isLoading
|
|
162
|
+
<Main aria-busy={isLoading}>
|
|
254
163
|
<HeaderLayout
|
|
255
164
|
title={formatMessage({ id: 'Settings.webhooks.title', defaultMessage: 'Webhooks' })}
|
|
256
165
|
subtitle={formatMessage({
|
|
@@ -259,7 +168,7 @@ const ListView = () => {
|
|
|
259
168
|
})}
|
|
260
169
|
primaryAction={
|
|
261
170
|
canCreate &&
|
|
262
|
-
!
|
|
171
|
+
!isLoading && (
|
|
263
172
|
<LinkButton startIcon={<Plus />} variant="default" to={`${pathname}/create`} size="S">
|
|
264
173
|
{formatMessage({
|
|
265
174
|
id: 'Settings.webhooks.list.button.add',
|
|
@@ -278,13 +187,13 @@ const ListView = () => {
|
|
|
278
187
|
{
|
|
279
188
|
id: 'Settings.webhooks.to.delete',
|
|
280
189
|
defaultMessage:
|
|
281
|
-
'{webhooksToDeleteLength, plural, one {#
|
|
190
|
+
'{webhooksToDeleteLength, plural, one {# webhook} other {# webhooks}} selected',
|
|
282
191
|
},
|
|
283
192
|
{ webhooksToDeleteLength }
|
|
284
193
|
)}
|
|
285
194
|
</Typography>
|
|
286
195
|
<Button
|
|
287
|
-
onClick={() =>
|
|
196
|
+
onClick={() => setShowModal(true)}
|
|
288
197
|
startIcon={<Trash />}
|
|
289
198
|
size="L"
|
|
290
199
|
variant="danger-light"
|
|
@@ -299,16 +208,16 @@ const ListView = () => {
|
|
|
299
208
|
/>
|
|
300
209
|
)}
|
|
301
210
|
<ContentLayout>
|
|
302
|
-
{isLoading
|
|
211
|
+
{isLoading ? (
|
|
303
212
|
<Box background="neutral0" padding={6} shadow="filterShadow" hasRadius>
|
|
304
213
|
<LoadingIndicatorPage />
|
|
305
214
|
</Box>
|
|
306
|
-
) :
|
|
215
|
+
) : numberOfWebhooks > 0 ? (
|
|
307
216
|
<Table
|
|
308
217
|
colCount={5}
|
|
309
|
-
rowCount={
|
|
218
|
+
rowCount={numberOfWebhooks + 1}
|
|
310
219
|
footer={
|
|
311
|
-
<TFooter onClick={() => (canCreate ?
|
|
220
|
+
<TFooter onClick={() => (canCreate ? goTo('create') : {})} icon={<Plus />}>
|
|
312
221
|
{formatMessage({
|
|
313
222
|
id: 'Settings.webhooks.list.button.add',
|
|
314
223
|
defaultMessage: 'Create new webhook',
|
|
@@ -325,10 +234,10 @@ const ListView = () => {
|
|
|
325
234
|
defaultMessage: 'Select all entries',
|
|
326
235
|
})}
|
|
327
236
|
indeterminate={
|
|
328
|
-
webhooksToDeleteLength > 0 && webhooksToDeleteLength <
|
|
237
|
+
webhooksToDeleteLength > 0 && webhooksToDeleteLength < numberOfWebhooks
|
|
329
238
|
}
|
|
330
|
-
value={webhooksToDeleteLength ===
|
|
331
|
-
onValueChange={
|
|
239
|
+
value={webhooksToDeleteLength === numberOfWebhooks}
|
|
240
|
+
onValueChange={selectAllCheckbox}
|
|
332
241
|
/>
|
|
333
242
|
</Th>
|
|
334
243
|
<Th width="20%">
|
|
@@ -370,7 +279,7 @@ const ListView = () => {
|
|
|
370
279
|
<Tr
|
|
371
280
|
key={webhook.id}
|
|
372
281
|
{...onRowClick({
|
|
373
|
-
fn: () =>
|
|
282
|
+
fn: () => goTo(webhook.id),
|
|
374
283
|
condition: canUpdate,
|
|
375
284
|
})}
|
|
376
285
|
>
|
|
@@ -381,8 +290,7 @@ const ListView = () => {
|
|
|
381
290
|
defaultMessage: 'Select',
|
|
382
291
|
})} ${webhook.name}`}
|
|
383
292
|
value={webhooksToDelete?.includes(webhook.id)}
|
|
384
|
-
onValueChange={(
|
|
385
|
-
id="select"
|
|
293
|
+
onValueChange={(selected) => selectOneCheckbox(selected, webhook.id)}
|
|
386
294
|
name="select"
|
|
387
295
|
/>
|
|
388
296
|
</Td>
|
|
@@ -395,7 +303,7 @@ const ListView = () => {
|
|
|
395
303
|
<Typography textColor="neutral800">{webhook.url}</Typography>
|
|
396
304
|
</Td>
|
|
397
305
|
<Td>
|
|
398
|
-
<Flex
|
|
306
|
+
<Flex>
|
|
399
307
|
<Switch
|
|
400
308
|
onLabel={formatMessage({
|
|
401
309
|
id: 'global.enabled',
|
|
@@ -410,18 +318,21 @@ const ListView = () => {
|
|
|
410
318
|
defaultMessage: 'Status',
|
|
411
319
|
})}`}
|
|
412
320
|
selected={webhook.isEnabled}
|
|
413
|
-
onChange={() =>
|
|
321
|
+
onChange={(e) => {
|
|
322
|
+
e.stopPropagation();
|
|
323
|
+
enabledMutation.mutate({
|
|
324
|
+
isEnabled: !webhook.isEnabled,
|
|
325
|
+
id: webhook.id,
|
|
326
|
+
});
|
|
327
|
+
}}
|
|
414
328
|
visibleLabels
|
|
415
329
|
/>
|
|
416
330
|
</Flex>
|
|
417
331
|
</Td>
|
|
418
332
|
<Td>
|
|
419
|
-
<Flex gap={1}
|
|
333
|
+
<Flex gap={1}>
|
|
420
334
|
{canUpdate && (
|
|
421
335
|
<IconButton
|
|
422
|
-
onClick={() => {
|
|
423
|
-
handleGoTo(webhook.id);
|
|
424
|
-
}}
|
|
425
336
|
label={formatMessage({
|
|
426
337
|
id: 'Settings.webhooks.events.update',
|
|
427
338
|
defaultMessage: 'Update',
|
|
@@ -432,14 +343,17 @@ const ListView = () => {
|
|
|
432
343
|
)}
|
|
433
344
|
{canDelete && (
|
|
434
345
|
<IconButton
|
|
435
|
-
onClick={() =>
|
|
346
|
+
onClick={(e) => {
|
|
347
|
+
e.stopPropagation();
|
|
348
|
+
setWebhooksToDelete([webhook.id]);
|
|
349
|
+
setShowModal(true);
|
|
350
|
+
}}
|
|
436
351
|
label={formatMessage({
|
|
437
|
-
id: '
|
|
438
|
-
defaultMessage: 'Delete',
|
|
352
|
+
id: 'Settings.webhooks.events.delete',
|
|
353
|
+
defaultMessage: 'Delete webhook',
|
|
439
354
|
})}
|
|
440
355
|
icon={<Trash />}
|
|
441
356
|
noBorder
|
|
442
|
-
id={`delete-${webhook.id}`}
|
|
443
357
|
/>
|
|
444
358
|
)}
|
|
445
359
|
</Flex>
|
|
@@ -459,7 +373,7 @@ const ListView = () => {
|
|
|
459
373
|
<Button
|
|
460
374
|
variant="secondary"
|
|
461
375
|
startIcon={<Plus />}
|
|
462
|
-
onClick={() => (canCreate ?
|
|
376
|
+
onClick={() => (canCreate ? goTo('create') : {})}
|
|
463
377
|
>
|
|
464
378
|
{formatMessage({
|
|
465
379
|
id: 'Settings.webhooks.list.button.add',
|
|
@@ -473,8 +387,9 @@ const ListView = () => {
|
|
|
473
387
|
</Main>
|
|
474
388
|
<ConfirmDialog
|
|
475
389
|
isOpen={showModal}
|
|
476
|
-
onToggleDialog={
|
|
477
|
-
onConfirm={
|
|
390
|
+
onToggleDialog={() => setShowModal((prev) => !prev)}
|
|
391
|
+
onConfirm={confirmDelete}
|
|
392
|
+
isConfirmButtonLoading={deleteMutation.isLoading}
|
|
478
393
|
/>
|
|
479
394
|
</Layout>
|
|
480
395
|
);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import axios from 'axios';
|
|
3
2
|
import { useIntl } from 'react-intl';
|
|
4
3
|
import { useHistory } from 'react-router-dom';
|
|
5
4
|
import styled from 'styled-components';
|
|
6
5
|
import { parse } from 'qs';
|
|
7
|
-
import { pxToRem, useNotification, auth } from '@strapi/helper-plugin';
|
|
6
|
+
import { pxToRem, useFetchClient, useNotification, auth } from '@strapi/helper-plugin';
|
|
8
7
|
import {
|
|
9
8
|
Main,
|
|
10
9
|
Flex,
|
|
@@ -74,23 +73,22 @@ const UseCasePage = () => {
|
|
|
74
73
|
const { formatMessage } = useIntl();
|
|
75
74
|
const [role, setRole] = useState();
|
|
76
75
|
const [otherRole, setOtherRole] = useState('');
|
|
76
|
+
const { post } = useFetchClient();
|
|
77
|
+
|
|
77
78
|
const { firstname, email } = auth.getUserInfo();
|
|
78
79
|
const { hasAdmin } = parse(location?.search, { ignoreQueryPrefix: true });
|
|
79
80
|
const isOther = role === 'other';
|
|
80
81
|
|
|
81
|
-
const handleSubmit = (skipPersona) => {
|
|
82
|
+
const handleSubmit = async (event, skipPersona) => {
|
|
83
|
+
event.preventDefault();
|
|
82
84
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
persona: {
|
|
91
|
-
role: skipPersona ? undefined : role,
|
|
92
|
-
otherRole: skipPersona ? undefined : otherRole,
|
|
93
|
-
},
|
|
85
|
+
await post('https://analytics.strapi.io/register', {
|
|
86
|
+
email,
|
|
87
|
+
username: firstname,
|
|
88
|
+
firstAdmin: Boolean(!hasAdmin),
|
|
89
|
+
persona: {
|
|
90
|
+
role: skipPersona ? undefined : role,
|
|
91
|
+
otherRole: skipPersona ? undefined : otherRole,
|
|
94
92
|
},
|
|
95
93
|
});
|
|
96
94
|
|
|
@@ -111,7 +109,7 @@ const UseCasePage = () => {
|
|
|
111
109
|
<UnauthenticatedLayout>
|
|
112
110
|
<Main labelledBy="usecase-title">
|
|
113
111
|
<LayoutContent>
|
|
114
|
-
<form onSubmit={() => handleSubmit(false)}>
|
|
112
|
+
<form onSubmit={(e) => handleSubmit(e, false)}>
|
|
115
113
|
<Flex direction="column" paddingBottom={7}>
|
|
116
114
|
<Logo />
|
|
117
115
|
<Box paddingTop={6} paddingBottom={1} width={pxToRem(250)}>
|