From fd174b4fb40c988564507486ee5e8f624a9f9a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 2 Nov 2026 13:00:35 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20the=20decided=20One=20P?= =?UTF-8?q?age=20design=20now=20covers=20the=20whole=20app:=20every=20butt?= =?UTF-8?q?on,=20field,=20choice=20row,=20dropdown,=20popover=20and=20menu?= =?UTF-8?q?=20shares=20one=20kit=20(38px=20fields,=2032px=20small=20button?= =?UTF-8?q?s=20and=20choices,=20280px=20inputs,=20560px=20text=20areas,=20?= =?UTF-8?q?130px=20label=20column,=2020px=20menus=20with=2034px=20rows),?= =?UTF-8?q?=20every=20page=20is=20one=20narrow=20column=20of=20head,=20tab?= =?UTF-8?q?s,=20sheet=20and=20quiet=20text=20actions=20under=20what=20they?= =?UTF-8?q?=20act=20on,=20and=20docs/ui-language.md=20holds=20the=20rules;?= =?UTF-8?q?=20the=20four=20older=20style=20layers=20are=20gone=20in=20favo?= =?UTF-8?q?ur=20of=20style/=5Fone*.scss;=20Ember=20on=20Anvil=20is=20the?= =?UTF-8?q?=20default=20look,=20and=20accounts=20that=20never=20chose=20co?= =?UTF-8?q?lours=20move=20with=20it;=20settings=20Keys=20shows=20one=20kin?= =?UTF-8?q?d=20at=20a=20time=20with=20SSH,=20GPG=20and=20tokens=20at=20the?= =?UTF-8?q?ir=20own=20addresses;=20run=20alerts=20are=20one=20row;=20issue?= =?UTF-8?q?=20and=20pull=20lists=20share=20one=20row=20with=20the=20tick?= =?UTF-8?q?=20beside=20the=20title=20on=20a=20phone;=20a=20pull's=20state?= =?UTF-8?q?=20badge=20has=20the=20colours=20of=20an=20issue's;=20the=20CI?= =?UTF-8?q?=20list=20opens=20each=20run=20on=20its=20own=20page=20and=20ma?= =?UTF-8?q?rks=20none=20as=20current;=20a=20queued=20job=20says=20No=20out?= =?UTF-8?q?put=20yet;=20the=20review=20panel=20offers=20Approve=20and=20Re?= =?UTF-8?q?quest=20changes=20only=20to=20people=20who=20are=20not=20the=20?= =?UTF-8?q?pull's=20author,=20and=20Discard=20only=20when=20something=20is?= =?UTF-8?q?=20pending=20=E2=9C=A8=20feat:=20a=20page=20you=20may=20not=20o?= =?UTF-8?q?pen=20shows=20a=20styled=20Not=20allowed=20page,=20and=20a=20si?= =?UTF-8?q?gned-out=20visitor=20is=20sent=20to=20log=20in=20and=20back;=20?= =?UTF-8?q?the=20login=20page=20links=20to=20Forgot=20password=20and,=20wh?= =?UTF-8?q?en=20sign-up=20is=20open,=20Create=20an=20account=20?= =?UTF-8?q?=F0=9F=90=9B=20fix:=20admin=20and=20settings=20styles=20no=20lo?= =?UTF-8?q?nger=20key=20on=20English=20labels,=20so=20Turkish=20pages=20ke?= =?UTF-8?q?ep=20their=20layout;=20Turkish=20health=20uptime,=20server=20se?= =?UTF-8?q?tting=20options,=20session=20device=20names=20and=20read-only?= =?UTF-8?q?=20hints=20are=20translated;=20health=20counts=20active=20alert?= =?UTF-8?q?s;=20an=20empty=20repo=20no=20longer=20shows=20a=20Branches=20h?= =?UTF-8?q?eading=20=E2=9C=85=20test:=20scripts/audit/mock.py=20fills=20ru?= =?UTF-8?q?nners,=20CI=20history=20and=20graphs,=20scripts/audit/paths.py?= =?UTF-8?q?=20lists=20every=20page,=20and=20seven=20measured=20passes=20(l?= =?UTF-8?q?ight,=20dark,=20Turkish,=20signed=20out,=20panels=20open,=20390?= =?UTF-8?q?=20to=202560=20wide)=20end=20with=20no=20problems?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0072_ember_anvil_default.sql | 19 + crates/forge-core/src/model.rs | 8 +- crates/forge-core/src/server_settings.rs | 2 +- crates/forge-core/src/store/migrate.rs | 1 + crates/forge-core/src/store/ui_prefs.rs | 4 +- crates/forge-e2e/tests/e2e/browse_e2e.rs | 27 +- crates/forge-e2e/tests/e2e/ci_e2e.rs | 4 +- .../forge-e2e/tests/e2e/community_i18n_e2e.rs | 4 +- crates/forge-e2e/tests/e2e/i18n_e2e.rs | 2 +- crates/forge-e2e/tests/e2e/pulls_e2e.rs | 2 +- crates/forge-e2e/tests/e2e/section_nav_e2e.rs | 5 +- crates/forge-e2e/tests/e2e/ui_prefs_e2e.rs | 9 +- crates/forge-web-base/src/accent.rs | 7 +- crates/forge-web-base/src/accent_palette.rs | 124 +- crates/forge-web-base/src/i18n/accounts.rs | 15 + crates/forge-web-base/src/i18n/admin.rs | 4 +- crates/forge-web-base/src/i18n/releases_ci.rs | 4 +- .../src/i18n/server_settings.rs | 2 +- crates/forge-web/assets/nav.js | 420 +-- crates/forge-web/src/pages/admin_backups.rs | 36 +- crates/forge-web/src/pages/admin_health.rs | 186 +- crates/forge-web/src/pages/admin_mail.rs | 30 +- .../forge-web/src/pages/admin_replication.rs | 16 +- crates/forge-web/src/pages/admin_runners.rs | 514 ++- crates/forge-web/src/pages/admin_server.rs | 168 +- .../forge-web/src/pages/admin_user_detail.rs | 44 +- crates/forge-web/src/pages/admin_users.rs | 209 +- crates/forge-web/src/pages/audit_log.rs | 124 +- crates/forge-web/src/pages/blame.rs | 44 +- crates/forge-web/src/pages/blob.rs | 141 +- crates/forge-web/src/pages/branches.rs | 21 +- crates/forge-web/src/pages/ci_estimate.rs | 13 - crates/forge-web/src/pages/ci_fail.rs | 158 +- crates/forge-web/src/pages/ci_job.rs | 160 +- crates/forge-web/src/pages/ci_runs.rs | 780 ++--- crates/forge-web/src/pages/ci_tests.rs | 32 +- crates/forge-web/src/pages/code_search.rs | 97 +- crates/forge-web/src/pages/commit.rs | 179 +- crates/forge-web/src/pages/commits.rs | 134 +- crates/forge-web/src/pages/compare.rs | 133 +- .../src/pages/discussion_settings.rs | 4 +- crates/forge-web/src/pages/discussion_view.rs | 60 +- crates/forge-web/src/pages/discussions.rs | 129 +- crates/forge-web/src/pages/edit_history.rs | 31 +- crates/forge-web/src/pages/explore.rs | 32 +- crates/forge-web/src/pages/forgot.rs | 26 +- crates/forge-web/src/pages/home.rs | 17 +- crates/forge-web/src/pages/import.rs | 420 +-- crates/forge-web/src/pages/invites.rs | 46 +- crates/forge-web/src/pages/issue_meta.rs | 13 +- crates/forge-web/src/pages/issue_parts.rs | 156 +- crates/forge-web/src/pages/issue_pin.rs | 14 +- crates/forge-web/src/pages/issue_view.rs | 95 +- crates/forge-web/src/pages/issues_list.rs | 326 +- crates/forge-web/src/pages/labels_page.rs | 13 +- crates/forge-web/src/pages/login.rs | 29 +- crates/forge-web/src/pages/merge_queue.rs | 94 +- crates/forge-web/src/pages/milestones_page.rs | 44 +- crates/forge-web/src/pages/needs_you.rs | 59 +- crates/forge-web/src/pages/new_repo.rs | 122 +- crates/forge-web/src/pages/not_found_page.rs | 85 +- crates/forge-web/src/pages/notifications.rs | 101 +- crates/forge-web/src/pages/org_members.rs | 147 +- crates/forge-web/src/pages/org_new.rs | 36 +- crates/forge-web/src/pages/org_settings.rs | 16 +- crates/forge-web/src/pages/org_teams.rs | 261 +- crates/forge-web/src/pages/packages.rs | 85 +- crates/forge-web/src/pages/packages_oci.rs | 22 +- crates/forge-web/src/pages/passkeys.rs | 48 +- crates/forge-web/src/pages/profile.rs | 179 +- crates/forge-web/src/pages/profile_pins.rs | 4 +- crates/forge-web/src/pages/pull_branch.rs | 12 +- crates/forge-web/src/pages/pull_files.rs | 434 ++- crates/forge-web/src/pages/pull_reviews.rs | 23 +- crates/forge-web/src/pages/pull_view.rs | 172 +- crates/forge-web/src/pages/pulls_list.rs | 269 +- crates/forge-web/src/pages/refs.rs | 8 +- crates/forge-web/src/pages/register.rs | 32 +- crates/forge-web/src/pages/releases.rs | 299 +- crates/forge-web/src/pages/releases_tests.rs | 4 +- crates/forge-web/src/pages/repo.rs | 299 +- .../forge-web/src/pages/repo_collaborators.rs | 5 +- crates/forge-web/src/pages/repo_ctx.rs | 34 +- crates/forge-web/src/pages/repo_mirrors.rs | 22 +- crates/forge-web/src/pages/repo_rename.rs | 4 +- crates/forge-web/src/pages/repo_scrub.rs | 24 +- crates/forge-web/src/pages/repo_secrets.rs | 6 +- crates/forge-web/src/pages/repo_security.rs | 70 +- crates/forge-web/src/pages/repo_settings.rs | 130 +- crates/forge-web/src/pages/repo_side.rs | 375 +-- crates/forge-web/src/pages/repo_transfer.rs | 54 +- crates/forge-web/src/pages/repo_webhooks.rs | 76 +- crates/forge-web/src/pages/review_requests.rs | 54 +- .../src/pages/settings_appearance.rs | 112 +- crates/forge-web/src/pages/settings_export.rs | 17 +- crates/forge-web/src/pages/settings_gpg.rs | 101 +- .../forge-web/src/pages/settings_gpg_tests.rs | 14 +- crates/forge-web/src/pages/settings_keys.rs | 199 +- .../src/pages/settings_notifications.rs | 141 +- .../forge-web/src/pages/settings_profile.rs | 7 +- .../forge-web/src/pages/settings_security.rs | 93 +- .../forge-web/src/pages/settings_sessions.rs | 39 +- crates/forge-web/src/pages/settings_tokens.rs | 141 +- crates/forge-web/src/pages/setup.rs | 8 +- crates/forge-web/src/pages/snippets.rs | 132 +- crates/forge-web/src/pages/tree.rs | 200 +- crates/forge-web/src/pages/user_prefs.rs | 66 +- crates/forge-web/src/pages/wiki.rs | 218 +- crates/forge-web/src/views/commit_line.rs | 11 - crates/forge-web/src/views/commit_status.rs | 6 +- crates/forge-web/src/views/diff.rs | 52 +- crates/forge-web/src/views/mod.rs | 282 +- crates/forge-web/src/views/parts.rs | 155 +- crates/forge-web/src/views/repo_list.rs | 8 +- crates/forge-web/src/views/review_thread.rs | 173 +- crates/forge-web/src/views/timeline.rs | 2 +- crates/forge-web/src/web_push/mod.rs | 15 +- docs/ui-language.md | 133 + scripts/audit/measure.ts | 167 +- scripts/audit/mock.py | 194 ++ scripts/audit/paths.py | 21 + scripts/audit/run.sh | 4 + style/_admin_rows.scss | 12 +- style/_alive_head.scss | 83 - style/_alive_heat.scss | 47 - style/_alive_issue.scss | 8 - style/_alive_lists.scss | 26 - style/_alive_motion.scss | 92 - style/_alive_scrub.scss | 61 - style/_alive_settings.scss | 189 -- style/_authoring.scss | 2 +- style/_browse.scss | 9 - style/_canvas.scss | 103 - style/_canvas_account.scss | 28 - style/_canvas_ci.scss | 110 - style/_canvas_commits.scss | 17 - style/_canvas_detail.scss | 192 -- style/_canvas_lists.scss | 282 -- style/_canvas_pull.scss | 402 --- style/_canvas_repo.scss | 608 ---- style/_fit.scss | 11 - style/_fit_admin.scss | 38 - style/_fit_code.scss | 53 - style/_fit_forms.scss | 64 - style/_fit_lists.scss | 4 - style/_fit_settings.scss | 10 - style/_fit_tables.scss | 5 - style/_fit_threads.scss | 17 - style/_kb_rerun.scss | 44 +- style/_lang_admin.scss | 78 - style/_lang_browse.scss | 49 - style/_lang_ci.scss | 132 - style/_lang_issues.scss | 266 -- style/_lang_lists.scss | 42 - style/_lang_people.scss | 91 - style/_language.scss | 5 - style/_look.scss | 12 +- style/_min.scss | 5 +- style/_min_menus.scss | 41 + style/_one.scss | 2932 +++++++++++++++++ style/_one_admin.scss | 217 ++ style/_one_ci.scss | 250 ++ style/_one_code.scss | 198 ++ style/_one_people.scss | 307 ++ style/_one_review.scss | 147 + style/_one_shell.scss | 259 ++ style/_one_threads.scss | 304 ++ style/_pull.scss | 2 +- style/_system.scss | 614 ---- style/main.scss | 158 +- 170 files changed, 10662 insertions(+), 9677 deletions(-) create mode 100644 crates/forge-core/migrations/0072_ember_anvil_default.sql create mode 100644 docs/ui-language.md create mode 100644 scripts/audit/mock.py create mode 100644 scripts/audit/paths.py delete mode 100644 style/_alive_head.scss delete mode 100644 style/_alive_heat.scss delete mode 100644 style/_alive_issue.scss delete mode 100644 style/_alive_lists.scss delete mode 100644 style/_alive_motion.scss delete mode 100644 style/_alive_scrub.scss delete mode 100644 style/_alive_settings.scss delete mode 100644 style/_canvas.scss delete mode 100644 style/_canvas_account.scss delete mode 100644 style/_canvas_ci.scss delete mode 100644 style/_canvas_commits.scss delete mode 100644 style/_canvas_detail.scss delete mode 100644 style/_canvas_lists.scss delete mode 100644 style/_canvas_pull.scss delete mode 100644 style/_canvas_repo.scss delete mode 100644 style/_fit.scss delete mode 100644 style/_fit_admin.scss delete mode 100644 style/_fit_code.scss delete mode 100644 style/_fit_forms.scss delete mode 100644 style/_fit_lists.scss delete mode 100644 style/_fit_settings.scss delete mode 100644 style/_fit_tables.scss delete mode 100644 style/_fit_threads.scss delete mode 100644 style/_lang_admin.scss delete mode 100644 style/_lang_browse.scss delete mode 100644 style/_lang_ci.scss delete mode 100644 style/_lang_issues.scss delete mode 100644 style/_lang_lists.scss delete mode 100644 style/_lang_people.scss delete mode 100644 style/_language.scss create mode 100644 style/_one.scss create mode 100644 style/_one_admin.scss create mode 100644 style/_one_ci.scss create mode 100644 style/_one_code.scss create mode 100644 style/_one_people.scss create mode 100644 style/_one_review.scss create mode 100644 style/_one_shell.scss create mode 100644 style/_one_threads.scss delete mode 100644 style/_system.scss diff --git a/crates/forge-core/migrations/0072_ember_anvil_default.sql b/crates/forge-core/migrations/0072_ember_anvil_default.sql new file mode 100644 index 0000000..1654c5f --- /dev/null +++ b/crates/forge-core/migrations/0072_ember_anvil_default.sql @@ -0,0 +1,19 @@ +-- Ember on Anvil becomes the look of a new account. An account that never chose its colours moves +-- with the default; one that chose keeps its choice. SQLite cannot change a column's default in +-- place, so each column is replaced. +ALTER TABLE users RENAME COLUMN accent TO accent_old; +ALTER TABLE users RENAME COLUMN accent_dark TO accent_dark_old; +ALTER TABLE users RENAME COLUMN base_light TO base_light_old; +ALTER TABLE users RENAME COLUMN base_dark TO base_dark_old; +ALTER TABLE users ADD COLUMN accent TEXT NOT NULL DEFAULT 'ember'; +ALTER TABLE users ADD COLUMN accent_dark TEXT NOT NULL DEFAULT 'ember'; +ALTER TABLE users ADD COLUMN base_light TEXT NOT NULL DEFAULT 'anvil'; +ALTER TABLE users ADD COLUMN base_dark TEXT NOT NULL DEFAULT 'anvil'; +UPDATE users SET accent = accent_old, accent_dark = accent_dark_old, + base_light = base_light_old, base_dark = base_dark_old +WHERE NOT (accent_old = 'sage' AND accent_dark_old = 'sage' + AND base_light_old = 'fern' AND base_dark_old = 'fern'); +ALTER TABLE users DROP COLUMN accent_old; +ALTER TABLE users DROP COLUMN accent_dark_old; +ALTER TABLE users DROP COLUMN base_light_old; +ALTER TABLE users DROP COLUMN base_dark_old; diff --git a/crates/forge-core/src/model.rs b/crates/forge-core/src/model.rs index 84cfb5a..644034d 100644 --- a/crates/forge-core/src/model.rs +++ b/crates/forge-core/src/model.rs @@ -48,13 +48,13 @@ pub struct User { /// Language code, e.g. "en"; "auto" uses the instance default. pub language: String, /// Accent colour for the light theme: the id of a palette in forge-web's `accent_palette.rs`. - /// "sage" is the default. + /// "ember" is the default. pub accent: String, - /// Accent colour for the dark theme, chosen separately from `accent`. "sage" is the default. + /// Accent colour for the dark theme, chosen separately from `accent`. "ember" is the default. pub accent_dark: String, - /// Base (neutral background, surface and text) set for the light theme. "fern" is the default. + /// Base (neutral background, surface and text) set for the light theme. "anvil" is the default. pub base_light: String, - /// Base set for the dark theme. "fern" is the default. + /// Base set for the dark theme. "anvil" is the default. pub base_dark: String, /// Which side the main shell sidebar sits on: "left" (the default) or "right". pub sidebar_side: String, diff --git a/crates/forge-core/src/server_settings.rs b/crates/forge-core/src/server_settings.rs index e5f1f15..e9d11e8 100644 --- a/crates/forge-core/src/server_settings.rs +++ b/crates/forge-core/src/server_settings.rs @@ -164,7 +164,7 @@ pub static FIELDS: &[Field] = &[ L, Ty::Choice(BANNER_LEVEL), "Banner level", - "info or warning.", + "Info or warning.", ), f( "banner.expires", diff --git a/crates/forge-core/src/store/migrate.rs b/crates/forge-core/src/store/migrate.rs index 0edfbdb..dba7b03 100644 --- a/crates/forge-core/src/store/migrate.rs +++ b/crates/forge-core/src/store/migrate.rs @@ -117,6 +117,7 @@ pub const MIGRATIONS: &[(u32, &str)] = &[ include_str!("../../migrations/0070_pull_viewed_files.sql"), ), (71, include_str!("../../migrations/0071_ci_job_steps.sql")), + (72, include_str!("../../migrations/0072_ember_anvil_default.sql")), ]; /// The highest migration version this binary knows about. diff --git a/crates/forge-core/src/store/ui_prefs.rs b/crates/forge-core/src/store/ui_prefs.rs index abd2fa4..c8e3cf4 100644 --- a/crates/forge-core/src/store/ui_prefs.rs +++ b/crates/forge-core/src/store/ui_prefs.rs @@ -15,11 +15,11 @@ pub const AUTO: &str = "auto"; /// The accent colour a new user gets. It must match the default palette in forge-web's /// `accent_palette.rs`, which a test there checks. -pub const DEFAULT_ACCENT: &str = "sage"; +pub const DEFAULT_ACCENT: &str = "ember"; /// The base colour set a new user gets, for both themes. It must match the default base in /// forge-web's `accent_palette.rs`, which a test there checks. -pub const DEFAULT_BASE: &str = "fern"; +pub const DEFAULT_BASE: &str = "anvil"; /// The sidebar sides, in the order the settings page lists them. pub const SIDEBAR_SIDES: &[&str] = &["left", "right"]; diff --git a/crates/forge-e2e/tests/e2e/browse_e2e.rs b/crates/forge-e2e/tests/e2e/browse_e2e.rs index 909786a..f9d6160 100644 --- a/crates/forge-e2e/tests/e2e/browse_e2e.rs +++ b/crates/forge-e2e/tests/e2e/browse_e2e.rs @@ -124,25 +124,22 @@ fn element_texts(body: &str, selector: &str) -> Vec { .collect() } -/// Checks the dock of a repo page: one dock, with the subject of the commit, its short sha, the -/// commit count label and the subject's absolute time in its title. +/// Checks the latest commit in a repo page's head line: its short sha and subject, both linking to +/// the commit, and the commit count label. fn assert_latest_bar(body: &str, what: &str, subject: &str, oid: &str, count: &str) { - let docks = element_texts(body, ".canvas-dock"); - assert_eq!(docks.len(), 1, "{what}: exactly one dock"); - let subjects = element_texts(body, ".canvas-dock .dock-subject"); - assert_eq!(subjects.len(), 1, "{what}: dock must show the subject"); - assert_eq!(subjects[0].trim(), subject, "{what}: dock subject"); - let shas = element_texts(body, ".canvas-dock .dock-sha"); - assert_eq!(shas.len(), 1, "{what}: dock must show the sha"); - assert_eq!(shas[0].trim(), &oid[..7], "{what}: dock short sha"); - let counts = element_texts(body, ".canvas-dock .dock-count"); + assert_eq!(element_texts(body, ".head-sub").len(), 1, "{what}: one head line"); + let shas = element_texts(body, ".head-sub a.mono"); + assert_eq!(shas.len(), 1, "{what}: the head line must show the sha"); + assert_eq!(shas[0].trim(), &oid[..7], "{what}: short sha"); + let links = element_texts(body, ".head-sub a[href*=\"/commit/\"]"); assert!( - counts.iter().any(|c| c.trim() == count), - "{what}: dock must show {count:?}, got {counts:?}" + links.iter().any(|l| l.trim() == subject), + "{what}: the head line must show {subject:?}, got {links:?}" ); + let parts = element_texts(body, ".head-sub span"); assert!( - !attr_values(body, ".canvas-dock .dock-subject", "title").is_empty(), - "{what}: dock subject needs an absolute time in its title" + parts.iter().any(|c| c.trim() == count), + "{what}: the head line must show {count:?}, got {parts:?}" ); } diff --git a/crates/forge-e2e/tests/e2e/ci_e2e.rs b/crates/forge-e2e/tests/e2e/ci_e2e.rs index bf4a747..c32e335 100644 --- a/crates/forge-e2e/tests/e2e/ci_e2e.rs +++ b/crates/forge-e2e/tests/e2e/ci_e2e.rs @@ -577,8 +577,8 @@ async fn run_page_lists_a_jobs_steps_and_a_step_opens_its_part_of_the_log() { .await; assert_eq!(page.status, 200, "GET run page"); assert!( - page.body.contains("ci-tl-stepname") && page.body.contains("Compile"), - "the rail lists the step names: {}", + page.body.contains("class=\"lab\"") && page.body.contains("Compile"), + "the strip lists the step names: {}", page.body ); assert!( diff --git a/crates/forge-e2e/tests/e2e/community_i18n_e2e.rs b/crates/forge-e2e/tests/e2e/community_i18n_e2e.rs index 04878d2..f74024d 100644 --- a/crates/forge-e2e/tests/e2e/community_i18n_e2e.rs +++ b/crates/forge-e2e/tests/e2e/community_i18n_e2e.rs @@ -51,7 +51,7 @@ async fn snippets_page_follows_the_browser_language() { let body = turkish.text().await.expect("read body"); assert!(body.contains("Parçacıklar"), + body.contains("

Parçacıklar

"), "Turkish heading" ); assert!( @@ -68,7 +68,7 @@ async fn snippets_page_follows_the_browser_language() { .expect("GET /snippets (en)"); let body = english.text().await.expect("read body"); assert!( - body.contains("

Snippets

"), + body.contains("

Snippets

"), "English heading" ); assert!(body.contains("No snippets to show."), "English empty state"); diff --git a/crates/forge-e2e/tests/e2e/i18n_e2e.rs b/crates/forge-e2e/tests/e2e/i18n_e2e.rs index 7e682da..c5d055e 100644 --- a/crates/forge-e2e/tests/e2e/i18n_e2e.rs +++ b/crates/forge-e2e/tests/e2e/i18n_e2e.rs @@ -168,7 +168,7 @@ async fn releases_page_follows_the_stored_turkish_language() { .await; assert_eq!(releases.status, 200, "releases page"); assert!( - releases.body.contains("

Sürümler

"), + releases.body.contains("

Sürümler

"), "Turkish heading" ); assert!(releases.body.contains("Yeni sürüm"), "Turkish new button"); diff --git a/crates/forge-e2e/tests/e2e/pulls_e2e.rs b/crates/forge-e2e/tests/e2e/pulls_e2e.rs index 30b3e8d..c200645 100644 --- a/crates/forge-e2e/tests/e2e/pulls_e2e.rs +++ b/crates/forge-e2e/tests/e2e/pulls_e2e.rs @@ -23,7 +23,7 @@ const REPO_PATH: &str = "/tahinli/r"; /// Text of the first state badge on a page, e.g. `Open`, `Closed` or `Merged`. fn state_badge(body: &str) -> String { let doc = scraper::Html::parse_document(body); - let selector = scraper::Selector::parse(".issue-badge").expect("selector"); + let selector = scraper::Selector::parse(".head-sub > .badge, .head-sub > .issue-badge").expect("selector"); doc.select(&selector) .next() .map(|el| el.text().collect::().trim().to_owned()) diff --git a/crates/forge-e2e/tests/e2e/section_nav_e2e.rs b/crates/forge-e2e/tests/e2e/section_nav_e2e.rs index f9e7f0f..557b7c6 100644 --- a/crates/forge-e2e/tests/e2e/section_nav_e2e.rs +++ b/crates/forge-e2e/tests/e2e/section_nav_e2e.rs @@ -216,9 +216,10 @@ async fn settings_pages_get_the_settings_tabs() { assert_eq!(page.status, 200, "GET {path}"); assert_tabs(&page.body, current, &tabs); } - // GPG keys and tokens moved into the Keys tab; their old addresses go there. + // GPG keys and tokens are kinds of the Keys tab, each at its own address. for path in ["/settings/gpg", "/settings/tokens"] { let page = env.http.get(path, Some(&session)).await; - assert_eq!(page.status, 303, "GET {path}"); + assert_eq!(page.status, 200, "GET {path}"); + assert_tabs(&page.body, "/settings/keys", &tabs); } } diff --git a/crates/forge-e2e/tests/e2e/ui_prefs_e2e.rs b/crates/forge-e2e/tests/e2e/ui_prefs_e2e.rs index 3310596..c63d435 100644 --- a/crates/forge-e2e/tests/e2e/ui_prefs_e2e.rs +++ b/crates/forge-e2e/tests/e2e/ui_prefs_e2e.rs @@ -59,8 +59,11 @@ fn checked_radio(body: &str, name: &str) -> Option { /// The option value that is selected in the ` + + + post_act(label: g::t(lang, K::RunFsckNow), action: "/admin/backups/fsck", csrf: csrf.as_str()) + ) if let Some(message) = notice {

(message.as_str())

} +
+ if let Some(line) = backup_running { +

(line)

+ } + if let Some(line) = fsck_running { +

(line)

+ }
if settings.enabled {

(crate::pages::passkeys::s(lang, "Configuration", "Yapılandırma"))

@@ -177,22 +189,6 @@ async fn backups_view(

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

}
-
-

(crate::pages::passkeys::s(lang, "Run now", "Şimdi çalıştır"))

- if let Some(line) = backup_running { -

(line)

- } - if let Some(line) = fsck_running { -

(line)

- } -
-
- - -
- post_act(label: g::t(lang, K::RunFsckNow), action: "/admin/backups/fsck", csrf: csrf.as_str()) -
-

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

if rows.is_empty() { diff --git a/crates/forge-web/src/pages/admin_health.rs b/crates/forge-web/src/pages/admin_health.rs index ffc86c1..c0222d8 100644 --- a/crates/forge-web/src/pages/admin_health.rs +++ b/crates/forge-web/src/pages/admin_health.rs @@ -1,8 +1,8 @@ -//! Page: instance health for admins (`/admin/health`). A summary line, a storage topic with the data -//! disk's usage bar, and a services topic. Every number is a cheap query or a short external probe -//! (`df`), so there is no polling; reloading the page, or opening it again, reads fresh values. The -//! tree size of the repos (`du`) walks every repo, so a background task caches it (see -//! [`spawn_repo_size`]) and the page only reads the cache. Non-admins get 404. +//! Page: instance health for admins (`/admin/health`). A summary line, then one sheet with the alerts, +//! a storage topic with the data disk's usage bar, and a services topic. Every number is a cheap query +//! or a short external probe (`df`), so there is no polling; reloading the page, or opening it again, +//! reads fresh values. The tree size of the repos (`du`) walks every repo, so a background task caches +//! it (see [`spawn_repo_size`]) and the page only reads the cache. Non-admins get 404. use std::path::Path; use std::sync::Mutex; @@ -19,16 +19,17 @@ use topcoat::router::response::Response; 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}; +use crate::i18n::accounts::{A, duration_short, duration_short_in, meta_line, needs_attention, on_disk, t as at}; use crate::i18n::alerts as alert_text; 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::parts::{SubPart, head}; 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 +/// Active alerts per page of the alerts topic. Each row is about 56px tall, so three keep the sheet /// short enough to fit the window. const ALERTS_PER_PAGE: usize = 3; @@ -81,59 +82,17 @@ struct Usage { bad: bool, } -/// The icon a status row shows. -#[derive(Clone, Copy)] -enum Glyph { - Database, - Folder, - Archive, - Queue, - Mail, - Clock, - Sync, -} - -/// The row icon for one glyph: a 24 grid stroke icon, 20px. -#[component] -async fn glyph(kind: Glyph) -> Result { - Ok(view! { - if matches!(kind, Glyph::Database) { - - } - if matches!(kind, Glyph::Folder) { - - } - if matches!(kind, Glyph::Archive) { - - } - if matches!(kind, Glyph::Queue) { - - } - if matches!(kind, Glyph::Mail) { - - } - if matches!(kind, Glyph::Clock) { - - } - if matches!(kind, Glyph::Sync) { - - } - }) -} - -/// One fact in the storage pane: one row. +/// One fact in the storage topic: one row. struct Fact { label: &'static str, - glyph: Glyph, value: String, detail: String, dot: Dot, } -/// One row of the services pane. +/// One row of the services topic. struct Service { label: &'static str, - glyph: Glyph, dot: Dot, value: String, detail: String, @@ -300,7 +259,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { let mut facts = vec![Fact { label: at(lang, A::DatabaseFile), - glyph: Glyph::Database, value: db_bytes.map_or_else( || at(lang, A::Unavailable).to_owned(), |b| human_size(lang, b), @@ -310,7 +268,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { }]; facts.push(Fact { label: at(lang, A::Repositories), - glyph: Glyph::Folder, value: counts.repos.to_string(), detail: match repo_bytes { Some(b) => on_disk(lang, &human_size(lang, b)), @@ -325,7 +282,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { let (pct, text) = space(lang, total, avail); Fact { label: at(lang, A::BackupDirectory), - glyph: Glyph::Archive, value: text, detail: backup, dot: if pct >= 90 { Dot::Bad } else { Dot::Neutral }, @@ -333,7 +289,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { } None => Fact { label: at(lang, A::BackupDirectory), - glyph: Glyph::Archive, value: at(lang, A::Unavailable).to_owned(), detail: backup, dot: Dot::Neutral, @@ -342,7 +297,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { } else { Fact { label: at(lang, A::BackupDirectory), - glyph: Glyph::Archive, value: at(lang, A::NotConfigured).to_owned(), detail: String::new(), dot: Dot::Off, @@ -352,7 +306,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { let mut services = vec![ Service { label: at(lang, A::CiQueue), - glyph: Glyph::Queue, dot: Dot::Neutral, value: format!("{} {}", counts.queued_jobs, at(lang, A::QueuedJobs)), detail: format!( @@ -365,7 +318,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { }, Service { label: at(lang, A::MailQueue), - glyph: Glyph::Mail, dot: if failed > 0 { Dot::Bad } else { Dot::Neutral }, value: format!("{pending} {}", at(lang, A::Pending)), detail: format!("{failed} {}", at(lang, A::Failed)), @@ -387,7 +339,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { }; Service { label: at(lang, A::LastBackup), - glyph: Glyph::Clock, dot, value: value.to_owned(), detail: String::new(), @@ -396,7 +347,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { } None if backup_on => Service { label: at(lang, A::LastBackup), - glyph: Glyph::Clock, dot: Dot::Neutral, value: at(lang, A::Never).to_owned(), detail: String::new(), @@ -404,7 +354,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { }, None => Service { label: at(lang, A::LastBackup), - glyph: Glyph::Clock, dot: Dot::Off, value: at(lang, A::NotConfigured).to_owned(), detail: String::new(), @@ -429,7 +378,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { }; Service { label: at(lang, A::Replication), - glyph: Glyph::Sync, dot, value: value.to_owned(), detail: if ok_unix.is_some() { @@ -442,7 +390,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { } None => Service { label: at(lang, A::Replication), - glyph: Glyph::Sync, dot: Dot::Neutral, value: at(lang, A::Never).to_owned(), detail: String::new(), @@ -452,7 +399,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result { } else { Service { label: at(lang, A::Replication), - glyph: Glyph::Sync, dot: Dot::Off, value: at(lang, A::NotConfigured).to_owned(), detail: String::new(), @@ -460,7 +406,10 @@ async fn gather(state: &AppState, lang: Lang) -> Result { } }); - let uptime = uptime_secs().map_or_else(|| at(lang, A::Unavailable).to_owned(), duration_short); + let uptime = uptime_secs().map_or_else( + || at(lang, A::Unavailable).to_owned(), + |secs| duration_short_in(lang, secs), + ); let build = format!( "{}{}", forge_ci::build::commit(), @@ -535,7 +484,7 @@ async fn health_view( pages: u64, nav: (Vec, Option, Option), ) -> Result { - // The heading counts every active alert; the card lists the current page of them. + // The heading counts every active alert; the sheet lists the current page of them. let count = total; let (links, prev, next) = nav; let Health { @@ -545,6 +494,8 @@ async fn health_view( meta, attention, } = health; + // An active alert needs attention as much as a failing service does. + let attention = attention + count; let summary_dot = if attention > 0 { Dot::Bad } else { Dot::Ok }; let summary = if attention > 0 { needs_attention(lang, attention) @@ -552,68 +503,67 @@ async fn health_view( at(lang, A::Fine).to_owned() }; Ok(view! { -
-

(at(lang, A::Health))

+ head(title: at(lang, A::Health), sub: vec![SubPart::text(at(lang, A::HealthIntro))], live: Some("/admin/health/events"))

" " (summary)

-

(at(lang, A::HealthIntro))

- if count > 0 { - - } else { -
- if tab == "logs" { + } else if tab == "logs" { + if !log.is_empty() { +
(s(lang, "Runner log", "Çalıştırıcı günlüğü"))
+ } +
if log.is_empty() {

(s(lang, "No log lines yet. Only a runner from the version that sends its log does so; an older runner sends nothing.", "Henüz günlük satırı yok. Günlüğünü yalnızca bunu destekleyen sürüm gönderir; eski sürüm hiçbir şey göndermez."))

} else { -
- -
                         for row in log.iter() {
                             (row.time.as_str())" "(row.level.as_str())" "(row.chip)" "(row.text.as_str())"\n"
                         }
                     
} - } else if tab == "jobs" { +
+ } else { +

(s(lang, "Running now", "Şu an çalışan"))

if running_jobs.is_empty() {

(s(lang, "Not running any job.", "Hiçbir iş çalıştırmıyor."))

- } else { -
- - - - for job in running_jobs.iter() { - - - - - - - - } - -
(s(lang, "Job", "İş"))(s(lang, "Repo", "Depo"))(s(lang, "Run", "Çalıştırma"))(s(lang, "Running for", "Çalışma süresi"))(s(lang, "Waited", "Bekleme"))
(job.name.as_str())(job.repo.as_str())(job.run_text.as_str())(job.duration.as_str())(job.waited.as_str())
-
} + for job in running_jobs.iter() { +
(job.name.as_str())(job.repo.as_str())(job.run_text.as_str())(job.duration.as_str()) " · " (s(lang, "waited", "bekleme")) " " (job.waited.as_str())
+ } +
+

(s(lang, "Recent", "Son"))

if recent_jobs.is_empty() {

(s(lang, "No finished jobs yet.", "Henüz biten iş yok."))

- } else { -
- - - - for job in recent_jobs.iter() { - - - - - - - - - - } - -
(s(lang, "Job", "İş"))(s(lang, "Repo", "Depo"))(s(lang, "Run", "Çalıştırma"))(s(lang, "State", "Durum"))(s(lang, "Took", "Süre"))(s(lang, "Waited", "Bekleme"))(s(lang, "Finished", "Bitiş"))
(job.name.as_str())(job.repo.as_str())(job.run_text.as_str())(job.state_text.as_str())(job.duration.as_str())(job.waited.as_str())
-
} - } -
+ for job in recent_jobs.iter() { +
(job.name.as_str())(job.repo.as_str())(job.run_text.as_str())(job.state_text.as_str())(job.duration.as_str()) " · " (s(lang, "waited", "bekleme")) " " (job.waited.as_str())
+ } +
}
}) @@ -2351,7 +2218,7 @@ mod tests { .expect("disable"); let (_, page) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; assert!(page.contains(r#"class="runner-dot is-disabled""#)); - assert!(page.contains(r#"idle · disabled"#)); + assert!(page.contains(r#"idle"#)); } // Scenario: restart is capability-gated and audited, then the runner is disabled, enabled and deleted. @@ -2376,7 +2243,8 @@ mod tests { assert_eq!(status, 403); // A runner that never advertised the capability: the button is off and the post refused. - let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; + let runner_page = format!("/admin/runners/{}", runner.id); + let (_, list) = send(&router, "GET", &runner_page, Some(ADMIN_TOKEN), None).await; assert!(list.contains("Runner too old, update it first"), "{list}"); let (status, _) = send( &router, @@ -2401,7 +2269,7 @@ mod tests { ) .await .unwrap(); - let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; + let (_, list) = send(&router, "GET", &runner_page, Some(ADMIN_TOKEN), None).await; assert!(list.contains("Restart after current jobs")); assert!(list.contains("Restart now")); let (status, _) = send( @@ -2417,7 +2285,7 @@ mod tests { store.runner_restart(&runner.id).await.unwrap(), Some(RestartMode::Drain) ); - let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; + let (_, list) = send(&router, "GET", &runner_page, Some(ADMIN_TOKEN), None).await; assert!(list.contains("restart pending")); let entries = store .list_audit(&Default::default(), None, 50) @@ -2441,7 +2309,7 @@ mod tests { ) .await .unwrap(); - let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; + let (_, list) = send(&router, "GET", &runner_page, Some(ADMIN_TOKEN), None).await; assert!(!list.contains("restart pending")); // Disable, then enable again. @@ -2580,9 +2448,16 @@ mod tests { store.list_runners().await.unwrap()[0].concurrency_override, Some(3) ); - let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; + let (_, list) = send( + &router, + "GET", + &format!("{detail_uri}?tab=general"), + Some(ADMIN_TOKEN), + None, + ) + .await; assert!(list.contains(r#"value="3""#)); - assert!(list.contains("Use the runner.toml value")); + assert!(list.contains("Reset to runner.toml")); assert!(list.contains(r#"data-live="/admin/runners/events""#)); // Out of range, wrong kind of field and a read-only field change nothing. @@ -2612,7 +2487,14 @@ mod tests { ) .await; assert_eq!(status, 303); - let (status, detail) = send(&router, "GET", &detail_uri, Some(ADMIN_TOKEN), None).await; + let (status, detail) = send( + &router, + "GET", + &format!("{detail_uri}?tab=general"), + Some(ADMIN_TOKEN), + None, + ) + .await; assert_eq!(status, 200); assert!(detail.contains("Concurrency")); assert!(detail.contains(r#"data-live="/admin/runners/events""#)); diff --git a/crates/forge-web/src/pages/admin_server.rs b/crates/forge-web/src/pages/admin_server.rs index e2bdd38..6d3a8f4 100644 --- a/crates/forge-web/src/pages/admin_server.rs +++ b/crates/forge-web/src/pages/admin_server.rs @@ -38,7 +38,7 @@ use crate::pages::ci_runs::{changed_event, events_response}; use crate::pages::passkeys::s; use crate::self_update; use crate::state::AppState; -use crate::views::parts::{confirm_act, reveal}; +use crate::views::parts::{RailItem, SubPart, confirm_act, head, rail, reveal}; use crate::views::{enc, shell}; #[query_params(error = bad_request)] @@ -128,6 +128,22 @@ pub(crate) fn tab_label(lang: Lang, group: Group) -> &'static str { ) } +/// The words for a choice's stored value. Values that are names (smtp, s3, eu) read as they are. +fn option_label(lang: Lang, option: &str) -> String { + let (en, tr) = match option { + "" => return g::t(lang, K::SrvEmpty).to_owned(), + "closed" => ("Closed", "Kapalı"), + "invite" => ("Invite only", "Yalnızca davetle"), + "open" => ("Open", "Açık"), + "all" => ("Everyone", "Herkes"), + "admin" => ("Admins only", "Yalnızca yöneticiler"), + "info" => ("Info", "Bilgi"), + "warning" => ("Warning", "Uyarı"), + other => return other.to_owned(), + }; + s(lang, en, tr).to_owned() +} + fn row(lang: Lang, view: &FieldView) -> Row { let field: &Field = view.field; let kind_label = match field.kind { @@ -145,11 +161,7 @@ fn row(lang: Lang, view: &FieldView) -> Row { .iter() .map(|option| OptionRow { value: (*option).to_owned(), - label: if option.is_empty() { - g::t(lang, K::SrvEmpty).to_owned() - } else { - (*option).to_owned() - }, + label: option_label(lang, option), selected: *option == view.value, }) .collect(), @@ -385,25 +397,26 @@ async fn server_view( ), _ => "/admin/server/events".to_owned(), }; + let items: Vec = Group::ALL + .into_iter() + .map(|g_tab| RailItem { + name: tab_label(lang, g_tab).to_owned(), + val: String::new(), + href: format!("/admin/server?cat={}", g_tab.slug()), + current: g_tab == group, + }) + .collect(); + let sub = vec![ + SubPart::text(g::t(lang, K::ServerSettingsIntro)), + SubPart::mono(format!( + "{} {}", + s(lang, "Version", "Sürüm"), + forge_ci::build::display() + )), + ]; Ok(view! { + head(title: g::t(lang, K::ServerSettings), sub: sub)
-

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

- - -

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

-

(s(lang, "Version", "Sürüm")) " " (forge_ci::build::display())

if restart == Restart::Pending {

(s(lang, "Restarting...", "Yeniden başlatılıyor...")) " " (s(lang, "This page comes back by itself when the server is up again.", "Sunucu tekrar ayağa kalkınca bu sayfa kendiliğinden geri gelir."))

} else if restart == Restart::Done { @@ -412,60 +425,71 @@ async fn server_view( if let Some(message) = notice {

(message.as_str())

} - if let Some(hits) = search { -
-

(s(lang, "Results", "Sonuçlar"))

- if hits.is_empty() { -

(s(lang, "No setting matches.", "Eşleşen ayar yok."))

- } - for hit in hits.iter() { - - (hit.label) - (tab_label(lang, hit.group)) - +
+ rail(label: g::t(lang, K::ServerSettings), items: items, + + ) +
+ if let Some(hits) = search { +
+

(s(lang, "Results", "Sonuçlar"))

+ if hits.is_empty() { +

(s(lang, "No setting matches.", "Eşleşen ayar yok."))

+ } + for hit in hits.iter() { + + (hit.label) + (tab_label(lang, hit.group)) + + } +
+ } else { +
+

(tab_label(lang, group))

+
+ + + for block in blocks.iter() { + if block.len() > 1 { +
+ for r in block.iter() { + srv_row(lang: lang, row: r) + } +
+ } else { + for r in block.iter() { + srv_row(lang: lang, row: r) + } + } + } + if any_editable { + + } +
+
} -
- } else { -
-

(tab_label(lang, group))

-
+ - for block in blocks.iter() { - if block.len() > 1 { -
- for r in block.iter() { - srv_row(lang: lang, row: r) - } -
- } else { - for r in block.iter() { - srv_row(lang: lang, row: r) - } - } +
+
+

(s(lang, "Restart server", "Sunucuyu yeniden başlat"))

+

(s(lang, "Stops gracefully and starts again, so a newly installed binary and every setting marked restart needed take effect. Needs a supervisor such as systemd to start it again.", "Düzgünce durdurup yeniden başlatır; böylece yeni kurulan ikili ve \"yeniden başlatma gerekli\" işaretli her ayar devreye girer. Yeniden başlatmak için systemd gibi bir gözetmen gerekir."))

+ if restart == Restart::Pending { +

(s(lang, "A restart is in progress.", "Yeniden başlatma sürüyor."))

} - if any_editable { - + if restart != Restart::Pending { +
+ confirm_act(lang: lang, label: s(lang, "Restart server", "Sunucuyu yeniden başlat"), action: "/admin/server/restart", csrf: csrf.as_str(), fields: vec![("tab".to_owned(), tab.to_owned())], note: Some(s(lang, "Restart the server now? Requests in flight finish first, and the site is unavailable for a few seconds.", "Sunucu şimdi yeniden başlatılsın mı? Süren istekler önce biter, site birkaç saniye kullanılamaz.").to_owned())) +
} - -
- } -
- - -
-
-

(s(lang, "Restart server", "Sunucuyu yeniden başlat"))

-

(s(lang, "Stops gracefully and starts again, so a newly installed binary and every setting marked restart needed take effect. Needs a supervisor such as systemd to start it again.", "Düzgünce durdurup yeniden başlatır; böylece yeni kurulan ikili ve \"yeniden başlatma gerekli\" işaretli her ayar devreye girer. Yeniden başlatmak için systemd gibi bir gözetmen gerekir."))

- if restart == Restart::Pending { -

(s(lang, "A restart is in progress.", "Yeniden başlatma sürüyor."))

- } - if restart != Restart::Pending { -
- confirm_act(lang: lang, label: s(lang, "Restart server", "Sunucuyu yeniden başlat"), action: "/admin/server/restart", csrf: csrf.as_str(), fields: vec![("tab".to_owned(), tab.to_owned())], note: Some(s(lang, "Restart the server now? Requests in flight finish first, and the site is unavailable for a few seconds.", "Sunucu şimdi yeniden başlatılsın mı? Süren istekler önce biter, site birkaç saniye kullanılamaz.").to_owned())) -
- } -
+
+
+
}) } diff --git a/crates/forge-web/src/pages/admin_user_detail.rs b/crates/forge-web/src/pages/admin_user_detail.rs index 89b3284..7f07286 100644 --- a/crates/forge-web/src/pages/admin_user_detail.rs +++ b/crates/forge-web/src/pages/admin_user_detail.rs @@ -26,7 +26,7 @@ use crate::live::{Topic, stream_changes}; use crate::pages::admin_users::admin_only; use crate::pages::passkeys::s; use crate::state::AppState; -use crate::views::parts::{confirm_act, post_act, reveal}; +use crate::views::parts::{confirm_act, head, post_act, reveal}; use crate::views::{alert, enc, rel_time, rel_time_or_never, shell, user_facing_message}; #[query_params(error = bad_request)] @@ -198,9 +198,12 @@ async fn detail_body( passkey_count ); Ok(view! { -
- (g::t(lang, K::BackToUsers)) -

(target.username.as_str())

+ head(title: target.username.as_str()) +
+

if !email.is_empty() { (email.as_str()) " · " @@ -216,9 +219,6 @@ async fn detail_body(

(access_title)

(access_state.as_str())

- if suspended {

(suspended_note.as_str())

@@ -238,9 +238,7 @@ async fn detail_body(
-
- -
+ )
@@ -310,24 +308,22 @@ async fn org_body(lang: Lang, csrf: &str, org: User, members: usize) -> Result(g::t(lang, K::BackToUsers)) -

(org.username.as_str())

-

(og::t(lang, OG::Members)) " " (members.as_str())

-
-

(access_title)

-
+ head(title: org.username.as_str()) +
-
-

(i18n::t(lang, Key::Delete))

-
- confirm_act(lang: lang, label: g::t(lang, K::DeleteOrgTitle), action: delete_action.as_str(), csrf: csrf) -
-
+

(og::t(lang, OG::Members)) " " (members.as_str())

+
+

(i18n::t(lang, Key::Delete))

+
+ confirm_act(lang: lang, label: g::t(lang, K::DeleteOrgTitle), action: delete_action.as_str(), csrf: csrf) +
+
+
}) } diff --git a/crates/forge-web/src/pages/admin_users.rs b/crates/forge-web/src/pages/admin_users.rs index 67156b4..3861dba 100644 --- a/crates/forge-web/src/pages/admin_users.rs +++ b/crates/forge-web/src/pages/admin_users.rs @@ -22,7 +22,7 @@ use crate::i18n::{self, Key, Lang}; use crate::live::{Topic, stream_changes}; use crate::pages::passkeys::s; use crate::state::AppState; -use crate::views::parts::reveal; +use crate::views::parts::{head, reveal}; use crate::views::repo_list::{pager, pager_links}; use crate::views::{alert, enc, rel_time, shell, user_facing_message}; @@ -221,18 +221,7 @@ async fn users_view( let people_href = users_href(&q, Kind::People, 1); let orgs_href = users_href(&q, Kind::Organizations, 1); 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 e7f6814..d29d7d9 100644 --- a/crates/forge-web/src/pages/audit_log.rs +++ b/crates/forge-web/src/pages/audit_log.rs @@ -17,6 +17,7 @@ use crate::live::{Topic, stream_changes}; use crate::pages::admin_users::admin_only; use crate::pages::issues_list::list_href; use crate::state::AppState; +use crate::views::parts::{SubPart, head}; use crate::views::{rel_time, shell}; /// Entries per page of the admin audit log, under its filter bar. @@ -101,21 +102,38 @@ async fn audit_table(lang: Lang, rows: Vec, show_actor: bool) -> Result

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

} else { for row in rows.into_iter() { -
- (row.action.as_str()) - - rel_time(lang: lang, stamp: row.when.as_str()) - if show_actor { - " · " (row.actor.as_str()) - } - " · " (row.target.as_str()) - -
- if !row.ip.is_empty() { -

"IP " (row.ip.as_str())

- } - if !row.details.is_empty() { -

(row.details.as_str())

+ if row.ip.is_empty() && row.details.is_empty() { +
+ (row.action.as_str()) + + rel_time(lang: lang, stamp: row.when.as_str()) + if show_actor { + " · " (row.actor.as_str()) + } + " · " (row.target.as_str()) + +
+ } else { +
+ + (row.action.as_str()) + + rel_time(lang: lang, stamp: row.when.as_str()) + if show_actor { + " · " (row.actor.as_str()) + } + " · " (row.target.as_str()) + + +
+ if !row.ip.is_empty() { +

"IP " (row.ip.as_str())

+ } + if !row.details.is_empty() { +

(row.details.as_str())

+ } +
+
} } } @@ -132,37 +150,37 @@ async fn admin_audit_view( rows: Vec, older_href: Option, ) -> Result { + let sub = vec![SubPart::text(g::t(lang, K::AuditIntro))]; Ok(view! { -
-

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

-

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

-
- -
- + head(title: g::t(lang, K::AuditLog), sub: sub) +
+
+ + + +
- - if let Some(message) = notice { -

(message.as_str())

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

(message.as_str())

+ } + audit_table(lang: lang, rows: rows, show_actor: true) + if let Some(href) = older_href { + + }
}) } @@ -173,15 +191,17 @@ async fn own_log_view( rows: Vec, older_href: Option, ) -> Result { + let sub = vec![SubPart::text(g::t(lang, K::OwnLogIntro))]; Ok(view! { -

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

-

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

- audit_table(lang: lang, rows: rows, show_actor: false) - if let Some(href) = older_href { - - } + head(title: g::t(lang, K::SecurityLogTitle), sub: sub) +
+ audit_table(lang: lang, rows: rows, show_actor: false) + if let Some(href) = older_href { + + } +
}) } diff --git a/crates/forge-web/src/pages/blame.rs b/crates/forge-web/src/pages/blame.rs index 0285efb..b237791 100644 --- a/crates/forge-web/src/pages/blame.rs +++ b/crates/forge-web/src/pages/blame.rs @@ -19,13 +19,12 @@ use crate::pages::blob::{Line, text_lines}; use crate::pages::ref_live; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::load_repo; -use crate::pages::tree::{MAX_BLOB_BYTES, path_crumbs, read_file, resolve}; +use crate::pages::passkeys::s; +use crate::pages::tree::{MAX_BLOB_BYTES, read_file, resolve}; use crate::render::emoji::emojify; use crate::state::AppState; use crate::views::commit_line::commit_line; -use crate::views::{ - Crumb, breadcrumb, human_size, iso_time, now_unix, relative_time, repo_href, shell, short_oid, -}; +use crate::views::{human_size, iso_time, now_unix, relative_time, repo_href, shell, short_oid}; path_param!(owner); path_param!(repo); @@ -116,9 +115,9 @@ async fn blame_table(rows: Vec, lang: Lang) -> Result {
(meta.short.as_str()) (meta.author.as_str()) - + if let Some(prior) = meta.prior_href { - "↶" + (s(lang, "Prior", "Önceki")) }
commit_line(subject: meta.summary.clone()) @@ -204,7 +203,6 @@ async fn blame_page(cx: &Cx) -> Result { "commits", &format!("{ref_name}/{file}"), ); - let crumbs: Vec = path_crumbs(repo, &ref_name, "blob", &file); let title = format!( "{}/{} \u{b7} {} \u{b7} {file}", repo.owner_name, @@ -225,24 +223,22 @@ async fn blame_page(cx: &Cx) -> Result { Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), repo_head(head: header) -
- breadcrumb(lang: lang, crumbs: crumbs) +
+ +
+ if let Some(text) = message { +

(text)

+ } + if has_rows { + blame_table(rows: rows, lang: lang) + } +
-
-
- (b::t(lang, b::K::BlameTitle)) " \u{b7} " (size) - -
- if let Some(text) = message { -

(text)

- } - if has_rows { - blame_table(rows: rows, lang: lang) - } -
) }) } diff --git a/crates/forge-web/src/pages/blob.rs b/crates/forge-web/src/pages/blob.rs index 05d13a4..ba2c85d 100644 --- a/crates/forge-web/src/pages/blob.rs +++ b/crates/forge-web/src/pages/blob.rs @@ -11,21 +11,26 @@ use topcoat::view::{Unescaped, View, component, view}; use crate::i18n::browse as b; use crate::i18n::code::{self as g, K}; +use crate::i18n::misc::{self as mi, K as MK}; use crate::i18n::{self}; use crate::lfs::has_object; use crate::lfs_pointer; use crate::pages::code_live::{follows_branch, live_url}; use crate::pages::finder::file_finder; use crate::pages::media::media_url; -use crate::pages::refs::load_refs; +use crate::pages::passkeys::s; +use crate::pages::refs::{load_refs, ref_links}; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::load_repo; -use crate::pages::tree::{link_context, path_crumbs, read_file, resolve}; +use crate::pages::repo_side::{code_sub, commit_strip, run_pips, run_rows, tree_facts}; +use crate::pages::tree::{ + entry_rows, last_commits, latest_bar, link_context, read_dir, read_file, resolve, tree_table, +}; use crate::raw::raw_url; use crate::render::highlight::highlight_lines; use crate::render::markdown::render_markdown; use crate::state::AppState; -use crate::views::{Crumb, breadcrumb, human_size, repo_href, shell}; +use crate::views::{human_size, now_unix, ref_selector, repo_href, shell}; const IMAGE_EXTS: [&str; 8] = ["png", "jpg", "jpeg", "gif", "webp", "avif", "svg", "ico"]; const MARKDOWN_EXTS: [&str; 2] = ["md", "markdown"]; @@ -255,9 +260,7 @@ async fn blob_page(cx: &Cx) -> Result { let finder_owner = repo.owner_name.clone(); let finder_repo = repo.name.clone(); let finder_ref = ref_name.clone(); - let crumbs: Vec = path_crumbs(repo, &ref_name, "blob", &file); let title = format!("{}/{} \u{b7} {file}", repo.owner_name, repo.name); - let size = human_size(lang, blob.size); let kind = viewer.kind; let is_text = kind == "text"; @@ -271,19 +274,69 @@ async fn blob_page(cx: &Cx) -> Result { let refs = load_refs(ctx.path.clone()).await?; let follows = follows_branch(&refs, &ref_name); + // The head and the rail describe the folder the file sits in, as the folder page does. + let siblings = read_dir(ctx.path.clone(), commit.clone(), dir.clone()) + .await? + .unwrap_or_default(); + let names: Vec = siblings.iter().map(|e| e.name.clone()).collect(); + let root_names: Vec = if dir.is_empty() { + names.clone() + } else { + read_dir(ctx.path.clone(), commit.clone(), String::new()) + .await? + .unwrap_or_default() + .into_iter() + .map(|e| e.name) + .collect() + }; + let (last, bar, strip, runs) = tokio::join!( + last_commits(state, &ctx.path, &commit, &dir, &names), + latest_bar(state, repo, &ctx.path, &commit, "", lang, ctx.viewer_tz()), + commit_strip(state, repo, &ctx.path, &commit), + run_rows(state, lang, repo), + ); + let runs = runs?; + let facts = tree_facts(state, repo, &ctx.path, &commit, &root_names).await?; + let pips = run_pips(&runs); + let sub = code_sub(lang, bar, Some(facts), None, Vec::new(), strip.total); + let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo); + let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", ""); + let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", ""); + let rows = entry_rows( + lang, + repo, + &ref_name, + &dir, + siblings, + &last, + now_unix(), + ctx.viewer_tz(), + ); let mut header = ctx.head(state, "code").await?; header.live = live_url(&repo.owner_name, &repo.name, &refs, &ref_name); + let size = human_size(lang, blob.size); + let size_line = if is_text { + format!("{} {}, {size}", lines.len(), s(lang, "lines", "satır")) + } else { + size + }; Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) -
- breadcrumb(lang: lang, crumbs: crumbs) - file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) -
-
-
- (size) - -
- if kind == "image" { -
- (image_alt)
- } - if kind == "markdown" { -
(Unescaped::new_unchecked(html))
- } - if kind == "text" { - file_table(lines: lines) - } - if kind == "lfs" { -

(note.clone())

- } - if kind == "binary" { -

(note.clone())

- } - if kind == "symlink" { -

(g::t(lang, K::SymlinkPrefix)) (note.clone())

- } - if kind == "submodule" { -

(g::t(lang, K::SubmodulePrefix)) (note.clone()) (g::t(lang, K::SubmoduleSuffix))

- } - if truncated { -

(g::t(lang, K::TruncatedPrefix)) - (g::t(lang, K::ViewFullRaw)) "."

- } -
+
+ if kind == "image" { +
+ (image_alt) +
+ } + if kind == "markdown" { +
(Unescaped::new_unchecked(html))
+ } + if kind == "text" { + file_table(lines: lines) + } + if kind == "lfs" { +

(note.clone())

+ } + if kind == "binary" { +

(note.clone())

+ } + if kind == "symlink" { +

(g::t(lang, K::SymlinkPrefix)) (note.clone())

+ } + if kind == "submodule" { +

(g::t(lang, K::SubmodulePrefix)) (note.clone()) (g::t(lang, K::SubmoduleSuffix))

+ } + if truncated { +

(g::t(lang, K::TruncatedPrefix)) + (g::t(lang, K::ViewFullRaw)) "."

+ } +
+
+
) }) } diff --git a/crates/forge-web/src/pages/branches.rs b/crates/forge-web/src/pages/branches.rs index 41e6756..1e07353 100644 --- a/crates/forge-web/src/pages/branches.rs +++ b/crates/forge-web/src/pages/branches.rs @@ -147,7 +147,7 @@ async fn branch_table( (row.name.as_str()) if row.is_default { - (g::t(lang, K::DefaultBadge)) + (g::t(lang, K::DefaultBadge)) } (row.author.as_str()) " · " if let Some(counts) = row.counts { @@ -159,7 +159,7 @@ async fn branch_table(
if let Some(last) = row.last { -

commit_line(subject: last.summary.clone())

+

commit_line(subject: last.summary.clone())

}
if let Some(pr) = row.pr_href { @@ -274,7 +274,12 @@ async fn branches_page(cx: &Cx) -> Result { header.live = ref_live::live_url(&ctx.repo.owner_name, &ctx.repo.name); Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) + repo_head(head: header, + if can_write { + new_branch_form(lang: lang, action: action.clone(), csrf: csrf.clone(), + default_branch: default_branch, options: options) + } + ) if let Some((key, is_error)) = notice { if is_error { alert(message: b::t(lang, key)) @@ -282,16 +287,12 @@ async fn branches_page(cx: &Cx) -> Result {

(b::t(lang, key))

} } - if can_write { -
- new_branch_form(lang: lang, action: action.clone(), csrf: csrf.clone(), - default_branch: default_branch, options: options) -
- } if empty {

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

} else { - branch_table(rows: rows, lang: lang, csrf: csrf.clone(), delete_action: delete_action, can_delete: can_write) +
+ branch_table(rows: rows, lang: lang, csrf: csrf.clone(), delete_action: delete_action, can_delete: can_write) +
} ) }) diff --git a/crates/forge-web/src/pages/ci_estimate.rs b/crates/forge-web/src/pages/ci_estimate.rs index 4ad04fc..ff31b1e 100644 --- a/crates/forge-web/src/pages/ci_estimate.rs +++ b/crates/forge-web/src/pages/ci_estimate.rs @@ -7,7 +7,6 @@ use std::collections::{HashMap, HashSet}; use forge_core::ci::{JobSample, JobState, StepSample}; -use serde::Deserialize; use crate::i18n::Lang; use crate::i18n::releases_ci as rc; @@ -24,18 +23,6 @@ pub struct Step { pub finished: Option, } -/// The `needs` of a job spec, read from its JSON. A spec that does not read has none. -pub fn needs_of(spec_json: &str) -> Vec { - #[derive(Deserialize, Default)] - #[serde(default)] - struct Needs { - needs: Vec, - } - serde_json::from_str::(spec_json) - .map(|spec| spec.needs) - .unwrap_or_default() -} - /// The expected duration of `job` on `git_ref`, in seconds: the median of its durations in the newest /// five successful runs on that branch, or in the newest five on any branch when the branch has fewer /// than `MIN_SAMPLES`. None when neither has enough. diff --git a/crates/forge-web/src/pages/ci_fail.rs b/crates/forge-web/src/pages/ci_fail.rs index 3e920bb..15bbe10 100644 --- a/crates/forge-web/src/pages/ci_fail.rs +++ b/crates/forge-web/src/pages/ci_fail.rs @@ -2,8 +2,6 @@ //! its log around the first error, and a link to that line in the job page's numbered log. Steps are //! not stored, so the failed job is the unit. The log is untrusted: its lines are rendered as text. -use std::ops::Range; - use topcoat::Result; use topcoat::view::{View, component, view}; @@ -16,12 +14,8 @@ use crate::pages::ci_job::log_tail; use crate::pages::ci_runs::{job_href, strip_ansi}; use crate::state::AppState; -/// Most lines the block shows. +/// How far after the first error line its reason and place are looked for. const WINDOW: usize = 30; -/// Lines kept before the first error. -const BEFORE: usize = 5; -/// Lines shown when no line matches an error pattern. -const FALLBACK: usize = 20; /// Patterns that mark an error line. Matching is case-sensitive, which keeps prose such as "error /// handling" out. `FAILED` also covers `test result: FAILED`. const PATTERNS: [&str; 6] = [ @@ -40,28 +34,6 @@ fn first_error(lines: &[String]) -> Option { .position(|line| PATTERNS.iter().any(|pattern| line.contains(pattern))) } -/// The indices of the lines to show for a failed step's log: at most 30 lines, starting 5 lines before -/// the first line that matches an error pattern. With no match, the last 20 lines. -pub(crate) fn error_range(lines: &[String]) -> Range { - let len = lines.len(); - match first_error(lines) { - Some(hit) => { - let start = hit.saturating_sub(BEFORE).min(len.saturating_sub(WINDOW)); - start..(start + WINDOW).min(len) - } - None => len.saturating_sub(FALLBACK)..len, - } -} - -/// One shown line: its number in the whole job log, its text without ANSI codes, and whether it is -/// the first error. -#[derive(Clone)] -pub(crate) struct FailLine { - no: u64, - text: String, - hit: bool, -} - /// The values of the failure block, read once per run page. #[derive(Clone)] pub(crate) struct FailFirst { @@ -71,7 +43,30 @@ pub(crate) struct FailFirst { has_log: bool, /// The job's number for the first error line, when a line matched. line_no: Option, - lines: Vec, + /// The first error line itself, when the job has no message of its own. + error: Option, + /// Where the error points, `file:line`, from the lines right after it. + place: Option, +} + +impl FailFirst { + /// The log line the page opens at. + pub(crate) fn line_no(&self) -> Option { + self.line_no + } +} + +/// The `file:line` in a compiler's or test's lines around an error: the first word that ends in +/// digits after a colon and holds a dot. +fn place_in(lines: &[String]) -> Option { + lines.iter().flat_map(|line| line.split_whitespace()).find_map(|word| { + let word = word.trim_matches(|c: char| matches!(c, '(' | ')' | ',')); + let mut parts = word.split(':'); + let file = parts.next()?; + let line = parts.next()?; + (file.contains('.') && !file.contains("::") && !line.is_empty() && line.bytes().all(|b| b.is_ascii_digit())) + .then(|| format!("{}:{line}", file.rsplit('/').next().unwrap_or(file))) + }) } /// Reads the failed job's log tail (the same bounded read as the job page) and picks the lines to show. @@ -88,92 +83,67 @@ pub(crate) async fn read( all.pop(); } let hit = first_error(&all); - let range = error_range(&all); - let start = range.start; - let lines = all[range] - .iter() - .enumerate() - .map(|(k, text)| { - let index = start + k; - FailLine { - no: tail.first_line + index as u64, - text: text.clone(), - hit: hit == Some(index), - } - }) - .collect(); + // A test's FAILED line is followed by the error that says why, so the later `error:` reads better. + let reason = hit.map(|index| { + all[index..] + .iter() + .take(WINDOW) + .find(|line| line.trim_start().starts_with("error")) + .unwrap_or(&all[index]) + .trim() + .to_owned() + }); + let place = hit.and_then(|index| place_in(&all[index..(index + WINDOW).min(all.len())])); Ok(FailFirst { job_name: job_name.to_owned(), job_href: job_href(title, job_id), message: message.to_owned(), has_log: !all.is_empty(), line_no: hit.map(|index| tail.first_line + index as u64), - lines, + error: reason, + place, }) } -/// The failure block. The job's name links to its page; the first error links to its line there. +/// The failure row, pinned above the log, which opens at the first error line: why it failed, the +/// place in the code, and a link to that line in the job's log. #[component] pub(crate) async fn fail_first_block(lang: Lang, fail: FailFirst) -> Result { let line_href = fail.line_no.map(|no| format!("{}#L{no}", fail.job_href)); + let why = if fail.message.is_empty() { + fail.error.clone().unwrap_or_else(|| fail.job_name.clone()) + } else { + fail.message.clone() + }; Ok(view! { -
-

- (g::t(lang, K::FailHeading)) - " " (fail.job_name.as_str()) -

- if !fail.message.is_empty() { -

(fail.message.as_str())

+
+ (why.as_str()) + if let Some(place) = fail.place.as_ref() { + (place.as_str()) + } + if let Some(href) = line_href.as_ref() { + (g::t(lang, K::FailOpenLog)) } if !fail.has_log { -

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

- } else { - if let (Some(href), Some(no)) = (line_href.as_ref(), fail.line_no) { -

(g::t(lang, K::FailOpenLog)) " \u{b7} " (g::t(lang, K::FailLine)) " " (no)

- } else { -

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

- } -
- for line in fail.lines.iter() { -
(line.no)(line.text.as_str())
- } -
+ (g::t(lang, K::FailNoLog)) + } else if line_href.is_none() { + (g::t(lang, K::FailNoError)) } -
+
}) } #[cfg(test)] mod tests { - use super::{FALLBACK, WINDOW, error_range}; - - fn lines(count: usize) -> Vec { - (0..count).map(|i| format!("line {i}")).collect() - } - - #[test] - fn the_first_error_opens_a_window_of_at_most_thirty_lines() { - let mut log = lines(40); - log[12] = "error[E0425]: cannot find value".to_owned(); - log[20] = "error: later one".to_owned(); - let range = error_range(&log); - assert_eq!(range, 7..37); - assert!(range.len() <= WINDOW); - assert!(range.contains(&12)); - } - - #[test] - fn a_match_near_the_end_keeps_a_full_window() { - let mut log = lines(40); - log[39] = "thread 'x' panicked at src/lib.rs:3".to_owned(); - assert_eq!(error_range(&log), 10..40); - } + use super::place_in; #[test] - fn without_an_error_the_last_lines_are_shown() { - let log = lines(100); - assert_eq!(error_range(&log), (100 - FALLBACK)..100); - assert_eq!(error_range(&lines(5)), 0..5); - assert_eq!(error_range(&[]), 0..0); + fn the_place_of_an_error_is_its_file_and_line() { + let lines = [ + "error: stream closed".to_owned(), + " --> crates/forge-e2e/tests/e2e/wiki_e2e.rs:212:9".to_owned(), + ]; + assert_eq!(place_in(&lines).as_deref(), Some("wiki_e2e.rs:212")); + assert_eq!(place_in(&["test a::b::c ... FAILED".to_owned()]), None); } } diff --git a/crates/forge-web/src/pages/ci_job.rs b/crates/forge-web/src/pages/ci_job.rs index 0d80187..ea3fd4d 100644 --- a/crates/forge-web/src/pages/ci_job.rs +++ b/crates/forge-web/src/pages/ci_job.rs @@ -38,7 +38,6 @@ use crate::pages::ci_runs::{ age_text, can_write, changed_event, commit_reachable_for, 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}; @@ -433,93 +432,92 @@ async fn job_body( repo: String, bars: Vec, ) -> Result { + let archived = head.archived; Ok(view! { - repo_head(head: RepoHead { live: String::new(), ..head }) -
-
-
-
- (g::t(lang, K::RunNumber)) (job.run_number) -

(job.name.as_str())

- if let Some((action, csrf)) = job.rerun.as_ref() { -
-
- - -
-
- } -
-
- (job.state.as_str()) - if !job.runner.is_empty() { - (g::t(lang, K::Runner)) " " (job.runner.as_str()) - } - if !job.exit_code.is_empty() { - (g::t(lang, K::Exit)) " " (job.exit_code.as_str()) - } - if !job.duration.is_empty() { - (g::t(lang, K::Duration)) " " (job.duration.as_str()) - } + if archived { +

(crate::i18n::code::t(lang, crate::i18n::code::K::ArchivedNotice))

+ } +
+
+
+

(job.name.as_str())

+ if let Some((action, csrf)) = job.rerun.as_ref() { +
+ + +
+ } +
+

+ (g::t(lang, K::RunNumber)) " " (job.run_number) + + (job.state.as_str()) + if !job.runner.is_empty() { + + (g::t(lang, K::Runner)) " " (job.runner.as_str()) + } + if !job.exit_code.is_empty() { + + (g::t(lang, K::Exit)) " " (job.exit_code.as_str()) + } + if !job.duration.is_empty() { + + (g::t(lang, K::Duration)) " " (job.duration.as_str()) + } + if !job.started.is_empty() { + + (g::t(lang, K::Started)) " " + } + if !job.finished.is_empty() { + + (g::t(lang, K::Finished)) " " + } +

+
+
+
+ (g::t(lang, K::Log)) +
+ + + + + + (g::t(lang, K::FullLog)) +
-
-
-
-

(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 !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 truncated { +

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

+ } +
(log.as_str())
+ if !artifacts.is_empty() { +
+

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

+ for artifact in artifacts.iter() { +
+ (artifact.name.as_str()) + (artifact.size.as_str()) +
}
- if !artifacts.is_empty() { -

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

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

(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)
- if truncated { -

(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)
-
+
}) } diff --git a/crates/forge-web/src/pages/ci_runs.rs b/crates/forge-web/src/pages/ci_runs.rs index bc17137..7b8f723 100644 --- a/crates/forge-web/src/pages/ci_runs.rs +++ b/crates/forge-web/src/pages/ci_runs.rs @@ -48,7 +48,7 @@ use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable}; use crate::pages::repo_side::{commit_strip, run_states, strip_bars}; use crate::state::AppState; -use crate::views::commit_line::{commit_line, headline}; +use crate::views::commit_line::commit_line; use crate::views::timeline::{StripBar, history_strip}; use crate::views::{ alert, empty_state, enc, human_size, now_unix, rel_time, relative_time, shell, short_oid, @@ -203,7 +203,11 @@ pub(crate) fn duration_text(lang: Lang, started: Option<&str>, finished: Option< return String::new(); }; let end = finished.and_then(unix_of).unwrap_or_else(now_unix); - let secs = (end - start).max(0); + secs_text(lang, (end - start).max(0)) +} + +/// A length of time as the CI pages write it: minutes and seconds, or seconds alone under a minute. +fn secs_text(lang: Lang, secs: i64) -> String { if secs >= 60 { g::duration_minutes(lang, secs / 60, secs % 60) } else { @@ -249,6 +253,48 @@ pub fn run_finished(state: &RunState) -> bool { ) } +/// The run page's headline, a sentence about the state: `Failed in `, `Running `, `Passed in +/// `. Returns the class it takes: `bad` for a failure, `live` while running, else none. +fn run_headline(lang: Lang, state: RunState, job: &str, took: &str) -> (String, &'static str) { + let (text, class) = run_headline_text(lang, state, job, took); + // A state word alone is a sentence here, so it starts with a capital: `Queued`, not `queued`. + let mut chars = text.chars(); + let text = match chars.next() { + Some(first) => first.to_uppercase().chain(chars).collect(), + None => text, + }; + (text, class) +} + +fn run_headline_text(lang: Lang, state: RunState, job: &str, took: &str) -> (String, &'static str) { + match state { + RunState::Failure | RunState::Error => { + let text = match (lang, job.is_empty()) { + (_, true) => state_text(lang, state.as_str()), + (Lang::Tr, false) => format!("{job} başarısız"), + (Lang::En, false) => format!("Failed in {job}"), + }; + (text, "bad") + } + RunState::Running => { + let text = match (lang, job.is_empty()) { + (_, true) => state_text(lang, state.as_str()), + (Lang::Tr, false) => format!("{job} çalışıyor"), + (Lang::En, false) => format!("Running {job}"), + }; + (text, "live") + } + RunState::Success if !took.is_empty() => { + let text = match lang { + Lang::Tr => format!("{took} içinde geçti"), + Lang::En => format!("Passed in {took}"), + }; + (text, "") + } + _ => (state_text(lang, state.as_str()), ""), + } +} + /// A ref as the lists show it: `refs/heads/main` reads `main`, and so does a tag without its prefix. fn short_ref(git_ref: &str) -> &str { git_ref @@ -350,6 +396,8 @@ struct RunRow { duration: String, /// Unix seconds the duration counts from while the run is live, for the client's local ticker. since: Option, + /// The state tone of the row's tick: `bad`, `live`, `skip`, `wait` or empty for passed. + tick: &'static str, /// The run's start and the list's scale, which the ticker needs to grow the running segments. origin: String, scale: String, @@ -424,15 +472,13 @@ struct JobLine { /// The job's steps, a dropdown under its row. Every job has its lines; only the selected job's /// step carries the log's mark. steps: Vec, - /// The job's bar along the bottom of its row: one segment per step. Empty for a job with no steps. - step_bar: Vec, + /// The state tone of the job's tick: `bad`, `live`, `done` or empty. + tick: &'static str, } /// One step of a job, drawn as a line under its row in the jobs pane. struct StepLine { name: String, - /// The classes of the step's mark, which carry its state's colour. - mark: &'static str, duration: String, /// Unix seconds a running step's duration counts from. since: Option, @@ -450,6 +496,10 @@ struct StepLine { expected_secs: Option, /// The state class of the step's progress bar, which sets its fill colour. state_class: &'static str, + /// The strip segment's tone: `bad`, `live`, `skip` or empty for a passed step. + seg: &'static str, + /// The segment's share of the job's strip, as `fr1`..`fr40`, by the step's duration. + fr: String, } /// One artifact of the run: its download link, the job that made it, its name and size. @@ -464,8 +514,9 @@ struct ArtifactLine { struct RunDetail { number: i64, title: String, - state: String, - state_class: String, + /// The head's sentence about the state, and its class (`bad`, `live` or empty). + headline: String, + headline_class: &'static str, trigger: String, branch: String, /// The commit's page. None when a force push overwrote the commit. @@ -743,8 +794,6 @@ const STEP_H: i64 = 20; const BAR_DY: i64 = 9; const BAR_H: i64 = 22; /// The narrowest segment of a job's step bar, and the gap between segments, in its SVG units. -const STEP_BAR_MIN: i64 = 8; -const STEP_BAR_GAP: i64 = 6; /// The narrowest a box is drawn, so a short lead-in or job still shows. const MIN_BOX_W: i64 = 3; /// The most intervals an axis has, so its ticks stay readable. @@ -1318,7 +1367,7 @@ fn step_job_state(state: StepState) -> JobState { } /// The steps of a job as the timeline draws them. A step whose start does not read is left out. -fn step_spans(steps: &[JobStep], job: JobState) -> Vec { +fn step_spans(steps: &[JobStep], job: JobState, job_end: Option) -> Vec { steps .iter() .filter_map(|step| { @@ -1326,49 +1375,13 @@ fn step_spans(steps: &[JobStep], job: JobState) -> Vec { name: step.name.clone(), state: step_job_state(step.state(job)), start: unix_of(&step.started_at)?, - end: step.finished_at.as_deref().and_then(unix_of), + // A step left open ends with its job. + end: step.finished_at.as_deref().and_then(unix_of).or(job_end), }) }) .collect() } -/// A step's share of its job's bar: its state, its elapsed seconds and, while it runs, its expected ones. -struct BarStep { - state: StepState, - elapsed: i64, - expected: Option, -} - -/// The bar along a job's row: one segment per step, as wide as its seconds (a running step counts the -/// larger of its elapsed and expected seconds), with a gap between segments. A running step with an -/// estimate is a track of its full width with its elapsed share filled in the accent. -fn step_bar(steps: &[BarStep]) -> Vec { - let weight = |step: &BarStep| step.expected.unwrap_or(0).max(step.elapsed).max(1); - let total: i64 = steps.iter().map(weight).sum(); - let gaps = STEP_BAR_GAP * (steps.len() as i64 - 1).max(0); - // Every segment gets its least first, so 32 short steps beside a long one still all fit. - let room = (LIST_BAR_W - gaps - STEP_BAR_MIN * steps.len() as i64).max(0); - let mut rects = Vec::with_capacity(steps.len() + 1); - let mut x = 0; - for step in steps { - let weight = weight(step); - let w = STEP_BAR_MIN + weight * room / total; - match (step.state, step.expected) { - (StepState::Running, Some(expected)) => { - rects.push(Rect::new("ci-sbar-track", x, 0, w, 3)); - let done = step.elapsed.min(expected) * w / weight; - rects.push(Rect::new("ci-sbar-run", x, 0, done, 3)); - } - (StepState::Running, None) => rects.push(Rect::new("ci-sbar-run", x, 0, w, 3)), - (StepState::Passed, _) => rects.push(Rect::new("ci-sbar-pass", x, 0, w, 3)), - (StepState::Failed, _) => rects.push(Rect::new("ci-sbar-fail", x, 0, w, 3)), - (StepState::Cancelled, _) => rects.push(Rect::new("ci-sbar-off", x, 0, w, 3)), - } - x += w + STEP_BAR_GAP; - } - rects -} - /// The rail's step lines of a job and the bar under its row. Every job gets its lines, the dropdown /// under its row; `wanted` marks the step the log shows and is passed for the selected job only. A /// running step's expected time comes from the repo's step samples. @@ -1381,25 +1394,31 @@ fn job_steps( wanted: Option, now: i64, lang: Lang, -) -> (Vec, Vec) { +) -> Vec { let mut lines = Vec::with_capacity(steps.len()); - let mut bar = Vec::with_capacity(steps.len()); - for step in steps { + // A step left open ends with its job: only a step of a job still going runs until now. + let elapsed_of: Vec = steps + .iter() + .map(|step| { + unix_of(&step.started_at).map_or(0, |at| { + let end = step + .finished_at + .as_deref() + .and_then(unix_of) + .or(job.finished) + .unwrap_or(now); + (end - at).max(0) + }) + }) + .collect(); + let total: u64 = elapsed_of.iter().map(|secs| u64::try_from(*secs).unwrap_or(0)).sum(); + for (step, elapsed) in steps.iter().zip(elapsed_of) { let state = step.state(job.state); let running = state == StepState::Running; let started = unix_of(&step.started_at); - let elapsed = started.map_or(0, |at| { - let end = step.finished_at.as_deref().and_then(unix_of).unwrap_or(now); - (end - at).max(0) - }); let expected = running .then(|| ci_estimate::step_expected(samples, &run.git_ref, &job.name, &step.name)) .flatten(); - bar.push(BarStep { - state, - elapsed, - expected, - }); // A step of a job whose log was pruned has no part of the log to open. let href = (job.log_bytes != 0).then(|| format!("{pick}&step={}", step.seq)); // Only a running step with an estimate has a share; one without is indeterminate, never a guess. @@ -1408,17 +1427,11 @@ fn job_steps( .map(|secs| (elapsed * 100 / secs).min(99).to_string()); lines.push(StepLine { name: step.name.clone(), - mark: match state { - StepState::Passed => "ci-st-pass", - StepState::Running => "ci-st-run", - StepState::Failed => "ci-st-fail", - StepState::Cancelled => "ci-st-off", + duration: if started.is_some() { + secs_text(lang, elapsed) + } else { + String::new() }, - duration: duration_text( - lang, - Some(step.started_at.as_str()), - step.finished_at.as_deref(), - ), since: started.filter(|_| running).map(|at| at.to_string()), expected: expected.map(|secs| format!("~{}", span_text(secs))), selected: href.is_some() && wanted == Some(step.seq), @@ -1438,9 +1451,16 @@ fn job_steps( StepState::Failed => "ci-sp-fail", StepState::Cancelled => "ci-sp-off", }, + seg: match state { + StepState::Passed => "", + StepState::Running => "live", + StepState::Failed => "bad", + StepState::Cancelled => "skip", + }, + fr: crate::views::parts::seg_fr(u64::try_from(elapsed).unwrap_or(0), total), }); } - (lines, step_bar(&bar)) + lines } /// "test OOM" for a failed run: the first failed job's message, or its name and state. @@ -1575,11 +1595,16 @@ async fn usernames( /// A small form that POSTs the CSRF token to `action`, with one button. #[component] -async fn action_button(action: String, csrf: String, label: &'static str) -> Result { +async fn action_button( + action: String, + csrf: String, + label: &'static str, + primary: bool, +) -> Result { Ok(view! {
- +
}) } @@ -1712,8 +1737,16 @@ async fn runs_split( names.get(&run.actor_id).cloned().unwrap_or_default() }; RunRow { + tick: match run.state { + RunState::Failure | RunState::Error => "bad", + RunState::Running => "live", + RunState::Cancelled => "skip", + RunState::Queued | RunState::WaitingApproval => "wait", + _ => "done", + }, href: row_href(run.number), - current: if selected.as_ref().is_some_and(|sel| sel.id == run.id) { + // The list page alone draws no run, so it marks none. + current: if number.is_some() && selected.as_ref().is_some_and(|sel| sel.id == run.id) { "true" } else { "false" @@ -1774,7 +1807,8 @@ async fn runs_split( } else { None }; - let detail = match selected.as_ref() { + // The list page shows rows only; a run's detail is on its own page. + let detail = match number.and(selected.as_ref()) { Some(run) => { let actor = if run.trigger == "schedule" { String::new() @@ -1886,7 +1920,7 @@ async fn run_detail( for job in jobs.iter_mut() { let spans = steps_of .get(&job.id) - .map_or_else(Vec::new, |steps| step_spans(steps, job.state)); + .map_or_else(Vec::new, |steps| step_spans(steps, job.state, job.finished)); job.steps = spans; } // A running step's expected time is judged from the samples of the run's branch. @@ -1928,7 +1962,7 @@ async fn run_detail( } let tail = log_last_lines(&log_path(&state.config.data_dir, &job.id)).await; let pick = format!("{}?job={}", run_href(title, run.number), job.id); - let (steps, step_bar) = job_steps( + let steps = job_steps( job, steps_of.get(&job.id).map(Vec::as_slice).unwrap_or_default(), &step_samples, @@ -1960,7 +1994,6 @@ async fn run_detail( id: job.id.clone(), selected: picked == Some(index), steps, - step_bar, pick, expanded: !tail.is_empty() && starts_expanded(job.state, jobs.len()), preview, @@ -1971,6 +2004,12 @@ async fn run_detail( href: job_href(title, &job.id), name: variant.unwrap_or(job.name.as_str()).to_owned(), dot: format!("ci-dot ci-{}", job.state.as_str()), + tick: match job.state { + JobState::Failure | JobState::Error => "bad", + JobState::Running => "live", + JobState::Success => "done", + _ => "", + }, detail: job.image.clone(), rerun: (rerunnable && job.state.is_terminal()) .then(|| format!("{}/rerun", job_href(title, &job.id))), @@ -2046,11 +2085,24 @@ async fn run_detail( } _ => None, }; + let (headline, headline_class) = run_headline( + lang, + run.state, + // The step that failed or runs says more than its job does. + picked.map_or("", |index| { + let job = &lines[index]; + job.steps + .iter() + .find(|step| matches!(step.seg, "bad" | "live")) + .map_or(job.name.as_str(), |step| step.name.as_str()) + }), + &duration_text(lang, Some(run.created_at.as_str()), run.finished_at.as_deref()), + ); Ok(RunDetail { number: run.number, title: header.title, - state: state_text(lang, run.state.as_str()), - state_class: format!("ci-state ci-{}", run.state.as_str()), + headline, + headline_class, trigger: trigger_text(lang, &run.trigger), branch: short_ref(&run.git_ref).to_owned(), commit_href: header @@ -2124,13 +2176,50 @@ fn query_value(cx: &Cx, key: &str) -> Option { .map(|(_, value)| value.into_owned()) } -/// The runs list: its head with the Run workflow and badge menus, the rows and the pager. The list page -/// and a run's page both keep it at the left, so moving between runs never loses it. +/// The Run workflow and badge menus of the runs list. They sit in the list's head, beside its title. #[component] -async fn run_side(lang: Lang, list: ListView) -> Result { +async fn ci_menus(lang: Lang, list: &ListView) -> Result { + let badge = &list.badge; + Ok(view! { + if let Some(form) = list.manual.as_ref() { + + } + + }) +} + +/// The runs list: one sheet with its tools row, one line per run (each opens the run's page) and the +/// pager. The live list keeps its classes for the page script. +#[component] +async fn runs_sheet(lang: Lang, list: &ListView) -> Result { let ListView { - manual, - badge, total, scale, rows, @@ -2138,99 +2227,66 @@ async fn run_side(lang: Lang, list: ListView) -> Result { older_href, page_label, next_scheduled, + .. } = list; Ok(view! { -
-
-

(g::t(lang, K::Runs)) (total)

-
- if let Some(form) = manual { - - } - -
-
- if let Some(next) = next_scheduled.as_ref() { -

(g::t(lang, K::NextScheduledRun)) ": " rel_time(lang: lang, stamp: next.as_str())

- } - if rows.is_empty() { - empty_state(title: g::t(lang, K::NoRunsYet), hint: Some(g::t(lang, K::NoRunsHint))) - } else { -

(scale.as_str())

- - } - if newer_href.is_some() || older_href.is_some() { - - } -
+ + if let Some((action, token)) = row.rerun.as_ref() { +
+ + +
+ } +
+ } + + } + if newer_href.is_some() || older_href.is_some() { + + } + }) } -/// The runs page body. The header (the Run workflow and badge menus, the count) is the list's, and the -/// split view sits in the live region. The selected run is marked in the list and drawn on the right. +/// The runs page body: the repo head with the Run workflow and badge menus beside its title, then the +/// runs sheet. The live region is the list's stream, so the list re-renders when a run changes. #[component] async fn runs_body( head: RepoHead, @@ -2238,11 +2294,10 @@ async fn runs_body( notice: Option<(&'static str, bool)>, live: Option, list: ListView, - detail: Option, ) -> Result { let (fm, fs) = duration_templates(lang); Ok(view! { - repo_head(head: RepoHead { live: String::new(), ..head }) + repo_head(head: RepoHead { live: String::new(), ..head }, ci_menus(lang: lang, list: &list)) if let Some((text, is_error)) = notice { if is_error { alert(message: text) @@ -2250,7 +2305,7 @@ async fn runs_body(

