+
+ {}} />
+ |
+
+ {name}
+ |
+
+ {url}
+ |
+
+
+ |
+
+
+
+ setShowModal(!showModal)}
+ popUpWarningType="danger"
+ onConfirm={handleDeleteConfirm}
+ />
+
+ |
+
+ >
);
}
diff --git a/packages/strapi-admin/admin/src/containers/Webhooks/ListView/Wrapper.js b/packages/strapi-admin/admin/src/containers/Webhooks/ListView/Wrapper.js
index 219267c759..c3a959f0ce 100644
--- a/packages/strapi-admin/admin/src/containers/Webhooks/ListView/Wrapper.js
+++ b/packages/strapi-admin/admin/src/containers/Webhooks/ListView/Wrapper.js
@@ -5,7 +5,6 @@
*/
import styled from 'styled-components';
-import { sizes } from 'strapi-helper-plugin';
const Wrapper = styled.div`
> div:first-of-type {
@@ -21,33 +20,6 @@ const Wrapper = styled.div`
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
- table tr {
- td {
- p {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- &:first-of-type {
- padding-left: 30px;
- width: 65px;
- }
- &:nth-of-type(2) {
- max-width: 158px;
- }
- &:nth-of-type(3) {
- max-width: 300px;
- }
- &:nth-of-type(4) {
- min-width: 125px;
- }
- @media (min-width: ${sizes.wide}) {
- &:nth-of-type(3) {
- max-width: 400px;
- }
- }
- }
- }
}
p {
margin-bottom: 0;
diff --git a/packages/strapi-admin/admin/src/containers/Webhooks/ListView/index.js b/packages/strapi-admin/admin/src/containers/Webhooks/ListView/index.js
index 5ef833db18..ee778da2a1 100644
--- a/packages/strapi-admin/admin/src/containers/Webhooks/ListView/index.js
+++ b/packages/strapi-admin/admin/src/containers/Webhooks/ListView/index.js
@@ -29,9 +29,6 @@ function ListView() {
try {
const { data } = await request(`/admin/webhooks`, {
method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
});
dispatch({
@@ -48,6 +45,9 @@ function ListView() {
fetchData();
}, []);
+ const webhookIndex = id => webhooks.findIndex(webhook => webhook.id === id);
+
+ // New button
const addBtnLabel = formatMessage({
id: `Settings.webhooks.list.button.add`,
});
@@ -108,14 +108,28 @@ function ListView() {
};
const handleDeleteClick = id => {
- console.log(id);
+ deleteWebhook(id);
};
- const webhookById = id => webhooks.find(webhook => webhook.id === id);
- const webhookIndex = id => webhooks.findIndex(webhook => webhook.id === id);
+ const deleteWebhook = async id => {
+ try {
+ await request(`/admin/webhooks/${id}`, {
+ method: 'DELETE',
+ });
+
+ dispatch({
+ type: 'WEBHOOK_DELETED',
+ index: webhookIndex(id),
+ });
+ } catch (err) {
+ if (err.code !== 20) {
+ strapi.notification.error('notification.error');
+ }
+ }
+ };
const handleEnabledChange = async (value, id) => {
- const initialWebhookProps = webhookById(id);
+ const initialWebhookProps = webhooks[webhookIndex];
const body = {
...initialWebhookProps,
isEnabled: value,
@@ -124,9 +138,6 @@ function ListView() {
try {
await request(`/admin/webhooks/${id}`, {
method: 'PUT',
- headers: {
- 'Content-Type': 'application/json',
- },
body,
});
diff --git a/packages/strapi-admin/admin/src/containers/Webhooks/ListView/reducer.js b/packages/strapi-admin/admin/src/containers/Webhooks/ListView/reducer.js
index 6f6c7930e4..3161d23590 100644
--- a/packages/strapi-admin/admin/src/containers/Webhooks/ListView/reducer.js
+++ b/packages/strapi-admin/admin/src/containers/Webhooks/ListView/reducer.js
@@ -10,6 +10,14 @@ const reducer = (state, action) => {
return state.update('webhooks', () => fromJS(action.data));
case 'SET_WEBHOOK_ENABLED':
return state.updateIn(['webhooks', ...action.keys], () => action.value);
+ case 'WEBHOOK_DELETED': {
+ console.log(state.get('webhooks'));
+ console.log(action.index);
+
+ return state.update('webhooks', webhooks =>
+ webhooks.splice(action.index, 1)
+ );
+ }
default:
return state;
}