From 1e336175d33506ee971267bd61062c860044d0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 1 Nov 2026 08:11:25 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20pages=20now=20match=20t?= =?UTF-8?q?he=20approved=20design=20measure=20for=20measure:=20shell,=20pa?= =?UTF-8?q?nes,=20rows,=20labels=20and=20spacing=20across=20every=20page?= =?UTF-8?q?=20in=20dark=20and=20light,=20branch=20protection=20is=20a=20ru?= =?UTF-8?q?le=20list=20beside=20an=20editor,=20labels=20are=20one=20line?= =?UTF-8?q?=20each=20with=20Delete=20inside=20Edit,=20server=20settings=20?= =?UTF-8?q?use=20the=20full=20width,=20and=20pages=20keep=20clear=20of=20t?= =?UTF-8?q?he=20profile=20corner;=20=E2=9C=A8=20feat:=20drag=20along=20the?= =?UTF-8?q?=20commit=20strip=20to=20preview=20the=20tree=20at=20an=20older?= =?UTF-8?q?=20commit,=20Back=20to=20latest=20or=20Escape=20returns;=20repo?= =?UTF-8?q?sitory=20tabs=20that=20do=20not=20fit=20move=20to=20a=20menu;?= =?UTF-8?q?=20issue=20and=20pull=20sidebars=20apply=20labels=20through=20t?= =?UTF-8?q?he=20server=20and=20show=20them=20pending=20until=20it=20answer?= =?UTF-8?q?s;=20the=20repo=20bar=20shows=20the=20commit's=20author=20pictu?= =?UTF-8?q?re=20and=20opens=20the=20full=20message;=20=F0=9F=90=9B=20fix:?= =?UTF-8?q?=20changing=20an=20issue's=20labels=20saved=20the=20opposite=20?= =?UTF-8?q?of=20what=20was=20picked;=20the=20commit=20strip's=20drag=20nev?= =?UTF-8?q?er=20started;=20repo=20owners=20see=20Delete=20again;=20?= =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20page=20transitions=20and=20the?= =?UTF-8?q?=20row=20morph=20are=20removed,=20as=20is=20the=20dead=20CSS=20?= =?UTF-8?q?and=20code=20they=20left?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-web/assets/nav.js | 554 +++++++++++++-- crates/forge-web/src/i18n/code.rs | 20 - crates/forge-web/src/pages/admin_server.rs | 4 +- crates/forge-web/src/pages/blame.rs | 8 +- crates/forge-web/src/pages/ci_job.rs | 82 ++- crates/forge-web/src/pages/ci_runs.rs | 430 +++++------- crates/forge-web/src/pages/commit.rs | 75 +- crates/forge-web/src/pages/commits.rs | 168 +++-- .../src/pages/discussion_settings.rs | 4 +- crates/forge-web/src/pages/explore.rs | 20 +- crates/forge-web/src/pages/finder.rs | 2 +- crates/forge-web/src/pages/issue_parts.rs | 22 +- crates/forge-web/src/pages/issues_list.rs | 18 +- crates/forge-web/src/pages/labels_page.rs | 34 +- crates/forge-web/src/pages/mod.rs | 1 + crates/forge-web/src/pages/profile.rs | 11 +- crates/forge-web/src/pages/pull_files.rs | 391 ++++++++--- crates/forge-web/src/pages/pull_view.rs | 41 +- crates/forge-web/src/pages/pulls_list.rs | 7 +- crates/forge-web/src/pages/refs.rs | 3 + crates/forge-web/src/pages/releases.rs | 28 +- crates/forge-web/src/pages/repo.rs | 129 ++-- .../forge-web/src/pages/repo_collaborators.rs | 3 +- crates/forge-web/src/pages/repo_ctx.rs | 3 + crates/forge-web/src/pages/repo_mirrors.rs | 3 +- crates/forge-web/src/pages/repo_rename.rs | 2 +- crates/forge-web/src/pages/repo_scrub.rs | 248 +++++++ crates/forge-web/src/pages/repo_secrets.rs | 3 +- crates/forge-web/src/pages/repo_settings.rs | 153 ++-- crates/forge-web/src/pages/repo_side.rs | 50 +- crates/forge-web/src/pages/repo_webhooks.rs | 3 +- .../forge-web/src/pages/settings_sessions.rs | 2 +- crates/forge-web/src/pages/snippets.rs | 6 +- crates/forge-web/src/pages/tree.rs | 302 ++++---- crates/forge-web/src/pages/wiki.rs | 1 + crates/forge-web/src/render/commit_message.rs | 6 - crates/forge-web/src/views/commit_line.rs | 33 +- crates/forge-web/src/views/heatmap.rs | 17 +- crates/forge-web/src/views/mod.rs | 109 ++- crates/forge-web/src/views/repo_list.rs | 12 +- crates/forge-web/src/views/timeline.rs | 4 +- crates/forge-web/tests/e2e/browse_e2e.rs | 28 +- .../forge-web/tests/e2e/repo_settings_e2e.rs | 67 +- style/_alive_head.scss | 99 +++ style/_alive_heat.scss | 61 ++ style/_alive_issue.scss | 8 + style/_alive_lists.scss | 88 +++ style/_alive_motion.scss | 92 +++ style/_alive_scrub.scss | 61 ++ style/_alive_settings.scss | 245 +++++++ style/_canvas.scss | 109 +++ style/_canvas_account.scss | 140 ++++ style/_canvas_ci.scss | 110 +++ style/_canvas_commits.scss | 272 +++++++ style/_canvas_detail.scss | 308 ++++++++ style/_canvas_lists.scss | 523 ++++++++++++++ style/_canvas_pull.scss | 402 +++++++++++ style/_canvas_repo.scss | 661 ++++++++++++++++++ style/_commit_line.scss | 17 +- style/_commit_page.scss | 15 +- style/_continuity.scss | 77 -- style/_fit_admin.scss | 9 +- style/_fit_settings.scss | 17 - style/_fit_tables.scss | 7 - style/_lang_admin.scss | 54 +- style/_lang_ci.scss | 4 +- style/_lang_lists.scss | 3 +- style/_look.scss | 6 +- style/_repo.scss | 236 +------ style/_shell.scss | 4 +- style/_timeline.scss | 145 +--- style/_timeline_ci.scss | 454 ++++++++---- style/main.scss | 24 +- 73 files changed, 5716 insertions(+), 1642 deletions(-) create mode 100644 crates/forge-web/src/pages/repo_scrub.rs create mode 100644 style/_alive_head.scss create mode 100644 style/_alive_heat.scss create mode 100644 style/_alive_issue.scss create mode 100644 style/_alive_lists.scss create mode 100644 style/_alive_motion.scss create mode 100644 style/_alive_scrub.scss create mode 100644 style/_alive_settings.scss create mode 100644 style/_canvas.scss create mode 100644 style/_canvas_account.scss create mode 100644 style/_canvas_ci.scss create mode 100644 style/_canvas_commits.scss create mode 100644 style/_canvas_detail.scss create mode 100644 style/_canvas_lists.scss create mode 100644 style/_canvas_pull.scss create mode 100644 style/_canvas_repo.scss delete mode 100644 style/_continuity.scss diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index d764045..41735be 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -352,67 +352,6 @@ else { window.scrollTo(0, 0); } } - // Continuity: every navigation (a link, back or forward) is one calm View Transition. The top bar and - // the repo head stay still, the active tab slides to its new place, and the page body fades in. A link - // from a row also grows into the title of the page it opens: the row takes the name forge-row once the - // response has arrived, the new page's title takes it in the transition's update callback, where the - // swap runs. Names are on only for the transition: `html.is-navigating` in _continuity.scss, and the - // row's and title's own names are removed when it ends, since a duplicate name aborts a transition. - // Without the API or with reduced motion the swap runs as it always has. Live refreshes and form - // posts never animate. - var MORPH_NAME = 'forge-row'; - - // The title a row grows into, by page: commit, issue and pull, CI run and job, a repo's title row, - // and the active tab for the Code tab, which has no title row. Most specific first: the first of - // these that is visible wins, not the first in the page, where the repo's title and tabs come first. - var TITLE_SELECTORS = ['.commit-summary-title', '.issue-heading', '.ci-tl-title', '.ci-job-title', '.repo-title', '.repo-tabs .tab.active']; - - function pageTitle() { - for (var i = 0; i < TITLE_SELECTORS.length; i++) { - var el = document.querySelector(TITLE_SELECTORS[i]); - var box = el ? el.getBoundingClientRect() : null; - if (box && box.width > 0 && box.height > 0) { return el; } - } - return null; - } - - function morph(row, run) { - if (!document.startViewTransition || motionHeld()) { run(); return undefined; } - var root = document.documentElement; - root.classList.add('is-navigating'); - if (row) { row.style.viewTransitionName = MORPH_NAME; } - return new Promise(function (resolve, reject) { - var ran = false; - var title = null; - function update() { - if (ran) { return; } - ran = true; - // The old row leaves the page now, so its name goes with it. - if (row) { row.style.viewTransitionName = ''; } - try { run(); } catch (err) { reject(err); return; } - title = row ? pageTitle() : null; - if (title) { title.style.viewTransitionName = MORPH_NAME; } - resolve(); - } - var transition; - try { - transition = document.startViewTransition(update); - } catch (err) { - update(); - return; - } - // A skipped transition may never call its callback: the swap then runs here instead. - transition.ready.catch(function () { }); - transition.updateCallbackDone.then(update, update); - var done = function () { - root.classList.remove('is-navigating'); - if (row) { row.style.viewTransitionName = ''; } - if (title) { title.style.viewTransitionName = ''; } - }; - transition.finished.then(done, done); - }); - } - // A live change keeps the reader's place in a diff. Before the swap: the first element marked // data-keep-anchor (a diff file, keyed by its path) that is still at least partly in view, and // its offset from the top of the view. After the swap: the same key, moved so it sits at that @@ -566,8 +505,6 @@ // Other parts of this file follow page changes through this event (list memory, say). document.dispatchEvent(new CustomEvent('forge:swapped', { detail: { how: how, url: dest } })); }; - // A navigation swaps inside its transition, and the load counts as done only after it. - if (how === 'nav' || how === 'pop') { return morph(o.morph, finish); } finish(); }).catch(function () { if (mark !== latest || o.how === 'live') { return; } @@ -829,7 +766,7 @@ // Dropdown menus: the
that float over the page (avatar menu, branch selector, clone // popover, section menu, profile corner). Inline disclosures are not listed: a click outside leaves them open. - var DROPDOWN = 'details.menu, details.ref-select, details.clone, details.nav-toggle, details.corner, details.strip-runs'; + var DROPDOWN = 'details.menu, details.ref-select, details.clone, details.nav-toggle, details.corner, details.strip-runs, details.dock-expand'; // Closes every open dropdown that does not contain `from` (pass null to close them all). A click // inside the floating corner keeps its own menu open. @@ -1599,9 +1536,7 @@ return; } saveScroll(); - // The row the link sits in, if any: the page it opens grows out of that row (see morph). - var row = a.closest('nav, .repo-tabs, .pathbar, .topbar') ? null : a.closest('[data-kb-row], tbody tr, ul > li'); - load({ target: withoutHash(url), dest: url, init: GET_INIT, how: 'nav', keep: false, post: false, form: null, morph: row }); + load({ target: withoutHash(url), dest: url, init: GET_INIT, how: 'nav', keep: false, post: false, form: null }); }, true); document.addEventListener('submit', function (e) { @@ -3315,6 +3250,9 @@ load({ target: withoutHash(here), dest: here, init: GET_INIT, how: 'live', keep: true, post: false, form: null }); } + // The timeline scrub (its own section below) ends its preview by asking for the page again here. + document.addEventListener('forge:refresh', function () { refreshLive(true); }); + // A code view whose path is gone at the new ref keeps its page and shows one inline notice. function showGone() { var bar = document.querySelector('[data-live-code]'); @@ -3384,6 +3322,7 @@ function relUpdate() { relTimer = null; + heatApply(); // heat as age: rows cool as the ticker runs (see heatApply below) var words = (document.documentElement.getAttribute('data-rel-words') || '').split('|'); if (words.length < 21) { return; } // no wording from the server: nothing to re-word var nowSec = (Date.now() + relSkew) / 1000; @@ -4488,6 +4427,85 @@ openPalette(); }); + // ---- issue sidebar: labels, milestone and assignees apply on their own ---- + // A form marked data-apply has no Save button for scripts (its button sits in a noscript). Nothing + // shows as done here: the post goes through the soft path and the answer swaps the sidebar in place. + // Until then the part being sent is dimmed (is-pending) and the form takes no further input. + // A failed post clears that state and restores the controls to the page's own values. + function applyPost(form, data, marked) { + if (pending.has(form)) { return; } + var url = pageUrl(form.getAttribute('action') || location.href); + if (!url) { return; } + pending.add(form); + if (marked) { marked.classList.add('is-pending'); } + saveScroll(); + load({ + target: withoutHash(url), + dest: url, + init: { method: 'POST', headers: { accept: 'text/html' }, body: new URLSearchParams(data) }, + how: 'post', + keep: true, + post: true, + form: form, + submitter: null + }); + } + + function applyForm(el) { + return el && el.form && el.form.hasAttribute('data-apply') ? el.form : null; + } + + // A label checkbox. The browser flips a box before its click event and flips it back after + // preventDefault, so a FormData read here holds the set the reader asked for, and the box shows + // the old state until the server's answer swaps the sidebar. + document.addEventListener('click', function (e) { + var box = e.target && e.target.closest ? e.target.closest('form[data-apply] input[type="checkbox"]') : null; + if (!box) { return; } + e.preventDefault(); + var form = box.form; + if (pending.has(form)) { return; } + applyPost(form, new FormData(form), box.closest('label')); + }, false); + + // Milestone: one choice posts. The select is disabled while it is on the wire, so it is read first. + // Assignees: the text posts on blur after an edit, and on Enter. + document.addEventListener('change', function (e) { + var form = applyForm(e.target); + if (!form || e.target.tagName !== 'SELECT') { + if (form && e.target.type === 'text') { applyPost(form, new FormData(form), e.target.closest('.issue-side-section')); } + return; + } + if (pending.has(form)) { return; } + var data = new FormData(form); + var section = e.target.closest('.issue-side-section'); + e.target.disabled = true; + applyPost(form, data, section); + if (!pending.has(form)) { e.target.disabled = false; } + }, false); + + document.addEventListener('keydown', function (e) { + if (e.key !== 'Enter' || !e.target || e.target.type !== 'text') { return; } + var form = applyForm(e.target); + if (!form) { return; } + e.preventDefault(); + applyPost(form, new FormData(form), e.target.closest('.issue-side-section')); + }, false); + + // Any answer that is not a redirect to the page (a refusal, an outage): the sidebar shows its own + // values again. A success swapped the form out already, so this only touches what is still shown. + document.addEventListener('forge:submitted', function (e) { + var form = e.detail ? e.detail.form : null; + if (!form || !form.hasAttribute || !form.hasAttribute('data-apply') || e.detail.ok) { return; } + var section = form.closest('.issue-side-section'); + if (section) { section.classList.remove('is-pending'); } + Array.prototype.forEach.call(form.querySelectorAll('.is-pending'), function (n) { n.classList.remove('is-pending'); }); + Array.prototype.forEach.call(form.querySelectorAll('select'), function (s) { + s.disabled = false; + Array.prototype.forEach.call(s.options, function (o) { o.selected = o.defaultSelected; }); + }); + Array.prototype.forEach.call(form.querySelectorAll('input[type="text"]'), function (i) { i.value = i.defaultValue; }); + }); + // Every relative time shows its exact moment on hover, in the reader's own time zone and language, // so one format holds across the site whatever title the server wrote. var relFormat = null, relLang = null; @@ -4507,6 +4525,298 @@ if (el.getAttribute('title') !== exact) { el.setAttribute('title', exact); } }); } + + // Heat as age (memory design/ALIVE.md). A row in a list (tree table, commit list, repo list, + // pinned cards) gets data-heat from the newest time[data-rel] inside it: 3 under an hour, 2 under + // a day, 1 under a week, and no attribute when older. It runs on load, after a swap, and from + // relUpdate (the ticker), so rows cool while the page is open. It sets attributes only. + function heatLevel(row, nowSec) { + var newest = NaN; + Array.prototype.forEach.call(row.querySelectorAll('time[data-rel][datetime]'), function (el) { + var at = Date.parse(el.getAttribute('datetime') || ''); + if (!isNaN(at) && (isNaN(newest) || at > newest)) { newest = at; } + }); + if (isNaN(newest)) { return 0; } + var age = nowSec - newest / 1000; + if (age < 3600) { return 3; } + if (age < 86400) { return 2; } + if (age < 604800) { return 1; } + return 0; + } + + function heatApply() { + var nowSec = (Date.now() + relSkew) / 1000; + Array.prototype.forEach.call(document.querySelectorAll('.repo-main tbody tr, [data-kb-row], .repo-item, .pin-card'), function (row) { + var listed = row.matches('.repo-main tbody tr, .repo-item, .pin-card') || !!row.querySelector('.commit-summary'); + if (!listed) { return; } + var level = heatLevel(row, nowSec); + if (level) { + if (row.getAttribute('data-heat') !== String(level)) { row.setAttribute('data-heat', String(level)); } + } else if (row.hasAttribute('data-heat')) { + row.removeAttribute('data-heat'); + } + }); + } + + document.addEventListener('forge:swapped', heatApply); + if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', heatApply); } else { heatApply(); } +})(); + +// Timeline scrub: dragging across the repo home's commit strip previews the root listing and README at +// that commit. A press that moves more than 4px is a scrub; a plain click still follows the bar's link, +// and the click that ends a real drag is swallowed. A bar change waits 80ms, and each request aborts the +// one before, so only the newest answer is shown. The answer's two wrappers are copied into the page +// with replaceChildren, never innerHTML. The dock note says which commit is shown. Back to latest, +// Escape, a live swap or any navigation ends the preview; Back to latest and Escape also ask the server +// for the page again (forge:refresh), so the page is the truth. A failed request keeps the screen as it is. +(function () { + 'use strict'; + if (window.__forgeScrub) { return; } + window.__forgeScrub = true; + + var DRAG_PX = 4; + var SETTLE_MS = 80; + var TEXT = { + en: { back: 'Back to latest', note: 'Not the latest commit' }, + tr: { back: 'Son haline dön', note: 'En son commit değil' } + }; + + var drag = null; // the press in progress: { strip, id, x, y, on, bar } + var swallow = 0; // until this time the click that ends a real drag is swallowed + var timer = null; // the settle timer before the next request + var ctrl = null; // the AbortController of the request on the wire + var active = false; // a preview is on screen + var note = null; // the dock note while a preview is on screen + + function lang() { + return (document.documentElement.getAttribute('lang') || '').toLowerCase().indexOf('tr') === 0 ? 'tr' : 'en'; + } + + function each(list, fn) { Array.prototype.forEach.call(list, fn); } + + function barsOf(strip) { return Array.prototype.slice.call(strip.querySelectorAll('.hs-bar')); } + + function stripOf(el) { return el && el.closest ? el.closest('.history-bars') : null; } + + // The scrub is for the repo home only: its listing and README are the panes a preview replaces. + function listing() { return document.querySelector('.repo-home > .repo-main > .table-wrap'); } + function readmePane() { return document.querySelector('.repo-home > .repo-readme > .canvas-body'); } + + // The bar whose span holds x, else the nearest one. Works while the pointer is captured. + function barAt(strip, x) { + var best = null; + var dist = Infinity; + var bars = barsOf(strip); + for (var i = 0; i < bars.length; i++) { + var box = bars[i].getBoundingClientRect(); + if (x >= box.left && x <= box.right) { return bars[i]; } + var d = x < box.left ? box.left - x : x - box.right; + if (d < dist) { dist = d; best = bars[i]; } + } + return best; + } + + function unmarkBars() { + each(document.querySelectorAll('.history-bars .hs-bar.is-scrubbed'), function (b) { b.classList.remove('is-scrubbed'); }); + } + + function clearMarks() { + each(document.querySelectorAll('.history-bars.is-scrubbing'), function (s) { s.classList.remove('is-scrubbing'); }); + unmarkBars(); + } + + // The bar in the pointer's or the keys' place gets the mark at once; its request waits for the settle. + function pick(bar) { + unmarkBars(); + bar.classList.add('is-scrubbed'); + clearTimeout(timer); + timer = setTimeout(function () { timer = null; fetchBar(bar); }, SETTLE_MS); + } + + // The request for a bar's commit: /{owner}/{repo}/scrub/{oid}, from the bar's commit link. + function scrubUrl(bar) { + var href = bar.getAttribute('href') || ''; + var at = href.indexOf('/commit/'); + var oid = bar.getAttribute('data-oid') || ''; + if (at < 0 || !/^[0-9a-f]{40}$/.test(oid)) { return null; } + return href.slice(0, at) + '/scrub/' + oid; + } + + function fetchBar(bar) { + var url = bar.isConnected ? scrubUrl(bar) : null; + if (!url || !listing()) { return; } + if (ctrl) { ctrl.abort(); } + var mine = new AbortController(); + ctrl = mine; + fetch(url, { headers: { accept: 'text/html' }, credentials: 'same-origin', signal: mine.signal }) + .then(function (r) { + if (!r.ok) { throw new Error('scrub ' + r.status); } + return r.text(); + }) + .then(function (text) { + if (mine !== ctrl) { return; } + ctrl = null; + show(text, bar.getAttribute('data-oid')); + }) + .catch(function () { + // A stale request (aborted or replaced) says nothing. A failed one keeps what is on screen; with + // no preview up, the bar's mark goes, so no bar looks selected for a page that did not change. + if (mine !== ctrl) { return; } + ctrl = null; + if (!active) { clearMarks(); } + }); + } + + // Copies the children of a wrapper in the answer into the page, as imported nodes. + function copyOf(el) { + if (!el) { return []; } + return Array.prototype.map.call(el.childNodes, function (n) { return document.importNode(n, true); }); + } + + function show(text, oid) { + var wrap = listing(); + var side = readmePane(); + if (!wrap || !side) { return; } + var doc = new DOMParser().parseFromString(text, 'text/html'); + var tree = doc.querySelector('[data-scrub-tree]'); + if (!tree) { return; } + var when = Number(tree.getAttribute('data-scrub-when')) || 0; + var marker = document.createElement('p'); + marker.className = 'label scrub-marker'; + marker.textContent = TEXT[lang()].note; + wrap.replaceChildren(marker, ...copyOf(tree)); + side.replaceChildren(...copyOf(doc.querySelector('[data-scrub-readme]'))); + var home = document.querySelector('.repo-home'); + if (home) { home.classList.add('is-scrub-preview'); } + active = true; + showNote(oid, when); + } + + // Relative time of a unix time, in the page's language. + function relWhen(unix) { + var rtf = new Intl.RelativeTimeFormat(lang(), { numeric: 'auto' }); + var diff = unix - Date.now() / 1000; + var steps = [['year', 31536000], ['month', 2592000], ['week', 604800], ['day', 86400], ['hour', 3600], ['minute', 60]]; + for (var i = 0; i < steps.length; i++) { + if (Math.abs(diff) >= steps[i][1]) { return rtf.format(Math.round(diff / steps[i][1]), steps[i][0]); } + } + return rtf.format(Math.round(diff), 'second'); + } + + function showNote(oid, when) { + var dock = document.querySelector('.repo-dock .dock-info'); + if (!dock) { return; } + if (!note) { + note = document.createElement('span'); + note.className = 'scrub-note label'; + note.setAttribute('role', 'status'); + var sha = document.createElement('span'); + sha.className = 'mono scrub-sha'; + var age = document.createElement('span'); + age.className = 'scrub-when'; + var back = document.createElement('button'); + back.type = 'button'; + back.className = 'small scrub-back'; + back.addEventListener('click', function () { endPreview(true); }); + note.append(sha, ' · ', age, ' ', back); + dock.appendChild(note); + } + note.querySelector('.scrub-sha').textContent = oid.slice(0, 7); + note.querySelector('.scrub-when').textContent = relWhen(when); + note.querySelector('.scrub-back').textContent = TEXT[lang()].back; + } + + // Ends the preview and drops everything it left behind. With `restore`, the page is fetched again + // through the live refresh, so the listing and README are the current ones. + function endPreview(restore) { + clearTimeout(timer); + timer = null; + if (ctrl) { var c = ctrl; ctrl = null; c.abort(); } + clearMarks(); + var was = active; + active = false; + if (note) { note.remove(); note = null; } + var home = document.querySelector('.repo-home.is-scrub-preview'); + if (home) { home.classList.remove('is-scrub-preview'); } + if (was && restore) { document.dispatchEvent(new CustomEvent('forge:refresh')); } + } + + // Any swap (a live change, a link, back or forward) replaced the page the preview was on. + document.addEventListener('forge:swapped', function () { + drag = null; + endPreview(false); + }); + + // The bars are links, and a browser would start dragging the link and stop sending pointer moves. + document.addEventListener('dragstart', function (e) { + if (stripOf(e.target)) { e.preventDefault(); } + }); + + document.addEventListener('pointerdown', function (e) { + swallow = 0; + if (e.button !== 0 || !e.isPrimary) { return; } + var strip = stripOf(e.target); + if (!strip || !listing()) { return; } + drag = { strip: strip, id: e.pointerId, x: e.clientX, y: e.clientY, on: false, bar: null }; + }); + + document.addEventListener('pointermove', function (e) { + if (!drag || e.pointerId !== drag.id) { return; } + if (!drag.on) { + var dx = e.clientX - drag.x; + var dy = e.clientY - drag.y; + if (Math.sqrt(dx * dx + dy * dy) <= DRAG_PX) { return; } + drag.on = true; + try { drag.strip.setPointerCapture(drag.id); } catch (err) { } + drag.strip.classList.add('is-scrubbing'); + } + var bar = barAt(drag.strip, e.clientX); + if (bar && bar !== drag.bar) { drag.bar = bar; pick(bar); } + }); + + function release(e) { + if (!drag || e.pointerId !== drag.id) { return; } + var d = drag; + drag = null; + if (!d.on) { return; } + // The preview stays after the release. The click that ends the drag must not follow a bar's link. + swallow = Date.now() + 400; + try { d.strip.releasePointerCapture(d.id); } catch (err) { } + d.strip.classList.remove('is-scrubbing'); + } + document.addEventListener('pointerup', release); + document.addEventListener('pointercancel', release); + + window.addEventListener('click', function (e) { + if (Date.now() >= swallow) { return; } + swallow = 0; + e.preventDefault(); + e.stopPropagation(); + }, true); + + // Left and Right on a focused bar move the preview one bar, older to the left. + document.addEventListener('keydown', function (e) { + if (e.key === 'Escape') { + if (!active || document.querySelector('dialog[open]')) { return; } + var t = e.target; + if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) { return; } + endPreview(true); + return; + } + if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') { return; } + if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !listing()) { return; } + var bar = e.target && e.target.closest ? e.target.closest('.history-bars .hs-bar') : null; + if (!bar) { return; } + var strip = stripOf(bar); + var bars = barsOf(strip); + var mark = strip.querySelector('.hs-bar.is-scrubbed'); + var base = mark || bar; + var i = bars.indexOf(base) + (e.key === 'ArrowLeft' ? -1 : 1); + e.preventDefault(); + if (i < 0 || i >= bars.length) { return; } + bars[i].focus({ preventScroll: true }); + pick(bars[i]); + }); })(); // Code browsing: line selection on blobs and blame, the permalink copy and `y` shortcut, the file @@ -5790,3 +6100,113 @@ } }); })(); + +// ---- alive: arrivals, the live bar's breath, settling, the CI tab and the favicon -------------------- +// See memory design/ALIVE.md. The page as it was before each live swap is kept here. After a live swap, +// a data-arrive value that was not there gets `arrived`, and a live `.hs-bar` (data-oid) that is no longer +// live gets `hs-settle`; each class goes once its animation ends. The CI tab gets `tab-live` while a run +// of this repo goes, and the favicon shows a dot then. Nothing moves under reduced motion. +(function () { + 'use strict'; + + var still = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : null; + var before = null; // { arrive: {value: true}, live: {oid: true} } of the page before the last swap + var pending = false; + + function snapshot() { + var arrive = Object.create(null), live = Object.create(null); + Array.prototype.forEach.call(document.querySelectorAll('[data-arrive]'), function (el) { arrive[el.getAttribute('data-arrive')] = true; }); + Array.prototype.forEach.call(document.querySelectorAll('.hs-bar.hs-live[data-oid]'), function (el) { live[el.getAttribute('data-oid')] = true; }); + return { arrive: arrive, live: live }; + } + + // Adds the class and removes it when its animation ends (the element's own end, not a child's). + function flash(el, cls) { + var end = function (e) { + if (e.target !== el) { return; } + el.classList.remove(cls); + el.removeEventListener('animationend', end); + }; + el.addEventListener('animationend', end); + el.classList.add(cls); + } + + function afterLive(prev) { + if (still && still.matches) { return; } + Array.prototype.forEach.call(document.querySelectorAll('[data-arrive]'), function (el) { + if (!prev.arrive[el.getAttribute('data-arrive')]) { flash(el, 'arrived'); } + }); + Array.prototype.forEach.call(document.querySelectorAll('.hs-bar[data-oid]'), function (el) { + if (prev.live[el.getAttribute('data-oid')] && !el.classList.contains('hs-live')) { flash(el, 'hs-settle'); } + }); + } + + // The favicon: the page's own link[rel~=icon], or one made here when the page has none. While a run goes + // it shows a stand-in forge mark with an accent dot; when idle the original is put back (a made link is removed). + var icon = null, iconMade = false, iconOrig = null, iconLive = false; + + function liveIcon() { + var accent = getComputedStyle(document.documentElement).getPropertyValue('--accent').trim() || '#e5484d'; + var svg = '' + + '' + + '' + + ''; + return 'data:image/svg+xml,' + encodeURIComponent(svg); + } + + function setIcon(on) { + if (on === iconLive) { return; } + if (!icon) { + icon = document.querySelector('link[rel~="icon"]'); + if (!icon) { + if (!on) { return; } + icon = document.createElement('link'); + icon.rel = 'icon'; + iconMade = true; + document.head.appendChild(icon); + } + iconOrig = icon.getAttribute('href'); + } + iconLive = on; + if (on) { icon.setAttribute('href', liveIcon()); } + else if (iconMade) { icon.parentNode.removeChild(icon); icon = null; iconMade = false; } + else if (iconOrig !== null) { icon.setAttribute('href', iconOrig); } + } + + // The CI tab's dot: a running pill of this repo in the top bar, or a live bar on the page. The strip's + // pill is redrawn by the activity poll, so the body's changes are watched too. + function syncLive() { + var tab = document.querySelector('.repo-tabs a[href$="/ci"]'); + var base = tab ? tab.getAttribute('href') : ''; + var going = false; + if (tab) { + going = !!document.querySelector('.hs-live') || Array.prototype.some.call( + document.querySelectorAll('.live-strip a.pill.hot, .live-strip .strip-list a.strip-row.hot'), + function (a) { return (a.getAttribute('href') || '').indexOf(base + '/') === 0; }); + tab.classList.toggle('tab-live', going); + } + setIcon(going || !!document.querySelector('.ci-run .ci-state.ci-running')); + } + + function queueSync() { + if (pending) { return; } + pending = true; + requestAnimationFrame(function () { pending = false; syncLive(); }); + } + + document.addEventListener('forge:swapped', function (e) { + var prev = before; + before = snapshot(); + queueSync(); + if (prev && e.detail && e.detail.how === 'live') { afterLive(prev); } + }); + + function init() { + before = snapshot(); + syncLive(); + new MutationObserver(queueSync).observe(document.body, { childList: true, subtree: true }); + } + + if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } + else { init(); } +})(); diff --git a/crates/forge-web/src/i18n/code.rs b/crates/forge-web/src/i18n/code.rs index 578e8d3..0a46d9d 100644 --- a/crates/forge-web/src/i18n/code.rs +++ b/crates/forge-web/src/i18n/code.rs @@ -39,10 +39,8 @@ pub enum K { HadRecentPushes, CompareAndPr, BranchLabel, - NameHeader, LastCommitHeader, AgeHeader, - LatestCommitLabel, KindDir, KindFile, KindExec, @@ -104,7 +102,6 @@ pub enum K { FilteredTo, ClearFilter, NoCommits, - Committed, BrowseFilesShort, NewerLink, OlderLink, @@ -199,14 +196,10 @@ pub fn t(lang: Lang, key: K) -> &'static str { (CompareAndPr, Tr) => "Karşılaştır ve çekme isteği aç", (BranchLabel, En) => "Branch", (BranchLabel, Tr) => "Dal", - (NameHeader, En) => "Name", - (NameHeader, Tr) => "Ad", (LastCommitHeader, En) => "Last commit", (LastCommitHeader, Tr) => "Son commit", (AgeHeader, En) => "Age", (AgeHeader, Tr) => "Zaman", - (LatestCommitLabel, En) => "Latest commit", - (LatestCommitLabel, Tr) => "Son commit", (KindDir, En) => "dir", (KindDir, Tr) => "dizin", (KindFile, En) => "file", @@ -329,8 +322,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { (ClearFilter, Tr) => "Filtreyi temizle", (NoCommits, En) => "No commits yet. Push a branch and its history shows up here.", (NoCommits, Tr) => "Henüz commit yok. Bir dal gönderin, geçmişi burada görünsün.", - (Committed, En) => "committed", - (Committed, Tr) => "commit etti", (BrowseFilesShort, En) => "Browse files", (BrowseFilesShort, Tr) => "Dosyalara göz at", (NewerLink, En) => "Newer", @@ -453,14 +444,6 @@ pub fn changed_files(lang: Lang, count: usize) -> String { } } -/// `N commits` in English (`1 commit` for one), `N commit` in Turkish. -pub fn commit_count(lang: Lang, count: u64) -> String { - match lang { - Lang::En => format!("{count} commit{}", if count == 1 { "" } else { "s" }), - Lang::Tr => format!("{count} commit"), - } -} - /// The note that a diff stops at `max` files. `subject` names what the diff shows. pub fn diff_truncated(lang: Lang, max: usize, subject: &str) -> String { match lang { @@ -584,10 +567,8 @@ mod tests { K::HadRecentPushes, K::CompareAndPr, K::BranchLabel, - K::NameHeader, K::LastCommitHeader, K::AgeHeader, - K::LatestCommitLabel, K::KindDir, K::KindFile, K::KindExec, @@ -649,7 +630,6 @@ mod tests { K::FilteredTo, K::ClearFilter, K::NoCommits, - K::Committed, K::BrowseFilesShort, K::NewerLink, K::OlderLink, diff --git a/crates/forge-web/src/pages/admin_server.rs b/crates/forge-web/src/pages/admin_server.rs index b596ef2..efe3a62 100644 --- a/crates/forge-web/src/pages/admin_server.rs +++ b/crates/forge-web/src/pages/admin_server.rs @@ -265,7 +265,7 @@ async fn server_view( for r in rows.iter() {
- (r.label) + (r.label) (r.kind_label) (r.source_label) if r.pending { @@ -293,7 +293,7 @@ async fn server_view(

(r.secret_state) ". " (g::t(lang, K::SrvSecretHint))

} else if r.fixed { - (r.value.as_str()) + (r.value.as_str()) } else { } diff --git a/crates/forge-web/src/pages/blame.rs b/crates/forge-web/src/pages/blame.rs index 0428a24..9eb5042 100644 --- a/crates/forge-web/src/pages/blame.rs +++ b/crates/forge-web/src/pages/blame.rs @@ -117,11 +117,11 @@ async fn blame_table(rows: Vec, lang: Lang) -> Result { (meta.short.as_str()) (meta.author.as_str()) + if let Some(prior) = meta.prior_href { + "↶" + }
- commit_line(subject: meta.summary.clone(), no_tag: true) - if let Some(prior) = meta.prior_href { - (b::t(lang, b::K::BlamePrior)) - } + commit_line(subject: meta.summary.clone()) } (row.line.num.as_str()) diff --git a/crates/forge-web/src/pages/ci_job.rs b/crates/forge-web/src/pages/ci_job.rs index d85fd1b..7527ef7 100644 --- a/crates/forge-web/src/pages/ci_job.rs +++ b/crates/forge-web/src/pages/ci_job.rs @@ -35,12 +35,13 @@ use crate::i18n::{ releases_ci::{self as g, K}, }; use crate::pages::ci_runs::{ - age_text, can_write, changed_event, duration_text, events_response, job_href, run_href, - state_text, strip_ansi, + age_text, can_write, changed_event, dock_bars, duration_text, events_response, job_href, + run_href, state_text, strip_ansi, }; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable}; use crate::state::AppState; +use crate::views::timeline::{StripBar, history_strip}; use crate::views::{enc, human_size, shell}; path_param!(owner); @@ -375,6 +376,9 @@ async fn job_body( truncated: bool, artifacts: Vec, live: String, + owner: String, + repo: String, + bars: Vec, ) -> Result { Ok(view! { repo_head(head: RepoHead { live: String::new(), ..head }) @@ -408,48 +412,61 @@ async fn job_body( }
-
- if !job.started.is_empty() { -

(g::t(lang, K::Started)) " "

- } - if !job.finished.is_empty() { -

(g::t(lang, K::Finished)) " "

- } - if !job.message.is_empty() { -

(job.message.as_str())

- } - if let Some(kills) = job.oom_kills { -

(if matches!(lang, Lang::Tr) { "sonlandırıldı: bellek yetersiz" } else { "killed: out of memory" })

- } +
+

(crate::pages::passkeys::s(lang, "Details", "Ayrıntılar"))

+
+ if !job.started.is_empty() { +

(g::t(lang, K::Started)) " "

+ } + if !job.finished.is_empty() { +

(g::t(lang, K::Finished)) " "

+ } + if !job.message.is_empty() { +

(job.message.as_str())

+ } + if let Some(kills) = job.oom_kills { +

(if matches!(lang, Lang::Tr) { "sonlandırıldı: bellek yetersiz" } else { "killed: out of memory" })

+ } +
if !artifacts.is_empty() { -

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

-
    +

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

    + }
-
+
- (g::t(lang, K::Log)) - - - - - - (g::t(lang, K::FullLog)) - +
+ (g::t(lang, K::Log)) +
+
+ + + + + + (g::t(lang, K::FullLog)) + +
if truncated { -

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

+

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

}
(log.as_str())
+
+

(crate::pages::passkeys::s(lang, "bar height is lines changed", "çubuk yüksekliği değişen satır sayısıdır"))

+
+ history_strip(lang: lang, owner: owner, repo: repo, bars: bars) +
+
}) } @@ -538,11 +555,14 @@ async fn job_page(cx: &Cx) -> Result { }, }; let head = ctx.head(state, "ci").await?; + let bars = dock_bars(state, &ctx).await; + let dock_owner = ctx.repo.owner_name.clone(); + let dock_repo = ctx.repo.name.clone(); let page_title = format!("{title} \u{b7} CI \u{b7} {}", view.name); Ok(view! { shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), job_body(head: head, lang: lang, job: view, log: log, log_offset: log_offset.to_string(), first_line: first_line.to_string(), - truncated: truncated, artifacts: artifacts, live: live)) + truncated: truncated, artifacts: artifacts, live: live, owner: dock_owner, repo: dock_repo, bars: bars)) }) } diff --git a/crates/forge-web/src/pages/ci_runs.rs b/crates/forge-web/src/pages/ci_runs.rs index ac27a4e..3a771b5 100644 --- a/crates/forge-web/src/pages/ci_runs.rs +++ b/crates/forge-web/src/pages/ci_runs.rs @@ -472,7 +472,6 @@ struct RunDetail { /// The log pane of the run page: the selected job's name, its links and the tail of its log. struct JobLog { - name: String, href: String, log_href: String, /// The job's event stream (plain lines) while the job is not finished; None once it is. @@ -1679,7 +1678,6 @@ async fn run_detail( } = log_tail(&log_path(&state.config.data_dir, &job.id)).await?; let href = job_href(title, &job.id); Some(JobLog { - name: job.name.clone(), log_href: format!("{href}/log.txt"), live: (!job.state.is_terminal()).then(|| format!("{href}/events?plain=1")), href, @@ -1913,73 +1911,13 @@ async fn runs_body( } -
+
if let Some(run) = detail { -
-
-
- (g::t(lang, K::RunNumber)) (run.number) -

(headline(run.title.as_str()))

-
- (crate::i18n::code::t(lang, crate::i18n::code::K::ShowFullMessage)) -

(run.title.as_str())

-
-
-
- (run.state.as_str()) - (run.trigger.as_str()) " \u{b7} " (run.branch.as_str()) - (run.commit.as_str()) - if !run.actor.is_empty() { - (run.actor.as_str()) - } - if !run.duration.is_empty() { - if let Some(est) = run.est.as_ref() { - (run.duration.as_str()) - } else { - (run.duration.as_str()) - } - } - -
-
- if let Some(csrf) = run.writer_csrf.as_ref() { -
- if run.can_approve { - action_button(action: format!("{}/approve", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::ApproveAndRun)) - } - if run.can_cancel && run.stopping { - - } else if run.can_cancel { - action_button(action: format!("{}/cancel", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Cancel)) - } - if run.can_rerun_failed { - action_button(action: format!("{}/rerun-failed", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::RerunFailed)) - } - action_button(action: format!("{}/rerun", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Rerun)) -
- } -
- if let Some(est) = run.est.as_ref() { - - } - if let Some(fail) = run.failing.clone() { - fail_first_block(lang: lang, fail: fail) - } - if let Some(message) = run.config_error.as_ref() { -
(message.as_str())
- } - if !run.warnings.is_empty() { -
-

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

-

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

-
    - for warning in run.warnings.iter() { -
  • (warning.as_str())
  • - } -
-
- } - run_timeline(lang: lang, run: &run) + run_head(lang: lang, run: &run, all_href: None) +
+ run_jobs(lang: lang, run: &run) + run_log(lang: lang, run: &run, timeline: false) +
} else { empty_state(title: g::t(lang, K::NoRunsYet), hint: Some(g::t(lang, K::NoRunsHint))) } @@ -2084,26 +2022,193 @@ async fn run_timeline(lang: Lang, run: &RunDetail) -> Result { } } - if !run.artifacts.is_empty() { -
-

(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()) - (artifact.job.as_str()) " \u{b7} " (artifact.size.as_str()) - (g::t(lang, K::Download)) -
  • + }) +} + +/// The head of a run: `Run #N` and the commit's first clause, the full message on demand, a meta line +/// (the state in accent while it is live) and at most two actions at the right. `all_href` adds the All +/// runs link, which the run page needs; the list page has the runs beside it. +#[component] +async fn run_head(lang: Lang, run: &RunDetail, all_href: Option) -> Result { + Ok(view! { +
    +
    +
    + (g::t(lang, K::RunNumber)) (run.number) +

    (headline(run.title.as_str()))

    +
    + (crate::i18n::code::t(lang, crate::i18n::code::K::ShowFullMessage)) +

    (run.title.as_str())

    +
    +
    +
    + (run.state.as_str()) + (run.trigger.as_str()) " \u{b7} " (run.branch.as_str()) + (run.commit.as_str()) + if !run.actor.is_empty() { + (run.actor.as_str()) + } + if !run.duration.is_empty() { + if let Some(est) = run.est.as_ref() { + (run.duration.as_str()) + } else { + (run.duration.as_str()) + } + } + + if let Some(href) = all_href { + (tl::t(lang, TK::AllRuns)) + } +
    + if let Some(est) = run.est.as_ref() { + + } +
    + if let Some(csrf) = run.writer_csrf.as_ref() { +
    + if run.can_approve { + action_button(action: format!("{}/approve", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::ApproveAndRun)) + } + if run.can_cancel && run.stopping { + + } else if run.can_cancel { + action_button(action: format!("{}/cancel", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Cancel)) + } + if run.can_rerun_failed && !run.can_approve && !run.can_cancel { + action_button(action: format!("{}/rerun-failed", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::RerunFailed)) + } + if !run.can_approve { + action_button(action: format!("{}/rerun", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Rerun)) + } +
    + } +
    + }) +} + +/// The jobs pane (300 px): `Jobs`, one 36 px row per job with its dot, name, image and time at the right, +/// then the run's artifacts. The selected job is the one the log shows. +#[component] +async fn run_jobs(lang: Lang, run: &RunDetail) -> Result { + Ok(view! { +
    +

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

    + if run.jobs.is_empty() { +

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

    + } else { + + } + if !run.artifacts.is_empty() { +
    +

    (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()) + (artifact.job.as_str()) " \u{b7} " (artifact.size.as_str()) + (g::t(lang, K::Download)) +
    • + } +
    + } +
    + }) +} + +/// The log pane: a 48 px bar with the Log and Timeline tabs and the log's tools, then the selected job's +/// log on `--bg` (or the config errors and the fail-first block above it). The timeline is the other tab. +#[component] +async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result { + Ok(view! { +
    + + +
    +
    + + +
    + if let Some(log) = run.log.as_ref() { +
    + + + + + + (g::t(lang, K::FullLog)) + if let (Some(action), Some(csrf)) = (log.rerun.as_ref(), run.writer_csrf.as_ref()) { +
    + + +
    + } + +
    + } +
    +
    + if let Some(message) = run.config_error.as_ref() { +
    (message.as_str())
    + } + if !run.warnings.is_empty() { +
    +

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

    +

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

    +
      + for warning in run.warnings.iter() { +
    • (warning.as_str())
    • }
    +
    + } + if let Some(fail) = run.failing.clone() { + fail_first_block(lang: lang, fail: fail) + } + if let Some(log) = run.log.as_ref() { + if log.truncated { +

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

    } +
    (log.text.as_str())
    + } else { +

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

    + } +
    +
    + run_timeline(lang: lang, run: run) +
    +
    }) } - /// The run page body: a one-line header with the run's actions, the jobs (left) and the selected job's /// log (right), and the history dock under them. The page fits the window: the panes scroll inside. /// The live region is the run list's stream, so the page re-renders when a run or a job changes. @@ -2131,160 +2236,13 @@ async fn run_body( } }
    -
    -
    -
    - (g::t(lang, K::RunNumber)) (run.number) -

    (headline(run.title.as_str()))

    -
    - (crate::i18n::code::t(lang, crate::i18n::code::K::ShowFullMessage)) -

    (run.title.as_str())

    -
    -
    -
    - (run.state.as_str()) - (run.trigger.as_str()) " \u{b7} " (run.branch.as_str()) - (run.commit.as_str()) - if !run.actor.is_empty() { - (run.actor.as_str()) - } - if !run.duration.is_empty() { - if let Some(est) = run.est.as_ref() { - (run.duration.as_str()) - } else { - (run.duration.as_str()) - } - } - - (tl::t(lang, TK::AllRuns)) -
    - if let Some(est) = run.est.as_ref() { - - } -
    - if let Some(csrf) = run.writer_csrf.as_ref() { -
    - if run.can_approve { - action_button(action: format!("{}/approve", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::ApproveAndRun)) - } - if run.can_cancel && run.stopping { - - } else if run.can_cancel { - action_button(action: format!("{}/cancel", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Cancel)) - } - if run.can_rerun_failed { - action_button(action: format!("{}/rerun-failed", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::RerunFailed)) - } - action_button(action: format!("{}/rerun", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Rerun)) -
    - } -
    + run_head(lang: lang, run: &run, all_href: Some(all_href))
    -
    -

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

    - if run.jobs.is_empty() { -

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

    - } else { - - } - if !run.artifacts.is_empty() { -

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

    -
      - for artifact in run.artifacts.iter() { -
    • - (artifact.name.as_str()) - (artifact.job.as_str()) " \u{b7} " (artifact.size.as_str()) - (g::t(lang, K::Download)) -
    • - } -
    - if let Some(href) = run.zip_href.as_ref() { - (g::t(lang, K::DownloadAll)) - } - } -
    -
    - - -
    - - -
    -
    - if let Some(message) = run.config_error.as_ref() { -
    (message.as_str())
    - } - if !run.warnings.is_empty() { -
    -

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

    -

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

    -
      - for warning in run.warnings.iter() { -
    • (warning.as_str())
    • - } -
    -
    - } - if let Some(fail) = run.failing.clone() { - fail_first_block(lang: lang, fail: fail) - } - if let Some(log) = run.log.as_ref() { -
    - (g::t(lang, K::Log)) " \u{b7} " (log.name.as_str()) - - - - - - (g::t(lang, K::FullLog)) - if let (Some(action), Some(csrf)) = (log.rerun.as_ref(), run.writer_csrf.as_ref()) { -
    - - -
    - } - -
    - if log.truncated { -

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

    - } -
    (log.text.as_str())
    - } else { -

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

    - } -
    -
    - run_timeline(lang: lang, run: &run) -
    -
    + run_jobs(lang: lang, run: &run) + run_log(lang: lang, run: &run, timeline: timeline)
    -
    +
    +

    (crate::pages::passkeys::s(lang, "bar height is lines changed", "çubuk yüksekliği değişen satır sayısıdır"))

    history_strip(lang: lang, owner: owner, repo: repo, bars: bars)
    @@ -2346,7 +2304,7 @@ async fn run_page(cx: &Cx) -> Result { /// The dock's bars: the newest commits of the default branch, oldest first, each with its latest CI /// state. Empty when the branch cannot be read, which draws no strip. -async fn dock_bars(state: &AppState, ctx: &RepoCtx) -> Vec { +pub(crate) async fn dock_bars(state: &AppState, ctx: &RepoCtx) -> Vec { let path = ctx.path.clone(); let branch = ctx.repo.default_branch.clone(); let head = tokio::task::spawn_blocking(move || { diff --git a/crates/forge-web/src/pages/commit.rs b/crates/forge-web/src/pages/commit.rs index ef0d948..2d5da7f 100644 --- a/crates/forge-web/src/pages/commit.rs +++ b/crates/forge-web/src/pages/commit.rs @@ -231,35 +231,42 @@ async fn commit_page(cx: &Cx) -> Result { .get(&full_oid) .map(|badge| SigBadgeView::from_badge(badge, lang)); - let (copy, copied, copy_failed) = match lang { - i18n::Lang::En => ("Copy", "Copied", "Failed"), - i18n::Lang::Tr => ("Kopyala", "Kopyalandı", "Başarısız"), + let short = short_oid(&info.oid).to_owned(); + // The committer is not shown on the line when it is the author: a title holds it when it differs. + let who_title = if committer_differs { + format!( + "{} {} <{}>\n{} {} <{}> · {}", + g::t(lang, K::AuthorLabel), + author.name, + author.email, + g::t(lang, K::CommitterLabel), + committer.name, + committer.email, + committer.absolute, + ) + } else if author.email.is_empty() { + String::new() + } else { + format!("<{}>", author.email) + }; + let (copied, copy_failed) = match lang { + i18n::Lang::En => ("Copied", "Failed"), + i18n::Lang::Tr => ("Kopyalandı", "Başarısız"), }; let mut header = ctx.head(state, "commits").await?; header.live = ref_live::live_url(&owner_name, &repo_name); - let author_mailto = format!("mailto:{}", author.email); - let committer_mailto = format!("mailto:{}", committer.email); Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), repo_head(head: header)

    (heading.as_str())

    -
    -

    - - (full_oid.as_str()) - - - if let Some(badge) = sig { - (badge.label) - } -

    - if let Some(summary) = checks { - checks_summary(summary: summary, lang: StatusLang(lang)) +
    + + (full_oid.as_str()) + if let Some(badge) = sig { + (badge.label) } -
    (g::t(lang, K::AuthorLabel)) (author.name.as_str()) - if !author.email.is_empty() { - " " (author.email.as_str()) - } + + (author.name.as_str()) if has_coauthors { (g::t(lang, K::CoAuthorAnd)) for c in coauthors.iter() { @@ -298,26 +305,22 @@ async fn commit_page(cx: &Cx) -> Result {
} } - " · " - - if committer_differs { -

(g::t(lang, K::CommitterLabel)) (committer.name.as_str()) - if !committer.email.is_empty() { - " " (committer.email.as_str()) - } - " · "

- } + + if is_root { -

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

+ (g::t(lang, K::RootCommit)) } else { -

(g::t(lang, K::ParentLabel)) + (g::t(lang, K::ParentLabel)) for p in parents.iter() { - (p.short.as_str()) " " + (p.short.as_str()) } -

+ } -

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

- + if let Some(summary) = checks { + checks_summary(summary: summary, lang: StatusLang(lang)) + } + (g::t(lang, K::BrowseFiles)) + if let Some(msg) = parsed.as_ref() { + } - if has_newer || has_older {