diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index 75ef11e..63704cf 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -330,8 +330,11 @@ if (how !== 'live') { closeDropdowns(null); } var oldList = document.querySelector('.ci-run-list'); var listTop = how === 'live' && oldList ? oldList.scrollTop : null; + // A fit pane keeps its scroll when the page stays put (a live change, a post, a filter), by its place in the page. + var paneTops = how === 'live' || how === 'post' || how === 'query' ? paneScrolls() : null; adopt(doc, keepFields, dd, how === 'live' ? captureJobs() : null); placeRun(listTop); + if (paneTops) { setPaneScrolls(paneTops); } if (tailAt) { var nextTail = document.querySelector('[data-live-log]'); if (nextTail) { nextTail.scrollTop = tailAt.end ? nextTail.scrollHeight : tailAt.top; } @@ -365,13 +368,29 @@ var els = document.querySelectorAll('[data-keep-anchor]'); for (var i = 0; i < els.length; i++) { if (els[i].getAttribute('data-keep-anchor') === at.key) { - window.scrollTo(window.scrollX, window.scrollY + els[i].getBoundingClientRect().top - at.dy); + var delta = els[i].getBoundingClientRect().top - at.dy; + // A diff inside a fit pane moves the pane; the page itself does not scroll there. + var pane = els[i].closest('.fit-pane'); + if (pane && pane.scrollHeight > pane.clientHeight) { pane.scrollTop += delta; } + else { window.scrollTo(window.scrollX, window.scrollY + delta); } return true; } } return false; } + // The scroll of each fit pane on the page, in order. A pane is a new element after a swap, so its place is + // set again by its index. + function paneScrolls() { + return Array.prototype.map.call(document.querySelectorAll('.fit-pane'), function (p) { return p.scrollTop; }); + } + + function setPaneScrolls(tops) { + Array.prototype.forEach.call(document.querySelectorAll('.fit-pane'), function (p, i) { + if (i < tops.length) { p.scrollTop = tops[i]; } + }); + } + // The runs list scrolls inside its card: bring the selected row into view there. scrollIntoView // would also scroll the page, so the list's own scrollTop is set instead. function placeRun(keepTop) { @@ -1088,16 +1107,21 @@ } } - // Fills the popover's list with the server's fragment. A reader who closed it meanwhile, or a newer - // open, leaves the answer unused. + // Fills the popover's list with the server's fragment. The popover stays invisible until then, so it + // opens at its final height; a slow answer shows the loading note first. A reader who closed it + // meanwhile, or a newer open, leaves the answer unused. function loadPeek(pop) { var list = pop.querySelector('.bell-list'); if (!list) { return; } var seq = ++peekSeq; - var note = document.createElement('p'); - note.className = 'bell-empty muted'; - note.textContent = pop.getAttribute('data-loading') || ''; - list.replaceChildren(note); + var slow = setTimeout(function () { + if (seq !== peekSeq || !isPeekOpen(pop)) { return; } + var note = document.createElement('p'); + note.className = 'bell-empty muted'; + note.textContent = pop.getAttribute('data-loading') || ''; + list.replaceChildren(note); + pop.classList.add('bell-ready'); + }, PEEK_SLOW); fetch('/notifications/peek', { headers: { accept: 'text/html' }, credentials: 'same-origin' }).then(function (r) { if (!r.ok) { throw new Error('status ' + r.status); } return r.text(); @@ -1112,8 +1136,12 @@ err.className = 'bell-empty muted'; err.textContent = pop.getAttribute('data-error') || ''; list.replaceChildren(err); + }).then(function () { + clearTimeout(slow); + if (seq === peekSeq && isPeekOpen(pop)) { pop.classList.add('bell-ready'); } }); } + var PEEK_SLOW = 300; // ms before a slow list shows its loading note var peekSeq = 0; // a fetch's number: only the newest answer is drawn // Records whether the popover was open when the press began. Light dismiss closes it on the press, @@ -1158,9 +1186,12 @@ 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; + } else { + pop.classList.remove('bell-ready'); + if (hoverOn === 'bell') { + // Closed by Escape or a light dismiss: the mouse no longer holds it open. + hoverOn = null; + } } }, true); @@ -3153,21 +3184,73 @@ shellFrame = 0; var shell = document.querySelector('.shell'); if (!shell) { return; } - document.documentElement.style.setProperty('--shell-top', Math.round(shell.getBoundingClientRect().top) + 'px'); + var root = document.documentElement.style; + root.setProperty('--shell-top', Math.round(shell.getBoundingClientRect().top) + 'px'); + // A pane that fills the window sits between headers and a footer of any height: both are measured. + // The CI card sticks while the page scrolls, so its wrapper gives the top. + var pane = document.querySelector('.repo-home, .ci-split, .fit-pane'); + var main = document.querySelector('main'); + var foot = document.querySelector('.site-footer'); + if (!pane || !main || !foot) { return; } + root.setProperty('--pane-top', Math.ceil(pane.getBoundingClientRect().top + window.scrollY) + 'px'); + root.setProperty('--pane-foot', Math.ceil(foot.getBoundingClientRect().height + parseFloat(getComputedStyle(main).paddingBottom)) + 'px'); + } + + // A CI badge (`/{owner}/{repo}/badge.svg`, often in a README) is drawn here as HTML from the data in + // its SVG, so it takes the theme's colours: an image cannot read them, and other sites keep the SVG. + // It is fetched again after a swap, and a badge seen before is drawn at once so a live render does + // not blink. + var badgeSeen = {}; // badge URL -> { label, status } + + function readBadge(href) { + return fetch(href, { credentials: 'same-origin' }).then(function (res) { + if (!res.ok) { throw new Error('badge'); } + return res.text(); + }).then(function (text) { + var svg = new DOMParser().parseFromString(text, 'image/svg+xml').documentElement; + var label = svg.querySelector('text'); + var status = svg.getAttribute('data-status'); + if (!label || !status) { throw new Error('badge'); } + return { label: label.textContent, status: status }; + }); + } + + function drawBadge(el, data) { + var chip = document.createElement('span'); + chip.className = 'ci-chip'; + chip.setAttribute('role', 'img'); + chip.setAttribute('aria-label', data.label + ': ' + data.status); + chip.setAttribute('data-badge', el.getAttribute('data-badge')); + chip.setAttribute('data-status', data.status); + [data.label, data.status].forEach(function (text) { + var part = document.createElement('span'); + part.textContent = text; + chip.appendChild(part); + }); + el.replaceWith(chip); } - // A CI badge (`/{owner}/{repo}/badge.svg`, often in a README) is fetched again after a swap. The - // document stays the same across a soft navigation, and the browser reuses an image it already - // has at the same URL whatever its Cache-Control says, so the badge would keep an old state until - // a reload. The badge ignores query keys it does not know, so `_r` only makes the URL new. function syncBadges() { - var stamp = String(Date.now()); document.querySelectorAll('img[src*="/badge.svg"]').forEach(function (img) { var url; try { url = new URL(img.getAttribute('src'), location.href); } catch (err) { return; } if (url.origin !== location.origin || !/\/badge\.svg$/.test(url.pathname)) { return; } - url.searchParams.set('_r', stamp); - img.src = url.pathname + url.search; + var href = url.pathname + url.search; + img.setAttribute('data-badge', href); + if (badgeSeen[href]) { drawBadge(img, badgeSeen[href]); } else { img.classList.add('badge-wait'); } + }); + var all = document.querySelectorAll('[data-badge]'); + var hrefs = {}; + all.forEach(function (el) { hrefs[el.getAttribute('data-badge')] = true; }); + Object.keys(hrefs).forEach(function (href) { + readBadge(href).then(function (data) { + badgeSeen[href] = data; + document.querySelectorAll('[data-badge]').forEach(function (el) { + if (el.getAttribute('data-badge') === href) { drawBadge(el, data); } + }); + }).catch(function () { + document.querySelectorAll('img.badge-wait').forEach(function (img) { img.classList.remove('badge-wait'); }); + }); }); } @@ -3260,6 +3343,7 @@ syncBannerExpiry(); syncShellTop(); syncDrafts(); + syncBadges(); window.__forgeQuery = function (href) { var url = pageUrl(href); diff --git a/crates/forge-web/src/i18n/misc.rs b/crates/forge-web/src/i18n/misc.rs index 4e0a18d..d32570a 100644 --- a/crates/forge-web/src/i18n/misc.rs +++ b/crates/forge-web/src/i18n/misc.rs @@ -166,6 +166,7 @@ pub enum K { // Top-bar user menu: the viewer's public profile and the settings editor. YourProfile, EditProfile, + EditOrganization, // Profile corner, live strip and path bar search. AllNotifications, Passed, @@ -323,6 +324,7 @@ const ALL: &[K] = &[ K::RefLabel, K::YourProfile, K::EditProfile, + K::EditOrganization, K::AllNotifications, K::Passed, K::Failed, @@ -483,8 +485,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { (MarkAllAsRead, Tr) => "Tümünü okundu olarak işaretle", (MarkAllRead, En) => "Mark all read", (MarkAllRead, Tr) => "Tümünü okundu işaretle", - (ClearNotifications, En) => "Clear", - (ClearNotifications, Tr) => "Temizle", + (ClearNotifications, En) => "Mark as read", + (ClearNotifications, Tr) => "Okundu işaretle", (MarkRead, En) => "Mark read", (MarkRead, Tr) => "Okundu işaretle", (NoNotificationsYet, En) => "No notifications yet.", @@ -645,6 +647,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { (YourProfile, Tr) => "Profilin", (EditProfile, En) => "Edit profile", (EditProfile, Tr) => "Profili düzenle", + (EditOrganization, En) => "Edit organization", + (EditOrganization, Tr) => "Kuruluşu düzenle", (AllNotifications, En) => "All notifications", (AllNotifications, Tr) => "Tüm bildirimler", (Passed, En) => "passed", diff --git a/crates/forge-web/src/i18n/orgs.rs b/crates/forge-web/src/i18n/orgs.rs index 0a9cd1f..dcc5b4c 100644 --- a/crates/forge-web/src/i18n/orgs.rs +++ b/crates/forge-web/src/i18n/orgs.rs @@ -50,6 +50,8 @@ pub enum K { CreateOrg, // Organization settings. Settings, + General, + BackToOrganization, Description, DisplayNameLabel, DefaultRoleLabel, @@ -62,6 +64,7 @@ pub enum K { Members, Teams, Organization, + ViewAllMembers, MemberHeader, Role, RoleOwner, @@ -121,7 +124,6 @@ pub enum K { PinsTooMany, NoPinnableRepos, TabOverview, - Overview, TabStars, FilterRepos, NoReposMatch, @@ -213,6 +215,12 @@ pub fn t(lang: Lang, key: K) -> &'static str { (NewRepository, Tr) => "Yeni depo", (NewOrganization, En) => "New organization", (NewOrganization, Tr) => "Yeni kuruluş", + (General, En) => "General", + (General, Tr) => "Genel", + (BackToOrganization, En) => "Back to organization", + (BackToOrganization, Tr) => "Kuruluşa dön", + (ViewAllMembers, En) => "View all", + (ViewAllMembers, Tr) => "Tümünü gör", (NewOrgIntro, En) => { "An organization owns repositories and shares them with its members through teams. You become its first owner." } @@ -375,8 +383,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { (NoPinnableRepos, Tr) => "Henüz sabitlenecek depo yok.", (TabOverview, En) => "Overview", (TabOverview, Tr) => "Genel bakış", - (Overview, En) => "Overview", - (Overview, Tr) => "Genel bakış", (TabStars, En) => "Stars", (TabStars, Tr) => "Yıldızlar", (FilterRepos, En) => "Find a repository", @@ -618,7 +624,8 @@ mod tests { K::PinsTooMany, K::NoPinnableRepos, K::TabOverview, - K::Overview, + K::General, + K::BackToOrganization, K::TabStars, K::FilterRepos, K::NoReposMatch, diff --git a/crates/forge-web/src/pages/admin_health.rs b/crates/forge-web/src/pages/admin_health.rs index 4dbabf6..4ddb187 100644 --- a/crates/forge-web/src/pages/admin_health.rs +++ b/crates/forge-web/src/pages/admin_health.rs @@ -16,7 +16,7 @@ use tokio::process::Command; use topcoat::Result; use topcoat::context::{Cx, app_context}; use topcoat::router::response::Response; -use topcoat::router::{page, route}; +use topcoat::router::{page, query_params, route}; use topcoat::view::{View, component, view}; use crate::i18n::accounts::{A, duration_short, meta_line, needs_attention, on_disk, t as at}; @@ -25,8 +25,19 @@ use crate::i18n::{self, Lang}; use crate::live::{Topic, stream_changes}; use crate::pages::admin_users::admin_only; use crate::state::AppState; +use crate::views::repo_list::{PageLink, pager, pager_links}; use crate::views::{human_size, now_unix, rel_time, shell}; +/// Active alerts per page of the alerts card. Each row is about 56px tall, so three keep the card +/// short enough to fit the window. +const ALERTS_PER_PAGE: usize = 3; + +/// The health page's query: only the alerts' page. +#[query_params(error = bad_request)] +struct HealthQuery { + page: Option, +} + /// How a dot or a value is drawn: a bad outcome, a good one, a plain count, or a feature that is /// not set up. #[derive(Clone, Copy, PartialEq, Eq)] @@ -458,8 +469,18 @@ async fn since_line(lang: Lang, stamp: &str) -> Result { } #[component] -async fn health_view(lang: Lang, health: Health, alerts: Vec) -> Result { - let count = alerts.len(); +async fn health_view( + lang: Lang, + health: Health, + alerts: Vec, + total: usize, + page: u64, + pages: u64, + nav: (Vec, Option, Option), +) -> Result { + // The heading counts every active alert; the card lists the current page of them. + let count = total; + let (links, prev, next) = nav; let Health { usage, facts, @@ -474,7 +495,7 @@ async fn health_view(lang: Lang, health: Health, alerts: Vec) -> Resul at(lang, A::Fine).to_owned() }; Ok(view! { -
+

