From aa3031d53528a28b214810940844dfa290bdc77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 31 Oct 2026 15:49:44 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20the=20contribution=20ca?= =?UTF-8?q?lendar=20returns=20to=20the=20top=20of=20the=20profile=20overvi?= =?UTF-8?q?ew=20and=20the=20Contributions=20tab=20goes;=20the=20search=20a?= =?UTF-8?q?nd=20sort=20of=20a=20repository=20list=20share=20one=20aligned?= =?UTF-8?q?=20toolbar,=20styles=20lost=20with=20the=20dashboard=20are=20re?= =?UTF-8?q?stored,=20and=20organization=20rows=20line=20up;=20a=20runner's?= =?UTF-8?q?=20page=20drops=20its=20Metrics=20tab=20and=20shows=20the=20num?= =?UTF-8?q?bers=20and=20charts=20in=20a=20card=20on=20top;=20the=20floatin?= =?UTF-8?q?g=20profile=20panel=20shows=20the=20full=20name=20and=20its=20m?= =?UTF-8?q?enus=20open=20on=20hover;=20=E2=9C=A8=20feat:=20deleting=20an?= =?UTF-8?q?=20organization=20from=20the=20admin=20pages=20explains=20that?= =?UTF-8?q?=20it=20goes=20through=20its=20own=20settings=20and=20links=20t?= =?UTF-8?q?here;=20=F0=9F=90=9B=20fix:=20page=20loads=20no=20longer=20stal?= =?UTF-8?q?l=20on=20open=20streams:=20a=20page=20closes=20its=20streams=20?= =?UTF-8?q?when=20it=20is=20left,=20and=20a=20tab=20hidden=20for=20three?= =?UTF-8?q?=20seconds=20gives=20them=20up=20and=20catches=20up=20when=20sh?= =?UTF-8?q?own;=20a=20job=20page's=20log=20tail=20keeps=20its=20byte=20off?= =?UTF-8?q?set,=20so=20its=20stream=20resumes=20where=20it=20stopped=20eve?= =?UTF-8?q?n=20when=20the=20catch-up=20render=20is=20held=20back=20or=20fa?= =?UTF-8?q?ils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + crates/forge-core/src/store/user_delete.rs | 2 +- crates/forge-web/assets/nav.js | 197 +++++++++++++++++-- crates/forge-web/src/ci/metrics_chart.rs | 4 +- crates/forge-web/src/i18n/admin.rs | 24 +++ crates/forge-web/src/i18n/orgs.rs | 4 - crates/forge-web/src/pages/admin_runners.rs | 198 ++++++++++---------- crates/forge-web/src/pages/admin_users.rs | 73 +++++++- crates/forge-web/src/pages/explore.rs | 6 +- crates/forge-web/src/pages/profile.rs | 93 ++++----- crates/forge-web/src/views/heatmap.rs | 10 +- crates/forge-web/src/views/mod.rs | 2 +- style/_admin_rows.scss | 51 +++-- style/_dashboard.scss | 179 ++++++++++++++++++ style/_shell.scss | 18 +- style/main.scss | 21 ++- 16 files changed, 681 insertions(+), 202 deletions(-) create mode 100644 style/_dashboard.scss diff --git a/.gitignore b/.gitignore index 65ebc47..d22c0b8 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ ssh_host_ed25519_key # smoke check deps /scripts/smoke/node_modules +__pycache__/ diff --git a/crates/forge-core/src/store/user_delete.rs b/crates/forge-core/src/store/user_delete.rs index b214cf8..191b26d 100644 --- a/crates/forge-core/src/store/user_delete.rs +++ b/crates/forge-core/src/store/user_delete.rs @@ -247,7 +247,7 @@ async fn plan(conn: &Connection, user_id: &str, ghost_id: Option<&str>) -> Resul .ok_or(Error::NotFound)?; if kind == "org" { return Err(Error::Conflict( - "an organization is removed with its own delete, not as a user".into(), + "this is an organization: an owner deletes it from its settings page".into(), )); } if count(conn, LAST_OWNER_OF_ORG, user_id).await? > 0 { diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index 2a0f978..75ef11e 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -540,7 +540,7 @@ // One EventSource that stays open. The browser reconnects by itself, except when a proxy answers // with an error: EventSource then closes for good, so it is opened again here after 1, 2, then 3 s. - // `restart()` reconnects at once. + // `restart()` reconnects at once and `stop()` closes it until the next restart. function keepOpen(url, onOpen, onError, handlers) { var es = null, delay = 1000, timer = null; function connect() { @@ -558,14 +558,18 @@ delay = Math.min(delay + 1000, 3000); }; } + function stop() { + if (timer) { clearTimeout(timer); timer = null; } + if (es) { es.close(); } + } connect(); return { restart: function () { - if (timer) { clearTimeout(timer); timer = null; } - if (es) { es.close(); } + stop(); delay = 1000; connect(); - } + }, + stop: stop }; } @@ -609,6 +613,39 @@ if (fresh || !streamUp) { alive.restart(); } if (link.down) { armBanner(); } } + // Over HTTP/1.1 a browser allows six connections to a host, and a stream holds one for as long as it + // is open, so a few tabs would leave none for the next page load. A tab hidden for a while gives up + // its streams and takes them back when shown, then re-renders to catch up on what it missed. + var HIDDEN_CLOSE = 3000; // a quick look at another tab keeps the streams + var hiddenTimer = null; + var streamsAsleep = false; // a hidden tab has closed its streams + + function sleepSoon() { + if (hiddenTimer) { return; } + hiddenTimer = setTimeout(function () { + hiddenTimer = null; + if (!document.hidden) { return; } + streamsAsleep = true; + alive.stop(); + closeLive(); + }, HIDDEN_CLOSE); + } + + // The streams reopen first, as the render may be held back or fail. A job page's tail knows the + // offset it reached, so its stream resumes there and the render's own offset replaces it. + function catchUp() { + syncLive(); + refreshLive(true); + } + + function wakeStreams() { + if (hiddenTimer) { clearTimeout(hiddenTimer); hiddenTimer = null; } + if (!streamsAsleep) { return; } + streamsAsleep = false; + alive.restart(); + catchUp(); + } + if (window.EventSource) { alive = keepOpen('/-/shell/events', aliveOpen, aliveDown, { theme: applyAppearance, @@ -622,10 +659,24 @@ // The viewer's activity changed: the strip, ring and chips are fetched again. activity: function () { refreshActivity(); } }); - document.addEventListener('visibilitychange', function () { wake(false); }); + document.addEventListener('visibilitychange', function () { + if (document.hidden) { sleepSoon(); return; } + wakeStreams(); + wake(false); + }); + if (document.hidden) { sleepSoon(); } document.addEventListener('resume', function () { wake(true); }); - window.addEventListener('pageshow', function (e) { leaving = false; if (e.persisted) { wake(true); } }); - window.addEventListener('pagehide', function () { leaving = true; }); + // A page kept in the back-forward cache holds its streams open, so they close on leaving and open + // again if the page is restored. + window.addEventListener('pageshow', function (e) { + leaving = false; + if (e.persisted) { streamsAsleep = false; wake(true); catchUp(); } + }); + window.addEventListener('pagehide', function () { + leaving = true; + alive.stop(); + closeLive(); + }); } if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js').catch(function () {}); } @@ -801,6 +852,10 @@ if (!p.dragging) { if (Math.hypot(e.clientX - p.x, e.clientY - p.y) < CORNER_SLOP) { return; } p.dragging = true; + // A drag ends any hover the mouse started: the menu or the bell closes, and a pending open is dropped. + clearTimeout(hoverTimer); + hoverTimer = 0; + hoverHide(); try { p.el.setPointerCapture(p.id); } catch (err) { } p.el.classList.add('dragging'); } @@ -903,11 +958,113 @@ }); document.addEventListener('scroll', cornerScrolled, { capture: true, passive: true }); + // A mouse that rests on the profile corner opens its account menu, or the bell popover on the bell, + // after a short rest; when it leaves, the menu or popover it opened closes. Touch and keyboard + // keep the click. hoverOn names what the mouse opened; hoverWait says whether the pending timer + // shows it or hides it. + var HOVER_OPEN = 120; // a mouse rests this long before a menu opens + var HOVER_CLOSE = 250; // and may leave this long, enough to cross the gap to the menu + var hoverOn = null; // 'menu' or 'bell': what the mouse opened + var hoverTimer = 0; + var hoverWait = ''; // 'show' or 'hide': what the pending timer does + var hoverMute = false; // a click on the bell: it stays shut until the mouse leaves the bell + + // The part of the corner a node belongs to: 'bell' for the bell and its popover (tested first, as + // the popover sits inside the panel), 'menu' for the rest of the panel, null elsewhere. + function hoverKind(node) { + if (!node || !node.closest) { return null; } + if (node.closest('.corner-bell, .bell-pop')) { return 'bell'; } + if (node.closest('.corner-float')) { return 'menu'; } + return null; + } + + // Whether the account menu or the bell popover is open right now. + function hoverIsOpen(kind) { + if (kind === 'menu') { + var details = document.querySelector('details.corner'); + return !!(details && details.open); + } + var pop = document.querySelector('.bell-pop'); + return !!(pop && isPeekOpen(pop)); + } + + // Opens the menu or the bell popover for a resting mouse. One the reader opened by click or keyboard + // is left alone. + function hoverShow(kind) { + if (hoverOn && hoverOn !== kind) { hoverHide(); } + if (hoverIsOpen(kind) && hoverOn !== kind) { return; } + if (kind === 'menu') { + var details = document.querySelector('details.corner'); + if (details) { details.open = true; } + } else { + var pop = document.querySelector('.bell-pop'); + try { if (pop) { pop.showPopover(); } } catch (err) { } + } + hoverOn = kind; + } + + // Closes what the mouse opened, and forgets it. + function hoverHide() { + if (hoverOn === 'menu') { + var details = document.querySelector('details.corner'); + if (details) { details.open = false; } + } else if (hoverOn === 'bell') { + var pop = document.querySelector('.bell-pop'); + try { if (pop) { pop.hidePopover(); } } catch (err) { } + } + hoverOn = null; + } + + // A mouse entering the corner starts a show (a fresh rest each time it moves within it). Leaving the + // corner cancels a pending show, and starts a hide only when nothing is pending, so moving across the + // page does not keep pushing the hide back. + document.addEventListener('pointerover', function (e) { + if (e.pointerType !== 'mouse' || cornerPress) { return; } + var kind = hoverKind(e.target); + if (hoverMute) { + if (kind === 'bell') { return; } + hoverMute = false; + } + if (kind) { + clearTimeout(hoverTimer); + hoverTimer = 0; + if (kind === hoverOn && hoverIsOpen(kind)) { return; } + hoverWait = 'show'; + hoverTimer = setTimeout(function () { + hoverTimer = 0; + hoverShow(kind); + }, HOVER_OPEN); + return; + } + if (hoverWait === 'show' && hoverTimer) { + clearTimeout(hoverTimer); + hoverTimer = 0; + } + if (hoverOn && !hoverTimer) { + hoverWait = 'hide'; + hoverTimer = setTimeout(function () { + hoverTimer = 0; + hoverHide(); + }, HOVER_CLOSE); + } + }); + + // A click on the menu's summary, while the mouse holds it open, does nothing: the menu stays open. + // A chip link inside the summary still goes where it leads. Registered after the drag's swallow + // listener, so that one runs first. + window.addEventListener('click', function (e) { + if (hoverOn !== 'menu' || !e.target || !e.target.closest) { return; } + if (!e.target.closest('summary.corner-btn') || e.target.closest('a')) { return; } + e.preventDefault(); + }, true); + // The bell beside the profile corner opens a popover of the newest notifications instead of going - // to the inbox. A plain click toggles it; with a modifier or a middle click the link's own - // behaviour stays. The Popover API light-dismisses it and Escape closes it. Its list is fetched - // each time it opens (see the toggle handler). The bell and the popover are siblings. + // to the inbox. A touch or keyboard click toggles it; a mouse has already opened it by hovering, so + // its click goes to the inbox. With a modifier or a middle click the link's own behaviour stays. + // The Popover API light-dismisses it and Escape closes it. Its list is fetched each time it opens + // (see the toggle handler). The bell and the popover are siblings. var peekPress = null; // at a press: whether the popover was open (null before any press) + var peekHover = false; // at a press: whether the mouse held the popover open function isPeekOpen(pop) { try { return pop.matches(':popover-open'); } catch (err) { return false; } @@ -966,6 +1123,7 @@ if (!bell) { return; } var pop = bell.nextElementSibling; peekPress = !!(pop && pop.classList.contains('bell-pop') && isPeekOpen(pop)); + peekHover = hoverOn === 'bell'; }, true); // Capture on window, so it runs before the soft navigation (capture on document) follows the @@ -976,6 +1134,11 @@ if (!bell) { return; } var pop = bell.nextElementSibling; if (!pop || !pop.classList.contains('bell-pop')) { return; } + // The mouse opened the popover by resting on the bell: this click goes to the inbox instead. The + // press decides, as light dismiss has closed the popover by now. + clearTimeout(hoverTimer); + hoverTimer = 0; + if (peekHover) { peekHover = false; hoverOn = null; peekPress = null; hoverMute = true; return; } e.preventDefault(); // A keyboard click has no press: the popover's own state decides. var was = peekPress === null ? isPeekOpen(pop) : peekPress; @@ -995,6 +1158,9 @@ if (open) { placePeek(bell, pop); loadPeek(pop); + } else if (hoverOn === 'bell') { + // Closed by Escape or a light dismiss: the mouse no longer holds it open. + hoverOn = null; } }, true); @@ -1004,6 +1170,10 @@ try { pop.hidePopover(); } catch (err) { } }); }); + // A swap that took the mouse's popover or menu away leaves nothing for hover to close. + document.addEventListener('forge:swapped', function () { + if (hoverOn && !hoverIsOpen(hoverOn)) { hoverOn = null; } + }); // Repo home resize: a drag on the separator between the file tree and the README sets the tree's // width, the --tree-w property of the .repo-home grid. The width is kept in localStorage and applied @@ -2788,12 +2958,13 @@ if (liveTimer) { return; } liveTimer = setTimeout(function () { liveTimer = null; refreshLive(); }, 1000); }); - es.addEventListener('log', function (e) { appendLog(e.data); }); + es.addEventListener('log', function (e) { appendLog(e.data, e.lastEventId); }); return es; } // Closes the streams the page no longer names and opens the ones it newly names. function syncLive() { + if (streamsAsleep) { return; } var want = liveWanted(); Object.keys(liveStreams).forEach(function (url) { if (!want[url]) { liveStreams[url].close(); delete liveStreams[url]; } @@ -2813,9 +2984,11 @@ // Appends streamed log text to the tail as a text node, never as HTML. The tail follows the end // only while the reader is already at the end (within 24px). Scrolling back down resumes following. - function appendLog(text) { + // The event's id is the log's byte offset after this text: the tail keeps it for the next stream. + function appendLog(text, offset) { var pre = document.querySelector('[data-live-log]'); if (!pre || !text) { return; } + if (offset) { pre.setAttribute('data-offset', offset); } var atEnd = pre.scrollTop + pre.clientHeight >= pre.scrollHeight - 24; if (pre._ci) { logFeed(pre, text); logRefind(pre); } else { pre.appendChild(document.createTextNode(text)); } diff --git a/crates/forge-web/src/ci/metrics_chart.rs b/crates/forge-web/src/ci/metrics_chart.rs index 2cb15f9..b983b8d 100644 --- a/crates/forge-web/src/ci/metrics_chart.rs +++ b/crates/forge-web/src/ci/metrics_chart.rs @@ -6,12 +6,12 @@ use forge_ci::proto::RunnerSample; /// The width of the chart's viewBox. The SVG scales to its container with the aspect kept. -pub const VIEW_W: f64 = 700.0; +pub const VIEW_W: f64 = 360.0; /// The height of the chart's viewBox. pub const VIEW_H: f64 = 110.0; /// Where the plot starts and ends on the x axis, and its top and bottom on the y axis. pub const X0: f64 = 40.0; -pub const X1: f64 = 696.0; +pub const X1: f64 = 356.0; pub const Y0: f64 = 6.0; pub const Y1: f64 = 94.0; /// The time one bucket covers, in milliseconds. diff --git a/crates/forge-web/src/i18n/admin.rs b/crates/forge-web/src/i18n/admin.rs index dbe2372..77f212c 100644 --- a/crates/forge-web/src/i18n/admin.rs +++ b/crates/forge-web/src/i18n/admin.rs @@ -33,6 +33,7 @@ pub enum K { DatabaseErrorPrefix, DeleteAccountRest, DeletesAccount, + DeleteOrgTitle, DeleteUser, Directory, Disable, @@ -180,6 +181,10 @@ pub enum K { TransferOrDeleteFirst, UnknownHost, Users, + OpenOrgSettings, + OrgNotAUser, + OrgReposFirst, + ViewOrg, WhatHappens, } @@ -253,6 +258,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { } (DeletesAccount, En) => "This deletes the account ", (DeletesAccount, Tr) => "Bu işlem ", + (DeleteOrgTitle, En) => "Delete organization", + (DeleteOrgTitle, Tr) => "Kuruluşu sil", (DeleteUser, En) => "Delete user", (DeleteUser, Tr) => "Kullanıcıyı sil", (Directory, En) => "Directory", @@ -263,6 +270,16 @@ pub fn t(lang: Lang, key: K) -> &'static str { (Disabled, Tr) => "devre dışı", (Enable, En) => "Enable", (Enable, Tr) => "Etkinleştir", + (OpenOrgSettings, En) => "Open organization settings", + (OpenOrgSettings, Tr) => "Kuruluş ayarlarını aç", + (OrgNotAUser, En) => { + " is an organization, not a user account, so it cannot be deleted from here. One of its owners deletes it from the organization's settings." + } + (OrgNotAUser, Tr) => { + " bir kuruluştur, kullanıcı hesabı değildir, bu yüzden buradan silinemez. Kuruluşu sahiplerinden biri, kuruluşun ayarlarından siler." + } + (OrgReposFirst, En) => "It can be deleted once it owns no repositories. It still owns:", + (OrgReposFirst, Tr) => "Hiç deposu kalmadığında silinebilir. Hâlâ sahip olduğu depolar:", (ErrAccountCannotBeDeleted, En) => "this account cannot be deleted", (ErrAccountCannotBeDeleted, Tr) => "bu hesap silinemez", (ErrBackupsNotConfigured, En) => { @@ -605,6 +622,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { (UnknownHost, Tr) => "bilinmiyor", (Users, En) => "Users", (Users, Tr) => "Kullanıcılar", + (ViewOrg, En) => "View organization", + (ViewOrg, Tr) => "Kuruluşu görüntüle", (WhatHappens, En) => "What happens", (WhatHappens, Tr) => "Ne olacak", } @@ -833,11 +852,15 @@ mod tests { K::DatabaseErrorPrefix, K::DeleteAccountRest, K::DeletesAccount, + K::DeleteOrgTitle, K::DeleteUser, K::Directory, K::Disable, K::Disabled, K::Enable, + K::OpenOrgSettings, + K::OrgNotAUser, + K::OrgReposFirst, K::ErrAccountCannotBeDeleted, K::ErrBackupsNotConfigured, K::ErrChooseSecurity, @@ -980,6 +1003,7 @@ mod tests { K::TransferOrDeleteFirst, K::UnknownHost, K::Users, + K::ViewOrg, K::WhatHappens, ]; diff --git a/crates/forge-web/src/i18n/orgs.rs b/crates/forge-web/src/i18n/orgs.rs index 9e0335f..0a9cd1f 100644 --- a/crates/forge-web/src/i18n/orgs.rs +++ b/crates/forge-web/src/i18n/orgs.rs @@ -121,7 +121,6 @@ pub enum K { PinsTooMany, NoPinnableRepos, TabOverview, - TabContributions, Overview, TabStars, FilterRepos, @@ -376,8 +375,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { (NoPinnableRepos, Tr) => "Henüz sabitlenecek depo yok.", (TabOverview, En) => "Overview", (TabOverview, Tr) => "Genel bakış", - (TabContributions, En) => "Contributions", - (TabContributions, Tr) => "Katkılar", (Overview, En) => "Overview", (Overview, Tr) => "Genel bakış", (TabStars, En) => "Stars", @@ -621,7 +618,6 @@ mod tests { K::PinsTooMany, K::NoPinnableRepos, K::TabOverview, - K::TabContributions, K::Overview, K::TabStars, K::FilterRepos, diff --git a/crates/forge-web/src/pages/admin_runners.rs b/crates/forge-web/src/pages/admin_runners.rs index 65a53a1..e2cc99c 100644 --- a/crates/forge-web/src/pages/admin_runners.rs +++ b/crates/forge-web/src/pages/admin_runners.rs @@ -795,15 +795,13 @@ fn sel(on: bool) -> Option<&'static str> { on.then_some("selected") } -/// The detail page tabs: slug and the config keys on it. `jobs`, `metrics`, `identity` and `logs` are -/// read-only. -const TABS: [(&str, &[&str]); 8] = [ +/// The detail page tabs: slug and the config keys on it. `jobs`, `identity` and `logs` are read-only. +const TABS: [(&str, &[&str]); 7] = [ ( "general", &["concurrency", "labels", "executor", "auto_update"], ), ("jobs", &[]), - ("metrics", &[]), ( "limits", &[ @@ -837,7 +835,6 @@ fn tab_label(lang: Lang, slug: &str) -> &'static str { "sandbox" => s(lang, "Sandbox", "Kum havuzu"), "logs" => s(lang, "Logs", "Günlük"), "jobs" => s(lang, "Jobs", "İşler"), - "metrics" => s(lang, "Metrics", "Ölçümler"), _ => s(lang, "Identity", "Kimlik"), } } @@ -1243,9 +1240,8 @@ async fn runner_job_rows( )) } -/// The metrics tab: three graphs over the last hour and the table of their buckets. -#[derive(Default)] -struct MetricsTab { +/// The metrics on the runner page: three graphs over the last hour and the table of their buckets. +struct MetricsView { /// True when no sample falls in the last hour. empty: bool, charts: Vec, @@ -1451,7 +1447,7 @@ fn mx_chart( } /// The three graphs of a runner's samples as of `now_ms`, with the table of their buckets. -fn metrics_tab(lang: Lang, samples: &[RunnerSample], now_ms: i64) -> MetricsTab { +fn metrics_view(lang: Lang, samples: &[RunnerSample], now_ms: i64) -> MetricsView { let points = metrics_chart::chart_points(samples, now_ms); let latest = points.iter().rev().flatten().next().copied(); let empty = latest.is_none(); @@ -1526,7 +1522,7 @@ fn metrics_tab(lang: Lang, samples: &[RunnerSample], now_ms: i64) -> MetricsTab tx: rate_text(b.tx), }) .collect(); - MetricsTab { + MetricsView { empty, charts: vec![cpu, mem, net], rows, @@ -1553,7 +1549,7 @@ async fn runner_detail_view( log: Vec, running_jobs: Vec, recent_jobs: Vec, - metrics: MetricsTab, + metrics: MetricsView, ) -> Result { let version = or_dash(runner.reported.version.clone().unwrap_or_default()); let cpus = or_dash( @@ -1586,10 +1582,27 @@ async fn runner_detail_view( }; let shown = detail_fields(lang, tab, &fields); let identity = identity_rows(lang, &fields); - let editing = !matches!(tab, "identity" | "logs" | "jobs" | "metrics"); + let editing = !matches!(tab, "identity" | "logs" | "jobs"); let jobs_href = format!("{}?tab=jobs", row.detail_href); let save_action = format!("{}/settings", row.detail_href); let reset_action = row.config_action.clone(); + // The facts under each graph's caption. Memory's total is in its caption once a sample exists, + // so the memory facts name the total only when there is none. + let cpu_facts = format!("{cpus} {}", s(lang, "CPUs", "CPU")); + let budget_facts = format!( + "{} {budget_text} · {} {reserved_text} · {} {free_text}", + s(lang, "Budget", "Bütçe"), + s(lang, "Reserved", "Ayrılan"), + s(lang, "Free to admit", "Alınabilir"), + ); + let mem_facts = if metrics.empty { + format!("{memory} · {budget_facts}") + } else { + budget_facts + }; + let facts = [cpu_facts, mem_facts, String::new()]; + // A runner that has reported nothing has no figures to show, only the note below. + let has_host = !metrics.empty || runner.reported.cpus.is_some(); Ok(view! {
@@ -1612,18 +1625,89 @@ async fn runner_detail_view(
(text)
} } -
+
(s(lang, "Running jobs", "Çalışan işler"))(in_use.as_str())
(g::t(lang, K::LastSeen))
(s(lang, "Build", "Derleme"))(if row.build_short.is_empty() { "-" } else { row.build_short.as_str() })(row.build_label)
(s(lang, "Runner version", "Çalıştırıcı sürümü"))(version.as_str())
-
(s(lang, "CPUs", "CPU sayısı"))(cpus.as_str())
-
(s(lang, "Memory", "Bellek"))(memory.as_str())
-
(s(lang, "Memory budget", "Bellek bütçesi"))(budget_text.as_str())
-
(s(lang, "Reserved", "Ayrılan"))(reserved_text.as_str())
-
(s(lang, "Free to admit", "Alınabilir"))(free_text.as_str())
+ if has_host { +
+ for (c, fact) in metrics.charts.iter().zip(facts.iter()) { +
+
+

(c.caption.as_str())

+ if !fact.is_empty() { +

(fact.as_str())

+ } + if !c.legend.is_empty() { +
    + for (key, text) in c.legend.iter() { +
  • (*text)
  • + } +
+ } +
+ if !metrics.empty { + + for y in c.grids.iter() { + + } + for (x, w) in c.bands.iter() { + + } + for (y, text) in c.ticks.iter() { + (text.as_str()) + } + for p in c.paths.iter() { + + } + (s(lang, "-60 min", "-60 dk")) + (s(lang, "-30 min", "-30 dk")) + (s(lang, "now", "şimdi")) + for hit in c.hits.iter() { + + (hit.title.as_str()) + + + + + for line in hit.lines.iter() { + (line.text.as_str()) + } + + + } + + } +
+ } +
+ } + if metrics.empty { +

(s(lang, "No metrics yet. A runner sends them from this version on; an older one sends nothing.", "Henüz ölçüm yok. Ölçümleri bu sürümden itibaren çalıştırıcı gönderir; eski sürüm hiçbir şey göndermez."))

+ } else { +
+ (s(lang, "Show as table", "Tablo olarak göster")) +
+ + + + for row in metrics.rows.iter() { + + + + + + + + } + +
(s(lang, "Time (UTC)", "Saat (UTC)"))(s(lang, "CPU", "CPU"))(s(lang, "Memory", "Bellek"))(s(lang, "Received", "Alınan"))(s(lang, "Sent", "Gönderilen"))
(row.time.as_str())(row.cpu.as_str())(row.mem.as_str())(row.rx.as_str())(row.tx.as_str())
+
+
+ }
if has_orgs { -
    +
      for org in orgs.into_iter() {
    • - (org.name.as_str()) + (org.name.as_str()) if !org.display_name.is_empty() { - " " (org.display_name.as_str()) + (org.display_name.as_str()) } - " " (org.role) + (org.role)
    • }
    @@ -1218,17 +1207,17 @@ mod tests { ); } - /// The calendar sits on the Contributions tab, not the overview, and an old `?day=` link with no - /// tab opens that tab. + /// The calendar sits on the overview. An old `?tab=contributions` link falls through to it. #[tokio::test] - async fn contributions_tab_holds_the_calendar() { + async fn overview_holds_the_calendar() { let site = seeded().await; let (_, overview) = get(&site.router, "/tahinli", None).await; - assert!(!overview.contains("class=\"heat\""), "overview: no calendar"); - let (_, tab) = get(&site.router, "/tahinli?tab=contributions", None).await; - assert!(tab.contains("class=\"heat\""), "contributions: calendar"); - let (_, old) = get(&site.router, "/tahinli?day=2020-01-01", None).await; - assert!(old.contains("class=\"heat\""), "old day link: calendar"); + assert!(overview.contains("class=\"heat\""), "overview: calendar"); + let (_, old) = get(&site.router, "/tahinli?tab=contributions", None).await; + assert!(old.contains("class=\"heat\""), "old tab link: calendar"); + assert!(!overview.contains("tab=contributions"), "nav: no contributions tab"); + let (_, day) = get(&site.router, "/tahinli?day=2020-01-01", None).await; + assert!(day.contains("class=\"heat\""), "day link: calendar"); } fn count(body: &str, needle: &str) -> usize { diff --git a/crates/forge-web/src/views/heatmap.rs b/crates/forge-web/src/views/heatmap.rs index b3eaffe..f128d52 100644 --- a/crates/forge-web/src/views/heatmap.rs +++ b/crates/forge-web/src/views/heatmap.rs @@ -4,7 +4,7 @@ //! `build` is pure date and streak maths over the counts from the store. `contribution_calendar` //! draws it with classes only (CSP): the grid placement comes from CSS (`grid-auto-flow: column` //! with seven rows), so every cell is an element and the blank slots keep the columns aligned. -//! Each day is a link to `?tab=contributions&day=` (a plain link, no script): the page then lists +//! Each day is a link to `?day=` (a plain link, no script): the page then lists //! that day's contributions under the calendar, and clicking the selected day again clears it. use std::collections::HashMap; @@ -210,14 +210,14 @@ struct DayView { /// The link for a calendar day: the day's contributions below the calendar, or back to the /// plain calendar when the day is the selected one. `base` is the profile's path, without a query. -/// Both links stay on the Contributions tab. The anchor brings a full page load back to the -/// calendar; nav.js swaps in place and keeps the scroll (`data-keep-scroll`), so it is not used there. +/// The anchor brings a full page load back to the calendar; nav.js swaps in place and keeps the +/// scroll (`data-keep-scroll`), so it is not used there. fn day_href(base: &str, date: (i64, i64, i64), selected: bool) -> String { if selected { - format!("{base}?tab=contributions#contributions-h") + format!("{base}#contributions-h") } else { format!( - "{base}?tab=contributions&day={:04}-{:02}-{:02}#contributions-h", + "{base}?day={:04}-{:02}-{:02}#contributions-h", date.0, date.1, date.2 ) } diff --git a/crates/forge-web/src/views/mod.rs b/crates/forge-web/src/views/mod.rs index db45b5a..4f21cbb 100644 --- a/crates/forge-web/src/views/mod.rs +++ b/crates/forge-web/src/views/mod.rs @@ -294,7 +294,7 @@ struct ProfileCorner { } /// The floating account panel fixed at the bottom left of the window (signed in only). It opens -/// upward: the avatar, the chips, the notifications bell with its unread count and popover, then +/// upward: the avatar, the viewer's full name, the chips, the notifications bell with its unread count and popover, then /// the Explore, profile, settings, admin and log out links and the theme choice. #[component] async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result { diff --git a/style/_admin_rows.scss b/style/_admin_rows.scss index c0c35c5..233f4b8 100644 --- a/style/_admin_rows.scss +++ b/style/_admin_rows.scss @@ -134,30 +134,50 @@ margin-bottom: 6px; } -// The metrics tab: three small graphs, one under another, each with its caption on the left. Every -// graph is its own SVG with one y axis; colours come from tokens only. A line follows the accent, a -// sent line is dashed in the secondary text colour so it is told apart without colour. -.mx-stack { +// The runner's metrics sit under its stats: three graphs side by side on a wide page (one column +// below 900px), each in a panel with its caption and facts above it. Every graph is its own SVG with +// one y axis; colours come from tokens only. A line follows the accent, a sent line is dashed in the +// secondary text colour so it is told apart without colour. +// The wrapper is `.mx-panels`, not `.mx-grid`: that name is the SVG gridline class below. +.mx-panels { display: grid; - gap: 10px; + grid-template-columns: minmax(0, 1fr); + gap: 16px 24px; + margin-top: 16px; + padding-top: 16px; + border-top: 1px solid var(--border); } -.mx-row { +@media (min-width: 900px) { + .mx-panels { + grid-template-columns: repeat(3, minmax(0, 1fr)); + } +} + +.mx-panel { display: grid; - grid-template-columns: 200px minmax(0, 1fr); - align-items: center; - gap: 4px 16px; + gap: 6px; + align-content: start; + min-width: 0; +} + +.mx-head { + min-height: 2.75rem; } .mx-caption { margin: 0; color: var(--text); - font-size: 0.875rem; + font-size: 1.0625rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; } +.mx-facts { + margin: 0; +} + .mx-legend { display: flex; flex-wrap: wrap; @@ -169,6 +189,10 @@ font-size: 0.75rem; } +.mx-panel .mx-legend { + margin-top: 0; +} + // A legend swatch: a short line in the series' style. It carries the identity, the text does not. .mx-key { display: inline-block; @@ -186,6 +210,7 @@ .mx-svg { display: block; width: 100%; + max-width: 560px; height: auto; overflow: visible; } @@ -267,9 +292,3 @@ max-height: 240px; overflow: auto; } - -@media (max-width: 600px) { - .mx-row { - grid-template-columns: minmax(0, 1fr); - } -} diff --git a/style/_dashboard.scss b/style/_dashboard.scss new file mode 100644 index 0000000..ce0d7b4 --- /dev/null +++ b/style/_dashboard.scss @@ -0,0 +1,179 @@ +// Shared list and page styles that were in the dashboard file until c812504: the explore search and +// sort chips, the repo listing on profile tabs, repo rows, the numbered pager and the org page head. + +// Explore: one-row search (input, then its button) and a sort control of pill links. +.explore-search { + display: flex; + flex-wrap: wrap; + gap: 8px; + align-items: center; + margin: 18px 0 0; + + input[type="search"] { + flex: 1 1 240px; + width: auto; + min-width: 0; + } + + button { + flex: 0 0 auto; + } + + @media (max-width: 479px) { + input[type="search"] { + flex: 1 1 100%; + } + } +} + +.explore-sort { + display: flex; + flex-wrap: wrap; + gap: 6px 8px; + align-items: center; + margin: 14px 0 0; + font-size: 13px; + + a, + .current { + display: inline-flex; + align-items: center; + height: 28px; + padding: 0 12px; + border: 1px solid var(--border); + border-radius: var(--radius-full); + color: var(--text-2); + text-decoration: none; + } + + a:hover { + background: var(--surface-2); + text-decoration: none; + } + + .current { + border-color: transparent; + background: var(--accent-soft); + color: var(--accent-ink); + font-weight: 600; + } +} + +// Repo listing toolbar: the search takes the free width, and the New repository button sits beside it. +.repo-tools { + display: flex; + flex-wrap: wrap; + gap: 8px; + align-items: center; + + .explore-search { + flex: 1 1 320px; + margin: 0; + } + + .button { + flex: none; + } +} + +// Sort chips and the count on one line under the toolbar; the chips' own gap spaces "Sort by". +.repo-subbar { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 8px 16px; + + .explore-sort, + p { + margin: 0; + } +} + +// A repo listing (profile tabs): search, sort chips, count, rows and pager as one tight block, so +// the profile's section gap does not open between the count line and the list. +.repo-listing { + display: flex; + flex-direction: column; + gap: 10px; + + > .explore-search, + > .explore-sort, + > p { + margin: 0; + } +} + +.repo-item-head { + display: flex; + align-items: center; + gap: 8px; + min-width: 0; + + .repo-name { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .badge { + flex: 0 0 auto; + } +} + +.repo-item .repo-desc { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.pager-numbered { + flex-wrap: wrap; + gap: 4px; + font-size: 13px; + + .pager-page, + .pager-step, + .pager-gap { + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 30px; + height: 30px; + padding: 0 8px; + border-radius: var(--radius-full); + color: var(--text-2); + text-decoration: none; + } + + a:hover { + background: var(--surface-2); + text-decoration: none; + } + + .current { + background: var(--accent-soft); + color: var(--accent-ink); + font-weight: 600; + } + + .pager-gap { + min-width: 20px; + padding: 0; + } +} + +// Organization pages: the name and description stack; the section links are in the shell sidebar. +.org-head { + .org-head-text { + display: grid; + gap: 4px; + min-width: 0; + } + + h1, + p { + margin: 0; + } +} diff --git a/style/_shell.scss b/style/_shell.scss index 00fd4d6..ce84755 100644 --- a/style/_shell.scss +++ b/style/_shell.scss @@ -898,14 +898,14 @@ a.chip { box-shadow: var(--shadow); } -// The profile corner: a small panel fixed at the bottom left of the window, the avatar, the chips and -// the bell. The name is left out of the panel; its aria-label still names the viewer. +// The profile corner: a small panel fixed at the bottom left of the window, the avatar, the name, the +// chips and the bell. The name is always shown in full (see `.corner-name` below). .corner-float { position: fixed; left: 16px; bottom: 16px; z-index: 40; - max-width: min(280px, calc(100vw - 32px)); + max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; @@ -953,8 +953,18 @@ a.chip { right: 8px; } +// The viewer's full name, never truncated. On a phone it wraps instead of running off the screen. .corner-float .corner-name { - display: none; + display: block; + padding-right: 4px; + white-space: nowrap; + overflow: visible; +} + +@media (max-width: 479px) { + .corner-float .corner-name { + white-space: normal; + } } .corner-float .corner-btn { diff --git a/style/main.scss b/style/main.scss index 0e9de9f..336f9fd 100644 --- a/style/main.scss +++ b/style/main.scss @@ -2328,7 +2328,21 @@ code { } } -// Pinned repos: two cards per row on wide screens, one on phones. +// The viewer's organization rows: avatar, name, display name and role on one centred line, with the +// same row rule as `.repo-item`. +.org-rows li { + display: flex; + align-items: center; + gap: 10px; + padding: 10px 0; + border-bottom: 1px solid var(--border); + + &:last-child { + border-bottom: 0; + } +} + +// Pinned repos: three cards per row on wide screens, two on tablets, one on phones. .pin-grid { display: grid; grid-template-columns: minmax(0, 1fr); @@ -2340,6 +2354,10 @@ code { @media (min-width: 720px) { grid-template-columns: repeat(2, minmax(0, 1fr)); } + + @media (min-width: 1100px) { + grid-template-columns: repeat(3, minmax(0, 1fr)); + } } .pin-card { @@ -7043,6 +7061,7 @@ button.ci-job-last { @import "heatmap"; @import "repo"; @import "pull"; +@import "dashboard"; @import "wiki"; @import "browse"; @import "import";