The bell's popover stays open instead of closing as the click also followed its link to the inbox
Browse files at this commit240478f3c3da80d277a97943f3b211e0d40603a0Parent: 8e5a2cf- fix
- the bell's popover stays open instead of closing as the click also followed its link to the inbox
- a live page waits to re-render while the reader holds a button or has text selected, so selecting a log line to copy no longer resets
- a runner's log has a Copy all button, and a line that wraps or holds newlines continues under the message column
- the runner leaves an HTML error page out of its error (forge answered 503 Service Unavailable) and folds other bodies onto one line
- a runner's whole row in the list opens its page
- the repo home puts the branch bar and the tree in a left column, the README beside it and About on the right, filling the screen with each column scrolling on its own (tree and README side by side from 900px, the aside under them until 1200px)
7 changed files +199 -28
- crates/forge-runner/src/client.rs +17 -7
- crates/forge-web/assets/nav.js +25 -3
- crates/forge-web/src/pages/admin_runners.rs +7 -3
- crates/forge-web/src/pages/repo.rs +12 -10
- style/_admin_rows.scss +14 -2
- style/_repo.scss +98 -3
- style/main.scss +26 -0
crates/forge-runner/src/client.rsmodified+17 -7
| @@ -44,7 +44,7 @@ const RUNNER_METRICS_PATH: &str = "/api/v1/ci/runners/metrics"; | |||
| 44 | pub enum ClientError { | 44 | pub enum ClientError { |
| 45 | #[error("http: {0}")] | 45 | #[error("http: {0}")] |
| 46 | Http(#[from] reqwest::Error), | 46 | Http(#[from] reqwest::Error), |
| 47 | - #[error("forge answered {status}: {body}")] | 47 | + #[error("forge answered {status}{}", if body.is_empty() { String::new() } else { format!(": {body}") })] |
| 48 | Status { status: StatusCode, body: String }, | 48 | Status { status: StatusCode, body: String }, |
| 49 | #[error("local io: {0}")] | 49 | #[error("local io: {0}")] |
| 50 | Io(#[from] std::io::Error), | 50 | Io(#[from] std::io::Error), |
| @@ -500,14 +500,24 @@ async fn json_or_error<T: DeserializeOwned>(resp: reqwest::Response) -> Result<T | |||
| 500 | 500 | ||
| 501 | async fn status_error(resp: reqwest::Response) -> ClientError { | 501 | async fn status_error(resp: reqwest::Response) -> ClientError { |
| 502 | let status = resp.status(); | 502 | let status = resp.status(); |
| 503 | - let body: String = resp | 503 | + let body = short_body(&resp.text().await.unwrap_or_default()); |
| 504 | - .text() | 504 | + ClientError::Status { status, body } |
| 505 | - .await | 505 | +} |
| 506 | - .unwrap_or_default() | 506 | + |
| 507 | +/// The part of an error body worth a log line: an HTML error page (a proxy's or the forge's own 503 | ||
| 508 | +/// page) says no more than the status does, so it is dropped; any other text is folded onto one line | ||
| 509 | +/// and cut at 512 characters. | ||
| 510 | +fn short_body(text: &str) -> String { | ||
| 511 | + let text = text.trim_start(); | ||
| 512 | + if text.starts_with('<') { | ||
| 513 | + return String::new(); | ||
| 514 | + } | ||
| 515 | + text.split_whitespace() | ||
| 516 | + .collect::<Vec<_>>() | ||
| 517 | + .join(" ") | ||
| 507 | .chars() | 518 | .chars() |
| 508 | .take(512) | 519 | .take(512) |
| 509 | - .collect(); | 520 | + .collect() |
| 510 | - ClientError::Status { status, body } | ||
| 511 | } | 521 | } |
| 512 | 522 | ||
| 513 | #[cfg(test)] | 523 | #[cfg(test)] |
crates/forge-web/assets/nav.jsmodified+25 -3
| @@ -763,7 +763,9 @@ | |||
| 763 | peekPress = !!(pop && pop.classList.contains('bell-pop') && isPeekOpen(pop)); | 763 | peekPress = !!(pop && pop.classList.contains('bell-pop') && isPeekOpen(pop)); |
| 764 | }, true); | 764 | }, true); |
| 765 | 765 | ||
| 766 | - document.addEventListener('click', function (e) { | 766 | + // Capture on window, so it runs before the soft navigation (capture on document) follows the |
| 767 | + // bell's link to the inbox, which would swap the page and close the popover it just opened. | ||
| 768 | + window.addEventListener('click', function (e) { | ||
| 767 | if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) { return; } | 769 | if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) { return; } |
| 768 | var bell = e.target && e.target.closest ? e.target.closest('.corner-bell') : null; | 770 | var bell = e.target && e.target.closest ? e.target.closest('.corner-bell') : null; |
| 769 | if (!bell) { return; } | 771 | if (!bell) { return; } |
| @@ -776,7 +778,7 @@ | |||
| 776 | try { | 778 | try { |
| 777 | if (was) { pop.hidePopover(); } else { pop.showPopover(); } | 779 | if (was) { pop.hidePopover(); } else { pop.showPopover(); } |
| 778 | } catch (err) { } | 780 | } catch (err) { } |
| 779 | - }, false); | 781 | + }, true); |
| 780 | 782 | ||
| 781 | // The popover's open state drives its bell's aria-expanded; opening places it and fetches its list. | 783 | // The popover's open state drives its bell's aria-expanded; opening places it and fetches its list. |
| 782 | document.addEventListener('toggle', function (e) { | 784 | document.addEventListener('toggle', function (e) { |
| @@ -2494,6 +2496,26 @@ | |||
| 2494 | if (atEnd) { pre.scrollTop = pre.scrollHeight; } | 2496 | if (atEnd) { pre.scrollTop = pre.scrollHeight; } |
| 2495 | } | 2497 | } |
| 2496 | 2498 | ||
| 2499 | + // A re-render replaces the text the reader is selecting (a log line to copy, say), so a live change | ||
| 2500 | + // waits while a button is held or text on the page is selected, and is sent once the selection is | ||
| 2501 | + // gone. A selection inside a field does not count: fields keep their state across a re-render. | ||
| 2502 | + var pressing = false; | ||
| 2503 | + function selecting() { | ||
| 2504 | + if (pressing) { return true; } | ||
| 2505 | + var sel = window.getSelection ? window.getSelection() : null; | ||
| 2506 | + if (!sel || sel.isCollapsed || !sel.rangeCount) { return false; } | ||
| 2507 | + var act = document.activeElement; | ||
| 2508 | + return !(act && (act.tagName === 'INPUT' || act.tagName === 'TEXTAREA')); | ||
| 2509 | + } | ||
| 2510 | + function selectionDone() { | ||
| 2511 | + if (liveDirty && !selecting()) { refreshLive(liveForced); } | ||
| 2512 | + } | ||
| 2513 | + document.addEventListener('pointerdown', function (e) { if (e.button === 0) { pressing = true; } }, true); | ||
| 2514 | + document.addEventListener('pointerup', function () { pressing = false; setTimeout(selectionDone, 0); }, true); | ||
| 2515 | + document.addEventListener('pointercancel', function () { pressing = false; selectionDone(); }, true); | ||
| 2516 | + document.addEventListener('selectionchange', selectionDone); | ||
| 2517 | + window.addEventListener('blur', function () { pressing = false; }); | ||
| 2518 | + | ||
| 2497 | // A change re-renders the current page. It waits while a navigation is on the wire, since that | 2519 | // A change re-renders the current page. It waits while a navigation is on the wire, since that |
| 2498 | // response could be superseded: the change is kept and sent after that request completes. | 2520 | // response could be superseded: the change is kept and sent after that request completes. |
| 2499 | // `force` re-renders a page that holds no stream of its own (a language change, or a live server | 2521 | // `force` re-renders a page that holds no stream of its own (a language change, or a live server |
| @@ -2503,7 +2525,7 @@ | |||
| 2503 | // A one-time secret (a token, recovery codes) is on screen only in the response that made it: a | 2525 | // A one-time secret (a token, recovery codes) is on screen only in the response that made it: a |
| 2504 | // re-render would take it away. The page is refreshed at the next navigation instead. | 2526 | // re-render would take it away. The page is refreshed at the next navigation instead. |
| 2505 | if (document.querySelector('[data-once]')) { return; } | 2527 | if (document.querySelector('[data-once]')) { return; } |
| 2506 | - if (userBusy > 0 || liveBusy) { liveDirty = true; if (force) { liveForced = true; } return; } | 2528 | + if (userBusy > 0 || liveBusy || selecting()) { liveDirty = true; if (force) { liveForced = true; } return; } |
| 2507 | liveDirty = false; | 2529 | liveDirty = false; |
| 2508 | liveForced = false; | 2530 | liveForced = false; |
| 2509 | liveBusy = true; | 2531 | liveBusy = true; |
crates/forge-web/src/pages/admin_runners.rsmodified+7 -3
| @@ -31,6 +31,7 @@ use crate::ci::runner_log::Line; | |||
| 31 | use crate::auth::check_csrf; | 31 | use crate::auth::check_csrf; |
| 32 | use crate::i18n::admin::{self as g, K}; | 32 | use crate::i18n::admin::{self as g, K}; |
| 33 | use crate::i18n::{self, Key, Lang}; | 33 | use crate::i18n::{self, Key, Lang}; |
| 34 | +use crate::i18n::releases_ci as rc; | ||
| 34 | use crate::pages::admin_users::admin_only; | 35 | use crate::pages::admin_users::admin_only; |
| 35 | use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; | 36 | use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; |
| 36 | use crate::pages::repo_mirrors::stamp_in_tz; | 37 | use crate::pages::repo_mirrors::stamp_in_tz; |
| @@ -338,7 +339,7 @@ async fn runners_view( | |||
| 338 | } else { | 339 | } else { |
| 339 | <ul class="runner-list"> | 340 | <ul class="runner-list"> |
| 340 | for row in rows.iter() { | 341 | for row in rows.iter() { |
| 341 | - <li class="runner-row"> | 342 | + <li class="runner-row is-linked"> |
| 342 | <div class="runner-id"> | 343 | <div class="runner-id"> |
| 343 | <div class="runner-title"> | 344 | <div class="runner-title"> |
| 344 | <span class=(row.dot_class) role="img" aria-label=(row.state_text) title=(row.state_text)></span> | 345 | <span class=(row.dot_class) role="img" aria-label=(row.state_text) title=(row.state_text)></span> |
| @@ -1679,9 +1680,12 @@ async fn runner_detail_view( | |||
| 1679 | if log.is_empty() { | 1680 | if log.is_empty() { |
| 1680 | <p class="muted small">(s(lang, "No log lines yet. Only a runner from the version that sends its log does so; an older runner sends nothing.", "Henüz günlük satırı yok. Günlüğünü yalnızca bunu destekleyen sürüm gönderir; eski sürüm hiçbir şey göndermez."))</p> | 1681 | <p class="muted small">(s(lang, "No log lines yet. Only a runner from the version that sends its log does so; an older runner sends nothing.", "Henüz günlük satırı yok. Günlüğünü yalnızca bunu destekleyen sürüm gönderir; eski sürüm hiçbir şey göndermez."))</p> |
| 1681 | } else { | 1682 | } else { |
| 1682 | - <pre class="ci-log runner-log" role="log" aria-label=(s(lang, "Runner log", "Çalıştırıcı günlüğü"))> | 1683 | + <div class="runner-log-bar"> |
| 1684 | + <button type="button" class="ci-mini" data-copy="runner-log" data-copied=(rc::t(lang, rc::K::CopyDone)) data-failed=(rc::t(lang, rc::K::CopyFailed))>(s(lang, "Copy all", "Tümünü kopyala"))</button> | ||
| 1685 | + </div> | ||
| 1686 | + <pre id="runner-log" class="ci-log runner-log" role="log" aria-label=(s(lang, "Runner log", "Çalıştırıcı günlüğü"))> | ||
| 1683 | for row in log.iter() { | 1687 | for row in log.iter() { |
| 1684 | - <span class=(row.class)><span class="runner-log-time">(row.time.as_str())</span>" "<span class="runner-log-level">(row.level.as_str())</span>" "<span class="runner-log-chip">(row.chip)</span>" "(row.text.as_str())</span>"\n" | 1688 | + <span class=(row.class)><span class="runner-log-time">(row.time.as_str())</span>" "<span class="runner-log-level">(row.level.as_str())</span>" "<span class="runner-log-chip">(row.chip)</span>" "(row.text.as_str())"\n"</span> |
| 1685 | } | 1689 | } |
| 1686 | </pre> | 1690 | </pre> |
| 1687 | } | 1691 | } |
crates/forge-web/src/pages/repo.rsmodified+12 -10
| @@ -500,18 +500,20 @@ async fn repo_page(cx: &Cx) -> Result<impl View> { | |||
| 500 | recent_pushes(banners: banners, now: now, lang: lang) | 500 | recent_pushes(banners: banners, now: now, lang: lang) |
| 501 | } | 501 | } |
| 502 | if let Some(rows) = tree { | 502 | if let Some(rows) = tree { |
| 503 | - <div class="browse-bar" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> | 503 | + <div class="repo-grid repo-home"> |
| 504 | - ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags, | ||
| 505 | - branches_href: branches_href, tags_href: tags_href) | ||
| 506 | - file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), | ||
| 507 | - ref_name: branch.clone()) | ||
| 508 | - archive_links(owner: owner_name, repo: repo_name, | ||
| 509 | - ref_name: branch.clone(), lang: lang) | ||
| 510 | - clone_popover(https: https, ssh: ssh, lang: lang) | ||
| 511 | - </div> | ||
| 512 | - <div class="repo-grid"> | ||
| 513 | <div class="repo-main"> | 504 | <div class="repo-main"> |
| 505 | + <div class="browse-bar" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> | ||
| 506 | + ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags, | ||
| 507 | + branches_href: branches_href, tags_href: tags_href) | ||
| 508 | + file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), | ||
| 509 | + ref_name: branch.clone()) | ||
| 510 | + archive_links(owner: owner_name, repo: repo_name, | ||
| 511 | + ref_name: branch.clone(), lang: lang) | ||
| 512 | + clone_popover(https: https, ssh: ssh, lang: lang) | ||
| 513 | + </div> | ||
| 514 | tree_table(rows: rows, latest: bar, lang: lang) | 514 | tree_table(rows: rows, latest: bar, lang: lang) |
| 515 | + </div> | ||
| 516 | + <div class="repo-readme"> | ||
| 515 | if let Some(readme) = readme { | 517 | if let Some(readme) = readme { |
| 516 | readme_card(name: readme.name, markdown: readme.markdown, body: readme.body) | 518 | readme_card(name: readme.name, markdown: readme.markdown, body: readme.body) |
| 517 | } | 519 | } |
style/_admin_rows.scssmodified+14 -2
| @@ -93,9 +93,14 @@ | |||
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | -// The runner's own log on its admin page (the logs tab), newest line first. Lines stay inline: | 96 | +// The runner's own log on its admin page (the logs tab), newest line first. Each line is a block |
| 97 | -// the pre breaks them with its own newlines. | 97 | +// with a hanging indent, so a message that wraps or holds newlines of its own continues under the |
| 98 | +// message column (past the time and level) instead of at the left edge, where it reads as new lines. | ||
| 98 | .runner-log-line { | 99 | .runner-log-line { |
| 100 | + display: block; | ||
| 101 | + padding-left: 15ch; | ||
| 102 | + text-indent: -15ch; | ||
| 103 | + | ||
| 99 | &.is-warn { | 104 | &.is-warn { |
| 100 | color: var(--warn); | 105 | color: var(--warn); |
| 101 | } | 106 | } |
| @@ -122,6 +127,13 @@ | |||
| 122 | padding: 8px 12px; | 127 | padding: 8px 12px; |
| 123 | } | 128 | } |
| 124 | 129 | ||
| 130 | +// Copy all sits above the log, at its right edge. | ||
| 131 | +.runner-log-bar { | ||
| 132 | + display: flex; | ||
| 133 | + justify-content: flex-end; | ||
| 134 | + margin-bottom: 6px; | ||
| 135 | +} | ||
| 136 | + | ||
| 125 | // The metrics tab: three small graphs, one under another, each with its caption on the left. Every | 137 | // The metrics tab: three small graphs, one under another, each with its caption on the left. Every |
| 126 | // graph is its own SVG with one y axis; colours come from tokens only. A line follows the accent, a | 138 | // graph is its own SVG with one y axis; colours come from tokens only. A line follows the accent, a |
| 127 | // sent line is dashed in the secondary text colour so it is told apart without colour. | 139 | // sent line is dashed in the secondary text colour so it is told apart without colour. |
style/_repo.scssmodified+98 -3
| @@ -242,8 +242,7 @@ | |||
| 242 | } | 242 | } |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | -// Two columns at 900px and up: the directory and README take the remaining width, then a | 245 | +// Grid of the repo-meta aside and the main column. Below 900px the columns stack in normal flow. |
| 246 | -// narrow repo-meta aside (280px). Below 900px the aside stacks under the main column. | ||
| 247 | .repo-grid { | 246 | .repo-grid { |
| 248 | display: grid; | 247 | display: grid; |
| 249 | grid-template-columns: minmax(0, 1fr); | 248 | grid-template-columns: minmax(0, 1fr); |
| @@ -269,11 +268,107 @@ | |||
| 269 | } | 268 | } |
| 270 | } | 269 | } |
| 271 | 270 | ||
| 271 | +// Repo home: the browse bar and the tree form a left column, the README fills the middle and the | ||
| 272 | +// repo-meta aside sits on the right. The columns scroll inside the grid so the page fits the | ||
| 273 | +// viewport; the height is the viewport less the top bar and the page header. | ||
| 274 | +.repo-home { | ||
| 275 | + --repo-home-h: max(480px, calc(100dvh - var(--topbar-h) - 200px)); | ||
| 276 | + margin-top: 20px; | ||
| 277 | + | ||
| 278 | + // The grid's own margin carries the space above the browse bar. | ||
| 279 | + .browse-bar { | ||
| 280 | + margin: 0 0 12px; | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + .repo-main { | ||
| 284 | + display: flex; | ||
| 285 | + flex-direction: column; | ||
| 286 | + min-height: 0; | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + // Only the tree scrolls, not the browse bar: the Clone popover drops over the tree and a scrolling | ||
| 290 | + // ancestor would clip it. | ||
| 291 | + .repo-main .table-wrap { | ||
| 292 | + flex: 1 1 auto; | ||
| 293 | + min-height: 0; | ||
| 294 | + overflow-y: auto; | ||
| 295 | + } | ||
| 296 | + | ||
| 297 | + .repo-readme { | ||
| 298 | + min-width: 0; | ||
| 299 | + min-height: 0; | ||
| 300 | + overflow-y: auto; | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | + .readme { | ||
| 304 | + margin-top: 0; | ||
| 305 | + } | ||
| 306 | +} | ||
| 307 | + | ||
| 308 | +// 900px to 1199px: the tree and README sit side by side and the aside drops under them at full | ||
| 309 | +// width, so the columns keep their own height and the aside flows with the page. | ||
| 272 | @media (min-width: 900px) { | 310 | @media (min-width: 900px) { |
| 273 | .repo-grid { | 311 | .repo-grid { |
| 274 | - grid-template-columns: minmax(0, 1fr) 280px; | ||
| 275 | gap: 40px; | 312 | gap: 40px; |
| 313 | + } | ||
| 314 | + | ||
| 315 | + .repo-home { | ||
| 316 | + grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); | ||
| 276 | align-items: start; | 317 | align-items: start; |
| 318 | + | ||
| 319 | + .repo-main, | ||
| 320 | + .repo-readme { | ||
| 321 | + max-height: var(--repo-home-h); | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | + .repo-meta { | ||
| 325 | + grid-column: 1 / -1; | ||
| 326 | + } | ||
| 327 | + | ||
| 328 | + // The name keeps half the narrow column and the last-commit message takes the rest. | ||
| 329 | + .tree-table { | ||
| 330 | + th, | ||
| 331 | + td { | ||
| 332 | + padding-right: 10px; | ||
| 333 | + } | ||
| 334 | + | ||
| 335 | + .tree-name { | ||
| 336 | + max-width: 50%; | ||
| 337 | + } | ||
| 338 | + | ||
| 339 | + .tree-commit a { | ||
| 340 | + font-size: 13px; | ||
| 341 | + } | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + .latest-commit { | ||
| 345 | + gap: 8px; | ||
| 346 | + | ||
| 347 | + .latest-author { | ||
| 348 | + max-width: 8rem; | ||
| 349 | + } | ||
| 350 | + } | ||
| 351 | + } | ||
| 352 | +} | ||
| 353 | + | ||
| 354 | +// 1200px and up: browse bar and tree | README | aside, all filling the viewport height. | ||
| 355 | +@media (min-width: 1200px) { | ||
| 356 | + .repo-home { | ||
| 357 | + grid-template-columns: minmax(320px, 420px) minmax(0, 1fr) 260px; | ||
| 358 | + gap: 32px; | ||
| 359 | + align-items: stretch; | ||
| 360 | + height: var(--repo-home-h); | ||
| 361 | + | ||
| 362 | + .repo-main, | ||
| 363 | + .repo-readme { | ||
| 364 | + max-height: none; | ||
| 365 | + } | ||
| 366 | + | ||
| 367 | + .repo-meta { | ||
| 368 | + grid-column: auto; | ||
| 369 | + min-height: 0; | ||
| 370 | + overflow-y: auto; | ||
| 371 | + } | ||
| 277 | } | 372 | } |
| 278 | } | 373 | } |
| 279 | 374 | ||
style/main.scssmodified+26 -0
| @@ -5343,6 +5343,32 @@ $ansi-colours: ( | |||
| 5343 | border-top: 1px solid var(--border); | 5343 | border-top: 1px solid var(--border); |
| 5344 | } | 5344 | } |
| 5345 | 5345 | ||
| 5346 | +// A runner's whole row opens its page: the name's link stretches over the row, and the controls | ||
| 5347 | +// in it (the concurrency stepper, the actions menu) sit above that link so they still work. The | ||
| 5348 | +// row reaches 12px past the list on each side, so its hover background does not touch the text. | ||
| 5349 | +.runner-row.is-linked { | ||
| 5350 | + position: relative; | ||
| 5351 | + margin: 0 -12px; | ||
| 5352 | + padding-inline: 12px; | ||
| 5353 | + border-radius: var(--radius-sm); | ||
| 5354 | + | ||
| 5355 | + &:hover { | ||
| 5356 | + background: var(--surface-2); | ||
| 5357 | + } | ||
| 5358 | + | ||
| 5359 | + .runner-name::after { | ||
| 5360 | + content: ""; | ||
| 5361 | + position: absolute; | ||
| 5362 | + inset: 0; | ||
| 5363 | + } | ||
| 5364 | + | ||
| 5365 | + > .runner-load, | ||
| 5366 | + > .row-menu { | ||
| 5367 | + position: relative; | ||
| 5368 | + z-index: 1; | ||
| 5369 | + } | ||
| 5370 | +} | ||
| 5371 | + | ||
| 5346 | .runner-id, | 5372 | .runner-id, |
| 5347 | .runner-load, | 5373 | .runner-load, |
| 5348 | .runner-version { | 5374 | .runner-version { |