(text)

} } -
+
- run_side(lang: lang, list: list) -
- if let Some(run) = detail { - 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))) - } -
+ runs_sheet(lang: lang, list: &list)
}) } @@ -2380,191 +2424,190 @@ async fn run_timeline(lang: Lang, run: &RunDetail) -> Result { #[component] async fn run_head(lang: Lang, run: &RunDetail, all_href: Option) -> Result { let cancel_action = format!("{}/cancel", run.action_base); + let rerun_failed_shown = run.writer_csrf.is_some() + && run.can_rerun_failed + && !run.can_approve + && !run.can_cancel; 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())

-
- 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 { - confirm_post(lang: lang, csrf: csrf.as_str(), action: cancel_action.as_str(), label: g::t(lang, K::Cancel), message: crate::pages::passkeys::s(lang, "The run stops and its unfinished jobs are cancelled.", "Çalıştırma durur ve bitmemiş işleri iptal edilir.").to_owned(), confirm: crate::pages::passkeys::s(lang, "Yes, cancel", "Evet, iptal et"), danger: true, fields: vec![]) - } - 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 && run.reachable { - action_button(action: format!("{}/rerun", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Rerun)) - } -
+
+
+

(run.headline.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), primary: true) } -
-
- (run.state.as_str()) - (run.trigger.as_str()) " \u{b7} " (run.branch.as_str()) - if let Some(href) = run.commit_href.as_ref() { - (run.commit.as_str()) - } else { - (run.commit.as_str()) + if run.can_cancel && run.stopping { + + } else if run.can_cancel { + confirm_post(lang: lang, csrf: csrf.as_str(), action: cancel_action.as_str(), label: g::t(lang, K::Cancel), message: crate::pages::passkeys::s(lang, "The run stops and its unfinished jobs are cancelled.", "Çalıştırma durur ve bitmemiş işleri iptal edilir.").to_owned(), confirm: crate::pages::passkeys::s(lang, "Yes, cancel", "Evet, iptal et"), fields: vec![]) } - if !run.actor.is_empty() { - (run.actor.as_str()) + if rerun_failed_shown { + action_button(action: format!("{}/rerun-failed", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::RerunFailed), primary: true) } - 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 !run.can_approve && run.reachable { + action_button(action: format!("{}/rerun", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Rerun), primary: !rerun_failed_shown) } -
- if let Some(est) = run.est.as_ref() { - }
-
+

+ (run.title.as_str()) + + (run.trigger.as_str()) " \u{b7} " (run.branch.as_str()) + + if let Some(href) = run.commit_href.as_ref() { + (run.commit.as_str()) + } else { + (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() { + + } + }) } -/// The class of a job's row: `ci-tl-sub` for a matrix combination, `ci-tl-hassteps` when its steps -/// dropdown sits under the row. -fn job_row_class(job: &JobLine) -> Option<&'static str> { - match (job.sub, job.steps.is_empty()) { - (true, false) => Some("ci-tl-sub ci-tl-hassteps"), - (true, true) => Some("ci-tl-sub"), - (false, false) => Some("ci-tl-hassteps"), - (false, true) => None, - } -} - -/// The class of a step's row under its job: a matrix combination's steps sit one level in. -fn step_class(sub: bool) -> &'static str { - if sub { - "ci-tl-step ci-tl-step-sub" - } else { - "ci-tl-step" - } -} - -/// 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. Each job's steps are a dropdown under its row, open for the selected job. +/// The jobs of a run with more than one job: one `.job-row` each, its name, its tick and a mini strip +/// of its steps. The selected job's row is marked; its steps are the strip under the head. #[component] async fn run_jobs(lang: Lang, run: &RunDetail) -> Result { - let steps_label = crate::pages::passkeys::s(lang, "Steps", "Adımlar"); 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))

+ } + }) +} + +/// The run's artifacts: the zip of all of them and one download line each. +#[component] +async fn run_artifacts(lang: Lang, run: &RunDetail) -> Result { + Ok(view! { + 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)) -
  • - } -
