Commit 02745527b1

02745527b1d7c05ab4e3f14dd3ef8c3061dadac7

parent: 875ef13ad2

Verified · cmc ci/build: success ci/quality: success ci/test: success

cmc <hello@cleberg.net> · 2026-11-25 05:21 UTC

web: redesign /settings, /admin, and /admin/users with popovers, cards, and live JS

Layout: unified · split

Changed files (6)
internal/httpd/webux_test.go +68
@@ -104,3 +104,71 @@ func TestWebUXPickersStatebarAndRailPins(t *testing.T) {
104 t.Fatalf("labels after picker click: %+v err=%v", iss.Labels, err) 104 t.Fatalf("labels after picker click: %+v err=%v", iss.Labels, err)
105 } 105 }
106} 106}
107
108func TestAccountAndAdminUX(t *testing.T) {
109 st, err := store.Open(":memory:")
110 if err != nil {
111 t.Fatal(err)
112 }
113 defer st.Close()
114 if err := st.MigrateUp(); err != nil {
115 t.Fatal(err)
116 }
117 uid, err := st.CreateUser("admin", true)
118 if err != nil {
119 t.Fatal(err)
120 }
121 if _, err := st.CreateUser("bob", false); err != nil {
122 t.Fatal(err)
123 }
124
125 var cfg config.Config
126 cfg.Server.Root = t.TempDir()
127 cfg.Server.SiteURL = "https://forge.test"
128 cfg.Web.Mode = "accounts"
129 srv := New(cfg, st, nil)
130 cookie := sessionCookieFor(t, srv, st, uid)
131 h := srv.Handler()
132
133 // /settings renders setcard sections, autosave forms, and popover confirmations.
134 req := httptest.NewRequest("GET", "/settings", nil)
135 req.AddCookie(cookie)
136 rec := httptest.NewRecorder()
137 h.ServeHTTP(rec, req)
138 if rec.Code != http.StatusOK {
139 t.Fatalf("GET /settings: %d", rec.Code)
140 }
141 for _, want := range []string{`class="setcard"`, `data-autosave="1"`, `data-live-theme="1"`, `data-scrollspy="1"`, `class="popover"`} {
142 if !strings.Contains(rec.Body.String(), want) {
143 t.Errorf("/settings missing %s", want)
144 }
145 }
146
147 // /admin renders unified tabs, overview tiles, and in-place refresh trigger.
148 req = httptest.NewRequest("GET", "/admin", nil)
149 req.AddCookie(cookie)
150 rec = httptest.NewRecorder()
151 h.ServeHTTP(rec, req)
152 if rec.Code != http.StatusOK {
153 t.Fatalf("GET /admin: %d", rec.Code)
154 }
155 for _, want := range []string{`admintabs`, `data-refresh="/admin"`, `id="admin-queues"`, `class="tiles"`} {
156 if !strings.Contains(rec.Body.String(), want) {
157 t.Errorf("/admin missing %s", want)
158 }
159 }
160
161 // /admin/users renders live filter input and popover confirm controls.
162 req = httptest.NewRequest("GET", "/admin/users", nil)
163 req.AddCookie(cookie)
164 rec = httptest.NewRecorder()
165 h.ServeHTTP(rec, req)
166 if rec.Code != http.StatusOK {
167 t.Fatalf("GET /admin/users: %d", rec.Code)
168 }
169 for _, want := range []string{`admintabs`, `data-filter-table="accounts-table"`, `class="popover"`, `bob`} {
170 if !strings.Contains(rec.Body.String(), want) {
171 t.Errorf("/admin/users missing %s", want)
172 }
173 }
174}
internal/web/static/app.js +108 −5
@@ -3,6 +3,24 @@
3// keyboard shortcuts. Every action degrades cleanly without JS. 3// keyboard shortcuts. Every action degrades cleanly without JS.
4(() => { 4(() => {
5 'use strict'; 5 'use strict';
6 document.documentElement.classList.add('js');
7
8 let toastTimer = 0;
9 function showToast(msg, isErr = false) {
10 let el = document.getElementById('gb-toast');
11 if (!el) {
12 el = document.createElement('div');
13 el.id = 'gb-toast';
14 el.className = 'toast';
15 el.setAttribute('role', 'status');
16 document.body.appendChild(el);
17 }
18 el.textContent = msg;
19 el.classList.toggle('toast-err', isErr);
20 el.classList.add('toast-show');
21 clearTimeout(toastTimer);
22 toastTimer = setTimeout(() => el.classList.remove('toast-show'), 2200);
23 }
6 24
7 const isTyping = (el) => { 25 const isTyping = (el) => {
8 if (!el) return false; 26 if (!el) return false;
@@ -29,13 +47,12 @@
29 } 47 }
30 }); 48 });
31 49
32 // ---- 2. Copy buttons on clone blocks ---- 50 // ---- 2. Copy buttons on clone & copyable blocks ----
33 function initCopyButtons(root = document) { 51 function initCopyButtons(root = document) {
34 for (const pre of root.querySelectorAll('.clone pre')) { 52 for (const pre of root.querySelectorAll('.clone pre, pre.copyable')) {
35 if (pre.dataset.copyWired) continue; 53 if (pre.dataset.copyWired) continue;
36 pre.dataset.copyWired = '1'; 54 pre.dataset.copyWired = '1';
37 const code = pre.querySelector('code'); 55 const code = pre.querySelector('code') || pre;
38 if (!code) continue;
39 const wrap = document.createElement('div'); 56 const wrap = document.createElement('div');
40 wrap.className = 'copywrap'; 57 wrap.className = 'copywrap';
41 pre.parentNode.insertBefore(wrap, pre); 58 pre.parentNode.insertBefore(wrap, pre);
@@ -325,9 +342,95 @@
325 } 342 }
326 }); 343 });
327 344
345 // ---- 7. Auto-save checkboxes & selects on /settings ----
346 document.addEventListener('change', async (e) => {
347 const form = e.target.closest('form[data-autosave]');
348 if (!(form instanceof HTMLFormElement)) return;
349 if (e.target.matches('[data-live-theme]')) {
350 const val = e.target.value;
351 if (val === 'system') delete document.documentElement.dataset.theme;
352 else document.documentElement.dataset.theme = val;
353 }
354 const body = new URLSearchParams(new FormData(form));
355 try {
356 const res = await fetch(form.action, {
357 method: 'POST',
358 body,
359 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
360 credentials: 'same-origin',
361 });
362 if (!res.ok) { showToast('Save failed', true); return; }
363 showToast('Saved');
364 } catch {
365 showToast('Save failed', true);
366 }
367 });
368
369 // ---- 8. Live client-side table filter (/admin/users) ----
370 document.addEventListener('input', (e) => {
371 const inp = e.target.closest('input[data-filter-table]');
372 if (!inp) return;
373 const table = document.getElementById(inp.dataset.filterTable);
374 if (!table) return;
375 const q = inp.value.trim().toLowerCase();
376 for (const row of table.querySelectorAll('tbody tr')) {
377 row.hidden = q !== '' && !row.textContent.toLowerCase().includes(q);
378 }
379 });
380
381 // ---- 9. In-place Refresh (/admin) ----
382 document.addEventListener('click', async (e) => {
383 const btn = e.target.closest('button[data-refresh]');
384 if (!btn) return;
385 const url = btn.dataset.refresh;
386 btn.disabled = true;
387 try {
388 const res = await fetch(url, { credentials: 'same-origin' });
389 if (!res.ok) { showToast('Refresh failed', true); return; }
390 const html = await res.text();
391 const doc = new DOMParser().parseFromString(html, 'text/html');
392 const next = doc.getElementById('admin-queues');
393 const cur = document.getElementById('admin-queues');
394 if (next && cur) {
395 cur.replaceWith(next);
396 initScrollSpy();
397 showToast('Refreshed');
398 }
399 } catch {
400 showToast('Refresh failed', true);
401 } finally {
402 btn.disabled = false;
403 }
404 });
405
406 // ---- 10. Scroll-spy on sticky section navs ----
407 function initScrollSpy() {
408 const nav = document.querySelector('nav[data-scrollspy]');
409 if (!nav || !('IntersectionObserver' in window)) return;
410 const links = Array.from(nav.querySelectorAll('a[href^="#"]'));
411 const byId = new Map();
412 for (const a of links) {
413 const id = a.getAttribute('href').slice(1);
414 if (id) byId.set(id, a);
415 }
416 const io = new IntersectionObserver((entries) => {
417 for (const ent of entries) {
418 if (!ent.isIntersecting) continue;
419 for (const a of links) a.removeAttribute('aria-current');
420 const hit = byId.get(ent.target.id);
421 if (hit) hit.setAttribute('aria-current', 'location');
422 }
423 }, { rootMargin: '-15% 0px -70% 0px' });
424 for (const id of byId.keys()) {
425 const sec = document.getElementById(id);
426 if (sec) io.observe(sec);
427 }
428 }
429
328 if (document.readyState === 'loading') { 430 if (document.readyState === 'loading') {
329 document.addEventListener('DOMContentLoaded', () => initCopyButtons()); 431 document.addEventListener('DOMContentLoaded', () => { initCopyButtons(); initScrollSpy(); });
330 } else { 432 } else {
331 initCopyButtons(); 433 initCopyButtons();
434 initScrollSpy();
332 } 435 }
333})(); 436})();
internal/web/static/style.css +61
@@ -2205,3 +2205,64 @@ dialog.cmdk::backdrop { background: rgb(0 0 0 / 0.45); }
2205@media (max-width: 34rem) { 2205@media (max-width: 34rem) {
2206 .cmdk-trigger { display: none; } 2206 .cmdk-trigger { display: none; }
2207} 2207}
2208
2209/* ---- account & admin redesign ---- */
2210.setcard {
2211 background: var(--canvas);
2212 border: 1px solid var(--faint);
2213 border-radius: var(--r-card);
2214 padding: var(--sp-5);
2215 margin: 0 0 var(--sp-5);
2216}
2217.setcard > h2:first-child { margin-top: 0; }
2218.setcard > h2 { display: flex; align-items: center; gap: var(--sp-2); }
2219.setcard-danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--faint)); }
2220.setcard .tablewrap { overflow: visible; }
2221@media (max-width: 52rem) {
2222 .setcard .tablewrap { overflow-x: auto; }
2223}
2224.adminhead {
2225 display: flex;
2226 align-items: center;
2227 gap: var(--sp-3);
2228 flex-wrap: wrap;
2229 margin-bottom: var(--sp-3);
2230}
2231.adminhead h1 { margin: 0 0 var(--sp-1); }
2232.adminhead p.meta { margin: 0; }
2233nav.admintabs {
2234 border-bottom: 1px solid var(--faint);
2235 margin-top: 0;
2236 margin-bottom: var(--sp-5);
2237}
2238.sidecol.sticky {
2239 position: sticky;
2240 top: var(--sp-4);
2241 align-self: start;
2242}
2243.popbtn-danger { color: var(--bad); }
2244.popbtn-danger:hover, .popover[open] > .popbtn-danger {
2245 background: color-mix(in srgb, var(--bad) 10%, transparent);
2246 color: var(--bad);
2247}
2248.tablefilter { min-width: 14rem; }
2249pre.copyable { margin: var(--sp-2) 0 0; }
2250html.js form[data-autosave] button[type="submit"] { display: none; }
2251.toast {
2252 position: fixed;
2253 right: var(--sp-5);
2254 bottom: var(--sp-5);
2255 z-index: 60;
2256 padding: var(--sp-2) var(--sp-4);
2257 border-radius: var(--r-ctl);
2258 background: var(--shell-bg);
2259 color: var(--shell-fg);
2260 font-size: var(--fs-2);
2261 box-shadow: var(--shadow);
2262 opacity: 0;
2263 transform: translateY(6px);
2264 pointer-events: none;
2265 transition: opacity 0.16s ease, transform 0.16s ease;
2266}
2267.toast-show { opacity: 1; transform: translateY(0); }
2268.toast-err { background: var(--bad); color: var(--canvas); }
internal/web/templates/account.html +74 −78
@@ -1,12 +1,16 @@
1{{define "width"}}wide{{end}} 1{{define "width"}}wide{{end}}
2{{define "title"}}account settings{{end}} 2{{define "title"}}account settings{{end}}
3{{define "content"}} 3{{define "content"}}
4<h1>Account settings</h1> 4<div class="pagehead">
5 <h1>Account settings</h1>
6 <span class="grow"></span>
7 <a class="button btn" href="/{{.Viewer}}">View profile</a>
8</div>
5{{if .Notice}}<p class="error" role="alert">{{.Notice}}{{if .Reauth}} <a href="/login">Sign in again</a>{{end}}</p>{{end}} 9{{if .Notice}}<p class="error" role="alert">{{.Notice}}{{if .Reauth}} <a href="/login">Sign in again</a>{{end}}</p>{{end}}
6{{if .Message}}<p class="notice" role="status">{{.Message}}</p>{{end}} 10{{if .Message}}<p class="notice" role="status">{{.Message}}</p>{{end}}
7 11
8<div class="withcol narrow"> 12<div class="withcol narrow">
9<nav class="sidecol" aria-label="Sections"> 13<nav class="sidecol sticky" aria-label="Sections" data-scrollspy="1">
10<details class="sidedrop"> 14<details class="sidedrop">
11<summary><span class="sideword">Sections</span></summary> 15<summary><span class="sideword">Sections</span></summary>
12 <div class="grp"><h2 class="colhead">Sections</h2> 16 <div class="grp"><h2 class="colhead">Sections</h2>
@@ -17,15 +21,15 @@
17 <li><a href="#pgp">OpenPGP keys</a></li> 21 <li><a href="#pgp">OpenPGP keys</a></li>
18 <li><a href="#notifications">Notifications</a></li> 22 <li><a href="#notifications">Notifications</a></li>
19 <li><a href="#appearance">Appearance</a></li> 23 <li><a href="#appearance">Appearance</a></li>
20 <li><a href="#export">Export</a></li>
21 <li><a href="#tokens">API tokens</a></li> 24 <li><a href="#tokens">API tokens</a></li>
25 <li><a href="#export">Export</a></li>
22 <li><a href="#cli">On the command line</a></li> 26 <li><a href="#cli">On the command line</a></li>
23 <li><a href="#delete">Delete account</a></li> 27 <li><a href="#delete">Delete account</a></li>
24 </ul></div> 28 </ul></div>
25</details> 29</details>
26</nav> 30</nav>
27<div class="colmain"> 31<div class="colmain">
28<section id="profile"><h2>Profile</h2> 32<section id="profile" class="setcard"><h2>Profile</h2>
29<p class="meta">Shown on your profile page, <a href="/{{.Viewer}}">/{{.Viewer}}</a>.</p> 33<p class="meta">Shown on your profile page, <a href="/{{.Viewer}}">/{{.Viewer}}</a>.</p>
30<form method="post" action="/settings" class="setform stack"> 34<form method="post" action="/settings" class="setform stack">
31 <input type="hidden" name="field" value="profile"> 35 <input type="hidden" name="field" value="profile">
@@ -35,20 +39,20 @@
35 <input type="text" id="p-website" name="website" value="{{.Profile.Website}}" placeholder="https://example.org"> 39 <input type="text" id="p-website" name="website" value="{{.Profile.Website}}" placeholder="https://example.org">
36 <label for="p-links">Links</label> 40 <label for="p-links">Links</label>
37 <textarea id="p-links" name="links" rows="3" placeholder="one per line: label|https://… or a bare https://… (at most 5)">{{.LinksText}}</textarea> 41 <textarea id="p-links" name="links" rows="3" placeholder="one per line: label|https://… or a bare https://… (at most 5)">{{.LinksText}}</textarea>
38 <span class="btngroup"><button type="submit" class="btn">Save profile</button></span> 42 <span class="btngroup"><button type="submit">Save profile</button></span>
39</form> 43</form>
40<h3>About</h3> 44<h3>About</h3>
41<p class="meta">The longer text below your repositories is a file: 45<p class="meta">The longer text below your repositories is a file:
42<code>profile/README.md</code> in <a href="/{{.AboutRepo}}">{{.AboutRepo}}</a>. 46<code>profile/README.md</code> in <a href="/{{.AboutRepo}}">{{.AboutRepo}}</a>.
43Write it with a push, or edit it here.</p> 47Write it with a push, or edit it here.</p>
44{{if .AboutEdit}}<p><a class="btn" href="{{.AboutEdit}}">Edit {{.Profile.AboutPath}}</a></p> 48{{if .AboutEdit}}<p><a class="button btn" href="{{.AboutEdit}}">Edit {{.Profile.AboutPath}}</a></p>
45{{else}}<form method="post" action="/settings" class="setform"> 49{{else}}<form method="post" action="/settings" class="actions">
46 <input type="hidden" name="field" value="profile-repo"> 50 <input type="hidden" name="field" value="profile-repo">
47 <button type="submit" class="btn">Create {{.AboutRepo}}</button> 51 <button type="submit" class="btn">Create {{.AboutRepo}}</button>
48</form>{{end}} 52</form>{{end}}
49</section> 53</section>
50 54
51<section id="keys"><h2>SSH keys</h2> 55<section id="keys" class="setcard"><h2>SSH keys</h2>
52<p class="meta">Your keys are your identity here. A <code>full</code> key can run 56<p class="meta">Your keys are your identity here. A <code>full</code> key can run
53commands and push; a <code>git</code> key can only move git data (e.g., CI).</p> 57commands and push; a <code>git</code> key can only move git data (e.g., CI).</p>
54{{if .Keys}}<div class="tablewrap"><table class="keys nowrap"> 58{{if .Keys}}<div class="tablewrap"><table class="keys nowrap">
@@ -57,8 +61,10 @@ commands and push; a <code>git</code> key can only move git data (e.g., CI).</p>
57 <td>{{.Label}}</td> 61 <td>{{.Label}}</td>
58 <td class="mono">{{.Fingerprint}}</td> 62 <td class="mono">{{.Fingerprint}}</td>
59 <td>{{.Algo}}</td> 63 <td>{{.Algo}}</td>
60 <td>{{.Scope}}</td> 64 <td><span class="chip">{{.Scope}}</span></td>
61 <td class="act"><form method="post" action="/settings"><input type="hidden" name="field" value="key-remove"><input type="hidden" name="fingerprint" value="{{.Fingerprint}}">{{template "confirmfield" .Confirm}} <button type="submit" class="danger">Remove</button></form></td> 65 <td class="act"><details class="popover"><summary class="popbtn popbtn-danger">Remove</summary><div class="popmenu">
66 <form method="post" action="/settings" class="popform"><input type="hidden" name="field" value="key-remove"><input type="hidden" name="fingerprint" value="{{.Fingerprint}}">{{template "confirmfield" .Confirm}}<button type="submit" class="danger">Remove</button></form>
67 </div></details></td>
62</tr> 68</tr>
63{{end}}</table></div> 69{{end}}</table></div>
64{{else}}<p class="none">No SSH keys? Which cannot be right, since you signed in.</p>{{end}} 70{{else}}<p class="none">No SSH keys? Which cannot be right, since you signed in.</p>{{end}}
@@ -75,24 +81,26 @@ commands and push; a <code>git</code> key can only move git data (e.g., CI).</p>
75 <option value="full">full: commands and git</option> 81 <option value="full">full: commands and git</option>
76 <option value="git">git: git transport only</option> 82 <option value="git">git: git transport only</option>
77 </select> 83 </select>
78 <button type="submit" class="btn">Add key</button> 84 <span class="btngroup"><button type="submit">Add key</button></span>
79 </form> 85 </form>
80</details> 86</details>
81</section> 87</section>
82 88
83<section id="emails"><h2>Email addresses</h2> 89<section id="emails" class="setcard"><h2>Email addresses</h2>
84<p class="meta">A verified address ties signed commits to this 90<p class="meta">A verified address ties signed commits to this
85account and where notifications go.</p> 91account and where notifications go.</p>
86{{if .Emails}}<ul class="plain"> 92{{if .Emails}}<ul class="plain">
87{{range .Emails}}<li>{{.Address}} 93{{range .Emails}}<li><span>{{.Address}}</span>
88 {{if .Primary}}<span class="chip">primary</span>{{end}} 94 {{if .Primary}}<span class="chip">primary</span>{{end}}
89 {{if .Verified}}<span class="badge badge-verified">verified{{with .VerifiedBy}} · {{.}}{{end}}</span> 95 {{if .Verified}}<span class="badge badge-verified">verified{{with .VerifiedBy}} · {{.}}{{end}}</span>
90 {{else}}<span class="badge badge-unsigned">unverified</span>{{end}} 96 {{else}}<span class="badge badge-unsigned">unverified</span>{{end}}
91 {{if not .Primary}}{{if .Verified}}<form method="post" action="/settings" class="inline"><input type="hidden" name="field" value="email-primary"><input type="hidden" name="address" value="{{.Address}}"><button type="submit" class="linklike">Make primary</button></form>{{end}} 97 {{if not .Primary}}{{if .Verified}}<form method="post" action="/settings" class="inline"><input type="hidden" name="field" value="email-primary"><input type="hidden" name="address" value="{{.Address}}"><button type="submit" class="linklike">Make primary</button></form>{{end}}
92 <form method="post" action="/settings" class="inline"><input type="hidden" name="field" value="email-remove"><input type="hidden" name="address" value="{{.Address}}">{{template "confirmfield" .Address}} <button type="submit" class="danger">Remove</button></form>{{end}}</li> 98 <details class="popover"><summary class="popbtn popbtn-danger">Remove</summary><div class="popmenu">
99 <form method="post" action="/settings" class="popform"><input type="hidden" name="field" value="email-remove"><input type="hidden" name="address" value="{{.Address}}">{{template "confirmfield" .Address}}<button type="submit" class="danger">Remove</button></form>
100 </div></details>{{end}}</li>
93{{end}}</ul>{{end}} 101{{end}}</ul>{{end}}
94<details class="editbox"> 102<details class="editbox">
95 <summary>Add an address</summary> 103 <summary>Add or verify an address</summary>
96 <form method="post" action="/settings" class="setform"> 104 <form method="post" action="/settings" class="setform">
97 <input type="hidden" name="field" value="email-add"> 105 <input type="hidden" name="field" value="email-add">
98 <label for="address">Address</label> 106 <label for="address">Address</label>
@@ -108,7 +116,7 @@ account and where notifications go.</p>
108</details> 116</details>
109</section> 117</section>
110 118
111<section id="pgp"><h2>OpenPGP keys</h2> 119<section id="pgp" class="setcard"><h2>OpenPGP keys</h2>
112<p class="meta">Only needed if you sign commits with GPG. SSH signing 120<p class="meta">Only needed if you sign commits with GPG. SSH signing
113(<code>gpg.format = ssh</code>) uses the keys above.</p> 121(<code>gpg.format = ssh</code>) uses the keys above.</p>
114{{if .PGP}}<div class="tablewrap"><table class="keys"> 122{{if .PGP}}<div class="tablewrap"><table class="keys">
@@ -116,7 +124,9 @@ account and where notifications go.</p>
116{{range .PGP}}<tr> 124{{range .PGP}}<tr>
117 <td class="mono">{{.Fingerprint}}</td> 125 <td class="mono">{{.Fingerprint}}</td>
118 <td>{{range .UIDs}}{{.}}<br>{{end}}{{if .Revoked}}<span class="badge badge-bad_signature">revoked</span>{{else if .Expired}}<span class="badge badge-signed_key_expired">expired</span>{{end}}</td> 126 <td>{{range .UIDs}}{{.}}<br>{{end}}{{if .Revoked}}<span class="badge badge-bad_signature">revoked</span>{{else if .Expired}}<span class="badge badge-signed_key_expired">expired</span>{{end}}</td>
119 <td class="act"><form method="post" action="/settings"><input type="hidden" name="field" value="pgp-remove"><input type="hidden" name="fingerprint" value="{{.Fingerprint}}">{{template "confirmfield" .Confirm}} <button type="submit" class="danger">Remove</button></form></td> 127 <td class="act"><details class="popover"><summary class="popbtn popbtn-danger">Remove</summary><div class="popmenu">
128 <form method="post" action="/settings" class="popform"><input type="hidden" name="field" value="pgp-remove"><input type="hidden" name="fingerprint" value="{{.Fingerprint}}">{{template "confirmfield" .Confirm}}<button type="submit" class="danger">Remove</button></form>
129 </div></details></td>
120</tr> 130</tr>
121{{end}}</table></div> 131{{end}}</table></div>
122{{else}}<p class="none">No OpenPGP keys.</p>{{end}} 132{{else}}<p class="none">No OpenPGP keys.</p>{{end}}
@@ -126,40 +136,36 @@ account and where notifications go.</p>
126 <input type="hidden" name="field" value="pgp-add"> 136 <input type="hidden" name="field" value="pgp-add">
127 <label for="pgpkey">Armored public key</label> 137 <label for="pgpkey">Armored public key</label>
128 <textarea id="pgpkey" name="key" rows="6" required placeholder="-----BEGIN PGP PUBLIC KEY BLOCK-----"></textarea> 138 <textarea id="pgpkey" name="key" rows="6" required placeholder="-----BEGIN PGP PUBLIC KEY BLOCK-----"></textarea>
129 <button type="submit" class="btn">Add key</button> 139 <span class="btngroup"><button type="submit">Add key</button></span>
130 </form> 140 </form>
131</details> 141</details>
132</section> 142</section>
133 143
134<section id="notifications"><h2>Notifications</h2> 144<section id="notifications" class="setcard"><h2>Notifications</h2>
135<form method="post" action="/settings" class="setform"> 145<form method="post" action="/settings" class="setform" data-autosave="1">
136 <input type="hidden" name="field" value="notify-mail"> 146 <input type="hidden" name="field" value="notify-mail">
137 <label for="notify-mail">Activity by mail</label> 147 <div><label for="notify-mail">Activity by mail</label><p class="hint">Receive activity alerts by email. Login links arrive regardless.</p></div>
138 <div class="check"><input type="checkbox" id="notify-mail" name="mail" value="on"{{if .MailOn}} checked{{end}}></div> 148 <div class="check"><input type="checkbox" id="notify-mail" name="mail" value="on"{{if .MailOn}} checked{{end}}></div>
139 <button type="submit" class="btn">Save</button> 149 <button type="submit" class="btn">Save</button>
140</form> 150</form>
141<p class="meta">Enable to receive activity alerts by email. Login links will arrive regardless of this setting.</p> 151{{if .ReplyOffered}}<form method="post" action="/settings" class="setform" data-autosave="1">
142{{if .ReplyOffered}}<form method="post" action="/settings" class="setform">
143 <input type="hidden" name="field" value="notify-reply"> 152 <input type="hidden" name="field" value="notify-reply">
144 <label for="notify-reply">Reply to mail to comment</label> 153 <div><label for="notify-reply">Reply to mail to comment</label><p class="hint">Issue and MR mail gets a reply address; replies from verified addresses post as comments.</p></div>
145 <div class="check"><input type="checkbox" id="notify-reply" name="reply" value="on"{{if .ReplyOn}} checked{{end}}></div> 154 <div class="check"><input type="checkbox" id="notify-reply" name="reply" value="on"{{if .ReplyOn}} checked{{end}}></div>
146 <button type="submit" class="btn">Save</button> 155 <button type="submit" class="btn">Save</button>
147</form> 156</form>{{end}}
148<p class="meta">Issue and merge request mail gets a reply address. A reply posts a comment as you when it comes from one of your verified addresses; quoted text and signatures are removed.</p> 157<form method="post" action="/settings" class="setform" data-autosave="1">
149{{end}}<form method="post" action="/settings" class="setform">
150 <input type="hidden" name="field" value="notify-watch"> 158 <input type="hidden" name="field" value="notify-watch">
151 <label for="notify-watch">Watch repositories you can write to</label> 159 <div><label for="notify-watch">Watch repositories you can write to</label><p class="hint">Alerts for every issue and MR on writable repos unless overridden per repo.</p></div>
152 <div class="check"><input type="checkbox" id="notify-watch" name="watch" value="on"{{if .WatchOn}} checked{{end}}></div> 160 <div class="check"><input type="checkbox" id="notify-watch" name="watch" value="on"{{if .WatchOn}} checked{{end}}></div>
153 <button type="submit" class="btn">Save</button> 161 <button type="submit" class="btn">Save</button>
154</form> 162</form>
155<p class="meta">Alerts for every issue and merge request on those repositories. A watch or mute on a repository has priority over this setting.</p> 163<form method="post" action="/settings" class="setform" data-autosave="1">
156<form method="post" action="/settings" class="setform">
157 <input type="hidden" name="field" value="notify-push"> 164 <input type="hidden" name="field" value="notify-push">
158 <label for="notify-push">Activity on your registered devices</label> 165 <div><label for="notify-push">Activity on your registered devices</label><p class="hint">Sends notification text to Apple devices registered in the iOS app.</p></div>
159 <div class="check"><input type="checkbox" id="notify-push" name="push" value="on"{{if .PushOn}} checked{{end}}></div> 166 <div class="check"><input type="checkbox" id="notify-push" name="push" value="on"{{if .PushOn}} checked{{end}}></div>
160 <button type="submit" class="btn">Save</button> 167 <button type="submit" class="btn">Save</button>
161</form> 168</form>
162<p class="meta">Notification text is sent in full, including for private repositories, so a repository name and item number reach Apple and appear on a lock screen.</p>
163<h3>Devices</h3> 169<h3>Devices</h3>
164{{if .Devices}}<div class="tablewrap"><table class="keys nowrap"> 170{{if .Devices}}<div class="tablewrap"><table class="keys nowrap">
165<tr class="cols"><th scope="col">id</th><th scope="col">label</th><th scope="col">token</th><th scope="col">last seen</th><th scope="col"><span class="vh">actions</span></th></tr> 171<tr class="cols"><th scope="col">id</th><th scope="col">label</th><th scope="col">token</th><th scope="col">last seen</th><th scope="col"><span class="vh">actions</span></th></tr>
@@ -168,52 +174,41 @@ account and where notifications go.</p>
168 <td>{{.Label}}</td> 174 <td>{{.Label}}</td>
169 <td class="mono">{{.Token}}</td> 175 <td class="mono">{{.Token}}</td>
170 <td>{{if .LastSeenAt}}{{when .LastSeenAt}}{{else}}never{{end}}</td> 176 <td>{{if .LastSeenAt}}{{when .LastSeenAt}}{{else}}never{{end}}</td>
171 <td class="act"><form method="post" action="/settings"><input type="hidden" name="field" value="device-remove"><input type="hidden" name="id" value="{{.ID}}">{{template "confirmfield" .Confirm}} <button type="submit" class="danger">Remove</button></form></td> 177 <td class="act"><details class="popover"><summary class="popbtn popbtn-danger">Remove</summary><div class="popmenu">
178 <form method="post" action="/settings" class="popform"><input type="hidden" name="field" value="device-remove"><input type="hidden" name="id" value="{{.ID}}">{{template "confirmfield" .Confirm}}<button type="submit" class="danger">Remove</button></form>
179 </div></details></td>
172</tr> 180</tr>
173{{end}}</table></div> 181{{end}}</table></div>
174{{else}}<p class="none">No registered devices.</p>{{end}} 182{{else}}<p class="none">No registered devices.</p>{{end}}
175<p class="meta">Devices register themselves from the iOS app; there is no 183<p class="meta">Devices register themselves from the iOS app; a browser cannot produce an APNs token.</p>
176form here to add one, since a browser cannot produce an APNs token.</p>
177</section> 184</section>
178 185
179<section id="appearance"><h2>Appearance</h2> 186<section id="appearance" class="setcard"><h2>Appearance</h2>
180<form method="post" action="/settings" class="setform"> 187<form method="post" action="/settings" class="setform" data-autosave="1">
181 <input type="hidden" name="field" value="theme"> 188 <input type="hidden" name="field" value="theme">
182 <label for="theme">Colour scheme</label> 189 <div><label for="theme">Colour scheme</label><p class="hint">Matches <code>gitbay web theme set</code>.</p></div>
183 <select id="theme" name="theme"> 190 <select id="theme" name="theme" data-live-theme="1">
184 <option value="system"{{if eq .ThemeSetting "system"}} selected{{end}}>follow the browser</option> 191 <option value="system"{{if eq .ThemeSetting "system"}} selected{{end}}>Follow the browser</option>
185 <option value="light"{{if eq .ThemeSetting "light"}} selected{{end}}>light</option> 192 <option value="light"{{if eq .ThemeSetting "light"}} selected{{end}}>Light</option>
186 <option value="dark"{{if eq .ThemeSetting "dark"}} selected{{end}}>dark</option> 193 <option value="dark"{{if eq .ThemeSetting "dark"}} selected{{end}}>Dark</option>
187 </select> 194 </select>
188 <button type="submit" class="btn">Save</button> 195 <button type="submit" class="btn">Save</button>
189</form> 196</form>
190<p class="meta">The same setting as <code>gitbay web theme set</code>. Following the browser takes its light or dark preference.</p> 197<form method="post" action="/settings" class="setform" data-autosave="1">
191<form method="post" action="/settings" class="setform">
192 <input type="hidden" name="field" value="diff-layout"> 198 <input type="hidden" name="field" value="diff-layout">
193 <label for="layout">Diff layout</label> 199 <div><label for="layout">Diff layout</label><p class="hint">Matches <code>gitbay web diff set</code>. Narrow windows stay unified.</p></div>
194 <select id="layout" name="layout"> 200 <select id="layout" name="layout">
195 <option value="unified"{{if ne .DiffSetting "split"}} selected{{end}}>unified</option> 201 <option value="unified"{{if ne .DiffSetting "split"}} selected{{end}}>Unified</option>
196 <option value="split"{{if eq .DiffSetting "split"}} selected{{end}}>side by side</option> 202 <option value="split"{{if eq .DiffSetting "split"}} selected{{end}}>Side by side</option>
197 </select> 203 </select>
198 <button type="submit" class="btn">Save</button> 204 <button type="submit" class="btn">Save</button>
199</form> 205</form>
200<p class="meta">The same setting as <code>gitbay web diff set</code>. A <code>?layout=split</code> or <code>?layout=unified</code> on a diff page overrides it for that request. Narrow windows always show a unified diff.</p>
201</section>
202
203<section id="export"><h2>Export</h2>
204<p class="meta">Your profile, repositories, issues and merge requests as one
205JSON bundle, the same one <code>gitbay auth export</code> writes. Keys are
206never included; a replayed bundle's emails arrive unverified.</p>
207<p><a href="/settings/export">Download bundle</a></p>
208</section> 206</section>
209 207
210<section id="tokens"><h2>API tokens</h2> 208<section id="tokens" class="setcard"><h2>API tokens</h2>
211<p class="meta">A token signs in the iOS app, or a script, without your 209<p class="meta">A token signs in the iOS app or a script. Give each token the narrowest scope and shortest lifetime the job needs.</p>
212password. A phone app needs full scope to comment and merge; full scope
213on an admin account can administer the instance, so give a token the
214narrowest scope and shortest lifetime the job needs.</p>
215{{if .TokenShown}}<p class="notice" role="status">Token created. It is shown once; store it now.</p> 210{{if .TokenShown}}<p class="notice" role="status">Token created. It is shown once; store it now.</p>
216<pre class="message" tabindex="0">{{.TokenShown}}</pre>{{end}} 211<pre class="message copyable" tabindex="0"><code>{{.TokenShown}}</code></pre>{{end}}
217{{if .Tokens}}<div class="tablewrap"><table class="keys nowrap"> 212{{if .Tokens}}<div class="tablewrap"><table class="keys nowrap">
218<tr class="cols"><th scope="col">name</th><th scope="col">scope</th><th scope="col">created</th><th scope="col">expires</th><th scope="col">last used</th><th scope="col"><span class="vh">actions</span></th></tr> 213<tr class="cols"><th scope="col">name</th><th scope="col">scope</th><th scope="col">created</th><th scope="col">expires</th><th scope="col">last used</th><th scope="col"><span class="vh">actions</span></th></tr>
219{{range .Tokens}}<tr> 214{{range .Tokens}}<tr>
@@ -222,7 +217,9 @@ narrowest scope and shortest lifetime the job needs.</p>
222 <td>{{when .Created}}</td> 217 <td>{{when .Created}}</td>
223 <td>{{.Expires}}</td> 218 <td>{{.Expires}}</td>
224 <td>{{.LastUsed}}</td> 219 <td>{{.LastUsed}}</td>
225 <td class="act"><form method="post" action="/settings"><input type="hidden" name="field" value="token-revoke"><input type="hidden" name="name" value="{{.Name}}">{{template "confirmfield" .Name}} <button type="submit" class="danger">Revoke</button></form></td> 220 <td class="act"><details class="popover"><summary class="popbtn popbtn-danger">Revoke</summary><div class="popmenu">
221 <form method="post" action="/settings" class="popform"><input type="hidden" name="field" value="token-revoke"><input type="hidden" name="name" value="{{.Name}}">{{template "confirmfield" .Name}}<button type="submit" class="danger">Revoke</button></form>
222 </div></details></td>
226</tr> 223</tr>
227{{end}}</table></div> 224{{end}}</table></div>
228{{else}}<p class="none">No API tokens.</p>{{end}} 225{{else}}<p class="none">No API tokens.</p>{{end}}
@@ -239,28 +236,27 @@ narrowest scope and shortest lifetime the job needs.</p>
239 </select> 236 </select>
240 <label for="token-ttl">Expires after</label> 237 <label for="token-ttl">Expires after</label>
241 <input id="token-ttl" name="ttl" autocomplete="off" placeholder="e.g. 30d or 720h; empty never expires"> 238 <input id="token-ttl" name="ttl" autocomplete="off" placeholder="e.g. 30d or 720h; empty never expires">
242 <button type="submit" class="btn">Create token</button> 239 <span class="btngroup"><button type="submit">Create token</button></span>
243 </form> 240 </form>
244</details> 241</details>
245</section> 242</section>
246 243
247<section id="cli"><h2>On the command line</h2> 244<section id="export" class="setcard"><h2>Export</h2>
248<p class="meta">No page here yet, and nothing refusing one.</p> 245<p class="meta">Your profile, repositories, issues and merge requests as one JSON bundle, matching <code>gitbay auth export</code>. Keys are excluded.</p>
249<pre class="message" tabindex="0">gitbay web sessions list # browser sessions 246<p><a class="button btn" href="/settings/export">Download bundle</a></p>
250gitbay admin ... # instance administration</pre> 247</section>
251<p class="meta">All of it works from stock OpenSSH too, with the CLI's 248
252grouping words dropped: <code>ssh git@{{.Host}} whoami</code>, 249<section id="cli" class="setcard"><h2>On the command line</h2>
253<code>ssh git@{{.Host}} web sessions list</code>.</p> 250<p class="meta">Browser sessions and instance administration also run from the CLI or stock OpenSSH:</p>
251<pre class="message copyable" tabindex="0"><code>gitbay web sessions list
252ssh git@{{.Host}} whoami</code></pre>
254</section> 253</section>
255 254
256<section id="delete"><h2>Delete account</h2> 255<section id="delete" class="setcard setcard-danger"><h2>Delete account</h2>
257<p class="meta">Deletes your repositories, snippets, keys and addresses. 256<p class="meta">Deletes your repositories, snippets, keys and addresses. Issues, merge requests and comments on other people's repositories stay under <code>ghost</code>. A confirmation link is mailed to your primary address; opening it disables the account and purges it seven days later. <a href="#export">Export</a> first to keep a copy.</p>
258Issues, merge requests and comments you wrote on other people's 257<details class="popover"><summary class="button danger">Delete account…</summary><div class="popmenu">
259repositories stay, under the name <code>ghost</code>. A link is mailed to 258 <form method="post" action="/settings" class="popform"><input type="hidden" name="field" value="account-delete">{{template "confirmfield" .Viewer}}<button type="submit" class="danger">Mail link</button></form>
260your primary address; once it is opened the account is disabled, and it 259</div></details>
261is deleted seven days later. Signing in during those days cancels.
262<a href="#export">Export</a> first to keep a copy.</p>
263<form method="post" action="/settings" class="setform"><input type="hidden" name="field" value="account-delete">{{template "confirmfield" .Viewer}} <button type="submit" class="danger">Mail the deletion link</button></form>
264</section> 260</section>
265</div> 261</div>
266</div> 262</div>
internal/web/templates/admin.html +32 −12
@@ -1,15 +1,35 @@
1{{define "width"}}wide{{end}} 1{{define "width"}}wide{{end}}
2{{define "title"}}admin · {{.Site}}{{end}} 2{{define "title"}}admin · {{.Site}}{{end}}
3{{define "content"}} 3{{define "content"}}
4<h1>Admin</h1> 4<div class="adminhead">
5<p class="meta">Server build {{.Commit}}. Every background worker's backlog. This is the same read as <code>gitbay dashboard --json</code> for an admin.</p> 5 <div>
6<p class="meta"><a href="/admin/users">Accounts</a>: view every instance user account.</p> 6 <h1>Admin</h1>
7 <p class="meta">Server build <code>{{.Commit}}</code> · background worker queues</p>
8 </div>
9 <span class="grow"></span>
10 <button type="button" class="btn" data-refresh="/admin">Refresh</button>
11</div>
12
13<nav class="tabs admintabs" aria-label="Admin">
14 <a aria-current="page" href="/admin">Queues</a>
15 <a href="/admin/users">Accounts</a>
16</nav>
17
18<div id="admin-queues">
19<div class="tiles">
20 {{with .Queues.Webhooks}}<a class="tile{{if or .Pending .Failed}} wants{{end}}" href="#webhooks"><b>{{.Pending}}</b><span>webhooks pending{{if .Failed}} · {{.Failed}} failed{{end}}</span></a>{{end}}
21 {{with .Queues.Mail}}<a class="tile{{if or .Pending .Failed}} wants{{end}}" href="#mail"><b>{{.Pending}}</b><span>mail pending{{if .Failed}} · {{.Failed}} failed{{end}}</span></a>{{end}}
22 {{with .Queues.Push}}<a class="tile{{if or .Pending .Failed}} wants{{end}}" href="#push"><b>{{.Pending}}</b><span>push pending{{if .Failed}} · {{.Failed}} failed{{end}}</span></a>{{end}}
23 {{with .Queues.Mirrors}}<a class="tile{{if .Errors}} wants{{end}}" href="#mirrors"><b>{{.Errors}}</b><span>mirror errors · {{.Dirty}} dirty</span></a>{{end}}
24 {{with .Queues.Builds}}<a class="tile{{if or .Pending .Running}} wants{{end}}" href="#builds"><b>{{.Running}}</b><span>builds running · {{.Pending}} queued</span></a>{{end}}
25 {{with .Queues.Deps}}<a class="tile{{if .Errors}} wants{{end}}" href="#deps"><b>{{.Errors}}</b><span>dependency check errors</span></a>{{end}}
26</div>
7 27
8<div class="withcol narrow"> 28<div class="withcol narrow">
9<nav class="sidecol" aria-label="Sections"> 29<nav class="sidecol sticky" aria-label="Sections" data-scrollspy="1">
10<details class="sidedrop"> 30<details class="sidedrop">
11<summary><span class="sideword">Sections</span></summary> 31<summary><span class="sideword">Sections</span></summary>
12 <div class="grp"><h2 class="colhead">Sections</h2> 32 <div class="grp"><h2 class="colhead">Queues</h2>
13 <ul> 33 <ul>
14 <li><a href="#webhooks">Webhook deliveries</a></li> 34 <li><a href="#webhooks">Webhook deliveries</a></li>
15 <li><a href="#mail">Mail</a></li> 35 <li><a href="#mail">Mail</a></li>
@@ -23,7 +43,7 @@
23<div class="colmain"> 43<div class="colmain">
24 44
25{{with .Queues.Webhooks}} 45{{with .Queues.Webhooks}}
26<section id="webhooks"> 46<section id="webhooks" class="setcard">
27<h2>Webhook deliveries <span class="count">{{.Pending}}</span></h2> 47<h2>Webhook deliveries <span class="count">{{.Pending}}</span></h2>
28<p class="meta">{{.Pending}} pending · {{.Retrying}} retrying · {{.Failed}} dead-lettered{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p> 48<p class="meta">{{.Pending}} pending · {{.Retrying}} retrying · {{.Failed}} dead-lettered{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p>
29{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Repository</th><th>URL</th><th>Attempts</th><th>State</th><th>Last error</th></tr></thead><tbody> 49{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Repository</th><th>URL</th><th>Attempts</th><th>State</th><th>Last error</th></tr></thead><tbody>
@@ -33,7 +53,7 @@
33{{end}} 53{{end}}
34 54
35{{with .Queues.Mail}} 55{{with .Queues.Mail}}
36<section id="mail"> 56<section id="mail" class="setcard">
37<h2>Mail <span class="count">{{.Pending}}</span></h2> 57<h2>Mail <span class="count">{{.Pending}}</span></h2>
38<p class="meta">{{.Pending}} pending · {{.Retrying}} retrying · {{.Failed}} failed{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p> 58<p class="meta">{{.Pending}} pending · {{.Retrying}} retrying · {{.Failed}} failed{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p>
39{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Mail</th><th>Recipient</th><th>Subject</th><th>Attempts</th><th>State</th><th>Last error</th></tr></thead><tbody> 59{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Mail</th><th>Recipient</th><th>Subject</th><th>Attempts</th><th>State</th><th>Last error</th></tr></thead><tbody>
@@ -42,9 +62,8 @@
42</section> 62</section>
43{{end}} 63{{end}}
44 64
45{{/* A push row names the device id, never the token, as dashboard does. */}}
46{{with .Queues.Push}} 65{{with .Queues.Push}}
47<section id="push"> 66<section id="push" class="setcard">
48<h2>Push <span class="count">{{.Pending}}</span></h2> 67<h2>Push <span class="count">{{.Pending}}</span></h2>
49<p class="meta">{{.Pending}} pending · {{.Retrying}} retrying · {{.Failed}} failed{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p> 68<p class="meta">{{.Pending}} pending · {{.Retrying}} retrying · {{.Failed}} failed{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p>
50{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Push</th><th>Device</th><th>Title</th><th>Attempts</th><th>State</th><th>Last error</th></tr></thead><tbody> 69{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Push</th><th>Device</th><th>Title</th><th>Attempts</th><th>State</th><th>Last error</th></tr></thead><tbody>
@@ -54,7 +73,7 @@
54{{end}} 73{{end}}
55 74
56{{with .Queues.Mirrors}} 75{{with .Queues.Mirrors}}
57<section id="mirrors"> 76<section id="mirrors" class="setcard">
58<h2>Mirrors <span class="count">{{.Errors}}</span></h2> 77<h2>Mirrors <span class="count">{{.Errors}}</span></h2>
59<p class="meta">{{.Dirty}} waiting for a sync · {{.Errors}} with a failed last sync</p> 78<p class="meta">{{.Dirty}} waiting for a sync · {{.Errors}} with a failed last sync</p>
60{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Repository</th><th>Direction</th><th>URL</th><th>Last sync</th><th>Error</th></tr></thead><tbody> 79{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Repository</th><th>Direction</th><th>URL</th><th>Last sync</th><th>Error</th></tr></thead><tbody>
@@ -64,7 +83,7 @@
64{{end}} 83{{end}}
65 84
66{{with .Queues.Builds}} 85{{with .Queues.Builds}}
67<section id="builds"> 86<section id="builds" class="setcard">
68<h2>Builds <span class="count">{{.Pending}}</span></h2> 87<h2>Builds <span class="count">{{.Pending}}</span></h2>
69<p class="meta">{{.Pending}} pending · {{.Running}} running{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p> 88<p class="meta">{{.Pending}} pending · {{.Running}} running{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p>
70{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Repository</th><th>Build</th><th>Job</th><th>Status</th><th>Since</th></tr></thead><tbody> 89{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Repository</th><th>Build</th><th>Job</th><th>Status</th><th>Since</th></tr></thead><tbody>
@@ -74,7 +93,7 @@
74{{end}} 93{{end}}
75 94
76{{with .Queues.Deps}} 95{{with .Queues.Deps}}
77<section id="deps"> 96<section id="deps" class="setcard">
78<h2>Dependency checks <span class="count">{{.Errors}}</span></h2> 97<h2>Dependency checks <span class="count">{{.Errors}}</span></h2>
79{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Repository</th><th>Last check</th><th>Error</th></tr></thead><tbody> 98{{if .Items}}<div class="tablewrap"><table class="keys"><thead><tr class="cols"><th>Repository</th><th>Last check</th><th>Error</th></tr></thead><tbody>
80{{range .Items}}<tr><td><a href="/{{.Repo}}">{{.Repo}}</a></td><td>{{if .LastCheck}}{{when .LastCheck}}{{else}}never{{end}}</td><td>{{.LastError}}</td></tr> 99{{range .Items}}<tr><td><a href="/{{.Repo}}">{{.Repo}}</a></td><td>{{if .LastCheck}}{{when .LastCheck}}{{else}}never{{end}}</td><td>{{.LastError}}</td></tr>
@@ -83,4 +102,5 @@
83{{end}} 102{{end}}
84</div> 103</div>
85</div> 104</div>
105</div>
86{{end}} 106{{end}}
internal/web/templates/adminusers.html +57 −47
@@ -1,24 +1,35 @@
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}} 1{{define "width"}}wide{{end}}
6{{define "title"}}accounts · admin · {{.Site}}{{end}} 2{{define "title"}}accounts · admin · {{.Site}}{{end}}
7{{define "content"}} 3{{define "content"}}
8<h1>Accounts</h1> 4<div class="adminhead">
9<p class="meta"><a href="/admin">Admin</a> · the same read as <code>gitbay admin user list</code>.</p> 5 <div>
10{{if .Notice}}<p class="notice" role="status">{{.Notice}}{{if .Reauth}} <a href="/login">Sign in again</a>{{end}}</p>{{end}} 6 <h1>Admin</h1>
7 <p class="meta">Manage instance user accounts · matches <code>gitbay admin user list</code></p>
8 </div>
9</div>
11 10
12<nav class="filters"> 11<nav class="tabs admintabs" aria-label="Admin">
13 <a {{if eq .State "all"}}class="active" aria-current="page" {{end}}href="?state=all">all</a> 12 <a href="/admin">Queues</a>
14 <a {{if eq .State "active"}}class="active" aria-current="page" {{end}}href="?state=active">active</a> 13 <a aria-current="page" href="/admin/users">Accounts</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> 14</nav>
19 15
20{{if .Users}}<div class="tablewrap"><table class="keys accounts nowrap"> 16{{if .Notice}}<p class="notice" role="status">{{.Notice}}{{if .Reauth}} <a href="/login">Sign in again</a>{{end}}</p>{{end}}
21<thead><tr class="cols"><th>Account</th><th>State</th><th>Created</th><th>Last seen</th><th>Actions</th></tr></thead> 17
18<div class="listhead">
19 <nav class="filters" aria-label="Account state">
20 <a {{if eq .State "all"}}class="active" aria-current="page" {{end}}href="?state=all">all</a>
21 <a {{if eq .State "active"}}class="active" aria-current="page" {{end}}href="?state=active">active</a>
22 <a {{if eq .State "pending"}}class="active" aria-current="page" {{end}}href="?state=pending">pending</a>
23 <a {{if eq .State "disabled"}}class="active" aria-current="page" {{end}}href="?state=disabled">disabled</a>
24 <a {{if eq .State "admin"}}class="active" aria-current="page" {{end}}href="?state=admin">admins</a>
25 </nav>
26 <span class="spacer"></span>
27 <input type="search" class="tablefilter" aria-label="Filter accounts" placeholder="Filter by username…" data-filter-table="accounts-table">
28</div>
29
30<section class="setcard">
31{{if .Users}}<div class="tablewrap"><table id="accounts-table" class="keys accounts nowrap">
32<thead><tr class="cols"><th>Account</th><th>State</th><th>Created</th><th>Last seen</th><th class="act">Actions</th></tr></thead>
22<tbody> 33<tbody>
23{{range .Users}}<tr> 34{{range .Users}}<tr>
24 <td><a href="/{{.Username}}">{{.Username}}</a>{{if .Admin}} <span class="chip">admin</span>{{end}}</td> 35 <td><a href="/{{.Username}}">{{.Username}}</a>{{if .Admin}} <span class="chip">admin</span>{{end}}</td>
@@ -27,54 +38,53 @@
27 <td>{{if .LastSeen}}{{when .LastSeen}}{{else}}never{{end}}</td> 38 <td>{{if .LastSeen}}{{when .LastSeen}}{{else}}never{{end}}</td>
28 <td class="acts"> 39 <td class="acts">
29 {{if .Admin}} 40 {{if .Admin}}
30 <form method="post" action="/admin/users" class="actions"> 41 <details class="popover"><summary class="popbtn">Demote</summary><div class="popmenu">
31 <input type="hidden" name="field" value="demote"> 42 <form method="post" action="/admin/users" class="popform">
32 <input type="hidden" name="user" value="{{.Username}}"> 43 <input type="hidden" name="field" value="demote">
33 <input type="hidden" name="state" value="{{$.State}}"> 44 <input type="hidden" name="user" value="{{.Username}}">
34 {{template "confirmfield" .Username}} <button type="submit" class="btn">Demote</button> 45 <input type="hidden" name="state" value="{{$.State}}">
35 </form> 46 {{template "confirmfield" .Username}}<button type="submit" class="btn">Demote</button>
47 </form>
48 </div></details>
36 {{else if eq .State "active"}} 49 {{else if eq .State "active"}}
37 <form method="post" action="/admin/users" class="actions"> 50 <details class="popover"><summary class="popbtn">Promote</summary><div class="popmenu">
38 <input type="hidden" name="field" value="promote"> 51 <form method="post" action="/admin/users" class="popform">
39 <input type="hidden" name="user" value="{{.Username}}"> 52 <input type="hidden" name="field" value="promote">
40 <input type="hidden" name="state" value="{{$.State}}"> 53 <input type="hidden" name="user" value="{{.Username}}">
41 {{template "confirmfield" .Username}} <button type="submit" class="btn">Promote</button> 54 <input type="hidden" name="state" value="{{$.State}}">
42 </form> 55 {{template "confirmfield" .Username}}<button type="submit" class="btn">Promote</button>
43 {{else}} 56 </form>
44 {{/* An account that is not active cannot be promoted, but the row 57 </div></details>
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}} 58 {{end}}
53 {{if eq .State "disabled"}} 59 {{if eq .State "disabled"}}
54 <form method="post" action="/admin/users" class="actions"> 60 <form method="post" action="/admin/users" class="inline">
55 <input type="hidden" name="field" value="enable"> 61 <input type="hidden" name="field" value="enable">
56 <input type="hidden" name="user" value="{{.Username}}"> 62 <input type="hidden" name="user" value="{{.Username}}">
57 <input type="hidden" name="state" value="{{$.State}}"> 63 <input type="hidden" name="state" value="{{$.State}}">
58 <button type="submit" class="btn">Enable</button> 64 <button type="submit" class="btn">Enable</button>
59 </form> 65 </form>
60 {{else}} 66 {{else}}
61 <form method="post" action="/admin/users" class="actions"> 67 <details class="popover"><summary class="popbtn popbtn-danger">Disable</summary><div class="popmenu">
62 <input type="hidden" name="field" value="disable"> 68 <form method="post" action="/admin/users" class="popform">
63 <input type="hidden" name="user" value="{{.Username}}"> 69 <input type="hidden" name="field" value="disable">
64 <input type="hidden" name="state" value="{{$.State}}"> 70 <input type="hidden" name="user" value="{{.Username}}">
65 {{template "confirmfield" .Username}} <button type="submit" class="btn">Disable</button> 71 <input type="hidden" name="state" value="{{$.State}}">
66 </form> 72 {{template "confirmfield" .Username}}<button type="submit" class="danger">Disable</button>
73 </form>
74 </div></details>
67 {{end}} 75 {{end}}
68 </td> 76 </td>
69</tr> 77</tr>
70{{end}} 78{{end}}
71</tbody></table></div>{{else}}<p class="none">No account matches</p>{{end}} 79</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}} 80{{if .Next}}<p class="pager"><a href="{{.Next}}">more →</a></p>{{end}}
81</section>
73 82
74<p class="meta">Creating and deleting an account, issuing an invite and 83<section class="setcard">
75asserting an address stay on the command line: each takes a key, mints 84<h2>CLI administration</h2>
76a credential, or cannot be undone.</p> 85<p class="meta">Creating and deleting accounts, issuing invites, and asserting addresses stay on the command line:</p>
77<pre tabindex="0"><code>gitbay admin user create &lt;name&gt; --key - &lt; key.pub 86<pre class="copyable" tabindex="0"><code>gitbay admin user create &lt;name&gt; --key - &lt; key.pub
78gitbay admin user delete &lt;name&gt; --yes 87gitbay admin user delete &lt;name&gt; --yes
79gitbay admin invite --email &lt;address&gt;</code></pre> 88gitbay admin invite --email &lt;address&gt;</code></pre>
89</section>
80{{end}} 90{{end}}