V13: Add eventype to webhookevents (#15157)

* Refactor IWebhookEvent to contain event type.

* refactor frontend to filter on eventType.

* Display event names

* refactor to use eventNames

* remove npm from overview

* implement alias for WebhookEvents

* Implement [WebhookEvent] attribute

* Refactor IWebhookService to get by event alias and not name

* Rename parameter to fit method name

* to lower event type to avoid casing issues

* Apply suggestions from code review

Co-authored-by: Ronald Barendse <ronald@barend.se>

* Change event names from constants to hard coded. And give more friendly names

* Refactor to not use event names, where it was not intended

* Add renaming column migration

* display event alias in logs

* Update migration to check if old column is there

* Apply suggestions from code review

Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>

* add determineResource function to avoid duplicate code

---------

Co-authored-by: Zeegaan <nge@umbraco.dk>
Co-authored-by: Ronald Barendse <ronald@barend.se>
Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>
This commit is contained in:
Nikolaj Geisle
2023-11-09 14:18:34 +01:00
committed by GitHub
parent 1fcb96288f
commit 7bde16b4ef
40 changed files with 329 additions and 145 deletions

View File

@@ -10,7 +10,6 @@ public class WebhookMapDefinition : IMapDefinition
public void DefineMaps(IUmbracoMapper mapper)
{
mapper.Define<WebhookViewModel, Webhook>((_, _) => new Webhook(string.Empty), Map);
mapper.Define<Webhook, WebhookViewModel>((_, _) => new WebhookViewModel(), Map);
mapper.Define<IWebhookEvent, WebhookEventViewModel>((_, _) => new WebhookEventViewModel(), Map);
mapper.Define<WebhookLog, WebhookLogViewModel>((_, _) => new WebhookLogViewModel(), Map);
}
@@ -19,7 +18,7 @@ public class WebhookMapDefinition : IMapDefinition
private void Map(WebhookViewModel source, Webhook target, MapperContext context)
{
target.ContentTypeKeys = source.ContentTypeKeys;
target.Events = source.Events;
target.Events = source.Events.Select(x => x.Alias).ToArray();
target.Url = source.Url;
target.Enabled = source.Enabled;
target.Key = source.Key ?? Guid.NewGuid();
@@ -27,24 +26,18 @@ public class WebhookMapDefinition : IMapDefinition
}
// Umbraco.Code.MapAll
private void Map(Webhook source, WebhookViewModel target, MapperContext context)
private void Map(IWebhookEvent source, WebhookEventViewModel target, MapperContext context)
{
target.ContentTypeKeys = source.ContentTypeKeys;
target.Events = source.Events;
target.Url = source.Url;
target.Enabled = source.Enabled;
target.Key = source.Key;
target.Headers = source.Headers;
target.EventName = source.EventName;
target.EventType = source.EventType;
target.Alias = source.Alias;
}
// Umbraco.Code.MapAll
private void Map(IWebhookEvent source, WebhookEventViewModel target, MapperContext context) => target.EventName = source.EventName;
// Umbraco.Code.MapAll
private void Map(WebhookLog source, WebhookLogViewModel target, MapperContext context)
{
target.Date = source.Date;
target.EventName = source.EventName;
target.EventAlias = source.EventAlias;
target.Key = source.Key;
target.RequestBody = source.RequestBody ?? string.Empty;
target.ResponseBody = source.ResponseBody;