Hey Victor! Extending UI pages can be done with page extenders. I answered this same question pretty recently and wrote up this sample code:
[assembly: PageExtender(typeof(EventLogExtender))]
namespace MySite
{
public class EventLogExtender(IHttpContextAccessor httpContextAccessor) : PageExtender<EventLogList>
{
public override Task ConfigurePage()
{
Page.PageConfiguration.HeaderActions.AddCommand("Clear log", nameof(Clear));
return base.ConfigurePage();
}
[PageCommand]
public async Task<ICommandResponse> Clear()
{
var authenticatedUserAccessor = httpContextAccessor.HttpContext.RequestServices.GetRequiredService<IAuthenticatedUserAccessor>();
var user = await authenticatedUserAccessor.Get();
EventLogHelper.ClearEventLog(user.UserID, user.UserName, httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString());
return Response().UseCommand("LoadData").AddSuccessMessage("Event log cleared");
}
}
}
This also logs a "Log cleared" event after the button click (like we did in K13) so you can audit who is clearing the Event log. I find that I can usually guess the class that I need to reference in PageExtender<T>
but if you're not sure, you can find the backend template in System > UI Tree:
