webui: make Users summary static, edit shell on expand

Move the per-user shell editor out of the always-visible row into the
expanded detail; the summary now reports the shell as plain text.  This
also fixes the editor showing "bash" for non-bash users: the dropdown
matched the module-prefixed option value against the bare stored shell,
so it never matched and fell back to the first option.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-06-17 10:32:44 +02:00
parent 4d398bbf57
commit 584d6c57df
3 changed files with 35 additions and 15 deletions
+15 -1
View File
@@ -104,13 +104,27 @@ func (h *ConfigureUsersHandler) Overview(w http.ResponseWriter, r *http.Request)
const shellPath = "/ietf-system:system/authentication/user/infix-system:shell"
mgr := h.Schema.Manager()
data.Loading = mgr == nil
var defaultShell string
if mgr != nil {
data.ShellOptions = schema.OptionsFor(mgr, shellPath)
for _, o := range data.ShellOptions {
if o.IsDefault {
defaultShell = o.Label
break
}
}
}
for _, u := range raw.System.Auth.Users {
// Effective shell: the user's explicit shell, else the YANG default.
// Kept bare (no module prefix) so the static cell and the editor's
// selected-option test compare directly against the option .Label.
shell := schema.StripModulePrefix(u.Shell)
if shell == "" {
shell = defaultShell
}
data.Users = append(data.Users, cfgUserDisplay{
cfgUserJSON: u,
ShellLabel: schema.StripModulePrefix(u.Shell),
ShellLabel: shell,
KeyCount: len(u.AuthorizedKeys),
})
}
+1 -2
View File
@@ -2691,13 +2691,12 @@ details.cfg-fold[open] > summary::before { transform: rotate(90deg); }
.btn-add-row:hover { text-decoration: underline; }
/* Inline forms inside users table */
.user-shell-form, .user-add-inline {
.user-add-inline {
display: flex;
align-items: center;
gap: 0.5rem;
flex-wrap: wrap;
}
.user-shell-form .cfg-input { flex: 1; min-width: 0; }
.user-add-inline .cfg-input { width: auto; flex: 1; min-width: 8rem; }
/* Add Interface modal dialog */
+19 -12
View File
@@ -43,17 +43,7 @@
<span class="key-row-arrow" aria-hidden="true"></span>{{.Name}}
</button>
</td>
<td>
<form hx-post="/configure/users/{{.Name}}/shell" hx-swap="none"
class="user-shell-form">
<select class="cfg-input" name="shell">
{{$shell := .Shell}}
{{range $.ShellOptions}}<option value="{{.Value}}" {{if or (eq .Value $shell) (and (eq $shell "") .IsDefault)}}selected{{end}}>{{.Label}}{{if .IsDefault}} (default){{end}}</option>{{end}}
</select>
<button class="btn btn-primary btn-sm" type="submit">Save</button>
<span class="cfg-save-status"></span>
</form>
</td>
<td>{{.ShellLabel}}</td>
<td style="text-align:center">{{.KeyCount}}</td>
<td style="text-align:right">
<button type="button" class="btn-icon btn-icon-danger"
@@ -69,6 +59,21 @@
<td colspan="4" class="key-detail-cell">
<div class="key-detail-body">
{{/* Login shell — match the option's bare .Label against the
user's effective ShellLabel; .Value carries a module prefix
the stored shell does not. */}}
<form hx-post="/configure/users/{{.Name}}/shell" hx-swap="none">
<div class="section-subtitle">Login Shell</div>
<select class="cfg-input" name="shell" style="max-width:16rem">
{{$shell := .ShellLabel}}
{{range $.ShellOptions}}<option value="{{.Value}}" {{if eq .Label $shell}}selected{{end}}>{{.Label}}{{if .IsDefault}} (default){{end}}</option>{{end}}
</select>
<div class="cfg-card-footer" style="padding-left:0">
<button class="btn btn-primary btn-sm" type="submit">Save</button>
<span class="cfg-save-status"></span>
</div>
</form>
{{/* Change password */}}
<form hx-post="/configure/users/{{.Name}}/password" hx-swap="none">
<div class="section-subtitle">Change Password</div>
@@ -145,8 +150,10 @@
{{/* Hidden add-user row — revealed by the + Add user button */}}
<tr id="add-user-row" hidden>
<td colspan="4" class="key-detail-cell">
<form hx-post="/configure/users" hx-swap="none" class="user-add-inline">
<form hx-post="/configure/users" hx-swap="none" class="user-add-inline"
autocomplete="off">
<input class="cfg-input" type="text" name="username" required
autocomplete="off"
pattern="[a-zA-Z0-9_][a-zA-Z0-9_.-]*" placeholder="Username">
<input class="cfg-input" type="password" name="password" required
autocomplete="new-password" placeholder="Password">