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 @@
1389 .then(function () { done(true); }, function () { done(false); });1389 .then(function () { done(true); }, function () { done(false); });
1390 }1390 }
1391 1391
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+
1392 document.addEventListener('click', function (e) {1409 document.addEventListener('click', function (e) {
1393 var btn = e.target && e.target.closest ? e.target.closest('[data-copy-log]') : null;1410 var btn = e.target && e.target.closest ? e.target.closest('[data-copy-log]') : null;
1394 if (btn) { e.preventDefault(); copyLog(btn); }1411 if (btn) { e.preventDefault(); copyLog(btn); }
crates/forge-web/src/pages/admin_runners.rsmodified+65 -13
@@ -264,7 +264,7 @@ fn back_to_list(notice: &str) -> SeeOther {
264 /// The command a new runner runs. The base URL comes from the server config.264 /// The command a new runner runs. The base URL comes from the server config.
265 fn register_command(base_url: &str, token: &str) -> String {265 fn register_command(base_url: &str, token: &str) -> String {
266 format!(266 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",
268 base_url.trim_end_matches('/')268 base_url.trim_end_matches('/')
269 )269 )
270 }270 }
@@ -342,16 +342,17 @@ async fn runners_view(
342 </td>342 </td>
343 <td class="runner-actions">343 <td class="runner-actions">
344 <div class="runner-action-row">344 <div class="runner-action-row">
345+ if row.disabled {
345 <form method="post" action=(row.toggle_action.as_str()) class="inline-form">346 <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="csrf" value=(csrf.as_str())>
347- <input type="hidden" name="disabled" value=(if row.disabled { "0" } else { "1" })>348+ <input type="hidden" name="disabled" value="0">
348- <button type="submit">(if row.disabled { g::t(lang, K::Enable) } else { g::t(lang, K::Disable) })</button>349+ <button type="submit">(g::t(lang, K::Enable))</button>
349 </form>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+ }
350 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)354 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">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![])
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 </div>356 </div>
356 </td>357 </td>
357 </tr>358 </tr>
@@ -373,6 +374,51 @@ async fn runners_view(
373 })374 })
374 }375 }
375 376
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+
376 /// The restart control of a runner: a confirm popover with the two ways to restart. A runner that422 /// The restart control of a runner: a confirm popover with the two ways to restart. A runner that
377 /// reports no boot id is too old to obey, so the control is off with a hint. While a restart is423 /// reports no boot id is too old to obey, so the control is off with a hint. While a restart is
378 /// pending the control shows that instead, and the runner clears it by coming back with a new id.424 /// 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(
429 <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"))>475 <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"))>
430 <button type="submit">(s(lang, "Save", "Kaydet"))</button>476 <button type="submit">(s(lang, "Save", "Kaydet"))</button>
431 if has_override {477 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>
433 }479 }
434 if !source.is_empty() {480 if !source.is_empty() {
435 <span class="muted small runner-source">(source)</span>481 <span class="muted small runner-source">(source)</span>
@@ -455,10 +501,16 @@ async fn token_view(
455 </section>501 </section>
456 <section class="card">502 <section class="card">
457 <h2>(g::t(lang, K::Token))</h2>503 <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>
459 <h2>(g::t(lang, K::RegisterARunner))</h2>508 <h2>(g::t(lang, K::RegisterARunner))</h2>
460 <p class="muted small">(g::t(lang, K::ReplacePrefix))<code>"<name>"</code>(g::t(lang, K::ReplaceSuffix))</p>509 <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>
462 <p><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p>514 <p><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p>
463 </section>515 </section>
464 })516 })
@@ -1419,7 +1471,7 @@ mod tests {
1419 let cmd = register_command("https://forge.example/", "tok123");1471 let cmd = register_command("https://forge.example/", "tok123");
1420 assert_eq!(1472 assert_eq!(
1421 cmd,1473 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"
1423 );1475 );
1424 }1476 }
1425 1477
@@ -1507,7 +1559,7 @@ mod tests {
1507 .to_owned();1559 .to_owned();
1508 assert!(created.contains("forge runner register --url"));1560 assert!(created.contains("forge runner register --url"));
1509 assert!(1561 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"),
1511 "placeholder is escaped"1563 "placeholder is escaped"
1512 );1564 );
1513 assert_eq!(1565 assert_eq!(
@@ -1779,7 +1831,7 @@ mod tests {
1779 );1831 );
1780 let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await;1832 let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await;
1781 assert!(list.contains(r#"value="3""#));1833 assert!(list.contains(r#"value="3""#));
1782- assert!(list.contains("Use runner.toml value"));1834+ assert!(list.contains("Use the runner.toml value"));
1783 assert!(list.contains(r#"data-live="/admin/runners/events""#));1835 assert!(list.contains(r#"data-live="/admin/runners/events""#));
1784 1836
1785 // Out of range, wrong kind of field and a read-only field change nothing.1837 // 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: (
4242 4242
4243 // Admin runners table: every column sizes to its content except Name and Labels, which share the4243 // Admin runners table: every column sizes to its content except Name and Labels, which share the
4244 // slack in fixed proportions so a long label list wraps instead of pushing the rest to the right.4244 // 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`.
4246 .table.runners {4247 .table.runners {
4247 th.runner-conc,4248 th.runner-conc,
4248 td.runner-conc,4249 td.runner-conc,
4249 th.runner-running,4250 th.runner-running,
4250 td.runner-running,4251 td.runner-running,
4252+ th.runner-build,
4253+ td.runner-build,
4251 th.runner-seen,4254 th.runner-seen,
4252- th.runner-state,
4253 td.runner-seen,4255 td.runner-seen,
4256+ th.runner-state,
4254 td.runner-state {4257 td.runner-state {
4255 width: 1%;4258 width: 1%;
4256 white-space: nowrap;4259 white-space: nowrap;
4257 }4260 }
4258 4261
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,
4271 td.runner-running {4262 td.runner-running {
4272- text-align: right;
4273 font-variant-numeric: tabular-nums;4263 font-variant-numeric: tabular-nums;
4274 }4264 }
4275 4265
@@ -4288,7 +4278,7 @@ $ansi-colours: (
4288 4278
4289 th,4279 th,
4290 td {4280 td {
4291- padding-right: 8px;4281+ padding-right: 10px;
4292 }4282 }
4293 4283
4294 th.runner-actions,4284 th.runner-actions,
@@ -4297,13 +4287,19 @@ $ansi-colours: (
4297 }4287 }
4298 4288
4299 td.runner-name {4289 td.runner-name {
4290+ min-width: 6rem;
4300 max-width: 11rem;4291 max-width: 11rem;
4301 overflow-wrap: anywhere;4292 overflow-wrap: anywhere;
4302 }4293 }
4303 4294
4304- td.runner-state .ci-state {4295+ td.runner-build > *,
4296+ td.runner-state > * {
4305 vertical-align: middle;4297 vertical-align: middle;
4306 }4298 }
4299+
4300+ form.runner-conc-form {
4301+ flex-wrap: nowrap;
4302+ }
4307 }4303 }
4308 4304
4309 .runner-label-list {4305 .runner-label-list {
@@ -4324,8 +4320,8 @@ $ansi-colours: (
4324 white-space: nowrap;4320 white-space: nowrap;
4325 }4321 }
4326 4322
4327-// Runner concurrency and config forms: a compact input and its buttons on one line, the source hint4323+// Runner concurrency and config forms: a compact input, its buttons and the muted source tag on one
4328-// on a line of its own below. `form.` outranks the later plain `.inline-form { display: inline }`.4324+// line. `form.` outranks the later plain `.inline-form { display: inline }`.
4329 form.runner-conc-form {4325 form.runner-conc-form {
4330 display: flex;4326 display: flex;
4331 flex-wrap: wrap;4327 flex-wrap: wrap;
@@ -4336,7 +4332,7 @@ form.runner-conc-form {
4336 input[type="number"] {4332 input[type="number"] {
4337 width: 4.5rem;4333 width: 4.5rem;
4338 min-width: 0;4334 min-width: 0;
4339- text-align: center;4335+ text-align: left;
4340 }4336 }
4341 4337
4342 input,4338 input,
@@ -4348,8 +4344,7 @@ form.runner-conc-form {
4348 }4344 }
4349 4345
4350 .runner-source {4346 .runner-source {
4351- flex-basis: 100%;4347+ flex: none;
4352- line-height: 1.2;
4353 white-space: nowrap;4348 white-space: nowrap;
4354 }4349 }
4355 }4350 }
@@ -4385,11 +4380,22 @@ form.runner-conc-form {
4385 margin: 0;4380 margin: 0;
4386 }4381 }
4387 4382
4388- button {4383+ .confirm-inline {
4384+ display: flex;
4385+ }
4386+
4387+ button,
4388+ summary.button {
4389 box-sizing: border-box;4389 box-sizing: border-box;
4390- min-width: 5rem;4390+ min-width: 4.25rem;
4391 height: var(--control-h);4391 height: var(--control-h);
4392 margin: 0;4392 margin: 0;
4393+ padding-inline: 12px;
4394+ }
4395+
4396+ // The popover buttons keep their natural width.
4397+ .confirm-pop button {
4398+ min-width: 0;
4393 }4399 }
4394 }4400 }
4395 4401
@@ -6436,3 +6442,35 @@ button.ci-job-last {
6436 }6442 }
6437 6443
6438 @import "account_admin";6444 @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+}