forge
Explore
Log in

Don't you dare go Hollow

Align the runners table, confirm Delete and Disable, copy buttons on the registration token page

Browse files at this commit

d8b7772ae84b24a46597bbdc58e50c57745429dfAhmet Kaan GümüşParent: 978cff3
  • style
    • align the runners table, confirm Delete and Disable, copy buttons on the registration token page
Show full message
💄 style: align the runners table, confirm Delete and Disable, copy buttons on the registration token page

Headers share the cells' padding and every column is left aligned. The concurrency source is an inline tag so each cell is one line. Delete and Disable use the confirm-inline popover (naming the runner), next to the existing Restart ones. The token page gets Copy buttons and a register command with --config.
.claude/worktrees/agent-ad1405076d481b501added+1 -0
@@ -0,0 +1 @@
1+Subproject commit b0649a2b0f6303ab2693fd24f529b4a0d052ee2e
.claude/worktrees/agent-ae096288739fa88c6added+1 -0
@@ -0,0 +1 @@
1+Subproject commit b0649a2b0f6303ab2693fd24f529b4a0d052ee2e
.claude/worktrees/agent-afb59039872290877added+1 -0
@@ -0,0 +1 @@
1+Subproject commit b0649a2b0f6303ab2693fd24f529b4a0d052ee2e
crates/forge-web/assets/nav.jsmodified+17 -0
@@ -1389,6 +1389,23 @@
13891389 .then(function () { done(true); }, function () { done(false); });
13901390 }
13911391
1392+ // `data-copy="<id>"`: copies the text of that element, with the same Copied/Failed feedback.
1393+ document.addEventListener('click', function (e) {
1394+ var cb = e.target && e.target.closest ? e.target.closest('[data-copy]') : null;
1395+ if (!cb || cb.disabled) { return; }
1396+ var src = document.getElementById(cb.getAttribute('data-copy'));
1397+ if (!src) { return; }
1398+ e.preventDefault();
1399+ var label = cb.getAttribute('data-label') || cb.textContent;
1400+ cb.setAttribute('data-label', label);
1401+ cb.disabled = true;
1402+ var done = function (ok) {
1403+ cb.textContent = cb.getAttribute(ok ? 'data-copied' : 'data-failed') || label;
1404+ setTimeout(function () { cb.textContent = label; cb.disabled = false; }, 1500);
1405+ };
1406+ copyText(src.textContent.trim()).then(function () { done(true); }, function () { done(false); });
1407+ }, false);
1408+
13921409 document.addEventListener('click', function (e) {
13931410 var btn = e.target && e.target.closest ? e.target.closest('[data-copy-log]') : null;
13941411 if (btn) { e.preventDefault(); copyLog(btn); }
crates/forge-web/src/pages/admin_runners.rsmodified+68 -16
@@ -264,7 +264,7 @@ fn back_to_list(notice: &str) -> SeeOther {
264264 /// The command a new runner runs. The base URL comes from the server config.
265265 fn register_command(base_url: &str, token: &str) -> String {
266266 format!(
267- "forge runner register --url {} --token {token} --name <name> --labels linux",
267+ "forge runner register --url {} --token {token} --name <name> --labels linux,x86_64 --config ~/.config/forge-runner/runner.toml",
268268 base_url.trim_end_matches('/')
269269 )
270270 }
@@ -342,16 +342,17 @@ async fn runners_view(
342342 </td>
343343 <td class="runner-actions">
344344 <div class="runner-action-row">
345- <form method="post" action=(row.toggle_action.as_str()) class="inline-form">
346- <input type="hidden" name="csrf" value=(csrf.as_str())>
347- <input type="hidden" name="disabled" value=(if row.disabled { "0" } else { "1" })>
348- <button type="submit">(if row.disabled { g::t(lang, K::Enable) } else { g::t(lang, K::Disable) })</button>
349- </form>
345+ if row.disabled {
346+ <form method="post" action=(row.toggle_action.as_str()) class="inline-form">
347+ <input type="hidden" name="csrf" value=(csrf.as_str())>
348+ <input type="hidden" name="disabled" value="0">
349+ <button type="submit">(g::t(lang, K::Enable))</button>
350+ </form>
351+ } else {
352+ confirm_post(lang: lang, csrf: csrf.as_str(), action: row.toggle_action.as_str(), label: g::t(lang, K::Disable), message: disable_message(lang, row.name.as_str()), confirm: s(lang, "Yes, disable", "Evet, devre dışı bırak"), danger: false, fields: vec![("disabled", "1")])
353+ }
350354 restart_control(lang: lang, csrf: csrf.as_str(), action: row.restart_action.as_str(), back: "list", can_restart: row.can_restart, pending: row.restart_pending)
351- <form method="post" action=(row.delete_action.as_str()) class="inline-form">
352- <input type="hidden" name="csrf" value=(csrf.as_str())>
353- <button type="submit" class="danger">(i18n::t(lang, Key::Delete))</button>
354- </form>
355+ confirm_post(lang: lang, csrf: csrf.as_str(), action: row.delete_action.as_str(), label: i18n::t(lang, Key::Delete), message: delete_message(lang, row.name.as_str()), confirm: s(lang, "Yes, delete", "Evet, sil"), danger: true, fields: vec![])
355356 </div>
356357 </td>
357358 </tr>
@@ -373,6 +374,51 @@ async fn runners_view(
373374 })
374375 }
375376
377+/// A destructive button that opens the shared `confirm-inline` popover; the POST only fires from the
378+/// confirm button inside it, and Cancel closes the popover.
379+#[component]
380+async fn confirm_post(
381+ lang: Lang,
382+ csrf: &str,
383+ action: &str,
384+ label: &'static str,
385+ message: String,
386+ confirm: &'static str,
387+ danger: bool,
388+ fields: Vec<(&'static str, &'static str)>,
389+) -> Result<impl View> {
390+ Ok(view! {
391+ <details class="confirm-inline">
392+ <summary class=(if danger { "button danger" } else { "button" })>(label)</summary>
393+ <div class="confirm-pop">
394+ <p>(message)</p>
395+ <form method="post" action=(action)>
396+ <input type="hidden" name="csrf" value=(csrf)>
397+ for (name, value) in fields.iter() {
398+ <input type="hidden" name=(*name) value=(*value)>
399+ }
400+ <button type="submit" class=(if danger { "danger" } else { "primary" })>(confirm)</button>
401+ <button type="button" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button>
402+ </form>
403+ </div>
404+ </details>
405+ })
406+}
407+
408+fn delete_message(lang: Lang, name: &str) -> String {
409+ match lang {
410+ Lang::Tr => format!("{name} silinsin mi? Makinenin sonrasında yeniden kaydolması gerekir."),
411+ _ => format!("Delete runner {name}? The machine has to register again afterwards."),
412+ }
413+}
414+
415+fn disable_message(lang: Lang, name: &str) -> String {
416+ match lang {
417+ Lang::Tr => format!("{name} devre dışı bırakılsın mı? Yeni iş almayı bırakır."),
418+ _ => format!("Disable runner {name}? It stops taking new jobs."),
419+ }
420+}
421+
376422 /// The restart control of a runner: a confirm popover with the two ways to restart. A runner that
377423 /// reports no boot id is too old to obey, so the control is off with a hint. While a restart is
378424 /// pending the control shows that instead, and the runner clears it by coming back with a new id.
@@ -429,7 +475,7 @@ async fn concurrency_form(
429475 <input type="number" name="value" value=(value) min="1" max="64" step="1" inputmode="numeric" required="required" aria-label=(s(lang, "Concurrency", "Eşzamanlılık"))>
430476 <button type="submit">(s(lang, "Save", "Kaydet"))</button>
431477 if has_override {
432- <button type="submit" name="reset" value="1" formnovalidate="formnovalidate">(s(lang, "Use runner.toml value", "runner.toml değerini kullan"))</button>
478+ <button type="submit" name="reset" value="1" formnovalidate="formnovalidate" title=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan")) aria-label=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan"))>(s(lang, "Reset", "Sıfırla"))</button>
433479 }
434480 if !source.is_empty() {
435481 <span class="muted small runner-source">(source)</span>
@@ -455,10 +501,16 @@ async fn token_view(
455501 </section>
456502 <section class="card">
457503 <h2>(g::t(lang, K::Token))</h2>
458- <pre><code>(token.as_str())</code></pre>
504+ <div class="copy-box">
505+ <code id="reg-token">(token.as_str())</code>
506+ <button type="button" data-copy="reg-token" data-copied=(s(lang, "Copied", "Kopyalandı")) data-failed=(s(lang, "Failed", "Başarısız"))>(s(lang, "Copy", "Kopyala"))</button>
507+ </div>
459508 <h2>(g::t(lang, K::RegisterARunner))</h2>
460509 <p class="muted small">(g::t(lang, K::ReplacePrefix))<code>"<name>"</code>(g::t(lang, K::ReplaceSuffix))</p>
461- <pre><code>(command.as_str())</code></pre>
510+ <div class="copy-box">
511+ <code id="reg-command">(command.as_str())</code>
512+ <button type="button" data-copy="reg-command" data-copied=(s(lang, "Copied", "Kopyalandı")) data-failed=(s(lang, "Failed", "Başarısız"))>(s(lang, "Copy", "Kopyala"))</button>
513+ </div>
462514 <p><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p>
463515 </section>
464516 })
@@ -1419,7 +1471,7 @@ mod tests {
14191471 let cmd = register_command("https://forge.example/", "tok123");
14201472 assert_eq!(
14211473 cmd,
1422- "forge runner register --url https://forge.example --token tok123 --name <name> --labels linux"
1474+ "forge runner register --url https://forge.example --token tok123 --name <name> --labels linux,x86_64 --config ~/.config/forge-runner/runner.toml"
14231475 );
14241476 }
14251477
@@ -1507,7 +1559,7 @@ mod tests {
15071559 .to_owned();
15081560 assert!(created.contains("forge runner register --url"));
15091561 assert!(
1510- created.contains("--name &lt;name&gt; --labels linux"),
1562+ created.contains("--name &lt;name&gt; --labels linux,x86_64 --config ~/.config/forge-runner/runner.toml"),
15111563 "placeholder is escaped"
15121564 );
15131565 assert_eq!(
@@ -1779,7 +1831,7 @@ mod tests {
17791831 );
17801832 let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await;
17811833 assert!(list.contains(r#"value="3""#));
1782- assert!(list.contains("Use runner.toml value"));
1834+ assert!(list.contains("Use the runner.toml value"));
17831835 assert!(list.contains(r#"data-live="/admin/runners/events""#));
17841836
17851837 // Out of range, wrong kind of field and a read-only field change nothing.
style/main.scssmodified+62 -24
@@ -4242,34 +4242,24 @@ $ansi-colours: (
42424242
42434243 // Admin runners table: every column sizes to its content except Name and Labels, which share the
42444244 // slack in fixed proportions so a long label list wraps instead of pushing the rest to the right.
4245-// Cells are vertically centered; the actions sit flush right. State reuses the `.ci-state` pill.
4245+// All text is left aligned and th and td share the base padding, so a header sits over its cell.
4246+// Cells are single lines centered on one axis; the actions sit flush right. State reuses `.ci-state`.
42464247 .table.runners {
42474248 th.runner-conc,
42484249 td.runner-conc,
42494250 th.runner-running,
42504251 td.runner-running,
4252+ th.runner-build,
4253+ td.runner-build,
42514254 th.runner-seen,
4252- th.runner-state,
42534255 td.runner-seen,
4256+ th.runner-state,
42544257 td.runner-state {
42554258 width: 1%;
42564259 white-space: nowrap;
42574260 }
42584261
4259- th.runner-conc,
4260- td.runner-conc {
4261- min-width: 9.75rem;
4262- }
4263-
4264- th.runner-build,
4265- td.runner-build {
4266- width: 1%;
4267- white-space: nowrap;
4268- }
4269-
4270- th.runner-running,
42714262 td.runner-running {
4272- text-align: right;
42734263 font-variant-numeric: tabular-nums;
42744264 }
42754265
@@ -4288,7 +4278,7 @@ $ansi-colours: (
42884278
42894279 th,
42904280 td {
4291- padding-right: 8px;
4281+ padding-right: 10px;
42924282 }
42934283
42944284 th.runner-actions,
@@ -4297,13 +4287,19 @@ $ansi-colours: (
42974287 }
42984288
42994289 td.runner-name {
4290+ min-width: 6rem;
43004291 max-width: 11rem;
43014292 overflow-wrap: anywhere;
43024293 }
43034294
4304- td.runner-state .ci-state {
4295+ td.runner-build > *,
4296+ td.runner-state > * {
43054297 vertical-align: middle;
43064298 }
4299+
4300+ form.runner-conc-form {
4301+ flex-wrap: nowrap;
4302+ }
43074303 }
43084304
43094305 .runner-label-list {
@@ -4324,8 +4320,8 @@ $ansi-colours: (
43244320 white-space: nowrap;
43254321 }
43264322
4327-// Runner concurrency and config forms: a compact input and its buttons on one line, the source hint
4328-// on a line of its own below. `form.` outranks the later plain `.inline-form { display: inline }`.
4323+// Runner concurrency and config forms: a compact input, its buttons and the muted source tag on one
4324+// line. `form.` outranks the later plain `.inline-form { display: inline }`.
43294325 form.runner-conc-form {
43304326 display: flex;
43314327 flex-wrap: wrap;
@@ -4336,7 +4332,7 @@ form.runner-conc-form {
43364332 input[type="number"] {
43374333 width: 4.5rem;
43384334 min-width: 0;
4339- text-align: center;
4335+ text-align: left;
43404336 }
43414337
43424338 input,
@@ -4348,8 +4344,7 @@ form.runner-conc-form {
43484344 }
43494345
43504346 .runner-source {
4351- flex-basis: 100%;
4352- line-height: 1.2;
4347+ flex: none;
43534348 white-space: nowrap;
43544349 }
43554350 }
@@ -4385,11 +4380,22 @@ form.runner-conc-form {
43854380 margin: 0;
43864381 }
43874382
4388- button {
4383+ .confirm-inline {
4384+ display: flex;
4385+ }
4386+
4387+ button,
4388+ summary.button {
43894389 box-sizing: border-box;
4390- min-width: 5rem;
4390+ min-width: 4.25rem;
43914391 height: var(--control-h);
43924392 margin: 0;
4393+ padding-inline: 12px;
4394+ }
4395+
4396+ // The popover buttons keep their natural width.
4397+ .confirm-pop button {
4398+ min-width: 0;
43934399 }
43944400 }
43954401
@@ -6436,3 +6442,35 @@ button.ci-job-last {
64366442 }
64376443
64386444 @import "account_admin";
6445+
6446+// A monospace value with its Copy button on the right; long values wrap inside the box.
6447+.copy-box {
6448+ display: flex;
6449+ align-items: flex-start;
6450+ gap: 12px;
6451+ margin: 0 0 16px;
6452+ padding: 10px 12px;
6453+ border: 1px solid var(--border);
6454+ border-radius: var(--radius);
6455+ background: var(--code-bg);
6456+
6457+ code {
6458+ flex: 1;
6459+ min-width: 0;
6460+ padding: 0;
6461+ background: none;
6462+ font-family: var(--mono);
6463+ font-size: 0.8125rem;
6464+ line-height: 1.6;
6465+ overflow-wrap: anywhere;
6466+ white-space: pre-wrap;
6467+ user-select: all;
6468+ }
6469+
6470+ button {
6471+ flex: none;
6472+ height: var(--control-h);
6473+ margin: 0;
6474+ min-width: 5rem;
6475+ }
6476+}