(at(lang, A::Health))

@@ -497,6 +518,7 @@ async fn health_view(lang: Lang, health: Health, alerts: Vec) -> Resul } + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) (alert_text::settings_link(lang))

} @@ -559,11 +581,30 @@ async fn health_page(cx: &Cx) -> Result { let viewer = admin_only(cx).await?; let lang = i18n::lang(cx, Some(&viewer.0)); let state = app_context::(cx); + let query = query_params::(cx)?; let health = gather(state, lang).await?; - let alerts = alert_rows(state, lang).await?; + let all = alert_rows(state, lang).await?; + let total = all.len(); + let pages = total.div_ceil(ALERTS_PER_PAGE).max(1); + let page = query + .page + .as_deref() + .and_then(|p| p.parse::().ok()) + .unwrap_or(1) + .clamp(1, pages); + let alerts: Vec = all + .into_iter() + .skip((page - 1) * ALERTS_PER_PAGE) + .take(ALERTS_PER_PAGE) + .collect(); + let nav = pager_links(page as u64, pages as u64, |n| { + format!("/admin/health?page={n}") + }); let title = at(lang, A::Health); Ok(view! { - shell(title: title, viewer: Some(&viewer), health_view(lang: lang, health: health, alerts: alerts)) + shell(title: title, viewer: Some(&viewer), + health_view(lang: lang, health: health, alerts: alerts, total: total, + page: page as u64, pages: pages as u64, nav: nav)) }) } diff --git a/crates/forge-web/src/pages/admin_mail.rs b/crates/forge-web/src/pages/admin_mail.rs index 33119cf..c4d9a18 100644 --- a/crates/forge-web/src/pages/admin_mail.rs +++ b/crates/forge-web/src/pages/admin_mail.rs @@ -245,7 +245,7 @@ async fn mail_view( // Saved by any admin session: the stream re-renders the settings with the same signal // as the queue (the save bumps it too), and the form keeps what was typed.
-
+

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

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

(g::t(lang, K::MailTransportInUse)) " " (data.transport)

@@ -279,7 +279,7 @@ async fn mail_view(
} else if let Some(queue) = data.queue { -
+

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

for chip in queue.chips.into_iter() { diff --git a/crates/forge-web/src/pages/admin_runners.rs b/crates/forge-web/src/pages/admin_runners.rs index e2cc99c..1c231ca 100644 --- a/crates/forge-web/src/pages/admin_runners.rs +++ b/crates/forge-web/src/pages/admin_runners.rs @@ -22,7 +22,7 @@ use topcoat::router::content::Form; use topcoat::router::error::{SeeOther, forbidden, see_other}; use topcoat::router::request::uri; use topcoat::router::response::Response; -use topcoat::router::{page, path_param, route}; +use topcoat::router::{page, path_param, query_params, route}; use topcoat::view::{View, component, view}; use crate::audit::{self, Actor, Target}; @@ -36,10 +36,21 @@ use crate::pages::admin_users::admin_only; use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; use crate::pages::repo_mirrors::stamp_in_tz; use crate::state::AppState; +use crate::views::repo_list::{PageLink, pager, pager_links}; use crate::views::{empty_state, enc, now_unix, relative_time, shell}; path_param!(runner_id); +/// Runners per page on the list. Six rows fit the window beside the "Add a runner" card. +const PER_PAGE: usize = 6; + +/// The list's query: the page, and the notice word that a paging link keeps. +#[query_params(error = bad_request)] +struct RunnersQuery { + page: Option, + notice: Option, +} + /// Picks the English or Turkish text. The runner page strings live here, not in `i18n::admin`. fn s(lang: Lang, en: &'static str, tr: &'static str) -> &'static str { match lang { @@ -315,9 +326,13 @@ async fn runners_view( lang: Lang, csrf: String, rows: Vec, + page: u64, + pages: u64, + nav: (Vec, Option, Option), notice: Option<(&'static str, bool)>, note: String, ) -> Result { + let (links, prev, next) = nav; Ok(view! {
@@ -330,13 +345,15 @@ async fn runners_view(
(text)
} } -
+
+

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

if rows.is_empty() { empty_state(title: g::t(lang, K::NoRunnersYet), hint: Some(g::t(lang, K::RunnersEmptyHint))) {
"forge runner register --url  --token  --name  --labels linux,x86_64"
} } else { +
    for row in rows.iter() {
  • @@ -390,9 +407,11 @@ async fn runners_view(
  • }
+
+ pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) }
-
+

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

(note.as_str())

@@ -401,9 +420,20 @@ async fn runners_view(
+
}) } +/// The list page's link for `page`, keeping the notice word a refused or saved action left in the +/// query, so paging does not lose it. +fn list_href(page: u64, notice: &str) -> String { + if notice.is_empty() { + format!("/admin/runners?page={page}") + } else { + format!("/admin/runners?page={page}¬ice={}", enc(notice)) + } +} + /// A destructive button that opens the shared `confirm-inline` popover; the POST only fires from the /// confirm button inside it, and Cancel closes the popover. #[component] @@ -600,25 +630,44 @@ async fn token_view( async fn runners_page(cx: &Cx) -> Result { let viewer = admin_only(cx).await?; let lang = i18n::lang(cx, Some(&viewer.0)); + let query = query_params::(cx)?; let state = app_context::(cx); let tz = viewer.0.timezone.clone(); let now = now_unix(); - let rows: Vec = state + let all: Vec = state .store .list_runners() .await? .iter() .map(|runner| runner_row(runner, &tz, lang, now)) .collect(); + let pages = all.len().div_ceil(PER_PAGE).max(1); + let page = query + .page + .as_deref() + .and_then(|p| p.parse::().ok()) + .unwrap_or(1) + .clamp(1, pages); + let rows: Vec = all + .into_iter() + .skip((page - 1) * PER_PAGE) + .take(PER_PAGE) + .collect(); let csrf = viewer.1.csrf_token.clone(); let notice = notice_from_query(cx, lang); + let kept = if notice.is_some() { + query.notice.clone().unwrap_or_default() + } else { + String::new() + }; + let nav = pager_links(page as u64, pages as u64, |n| list_href(n, &kept)); let note = g::token_ttl_note( lang, &g::hours_text(lang, state.live().ci.registration_token_hours), ); let title = g::t(lang, K::CiRunners); Ok(view! { - shell(title: title, viewer: Some(&viewer), runners_view(lang: lang, csrf: csrf, rows: rows, notice: notice, note: note)) + shell(title: title, viewer: Some(&viewer), runners_view(lang: lang, csrf: csrf, rows: rows, page: page as u64, pages: pages as u64, nav: nav, notice: notice, note: note)) }) } diff --git a/crates/forge-web/src/pages/admin_server.rs b/crates/forge-web/src/pages/admin_server.rs index 1d1f4e5..213c9e6 100644 --- a/crates/forge-web/src/pages/admin_server.rs +++ b/crates/forge-web/src/pages/admin_server.rs @@ -232,7 +232,7 @@ async fn server_view( _ => "/admin/server/events".to_owned(), }; Ok(view! { -
+

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

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

