From 2596bea3292bf5f8655eb286f7961c8a780df03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 31 Oct 2026 03:31:51 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20the=20sidebar=20links=20to?= =?UTF-8?q?=20New=20organization=20for=20those=20the=20instance=20lets=20c?= =?UTF-8?q?reate=20one;=20commit=20pages,=20the=20commit=20list=20and=20co?= =?UTF-8?q?mpare=20show=20the=20email=20stored=20in=20git=20next=20to=20th?= =?UTF-8?q?e=20name;=20the=20bell's=20popover=20lists=20unread=20notificat?= =?UTF-8?q?ions=20only=20and=20has=20a=20Clear=20action=20that=20marks=20a?= =?UTF-8?q?ll=20read,=20with=20Open=20notifications=20as=20a=20full-width?= =?UTF-8?q?=20footer;=20=F0=9F=90=9B=20fix:=20the=20error=20box=20above=20?= =?UTF-8?q?the=20new=20repo=20and=20import=20forms=20matches=20their=20wid?= =?UTF-8?q?th,=20and=20the=20importer's=20rate=20limit=20message=20says=20?= =?UTF-8?q?the=20wait=20in=20minutes=20and=20hours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-web/src/i18n/misc.rs | 4 ++ crates/forge-web/src/importer/api.rs | 27 +++++++++++++- crates/forge-web/src/pages/ci_tests.rs | 2 +- crates/forge-web/src/pages/commit.rs | 15 +++++++- crates/forge-web/src/pages/commits.rs | 5 +++ crates/forge-web/src/pages/compare.rs | 3 ++ crates/forge-web/src/pages/notifications.rs | 41 ++++----------------- crates/forge-web/src/pages/org_new.rs | 2 +- crates/forge-web/src/views/mod.rs | 34 ++++++++++++++--- crates/forge-web/tests/e2e/orgs_ui_e2e.rs | 16 ++++++++ style/_import.scss | 4 ++ style/_repo.scss | 5 +++ style/_shell.scss | 23 ++++++++++-- 13 files changed, 135 insertions(+), 46 deletions(-) diff --git a/crates/forge-web/src/i18n/misc.rs b/crates/forge-web/src/i18n/misc.rs index 83e6bba..1aa1c52 100644 --- a/crates/forge-web/src/i18n/misc.rs +++ b/crates/forge-web/src/i18n/misc.rs @@ -88,6 +88,7 @@ pub enum K { // Notifications: inbox page. MarkAllAsRead, MarkAllRead, + ClearNotifications, MarkRead, NoNotificationsYet, NoUnreadNotifications, @@ -256,6 +257,7 @@ const ALL: &[K] = &[ K::NotReceivingThread, K::MarkAllAsRead, K::MarkAllRead, + K::ClearNotifications, K::MarkRead, K::NoNotificationsYet, K::NoUnreadNotifications, @@ -492,6 +494,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", (MarkRead, En) => "Mark read", (MarkRead, Tr) => "Okundu işaretle", (NoNotificationsYet, En) => "No notifications yet.", diff --git a/crates/forge-web/src/importer/api.rs b/crates/forge-web/src/importer/api.rs index 6b88f24..c9f4093 100644 --- a/crates/forge-web/src/importer/api.rs +++ b/crates/forge-web/src/importer/api.rs @@ -48,7 +48,8 @@ impl fmt::Display for ApiError { ApiError::Unauthorized(what) => write!(f, "access denied: {what}"), ApiError::RateLimited { wait_secs } => write!( f, - "the rate limit is used up and resets in {wait_secs} seconds; retry then, nothing imported is lost" + "the rate limit is used up and resets in {}; retry then, nothing imported is lost", + wait_text(*wait_secs) ), ApiError::TooLarge => write!(f, "the file is larger than the allowed size"), ApiError::Http(msg) => write!(f, "request failed: {msg}"), @@ -57,6 +58,21 @@ impl fmt::Display for ApiError { } } +/// `secs` as a reader would say it, rounded up to the minute so a retry at that time is not early. +fn wait_text(secs: u64) -> String { + let plural = |n: u64| if n == 1 { "" } else { "s" }; + if secs < 60 { + return format!("{secs} second{}", plural(secs)); + } + let minutes = secs.div_ceil(60); + let (hours, rest) = (minutes / 60, minutes % 60); + match (hours, rest) { + (0, m) => format!("{m} minute{}", plural(m)), + (h, 0) => format!("{h} hour{}", plural(h)), + (h, m) => format!("{h} hour{} {m} minute{}", plural(h), plural(m)), + } +} + pub type ApiResult = Result; #[derive(Debug, Clone, PartialEq, Eq, Default)] @@ -1427,6 +1443,15 @@ mod tests { assert!(valid_path("grp/sub/proj", 2, 20)); } + #[test] + fn wait_text_reads_naturally() { + assert_eq!(wait_text(45), "45 seconds"); + assert_eq!(wait_text(60), "1 minute"); + assert_eq!(wait_text(3188), "54 minutes"); + assert_eq!(wait_text(3600), "1 hour"); + assert_eq!(wait_text(3661), "1 hour 2 minutes"); + } + #[test] fn rate_limit_waits_follow_the_headers() { assert_eq!(rate_wait(Some("30"), None, None, 100), Some(30)); diff --git a/crates/forge-web/src/pages/ci_tests.rs b/crates/forge-web/src/pages/ci_tests.rs index 4016110..e20603b 100644 --- a/crates/forge-web/src/pages/ci_tests.rs +++ b/crates/forge-web/src/pages/ci_tests.rs @@ -752,7 +752,7 @@ async fn job_page_log_tail() { assert!(!text.contains("HEAD-MARK")); assert!(text.contains("Showing the last 512 KiB")); assert!( - page.body.len() < 530 * 1024, + page.body.len() < 540 * 1024, "page is {} bytes", page.body.len() ); diff --git a/crates/forge-web/src/pages/commit.rs b/crates/forge-web/src/pages/commit.rs index 5b28ab7..7fe8a57 100644 --- a/crates/forge-web/src/pages/commit.rs +++ b/crates/forge-web/src/pages/commit.rs @@ -31,6 +31,7 @@ path_param!(oid); /// Author, committer or parent line data. struct Person { name: String, + email: String, relative: String, absolute: String, iso: String, @@ -145,6 +146,7 @@ async fn commit_page(cx: &Cx) -> Result { let now = now_secs(); let author = Person { name: info.author_name.clone(), + email: info.author_email.clone(), relative: relative_time(lang, info.author_time, now), absolute: format_in_tz(info.author_time, &tz), iso: iso_time(info.author_time), @@ -153,6 +155,7 @@ async fn commit_page(cx: &Cx) -> Result { info.committer_name != info.author_name || info.committer_email != info.author_email; let committer = Person { name: info.committer_name.clone(), + email: info.committer_email.clone(), relative: relative_time(lang, info.committer_time, now), absolute: format_in_tz(info.committer_time, &tz), iso: iso_time(info.committer_time), @@ -225,6 +228,8 @@ async fn commit_page(cx: &Cx) -> Result { }; 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) @@ -244,6 +249,9 @@ async fn commit_page(cx: &Cx) -> Result { checks_summary(summary: summary, lang: StatusLang(lang)) }
(g::t(lang, K::AuthorLabel)) (author.name.as_str()) + if !author.email.is_empty() { + " " (author.email.as_str()) + } if has_coauthors { (g::t(lang, K::CoAuthorAnd)) for c in coauthors.iter() { @@ -285,7 +293,11 @@ async fn commit_page(cx: &Cx) -> Result { " · "
if committer_differs { -

(g::t(lang, K::CommitterLabel)) (committer.name.as_str()) " · "

+

(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))

@@ -357,6 +369,7 @@ mod tests { ) .await; assert_eq!(status, 200); + assert!(String::from_utf8_lossy(&body).contains("tester@example.com")); let html = doc(&body); let rows = rows(&html, "tr.diff-line"); diff --git a/crates/forge-web/src/pages/commits.rs b/crates/forge-web/src/pages/commits.rs index c78b3e1..7dfa0ee 100644 --- a/crates/forge-web/src/pages/commits.rs +++ b/crates/forge-web/src/pages/commits.rs @@ -107,6 +107,7 @@ pub(crate) fn short_oid(oid: &str) -> &str { pub(crate) struct CommitRow { pub summary: String, pub author: String, + pub email: String, pub commit_href: String, pub tree_href: String, pub short: String, @@ -156,6 +157,7 @@ impl CommitRow { Self { summary: emojify(&info.summary).into_owned(), author: info.author_name.clone(), + email: info.author_email.clone(), commit_href: format!("/{owner}/{repo}/commit/{}", info.oid), tree_href: format!("/{owner}/{repo}/tree/{}", info.oid), short: short_oid(&info.oid).to_owned(), @@ -299,6 +301,9 @@ async fn commits_page(cx: &Cx) -> Result { (row.summary.as_str())
(row.author.as_str()) + if !row.email.is_empty() { + (row.email.as_str()) + } if lang == Lang::Tr { (g::t(lang, K::Committed)) diff --git a/crates/forge-web/src/pages/compare.rs b/crates/forge-web/src/pages/compare.rs index 2edc588..1b3ecb3 100644 --- a/crates/forge-web/src/pages/compare.rs +++ b/crates/forge-web/src/pages/compare.rs @@ -348,6 +348,9 @@ async fn compare_view( (row.summary.as_str())
(row.author.as_str()) + if !row.email.is_empty() { + (row.email.as_str()) + } if lang == i18n::Lang::Tr { (g::t(lang, K::Committed)) diff --git a/crates/forge-web/src/pages/notifications.rs b/crates/forge-web/src/pages/notifications.rs index 3ced06b..c4bd312 100644 --- a/crates/forge-web/src/pages/notifications.rs +++ b/crates/forge-web/src/pages/notifications.rs @@ -149,15 +149,6 @@ impl Entry { } } - fn unread(&self) -> bool { - match self { - Entry::Issue(note) => note.unread, - Entry::Discussion(note) => note.unread, - Entry::Advisory(note) => note.unread, - Entry::Admin(note) => note.unread, - } - } - fn updated_at(&self) -> &str { match self { Entry::Issue(note) => ¬e.updated_at, @@ -373,26 +364,12 @@ async fn list_entries( Ok(entries) } -/// The bell's popover rows: the viewer's newest entries, unread ones first, then read ones, each -/// newest first. Entries the viewer can no longer read are left out and stay as they are. +/// 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?; - // Under PEEK_SIZE unread entries in all, every list was read to its end, so none is missing; - // the read ones come from the newest of each list. - if entries.len() < PEEK_SIZE as usize { - entries.extend( - list_entries(state, user, false, PEEK_SIZE) - .await? - .into_iter() - .filter(|entry| !entry.unread()), - ); - } - entries.sort_by(|a, b| { - b.unread() - .cmp(&a.unread()) - .then_with(|| b.updated_at().cmp(a.updated_at())) - }); + 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 { @@ -569,7 +546,7 @@ async fn inbox(cx: &Cx) -> Result { }) } -/// `GET /notifications/peek`: the bell's popover, the viewer's newest notifications as an HTML +/// `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 { @@ -585,8 +562,8 @@ async fn peek(cx: &Cx) -> Result { fragment.first().await?.into_response(cx) } -/// The bell's popover list: each row opens through its open route, which marks it read. An empty -/// list says the viewer is all caught up. +/// 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(); @@ -598,11 +575,7 @@ async fn peek_list(lang: Lang, rows: Vec) -> Result { for row in rows.into_iter() {
  • - if row.unread { - - } else { - - } + (row.title_line.as_str()) diff --git a/crates/forge-web/src/pages/org_new.rs b/crates/forge-web/src/pages/org_new.rs index 7c349f2..8d6f4a6 100644 --- a/crates/forge-web/src/pages/org_new.rs +++ b/crates/forge-web/src/pages/org_new.rs @@ -33,7 +33,7 @@ struct NewOrgForm { } /// Whether `user` may create an organization under the instance's policy. -fn may_create_org(state: &AppState, user: &User) -> bool { +pub(crate) fn may_create_org(state: &AppState, user: &User) -> bool { match state.live().orgs.creation { OrgCreation::All => true, OrgCreation::Admin => user.is_admin, diff --git a/crates/forge-web/src/views/mod.rs b/crates/forge-web/src/views/mod.rs index 67c33fc..f631915 100644 --- a/crates/forge-web/src/views/mod.rs +++ b/crates/forge-web/src/views/mod.rs @@ -105,9 +105,12 @@ struct SideRepo { href: String, } -/// The global nav item for a request path: `dashboard` for `/`, otherwise the first segment when -/// it is a global page. Empty for repo pages and everything else. +/// The global nav item for a request path: `dashboard` for `/`, `new-org` for `/org/new`, otherwise +/// the first segment when it is a global page. Empty for repo pages and everything else. fn nav_key(path: &str) -> &'static str { + if path.trim_matches('/') == "org/new" { + return "new-org"; + } match path.trim_matches('/').split('/').next().unwrap_or("") { "" => "dashboard", "explore" => "explore", @@ -357,6 +360,8 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result let logout_label = t(lang, Key::LogOut); let bell_title = i18n::t(lang, Key::Notifications); let open_label = mi::t(lang, MK::OpenNotifications); + let clear_label = mi::t(lang, MK::ClearNotifications); + let clear_title = mi::t(lang, MK::MarkAllRead); let loading_label = mi::t(lang, MK::PeekLoading); let error_label = mi::t(lang, MK::PeekError); Ok(view! { @@ -407,7 +412,13 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result