V13: Change WebhookLog status for clarity (#15247)
* Refactor to show icon and status code to make status more clear * Fix up migration * Add change log status migration * Fix up frontend to display cross when fail --------- Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
@@ -101,5 +101,6 @@ public class UmbracoPlan : MigrationPlan
|
||||
To<V_13_0_0.AddWebhookRequest>("{4E652F18-9A29-4656-A899-E3F39069C47E}");
|
||||
To<V_13_0_0.RenameWebhookIdToKey>("{148714C8-FE0D-4553-B034-439D91468761}");
|
||||
To<V_13_0_0.AddWebhookDatabaseLock>("{23BA95A4-FCCE-49B0-8AA1-45312B103A9B}");
|
||||
To<V_13_0_0.ChangeLogStatusCode>("{7DDCE198-9CA4-430C-8BBC-A66D80CA209F}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using System.Net;
|
||||
using NPoco;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Infrastructure.Persistence;
|
||||
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_13_0_0;
|
||||
|
||||
public class ChangeLogStatusCode : MigrationBase
|
||||
{
|
||||
public ChangeLogStatusCode(IMigrationContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Migrate()
|
||||
{
|
||||
if (!TableExists(Constants.DatabaseSchema.Tables.WebhookLog))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Sql<ISqlContext> fetchQuery = Database.SqlContext.Sql()
|
||||
.Select<WebhookLogDto>()
|
||||
.From<WebhookLogDto>();
|
||||
|
||||
// Use a custom SQL query to prevent selecting explicit columns (sortOrder doesn't exist yet)
|
||||
List<WebhookLogDto> webhookLogDtos = Database.Fetch<WebhookLogDto>(fetchQuery);
|
||||
|
||||
Sql<ISqlContext> deleteQuery = Database.SqlContext.Sql()
|
||||
.Delete<WebhookLogDto>();
|
||||
|
||||
Database.Execute(deleteQuery);
|
||||
|
||||
foreach (WebhookLogDto webhookLogDto in webhookLogDtos)
|
||||
{
|
||||
if (Enum.TryParse(webhookLogDto.StatusCode, out HttpStatusCode statusCode))
|
||||
{
|
||||
webhookLogDto.StatusCode = $"{statusCode.ToString()} ({(int)statusCode})";
|
||||
}
|
||||
}
|
||||
|
||||
Database.InsertBatch(webhookLogDtos);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user