Commit 02745527b1
Verified · cmc ci/build: success ci/quality: success ci/test: success
Layout: unified · split
Changed files (6)
internal/httpd/webux_test.go +68
| @@ -104,3 +104,71 @@ func TestWebUXPickersStatebarAndRailPins(t *testing.T) { | ||
| 104 | 104 | t.Fatalf("labels after picker click: %+v err=%v", iss.Labels, err) |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | ||
| 108 | func 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 | 3 | // keyboard shortcuts. Every action degrades cleanly without JS. |
| 4 | 4 | (() => { |
| 5 | 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 | 25 | const isTyping = (el) => { |
| 8 | 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 | 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 | 53 | if (pre.dataset.copyWired) continue; |
| 36 | 54 | pre.dataset.copyWired = '1'; |
| 37 | const code = pre.querySelector('code'); | |
| 38 | if (!code) continue; | |
| 55 | const code = pre.querySelector('code') || pre; | |
| 39 | 56 | const wrap = document.createElement('div'); |
| 40 | 57 | wrap.className = 'copywrap'; |
| 41 | 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 | 430 | if (document.readyState === 'loading') { |
| 329 | document.addEventListener('DOMContentLoaded', () => initCopyButtons()); | |
| 431 | document.addEventListener('DOMContentLoaded', () => { initCopyButtons(); initScrollSpy(); }); | |
| 330 | 432 | } else { |
| 331 | 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 | 2205 | @media (max-width: 34rem) { |
| 2206 | 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; } | |
| 2233 | nav.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; } | |
| 2249 | pre.copyable { margin: var(--sp-2) 0 0; } | |
| 2250 | html.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 | 1 | {{define "width"}}wide{{end}} |
| 2 | 2 | {{define "title"}}account settings{{end}} |
| 3 | 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 | 9 | {{if .Notice}}<p class="error" role="alert">{{.Notice}}{{if .Reauth}} <a href="/login">Sign in again</a>{{end}}</p>{{end}} |
| 6 | 10 | {{if .Message}}<p class="notice" role="status">{{.Message}}</p>{{end}} |
| 7 | 11 | |
| 8 | 12 | <div class="withcol narrow"> |
| 9 | <nav class="sidecol" aria-label="Sections"> | |
| 13 | <nav class="sidecol sticky" aria-label="Sections" data-scrollspy="1"> | |
| 10 | 14 | <details class="sidedrop"> |
| 11 | 15 | <summary><span class="sideword">Sections</span></summary> |
| 12 | 16 | <div class="grp"><h2 class="colhead">Sections</h2> |
| @@ -17,15 +21,15 @@ | ||
| 17 | 21 | <li><a href="#pgp">OpenPGP keys</a></li> |
| 18 | 22 | <li><a href="#notifications">Notifications</a></li> |
| 19 | 23 | <li><a href="#appearance">Appearance</a></li> |
| 20 | <li><a href="#export">Export</a></li> | |
| 21 | 24 | <li><a href="#tokens">API tokens</a></li> |
| 25 | <li><a href="#export">Export</a></li> | |
| 22 | 26 | <li><a href="#cli">On the command line</a></li> |
| 23 | 27 | <li><a href="#delete">Delete account</a></li> |
| 24 | 28 | </ul></div> |
| 25 | 29 | </details> |
| 26 | 30 | </nav> |
| 27 | 31 | <div class="colmain"> |
| 28 | <section id="profile"><h2>Profile</h2> | |
| 32 | <section id="profile" class="setcard"><h2>Profile</h2> | |
| 29 | 33 | <p class="meta">Shown on your profile page, <a href="/{{.Viewer}}">/{{.Viewer}}</a>.</p> |
| 30 | 34 | <form method="post" action="/settings" class="setform stack"> |
| 31 | 35 | <input type="hidden" name="field" value="profile"> |
| @@ -35,20 +39,20 @@ | ||
| 35 | 39 | <input type="text" id="p-website" name="website" value="{{.Profile.Website}}" placeholder="https://example.org"> |
| 36 | 40 | <label for="p-links">Links</label> |
| 37 | 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 | 43 | </form> |
| 40 | 44 | <h3>About</h3> |
| 41 | 45 | <p class="meta">The longer text below your repositories is a file: |
| 42 | 46 | <code>profile/README.md</code> in <a href="/{{.AboutRepo}}">{{.AboutRepo}}</a>. |
| 43 | 47 | Write it with a push, or edit it here.</p> |
| 44 | {{if .AboutEdit}}<p><a class="btn" href="{{.AboutEdit}}">Edit {{.Profile.AboutPath}}</a></p> | |
| 45 | {{else}}<form method="post" action="/settings" class="setform"> | |
| 48 | {{if .AboutEdit}}<p><a class="button btn" href="{{.AboutEdit}}">Edit {{.Profile.AboutPath}}</a></p> | |
| 49 | {{else}}<form method="post" action="/settings" class="actions"> | |
| 46 | 50 | <input type="hidden" name="field" value="profile-repo"> |
| 47 | 51 | <button type="submit" class="btn">Create {{.AboutRepo}}</button> |
| 48 | 52 | </form>{{end}} |
| 49 | 53 | </section> |
| 50 | 54 | |
| 51 | <section id="keys"><h2>SSH keys</h2> | |
| 55 | <section id="keys" class="setcard"><h2>SSH keys</h2> | |
| 52 | 56 | <p class="meta">Your keys are your identity here. A <code>full</code> key can run |
| 53 | 57 | commands and push; a <code>git</code> key can only move git data (e.g., CI).</p> |
| 54 | 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 | 61 | <td>{{.Label}}</td> |
| 58 | 62 | <td class="mono">{{.Fingerprint}}</td> |
| 59 | 63 | <td>{{.Algo}}</td> |
| 60 | <td>{{.Scope}}</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> | |
| 64 | <td><span class="chip">{{.Scope}}</span></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 | 68 | </tr> |
| 63 | 69 | {{end}}</table></div> |
| 64 | 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 | 81 | <option value="full">full: commands and git</option> |
| 76 | 82 | <option value="git">git: git transport only</option> |
| 77 | 83 | </select> |
| 78 | <button type="submit" class="btn">Add key</button> | |
| 84 | <span class="btngroup"><button type="submit">Add key</button></span> | |
| 79 | 85 | </form> |
| 80 | 86 | </details> |
| 81 | 87 | </section> |
| 82 | 88 | |
| 83 | <section id="emails"><h2>Email addresses</h2> | |
| 89 | <section id="emails" class="setcard"><h2>Email addresses</h2> | |
| 84 | 90 | <p class="meta">A verified address ties signed commits to this |
| 85 | 91 | account and where notifications go.</p> |
| 86 | 92 | {{if .Emails}}<ul class="plain"> |
| 87 | {{range .Emails}}<li>{{.Address}} | |
| 93 | {{range .Emails}}<li><span>{{.Address}}</span> | |
| 88 | 94 | {{if .Primary}}<span class="chip">primary</span>{{end}} |
| 89 | 95 | {{if .Verified}}<span class="badge badge-verified">verified{{with .VerifiedBy}} · {{.}}{{end}}</span> |
| 90 | 96 | {{else}}<span class="badge badge-unsigned">unverified</span>{{end}} |
| 91 | 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 | 101 | {{end}}</ul>{{end}} |
| 94 | 102 | <details class="editbox"> |
| 95 | <summary>Add an address</summary> | |
| 103 | <summary>Add or verify an address</summary> | |
| 96 | 104 | <form method="post" action="/settings" class="setform"> |
| 97 | 105 | <input type="hidden" name="field" value="email-add"> |
| 98 | 106 | <label for="address">Address</label> |
| @@ -108,7 +116,7 @@ account and where notifications go.</p> | ||
| 108 | 116 | </details> |
| 109 | 117 | </section> |
| 110 | 118 | |
| 111 | <section id="pgp"><h2>OpenPGP keys</h2> | |
| 119 | <section id="pgp" class="setcard"><h2>OpenPGP keys</h2> | |
| 112 | 120 | <p class="meta">Only needed if you sign commits with GPG. SSH signing |
| 113 | 121 | (<code>gpg.format = ssh</code>) uses the keys above.</p> |
| 114 | 122 | {{if .PGP}}<div class="tablewrap"><table class="keys"> |
| @@ -116,7 +124,9 @@ account and where notifications go.</p> | ||
| 116 | 124 | {{range .PGP}}<tr> |
| 117 | 125 | <td class="mono">{{.Fingerprint}}</td> |
| 118 | 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 | 130 | </tr> |
| 121 | 131 | {{end}}</table></div> |
| 122 | 132 | {{else}}<p class="none">No OpenPGP keys.</p>{{end}} |
| @@ -126,40 +136,36 @@ account and where notifications go.</p> | ||
| 126 | 136 | <input type="hidden" name="field" value="pgp-add"> |
| 127 | 137 | <label for="pgpkey">Armored public key</label> |
| 128 | 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 | 140 | </form> |
| 131 | 141 | </details> |
| 132 | 142 | </section> |
| 133 | 143 | |
| 134 | <section id="notifications"><h2>Notifications</h2> | |
| 135 | <form method="post" action="/settings" class="setform"> | |
| 144 | <section id="notifications" class="setcard"><h2>Notifications</h2> | |
| 145 | <form method="post" action="/settings" class="setform" data-autosave="1"> | |
| 136 | 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 | 148 | <div class="check"><input type="checkbox" id="notify-mail" name="mail" value="on"{{if .MailOn}} checked{{end}}></div> |
| 139 | 149 | <button type="submit" class="btn">Save</button> |
| 140 | 150 | </form> |
| 141 | <p class="meta">Enable to receive activity alerts by email. Login links will arrive regardless of this setting.</p> | |
| 142 | {{if .ReplyOffered}}<form method="post" action="/settings" class="setform"> | |
| 151 | {{if .ReplyOffered}}<form method="post" action="/settings" class="setform" data-autosave="1"> | |
| 143 | 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 | 154 | <div class="check"><input type="checkbox" id="notify-reply" name="reply" value="on"{{if .ReplyOn}} checked{{end}}></div> |
| 146 | 155 | <button type="submit" class="btn">Save</button> |
| 147 | </form> | |
| 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> | |
| 149 | {{end}}<form method="post" action="/settings" class="setform"> | |
| 156 | </form>{{end}} | |
| 157 | <form method="post" action="/settings" class="setform" data-autosave="1"> | |
| 150 | 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 | 160 | <div class="check"><input type="checkbox" id="notify-watch" name="watch" value="on"{{if .WatchOn}} checked{{end}}></div> |
| 153 | 161 | <button type="submit" class="btn">Save</button> |
| 154 | 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> | |
| 156 | <form method="post" action="/settings" class="setform"> | |
| 163 | <form method="post" action="/settings" class="setform" data-autosave="1"> | |
| 157 | 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 | 166 | <div class="check"><input type="checkbox" id="notify-push" name="push" value="on"{{if .PushOn}} checked{{end}}></div> |
| 160 | 167 | <button type="submit" class="btn">Save</button> |
| 161 | 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 | 169 | <h3>Devices</h3> |
| 164 | 170 | {{if .Devices}}<div class="tablewrap"><table class="keys nowrap"> |
| 165 | 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 | 174 | <td>{{.Label}}</td> |
| 169 | 175 | <td class="mono">{{.Token}}</td> |
| 170 | 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 | 180 | </tr> |
| 173 | 181 | {{end}}</table></div> |
| 174 | 182 | {{else}}<p class="none">No registered devices.</p>{{end}} |
| 175 | <p class="meta">Devices register themselves from the iOS app; there is no | |
| 176 | form here to add one, since a browser cannot produce an APNs token.</p> | |
| 183 | <p class="meta">Devices register themselves from the iOS app; a browser cannot produce an APNs token.</p> | |
| 177 | 184 | </section> |
| 178 | 185 | |
| 179 | <section id="appearance"><h2>Appearance</h2> | |
| 180 | <form method="post" action="/settings" class="setform"> | |
| 186 | <section id="appearance" class="setcard"><h2>Appearance</h2> | |
| 187 | <form method="post" action="/settings" class="setform" data-autosave="1"> | |
| 181 | 188 | <input type="hidden" name="field" value="theme"> |
| 182 | <label for="theme">Colour scheme</label> | |
| 183 | <select id="theme" name="theme"> | |
| 184 | <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> | |
| 186 | <option value="dark"{{if eq .ThemeSetting "dark"}} selected{{end}}>dark</option> | |
| 189 | <div><label for="theme">Colour scheme</label><p class="hint">Matches <code>gitbay web theme set</code>.</p></div> | |
| 190 | <select id="theme" name="theme" data-live-theme="1"> | |
| 191 | <option value="system"{{if eq .ThemeSetting "system"}} selected{{end}}>Follow the browser</option> | |
| 192 | <option value="light"{{if eq .ThemeSetting "light"}} selected{{end}}>Light</option> | |
| 193 | <option value="dark"{{if eq .ThemeSetting "dark"}} selected{{end}}>Dark</option> | |
| 187 | 194 | </select> |
| 188 | 195 | <button type="submit" class="btn">Save</button> |
| 189 | 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> | |
| 191 | <form method="post" action="/settings" class="setform"> | |
| 197 | <form method="post" action="/settings" class="setform" data-autosave="1"> | |
| 192 | 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 | 200 | <select id="layout" name="layout"> |
| 195 | <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> | |
| 201 | <option value="unified"{{if ne .DiffSetting "split"}} selected{{end}}>Unified</option> | |
| 202 | <option value="split"{{if eq .DiffSetting "split"}} selected{{end}}>Side by side</option> | |
| 197 | 203 | </select> |
| 198 | 204 | <button type="submit" class="btn">Save</button> |
| 199 | 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 | |
| 205 | JSON bundle, the same one <code>gitbay auth export</code> writes. Keys are | |
| 206 | never included; a replayed bundle's emails arrive unverified.</p> | |
| 207 | <p><a href="/settings/export">Download bundle</a></p> | |
| 208 | 206 | </section> |
| 209 | 207 | |
| 210 | <section id="tokens"><h2>API tokens</h2> | |
| 211 | <p class="meta">A token signs in the iOS app, or a script, without your | |
| 212 | password. A phone app needs full scope to comment and merge; full scope | |
| 213 | on an admin account can administer the instance, so give a token the | |
| 214 | narrowest scope and shortest lifetime the job needs.</p> | |
| 208 | <section id="tokens" class="setcard"><h2>API tokens</h2> | |
| 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> | |
| 215 | 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 | 212 | {{if .Tokens}}<div class="tablewrap"><table class="keys nowrap"> |
| 218 | 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 | 214 | {{range .Tokens}}<tr> |
| @@ -222,7 +217,9 @@ narrowest scope and shortest lifetime the job needs.</p> | ||
| 222 | 217 | <td>{{when .Created}}</td> |
| 223 | 218 | <td>{{.Expires}}</td> |
| 224 | 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 | 223 | </tr> |
| 227 | 224 | {{end}}</table></div> |
| 228 | 225 | {{else}}<p class="none">No API tokens.</p>{{end}} |
| @@ -239,28 +236,27 @@ narrowest scope and shortest lifetime the job needs.</p> | ||
| 239 | 236 | </select> |
| 240 | 237 | <label for="token-ttl">Expires after</label> |
| 241 | 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 | 240 | </form> |
| 244 | 241 | </details> |
| 245 | 242 | </section> |
| 246 | 243 | |
| 247 | <section id="cli"><h2>On the command line</h2> | |
| 248 | <p class="meta">No page here yet, and nothing refusing one.</p> | |
| 249 | <pre class="message" tabindex="0">gitbay web sessions list # browser sessions | |
| 250 | gitbay admin ... # instance administration</pre> | |
| 251 | <p class="meta">All of it works from stock OpenSSH too, with the CLI's | |
| 252 | grouping words dropped: <code>ssh git@{{.Host}} whoami</code>, | |
| 253 | <code>ssh git@{{.Host}} web sessions list</code>.</p> | |
| 244 | <section id="export" class="setcard"><h2>Export</h2> | |
| 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> | |
| 246 | <p><a class="button btn" href="/settings/export">Download bundle</a></p> | |
| 247 | </section> | |
| 248 | ||
| 249 | <section id="cli" class="setcard"><h2>On the command line</h2> | |
| 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 | |
| 252 | ssh git@{{.Host}} whoami</code></pre> | |
| 254 | 253 | </section> |
| 255 | 254 | |
| 256 | <section id="delete"><h2>Delete account</h2> | |
| 257 | <p class="meta">Deletes your repositories, snippets, keys and addresses. | |
| 258 | Issues, merge requests and comments you wrote on other people's | |
| 259 | repositories stay, under the name <code>ghost</code>. A link is mailed to | |
| 260 | your primary address; once it is opened the account is disabled, and it | |
| 261 | is 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> | |
| 255 | <section id="delete" class="setcard setcard-danger"><h2>Delete account</h2> | |
| 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> | |
| 257 | <details class="popover"><summary class="button danger">Delete account…</summary><div class="popmenu"> | |
| 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> | |
| 259 | </div></details> | |
| 264 | 260 | </section> |
| 265 | 261 | </div> |
| 266 | 262 | </div> |
internal/web/templates/admin.html +32 −12
| @@ -1,15 +1,35 @@ | ||
| 1 | 1 | {{define "width"}}wide{{end}} |
| 2 | 2 | {{define "title"}}admin · {{.Site}}{{end}} |
| 3 | 3 | {{define "content"}} |
| 4 | <h1>Admin</h1> | |
| 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> | |
| 6 | <p class="meta"><a href="/admin/users">Accounts</a>: view every instance user account.</p> | |
| 4 | <div class="adminhead"> | |
| 5 | <div> | |
| 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 | 28 | <div class="withcol narrow"> |
| 9 | <nav class="sidecol" aria-label="Sections"> | |
| 29 | <nav class="sidecol sticky" aria-label="Sections" data-scrollspy="1"> | |
| 10 | 30 | <details class="sidedrop"> |
| 11 | 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 | 33 | <ul> |
| 14 | 34 | <li><a href="#webhooks">Webhook deliveries</a></li> |
| 15 | 35 | <li><a href="#mail">Mail</a></li> |
| @@ -23,7 +43,7 @@ | ||
| 23 | 43 | <div class="colmain"> |
| 24 | 44 | |
| 25 | 45 | {{with .Queues.Webhooks}} |
| 26 | <section id="webhooks"> | |
| 46 | <section id="webhooks" class="setcard"> | |
| 27 | 47 | <h2>Webhook deliveries <span class="count">{{.Pending}}</span></h2> |
| 28 | 48 | <p class="meta">{{.Pending}} pending · {{.Retrying}} retrying · {{.Failed}} dead-lettered{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p> |
| 29 | 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 | 53 | {{end}} |
| 34 | 54 | |
| 35 | 55 | {{with .Queues.Mail}} |
| 36 | <section id="mail"> | |
| 56 | <section id="mail" class="setcard"> | |
| 37 | 57 | <h2>Mail <span class="count">{{.Pending}}</span></h2> |
| 38 | 58 | <p class="meta">{{.Pending}} pending · {{.Retrying}} retrying · {{.Failed}} failed{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p> |
| 39 | 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 | 62 | </section> |
| 43 | 63 | {{end}} |
| 44 | 64 | |
| 45 | {{/* A push row names the device id, never the token, as dashboard does. */}} | |
| 46 | 65 | {{with .Queues.Push}} |
| 47 | <section id="push"> | |
| 66 | <section id="push" class="setcard"> | |
| 48 | 67 | <h2>Push <span class="count">{{.Pending}}</span></h2> |
| 49 | 68 | <p class="meta">{{.Pending}} pending · {{.Retrying}} retrying · {{.Failed}} failed{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p> |
| 50 | 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 | 73 | {{end}} |
| 55 | 74 | |
| 56 | 75 | {{with .Queues.Mirrors}} |
| 57 | <section id="mirrors"> | |
| 76 | <section id="mirrors" class="setcard"> | |
| 58 | 77 | <h2>Mirrors <span class="count">{{.Errors}}</span></h2> |
| 59 | 78 | <p class="meta">{{.Dirty}} waiting for a sync · {{.Errors}} with a failed last sync</p> |
| 60 | 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 | 83 | {{end}} |
| 65 | 84 | |
| 66 | 85 | {{with .Queues.Builds}} |
| 67 | <section id="builds"> | |
| 86 | <section id="builds" class="setcard"> | |
| 68 | 87 | <h2>Builds <span class="count">{{.Pending}}</span></h2> |
| 69 | 88 | <p class="meta">{{.Pending}} pending · {{.Running}} running{{if .OldestPending}} · oldest pending {{when .OldestPending}}{{end}}</p> |
| 70 | 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 | 93 | {{end}} |
| 75 | 94 | |
| 76 | 95 | {{with .Queues.Deps}} |
| 77 | <section id="deps"> | |
| 96 | <section id="deps" class="setcard"> | |
| 78 | 97 | <h2>Dependency checks <span class="count">{{.Errors}}</span></h2> |
| 79 | 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 | 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 | 102 | {{end}} |
| 84 | 103 | </div> |
| 85 | 104 | </div> |
| 105 | </div> | |
| 86 | 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 | 1 | {{define "width"}}wide{{end}} |
| 6 | 2 | {{define "title"}}accounts · admin · {{.Site}}{{end}} |
| 7 | 3 | {{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}}{{if .Reauth}} <a href="/login">Sign in again</a>{{end}}</p>{{end}} | |
| 4 | <div class="adminhead"> | |
| 5 | <div> | |
| 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"> | |
| 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> | |
| 11 | <nav class="tabs admintabs" aria-label="Admin"> | |
| 12 | <a href="/admin">Queues</a> | |
| 13 | <a aria-current="page" href="/admin/users">Accounts</a> | |
| 18 | 14 | </nav> |
| 19 | 15 | |
| 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> | |
| 16 | {{if .Notice}}<p class="notice" role="status">{{.Notice}}{{if .Reauth}} <a href="/login">Sign in again</a>{{end}}</p>{{end}} | |
| 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 | 33 | <tbody> |
| 23 | 34 | {{range .Users}}<tr> |
| 24 | 35 | <td><a href="/{{.Username}}">{{.Username}}</a>{{if .Admin}} <span class="chip">admin</span>{{end}}</td> |
| @@ -27,54 +38,53 @@ | ||
| 27 | 38 | <td>{{if .LastSeen}}{{when .LastSeen}}{{else}}never{{end}}</td> |
| 28 | 39 | <td class="acts"> |
| 29 | 40 | {{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> | |
| 41 | <details class="popover"><summary class="popbtn">Demote</summary><div class="popmenu"> | |
| 42 | <form method="post" action="/admin/users" class="popform"> | |
| 43 | <input type="hidden" name="field" value="demote"> | |
| 44 | <input type="hidden" name="user" value="{{.Username}}"> | |
| 45 | <input type="hidden" name="state" value="{{$.State}}"> | |
| 46 | {{template "confirmfield" .Username}}<button type="submit" class="btn">Demote</button> | |
| 47 | </form> | |
| 48 | </div></details> | |
| 36 | 49 | {{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> | |
| 50 | <details class="popover"><summary class="popbtn">Promote</summary><div class="popmenu"> | |
| 51 | <form method="post" action="/admin/users" class="popform"> | |
| 52 | <input type="hidden" name="field" value="promote"> | |
| 53 | <input type="hidden" name="user" value="{{.Username}}"> | |
| 54 | <input type="hidden" name="state" value="{{$.State}}"> | |
| 55 | {{template "confirmfield" .Username}}<button type="submit" class="btn">Promote</button> | |
| 56 | </form> | |
| 57 | </div></details> | |
| 52 | 58 | {{end}} |
| 53 | 59 | {{if eq .State "disabled"}} |
| 54 | <form method="post" action="/admin/users" class="actions"> | |
| 60 | <form method="post" action="/admin/users" class="inline"> | |
| 55 | 61 | <input type="hidden" name="field" value="enable"> |
| 56 | 62 | <input type="hidden" name="user" value="{{.Username}}"> |
| 57 | 63 | <input type="hidden" name="state" value="{{$.State}}"> |
| 58 | 64 | <button type="submit" class="btn">Enable</button> |
| 59 | 65 | </form> |
| 60 | 66 | {{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 | <details class="popover"><summary class="popbtn popbtn-danger">Disable</summary><div class="popmenu"> | |
| 68 | <form method="post" action="/admin/users" class="popform"> | |
| 69 | <input type="hidden" name="field" value="disable"> | |
| 70 | <input type="hidden" name="user" value="{{.Username}}"> | |
| 71 | <input type="hidden" name="state" value="{{$.State}}"> | |
| 72 | {{template "confirmfield" .Username}}<button type="submit" class="danger">Disable</button> | |
| 73 | </form> | |
| 74 | </div></details> | |
| 67 | 75 | {{end}} |
| 68 | 76 | </td> |
| 69 | 77 | </tr> |
| 70 | 78 | {{end}} |
| 71 | 79 | </tbody></table></div>{{else}}<p class="none">No account matches</p>{{end}} |
| 72 | 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 | |
| 75 | asserting an address stay on the command line: each takes a key, mints | |
| 76 | a credential, or cannot be undone.</p> | |
| 77 | <pre tabindex="0"><code>gitbay admin user create <name> --key - < key.pub | |
| 83 | <section class="setcard"> | |
| 84 | <h2>CLI administration</h2> | |
| 85 | <p class="meta">Creating and deleting accounts, issuing invites, and asserting addresses stay on the command line:</p> | |
| 86 | <pre class="copyable" tabindex="0"><code>gitbay admin user create <name> --key - < key.pub | |
| 78 | 87 | gitbay admin user delete <name> --yes |
| 79 | 88 | gitbay admin invite --email <address></code></pre> |
| 89 | </section> | |
| 80 | 90 | {{end}} |