internal/web/templates/adminusers.html

v1.35.0
gitbay/internal/web/templates/adminusers.html history · blame · raw

80 lines · 4302 bytes

 1{{/* wide, because the Actions cell carries up to two forms, each an
 2     11rem confirm field and a button: about 1100px of row, which 48rem
 3     clipped. What it clipped was the second form's button, leaving its
 4     confirm field looking like it belonged to the button before it. */}}
 5{{define "width"}}wide{{end}}
 6{{define "title"}}accounts · admin · {{.Site}}{{end}}
 7{{define "content"}}
 8<h1>Accounts</h1>
 9<p class="meta"><a href="/admin">Admin</a> · the same read as <code>gitbay admin user list</code>.</p>
10{{if .Notice}}<p class="notice" role="status">{{.Notice}}</p>{{end}}
11
12<nav class="filters">
13  <a {{if eq .State "all"}}class="active" aria-current="page" {{end}}href="?state=all">all</a>
14  <a {{if eq .State "active"}}class="active" aria-current="page" {{end}}href="?state=active">active</a>
15  <a {{if eq .State "pending"}}class="active" aria-current="page" {{end}}href="?state=pending">pending</a>
16  <a {{if eq .State "disabled"}}class="active" aria-current="page" {{end}}href="?state=disabled">disabled</a>
17  <a {{if eq .State "admin"}}class="active" aria-current="page" {{end}}href="?state=admin">admins</a>
18</nav>
19
20{{if .Users}}<div class="tablewrap"><table class="keys accounts nowrap">
21<thead><tr class="cols"><th>Account</th><th>State</th><th>Created</th><th>Last seen</th><th>Actions</th></tr></thead>
22<tbody>
23{{range .Users}}<tr>
24  <td><a href="/{{.Username}}">{{.Username}}</a>{{if .Admin}} <span class="chip">admin</span>{{end}}</td>
25  <td><span class="chip {{if eq .State "active"}}chip-open{{else if eq .State "disabled"}}chip-closed{{else}}chip-neutral{{end}}">{{.State}}</span></td>
26  <td>{{when .CreatedAt}}</td>
27  <td>{{if .LastSeen}}{{when .LastSeen}}{{else}}never{{end}}</td>
28  <td class="acts">
29    {{if .Admin}}
30    <form method="post" action="/admin/users" class="actions">
31      <input type="hidden" name="field" value="demote">
32      <input type="hidden" name="user" value="{{.Username}}">
33      <input type="hidden" name="state" value="{{$.State}}">
34      {{template "confirmfield" .Username}} <button type="submit" class="btn">Demote</button>
35    </form>
36    {{else if eq .State "active"}}
37    <form method="post" action="/admin/users" class="actions">
38      <input type="hidden" name="field" value="promote">
39      <input type="hidden" name="user" value="{{.Username}}">
40      <input type="hidden" name="state" value="{{$.State}}">
41      {{template "confirmfield" .Username}} <button type="submit" class="btn">Promote</button>
42    </form>
43    {{else}}
44    {{/* An account that is not active cannot be promoted, but the row
45         still draws the button so the cell keeps its shape. It carries
46         no confirm field: nothing is confirmed, and a second field with
47         the same placeholder as the disable form's reads as a duplicate
48         of it. Disabled, so the form never posts. */}}
49    <form method="post" action="/admin/users" class="actions" title="Only an active account can be promoted">
50      <button type="submit" class="btn" disabled>Promote</button>
51    </form>
52    {{end}}
53    {{if eq .State "disabled"}}
54    <form method="post" action="/admin/users" class="actions">
55      <input type="hidden" name="field" value="enable">
56      <input type="hidden" name="user" value="{{.Username}}">
57      <input type="hidden" name="state" value="{{$.State}}">
58      <button type="submit" class="btn">Enable</button>
59    </form>
60    {{else}}
61    <form method="post" action="/admin/users" class="actions">
62      <input type="hidden" name="field" value="disable">
63      <input type="hidden" name="user" value="{{.Username}}">
64      <input type="hidden" name="state" value="{{$.State}}">
65      {{template "confirmfield" .Username}} <button type="submit" class="btn">Disable</button>
66    </form>
67    {{end}}
68  </td>
69</tr>
70{{end}}
71</tbody></table></div>{{else}}<p class="none">No account matches</p>{{end}}
72{{if .Next}}<p class="pager"><a href="{{.Next}}">more →</a></p>{{end}}
73
74<p class="meta">Creating and deleting an account, issuing an invite and
75asserting an address stay on the command line: each takes a key, mints
76a credential, or cannot be undone.</p>
77<pre tabindex="0"><code>gitbay admin user create &lt;name&gt; --key - &lt; key.pub
78gitbay admin user delete &lt;name&gt; --yes
79gitbay admin invite --email &lt;address&gt;</code></pre>
80{{end}}