Show admin toggle, but disable for current user

You shouldn't be able to demote yourself but displaying the disabled
toggle helps explain the group of admins at the top of the list. Builds
upon #140
This commit is contained in:
Jason Zimdars committed 2025-12-08 22:53:11 -06:00
1 parent 089a8b35c0
commit 6f256f5f2d
2 files changed
+9 -2

No files matched your search

+7
View File
@@ -127,6 +127,13 @@
}
}
&:has(input[type=checkbox][disabled]) {
cursor: not-allowed;
filter: grayscale(100%) contrast(0.5);
opacity: 0.5;
pointer-events: none;
}
[disabled] &[type=submit],
&[type=submit]:disabled {
cursor: not-allowed;
+2 -2
View File
@@ -9,13 +9,13 @@
<hr class="separator" aria-hidden="true">
<% if Current.user.can_administer? && user != Current.user && user.active? %>
<% if Current.user.can_administer? && user.active? %>
<% unless user.bot? %>
<%= form_with model: user, url: account_user_path(user), data: { controller: "form" }, method: :patch do | form | %>
<label class="btn txt-small flex-item-no-shrink" for="<%= dom_id(user, :role) %>">
<span class="for-screen-reader">Role: <%= user.administrator? ? "Administrator" : "Member" %></span>
<%= image_tag "crown.svg", size: 20, aria: { hidden: "true" } %>
<%= form.check_box :role, { data: { action: "form#submit" }, hidden: true, id: dom_id(user, :role) }, "administrator", "member" %>
<%= form.check_box :role, { data: { action: "form#submit" }, hidden: true, id: dom_id(user, :role), disabled: user == Current.user }, "administrator", "member" %>
</label>
<% end %>
<% end %>