58 lines
3.4 KiB
Plaintext
58 lines
3.4 KiB
Plaintext
<%#
|
|
Admin role detail body (todo §5), captured into the shell content slot. Config:
|
|
role { name }
|
|
members { action, rows: { kind:"group"|"user", label, subject }[] } action = revoke endpoint
|
|
effective { label }[] users who hold the role (expand)
|
|
add { action, options: {label,value}[] } action = assign endpoint
|
|
del { action } delete the whole role
|
|
csrfToken, error?
|
|
%><%
|
|
const role = locals.role;
|
|
const members = locals.members;
|
|
const effective = locals.effective;
|
|
const add = locals.add;
|
|
const del = locals.del;
|
|
const csrf = locals.csrfToken;
|
|
-%>
|
|
<div class="form-page">
|
|
<% if (locals.error) { -%>
|
|
<%- include("alert", { text: locals.error, tone: "neg" }) %>
|
|
<% } -%>
|
|
<section class="form-card" aria-labelledby="members-h">
|
|
<h2 class="card-title" id="members-h">Assigned to</h2>
|
|
<% if (members.rows.length) { -%>
|
|
<div class="table-wrap"><table class="table"><caption class="sr-only">Members of <%= role.name %></caption><thead><tr><th scope="col">Member</th><th scope="col">Type</th><th class="col-actions" scope="col"><span class="sr-only">Actions</span></th></tr></thead><tbody>
|
|
<% members.rows.forEach((m) => { -%>
|
|
<tr><th scope="row"><span class="cell-strong"><%= m.label %></span></th><td><span class="badge info"><span class="dot"></span><%= m.kind === "group" ? "Group" : "User" %></span></td><td class="col-actions"><form method="post" action="<%= members.action %>"><input type="hidden" name="_csrf" value="<%= csrf %>"><input type="hidden" name="member" value="<%= m.subject %>"><button class="btn" type="submit"><svg class="ico ico-sm" aria-hidden="true"><use href="#i-x"/></svg>Revoke</button></form></td></tr>
|
|
<% }) -%>
|
|
</tbody></table></div>
|
|
<% } else { -%>
|
|
<p class="cell-muted">Not assigned to anyone yet.</p>
|
|
<% } -%>
|
|
</section>
|
|
<section class="form-card" aria-labelledby="effective-h">
|
|
<h2 class="card-title" id="effective-h">Effective access</h2>
|
|
<p class="field-hint">Everyone who holds this role — directly or through a group (resolved by Keto).</p>
|
|
<% if (effective.length) { -%>
|
|
<ul class="plain-list">
|
|
<% effective.forEach((u) => { -%>
|
|
<li><span class="cell-strong"><%= u.label %></span></li>
|
|
<% }) -%>
|
|
</ul>
|
|
<% } else { -%>
|
|
<p class="cell-muted">No users hold this role yet.</p>
|
|
<% } -%>
|
|
</section>
|
|
<section class="form-card" aria-labelledby="add-h">
|
|
<h2 class="card-title" id="add-h">Assign the role</h2>
|
|
<% if (add.options.length) { -%>
|
|
<form class="inline-form" method="post" action="<%= add.action %>"><input type="hidden" name="_csrf" value="<%= csrf %>"><label class="sr-only" for="add-member">Member</label><span class="select"><select id="add-member" name="member" required><option value="" disabled selected>Choose a user or group…</option><% add.options.forEach((o) => { %><option value="<%= o.value %>"><%= o.label %></option><% }) %></select></span><button class="btn btn-primary" type="submit"><svg class="ico ico-sm" aria-hidden="true"><use href="#i-plus"/></svg>Assign</button></form>
|
|
<% } else { -%>
|
|
<p class="cell-muted">All users and groups already have this role.</p>
|
|
<% } -%>
|
|
</section>
|
|
<section class="form-card admin-actions" aria-label="Role actions">
|
|
<a class="btn btn-danger" href="<%= del.action %>"><svg class="ico ico-sm" aria-hidden="true"><use href="#i-trash"/></svg>Delete role</a>
|
|
</section>
|
|
</div>
|