Align the runners table, confirm Delete and Disable, copy buttons on the registration token page
Browse files at this commitd8b7772ae84b24a46597bbdc58e50c57745429dfParent: 978cff3- style
- align the runners table, confirm Delete and Disable, copy buttons on the registration token page
6 changed files +150 -40
- .claude/worktrees/agent-ad1405076d481b501 +1 -0
- .claude/worktrees/agent-ae096288739fa88c6 +1 -0
- .claude/worktrees/agent-afb59039872290877 +1 -0
- crates/forge-web/assets/nav.js +17 -0
- crates/forge-web/src/pages/admin_runners.rs +68 -16
- style/main.scss +62 -24
.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 | 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 | 1409 | document.addEventListener('click', function (e) { |
| 1393 | 1410 | var btn = e.target && e.target.closest ? e.target.closest('[data-copy-log]') : null; |
| 1394 | 1411 | 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 { | ||
| 264 | 264 | /// The command a new runner runs. The base URL comes from the server config. |
| 265 | 265 | fn register_command(base_url: &str, token: &str) -> String { |
| 266 | 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 | 268 | base_url.trim_end_matches('/') |
| 269 | 269 | ) |
| 270 | 270 | } |
| @@ -342,16 +342,17 @@ async fn runners_view( | ||
| 342 | 342 | </td> |
| 343 | 343 | <td class="runner-actions"> |
| 344 | 344 | <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 | + } | |
| 350 | 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"> | |
| 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![]) | |
| 355 | 356 | </div> |
| 356 | 357 | </td> |
| 357 | 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 | 422 | /// The restart control of a runner: a confirm popover with the two ways to restart. A runner that |
| 377 | 423 | /// reports no boot id is too old to obey, so the control is off with a hint. While a restart is |
| 378 | 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 | 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 | 476 | <button type="submit">(s(lang, "Save", "Kaydet"))</button> |
| 431 | 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 | 480 | if !source.is_empty() { |
| 435 | 481 | <span class="muted small runner-source">(source)</span> |
| @@ -455,10 +501,16 @@ async fn token_view( | ||
| 455 | 501 | </section> |
| 456 | 502 | <section class="card"> |
| 457 | 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 | 508 | <h2>(g::t(lang, K::RegisterARunner))</h2> |
| 460 | 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 | 514 | <p><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p> |
| 463 | 515 | </section> |
| 464 | 516 | }) |
| @@ -1419,7 +1471,7 @@ mod tests { | ||
| 1419 | 1471 | let cmd = register_command("https://forge.example/", "tok123"); |
| 1420 | 1472 | assert_eq!( |
| 1421 | 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 | 1559 | .to_owned(); |
| 1508 | 1560 | assert!(created.contains("forge runner register --url")); |
| 1509 | 1561 | assert!( |
| 1510 | - created.contains("--name <name> --labels linux"), | |
| 1562 | + created.contains("--name <name> --labels linux,x86_64 --config ~/.config/forge-runner/runner.toml"), | |
| 1511 | 1563 | "placeholder is escaped" |
| 1512 | 1564 | ); |
| 1513 | 1565 | assert_eq!( |
| @@ -1779,7 +1831,7 @@ mod tests { | ||
| 1779 | 1831 | ); |
| 1780 | 1832 | let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; |
| 1781 | 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 | 1835 | assert!(list.contains(r#"data-live="/admin/runners/events""#)); |
| 1784 | 1836 | |
| 1785 | 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 | 4243 | // Admin runners table: every column sizes to its content except Name and Labels, which share the |
| 4244 | 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 | 4247 | .table.runners { |
| 4247 | 4248 | th.runner-conc, |
| 4248 | 4249 | td.runner-conc, |
| 4249 | 4250 | th.runner-running, |
| 4250 | 4251 | td.runner-running, |
| 4252 | + th.runner-build, | |
| 4253 | + td.runner-build, | |
| 4251 | 4254 | th.runner-seen, |
| 4252 | - th.runner-state, | |
| 4253 | 4255 | td.runner-seen, |
| 4256 | + th.runner-state, | |
| 4254 | 4257 | td.runner-state { |
| 4255 | 4258 | width: 1%; |
| 4256 | 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 | 4262 | td.runner-running { |
| 4272 | - text-align: right; | |
| 4273 | 4263 | font-variant-numeric: tabular-nums; |
| 4274 | 4264 | } |
| 4275 | 4265 | |
| @@ -4288,7 +4278,7 @@ $ansi-colours: ( | ||
| 4288 | 4278 | |
| 4289 | 4279 | th, |
| 4290 | 4280 | td { |
| 4291 | - padding-right: 8px; | |
| 4281 | + padding-right: 10px; | |
| 4292 | 4282 | } |
| 4293 | 4283 | |
| 4294 | 4284 | th.runner-actions, |
| @@ -4297,13 +4287,19 @@ $ansi-colours: ( | ||
| 4297 | 4287 | } |
| 4298 | 4288 | |
| 4299 | 4289 | td.runner-name { |
| 4290 | + min-width: 6rem; | |
| 4300 | 4291 | max-width: 11rem; |
| 4301 | 4292 | overflow-wrap: anywhere; |
| 4302 | 4293 | } |
| 4303 | 4294 | |
| 4304 | - td.runner-state .ci-state { | |
| 4295 | + td.runner-build > *, | |
| 4296 | + td.runner-state > * { | |
| 4305 | 4297 | vertical-align: middle; |
| 4306 | 4298 | } |
| 4299 | + | |
| 4300 | + form.runner-conc-form { | |
| 4301 | + flex-wrap: nowrap; | |
| 4302 | + } | |
| 4307 | 4303 | } |
| 4308 | 4304 | |
| 4309 | 4305 | .runner-label-list { |
| @@ -4324,8 +4320,8 @@ $ansi-colours: ( | ||
| 4324 | 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 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 }`. | |
| 4329 | 4325 | form.runner-conc-form { |
| 4330 | 4326 | display: flex; |
| 4331 | 4327 | flex-wrap: wrap; |
| @@ -4336,7 +4332,7 @@ form.runner-conc-form { | ||
| 4336 | 4332 | input[type="number"] { |
| 4337 | 4333 | width: 4.5rem; |
| 4338 | 4334 | min-width: 0; |
| 4339 | - text-align: center; | |
| 4335 | + text-align: left; | |
| 4340 | 4336 | } |
| 4341 | 4337 | |
| 4342 | 4338 | input, |
| @@ -4348,8 +4344,7 @@ form.runner-conc-form { | ||
| 4348 | 4344 | } |
| 4349 | 4345 | |
| 4350 | 4346 | .runner-source { |
| 4351 | - flex-basis: 100%; | |
| 4352 | - line-height: 1.2; | |
| 4347 | + flex: none; | |
| 4353 | 4348 | white-space: nowrap; |
| 4354 | 4349 | } |
| 4355 | 4350 | } |
| @@ -4385,11 +4380,22 @@ form.runner-conc-form { | ||
| 4385 | 4380 | margin: 0; |
| 4386 | 4381 | } |
| 4387 | 4382 | |
| 4388 | - button { | |
| 4383 | + .confirm-inline { | |
| 4384 | + display: flex; | |
| 4385 | + } | |
| 4386 | + | |
| 4387 | + button, | |
| 4388 | + summary.button { | |
| 4389 | 4389 | box-sizing: border-box; |
| 4390 | - min-width: 5rem; | |
| 4390 | + min-width: 4.25rem; | |
| 4391 | 4391 | height: var(--control-h); |
| 4392 | 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 | 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 | +} |