Tidy the runners table and redesign the runner page like the server settings
Browse files at this commit489034cbad4fc3f956d820f6d9ae6791a3349166Parent: 1979f80- style
- tidy the runners table and redesign the runner page like the server settings
2 changed files +653 -134
- crates/forge-web/src/pages/admin_runners.rs +567 -123
- style/main.scss +86 -11
crates/forge-web/src/pages/admin_runners.rsmodified+567 -123
| @@ -42,7 +42,7 @@ fn s(lang: Lang, en: &'static str, tr: &'static str) -> &'static str { | |||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | /// Extra notice words: (word, English, Turkish, is an error). | 44 | /// Extra notice words: (word, English, Turkish, is an error). |
| 45 | -const EXTRA_NOTICES: [(&str, &str, &str, bool); 5] = [ | 45 | +const EXTRA_NOTICES: [(&str, &str, &str, bool); 6] = [ |
| 46 | ( | 46 | ( |
| 47 | "saved", | 47 | "saved", |
| 48 | "Saved. The runner picks it up on its next check-in.", | 48 | "Saved. The runner picks it up on its next check-in.", |
| @@ -61,6 +61,12 @@ const EXTRA_NOTICES: [(&str, &str, &str, bool); 5] = [ | |||
| 61 | "Üzerine yazma kaldırıldı. runner.toml değeri yeniden kullanılıyor.", | 61 | "Üzerine yazma kaldırıldı. runner.toml değeri yeniden kullanılıyor.", |
| 62 | false, | 62 | false, |
| 63 | ), | 63 | ), |
| 64 | + ( | ||
| 65 | + "unchanged", | ||
| 66 | + "Nothing changed.", | ||
| 67 | + "Hiçbir şey değişmedi.", | ||
| 68 | + false, | ||
| 69 | + ), | ||
| 64 | ( | 70 | ( |
| 65 | "invalid", | 71 | "invalid", |
| 66 | "That value is not valid for this field. Nothing was changed.", | 72 | "That value is not valid for this field. Nothing was changed.", |
| @@ -104,6 +110,9 @@ struct ConfigForm { | |||
| 104 | /// `detail` returns to the runner's page, anything else to the list. | 110 | /// `detail` returns to the runner's page, anything else to the list. |
| 105 | #[serde(default)] | 111 | #[serde(default)] |
| 106 | back: String, | 112 | back: String, |
| 113 | + /// The tab to return to on the runner's page. | ||
| 114 | + #[serde(default)] | ||
| 115 | + tab: String, | ||
| 107 | } | 116 | } |
| 108 | 117 | ||
| 109 | #[derive(Deserialize)] | 118 | #[derive(Deserialize)] |
| @@ -135,6 +144,8 @@ struct RunnerRow { | |||
| 135 | running: u32, | 144 | running: u32, |
| 136 | /// The build the runner reported, or empty for an older runner. | 145 | /// The build the runner reported, or empty for an older runner. |
| 137 | build: String, | 146 | build: String, |
| 147 | + /// Its commit sha alone, for the table and the stat strip; the full string is the tooltip. | ||
| 148 | + build_short: String, | ||
| 138 | /// "up to date", "outdated" or "unknown", with the `.ci-state` class that colours it. | 149 | /// "up to date", "outdated" or "unknown", with the `.ci-state` class that colours it. |
| 139 | build_label: &'static str, | 150 | build_label: &'static str, |
| 140 | build_class: &'static str, | 151 | build_class: &'static str, |
| @@ -199,6 +210,12 @@ fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { | |||
| 199 | concurrency_source, | 210 | concurrency_source, |
| 200 | has_override: runner.concurrency_override.is_some(), | 211 | has_override: runner.concurrency_override.is_some(), |
| 201 | running: runner.running_jobs, | 212 | running: runner.running_jobs, |
| 213 | + build_short: runner | ||
| 214 | + .reported | ||
| 215 | + .build | ||
| 216 | + .as_deref() | ||
| 217 | + .map(|b| build::commit_of(b).unwrap_or(b).to_owned()) | ||
| 218 | + .unwrap_or_default(), | ||
| 202 | build: runner.reported.build.clone().unwrap_or_default(), | 219 | build: runner.reported.build.clone().unwrap_or_default(), |
| 203 | build_label, | 220 | build_label, |
| 204 | build_class, | 221 | build_class, |
| @@ -286,9 +303,9 @@ async fn runners_view( | |||
| 286 | concurrency_form(lang: lang, csrf: csrf.as_str(), action: row.config_action.as_str(), key: "concurrency", value: row.concurrency.as_str(), source: row.concurrency_source, has_override: row.has_override, back: "list") | 303 | concurrency_form(lang: lang, csrf: csrf.as_str(), action: row.config_action.as_str(), key: "concurrency", value: row.concurrency.as_str(), source: row.concurrency_source, has_override: row.has_override, back: "list") |
| 287 | </td> | 304 | </td> |
| 288 | <td class="runner-running small">(row.running.to_string())</td> | 305 | <td class="runner-running small">(row.running.to_string())</td> |
| 289 | - <td class="runner-build small"> | 306 | + <td class="runner-build small" title=(row.build.as_str())> |
| 290 | - if !row.build.is_empty() { | 307 | + if !row.build_short.is_empty() { |
| 291 | - <span>(row.build.as_str())</span> | 308 | + <code>(row.build_short.as_str())</code> |
| 292 | } | 309 | } |
| 293 | <span class=(format!("ci-state {}", row.build_class))>(row.build_label)</span> | 310 | <span class=(format!("ci-state {}", row.build_class))>(row.build_label)</span> |
| 294 | </td> | 311 | </td> |
| @@ -524,7 +541,6 @@ struct FieldRow { | |||
| 524 | /// The override is stored but the runner has not started with it yet. | 541 | /// The override is stored but the runner has not started with it yet. |
| 525 | pending: bool, | 542 | pending: bool, |
| 526 | has_override: bool, | 543 | has_override: bool, |
| 527 | - reported: bool, | ||
| 528 | } | 544 | } |
| 529 | 545 | ||
| 530 | /// A JSON config value as the admin reads and types it: lists are comma separated. | 546 | /// A JSON config value as the admin reads and types it: lists are comma separated. |
| @@ -568,56 +584,324 @@ fn field_rows(runner: &CiRunner) -> Vec<FieldRow> { | |||
| 568 | value: shown.as_ref().map(show_value).unwrap_or_default(), | 584 | value: shown.as_ref().map(show_value).unwrap_or_default(), |
| 569 | source: if overridden.is_some() { | 585 | source: if overridden.is_some() { |
| 570 | "UI" | 586 | "UI" |
| 571 | - } else { | 587 | + } else if shown.is_some() { |
| 572 | "runner.toml" | 588 | "runner.toml" |
| 589 | + } else { | ||
| 590 | + "default" | ||
| 573 | }, | 591 | }, |
| 574 | kind: field.kind, | 592 | kind: field.kind, |
| 575 | pending, | 593 | pending, |
| 576 | has_override: overridden.is_some(), | 594 | has_override: overridden.is_some(), |
| 577 | - reported: shown.is_some(), | ||
| 578 | } | 595 | } |
| 579 | }) | 596 | }) |
| 580 | .collect() | 597 | .collect() |
| 581 | } | 598 | } |
| 582 | 599 | ||
| 583 | -/// The input for one editable field. | ||
| 584 | -#[component] | ||
| 585 | -async fn field_input(key: &'static str, value: &str, lang: Lang) -> Result<impl View> { | ||
| 586 | - let aria = key; | ||
| 587 | - Ok(view! { | ||
| 588 | - if key == "auto_update" { | ||
| 589 | - <select name="value" aria-label=(aria)> | ||
| 590 | - <option value="true" selected=(sel(value == "true"))>"true"</option> | ||
| 591 | - <option value="false" selected=(sel(value == "false"))>"false"</option> | ||
| 592 | - </select> | ||
| 593 | - } else if key == "executor" { | ||
| 594 | - <select name="value" aria-label=(aria)> | ||
| 595 | - <option value="builtin" selected=(sel(value == "builtin"))>"builtin"</option> | ||
| 596 | - <option value="podman" selected=(sel(value == "podman"))>"podman"</option> | ||
| 597 | - </select> | ||
| 598 | - } else if key == "sandbox.userns" { | ||
| 599 | - <select name="value" aria-label=(aria)> | ||
| 600 | - <option value="auto" selected=(sel(value == "auto"))>"auto"</option> | ||
| 601 | - <option value="single" selected=(sel(value == "single"))>"single"</option> | ||
| 602 | - <option value="subuid" selected=(sel(value == "subuid"))>"subuid"</option> | ||
| 603 | - </select> | ||
| 604 | - } else if matches!(key, "limits.pids" | "limits.image_max_gb" | "images.keep_days" | "cache_max_gib" | "concurrency") { | ||
| 605 | - <input type="number" name="value" value=(value) step="1" inputmode="numeric" aria-label=(aria) min=(if key == "concurrency" { "1" } else { "0" }) max=(if key == "concurrency" { Some("64") } else { None })> | ||
| 606 | - } else { | ||
| 607 | - <input type="text" name="value" value=(value) aria-label=(aria) placeholder=(s(lang, "(from runner.toml)", "(runner.toml'dan)")) autocomplete="off" spellcheck="false"> | ||
| 608 | - } | ||
| 609 | - }) | ||
| 610 | -} | ||
| 611 | - | ||
| 612 | fn sel(on: bool) -> Option<&'static str> { | 600 | fn sel(on: bool) -> Option<&'static str> { |
| 613 | on.then_some("selected") | 601 | on.then_some("selected") |
| 614 | } | 602 | } |
| 615 | 603 | ||
| 604 | +/// The detail page tabs: slug and the config keys on it. `identity` is the read-only block. | ||
| 605 | +const TABS: [(&str, &[&str]); 5] = [ | ||
| 606 | + ( | ||
| 607 | + "general", | ||
| 608 | + &["concurrency", "labels", "executor", "auto_update"], | ||
| 609 | + ), | ||
| 610 | + ("limits", &["limits.memory", "limits.cpus", "limits.pids"]), | ||
| 611 | + ( | ||
| 612 | + "storage", | ||
| 613 | + &[ | ||
| 614 | + "work_dir", | ||
| 615 | + "limits.image_max_gb", | ||
| 616 | + "images.keep_days", | ||
| 617 | + "cache_max_gib", | ||
| 618 | + ], | ||
| 619 | + ), | ||
| 620 | + ("sandbox", &["sandbox.userns"]), | ||
| 621 | + ("identity", &[]), | ||
| 622 | +]; | ||
| 623 | + | ||
| 624 | +fn tab_label(lang: Lang, slug: &str) -> &'static str { | ||
| 625 | + match slug { | ||
| 626 | + "general" => s(lang, "General", "Genel"), | ||
| 627 | + "limits" => s(lang, "Limits", "Sınırlar"), | ||
| 628 | + "storage" => s(lang, "Storage", "Depolama"), | ||
| 629 | + "sandbox" => s(lang, "Sandbox", "Kum havuzu"), | ||
| 630 | + _ => s(lang, "Identity", "Kimlik"), | ||
| 631 | + } | ||
| 632 | +} | ||
| 633 | + | ||
| 634 | +/// The tab slug from `?tab=`; anything unknown is the first tab. | ||
| 635 | +fn tab_from_query(cx: &Cx) -> &'static str { | ||
| 636 | + let wanted = uri(cx).query().and_then(|query| { | ||
| 637 | + form_urlencoded::parse(query.as_bytes()) | ||
| 638 | + .find(|(key, _)| key == "tab") | ||
| 639 | + .map(|(_, value)| value.into_owned()) | ||
| 640 | + }); | ||
| 641 | + TABS.iter() | ||
| 642 | + .map(|(slug, _)| *slug) | ||
| 643 | + .find(|slug| Some(*slug) == wanted.as_deref()) | ||
| 644 | + .unwrap_or("general") | ||
| 645 | +} | ||
| 646 | + | ||
| 647 | +/// The human label and the one-line hint of a config field. | ||
| 648 | +fn field_text(lang: Lang, key: &str) -> (&'static str, &'static str) { | ||
| 649 | + match key { | ||
| 650 | + "concurrency" => ( | ||
| 651 | + s(lang, "Concurrency", "Eşzamanlılık"), | ||
| 652 | + s( | ||
| 653 | + lang, | ||
| 654 | + "Jobs this runner runs at once, 1 to 64.", | ||
| 655 | + "Bu çalıştırıcının aynı anda yürüttüğü iş sayısı, 1 ile 64 arası.", | ||
| 656 | + ), | ||
| 657 | + ), | ||
| 658 | + "labels" => ( | ||
| 659 | + s(lang, "Labels", "Etiketler"), | ||
| 660 | + s( | ||
| 661 | + lang, | ||
| 662 | + "Comma separated. A job runs where its labels are all present.", | ||
| 663 | + "Virgülle ayrılır. İş, etiketlerinin hepsinin bulunduğu yerde çalışır.", | ||
| 664 | + ), | ||
| 665 | + ), | ||
| 666 | + "executor" => ( | ||
| 667 | + s(lang, "Executor", "Yürütücü"), | ||
| 668 | + s( | ||
| 669 | + lang, | ||
| 670 | + "How jobs run: builtin on the host, or podman in containers.", | ||
| 671 | + "İşlerin nasıl çalışacağı: sunucuda yerleşik ya da podman kapsayıcılarında.", | ||
| 672 | + ), | ||
| 673 | + ), | ||
| 674 | + "auto_update" => ( | ||
| 675 | + s(lang, "Auto update", "Otomatik güncelleme"), | ||
| 676 | + s( | ||
| 677 | + lang, | ||
| 678 | + "Replace the runner when the forge offers a newer build.", | ||
| 679 | + "Forge daha yeni bir sürüm sunduğunda çalıştırıcıyı güncelle.", | ||
| 680 | + ), | ||
| 681 | + ), | ||
| 682 | + "limits.memory" => ( | ||
| 683 | + s(lang, "Memory limit", "Bellek sınırı"), | ||
| 684 | + s( | ||
| 685 | + lang, | ||
| 686 | + "Per job, for example 2g or 512m.", | ||
| 687 | + "İş başına, örneğin 2g veya 512m.", | ||
| 688 | + ), | ||
| 689 | + ), | ||
| 690 | + "limits.cpus" => ( | ||
| 691 | + s(lang, "CPU limit", "CPU sınırı"), | ||
| 692 | + s( | ||
| 693 | + lang, | ||
| 694 | + "Per job, for example 2 or 1.5.", | ||
| 695 | + "İş başına, örneğin 2 veya 1.5.", | ||
| 696 | + ), | ||
| 697 | + ), | ||
| 698 | + "limits.pids" => ( | ||
| 699 | + s(lang, "Process limit", "İşlem sınırı"), | ||
| 700 | + s( | ||
| 701 | + lang, | ||
| 702 | + "Most processes one job may have running.", | ||
| 703 | + "Bir işin aynı anda çalıştırabileceği en çok işlem.", | ||
| 704 | + ), | ||
| 705 | + ), | ||
| 706 | + "work_dir" => ( | ||
| 707 | + s(lang, "Work directory", "Çalışma dizini"), | ||
| 708 | + s( | ||
| 709 | + lang, | ||
| 710 | + "Where checkouts and job files live on the runner host.", | ||
| 711 | + "Çıkışların ve iş dosyalarının çalıştırıcı sunucusundaki yeri.", | ||
| 712 | + ), | ||
| 713 | + ), | ||
| 714 | + "limits.image_max_gb" => ( | ||
| 715 | + s( | ||
| 716 | + lang, | ||
| 717 | + "Image cache max (GB)", | ||
| 718 | + "Kalıp önbelleği üst sınırı (GB)", | ||
| 719 | + ), | ||
| 720 | + s( | ||
| 721 | + lang, | ||
| 722 | + "Upper bound for stored container images.", | ||
| 723 | + "Saklanan kapsayıcı kalıpları için üst sınır.", | ||
| 724 | + ), | ||
| 725 | + ), | ||
| 726 | + "images.keep_days" => ( | ||
| 727 | + s(lang, "Keep images (days)", "Kalıpları sakla (gün)"), | ||
| 728 | + s( | ||
| 729 | + lang, | ||
| 730 | + "Unused images older than this are removed.", | ||
| 731 | + "Bundan eski ve kullanılmayan kalıplar silinir.", | ||
| 732 | + ), | ||
| 733 | + ), | ||
| 734 | + "cache_max_gib" => ( | ||
| 735 | + s( | ||
| 736 | + lang, | ||
| 737 | + "Build cache max (GiB)", | ||
| 738 | + "Derleme önbelleği üst sınırı (GiB)", | ||
| 739 | + ), | ||
| 740 | + s( | ||
| 741 | + lang, | ||
| 742 | + "Upper bound for the shared build cache.", | ||
| 743 | + "Ortak derleme önbelleği için üst sınır.", | ||
| 744 | + ), | ||
| 745 | + ), | ||
| 746 | + "sandbox.userns" => ( | ||
| 747 | + s(lang, "User namespaces", "Kullanıcı ad alanları"), | ||
| 748 | + s( | ||
| 749 | + lang, | ||
| 750 | + "How the sandbox maps user ids: auto, single or subuid.", | ||
| 751 | + "Kum havuzunun kullanıcı kimliklerini eşleme biçimi: auto, single veya subuid.", | ||
| 752 | + ), | ||
| 753 | + ), | ||
| 754 | + "name" => (s(lang, "Name", "Ad"), ""), | ||
| 755 | + "url" => (s(lang, "Forge URL", "Forge adresi"), ""), | ||
| 756 | + "runner_id" => (s(lang, "Runner id", "Çalıştırıcı kimliği"), ""), | ||
| 757 | + "runner_secret" => (s(lang, "Runner secret", "Çalıştırıcı sırrı"), ""), | ||
| 758 | + "registry" => (s(lang, "Registry", "Kayıt sunucusu"), ""), | ||
| 759 | + _ => ("", ""), | ||
| 760 | + } | ||
| 761 | +} | ||
| 762 | + | ||
| 763 | +/// The source badge text of a field. | ||
| 764 | +fn source_text(lang: Lang, source: &str) -> &'static str { | ||
| 765 | + match source { | ||
| 766 | + "UI" => s(lang, "UI", "Arayüz"), | ||
| 767 | + "runner.toml" => "runner.toml", | ||
| 768 | + _ => s(lang, "default", "varsayılan"), | ||
| 769 | + } | ||
| 770 | +} | ||
| 771 | + | ||
| 772 | +/// One option of a select: value, shown text, selected. | ||
| 773 | +type Choice = (&'static str, &'static str, bool); | ||
| 774 | + | ||
| 775 | +/// One editable field of the active tab, formatted for the template. | ||
| 776 | +struct DetailField { | ||
| 777 | + key: &'static str, | ||
| 778 | + label: &'static str, | ||
| 779 | + hint: &'static str, | ||
| 780 | + value: String, | ||
| 781 | + kind_label: &'static str, | ||
| 782 | + kind_class: &'static str, | ||
| 783 | + source_label: &'static str, | ||
| 784 | + pending_label: &'static str, | ||
| 785 | + has_override: bool, | ||
| 786 | + /// "text", "number" or "select". | ||
| 787 | + input: &'static str, | ||
| 788 | + min: &'static str, | ||
| 789 | + max: Option<&'static str>, | ||
| 790 | + options: Vec<Choice>, | ||
| 791 | +} | ||
| 792 | + | ||
| 793 | +fn detail_fields(lang: Lang, tab: &str, fields: &[FieldRow]) -> Vec<DetailField> { | ||
| 794 | + let keys = TABS | ||
| 795 | + .iter() | ||
| 796 | + .find(|(slug, _)| *slug == tab) | ||
| 797 | + .map_or(&[][..], |(_, keys)| *keys); | ||
| 798 | + keys.iter() | ||
| 799 | + .filter_map(|key| fields.iter().find(|f| f.key == *key)) | ||
| 800 | + .map(|f| { | ||
| 801 | + let (label, hint) = field_text(lang, f.key); | ||
| 802 | + let (kind_label, kind_class) = if f.kind == FieldKind::Live { | ||
| 803 | + (g::t(lang, K::SrvKindLive), "badge srv-live") | ||
| 804 | + } else { | ||
| 805 | + (g::t(lang, K::SrvKindRestart), "badge srv-restart") | ||
| 806 | + }; | ||
| 807 | + let choices: Vec<(&'static str, &'static str)> = match f.key { | ||
| 808 | + "auto_update" => vec![ | ||
| 809 | + ("true", s(lang, "On", "Açık")), | ||
| 810 | + ("false", s(lang, "Off", "Kapalı")), | ||
| 811 | + ], | ||
| 812 | + "executor" => vec![("builtin", "builtin"), ("podman", "podman")], | ||
| 813 | + "sandbox.userns" => { | ||
| 814 | + vec![("auto", "auto"), ("single", "single"), ("subuid", "subuid")] | ||
| 815 | + } | ||
| 816 | + _ => Vec::new(), | ||
| 817 | + }; | ||
| 818 | + let is_number = matches!( | ||
| 819 | + f.key, | ||
| 820 | + "limits.pids" | ||
| 821 | + | "limits.image_max_gb" | ||
| 822 | + | "images.keep_days" | ||
| 823 | + | "cache_max_gib" | ||
| 824 | + | "concurrency" | ||
| 825 | + ); | ||
| 826 | + DetailField { | ||
| 827 | + key: f.key, | ||
| 828 | + label, | ||
| 829 | + hint, | ||
| 830 | + value: f.value.clone(), | ||
| 831 | + kind_label, | ||
| 832 | + kind_class, | ||
| 833 | + source_label: source_text(lang, f.source), | ||
| 834 | + pending_label: if !f.pending { | ||
| 835 | + "" | ||
| 836 | + } else if f.kind == FieldKind::Live { | ||
| 837 | + s(lang, "next check-in", "sonraki yoklamada") | ||
| 838 | + } else { | ||
| 839 | + g::t(lang, K::SrvRestartNeeded) | ||
| 840 | + }, | ||
| 841 | + has_override: f.has_override, | ||
| 842 | + input: if !choices.is_empty() { | ||
| 843 | + "select" | ||
| 844 | + } else if is_number { | ||
| 845 | + "number" | ||
| 846 | + } else { | ||
| 847 | + "text" | ||
| 848 | + }, | ||
| 849 | + min: if f.key == "concurrency" { "1" } else { "0" }, | ||
| 850 | + max: (f.key == "concurrency").then_some("64"), | ||
| 851 | + options: if choices.is_empty() { | ||
| 852 | + Vec::new() | ||
| 853 | + } else { | ||
| 854 | + // An unreported field gets a blank first option, so saving the tab leaves it alone. | ||
| 855 | + std::iter::once(("", s(lang, "(from runner.toml)", "(runner.toml'dan)"))) | ||
| 856 | + .filter(|_| f.value.is_empty()) | ||
| 857 | + .chain(choices) | ||
| 858 | + .map(|(value, text)| (value, text, value == f.value)) | ||
| 859 | + .collect() | ||
| 860 | + }, | ||
| 861 | + } | ||
| 862 | + }) | ||
| 863 | + .collect() | ||
| 864 | +} | ||
| 865 | + | ||
| 866 | +/// The read-only identity entries: label and value. The secret is never shown. | ||
| 867 | +fn identity_rows(lang: Lang, fields: &[FieldRow]) -> Vec<(&'static str, String)> { | ||
| 868 | + fields | ||
| 869 | + .iter() | ||
| 870 | + .filter(|f| f.kind == FieldKind::ReadOnly) | ||
| 871 | + .map(|f| { | ||
| 872 | + let value = if f.key == "runner_secret" { | ||
| 873 | + s(lang, "hidden", "gizli").to_owned() | ||
| 874 | + } else if f.value.is_empty() { | ||
| 875 | + "-".to_owned() | ||
| 876 | + } else { | ||
| 877 | + f.value.clone() | ||
| 878 | + }; | ||
| 879 | + (field_text(lang, f.key).0, value) | ||
| 880 | + }) | ||
| 881 | + .collect() | ||
| 882 | +} | ||
| 883 | + | ||
| 616 | fn bytes_text(bytes: u64) -> String { | 884 | fn bytes_text(bytes: u64) -> String { |
| 617 | let gib = bytes as f64 / (1u64 << 30) as f64; | 885 | let gib = bytes as f64 / (1u64 << 30) as f64; |
| 618 | format!("{gib:.1} GiB") | 886 | format!("{gib:.1} GiB") |
| 619 | } | 887 | } |
| 620 | 888 | ||
| 889 | +fn or_dash(text: String) -> String { | ||
| 890 | + if text.is_empty() { | ||
| 891 | + "-".to_owned() | ||
| 892 | + } else { | ||
| 893 | + text | ||
| 894 | + } | ||
| 895 | +} | ||
| 896 | + | ||
| 897 | +fn tab_class(on: bool) -> &'static str { | ||
| 898 | + if on { | ||
| 899 | + "subnav-link current" | ||
| 900 | + } else { | ||
| 901 | + "subnav-link" | ||
| 902 | + } | ||
| 903 | +} | ||
| 904 | + | ||
| 621 | #[component] | 905 | #[component] |
| 622 | async fn runner_detail_view( | 906 | async fn runner_detail_view( |
| 623 | lang: Lang, | 907 | lang: Lang, |
| @@ -626,24 +910,47 @@ async fn runner_detail_view( | |||
| 626 | row: RunnerRow, | 910 | row: RunnerRow, |
| 627 | fields: Vec<FieldRow>, | 911 | fields: Vec<FieldRow>, |
| 628 | notice: Option<(&'static str, bool)>, | 912 | notice: Option<(&'static str, bool)>, |
| 629 | - action: String, | 913 | + tab: &'static str, |
| 630 | ) -> Result<impl View> { | 914 | ) -> Result<impl View> { |
| 631 | - let host_version = runner.reported.version.clone().unwrap_or_default(); | 915 | + let version = or_dash(runner.reported.version.clone().unwrap_or_default()); |
| 632 | - let host_cpus = runner | 916 | + let cpus = or_dash( |
| 633 | - .reported | 917 | + runner |
| 634 | - .cpus | 918 | + .reported |
| 635 | - .map(|n| n.to_string()) | 919 | + .cpus |
| 636 | - .unwrap_or_default(); | 920 | + .map(|n| n.to_string()) |
| 637 | - let host_mem = runner | 921 | + .unwrap_or_default(), |
| 638 | - .reported | 922 | + ); |
| 639 | - .memory_bytes | 923 | + let memory = or_dash( |
| 640 | - .map(bytes_text) | 924 | + runner |
| 641 | - .unwrap_or_default(); | 925 | + .reported |
| 926 | + .memory_bytes | ||
| 927 | + .map(bytes_text) | ||
| 928 | + .unwrap_or_default(), | ||
| 929 | + ); | ||
| 930 | + let in_use = if row.concurrency.is_empty() { | ||
| 931 | + row.running.to_string() | ||
| 932 | + } else { | ||
| 933 | + format!("{} / {}", row.running, row.concurrency) | ||
| 934 | + }; | ||
| 935 | + let shown = detail_fields(lang, tab, &fields); | ||
| 936 | + let identity = identity_rows(lang, &fields); | ||
| 937 | + let editing = tab != "identity"; | ||
| 938 | + let save_action = format!("{}/settings", row.detail_href); | ||
| 939 | + let reset_action = row.config_action.clone(); | ||
| 642 | Ok(view! { | 940 | Ok(view! { |
| 643 | <div data-live="/admin/runners/events"> | 941 | <div data-live="/admin/runners/events"> |
| 644 | <section class="page-head"> | 942 | <section class="page-head"> |
| 645 | - <h1>(runner.name.as_str())</h1> | 943 | + <div class="runner-head"> |
| 646 | - <p><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p> | 944 | + <h1>(runner.name.as_str())</h1> |
| 945 | + if row.disabled { | ||
| 946 | + <span class="ci-state runner-disabled">(g::t(lang, K::Disabled))</span> | ||
| 947 | + } else { | ||
| 948 | + <span class="ci-state ci-success">(g::t(lang, K::Enabled))</span> | ||
| 949 | + } | ||
| 950 | + </div> | ||
| 951 | + <div class="runner-head-actions"> | ||
| 952 | + <a href="/admin/runners">(g::t(lang, K::BackToRunners))</a> | ||
| 953 | + </div> | ||
| 647 | </section> | 954 | </section> |
| 648 | if let Some((text, is_error)) = notice { | 955 | if let Some((text, is_error)) = notice { |
| 649 | if is_error { | 956 | if is_error { |
| @@ -653,78 +960,80 @@ async fn runner_detail_view( | |||
| 653 | } | 960 | } |
| 654 | } | 961 | } |
| 655 | <section class="card"> | 962 | <section class="card"> |
| 656 | - <h2>(s(lang, "Status", "Durum"))</h2> | 963 | + <div class="srv-grid srv-stats"> |
| 657 | - <dl class="runner-facts"> | 964 | + <div class="srv-field"><span class="srv-label">(s(lang, "Running jobs", "Çalışan işler"))</span><strong>(in_use.as_str())</strong></div> |
| 658 | - <dt>(s(lang, "Running jobs", "Çalışan işler"))</dt><dd>(row.running.to_string())</dd> | 965 | + <div class="srv-field"><span class="srv-label">(g::t(lang, K::LastSeen))</span><strong title=(row.last_seen_full.as_str())>(row.last_seen.as_str())</strong></div> |
| 659 | - <dt>(g::t(lang, K::LastSeen))</dt><dd title=(row.last_seen_full.as_str())>(row.last_seen.as_str())</dd> | 966 | + <div class="srv-field"><span class="srv-label">(s(lang, "Build", "Derleme"))</span><strong class="runner-build-stat" title=(row.build.as_str())>(if row.build_short.is_empty() { "-" } else { row.build_short.as_str() })<span class=(format!("ci-state {}", row.build_class))>(row.build_label)</span></strong></div> |
| 660 | - <dt>(s(lang, "Build", "Derleme"))</dt> | 967 | + <div class="srv-field"><span class="srv-label">(s(lang, "Runner version", "Çalıştırıcı sürümü"))</span><strong>(version.as_str())</strong></div> |
| 661 | - <dd> | 968 | + <div class="srv-field"><span class="srv-label">(s(lang, "CPUs", "CPU sayısı"))</span><strong>(cpus.as_str())</strong></div> |
| 662 | - if !row.build.is_empty() { | 969 | + <div class="srv-field"><span class="srv-label">(s(lang, "Memory", "Bellek"))</span><strong>(memory.as_str())</strong></div> |
| 663 | - <span>(row.build.as_str())</span> | 970 | + </div> |
| 664 | - } | ||
| 665 | - <span class=(format!("ci-state {}", row.build_class))>(row.build_label)</span> | ||
| 666 | - </dd> | ||
| 667 | - if !host_version.is_empty() { | ||
| 668 | - <dt>(s(lang, "Runner version", "Çalıştırıcı sürümü"))</dt><dd>(host_version.as_str())</dd> | ||
| 669 | - } | ||
| 670 | - if !host_cpus.is_empty() { | ||
| 671 | - <dt>(s(lang, "CPUs", "CPU sayısı"))</dt><dd>(host_cpus.as_str())</dd> | ||
| 672 | - } | ||
| 673 | - if !host_mem.is_empty() { | ||
| 674 | - <dt>(s(lang, "Memory", "Bellek"))</dt><dd>(host_mem.as_str())</dd> | ||
| 675 | - } | ||
| 676 | - </dl> | ||
| 677 | </section> | 971 | </section> |
| 972 | + <nav class="subnav" aria-label=(s(lang, "Configuration", "Yapılandırma"))> | ||
| 973 | + for (slug, _) in TABS.iter() { | ||
| 974 | + <a class=(tab_class(*slug == tab)) href=(format!("{}?tab={}", row.detail_href, slug))>(tab_label(lang, slug))</a> | ||
| 975 | + } | ||
| 976 | + </nav> | ||
| 678 | <section class="card"> | 977 | <section class="card"> |
| 679 | - <h2>(s(lang, "Configuration", "Yapılandırma"))</h2> | 978 | + if editing { |
| 680 | - <p class="muted small">(s(lang, "Live fields apply on the runner's next check-in. Restart fields are stored now and apply when the runner next starts. A UI value beats runner.toml; resetting returns to runner.toml.", "Canlı alanlar çalıştırıcının sonraki yoklamasında uygulanır. Yeniden başlatma gerektiren alanlar şimdi saklanır, çalıştırıcı yeniden başlayınca uygulanır. Arayüzdeki değer runner.toml'u geçersiz kılar; sıfırlamak runner.toml'a döndürür."))</p> | 979 | + <form method="post" action=(save_action.as_str()) class="srv-form"> |
| 681 | - <div class="table-wrap"> | 980 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 682 | - <table class="table runner-config"> | 981 | + <input type="hidden" name="tab" value=(tab)> |
| 683 | - <thead> | 982 | + <div class="srv-grid"> |
| 684 | - <tr> | 983 | + for f in shown.iter() { |
| 685 | - <th>(s(lang, "Field", "Alan"))</th> | 984 | + <div class="srv-field"> |
| 686 | - <th>(s(lang, "Value", "Değer"))</th> | 985 | + <div class="srv-head"> |
| 687 | - <th>(s(lang, "Source", "Kaynak"))</th> | 986 | + <label class="srv-label" for=(format!("rf-{}", f.key))>(f.label)</label> |
| 688 | - <th>(s(lang, "Applies", "Uygulanma"))</th> | 987 | + <span class=(f.kind_class)>(f.kind_label)</span> |
| 689 | - </tr> | 988 | + <span class="badge srv-source">(f.source_label)</span> |
| 690 | - </thead> | 989 | + if !f.pending_label.is_empty() { |
| 691 | - <tbody> | 990 | + <span class="badge srv-pending">(f.pending_label)</span> |
| 692 | - for f in fields.iter() { | 991 | + } |
| 693 | - <tr> | 992 | + </div> |
| 694 | - <td><code>(f.key)</code></td> | 993 | + if f.input == "select" { |
| 695 | - if f.kind == FieldKind::ReadOnly { | 994 | + <select id=(format!("rf-{}", f.key)) name=(f.key)> |
| 696 | - <td colspan="1"> | 995 | + for (value, text, on) in f.options.iter() { |
| 697 | - if f.reported { <span class="runner-value">(f.value.as_str())</span> } else { <span class="muted">"-"</span> } | 996 | + <option value=(*value) selected=(sel(*on))>(*text)</option> |
| 698 | - </td> | ||
| 699 | - <td class="small muted">(if f.reported { "runner.toml" } else { "" })</td> | ||
| 700 | - <td><span class="runner-label">(s(lang, "read-only", "salt okunur"))</span></td> | ||
| 701 | - } else { | ||
| 702 | - <td> | ||
| 703 | - <form method="post" action=(action.as_str()) class="inline-form runner-conc-form"> | ||
| 704 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 705 | - <input type="hidden" name="key" value=(f.key)> | ||
| 706 | - <input type="hidden" name="back" value="detail"> | ||
| 707 | - field_input(key: f.key, value: f.value.as_str(), lang: lang) | ||
| 708 | - <button type="submit">(s(lang, "Save", "Kaydet"))</button> | ||
| 709 | - if f.has_override { | ||
| 710 | - <button type="submit" name="reset" value="1" formnovalidate="formnovalidate">(s(lang, "Use runner.toml value", "runner.toml değerini kullan"))</button> | ||
| 711 | - } | ||
| 712 | - </form> | ||
| 713 | - </td> | ||
| 714 | - <td class="small muted">(if f.reported || f.has_override { f.source } else { "" })</td> | ||
| 715 | - <td> | ||
| 716 | - if f.kind == FieldKind::Live { | ||
| 717 | - <span class="ci-state ci-success">(if f.pending { s(lang, "live, pending", "canlı, bekliyor") } else { s(lang, "live", "canlı") })</span> | ||
| 718 | - } else { | ||
| 719 | - <span class="ci-state runner-disabled">(if f.pending { s(lang, "restart needed", "yeniden başlatma gerekli") } else { s(lang, "applies on restart", "yeniden başlatınca") })</span> | ||
| 720 | } | 997 | } |
| 721 | - </td> | 998 | + </select> |
| 999 | + } else if f.input == "number" { | ||
| 1000 | + <input id=(format!("rf-{}", f.key)) type="number" name=(f.key) value=(f.value.as_str()) step="1" inputmode="numeric" min=(f.min) max=(f.max) placeholder=(s(lang, "(from runner.toml)", "(runner.toml'dan)"))> | ||
| 1001 | + } else { | ||
| 1002 | + <input id=(format!("rf-{}", f.key)) type="text" name=(f.key) value=(f.value.as_str()) placeholder=(s(lang, "(from runner.toml)", "(runner.toml'dan)")) autocomplete="off" spellcheck="false"> | ||
| 722 | } | 1003 | } |
| 723 | - </tr> | 1004 | + <p class="muted small">(f.hint)</p> |
| 1005 | + if f.has_override { | ||
| 1006 | + <p class="small srv-reset"> | ||
| 1007 | + <button type="submit" form="rn-reset" name="key" value=(f.key)>(s(lang, "Reset to runner.toml", "runner.toml değerine sıfırla"))</button> | ||
| 1008 | + </p> | ||
| 1009 | + } | ||
| 1010 | + </div> | ||
| 724 | } | 1011 | } |
| 725 | - </tbody> | 1012 | + </div> |
| 726 | - </table> | 1013 | + <div class="actions"> |
| 727 | - </div> | 1014 | + <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> |
| 1015 | + </div> | ||
| 1016 | + </form> | ||
| 1017 | + <form id="rn-reset" method="post" action=(reset_action.as_str())> | ||
| 1018 | + <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 1019 | + <input type="hidden" name="back" value="detail"> | ||
| 1020 | + <input type="hidden" name="tab" value=(tab)> | ||
| 1021 | + <input type="hidden" name="reset" value="1"> | ||
| 1022 | + </form> | ||
| 1023 | + } else { | ||
| 1024 | + <p class="muted small">(s(lang, "Set when the runner registered. These cannot be changed from the forge.", "Çalıştırıcı kaydolurken belirlenir. Forge üzerinden değiştirilemez."))</p> | ||
| 1025 | + <div class="srv-grid"> | ||
| 1026 | + for (label, value) in identity.iter() { | ||
| 1027 | + <div class="srv-field"> | ||
| 1028 | + <div class="srv-head"> | ||
| 1029 | + <span class="srv-label">(*label)</span> | ||
| 1030 | + <span class="badge srv-ro">(g::t(lang, K::SrvKindReadOnly))</span> | ||
| 1031 | + </div> | ||
| 1032 | + <code class="srv-fixed">(value.as_str())</code> | ||
| 1033 | + </div> | ||
| 1034 | + } | ||
| 1035 | + </div> | ||
| 1036 | + } | ||
| 728 | </section> | 1037 | </section> |
| 729 | </div> | 1038 | </div> |
| 730 | }) | 1039 | }) |
| @@ -744,13 +1053,99 @@ async fn runner_detail_page(cx: &Cx) -> Result<impl View> { | |||
| 744 | let fields = field_rows(&runner); | 1053 | let fields = field_rows(&runner); |
| 745 | let csrf = viewer.1.csrf_token.clone(); | 1054 | let csrf = viewer.1.csrf_token.clone(); |
| 746 | let notice = notice_from_query(cx, lang); | 1055 | let notice = notice_from_query(cx, lang); |
| 747 | - let action = row.config_action.clone(); | 1056 | + let tab = tab_from_query(cx); |
| 748 | let title = runner.name.clone(); | 1057 | let title = runner.name.clone(); |
| 749 | Ok(view! { | 1058 | Ok(view! { |
| 750 | - shell(title: title.as_str(), viewer: Some(&viewer), runner_detail_view(lang: lang, csrf: csrf, runner: runner.clone(), row: row, fields: fields, notice: notice, action: action)) | 1059 | + shell(title: title.as_str(), viewer: Some(&viewer), runner_detail_view(lang: lang, csrf: csrf, runner: runner.clone(), row: row, fields: fields, notice: notice, tab: tab)) |
| 751 | }) | 1060 | }) |
| 752 | } | 1061 | } |
| 753 | 1062 | ||
| 1063 | +/// Saves the fields of one tab in one post. Only fields whose value changed are stored; an | ||
| 1064 | +/// unchanged field keeps its source, so saving a tab never turns runner.toml values into overrides. | ||
| 1065 | +#[route(POST "/admin/runners/{runner_id}/settings")] | ||
| 1066 | +async fn runner_save_settings( | ||
| 1067 | + cx: &Cx, | ||
| 1068 | + Form(form): Form<std::collections::HashMap<String, String>>, | ||
| 1069 | +) -> Result<SeeOther> { | ||
| 1070 | + let viewer = admin_only(cx).await?; | ||
| 1071 | + if !check_csrf(&viewer.1, form.get("csrf").map_or("", String::as_str)) { | ||
| 1072 | + return Err(forbidden().into()); | ||
| 1073 | + } | ||
| 1074 | + let id = path_param::<RunnerId>(cx); | ||
| 1075 | + let state = app_context::<AppState>(cx); | ||
| 1076 | + let tab = TABS | ||
| 1077 | + .iter() | ||
| 1078 | + .find(|(slug, _)| Some(*slug) == form.get("tab").map(String::as_str)) | ||
| 1079 | + .map_or("general", |(slug, _)| *slug); | ||
| 1080 | + let back = |notice: &str| { | ||
| 1081 | + see_other(format!( | ||
| 1082 | + "/admin/runners/{}?tab={tab}¬ice={}", | ||
| 1083 | + enc(id), | ||
| 1084 | + enc(notice) | ||
| 1085 | + )) | ||
| 1086 | + }; | ||
| 1087 | + let Some(runner) = runner_named(state, id).await? else { | ||
| 1088 | + return Ok(back_to_list("missing")); | ||
| 1089 | + }; | ||
| 1090 | + let current = field_rows(&runner); | ||
| 1091 | + let keys = TABS | ||
| 1092 | + .iter() | ||
| 1093 | + .find(|(slug, _)| *slug == tab) | ||
| 1094 | + .map_or(&[][..], |(_, keys)| *keys); | ||
| 1095 | + let mut saved_live = false; | ||
| 1096 | + let mut saved_restart = false; | ||
| 1097 | + for key in keys { | ||
| 1098 | + let (Some(field), Some(posted), Some(now)) = ( | ||
| 1099 | + runner_field(key), | ||
| 1100 | + form.get(*key), | ||
| 1101 | + current.iter().find(|f| f.key == *key), | ||
| 1102 | + ) else { | ||
| 1103 | + continue; | ||
| 1104 | + }; | ||
| 1105 | + if field.kind == FieldKind::ReadOnly || posted.trim() == now.value { | ||
| 1106 | + continue; | ||
| 1107 | + } | ||
| 1108 | + match state | ||
| 1109 | + .store | ||
| 1110 | + .set_runner_field(id, field.key, Some(posted.as_str())) | ||
| 1111 | + .await | ||
| 1112 | + { | ||
| 1113 | + Ok(()) => {} | ||
| 1114 | + Err(forge_core::Error::Invalid(_)) => return Ok(back("invalid")), | ||
| 1115 | + Err(forge_core::Error::NotFound) => return Ok(back_to_list("missing")), | ||
| 1116 | + Err(e) => return Err(e.into()), | ||
| 1117 | + } | ||
| 1118 | + if field.kind == FieldKind::Live { | ||
| 1119 | + saved_live = true; | ||
| 1120 | + } else { | ||
| 1121 | + saved_restart = true; | ||
| 1122 | + } | ||
| 1123 | + tracing::info!(actor_id = %viewer.0.id, runner_id = %id, field = field.key, "ci runner config changed"); | ||
| 1124 | + audit::record( | ||
| 1125 | + &state.store, | ||
| 1126 | + Some(cx), | ||
| 1127 | + Actor::User(&viewer.0), | ||
| 1128 | + AuditAction::CiRunnerConfigChanged, | ||
| 1129 | + Target { | ||
| 1130 | + kind: "ci_runner", | ||
| 1131 | + id, | ||
| 1132 | + name: "", | ||
| 1133 | + }, | ||
| 1134 | + serde_json::json!({ "field": field.key, "reset": false }), | ||
| 1135 | + ) | ||
| 1136 | + .await; | ||
| 1137 | + } | ||
| 1138 | + if !(saved_live || saved_restart) { | ||
| 1139 | + return Ok(back("unchanged")); | ||
| 1140 | + } | ||
| 1141 | + state.ci_live.bump_runners(); | ||
| 1142 | + Ok(back(if saved_restart { | ||
| 1143 | + "saved-restart" | ||
| 1144 | + } else { | ||
| 1145 | + "saved" | ||
| 1146 | + })) | ||
| 1147 | +} | ||
| 1148 | + | ||
| 754 | /// The live `changed` stream of the runners pages. Sent on a runner's report, claim, finish or an | 1149 | /// The live `changed` stream of the runners pages. Sent on a runner's report, claim, finish or an |
| 755 | /// admin edit; nothing is sent on connect. | 1150 | /// admin edit; nothing is sent on connect. |
| 756 | #[route(GET "/admin/runners/events")] | 1151 | #[route(GET "/admin/runners/events")] |
| @@ -780,7 +1175,15 @@ async fn runner_set_config(cx: &Cx, Form(form): Form<ConfigForm>) -> Result<SeeO | |||
| 780 | let state = app_context::<AppState>(cx); | 1175 | let state = app_context::<AppState>(cx); |
| 781 | let back = |notice: &str| { | 1176 | let back = |notice: &str| { |
| 782 | if form.back == "detail" { | 1177 | if form.back == "detail" { |
| 783 | - see_other(format!("/admin/runners/{}?notice={}", enc(id), enc(notice))) | 1178 | + let tab = TABS |
| 1179 | + .iter() | ||
| 1180 | + .find(|(slug, _)| *slug == form.tab) | ||
| 1181 | + .map_or("general", |(slug, _)| *slug); | ||
| 1182 | + see_other(format!( | ||
| 1183 | + "/admin/runners/{}?tab={tab}¬ice={}", | ||
| 1184 | + enc(id), | ||
| 1185 | + enc(notice) | ||
| 1186 | + )) | ||
| 784 | } else { | 1187 | } else { |
| 785 | back_to_list(notice) | 1188 | back_to_list(notice) |
| 786 | } | 1189 | } |
| @@ -1173,9 +1576,7 @@ mod tests { | |||
| 1173 | let detail_uri = format!("/admin/runners/{}", runner.id); | 1576 | let detail_uri = format!("/admin/runners/{}", runner.id); |
| 1174 | let (status, detail) = send(&router, "GET", &detail_uri, Some(ADMIN_TOKEN), None).await; | 1577 | let (status, detail) = send(&router, "GET", &detail_uri, Some(ADMIN_TOKEN), None).await; |
| 1175 | assert_eq!(status, 200); | 1578 | assert_eq!(status, 200); |
| 1176 | - assert!(detail.contains("limits.memory")); | 1579 | + assert!(detail.contains("Concurrency")); |
| 1177 | - assert!(detail.contains("restart needed")); | ||
| 1178 | - assert!(detail.contains("read-only")); | ||
| 1179 | assert!(detail.contains(r#"data-live="/admin/runners/events""#)); | 1580 | assert!(detail.contains(r#"data-live="/admin/runners/events""#)); |
| 1180 | 1581 | ||
| 1181 | let (_, _) = send( | 1582 | let (_, _) = send( |
| @@ -1199,6 +1600,49 @@ mod tests { | |||
| 1199 | assert!(after.config_overrides.is_empty()); | 1600 | assert!(after.config_overrides.is_empty()); |
| 1200 | } | 1601 | } |
| 1201 | 1602 | ||
| 1603 | + #[tokio::test] | ||
| 1604 | + async fn one_post_saves_the_changed_fields_of_a_tab() { | ||
| 1605 | + let dir = tempfile::tempdir().expect("tempdir"); | ||
| 1606 | + let (store, router) = fixture(dir.path()).await; | ||
| 1607 | + let runner = one_runner(&store, &router).await; | ||
| 1608 | + let action = format!("/admin/runners/{}/settings", runner.id); | ||
| 1609 | + let (status, _) = send( | ||
| 1610 | + &router, | ||
| 1611 | + "POST", | ||
| 1612 | + &action, | ||
| 1613 | + Some(ADMIN_TOKEN), | ||
| 1614 | + csrf_form("&tab=limits&limits.memory=8g&limits.cpus=&limits.pids="), | ||
| 1615 | + ) | ||
| 1616 | + .await; | ||
| 1617 | + assert_eq!(status, 303); | ||
| 1618 | + let after = store.list_runners().await.unwrap().remove(0); | ||
| 1619 | + assert_eq!( | ||
| 1620 | + after.config_overrides.get("limits.memory"), | ||
| 1621 | + Some(&serde_json::json!("8g")) | ||
| 1622 | + ); | ||
| 1623 | + assert_eq!(after.config_overrides.len(), 1, "blank fields stay unset"); | ||
| 1624 | + let (status, page) = send( | ||
| 1625 | + &router, | ||
| 1626 | + "GET", | ||
| 1627 | + &format!("/admin/runners/{}?tab=limits", runner.id), | ||
| 1628 | + Some(ADMIN_TOKEN), | ||
| 1629 | + None, | ||
| 1630 | + ) | ||
| 1631 | + .await; | ||
| 1632 | + assert_eq!(status, 200); | ||
| 1633 | + assert!(page.contains("Memory limit")); | ||
| 1634 | + assert!(page.contains("Reset to runner.toml")); | ||
| 1635 | + let (status, _) = send( | ||
| 1636 | + &router, | ||
| 1637 | + "POST", | ||
| 1638 | + &action, | ||
| 1639 | + Some(USER_TOKEN), | ||
| 1640 | + csrf_form("&tab=limits&limits.memory=1g"), | ||
| 1641 | + ) | ||
| 1642 | + .await; | ||
| 1643 | + assert_eq!(status, 404); | ||
| 1644 | + } | ||
| 1645 | + | ||
| 1202 | #[tokio::test] | 1646 | #[tokio::test] |
| 1203 | async fn config_posts_need_admin_and_csrf_and_the_events_stream_is_admin_only() { | 1647 | async fn config_posts_need_admin_and_csrf_and_the_events_stream_is_admin_only() { |
| 1204 | let dir = tempfile::tempdir().expect("tempdir"); | 1648 | let dir = tempfile::tempdir().expect("tempdir"); |
style/main.scssmodified+86 -11
| @@ -4240,9 +4240,14 @@ $ansi-colours: ( | |||
| 4240 | } | 4240 | } |
| 4241 | } | 4241 | } |
| 4242 | 4242 | ||
| 4243 | -// Admin runners table: name and labels take the slack, the rest size to their content, and the | 4243 | +// Admin runners table: every column sizes to its content except Name and Labels, which share the |
| 4244 | -// actions sit flush right. State reuses the `.ci-state` pill; a disabled runner is muted. | 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 | .table.runners { | 4246 | .table.runners { |
| 4247 | + th.runner-conc, | ||
| 4248 | + td.runner-conc, | ||
| 4249 | + th.runner-running, | ||
| 4250 | + td.runner-running, | ||
| 4246 | th.runner-seen, | 4251 | th.runner-seen, |
| 4247 | th.runner-state, | 4252 | th.runner-state, |
| 4248 | td.runner-seen, | 4253 | td.runner-seen, |
| @@ -4251,6 +4256,23 @@ $ansi-colours: ( | |||
| 4251 | white-space: nowrap; | 4256 | white-space: nowrap; |
| 4252 | } | 4257 | } |
| 4253 | 4258 | ||
| 4259 | + th.runner-conc, | ||
| 4260 | + td.runner-conc { | ||
| 4261 | + min-width: 10.5rem; | ||
| 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 { | ||
| 4272 | + text-align: right; | ||
| 4273 | + font-variant-numeric: tabular-nums; | ||
| 4274 | + } | ||
| 4275 | + | ||
| 4254 | th.runner-actions, | 4276 | th.runner-actions, |
| 4255 | td.runner-actions { | 4277 | td.runner-actions { |
| 4256 | width: 1%; | 4278 | width: 1%; |
| @@ -4260,13 +4282,18 @@ $ansi-colours: ( | |||
| 4260 | } | 4282 | } |
| 4261 | 4283 | ||
| 4262 | td.runner-labels { | 4284 | td.runner-labels { |
| 4263 | - width: 50%; | 4285 | + width: 30%; |
| 4286 | + min-width: 9rem; | ||
| 4264 | } | 4287 | } |
| 4265 | 4288 | ||
| 4266 | - // A name is never broken mid-word; a narrow screen scrolls the table inside .table-wrap. | ||
| 4267 | td.runner-name { | 4289 | td.runner-name { |
| 4290 | + width: 24%; | ||
| 4268 | white-space: nowrap; | 4291 | white-space: nowrap; |
| 4269 | } | 4292 | } |
| 4293 | + | ||
| 4294 | + td.runner-state .ci-state { | ||
| 4295 | + vertical-align: middle; | ||
| 4296 | + } | ||
| 4270 | } | 4297 | } |
| 4271 | 4298 | ||
| 4272 | .runner-label-list { | 4299 | .runner-label-list { |
| @@ -4287,27 +4314,34 @@ $ansi-colours: ( | |||
| 4287 | white-space: nowrap; | 4314 | white-space: nowrap; |
| 4288 | } | 4315 | } |
| 4289 | 4316 | ||
| 4290 | -// Runner concurrency and config forms: a compact input with its buttons on one line. | 4317 | +// Runner concurrency and config forms: a compact input and its buttons on one line, the source hint |
| 4291 | -.runner-conc-form { | 4318 | +// on a line of its own below. `form.` outranks the later plain `.inline-form { display: inline }`. |
| 4319 | +form.runner-conc-form { | ||
| 4292 | display: flex; | 4320 | display: flex; |
| 4321 | + flex-wrap: wrap; | ||
| 4293 | align-items: center; | 4322 | align-items: center; |
| 4294 | - gap: 8px; | 4323 | + gap: 4px 8px; |
| 4295 | margin: 0; | 4324 | margin: 0; |
| 4296 | 4325 | ||
| 4297 | input[type="number"] { | 4326 | input[type="number"] { |
| 4298 | - width: 5.5rem; | 4327 | + width: 4.5rem; |
| 4328 | + min-width: 0; | ||
| 4329 | + text-align: center; | ||
| 4299 | } | 4330 | } |
| 4300 | 4331 | ||
| 4301 | input, | 4332 | input, |
| 4302 | select, | 4333 | select, |
| 4303 | button { | 4334 | button { |
| 4335 | + box-sizing: border-box; | ||
| 4304 | height: var(--control-h); | 4336 | height: var(--control-h); |
| 4305 | margin: 0; | 4337 | margin: 0; |
| 4306 | } | 4338 | } |
| 4307 | -} | ||
| 4308 | 4339 | ||
| 4309 | -.runner-source { | 4340 | + .runner-source { |
| 4310 | - white-space: nowrap; | 4341 | + flex-basis: 100%; |
| 4342 | + line-height: 1.2; | ||
| 4343 | + white-space: nowrap; | ||
| 4344 | + } | ||
| 4311 | } | 4345 | } |
| 4312 | 4346 | ||
| 4313 | .runner-facts { | 4347 | .runner-facts { |
| @@ -4342,6 +4376,8 @@ $ansi-colours: ( | |||
| 4342 | } | 4376 | } |
| 4343 | 4377 | ||
| 4344 | button { | 4378 | button { |
| 4379 | + box-sizing: border-box; | ||
| 4380 | + min-width: 5.5rem; | ||
| 4345 | height: var(--control-h); | 4381 | height: var(--control-h); |
| 4346 | margin: 0; | 4382 | margin: 0; |
| 4347 | } | 4383 | } |
| @@ -6234,6 +6270,45 @@ button.ci-job-last { | |||
| 6234 | margin-top: 16px; | 6270 | margin-top: 16px; |
| 6235 | } | 6271 | } |
| 6236 | 6272 | ||
| 6273 | +// Runner page: the name with its state pill on the left, the actions (back link, restart) on the | ||
| 6274 | +// right; a compact strip of status values built from the same grid cells. | ||
| 6275 | +.runner-head { | ||
| 6276 | + display: flex; | ||
| 6277 | + flex-wrap: wrap; | ||
| 6278 | + align-items: center; | ||
| 6279 | + gap: 8px 12px; | ||
| 6280 | + min-width: 0; | ||
| 6281 | + | ||
| 6282 | + h1 { | ||
| 6283 | + margin: 0; | ||
| 6284 | + overflow-wrap: anywhere; | ||
| 6285 | + } | ||
| 6286 | +} | ||
| 6287 | + | ||
| 6288 | +.runner-head-actions { | ||
| 6289 | + display: flex; | ||
| 6290 | + flex-wrap: wrap; | ||
| 6291 | + align-items: center; | ||
| 6292 | + gap: 8px 12px; | ||
| 6293 | +} | ||
| 6294 | + | ||
| 6295 | +.runner-build-stat { | ||
| 6296 | + display: flex; | ||
| 6297 | + flex-wrap: wrap; | ||
| 6298 | + align-items: center; | ||
| 6299 | + gap: 4px 8px; | ||
| 6300 | +} | ||
| 6301 | + | ||
| 6302 | +.srv-grid.srv-stats { | ||
| 6303 | + grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); | ||
| 6304 | + | ||
| 6305 | + strong { | ||
| 6306 | + font-size: 1.0625rem; | ||
| 6307 | + font-weight: 600; | ||
| 6308 | + overflow-wrap: anywhere; | ||
| 6309 | + } | ||
| 6310 | +} | ||
| 6311 | + | ||
| 6237 | // Draft pull requests: a neutral grey badge, distinct from open (green) and merged (purple). | 6312 | // Draft pull requests: a neutral grey badge, distinct from open (green) and merged (purple). |
| 6238 | .issue-badge.issue-badge-draft { | 6313 | .issue-badge.issue-badge-draft { |
| 6239 | background: var(--code-bg); | 6314 | background: var(--code-bg); |