@@ -257,7 +257,7 @@ async fn server_view(

(message.as_str())

} -
+
diff --git a/crates/forge-web/src/pages/admin_user_detail.rs b/crates/forge-web/src/pages/admin_user_detail.rs index 4ea4de8..3b94236 100644 --- a/crates/forge-web/src/pages/admin_user_detail.rs +++ b/crates/forge-web/src/pages/admin_user_detail.rs @@ -157,7 +157,7 @@ async fn detail_body( let live = format!("{base}/events"); let Notice { done, error, link } = notice; Ok(view! { -
+
"← "(g::t(lang, K::Users))
diff --git a/crates/forge-web/src/pages/audit_log.rs b/crates/forge-web/src/pages/audit_log.rs index 60197dc..d321708 100644 --- a/crates/forge-web/src/pages/audit_log.rs +++ b/crates/forge-web/src/pages/audit_log.rs @@ -1,6 +1,7 @@ //! Pages: the admin audit log (`/admin/audit`, instance admins only, 404 otherwise) and a user's //! own security log (`/settings/security/log`: entries the viewer acted in, or that targeted -//! them). Both list newest first, 50 per page, continued with a cursor. +//! them). Both list newest first, a page of rows at a time, continued with a cursor: 8 rows on the +//! admin page (its filter bar takes the room) and 10 in the own log, sized to fit the window. use forge_core::{AuditAction, AuditCursor, AuditEntry, AuditFilter, Store}; use topcoat::Result; @@ -18,8 +19,11 @@ use crate::pages::issues_list::list_href; use crate::state::AppState; use crate::views::{empty_state, rel_time, shell}; -/// Entries per page. -const PAGE_SIZE: usize = 50; +/// Entries per page of the admin audit log, under its filter bar. +const ADMIN_PAGE_SIZE: usize = 8; + +/// Entries per page of the own security log. +const OWN_PAGE_SIZE: usize = 10; #[query_params(error = bad_request)] pub(crate) struct AuditQuery { @@ -67,18 +71,19 @@ fn row_view(entry: &AuditEntry, lang: Lang) -> RowView { } } -/// One page of entries, and the cursor for the page after it when there may be one. +/// One page of `size` entries, and the cursor for the page after it when there may be one. async fn fetch_page( store: &Store, filter: &AuditFilter, before: Option<&str>, + size: usize, ) -> forge_core::Result<(Vec, Option)> { let cursor = before.and_then(AuditCursor::decode); let mut entries = store - .list_audit(filter, cursor.as_ref(), (PAGE_SIZE + 1) as u32) + .list_audit(filter, cursor.as_ref(), (size + 1) as u32) .await?; - let more = entries.len() > PAGE_SIZE; - entries.truncate(PAGE_SIZE); + let more = entries.len() > size; + entries.truncate(size); let next = if more { entries .last() @@ -168,7 +173,7 @@ async fn admin_audit_view(

(message.as_str())

} -
+
audit_table(lang: lang, rows: rows, show_actor: true) if let Some(href) = older_href {
-
+
audit_table(lang: lang, rows: rows, show_actor: false) if let Some(href) = older_href {
-
+
(size)
-
+

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

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

if truncated { @@ -411,6 +412,7 @@ async fn job_body(
}
+
}) } diff --git a/crates/forge-web/src/pages/commit.rs b/crates/forge-web/src/pages/commit.rs index 670764c..e693185 100644 --- a/crates/forge-web/src/pages/commit.rs +++ b/crates/forge-web/src/pages/commit.rs @@ -314,7 +314,9 @@ async fn commit_page(cx: &Cx) -> Result { if has_body {
(message.as_str())
} - diff_section(diff: &diff, owner: owner_name.as_str(), repo: repo_name.as_str(), oid: info.oid.as_str(), parent: parent.as_deref(), subject: g::t(lang, K::ThisCommit), lang: DiffLang(lang), opts: opts) +
+ diff_section(diff: &diff, owner: owner_name.as_str(), repo: repo_name.as_str(), oid: info.oid.as_str(), parent: parent.as_deref(), subject: g::t(lang, K::ThisCommit), lang: DiffLang(lang), opts: opts) +
) }) } diff --git a/crates/forge-web/src/pages/discussion_view.rs b/crates/forge-web/src/pages/discussion_view.rs index 16f644b..96984b6 100644 --- a/crates/forge-web/src/pages/discussion_view.rs +++ b/crates/forge-web/src/pages/discussion_view.rs @@ -421,7 +421,7 @@ async fn discussion_page(

-
+
diff --git a/crates/forge-web/src/pages/import.rs b/crates/forge-web/src/pages/import.rs index b6e1f07..10ff395 100644 --- a/crates/forge-web/src/pages/import.rs +++ b/crates/forge-web/src/pages/import.rs @@ -319,11 +319,10 @@ async fn import_form( let private = draft.private; let opts = draft.opts; Ok(view! { - newrepo_tabs(lang: lang, active: "import") if let Some(message) = error { alert(message: message.as_str()) } - + csrf_field(token: csrf)
@@ -401,7 +400,7 @@ async fn import_form( /// How many imports the Import tab lists under the form. const RECENT_IMPORTS: usize = 5; -/// The GET import page: the form, then the recent imports. +/// The GET import page: the tabs, then the form and the recent imports side by side on wide windows. #[component] async fn import_home( lang: Lang, @@ -412,8 +411,28 @@ async fn import_home( more: bool, ) -> Result { Ok(view! { - import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners) - recent_imports(lang: lang, jobs: jobs, more: more) + newrepo_tabs(lang: lang, active: "import") +
+ import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners) + recent_imports(lang: lang, jobs: jobs, more: more) +
+ }) +} + +/// The import form again after a rejected submit: the tabs, then the form. +#[component] +async fn import_error_body( + lang: Lang, + csrf: String, + draft: Draft, + error: String, + owners: Vec, +) -> Result { + Ok(view! { + newrepo_tabs(lang: lang, active: "import") +
+ import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(error), owners: owners) +
}) } @@ -449,7 +468,7 @@ async fn import_submit(cx: &Cx, Form(form): Form) -> Result shell(title: g::t(lang, K::ImportTitle), viewer: Some(&viewer), - import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(message), owners: owners)) + import_error_body(lang: lang, csrf: csrf, draft: draft, error: message, owners: owners)) }) } } @@ -1084,7 +1103,7 @@ async fn recent_imports( let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); Ok(view! { if !empty { -
+

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

job_rows(lang: lang, jobs: jobs) if more || retry { diff --git a/crates/forge-web/src/pages/issue_view.rs b/crates/forge-web/src/pages/issue_view.rs index 1abb6a3..973d6f3 100644 --- a/crates/forge-web/src/pages/issue_view.rs +++ b/crates/forge-web/src/pages/issue_view.rs @@ -106,7 +106,7 @@ async fn issue_page(

-
+
discussion_timeline(lang: lang, discussion: discussion) if can_comment { comment_form(lang: lang, action: comment_action.clone(), state_action: comment_action.clone(), @@ -121,7 +121,7 @@ async fn issue_page(

(g::comment_login_lead(lang))(g::t(lang, K::LogInLink))(g::t(lang, K::ToComment))

}
-