- } - + 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 { +async fn run_log( + lang: Lang, + run: &RunDetail, + timeline: bool, + owner: String, + repo: String, + bars: Vec, +) -> Result { + let job_name = run + .jobs + .iter() + .find(|job| job.selected) + .map(|job| job.name.clone()) + .unwrap_or_default(); Ok(view! { -
+
-
+
+ if !job_name.is_empty() { + (job_name.as_str()) + }
@@ -2597,7 +2640,7 @@ async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result

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

-

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

+

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

    for warning in run.warnings.iter() {
  • (warning.as_str())
  • @@ -2611,25 +2654,32 @@ async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result +

    (crate::pages::passkeys::s(lang, "Showing the end of this log.", "Günlüğün sonu gösteriliyor.")) " " (crate::pages::passkeys::s(lang, "Full log", "Tam günlük"))

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

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

    +

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

    }
run_timeline(lang: lang, run: run) + run_artifacts(lang: lang, run: run) +
+

(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) +
+
}) } -/// 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. +/// The run page body, with no repo tabs: the run's head (its state as the title, its actions, its commit +/// line), the jobs of the run, the strip of the selected job's steps and the sheet with its log and the +/// history. The live region wraps all of it, so the page re-renders when a run or a job changes. #[component] async fn run_body( head: RepoHead, @@ -2642,11 +2692,13 @@ async fn run_body( bars: Vec, timeline: bool, all_href: String, - list: ListView, ) -> Result { let (fm, fs) = duration_templates(lang); + let archived = head.archived; Ok(view! { - repo_head(head: RepoHead { live: String::new(), ..head }) + if archived { +

(crate::i18n::code::t(lang, crate::i18n::code::K::ArchivedNotice))

+ } if let Some((text, is_error)) = notice { if is_error { alert(message: text) @@ -2654,7 +2706,7 @@ async fn run_body(

(text)

} } -
+
- run_side(lang: lang, list: list) -
run_head(lang: lang, run: &run, all_href: Some(all_href)) -
- 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) -
-
-
+ run_jobs(lang: lang, run: &run) + run_strip(run: &run) + run_log(lang: lang, run: &run, timeline: timeline, owner: owner, repo: repo, bars: bars)
}) } @@ -2692,11 +2734,11 @@ async fn runs_list_page(cx: &Cx) -> Result { live, page_title, list, - detail, + .. } = runs_split(cx, None, None, None).await?; Ok(view! { shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), - runs_body(head: head, lang: lang, notice: notice, live: live, list: list, detail: detail)) + runs_body(head: head, lang: lang, notice: notice, live: live, list: list)) }) } @@ -2714,8 +2756,8 @@ async fn run_page(cx: &Cx) -> Result { notice, live, page_title, - list, detail, + .. } = runs_split(cx, Some(&number), wanted.as_deref(), wanted_step).await?; let Some(run) = detail else { return Err(not_found().into()); @@ -2728,7 +2770,7 @@ async fn run_page(cx: &Cx) -> Result { let all_href = ci_href(&title_of(&ctx)); Ok(view! { shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), - run_body(head: head, lang: lang, notice: notice, live: live, run: run, owner: owner, repo: repo, bars: bars, list: list, timeline: timeline, all_href: all_href)) + run_body(head: head, lang: lang, notice: notice, live: live, run: run, owner: owner, repo: repo, bars: bars, timeline: timeline, all_href: all_href)) }) } diff --git a/crates/forge-web/src/pages/ci_tests.rs b/crates/forge-web/src/pages/ci_tests.rs index 5d73559..a31e863 100644 --- a/crates/forge-web/src/pages/ci_tests.rs +++ b/crates/forge-web/src/pages/ci_tests.rs @@ -549,8 +549,8 @@ fn current_href(html: &str) -> Option<&str> { link[at..].split('"').next() } -/// `/ci` draws the newest run and `/ci/runs/n` draws run n. The drawn run is marked in the list. A run -/// that is not on the list page is still drawn, and no row of the list is marked for it. +/// `/ci` is the run list alone, each row opening its run; `/ci/runs/n` draws run n. A run that is not +/// on the list page is still drawn, and no row of the list is marked for it. #[tokio::test] async fn split_view_draws_the_newest_run_or_the_one_named() { let dir = tempfile::tempdir().expect("tempdir"); @@ -558,12 +558,12 @@ async fn split_view_draws_the_newest_run_or_the_one_named() { let first = run_with(&fx, &["build"], false).await; let second = run_with(&fx, &["build"], false).await; let tahinli = Some(cookie_for("tahinli-token")); - let newest = get(&fx.app, RUN_BASE, tahinli.as_deref()).await.text(); - assert!(newest.contains(&format!("data-run=\"{}\"", second.number))); - assert_eq!( - current_href(&newest), - Some(format!("{RUN_BASE}/runs/{}", second.number).as_str()) - ); + let list = get(&fx.app, RUN_BASE, tahinli.as_deref()).await.text(); + for run in [&first, &second] { + assert!(list.contains(&format!("href=\"{RUN_BASE}/runs/{}\"", run.number))); + } + assert!(!list.contains("data-run="), "the list draws no run"); + assert_eq!(current_href(&list), None); let named = get( &fx.app, &format!("{RUN_BASE}/runs/{}", first.number), @@ -572,13 +572,14 @@ async fn split_view_draws_the_newest_run_or_the_one_named() { .await .text(); assert!(named.contains(&format!("data-run=\"{}\"", first.number))); - // The run page keeps the list beside it, so the run row and the selected job are both marked. On a - // phone the list gives way to the All runs link. + // The run page is the run alone: the All runs link goes back to the list, and a one-job run has + // no job list to mark. assert!( named.contains(&format!("href=\"{RUN_BASE}\"")), "All runs link" ); - assert_eq!(named.matches("aria-current=\"true\"").count(), 2); + assert!(!named.contains("ci-run-list")); + assert_eq!(named.matches("aria-current=\"true\"").count(), 0); // Thirty runs make two pages. Run 1 is on page 2, so page 1 marks no row and draws run 1. for _ in 0..28 { @@ -592,9 +593,7 @@ async fn split_view_draws_the_newest_run_or_the_one_named() { .await .text(); assert!(off_page.contains(&format!("data-run=\"{}\"", first.number))); - // The list shows the newest page, which does not hold this run: only its selected job is marked. - assert!(off_page.contains("ci-run-list")); - assert_eq!(off_page.matches("aria-current=\"true\"").count(), 1); + // A run off the list's first page opens all the same. assert!(off_page.contains(&format!("data-live=\"{RUN_BASE}/events\""))); let rows = get(&fx.app, &format!("{RUN_BASE}?page=2"), tahinli.as_deref()) .await @@ -1482,6 +1481,11 @@ async fn running_runs_and_run_page_previews() { html.contains("data-tick=\"rest\""), "the hatched remainder follows the clock" ); + // The timeline is on the run's own page. + let html = get(&fx.app, &format!("{RUN_BASE}/runs/1"), Some(&cookie)) + .await + .text() + .to_owned(); assert!( html.contains("data-live-gantt=\"true\""), "the timeline is live" diff --git a/crates/forge-web/src/pages/code_search.rs b/crates/forge-web/src/pages/code_search.rs index d595b9f..93bf0dc 100644 --- a/crates/forge-web/src/pages/code_search.rs +++ b/crates/forge-web/src/pages/code_search.rs @@ -203,57 +203,57 @@ async fn search_page(cx: &Cx) -> Result { let ref_label = ref_name.clone(); let mut header = ctx.head(state, "code").await?; - header.hide_search = true; // Results of a branch go stale when it moves: the header's stream follows that branch's head. header.live = branch_live_url(&owner_name, &repo_name, &ref_name); Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), repo_head(head: header) -
-
- } else if searched { - empty_state(title: g::t(lang, K::NoMatches)) + } else if searched { + empty_state(title: g::t(lang, K::NoMatches)) + } } - } -
+ ) }) } diff --git a/crates/forge-web/src/pages/commit.rs b/crates/forge-web/src/pages/commit.rs index e26ffb1..82bfd14 100644 --- a/crates/forge-web/src/pages/commit.rs +++ b/crates/forge-web/src/pages/commit.rs @@ -172,7 +172,9 @@ async fn commit_page(cx: &Cx) -> Result { .collect(); let is_root = parents.is_empty(); let body = trailers::strip_co_authors(&info.message); - let has_body = !body.trim().is_empty(); + // The first line is the head's title, so only what follows it is shown as the message. + let body_rest = body.split_once('\n').map_or("", |(_, rest)| rest).trim(); + let has_body = !body_rest.is_empty(); let mut coauthors: Vec = Vec::new(); for co in trailers::co_authors(&info.message) { if co.email.eq_ignore_ascii_case(&info.author_email) { @@ -224,6 +226,7 @@ async fn commit_page(cx: &Cx) -> Result { let show_full = g::t(lang, K::ShowFullMessage); let full_oid = info.oid.clone(); let message = emojify(&body).into_owned(); + let rest_message = emojify(body_rest).into_owned(); let statuses = state.store.statuses_for(&ctx.repo.id, &full_oid).await?; let checks = (!statuses.is_empty()).then(|| StatusSummary::from_rows(&statuses)); let sig = signatures::badges(state, &ctx.repo, std::slice::from_ref(&full_oid)) @@ -257,98 +260,100 @@ async fn commit_page(cx: &Cx) -> Result { header.live = ref_live::live_url(&owner_name, &repo_name); 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) - } - - (author.name.as_str()) - if has_coauthors { - (g::t(lang, K::CoAuthorAnd)) - for c in coauthors.iter() { - if c.sep { ", " } - if let Some(href) = c.href.as_ref() { - - if let Some(src) = c.avatar.as_ref() { - - } - (c.name.as_str()) - - } else { - (c.name.as_str()) - } - } - if folded { - ", " -
- (others.as_str()) - -
- } + repo_head(head: header, title: Some(heading.clone()), + (g::t(lang, K::BrowseFiles)) + ) +
+
+ + (full_oid.as_str()) + if let Some(badge) = sig { + (badge.label) } - - - if is_root { - (g::t(lang, K::RootCommit)) - } else { - (g::t(lang, K::ParentLabel)) - for p in parents.iter() { - (p.short.as_str()) + + (author.name.as_str()) + if has_coauthors { + (g::t(lang, K::CoAuthorAnd)) + for c in coauthors.iter() { + if c.sep { ", " } + if let Some(href) = c.href.as_ref() { + + if let Some(src) = c.avatar.as_ref() { + + } + (c.name.as_str()) + + } else { + (c.name.as_str()) + } + } + if folded { + ", " +
+ (others.as_str()) + +
+ } }
+ + if is_root { + (g::t(lang, K::RootCommit)) + } else { + (g::t(lang, K::ParentLabel)) + for p in parents.iter() { + (p.short.as_str()) + } + + } + if let Some(summary) = checks { + checks_summary(summary: summary, lang: StatusLang(lang)) + } +
+ if let Some(msg) = parsed.as_ref() { +
+
    + for group in msg.groups.iter() { +
  • + (group.kind.as_str()) +
      + for clause in group.clauses.iter() { +
    • (clause.as_str())
    • + } +
    +
  • + } +
+
+ (show_full) +
+
(message.as_str())
+
+
+
} - if let Some(summary) = checks { - checks_summary(summary: summary, lang: StatusLang(lang)) + if parsed.is_none() && has_body { +
+
(rest_message.as_str())
+
}
- - if let Some(msg) = parsed.as_ref() { -
    - for group in msg.groups.iter() { -
  • - (group.kind.as_str()) -
      - for clause in group.clauses.iter() { -
    • (clause.as_str())
    • - } -
    -
  • - } -
-
- (show_full) -
-
(message.as_str())
-
-
- } - if parsed.is_none() && 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/commits.rs b/crates/forge-web/src/pages/commits.rs index e6a75de..0ccae65 100644 --- a/crates/forge-web/src/pages/commits.rs +++ b/crates/forge-web/src/pages/commits.rs @@ -5,7 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use std::collections::HashMap; -use forge_core::store::commit_status::{CommitStatus, StatusState}; +use forge_core::store::commit_status::CommitStatus; use forge_core::tz::{format_in_tz, local_date}; use forge_git::browse::{self, CommitInfo}; use forge_git::history; @@ -152,18 +152,6 @@ fn day_label( } } -impl CommitRow { - /// The CI dot's class: none without statuses, ok, bad, or live while a status is pending. - pub(crate) fn dot(&self) -> &'static str { - match self.status.state { - None => "commits-dot none", - Some(StatusState::Success) => "commits-dot ok", - Some(StatusState::Failure | StatusState::Error) => "commits-dot bad", - Some(StatusState::Pending) => "commits-dot live", - } - } -} - /// A signature badge prepared for display: the CSS classes, the visible label and the title. #[derive(Clone)] pub(crate) struct SigBadgeView { @@ -355,74 +343,76 @@ async fn commits_page(cx: &Cx) -> Result { Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), repo_head(head: header) -

(g::t(lang, K::CommitsOn)) (ref_name.as_str())

- if has_filter { -

(g::t(lang, K::FilteredTo)) (filter_text.as_str()) (g::t(lang, K::ClearFilter))

- } - if empty { -

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

- if has_filter { - - } - } else { - for group in groups.iter() { -
-

(group.label.as_str())

-
- for row in group.rows.iter() { - if let Some(body) = row.body.clone() { -
- - - +
+
+ (g::t(lang, K::CommitsOn)) (ref_name.as_str()) + if has_filter { + (g::t(lang, K::FilteredTo)) (filter_text.as_str()) + (g::t(lang, K::ClearFilter)) + } +
+ if empty { +

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

+ if has_filter { + + } + } else { + for group in groups.iter() { +
+

(group.label.as_str())

+
+ for row in group.rows.iter() { + if let Some(body) = row.body.clone() { +
+ + commit_line(subject: row.summary.clone()) + (row.author.as_str()) " · " + if let Some(badge) = row.sig.clone() { + (badge.label) + } + (row.short.as_str()) + +
+
(body.as_str())
+ if !row.status.items.is_empty() { +
+ status_list(items: row.status.items.clone(), lang: lang) +
+ } + +
+
+ } else { +
commit_line(subject: row.summary.clone()) (row.author.as_str()) " · " if let Some(badge) = row.sig.clone() { (badge.label) } (row.short.as_str()) -
-
-
(body.as_str())
- if !row.status.items.is_empty() { -
- status_list(items: row.status.items.clone(), lang: lang) -
- } - + commit_status(summary: row.status.clone(), lang: StatusLang(lang)) + (g::t(lang, K::BrowseFilesShort))
-
- } else { -
- - commit_line(subject: row.summary.clone()) - (row.author.as_str()) " · " - if let Some(badge) = row.sig.clone() { - (badge.label) - } - (row.short.as_str()) - commit_status(summary: row.status.clone(), lang: StatusLang(lang)) - (g::t(lang, K::BrowseFilesShort)) -
+ } } - } -
-
- } - } - if has_newer || has_older { -
+ } - - } + } + if has_newer || has_older { + + } + ) }) } diff --git a/crates/forge-web/src/pages/compare.rs b/crates/forge-web/src/pages/compare.rs index 7a646bf..1ee200a 100644 --- a/crates/forge-web/src/pages/compare.rs +++ b/crates/forge-web/src/pages/compare.rs @@ -324,81 +324,81 @@ async fn compare_view( let error_text = error.unwrap_or_default(); let csrf = csrf_of(&ctx); let pulls_action = repo_href(&owner, &name, "pulls", ""); - let heading_base = base.clone(); - let heading_head = head.clone(); + let compare_title = format!("{}{base}...{head}", g::t(lang, K::ComparingPrefix)); let mut header = ctx.head(state, "commits").await?; header.live = ref_live::live_url(&ctx.repo.owner_name, &ctx.repo.name); let __cx = cx; Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) - if has_commits { -
-

(commits_label.as_str())

-
- for row in rows.iter() { -
- commit_line(subject: row.summary.clone()) - - (row.author.as_str()) - if !row.email.is_empty() { - " · " (row.email.as_str()) - } - if lang == i18n::Lang::Tr { - " · " " " (g::t(lang, K::Committed)) - } else { - " · " (g::t(lang, K::Committed)) " " - } - - (row.short.as_str()) - (g::t(lang, K::BrowseFiles)) + repo_head(head: header, title: Some(compare_title)) +
+ if has_commits { +
+

(commits_label.as_str())

+
+ for row in rows.iter() { +
+ commit_line(subject: row.summary.clone()) + + (row.author.as_str()) + if !row.email.is_empty() { + " · " (row.email.as_str()) + } + if lang == i18n::Lang::Tr { + " · " " " (g::t(lang, K::Committed)) + } else { + " · " (g::t(lang, K::Committed)) " " + } + + (row.short.as_str()) + (g::t(lang, K::BrowseFiles)) +
+ }
+
+ } +
+ if unrelated { +

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

} -
-
- } -
-

(g::t(lang, K::ComparingPrefix)) (heading_base.as_str()) "..." (heading_head.as_str())

- if unrelated { -

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

- } - if nothing { -

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

- } - if show_form { -
- reveal(label: g::t(lang, K::OpenPullRequest), id: Some("open-pull"), open: has_error, - if has_error { - alert(message: error_text.as_str()) + if nothing { +

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

} -
- - - -
- - -
-
- - -
+ if show_form {
- - + reveal(label: g::t(lang, K::OpenPullRequest), id: Some("open-pull"), open: has_error, + if has_error { + alert(message: error_text.as_str()) + } + + + + +
+ + +
+
+ + +
+
+ + +
+ + )
- - ) -
- } - if has_existing { -

(g::t(lang, K::AlreadyOpen)) (g::t(lang, K::ViewIt))

- } - if archived_note { -

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

- } -
+ } + if has_existing { +

(g::t(lang, K::AlreadyOpen)) (g::t(lang, K::ViewIt))

+ } + if archived_note { +

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

+ } + + if show_diff { for d in diff.iter() { diff_section(diff: d, owner: owner.as_str(), repo: name.as_str(), oid: cmp.head_oid.as_str(), parent: parent.as_deref(), subject: g::t(lang, K::ThisComparison), lang: DiffLang(lang), opts: opts.clone()) @@ -426,9 +426,9 @@ async fn picker_view(cx: &Cx, ctx: RepoCtx, base: String, head: String) -> Resul let __cx = cx; Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) + repo_head(head: header, title: Some(g::t(lang, K::CompareBranches).to_owned())) +
-

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

@@ -446,6 +446,7 @@ async fn picker_view(cx: &Cx, ctx: RepoCtx, base: String, head: String) -> Resul
+
) }) } diff --git a/crates/forge-web/src/pages/discussion_settings.rs b/crates/forge-web/src/pages/discussion_settings.rs index 5c3c8c8..030df1b 100644 --- a/crates/forge-web/src/pages/discussion_settings.rs +++ b/crates/forge-web/src/pages/discussion_settings.rs @@ -23,7 +23,7 @@ use crate::views::repo_href; path_param!(owner); path_param!(repo); -/// The Discussions topic: a hint, then one switch. `enabled` is the current state. The switch submits +/// The Discussions topic: one switch, then its hint. `enabled` is the current state. The switch submits /// the form on change (`data-autosubmit`); an unchecked box sends no `enabled`, which the handler reads as off. #[component] pub(crate) async fn discussions_card( @@ -40,13 +40,13 @@ pub(crate) async fn discussions_card( Ok(view! {

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

