fix(ui): name role grant fields and wrap security details

This commit is contained in:
Joseph Doherty
2026-11-14 01:55:00 -05:00
parent ef1609f523
commit 455c874875
11 changed files with 791 additions and 21 deletions
@@ -49,12 +49,12 @@ else
else if (!Directory.Exists(store.Path))
{
<div style="padding:1rem" class="text-muted">
<span class="mono">@store.Path</span> doesn't exist yet. It will be created on first boot.
<span class="mono text-break">@store.Path</span> doesn't exist yet. It will be created on first boot.
</div>
}
else if (store.Certificates.Count == 0)
{
<div style="padding:1rem" class="text-muted">No certificates in <span class="mono">@store.Path</span>.</div>
<div style="padding:1rem" class="text-muted">No certificates in <span class="mono text-break">@store.Path</span>.</div>
}
else
{
@@ -22,13 +22,13 @@
<section class="card-grid rise" style="animation-delay:.02s">
<div class="metric-card">
<h2 class="panel-head">LDAP binding</h2>
<div class="kv"><span class="k">Enabled</span><span class="v">@(_options.Enabled ? "yes" : "no")</span></div>
<div class="kv"><span class="k">Server</span><span class="v mono">@_options.Server:@_options.Port</span></div>
<div class="kv"><span class="k">Transport</span><span class="v">@_options.Transport</span></div>
<div class="kv"><span class="k">SearchBase</span><span class="v mono small" title="@_options.SearchBase">@DisplayText.Abbreviate(_options.SearchBase, 48)</span></div>
<div class="kv flex-wrap" style="row-gap:.25rem"><span class="k">Enabled</span><span class="v text-break" style="min-width:0;max-width:100%">@(_options.Enabled ? "yes" : "no")</span></div>
<div class="kv flex-wrap" style="row-gap:.25rem"><span class="k">Server</span><span class="v mono text-break" style="min-width:0;max-width:100%">@_options.Server:@_options.Port</span></div>
<div class="kv flex-wrap" style="row-gap:.25rem"><span class="k">Transport</span><span class="v text-break" style="min-width:0;max-width:100%">@_options.Transport</span></div>
<div class="kv flex-wrap" style="row-gap:.25rem"><span class="k">SearchBase</span><span class="v mono small text-break" style="min-width:0;max-width:100%" title="@_options.SearchBase">@DisplayText.Abbreviate(_options.SearchBase, 48)</span></div>
@if (_options.Transport == ZB.MOM.WW.Auth.Abstractions.Ldap.LdapTransport.None && _options.AllowInsecure)
{
<div class="kv"><span class="k">Warning</span><span class="v"><span class="chip chip-bad">Plaintext credentials over LDAP — dev mode only</span></span></div>
<div class="kv flex-wrap" style="row-gap:.25rem"><span class="k">Warning</span><span class="v text-break" style="min-width:0;max-width:100%"><span class="chip chip-bad text-wrap">Plaintext credentials over LDAP — dev mode only</span></span></div>
}
</div>
</section>
@@ -37,21 +37,24 @@
<section class="panel rise mt-3" style="animation-delay:.08s">
<h2 class="panel-head">Group → role (database)</h2>
<div style="padding:1rem">
<div class="d-flex gap-2 align-items-center flex-wrap">
<input class="form-control form-control-sm mono" style="max-width:32rem"
@bind="_newGroup" placeholder="cn=fleet-admin,ou=groups,..." />
<select class="form-select form-select-sm" style="max-width:14rem" @bind="_newRole">
@foreach (var role in Enum.GetValues<AdminRole>())
{
<option value="@role">@role</option>
}
</select>
<div class="d-flex gap-2 align-items-end flex-wrap">
<div style="flex:1 1 20rem;max-width:32rem;min-width:0">
<label class="form-label" for='@FieldId("group")'>LDAP group</label>
<input id='@FieldId("group")' aria-describedby='@FieldId("error")' class="form-control form-control-sm mono"
@bind="_newGroup" placeholder="cn=fleet-admin,ou=groups,..." />
</div>
<div style="flex:1 1 12rem;max-width:14rem;min-width:0">
<label class="form-label" for='@FieldId("role")'>Role</label>
<select id='@FieldId("role")' aria-describedby='@FieldId("error")' class="form-select form-select-sm" @bind="_newRole">
@foreach (var role in Enum.GetValues<AdminRole>())
{
<option value="@role">@role</option>
}
</select>
</div>
<button class="btn btn-sm btn-primary" @onclick="AddAsync" disabled="@_busy">Add</button>
</div>
@if (_error is not null)
{
<div class="text-danger small mt-2">@_error</div>
}
<div id='@FieldId("error")' role="alert" hidden="@(_error is null)" class="text-danger small mt-2">@_error</div>
</div>
<div class="table-wrap" role="region" aria-label="Database role grants" tabindex="0">
<table class="data-table">
@@ -87,7 +90,7 @@
<section class="panel rise mt-3" style="animation-delay:.14s">
<h2 class="panel-head">Fallback (appsettings) (@(_options.GroupToRole?.Count ?? 0))</h2>
<div style="padding:1rem 1rem 0" class="text-muted small">
These <span class="mono">Security:Ldap:GroupToRole</span> entries apply when a group has no database row above.
These <span class="mono text-break">Security:Ldap:GroupToRole</span> entries apply when a group has no database row above.
</div>
@if (_options.GroupToRole is null || _options.GroupToRole.Count == 0)
{
@@ -115,6 +118,8 @@
</PageErrorBoundary>
@code {
private readonly string _fieldScope = "ot-role-grants-" + Guid.NewGuid().ToString("N");
private string FieldId(string suffix) => _fieldScope + "-" + suffix;
private LdapOptions? _options;
private IReadOnlyList<LdapGroupRoleMapping> _rows = [];
private string _newGroup = "";