diff --git a/crates/forge-web-base/src/i18n/misc.rs b/crates/forge-web-base/src/i18n/misc.rs index e1d4efc..f251d73 100644 --- a/crates/forge-web-base/src/i18n/misc.rs +++ b/crates/forge-web-base/src/i18n/misc.rs @@ -146,7 +146,6 @@ pub enum K { YourCiRuns, SearchPublicReposFor, // The bell's popover: the newest notifications, opened from the profile corner. - AllCaughtUp, } /// Every variant, for the coverage test below. @@ -270,7 +269,6 @@ const ALL: &[K] = &[ K::Cancelled, K::YourCiRuns, K::SearchPublicReposFor, - K::AllCaughtUp, ]; pub fn t(lang: Lang, key: K) -> &'static str { @@ -523,8 +521,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { (Cancelled, Tr) => "iptal edildi", (YourCiRuns, En) => "Your CI runs", (YourCiRuns, Tr) => "CI çalıştırmaların", - (AllCaughtUp, En) => "You're all caught up", - (AllCaughtUp, Tr) => "Hepsini gördünüz", (SearchPublicReposFor, En) => "Search public repositories for", (SearchPublicReposFor, Tr) => "Herkese açık depolarda ara:", } diff --git a/crates/forge-web-base/src/i18n/releases_ci.rs b/crates/forge-web-base/src/i18n/releases_ci.rs index a41fe92..c23b1a0 100644 --- a/crates/forge-web-base/src/i18n/releases_ci.rs +++ b/crates/forge-web-base/src/i18n/releases_ci.rs @@ -58,7 +58,6 @@ pub enum K { Exit, Log, FullLog, - CopyLog, CopyDone, CopyFailed, Duration, @@ -218,10 +217,10 @@ pub fn t(lang: Lang, key: K) -> &'static str { (LogNext, Tr) => "Sonraki eşleşme", (LogNoMatches, En) => "No matches", (LogNoMatches, Tr) => "Eşleşme yok", - (LogCollapseAll, En) => "Collapse groups", - (LogCollapseAll, Tr) => "Grupları daralt", - (LogExpandAll, En) => "Expand groups", - (LogExpandAll, Tr) => "Grupları genişlet", + (LogCollapseAll, En) => "Collapse all", + (LogCollapseAll, Tr) => "Hepsini daralt", + (LogExpandAll, En) => "Expand all", + (LogExpandAll, Tr) => "Hepsini genişlet", (Rerun, En) => "Re-run", (Rerun, Tr) => "Yeniden çalıştır", (Runs, En) => "Runs", @@ -254,10 +253,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { (Exit, Tr) => "çıkış", (Log, En) => "Log", (Log, Tr) => "Günlük", - (FullLog, En) => "Full log (log.txt)", - (FullLog, Tr) => "Tam günlük (log.txt)", - (CopyLog, En) => "Copy log", - (CopyLog, Tr) => "Günlüğü kopyala", + (FullLog, En) => "Full log", + (FullLog, Tr) => "Tam günlük", (CopyDone, En) => "Copied", (CopyDone, Tr) => "Kopyalandı", (CopyFailed, En) => "Copy failed", @@ -572,7 +569,6 @@ mod tests { K::Exit, K::Log, K::FullLog, - K::CopyLog, K::CopyDone, K::CopyFailed, K::Duration, diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index 68cd0b5..8045d42 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -2549,11 +2549,24 @@ if (el.hasAttribute('data-log-prev')) { logGo(pre, pre._ci.hit - 1, true); } else if (el.hasAttribute('data-log-next')) { logGo(pre, pre._ci.hit + 1, true); } else { - var open = el.getAttribute('data-log-fold') === 'open'; - Array.prototype.forEach.call(pre.querySelectorAll('details.lg'), function (d) { d.open = open; }); + var groups = pre.querySelectorAll('details.lg'); + var open = !Array.prototype.some.call(groups, function (d) { return d.open; }); + Array.prototype.forEach.call(groups, function (d) { d.open = open; }); } }, true); + function logFoldLabel() { + var btn = document.querySelector('[data-log-fold="toggle"]'); + var pre = document.querySelector('[data-live-log]'); + if (!btn || !pre) { return; } + var any = Array.prototype.some.call(pre.querySelectorAll('details.lg'), function (d) { return d.open; }); + btn.textContent = btn.getAttribute(any ? 'data-collapse' : 'data-expand'); + } + + document.addEventListener('toggle', function (e) { + if (e.target && e.target.matches && e.target.matches('details.lg')) { logFoldLabel(); } + }, true); + window.addEventListener('hashchange', function () { if (/^#L\d+$/.test(location.hash)) { logSelect(location.hash.slice(1), true); } }); @@ -5172,8 +5185,6 @@ } }, true); - // "Copy log": fetches the job's log.txt once and puts the whole text on the clipboard. The button is - // disabled meanwhile, so a big log is not fetched twice; its label shows the outcome, then returns. function copyText(text) { if (navigator.clipboard && navigator.clipboard.writeText) { return navigator.clipboard.writeText(text); @@ -5192,21 +5203,6 @@ }); } - function copyLog(btn) { - if (btn.disabled) { return; } - var label = btn.getAttribute('data-label') || btn.textContent; - btn.setAttribute('data-label', label); - btn.disabled = true; - var done = function (ok) { - btn.textContent = btn.getAttribute(ok ? 'data-copied' : 'data-failed') || label; - setTimeout(function () { btn.textContent = label; btn.disabled = false; }, 1500); - }; - fetch(btn.getAttribute('data-copy-log'), { credentials: 'include' }) - .then(function (r) { if (!r.ok) { throw new Error('fetch'); } return r.text(); }) - .then(function (text) { return copyText(text.replace(/\u001b\[[0-9;?]*[ -\/]*[@-~]/g, '')); }) - .then(function () { done(true); }, function () { done(false); }); - } - // Selects an element's text, so the reader can copy it by hand (a long press on a phone). function selectText(el) { var range = document.createRange(); @@ -5234,11 +5230,6 @@ copyText(text.trim()).then(function () { done(true); }, function () { selectText(src); done(false); }); }, false); - document.addEventListener('click', function (e) { - var btn = e.target && e.target.closest ? e.target.closest('[data-copy-log]') : null; - if (btn) { e.preventDefault(); copyLog(btn); } - }, false); - // ---- branch switcher ------------------------------------------------------------------------ // The ref popover in the browse bar: one filter over a Branches and a Tags section, the matched // part of each name marked, and arrow keys (or the pointer) through the visible entries as in the diff --git a/crates/forge-web/src/pages/ci_job.rs b/crates/forge-web/src/pages/ci_job.rs index 6c18e2b..28d0046 100644 --- a/crates/forge-web/src/pages/ci_job.rs +++ b/crates/forge-web/src/pages/ci_job.rs @@ -484,11 +484,9 @@ async fn job_body( - (g::t(lang, K::FullLog)) diff --git a/crates/forge-web/src/pages/ci_runs.rs b/crates/forge-web/src/pages/ci_runs.rs index bd7843e..2702774 100644 --- a/crates/forge-web/src/pages/ci_runs.rs +++ b/crates/forge-web/src/pages/ci_runs.rs @@ -560,8 +560,6 @@ struct JobLog { log_href: String, /// The job's event stream (plain lines) while the job is not finished; None once it is. live: Option, - /// The POST target that runs this job again, for a writer once the job has finished. - rerun: Option, text: String, truncated: bool, offset: String, @@ -2048,7 +2046,6 @@ async fn run_detail( log_href: format!("{href}/log.txt"), live: (!job.state.is_terminal()).then(|| format!("{href}/events?plain=1")), href, - rerun: lines[index].rerun.clone(), // Line for line, so line numbers and the byte offset of the stream still match. text: text .split('\n') @@ -2411,8 +2408,6 @@ async fn run_timeline(lang: Lang, run: &RunDetail) -> Result { } else if !job.preview.is_empty() {

@@ -2576,7 +2571,12 @@ async fn run_artifacts(lang: Lang, run: &RunDetail) -> Result { Ok(view! { if !run.artifacts.is_empty() {

-

(g::t(lang, K::Artifacts))

+
+

(g::t(lang, K::Artifacts))

+ if let Some(href) = run.zip_href.as_ref() { + (g::t(lang, K::DownloadAll)) + } +
for artifact in run.artifacts.iter() {
(artifact.name.as_str()) @@ -2625,20 +2625,9 @@ async fn run_log( - (g::t(lang, K::FullLog)) - if let Some(href) = run.zip_href.as_ref() { - (g::t(lang, K::DownloadAll)) - } - if let (Some(action), Some(csrf)) = (log.rerun.as_ref(), run.writer_csrf.as_ref()) { -
- - -
- }
} diff --git a/crates/forge-web/src/pages/notifications.rs b/crates/forge-web/src/pages/notifications.rs index 43e6aa5..ccfd841 100644 --- a/crates/forge-web/src/pages/notifications.rs +++ b/crates/forge-web/src/pages/notifications.rs @@ -19,9 +19,9 @@ use topcoat::context::{Cx, app_context}; use topcoat::router::content::Form; use topcoat::router::content::sse::Event; use topcoat::router::error::{SeeOther, bad_request, not_found, see_other}; -use topcoat::router::response::{IntoResponse, Response}; +use topcoat::router::response::Response; use topcoat::router::{Body, StatusCode, page, path_param, query_params, route}; -use topcoat::view::{View, ViewExt, component, view}; +use topcoat::view::{View, component, view}; use crate::auth::{current_user, percent_encode, require_csrf, require_user}; use crate::i18n::alerts as alert_text; @@ -52,9 +52,6 @@ path_param!(admin_note); /// The pseudo repo id of the admin alerts group in the inbox. const ADMIN_GROUP: &str = "admin"; -/// Rows in the bell's popover. -const PEEK_SIZE: u32 = 8; - #[query_params(error = bad_request)] struct InboxQuery { all: Option, @@ -320,76 +317,6 @@ async fn entry_visible( && (!matches!(entry, Entry::Advisory(_)) || can_manage_alerts(state, user, repo_id).await?)) } - -/// The newest entries of each list the inbox reads, unread ones only or all of them, at most -/// `limit` from each list. -async fn list_entries( - state: &AppState, - user: &User, - unread_only: bool, - limit: u32, -) -> Result> { - let mut entries: Vec = state - .store - .list_notifications(&user.id, unread_only, None, limit) - .await? - .into_iter() - .map(Entry::Issue) - .collect(); - entries.extend( - state - .store - .list_discussion_notifications(&user.id, unread_only, None, limit) - .await? - .into_iter() - .map(Entry::Discussion), - ); - entries.extend( - state - .store - .list_advisory_notifications(&user.id, unread_only, None, limit) - .await? - .into_iter() - .map(Entry::Advisory), - ); - if user.is_admin { - entries.extend( - state - .store - .list_admin_notices(&user.id, unread_only, None, limit) - .await? - .into_iter() - .map(Entry::Admin), - ); - } - Ok(entries) -} - -/// The bell's popover rows: the viewer's newest unread entries, newest first. Read entries are -/// left out, and so are entries the viewer can no longer read. -async fn peek_rows(state: &AppState, user: &User, lang: Lang, now: i64) -> Result> { - let tz = user.timezone.clone(); - let mut entries = list_entries(state, user, true, PEEK_SIZE).await?; - entries.sort_by(|a, b| b.updated_at().cmp(a.updated_at())); - let mut readable = HashMap::new(); - let mut rows = Vec::new(); - for entry in &entries { - if rows.len() == PEEK_SIZE as usize { - break; - } - if !entry_visible(state, user, &mut readable, entry).await? { - continue; - } - rows.push(match entry { - Entry::Issue(note) => issue_row(lang, note, &tz, now), - Entry::Discussion(note) => discussion_row(lang, note, &tz, now), - Entry::Advisory(note) => advisory_row(lang, note, &tz, now), - Entry::Admin(note) => admin_row(lang, note, &tz, now), - }); - } - Ok(rows) -} - #[page("/notifications")] async fn inbox(cx: &Cx) -> Result { let viewer = require_user(cx).await?; @@ -547,50 +474,6 @@ async fn inbox(cx: &Cx) -> Result { }) } -/// `GET /notifications/peek`: the bell's popover, the viewer's newest unread notifications as an HTML -/// fragment. Anonymous viewers get a bare 401. -#[route(GET "/notifications/peek")] -async fn peek(cx: &Cx) -> Result { - let Some((user, _)) = current_user(cx).await? else { - let mut res = Response::new(Body::empty()); - *res.status_mut() = StatusCode::UNAUTHORIZED; - return Ok(res); - }; - let state = app_context::(cx); - let lang = i18n::lang(cx, Some(&user)); - let rows = peek_rows(state, &user, lang, now_unix()).await?; - let fragment = view! { peek_list(lang: lang, rows: rows) }; - fragment.first().await?.into_response(cx) -} - -/// The bell's popover list of unread rows: each row opens through its open route, which marks it -/// read. An empty list says the viewer is all caught up. -#[component] -async fn peek_list(lang: Lang, rows: Vec) -> Result { - let empty = rows.is_empty(); - Ok(view! { - if empty { -

(g::t(lang, K::AllCaughtUp))

- } - - }) -} - /// The URL of the inbox's live stream for the tab the viewer is on. fn inbox_live_url(all: bool) -> String { if all { diff --git a/scripts/audit/measure.ts b/scripts/audit/measure.ts index ef9c042..6996d63 100644 --- a/scripts/audit/measure.ts +++ b/scripts/audit/measure.ts @@ -143,7 +143,7 @@ const DESIGN = `(() => { const tag = e.tagName; const isText = tag === 'INPUT' && !['checkbox','radio','color','file','range','hidden'].includes(e.type); const isBtn = tag === 'BUTTON' || (tag === 'INPUT' && ['submit','button'].includes(e.type)) || e.matches('summary.button, a.button, summary.act, a.act'); - if (isBtn && !e.closest('.heat-grid, .corner-theme-set, .choice, .swatches, .colour-grid') && !e.matches('.icon-btn, .rail-item, .line, .corner-link, .swatch')) { + if (isBtn && !e.closest('.heat-grid, .choice, .swatches, .colour-grid') && !e.matches('.icon-btn, .rail-item, .line, .corner-link, .swatch')) { if (!CONTROLS.some(([h, r, fs]) => p.h === h && p.r === r && p.fs === fs)) bad.push('control shape ' + p.h + '/' + p.r + '/' + p.fs + ': ' + label); } if (isText || tag === 'SELECT') { @@ -167,7 +167,7 @@ const DESIGN = `(() => { const sides = [c.borderTopWidth, c.borderRightWidth, c.borderBottomWidth, c.borderLeftWidth].filter((v) => parseFloat(v) > 0).length; if (sides === 4 && !e.closest('table') && !e.matches('input[type=checkbox], input[type=radio]')) bad.push('box border: ' + label); if (parseFloat(c.borderLeftWidth) >= 2 && sides === 1) bad.push('side stripe: ' + label); - if (c.boxShadow !== 'none' && /\\) -?\\d+px -?\\d+px [1-9]\\d*px/.test(c.boxShadow) && !e.matches('.corner-menu, .menu-list, .pop-panel, .ref-menu, .row-menu-panel, .tab-more-list, .strip-list, .bell-box, .palette-box, .decide, .decide-panel, .status-list, .ci-pop')) bad.push('shadow: ' + label); + if (c.boxShadow !== 'none' && /\\) -?\\d+px -?\\d+px [1-9]\\d*px/.test(c.boxShadow) && !e.matches('.corner-menu, .menu-list, .pop-panel, .ref-menu, .row-menu-panel, .tab-more-list, .strip-list, .palette-box, .decide, .decide-panel, .status-list, .ci-pop')) bad.push('shadow: ' + label); } // A form's submit and its Cancel are one row: neither sits alone as a child of the fields. for (const e of root.querySelectorAll('.fields > a.act, .fields > button.act')) { diff --git a/style/_one_ci.scss b/style/_one_ci.scss index 2d921b9..542568b 100644 --- a/style/_one_ci.scss +++ b/style/_one_ci.scss @@ -285,6 +285,15 @@ main:has(> .ci-job) > .sheet { display: none; } +// The count and the match arrows show only while the log search has text. +.ci-tl-tools:has(input:placeholder-shown) { + .ci-logcount, + [data-log-prev], + [data-log-next] { + display: none; + } +} + // The timeline tab: its parts keep their own heights in the scrolling panel (the chart had shrunk to // nothing), start on the sheet's inset, and every action sits on the left with the rest. .ci-tl-panel-timeline { diff --git a/style/main.scss b/style/main.scss index 4671386..cddc352 100644 --- a/style/main.scss +++ b/style/main.scss @@ -3679,14 +3679,6 @@ span.reaction { // Notifications: the header bell, the inbox, the sidebar box and the watch control. -.bell { - display: inline-flex; - align-items: center; - gap: 0.35rem; - color: var(--text); - text-decoration: none; -} - .bell-count { display: inline-block; min-width: 1.4rem; @@ -5383,10 +5375,6 @@ button.ci-job-last { } } -.ci-job-copy { - margin: 6px 0 0 8px; -} - .ci-job-full { display: inline-block; margin-top: 6px;