panel: hide domain pick for global administrators on user form
test / test (push) Has been cancelled

Global administrators manage every domain; the assignment checkboxes are
now hidden when that role is selected.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-11 22:37:04 +03:00
parent 9ff7514621
commit 5985977f21
4 changed files with 28 additions and 2 deletions
+2
View File
@@ -21,6 +21,8 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); version
### Changed ### Changed
- panel: the user create/edit form hides **Assigned domains** when the role is
global administrator, since that role manages every domain anyway.
- panel: **Settings** shows panel credentials and DMARC aggregate reports side - panel: **Settings** shows panel credentials and DMARC aggregate reports side
by side for global administrators (the same `.split` layout as a delivery's by side for global administrators (the same `.split` layout as a delivery's
message and history). Domain-scoped users keep the single narrow card. message and history). Domain-scoped users keep the single narrow card.
+1
View File
@@ -128,6 +128,7 @@ func (h *Handlers) renderUserForm(w http.ResponseWriter, r *http.Request, status
data["Error"] = view.FormErr data["Error"] = view.FormErr
data["FormUsername"] = view.FormUsername data["FormUsername"] = view.FormUsername
data["FormRole"] = view.FormRole data["FormRole"] = view.FormRole
data["GlobalRole"] = store.RoleGlobal
data["FormDomains"] = view.FormDomains data["FormDomains"] = view.FormDomains
data["FormPassword"] = view.FormPassword data["FormPassword"] = view.FormPassword
data["IsEdit"] = userID != 0 data["IsEdit"] = userID != 0
+23
View File
@@ -72,6 +72,28 @@
}); });
} }
// --- Domain pick shown only for domain administrators ------------------
// Global administrators manage every domain, so the assignment checkboxes
// are irrelevant for that role. The toggle runs on load too, because the
// edit form of an existing global user should not flash the fieldset.
function syncDomainPickField(select) {
var form = select.closest("form");
var field = form && form.querySelector("[data-domain-pick]");
if (!field) {
return;
}
field.hidden = select.value === select.dataset.globalRole;
}
function initDomainPickFields(root) {
root.querySelectorAll("select[data-global-role]").forEach(function (select) {
syncDomainPickField(select);
select.addEventListener("change", function () {
syncDomainPickField(select);
});
});
}
// --- Encryption password fields shown only when asked for -------------- // --- Encryption password fields shown only when asked for --------------
// The backup, export and import forms carry an optional password block. It // The backup, export and import forms carry an optional password block. It
// is hidden until the checkbox next to it is ticked, and cleared when it is // is hidden until the checkbox next to it is ticked, and cleared when it is
@@ -199,6 +221,7 @@
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
initAddressFields(document); initAddressFields(document);
initDomainPickFields(document);
initEncryptFields(document); initEncryptFields(document);
initImportPasswordField(document); initImportPasswordField(document);
initSectionIndex(); initSectionIndex();
+2 -2
View File
@@ -14,12 +14,12 @@
<input id="password" name="password" type="password" autocomplete="new-password" {{if not .IsEdit}}required{{end}}> <input id="password" name="password" type="password" autocomplete="new-password" {{if not .IsEdit}}required{{end}}>
<label for="role">Role</label> <label for="role">Role</label>
<select id="role" name="role"> <select id="role" name="role" data-global-role="{{.GlobalRole}}">
<option value="domain_admin" {{if eq .FormRole "domain_admin"}}selected{{end}}>Domain administrator</option> <option value="domain_admin" {{if eq .FormRole "domain_admin"}}selected{{end}}>Domain administrator</option>
<option value="global" {{if eq .FormRole "global"}}selected{{end}}>Global administrator</option> <option value="global" {{if eq .FormRole "global"}}selected{{end}}>Global administrator</option>
</select> </select>
<fieldset id="domain-pick"> <fieldset id="domain-pick" data-domain-pick>
<legend>Assigned domains</legend> <legend>Assigned domains</legend>
<p class="muted">Required for domain administrators.</p> <p class="muted">Required for domain administrators.</p>
{{range .Domains}} {{range .Domains}}