Skip to content

Add RemoveDefault() extension method to fluent API for CMS webhook events#15424

Merged
bergmania merged 2 commits intocontribfrom
v13/feature/webhooks-removedefault
Sep 26, 2024
Merged

Add RemoveDefault() extension method to fluent API for CMS webhook events#15424
bergmania merged 2 commits intocontribfrom
v13/feature/webhooks-removedefault

Conversation

@ronaldbarendse
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Description

PR #15345 added a fluent API for adding webhook events, but because the CMS adds a subset of events by default, you had to first clear all events to make sure you only end up with the configured ones. However, if other packages (like Deploy) also add events by default, those will also be cleared.

To address this, I've added a RemoveDefault() extension method, so the following example ensures all CMS default events are removed and only the content ones are added, without affecting other custom/non-CMS events:

using Umbraco.Cms.Core.Composing;

public class WebhookComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
        => builder.WebhookEvents()
            .AddCms(cmsBuilder => cmsBuilder.RemoveDefault().AddContent());
}

@ronaldbarendse
Copy link
Contributor Author

A quick update on this: we've implemented the RemoveDefault() extension method on both Deploy and Forms, so would be nice to have the CMS align on this as well!

Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me and agree it would be nice to have this common method across the products.

@bergmania bergmania merged commit 8f26263 into contrib Sep 26, 2024
@bergmania bergmania deleted the v13/feature/webhooks-removedefault branch September 26, 2024 05:52
bergmania pushed a commit that referenced this pull request Sep 26, 2024
…events (#15424)

* Add RemoveDefault extension method

* Move default webhook event types to single list

(cherry picked from commit 8f26263)
bergmania pushed a commit that referenced this pull request Sep 26, 2024
…events (#15424)

* Add RemoveDefault extension method

* Move default webhook event types to single list

(cherry picked from commit 8f26263)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants