18b61bed52
- Widen AdminCandidateEditorModal to size lg for better readability - Rename "Clip-Compilation" section to "Clip / Compilation", update copy to reflect single clips too, drop upload hint and Clip-Plattform field, rename label to "Link" - Fix NativeSelect dropdown clipping inside overflow-y-auto modals by teleporting the menu to body with fixed positioning, flip-up logic, and dynamic maxHeight capped to viewport - Add ClipAdminMenuVisible setting (backend domain, contracts, endpoint, migration) with matching frontend types, defaults, form wiring, and toggle in the Clip-Workflow modal — hides the Clips nav item from the admin sidebar when disabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
88 lines
3.1 KiB
C#
88 lines
3.1 KiB
C#
using Backend.Common;
|
|
using Backend.Contracts;
|
|
using Backend.Data;
|
|
using Backend.Services;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Backend.Endpoints;
|
|
|
|
public static partial class AdminSeasonManagementEndpoints
|
|
{
|
|
private static async Task<IResult> GetWorkflowRules(AwardsDbContext db)
|
|
{
|
|
var settings = await db.SiteSettings
|
|
.AsNoTracking()
|
|
.FirstOrDefaultAsync(item => item.Id == 1);
|
|
if (settings is null)
|
|
{
|
|
return Results.NotFound();
|
|
}
|
|
|
|
return Results.Ok(new AdminWorkflowRulesResponse(WorkflowRuleSettings.Read(settings).Select(ToWorkflowRuleDto).ToArray()));
|
|
}
|
|
|
|
private static async Task<IResult> UpdateWorkflowRules(
|
|
HttpContext context,
|
|
UpdateWorkflowRulesRequest request,
|
|
AwardsDbContext db,
|
|
IAdminAuditService adminAuditService)
|
|
{
|
|
var session = AdminEndpointConventions.CurrentSession(context);
|
|
var settings = await db.SiteSettings.FirstOrDefaultAsync(item => item.Id == 1);
|
|
if (settings is null)
|
|
{
|
|
return Results.NotFound();
|
|
}
|
|
|
|
var before = WorkflowRuleSettings.Read(settings);
|
|
var mergedRules = WorkflowRuleSettings.Defaults
|
|
.Select(defaultRule =>
|
|
{
|
|
var requestRule = request.Rules.FirstOrDefault(item => item.Key == defaultRule.Key);
|
|
return requestRule is null
|
|
? defaultRule
|
|
: new WorkflowRuleSetting(
|
|
defaultRule.Key,
|
|
defaultRule.Label,
|
|
requestRule.Enabled,
|
|
requestRule.Limit,
|
|
requestRule.Mode,
|
|
defaultRule.Description);
|
|
})
|
|
.ToArray();
|
|
|
|
settings.WorkflowRulesJson = WorkflowRuleSettings.Serialize(mergedRules);
|
|
var after = WorkflowRuleSettings.Read(settings);
|
|
var changes = after
|
|
.Select(rule =>
|
|
{
|
|
var previous = before.First(item => item.Key == rule.Key);
|
|
return new
|
|
{
|
|
field = rule.Key,
|
|
label = rule.Label,
|
|
from = $"{previous.Enabled}/{previous.Limit}/{previous.Mode}",
|
|
to = $"{rule.Enabled}/{rule.Limit}/{rule.Mode}",
|
|
sensitive = false,
|
|
};
|
|
})
|
|
.Where(change => change.from != change.to)
|
|
.ToArray();
|
|
|
|
adminAuditService.AddEntry(
|
|
session.TwitchUserId,
|
|
"workflow-rules.update",
|
|
"site-settings",
|
|
settings.Id.ToString(),
|
|
"Workflow-Regeln wurden aktualisiert.",
|
|
new { changes },
|
|
RequestMetadataReader.Read(context));
|
|
|
|
await db.SaveChangesAsync(context.RequestAborted);
|
|
return Results.Ok(new AdminWorkflowRulesResponse(after.Select(ToWorkflowRuleDto).ToArray()));
|
|
}
|
|
|
|
private static AdminWorkflowRuleDto ToWorkflowRuleDto(WorkflowRuleSetting rule) =>
|
|
new(rule.Key, rule.Label, rule.Enabled, rule.Limit, rule.Mode, rule.Description);
|
|
}
|