dosubot[bot] commented on issue #8001:
URL:
https://github.com/apache/incubator-devlake/issues/8001#issuecomment-2329299998
<!-- Answer -->
To address the issue where removing a webhook from a project deletes the
webhook entirely in version v1.0.1-beta7, you can use the `handleDelete`
function provided in the `WebhooksPanel` component. This function updates the
project's blueprint by filtering out the specific webhook connection without
deleting the webhook itself.
Here is the relevant code snippet:
```tsx
const handleDelete = async (id: ID) => {
const payload = {
...project.blueprint,
connections: project.blueprint.connections.filter(
(cs) => !(cs.pluginName === 'webhook' && cs.connectionId === id),
),
};
const [success] = await operator(() =>
API.blueprint.update(project.blueprint.id, payload), {
setOperating,
});
if (success) {
onRefresh();
}
};
```
This function constructs a new payload for the blueprint by excluding the
webhook connection with the specified `id` and then updates the blueprint using
the `API.blueprint.update` method. If the update is successful, it triggers a
refresh of the project data
<sup>[[1]](https://github.com/apache/incubator-devlake/blob/main/config-ui/src/routes/project/detail/webhooks-panel.tsx)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]