-

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

+

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

}) diff --git a/crates/forge-web/src/pages/discussion_view.rs b/crates/forge-web/src/pages/discussion_view.rs index 29a98b3..cf0f592 100644 --- a/crates/forge-web/src/pages/discussion_view.rs +++ b/crates/forge-web/src/pages/discussion_view.rs @@ -25,7 +25,7 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo}; use crate::pages::tree::link_context; use crate::render::markdown::{LinkContext, render_markdown}; use crate::state::AppState; -use crate::views::parts::{confirm_act, post_act, reveal}; +use crate::views::parts::{SubPart, confirm_act, post_act, reveal}; use crate::views::{avatar_url, display_name, now_unix, shell, user_href, user_link}; path_param!(owner); @@ -184,9 +184,9 @@ async fn comment_article(item: CommentView) -> Result { } = item; let profile = user_href(&login); let class = if accepted { - "sec discussion-accepted" + "sec thread-entry discussion-accepted" } else { - "sec" + "sec thread-entry" }; let answer_fields = vec![ ("comment_id".to_owned(), id.clone()), @@ -198,18 +198,18 @@ async fn comment_article(item: CommentView) -> Result { let edit_open = format!("edit-open-{id}"); Ok(view! {
-

+

if deleted { (g::t(lang, K::CommentDeleted)) } else { - " " user_link(shown: author.as_str(), login: login.as_str()) - " " + user_link(shown: author.as_str(), login: login.as_str()) + } if accepted { " · " (g::t(lang, K::Answer)) } -

+
if !deleted {
(Unescaped::new_unchecked(html))
if let Some(bar) = reactions { @@ -414,31 +414,29 @@ async fn discussion_page( let header = ctx.head(state, "discussions").await?; let comments_label = g::comments_total(lang, discussion.comment_count); + let mut sub = vec![SubPart::text(category)]; + if answered { + sub.push(SubPart::text(g::t(lang, K::Answered))); + } + if locked { + sub.push(SubPart::text(g::t(lang, K::Locked))); + } + sub.push(SubPart::link(author.clone(), author_profile.clone())); + sub.push(SubPart::text(opened.relative.clone())); + sub.push(SubPart::text(comments_label)); Ok(view! { cx => shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) -
-

(discussion.title.as_str()) " " (number_label.as_str())

-

- (category) - if answered { - " " (g::t(lang, K::Answered)) - } - if locked { - " " (g::t(lang, K::Locked)) - } - " " user_link(shown: author.as_str(), login: author_login.as_str()) - " " (g::t(lang, K::OpenedThis)) " " - - " " (g::t(lang, K::OpenedSeparator)) " " - (comments_label.as_str()) -

-
-
-

+ repo_head(head: header, title: Some(discussion.title.clone()), sub: sub, + (number_label.as_str()) + ) +

+
+
+
- " " user_link(shown: author.as_str(), login: author_login.as_str()) -

+ user_link(shown: author.as_str(), login: author_login.as_str()) + +
(Unescaped::new_unchecked(body_html))
if let Some(bar) = body_bar { reaction_row(lang: lang, bar: bar) @@ -487,13 +485,15 @@ async fn discussion_page(

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

} if triage && !archived { -
+

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

post_act(label: lock_label, action: lock_action.as_str(), csrf: csrf.as_str(), fields: vec![("locked".to_owned(), lock_value.to_owned())])
} +
+
) }) } diff --git a/crates/forge-web/src/pages/discussions.rs b/crates/forge-web/src/pages/discussions.rs index 1f2c5e9..0bdec6b 100644 --- a/crates/forge-web/src/pages/discussions.rs +++ b/crates/forge-web/src/pages/discussions.rs @@ -22,11 +22,12 @@ use crate::i18n::{self, Lang}; use crate::pages::discussion_live::list_live_url; use crate::pages::issue_meta::{can_triage, form_field, form_pairs, refusal_message}; use crate::pages::issue_parts::When; -use crate::pages::issues_list::{list_href, state_tab}; +use crate::pages::issues_list::list_href; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; use crate::render::markdown::mentioned_usernames; use crate::state::AppState; +use crate::views::parts::{RailItem, SubPart, rail}; use crate::views::{alert, csrf_field, now_unix, repo_href, shell, user_link}; path_param!(owner); @@ -262,18 +263,28 @@ async fn discussions_list_page(cx: &Cx) -> Result { let selected = category.map_or("", |c| c.as_str()); let all_on = category.is_none(); let all_href = list_href(&base, &[]); - let all_label = g::t(lang, K::AllCategories); let nav_label = g::t(lang, K::CategoriesNav); - let tabs: Vec<(&'static str, String, bool)> = DISCUSSION_CATEGORIES - .iter() - .map(|c| { - ( - g::category_label(lang, *c), - list_href(&base, &[("category", c.as_str())]), - category == Some(*c), - ) - }) - .collect(); + let list_title = match category { + Some(c) => g::category_label(lang, c), + None => g::t(lang, K::AllCategories), + }; + let mut rail_items: Vec = vec![RailItem { + name: g::t(lang, K::AllCategories).to_owned(), + val: String::new(), + href: all_href, + current: all_on, + }]; + rail_items.extend(DISCUSSION_CATEGORIES.iter().map(|c| RailItem { + name: g::category_label(lang, *c).to_owned(), + val: String::new(), + href: list_href(&base, &[("category", c.as_str())]), + current: category == Some(*c), + })); + let sub = vec![SubPart::text(match lang { + Lang::En if total == 1 => "1 discussion".to_owned(), + Lang::En => format!("{total} discussions"), + Lang::Tr => format!("{total} tartışma"), + })]; let last_page = total.div_ceil(u64::from(PER_PAGE)).max(1); let has_newer = page > 1; @@ -302,62 +313,51 @@ async fn discussions_list_page(cx: &Cx) -> Result { let header = ctx.head(state, "discussions").await?; Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) -
-

(title.as_str())

- - if can_start { - - } - if rows.is_empty() { -

(empty_text)

+ repo_head(head: header, sub: sub, if can_start { - + (new_label) } - } else { -
- for row in rows.iter() { -
-
-
- (row.title.as_str()) - (row.category) -
-
- (by_before) - user_link(shown: row.author.as_str(), login: row.author.as_str()) - (by_middle) + ) +
+ rail(label: nav_label, items: rail_items) +
+
+ (list_title) +
+ if rows.is_empty() { +

(empty_text)

+ if can_start { + + } + } else { + for row in rows.iter() { +
+ (row.title.as_str()) + (row.category) + + (by_before) user_link(shown: row.author.as_str(), login: row.author.as_str()) (by_middle) - if !by_after.is_empty() { - (by_after) - } - (row.comments_text.as_str()) -
+ (by_after) + " · " + (row.comments_text.as_str()) +
-
- } -
- } - if has_newer || has_older { - - } +
) }) @@ -382,8 +382,8 @@ async fn new_discussion_body( let action = discussions_href(&head.owner, &head.name, "new"); let cancel = discussions_href(&head.owner, &head.name, ""); Ok(view! { - repo_head(head: head) -

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

+ repo_head(head: head, title: Some(g::t(lang, K::NewDiscussion).to_owned())) +
if let Some(message) = draft.error { alert(message: message.as_str()) } @@ -411,6 +411,7 @@ async fn new_discussion_body( (g::t(lang, K::Cancel))
+
}) } diff --git a/crates/forge-web/src/pages/edit_history.rs b/crates/forge-web/src/pages/edit_history.rs index dda1609..0314565 100644 --- a/crates/forge-web/src/pages/edit_history.rs +++ b/crates/forge-web/src/pages/edit_history.rs @@ -23,6 +23,7 @@ use crate::pages::pull_live::pull_live_url; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, load_repo}; use crate::state::AppState; +use crate::views::parts::SubPart; use crate::views::{display_name, now_unix, repo_href, shell}; path_param!(owner); @@ -228,6 +229,10 @@ async fn history_page( let heading = g::history_heading(lang, what); let back_label = g::back_to_item(lang, number); let count_label = g::earlier_versions(lang, entries.len()); + let sub = vec![ + SubPart::link(back_label, back), + SubPart::text(count_label), + ]; // A history follows its item: a new edit adds a version to the list. let live = match kind_item { ItemKind::Issue => item_live_url(&owner, &name, number), @@ -236,22 +241,18 @@ async fn history_page( Ok(view! { cx => shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) -
-

(heading.as_str())

-

- (back_label.as_str()) - " · " - (count_label.as_str()) -

-
-
+ repo_head(head: header, title: Some(heading), sub: sub) +
+
if entries.is_empty() { -

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

- } - for entry in entries.into_iter() { - history_entry(lang: lang, entry: entry) +

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

} +
+ for entry in entries.into_iter() { + history_entry(lang: lang, entry: entry) + } +
+
) }) @@ -270,7 +271,7 @@ async fn history_entry(lang: Lang, entry: HistoryEntry) -> Result { } = entry; let title_text = title_change.map(|(from, to)| g::title_change(lang, &from, &to)); Ok(view! { -
+
(editor.as_str()) (g::t(lang, K::EditedBy)) diff --git a/crates/forge-web/src/pages/explore.rs b/crates/forge-web/src/pages/explore.rs index ef58d0d..011c2b3 100644 --- a/crates/forge-web/src/pages/explore.rs +++ b/crates/forge-web/src/pages/explore.rs @@ -15,6 +15,7 @@ use crate::i18n::orgs::{self as g, K}; use crate::i18n::{self, Lang}; use crate::live::{Topic, stream_changes}; use crate::state::AppState; +use crate::views::parts::{SubPart, head}; use crate::views::repo_list::{ PageLink, RepoRow, SortLink, pager, pager_links, repo_rows, sort_chips, }; @@ -199,18 +200,17 @@ async fn explore_body( let (links, prev, next) = nav; let clear_href = explore_href("", sort, 1); Ok(view! { -

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

-
-

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

- -
+ head(title: g::t(lang, K::Explore), sub: vec![SubPart::text(g::t(lang, K::PublicReposIntro))]) +
+
+ (g::repo_count(lang, total)) + sort_chips(links: sort_links, lang: lang) - (g::repo_count(lang, total))
if empty {

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

@@ -226,14 +226,12 @@ async fn explore_body( if has_orgs {

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

-
- for org in orgs.iter() { - (org.as_str()) - } -
+ for org in orgs.iter() { + (org.as_str()) + }
} -
+
}) } diff --git a/crates/forge-web/src/pages/forgot.rs b/crates/forge-web/src/pages/forgot.rs index ccf788c..20dfe30 100644 --- a/crates/forge-web/src/pages/forgot.rs +++ b/crates/forge-web/src/pages/forgot.rs @@ -22,6 +22,7 @@ use crate::mail::account; use crate::pages::register::check_new_password; use crate::state::AppState; use crate::throttle; +use crate::views::parts::{SubPart, head}; use crate::views::{alert, shell}; /// Reset requests allowed per client IP inside the throttle window. @@ -58,9 +59,8 @@ enum ResetMode { #[component] async fn forgot_form(lang: Lang, precsrf: &str) -> Result { Ok(view! { -
-

(t(lang, Key::ForgotTitle))

-

(t(lang, Key::ForgotSub))

+ head(title: t(lang, Key::ForgotTitle), sub: vec![SubPart::text(t(lang, Key::ForgotSub))]) +
@@ -69,17 +69,17 @@ async fn forgot_form(lang: Lang, precsrf: &str) -> Result {
-
+
}) } #[component] async fn forgot_sent(lang: Lang) -> Result { Ok(view! { -
-

(t(lang, Key::ForgotTitle))

+ head(title: t(lang, Key::ForgotTitle)) +

(t(lang, Key::ForgotSent))

-
+ }) } @@ -149,11 +149,15 @@ async fn reset_body( mode: ResetMode, error: Option, ) -> Result { + let sub = if mode == ResetMode::Form { + vec![SubPart::text(t(lang, Key::ResetSub))] + } else { + Vec::new() + }; Ok(view! { -
-

(t(lang, Key::ResetTitle))

+ head(title: t(lang, Key::ResetTitle), sub: sub) +
if mode == ResetMode::Form { -

(t(lang, Key::ResetSub))

if let Some(message) = error { alert(message: message.as_str()) @@ -183,7 +187,7 @@ async fn reset_body( (t(lang, Key::LogIn))
} -
+ }) } diff --git a/crates/forge-web/src/pages/home.rs b/crates/forge-web/src/pages/home.rs index a9b401b..c7e679e 100644 --- a/crates/forge-web/src/pages/home.rs +++ b/crates/forge-web/src/pages/home.rs @@ -11,6 +11,7 @@ use crate::i18n::orgs::{self as g, K}; use crate::i18n::{self, Lang}; use crate::pages::repo_settings::{notice_banner_for, take_notice}; use crate::state::AppState; +use crate::views::parts::{SubPart, head}; use crate::views::{enc, shell}; #[page("/")] @@ -33,15 +34,11 @@ async fn home(cx: &Cx) -> Result { #[component] async fn landing(has_users: bool, lang: Lang) -> Result { Ok(view! { -
-

"forge"

-

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

- -
+ head(title: "forge", sub: vec![SubPart::text(g::t(lang, K::LandingTagline))], + (g::t(lang, K::LogIn)) + if !has_users { + (g::t(lang, K::SetUpForge)) + } + ) }) } diff --git a/crates/forge-web/src/pages/import.rs b/crates/forge-web/src/pages/import.rs index 350e18f..1694dec 100644 --- a/crates/forge-web/src/pages/import.rs +++ b/crates/forge-web/src/pages/import.rs @@ -31,6 +31,7 @@ use crate::pages::ci_runs::{changed_event, events_response}; use crate::pages::new_repo::{owner_choices, repo_owner}; use crate::pages::repo_ctx::still_readable; use crate::state::AppState; +use crate::views::parts::{SubPart, head}; use crate::views::{alert, csrf_field, rel_time, shell, user_facing_message}; path_param!(job_id); @@ -179,7 +180,7 @@ async fn source_tabs(lang: Lang, base: &str, active: Source) -> Result + + readme_sheet(lang: lang, owner: dock_owner, repo: dock_repo, ref_name: ref_name.clone(), dir: dir.clone(), readme: readme, + none: s(lang, "No README in this folder", "Bu klasörde README yok")) - repo_dock(lang: lang, runs: runs, total: total, ci_href: ci_href, - owner: dock_owner, repo: dock_repo, bars: bars, latest: bar) ) }) } diff --git a/crates/forge-web/src/pages/user_prefs.rs b/crates/forge-web/src/pages/user_prefs.rs index d3d5093..c90230f 100644 --- a/crates/forge-web/src/pages/user_prefs.rs +++ b/crates/forge-web/src/pages/user_prefs.rs @@ -1,5 +1,4 @@ -//! Route: `POST /-/prefs`, a signed-in user's account preferences: the tree width of a repo home, -//! the profile corner's position and the diff view. The values live in the `user_prefs` table +//! Route: `POST /-/prefs`, a signed-in user's account preferences: the diff view. The values live in the `user_prefs` table //! (store/user_prefs.rs). Only the keys below are accepted; each has its own check. An empty value //! deletes the key. Signed-out callers get what `require_csrf` gives. @@ -15,16 +14,9 @@ use topcoat::router::{Body, route}; use crate::auth::require_csrf; use crate::state::AppState; -/// Key of the repo home's file tree width, in CSS pixels. -pub const TREE_WIDTH: &str = "tree_width"; -/// Key of the profile corner's position: `x,y` as fractions of the free space, each 0 to 1. -pub const CORNER_POS: &str = "corner_pos"; /// Key of the diff view: `split` or `unified`. pub const DIFF_VIEW: &str = "diff_view"; -const MIN_TREE_WIDTH: u32 = 120; -const MAX_TREE_WIDTH: u32 = 4000; - #[derive(Deserialize)] struct PrefForm { #[serde(default)] @@ -39,37 +31,6 @@ struct PrefForm { /// the value to store (normalised), and `Err` is the reason a 400 gives. pub fn clean_pref(key: &str, value: &str) -> std::result::Result, &'static str> { match key { - TREE_WIDTH => { - if value.is_empty() { - return Ok(None); - } - let width = value - .bytes() - .all(|b| b.is_ascii_digit()) - .then(|| value.parse::().ok()) - .flatten() - .filter(|w| (MIN_TREE_WIDTH..=MAX_TREE_WIDTH).contains(w)); - width - .map(|w| Some(w.to_string())) - .ok_or("tree_width must be a whole number from 120 to 4000") - } - CORNER_POS => { - if value.is_empty() { - return Ok(None); - } - let fraction = |s: &str| { - s.parse::() - .ok() - .filter(|v| v.is_finite() && (0.0..=1.0).contains(v)) - }; - match value.split_once(',') { - Some((x, y)) => match (fraction(x), fraction(y)) { - (Some(x), Some(y)) => Ok(Some(format!("{x},{y}"))), - _ => Err("corner_pos must be two numbers from 0 to 1 written x,y"), - }, - None => Err("corner_pos must be two numbers from 0 to 1 written x,y"), - } - } DIFF_VIEW => match value { "" => Ok(None), "split" | "unified" => Ok(Some(value.to_owned())), @@ -103,7 +64,7 @@ mod tests { use crate::test_support::{app_router, create_session, test_state}; #[tokio::test] - async fn prefs_route_refuses_unknown_keys_and_stores_a_corner_position() { + async fn prefs_route_refuses_unknown_keys_and_stores_the_diff_view() { let dir = tempfile::tempdir().expect("tempdir"); let state = test_state(dir.path()).await; let user = state @@ -131,28 +92,11 @@ mod tests { let _ = to_bytes(unknown.into_body(), usize::MAX).await.unwrap(); let stored = router - .handle(post("csrf=prefs-csrf&key=corner_pos&value=0.5%2C0.25")) + .handle(post("csrf=prefs-csrf&key=diff_view&value=split")) .await; - assert_eq!(stored.status().as_u16(), 204, "corner position saved"); + assert_eq!(stored.status().as_u16(), 204, "diff view saved"); let _ = to_bytes(stored.into_body(), usize::MAX).await.unwrap(); let prefs = state.store.user_prefs(&user.id).await.unwrap(); - assert_eq!(prefs.get(CORNER_POS).map(String::as_str), Some("0.5,0.25")); - - let page = router - .handle( - Request::builder() - .method("GET") - .uri("/tahinli") - .header("cookie", cookie.as_str()) - .body(Body::empty()) - .unwrap(), - ) - .await; - assert_eq!(page.status().as_u16(), 200); - let bytes = to_bytes(page.into_body(), usize::MAX).await.unwrap(); - assert!( - String::from_utf8_lossy(&bytes).contains("data-corner-pos=\"0.5,0.25\""), - "the page carries the stored corner" - ); + assert_eq!(prefs.get(DIFF_VIEW).map(String::as_str), Some("split")); } } diff --git a/crates/forge-web/src/pages/wiki.rs b/crates/forge-web/src/pages/wiki.rs index a72a95f..1fc4fe4 100644 --- a/crates/forge-web/src/pages/wiki.rs +++ b/crates/forge-web/src/pages/wiki.rs @@ -17,7 +17,7 @@ use topcoat::context::{Cx, app_context}; use topcoat::router::content::Form; use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; use topcoat::router::{page, path_param, route}; -use topcoat::view::{Unescaped, View, component, view}; +use topcoat::view::{Child, Unescaped, View, component, view}; use crate::audit::{self, Actor, Target}; use crate::auth::{require_csrf, require_user}; @@ -30,6 +30,7 @@ use crate::pages::repo_settings::settings_frame; use crate::pages::wiki_live::{bump_wiki, page_live_url, wiki_live_url}; use crate::render::markdown::render_markdown; use crate::state::AppState; +use crate::views::parts::{RailItem, rail}; use crate::views::{alert, empty_state, rel_time, repo_href, shell}; path_param!(owner); @@ -147,44 +148,87 @@ fn revision_rows(ctx: &RepoCtx, revs: &[PageRevision]) -> Vec { .collect() } -/// The header every wiki screen shares: the page name as its heading when the screen has links -/// of its own (a page, its history, an edit), then the wiki's navigation as second-level text -/// links (Home, All pages, any page-specific `extra` links) with "New page" as an action. +/// The links every wiki sheet offers: Home, All pages, the screen's own `extra` links, and New +/// page for a writer. +fn wiki_links( + lang: Lang, + owner: &str, + repo: &str, + can_write: bool, + extra: Vec<(String, String)>, +) -> Vec<(String, String)> { + let mut links = vec![ + ( + g::t(lang, K::Home).to_owned(), + repo_href(owner, repo, "wiki", ""), + ), + ( + g::t(lang, K::AllPages).to_owned(), + repo_href(owner, repo, "wiki", "-/pages"), + ), + ]; + links.extend(extra); + if can_write { + links.push(( + g::t(lang, K::NewPage).to_owned(), + repo_href(owner, repo, "wiki", "-/new"), + )); + } + links +} + +/// The page list beside a wiki page: every page, the one on screen marked. #[component] -async fn wiki_head( +async fn wiki_rail( lang: Lang, owner: String, repo: String, - can_write: bool, - title: String, - extra: Vec<(String, String)>, - live: Option, + names: Vec, + current: String, ) -> Result { - let home = repo_href(&owner, &repo, "wiki", ""); - let pages = repo_href(&owner, &repo, "wiki", "-/pages"); - let new = repo_href(&owner, &repo, "wiki", "-/new"); - let heading_shown = !extra.is_empty(); + let items: Vec = names + .into_iter() + .map(|name| RailItem { + href: repo_href(&owner, &repo, "wiki", &name), + current: name == current, + name: name.replace('-', " "), + val: String::new(), + }) + .collect(); Ok(view! { -
- if heading_shown { -

(title.as_str())

- } else { -

(title.as_str())

- } - +
+ (child) }) } +/// The page names of the wiki, for the rail and the page list. +async fn page_names(dir: PathBuf) -> Result> { + blocking(move || wiki::list_pages(&dir)).await +} + /// The Edit / History links shown in the header of a rendered page. fn page_links( lang: Lang, @@ -251,13 +295,11 @@ async fn wiki_list_body( if rows.is_empty() { empty_state(title: g::t(lang, K::NoPagesYet)) } else { -
- for (title, href) in rows.into_iter() { - - (title.as_str()) - - } -
+ for (title, href) in rows.into_iter() { + + (title.as_str()) + + } } }) } @@ -268,14 +310,12 @@ async fn wiki_history_body(lang: Lang, rows: Vec) -> Result - for row in rows.into_iter() { - - (row.subject.as_str()) - (row.short.as_str()) " · " (row.author.as_str()) " · " rel_time(lang: lang, stamp: row.when.as_str()) - - } - + for row in rows.into_iter() { + + (row.subject.as_str()) + (row.short.as_str()) " · " (row.author.as_str()) " · " rel_time(lang: lang, stamp: row.when.as_str()) + + } } }) } @@ -339,6 +379,7 @@ async fn wiki_home(cx: &Cx) -> Result { let state = app_context::(cx); ensure_enabled(state, &ctx).await?; let dir = wiki_dir(state, &ctx)?; + let names = page_names(dir.clone()).await?; let (_, home) = load_page(dir, "Home".to_owned()).await?; let can_write = ctx.can_write(); let owner_name = ctx.repo.owner_name.clone(); @@ -351,25 +392,32 @@ async fn wiki_home(cx: &Cx) -> Result { ctx.repo.name, g::t(lang, K::Wiki) ); - let (head_title, links) = if body_html.is_some() { + let live = wiki_live_url(&owner_name, &repo_name); + let (head_title, sheet_title, extra) = if body_html.is_some() { ( - g::t(lang, K::Home).to_owned(), + Some(g::t(lang, K::Home).to_owned()), + None, page_links(lang, &owner_name, &repo_name, "Home", can_write), ) } else { - (g::t(lang, K::Wiki).to_owned(), Vec::new()) + (None, Some(g::t(lang, K::Wiki).to_owned()), Vec::new()) }; + let links = wiki_links(lang, &owner_name, &repo_name, can_write, extra); let header = ctx.head(state, "wiki").await?; Ok(view! { cx => shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) - wiki_head(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: can_write, title: head_title.clone(), extra: links.clone(), live: Some(wiki_live_url(&owner_name, &repo_name))) - if let Some(html) = body_html.clone() { - wiki_view_body(html: html) - } - if body_html.is_none() { - wiki_empty_body(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: can_write) - } + repo_head(head: header, title: head_title) +
+ wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: "Home".to_owned()) + wiki_sheet(title: sheet_title, links: links, live: Some(live), + if let Some(html) = body_html.clone() { + wiki_view_body(html: html) + } + if body_html.is_none() { + wiki_empty_body(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: can_write) + } + ) +
) }) } @@ -383,7 +431,7 @@ async fn wiki_pages(cx: &Cx) -> Result { ensure_enabled(state, &ctx).await?; let lang = i18n::lang(cx, ctx.viewer.as_ref().map(|(user, _)| user)); let dir = wiki_dir(state, &ctx)?; - let names = blocking(move || wiki::list_pages(&dir)).await?; + let names = page_names(dir).await?; let can_write = ctx.can_write(); let owner_name = ctx.repo.owner_name.clone(); let repo_name = ctx.repo.name.clone(); @@ -393,12 +441,14 @@ async fn wiki_pages(cx: &Cx) -> Result { ctx.repo.name, g::t(lang, K::WikiPages) ); + let links = wiki_links(lang, &owner_name, &repo_name, can_write, Vec::new()); let header = ctx.head(state, "wiki").await?; Ok(view! { cx => shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) - wiki_head(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: can_write, title: g::t(lang, K::AllPages).to_owned(), extra: Vec::new(), live: Some(wiki_live_url(&owner_name, &repo_name))) - wiki_list_body(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names) + repo_head(head: header, title: Some(g::t(lang, K::AllPages).to_owned())) + wiki_sheet(links: links, live: Some(wiki_live_url(&owner_name, &repo_name)), + wiki_list_body(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names) + ) ) }) } @@ -415,6 +465,7 @@ async fn wiki_page_view(cx: &Cx) -> Result { return Err(not_found().into()); } let dir = wiki_dir(state, &ctx)?; + let names = page_names(dir.clone()).await?; let (_, text) = load_page(dir, page_name.clone()).await?; let Some(text) = text else { return Err(not_found().into()); @@ -430,12 +481,23 @@ async fn wiki_page_view(cx: &Cx) -> Result { ctx.repo.owner_name, ctx.repo.name ); + let links = wiki_links( + lang, + &owner_name, + &repo_name, + can_write, + page_links(lang, &owner_name, &repo_name, &page_name, can_write), + ); let header = ctx.head(state, "wiki").await?; Ok(view! { cx => shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) - wiki_head(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: can_write, title: page_name.replace('-', " "), extra: page_links(lang, &owner_name, &repo_name, &page_name, can_write), live: Some(page_live_url(&owner_name, &repo_name, &page_name))) - wiki_view_body(html: html) + repo_head(head: header, title: Some(page_name.replace('-', " "))) +
+ wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: page_name.clone()) + wiki_sheet(links: links, live: Some(page_live_url(&owner_name, &repo_name, &page_name)), + wiki_view_body(html: html) + ) +
) }) } @@ -452,6 +514,7 @@ async fn wiki_page_history(cx: &Cx) -> Result { return Err(not_found().into()); } let dir = wiki_dir(state, &ctx)?; + let names = page_names(dir.clone()).await?; let git = state.git.clone(); let revs = wiki::page_history(&git, &dir, &page_name).await?; let rows = revision_rows(&ctx, &revs); @@ -464,12 +527,27 @@ async fn wiki_page_history(cx: &Cx) -> Result { ctx.repo.owner_name, ctx.repo.name ); + let can_write = ctx.can_write(); + let links = wiki_links( + lang, + &owner_name, + &repo_name, + can_write, + vec![( + g::t(lang, K::BackToPage).to_owned(), + repo_href(&owner_name, &repo_name, "wiki", &page_name), + )], + ); let header = ctx.head(state, "wiki").await?; Ok(view! { cx => shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) - wiki_head(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: ctx.can_write(), title: format!("{} \u{b7} {}", page_name.replace('-', " "), g::t(lang, K::History)), extra: vec![(g::t(lang, K::BackToPage).to_owned(), repo_href(&owner_name, &repo_name, "wiki", &page_name))], live: Some(page_live_url(&owner_name, &repo_name, &page_name))) - wiki_history_body(lang: lang, rows: rows) + repo_head(head: header, title: Some(format!("{} \u{b7} {}", page_name.replace('-', " "), g::t(lang, K::History)))) +
+ wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: page_name.clone()) + wiki_sheet(links: links, live: Some(page_live_url(&owner_name, &repo_name, &page_name)), + wiki_history_body(lang: lang, rows: rows) + ) +
) }) } @@ -487,6 +565,7 @@ async fn edit_screen( let (user, session) = require_user(cx).await?; let lang = i18n::lang(cx, Some(&user)); let dir = wiki_dir(state, &ctx)?; + let names = page_names(dir.clone()).await?; let head = blocking(move || wiki::head_commit(&dir)).await?; let action = if is_new { repo_href(&ctx.repo.owner_name, &ctx.repo.name, "wiki", "-/new") @@ -522,11 +601,16 @@ async fn edit_screen( repo_href(&owner_name, &repo_name, "wiki", &name), )] }; + let links = wiki_links(lang, &owner_name, &repo_name, !is_new, back_links); Ok(view! { cx => shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) - wiki_head(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: !is_new, title: head_title.clone(), extra: back_links.clone(), live: None) - wiki_edit_body(lang: lang, action: action, csrf: csrf, base: base, name: name.clone(), is_new: is_new, content: content, error: error) + repo_head(head: header, title: Some(head_title)) +
+ wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: name.clone()) + wiki_sheet(links: links, + wiki_edit_body(lang: lang, action: action, csrf: csrf, base: base, name: name.clone(), is_new: is_new, content: content, error: error) + ) +
) }) } @@ -726,7 +810,7 @@ async fn wiki_settings_page(cx: &Cx) -> Result { let csrf = session.csrf_token.clone(); Ok(view! { cx => shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), - repo_head(head: header) + repo_head(head: header, title: Some(g::t(lang, K::Wiki).to_owned())) settings_frame(lang: lang, title: format!("{}/{}", ctx.repo.owner_name, ctx.repo.name), current: "wiki", can_delete: ctx.can_delete(), wiki_settings_body(lang: lang, action: action, csrf: csrf, enabled: enabled) diff --git a/crates/forge-web/src/views/commit_line.rs b/crates/forge-web/src/views/commit_line.rs index 0b9b889..3777e65 100644 --- a/crates/forge-web/src/views/commit_line.rs +++ b/crates/forge-web/src/views/commit_line.rs @@ -5,19 +5,8 @@ use topcoat::Result; use topcoat::view::{View, component, view}; -use crate::render::commit_message::CommitMessage; use crate::render::emoji::emojify; -/// The first clause of a subject, or the emojified subject when it does not parse. For text that -/// is not rendered through `commit_line`, such as a heading. -pub fn headline(subject: &str) -> String { - let emojified = emojify(subject); - match CommitMessage::parse(&emojified) { - Some(message) => message.title(), - None => emojified.into_owned(), - } -} - /// One subject on one line as it was written, header included, truncated by CSS. The full subject /// is the `title` attribute. #[component] diff --git a/crates/forge-web/src/views/commit_status.rs b/crates/forge-web/src/views/commit_status.rs index 82f6298..da4441e 100644 --- a/crates/forge-web/src/views/commit_status.rs +++ b/crates/forge-web/src/views/commit_status.rs @@ -140,7 +140,7 @@ pub async fn checks_summary( (text) if has_items {
- (g::t(lang, K::ShowChecks)) + (g::t(lang, K::ShowChecks)) status_list(items: items, lang: lang)
} @@ -175,10 +175,10 @@ pub async fn status_list(items: Vec, lang: Lang) -> Result(item.icon) (item.context.as_str()) if item.has_description { - (description_text(lang, item.description.as_str())) + (description_text(lang, item.description.as_str())) } if item.has_link { - (g::t(lang, K::DetailsLink)) + (g::t(lang, K::DetailsLink)) } } diff --git a/crates/forge-web/src/views/diff.rs b/crates/forge-web/src/views/diff.rs index 4d371c5..60b44f7 100644 --- a/crates/forge-web/src/views/diff.rs +++ b/crates/forge-web/src/views/diff.rs @@ -85,6 +85,8 @@ pub struct DiffOpts { pub query: Vec<(String, String)>, /// `.patch` and `.diff` download links, when the page has them. pub downloads: Option<(String, String)>, + /// Shows this file alone, with no list of files: the review page picks one from its rail. + pub only: Option, } impl DiffOpts { @@ -146,6 +148,7 @@ impl DiffOpts { path: request.path().to_owned(), query, downloads, + only: None, }) } @@ -526,8 +529,11 @@ pub async fn diff_section( .files .iter() .enumerate() - .map(|(i, file)| FileView::new(i, file, oid, parent, owner, repo, lang, &mut comments)) + .map(|(i, file)| (i, FileView::new(i, file, oid, parent, owner, repo, lang, &mut comments))) + .filter(|(i, _)| opts.only.is_none_or(|only| only == *i)) + .map(|(_, file)| file) .collect(); + let alone = opts.only.is_some(); if split { for file in &mut files { file.split_rows = split_rows(std::mem::take(&mut file.rows)); @@ -562,9 +568,15 @@ pub async fn diff_section( Ok(view! {
-

(files_label.as_str()) " " (add_label.as_str()) " " (del_label.as_str())

- if let Some(bar) = toolbar { - diff_toolbar(bar: bar, lang: lang) + if !alone || toolbar.is_some() { +
+ if !alone { +

(files_label.as_str()) " " (add_label.as_str()) " " (del_label.as_str())

+ } + if let Some(bar) = toolbar { + diff_toolbar(bar: bar, lang: lang) + } +
} if truncated_files {

(truncated_note.as_str())

@@ -572,6 +584,7 @@ pub async fn diff_section( if no_files {

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

} else { + if !alone {
    for item in nav.iter() {
  • @@ -581,6 +594,7 @@ pub async fn diff_section(
  • }
+ } for file in files.into_iter() { diff_file(file: file, lang: lang, split: split, anchored: anchored) } @@ -601,8 +615,8 @@ async fn diff_toolbar(bar: Toolbar, lang: Lang) -> Result { (b::t(lang, b::K::Split)) (b::t(lang, b::K::IgnoreWhitespace)) if let Some((patch, diff)) = bar.downloads { - (b::t(lang, b::K::PatchLink)) - (b::t(lang, b::K::DiffLink)) + (b::t(lang, b::K::PatchLink)) + (b::t(lang, b::K::DiffLink)) } }) @@ -622,13 +636,11 @@ async fn diff_file(file: FileView, lang: Lang, split: bool, anchored: bool) -> R }; Ok(view! {
-
- (file.label.as_str()) - - (file.status) - (add_label.as_str()) " " (del_label.as_str()) - -
+
+ (file.label.as_str()) + (file.status) + (add_label.as_str()) " " (del_label.as_str()) +
if file.binary {

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

} else { @@ -642,6 +654,18 @@ async fn diff_file(file: FileView, lang: Lang, split: bool, anchored: bool) -> R if has_rows {
+ // A fixed split table takes its column widths from here, not from its + // first row, which is a hunk header spanning all of them. + if split { + + if anchored { } + + + if anchored { } + + + + } for row in rows.into_iter() { diff_line(row: row, lang: lang) } @@ -817,7 +841,7 @@ async fn inline_comment_form(form: InlineForm, lang: Lang) -> Result if let Some(text) = suggest_line { } - (g::t(lang, K::CancelLink)) + (g::t(lang, K::CancelLink)) }) diff --git a/crates/forge-web/src/views/mod.rs b/crates/forge-web/src/views/mod.rs index bf31f75..6f09491 100644 --- a/crates/forge-web/src/views/mod.rs +++ b/crates/forge-web/src/views/mod.rs @@ -41,7 +41,6 @@ use crate::i18n::packages::{self as pk, K as PK}; use crate::i18n::{self, Key, Lang, t}; use crate::pages::assets::highlight_css_text; use crate::pages::passkeys::s; -use crate::pages::user_prefs::{CORNER_POS, TREE_WIDTH, clean_pref}; use crate::state::AppState; /// Stylesheet URL. The version is a hash of the compiled CSS (build.rs), so a changed stylesheet @@ -115,6 +114,9 @@ const TOP_LEVEL_PAGES: &[&str] = &[ "import", "review-requests", "setup", + "needs-you", + "verify", + "reset", "org", ]; @@ -183,15 +185,22 @@ fn path_segments(path: &str, title: &str) -> Vec<(String, Option)> { // Titles read "owner/repo · Page": the path bar has the repo already. A page titled by // the repo alone is named by its route. [_, ..] => { - let page = title.rsplit(" · ").next().unwrap_or(title); - let page = if page == format!("{owner}/{repo}") { - parts[2..] + // A title ending in the repo plus a word ("Install · owner/repo wiki") reads by + // the part before it. + let full = format!("{owner}/{repo}"); + let mut tail = title.rsplit(" · "); + let named = match tail.next() { + Some(last) if last == full => None, + Some(last) if last.starts_with(&format!("{full} ")) => tail.next(), + last => last, + }; + let page = match named { + Some(page) => page.to_owned(), + None => parts[2..] .iter() .map(|part| crumb_label(part)) .collect::>() - .join("/") - } else { - page.to_owned() + .join("/"), }; segments.push((page, None)); } @@ -336,29 +345,14 @@ struct ProfileCorner { failing_href: String, } -/// The floating account panel fixed at the bottom left of the window (signed in only). It opens -/// upward: the avatar, the viewer's full name, the chips, the notifications bell with its unread count and popover, then -/// the profile, settings, admin and log out links and the theme choice. +/// The profile at the start of the top bar (signed in only): the avatar, with a dot when something +/// waits. Its menu holds the name, notifications with their popover, what waits on the viewer, the +/// profile, settings and admin links, the theme choice and log out. #[component] async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result { - let review_chip = (corner.reviews > 0).then(|| { - ( - corner.reviews.to_string(), - mi::review_requests_count(lang, corner.reviews), - ) - }); - let mention_chip = (corner.mentions > 0).then(|| { - ( - corner.mentions.to_string(), - mi::mentions_count(lang, corner.mentions), - ) - }); - let failing_chip = (corner.failing > 0).then(|| { - ( - corner.failing.to_string(), - mi::failing_runs_count(lang, corner.failing), - ) - }); + let review_chip = (corner.reviews > 0).then(|| mi::review_requests_count(lang, corner.reviews)); + let mention_chip = (corner.mentions > 0).then(|| mi::mentions_count(lang, corner.mentions)); + let failing_chip = (corner.failing > 0).then(|| mi::failing_runs_count(lang, corner.failing)); let bell_label = mi::t(lang, MK::AllNotifications); let theme_label = mi::t(lang, MK::ThemeLabel); let match_label = mi::t(lang, MK::MatchSystem); @@ -399,24 +393,49 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result let loading_label = mi::t(lang, MK::PeekLoading); let error_label = mi::t(lang, MK::PeekError); Ok(view! { -
- - (corner.name.as_str()) - - if let Some((count, title)) = review_chip { - (count.as_str()) + + +
+

(corner.name.as_str())

+ (count.as_str()) + + +
+ if let Some(title) = review_chip { + (title.as_str()) } - if let Some((count, title)) = failing_chip { - (count.as_str()) + if let Some(title) = mention_chip { + (title.as_str()) } - - -
+ if let Some(title) = failing_chip { + (title.as_str()) + } +
+
+ (profile_label) + (settings_label) + if corner.is_admin { + (admin_label) + } +
(theme_label)
@@ -432,43 +451,19 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result
- (profile_label) - (settings_label) - if corner.is_admin { - (admin_label) - }
- - -
}) } -/// Page shell: sticky top bar (logo, path bar and, signed in, the live strip), the section sidebar -/// on section pages, `child` as the page content, and for signed-in viewers the floating profile -/// corner fixed at the bottom left. `viewer` drives the chrome: the live strip and the profile -/// corner when signed in; search, theme, Explore and Log in otherwise. `extra_stylesheet` adds one +/// Page shell: the top bar (profile, wordmark, path bar, Explore and, signed in, the live strip), +/// the section tabs on section pages, and `child` as the page content. A page's `.head` is placed +/// above those tabs by the stylesheet, so a page only writes its head and its sheets. `viewer` +/// drives the chrome: the live strip and the profile when signed in; search, theme and Log in otherwise. `extra_stylesheet` adds one /// more stylesheet link to the head (such as a repo's generated label colors). #[component] pub async fn shell( @@ -506,14 +501,6 @@ pub async fn shell( _ => None, }; let banner = crate::pages::banner::current(__cx, prefs.as_ref()); - let tree_w = prefs - .as_ref() - .and_then(|p| p.get(TREE_WIDTH)) - .and_then(|v| clean_pref(TREE_WIDTH, v).ok().flatten()); - let corner_pos = prefs - .as_ref() - .and_then(|p| p.get(CORNER_POS)) - .and_then(|v| clean_pref(CORNER_POS, v).ok().flatten()); let sound_attr = crate::pages::settings_appearance::sound_attr(prefs.as_ref()); let banner_back = back.clone().unwrap_or_else(|| "/".to_owned()); let dismiss_label = crate::i18n::accounts::t(lang, crate::i18n::accounts::A::Dismiss); @@ -583,12 +570,20 @@ pub async fn shell( theme_state, mi::t(lang, theme_next), ); - let anonymous = viewer.is_none(); - let search_label = o::t(lang, OK::SearchPublicRepos); let palette_label = br::t(lang, br::K::PaletteOpen).to_owned(); let explore_label = t(lang, Key::Explore); // The path bar: one segment per part of the request path, the last one unlinked. - let segments = path_segments(uri(__cx).path(), title); + let mut segments = path_segments(uri(__cx).path(), title); + // A page with no place of its own in the path, such as settings, names its section and itself. + if segments.is_empty() { + if let Some(section) = §ion { + let first = section.items.first().map(|item| item.href.clone()); + if section.title != title { + segments.push((section.title.clone(), first)); + } + } + segments.push((title.to_owned(), None)); + } let path_attr = segments .iter() .map(|(label, _)| label.as_str()) @@ -641,10 +636,6 @@ pub async fn shell( || "/notifications".to_owned(), |(owner, repo, number)| repo_href(owner, repo, "ci", &format!("runs/{number}")), ); - // The corner's drag saves its position with this token, the same one the page's forms send. - let prefs_csrf = viewer - .map(|(_, session)| session.csrf_token.clone()) - .unwrap_or_default(); let corner = viewer.map(|(user, session)| ProfileCorner { username: user.username.clone(), name: user @@ -674,7 +665,7 @@ pub async fn shell( - + @@ -690,22 +681,17 @@ pub async fn shell( } - +
- - - "forge" - - - - (explore_label) - + if let Some(corner) = corner { +
+ profile_corner(lang: lang, corner: corner) +
+ } + "forge"
+ (explore_label) if signed_in {
} else { - - - -
if let Some(csrf) = theme_csrf { @@ -795,33 +778,12 @@ pub async fn shell(
if let Some(section) = section { - section_tabs(label: section.title.as_str(), items: section.items, current: section.current, live: section.live) + section_tabs(key: section.key, label: section.title.as_str(), items: section.items, current: section.current, live: section.live) } (child)
-
- "forge" - if anonymous { - - - - - } -
- if let Some(corner) = corner { -
- profile_corner(lang: lang, corner: corner) -
- } } @@ -841,6 +803,8 @@ pub struct NavItem { /// A section's tabs: the admin area or the user's settings, one row of text links above the page. #[derive(Clone)] pub struct Section { + /// `admin` or `settings`: what the stylesheet keys on, the same in every language. + pub key: &'static str, pub title: String, pub items: Vec, pub current: &'static str, @@ -1008,9 +972,9 @@ pub fn section_for(lang: Lang, path: &str) -> Option
{ let mut parts = path.trim_matches('/').split('/'); let first = parts.next()?; let second = parts.next().unwrap_or(""); - let (title, items) = match first { - "admin" => (ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), - "settings" => (o::t(lang, OK::Settings).to_owned(), settings_items(lang)), + let (key, title, items) = match first { + "admin" => ("admin", ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), + "settings" => ("settings", o::t(lang, OK::Settings).to_owned(), settings_items(lang)), _ => return None, }; let second = match second { @@ -1029,6 +993,7 @@ pub fn section_for(lang: Lang, path: &str) -> Option
{ "" }; Some(Section { + key, title, items, current, @@ -1039,6 +1004,7 @@ pub fn section_for(lang: Lang, path: &str) -> Option
{ /// One row of text tabs, with `aria-current="page"` on the current one. #[component] async fn section_tabs( + key: &'static str, label: &str, items: Vec, current: &str, @@ -1053,7 +1019,7 @@ async fn section_tabs( }) .collect(); Ok(view! { -