The decided One Page design now covers the whole app: every button, field, choice row, dropdown, popover and menu shares one kit (38px fields, 32px small buttons and choices, 280px inputs, 560px text areas, 130px label column, 20px menus with 34px rows), every page is one narrow column of head, tabs, sheet and quiet text actions under what they act on, and docs/ui-language.md holds the rules
Browse files at this commitfd174b4fb40c988564507486ee5e8f624a9f9a1dParent: 949180bAll checks have passed
Show checks
ci/buildSucceededDetails
- style
- the decided One Page design now covers the whole app: every button, field, choice row, dropdown, popover and menu shares one kit (38px fields, 32px small buttons and choices, 280px inputs, 560px text areas, 130px label column, 20px menus with 34px rows), every page is one narrow column of head, tabs, sheet and quiet text actions under what they act on, and docs/ui-language.md holds the rules
- the four older style layers are gone in favour of style/_one*.scss
- Ember on Anvil is the default look, and accounts that never chose colours move with it
- settings Keys shows one kind at a time with SSH, GPG and tokens at their own addresses
- run alerts are one row
- issue and pull lists share one row with the tick beside the title on a phone
- a pull's state badge has the colours of an issue's
- the CI list opens each run on its own page and marks none as current
- a queued job says No output yet
- the review panel offers Approve and Request changes only to people who are not the pull's author, and Discard only when something is pending
170 changed files +10662 -9677
- crates/forge-core/migrations/0072_ember_anvil_default.sql +19 -0
- crates/forge-core/src/model.rs +4 -4
- crates/forge-core/src/server_settings.rs +1 -1
- crates/forge-core/src/store/migrate.rs +1 -0
- crates/forge-core/src/store/ui_prefs.rs +2 -2
- crates/forge-e2e/tests/e2e/browse_e2e.rs +12 -15
- crates/forge-e2e/tests/e2e/ci_e2e.rs +2 -2
- crates/forge-e2e/tests/e2e/community_i18n_e2e.rs +2 -2
- crates/forge-e2e/tests/e2e/i18n_e2e.rs +1 -1
- crates/forge-e2e/tests/e2e/pulls_e2e.rs +1 -1
- crates/forge-e2e/tests/e2e/section_nav_e2e.rs +3 -2
- crates/forge-e2e/tests/e2e/ui_prefs_e2e.rs +6 -3
- crates/forge-web-base/src/accent.rs +4 -3
- crates/forge-web-base/src/accent_palette.rs +62 -62
- crates/forge-web-base/src/i18n/accounts.rs +15 -0
- crates/forge-web-base/src/i18n/admin.rs +2 -2
- crates/forge-web-base/src/i18n/releases_ci.rs +2 -2
- crates/forge-web-base/src/i18n/server_settings.rs +1 -1
- crates/forge-web/assets/nav.js +34 -386
- crates/forge-web/src/pages/admin_backups.rs +16 -20
- crates/forge-web/src/pages/admin_health.rs +68 -118
- crates/forge-web/src/pages/admin_mail.rs +15 -15
- crates/forge-web/src/pages/admin_replication.rs +6 -10
- crates/forge-web/src/pages/admin_runners.rs +198 -316
- crates/forge-web/src/pages/admin_server.rs +96 -72
- crates/forge-web/src/pages/admin_user_detail.rs +20 -24
- crates/forge-web/src/pages/admin_users.rs +111 -98
- crates/forge-web/src/pages/audit_log.rs +72 -52
- crates/forge-web/src/pages/blame.rs +20 -24
- crates/forge-web/src/pages/blob.rs +98 -43
- crates/forge-web/src/pages/branches.rs +11 -10
- crates/forge-web/src/pages/ci_estimate.rs +0 -13
- crates/forge-web/src/pages/ci_fail.rs +64 -94
- crates/forge-web/src/pages/ci_job.rs +79 -81
- crates/forge-web/src/pages/ci_runs.rs +411 -369
- crates/forge-web/src/pages/ci_tests.rs +18 -14
- crates/forge-web/src/pages/code_search.rs +48 -49
- crates/forge-web/src/pages/commit.rs +92 -87
- crates/forge-web/src/pages/commits.rs +62 -72
- crates/forge-web/src/pages/compare.rs +67 -66
- crates/forge-web/src/pages/discussion_settings.rs +2 -2
- crates/forge-web/src/pages/discussion_view.rs +30 -30
- crates/forge-web/src/pages/discussions.rs +65 -64
- crates/forge-web/src/pages/edit_history.rs +16 -15
- crates/forge-web/src/pages/explore.rs +15 -17
- crates/forge-web/src/pages/forgot.rs +15 -11
- crates/forge-web/src/pages/home.rs +7 -10
- crates/forge-web/src/pages/import.rs +213 -207
- crates/forge-web/src/pages/invites.rs +20 -26
- crates/forge-web/src/pages/issue_meta.rs +7 -6
- crates/forge-web/src/pages/issue_parts.rs +82 -74
- crates/forge-web/src/pages/issue_pin.rs +8 -6
- crates/forge-web/src/pages/issue_view.rs +46 -49
- crates/forge-web/src/pages/issues_list.rs +189 -137
- crates/forge-web/src/pages/labels_page.rs +6 -7
- crates/forge-web/src/pages/login.rs +19 -10
- crates/forge-web/src/pages/merge_queue.rs +49 -45
- crates/forge-web/src/pages/milestones_page.rs +23 -21
- crates/forge-web/src/pages/needs_you.rs +26 -33
- crates/forge-web/src/pages/new_repo.rs +62 -60
- crates/forge-web/src/pages/not_found_page.rs +72 -13
- crates/forge-web/src/pages/notifications.rs +62 -39
- crates/forge-web/src/pages/org_members.rs +74 -73
- crates/forge-web/src/pages/org_new.rs +19 -17
- crates/forge-web/src/pages/org_settings.rs +8 -8
- crates/forge-web/src/pages/org_teams.rs +128 -133
- crates/forge-web/src/pages/packages.rs +47 -38
- crates/forge-web/src/pages/packages_oci.rs +15 -7
- crates/forge-web/src/pages/passkeys.rs +22 -26
- crates/forge-web/src/pages/profile.rs +88 -91
- crates/forge-web/src/pages/profile_pins.rs +2 -2
- crates/forge-web/src/pages/pull_branch.rs +6 -6
- crates/forge-web/src/pages/pull_files.rs +271 -163
- crates/forge-web/src/pages/pull_reviews.rs +11 -12
- crates/forge-web/src/pages/pull_view.rs +68 -104
- crates/forge-web/src/pages/pulls_list.rs +141 -128
- crates/forge-web/src/pages/refs.rs +4 -4
- crates/forge-web/src/pages/register.rs +18 -14
- crates/forge-web/src/pages/releases.rs +143 -156
- crates/forge-web/src/pages/releases_tests.rs +2 -2
- crates/forge-web/src/pages/repo.rs +125 -174
- crates/forge-web/src/pages/repo_collaborators.rs +3 -2
- crates/forge-web/src/pages/repo_ctx.rs +31 -3
- crates/forge-web/src/pages/repo_mirrors.rs +10 -12
- crates/forge-web/src/pages/repo_rename.rs +2 -2
- crates/forge-web/src/pages/repo_scrub.rs +17 -7
- crates/forge-web/src/pages/repo_secrets.rs +3 -3
- crates/forge-web/src/pages/repo_security.rs +36 -34
- crates/forge-web/src/pages/repo_settings.rs +47 -83
- crates/forge-web/src/pages/repo_side.rs +51 -324
- crates/forge-web/src/pages/repo_transfer.rs +28 -26
- crates/forge-web/src/pages/repo_webhooks.rs +41 -35
- crates/forge-web/src/pages/review_requests.rs +26 -28
- crates/forge-web/src/pages/settings_appearance.rs +64 -48
- crates/forge-web/src/pages/settings_export.rs +8 -9
- crates/forge-web/src/pages/settings_gpg.rs +54 -47
- crates/forge-web/src/pages/settings_gpg_tests.rs +3 -11
- crates/forge-web/src/pages/settings_keys.rs +148 -51
- crates/forge-web/src/pages/settings_notifications.rs +72 -69
- crates/forge-web/src/pages/settings_profile.rs +5 -2
- crates/forge-web/src/pages/settings_security.rs +90 -3
- crates/forge-web/src/pages/settings_sessions.rs +24 -15
- crates/forge-web/src/pages/settings_tokens.rs +74 -67
- crates/forge-web/src/pages/setup.rs +4 -4
- crates/forge-web/src/pages/snippets.rs +65 -67
- crates/forge-web/src/pages/tree.rs +89 -111
- crates/forge-web/src/pages/user_prefs.rs +5 -61
- crates/forge-web/src/pages/wiki.rs +151 -67
- crates/forge-web/src/views/commit_line.rs +0 -11
- crates/forge-web/src/views/commit_status.rs +3 -3
- crates/forge-web/src/views/diff.rs +38 -14
- crates/forge-web/src/views/mod.rs +108 -174
- crates/forge-web/src/views/parts.rs +149 -6
- crates/forge-web/src/views/repo_list.rs +4 -4
- crates/forge-web/src/views/review_thread.rs +70 -103
- crates/forge-web/src/views/timeline.rs +1 -1
- crates/forge-web/src/web_push/mod.rs +14 -1
- docs/ui-language.md +133 -0
- scripts/audit/measure.ts +113 -54
- scripts/audit/mock.py +194 -0
- scripts/audit/paths.py +21 -0
- scripts/audit/run.sh +4 -0
- style/_admin_rows.scss +7 -5
- style/_alive_head.scss +0 -83
- style/_alive_heat.scss +0 -47
- style/_alive_issue.scss +0 -8
- style/_alive_lists.scss +0 -26
- style/_alive_motion.scss +0 -92
- style/_alive_scrub.scss +0 -61
- style/_alive_settings.scss +0 -189
- style/_authoring.scss +1 -1
- style/_browse.scss +0 -9
- style/_canvas.scss +0 -103
- style/_canvas_account.scss +0 -28
- style/_canvas_ci.scss +0 -110
- style/_canvas_commits.scss +0 -17
- style/_canvas_detail.scss +0 -192
- style/_canvas_lists.scss +0 -282
- style/_canvas_pull.scss +0 -402
- style/_canvas_repo.scss +0 -608
- style/_fit.scss +0 -11
- style/_fit_admin.scss +0 -38
- style/_fit_code.scss +0 -53
- style/_fit_forms.scss +0 -64
- style/_fit_lists.scss +0 -4
- style/_fit_settings.scss +0 -10
- style/_fit_tables.scss +0 -5
- style/_fit_threads.scss +0 -17
- style/_kb_rerun.scss +6 -38
- style/_lang_admin.scss +0 -78
- style/_lang_browse.scss +0 -49
- style/_lang_ci.scss +0 -132
- style/_lang_issues.scss +0 -266
- style/_lang_lists.scss +0 -42
- style/_lang_people.scss +0 -91
- style/_language.scss +0 -5
- style/_look.scss +6 -6
- style/_min.scss +2 -3
- style/_min_menus.scss +41 -0
- style/_one.scss +2932 -0
- style/_one_admin.scss +217 -0
- style/_one_ci.scss +250 -0
- style/_one_code.scss +198 -0
- style/_one_people.scss +307 -0
- style/_one_review.scss +147 -0
- style/_one_shell.scss +259 -0
- style/_one_threads.scss +304 -0
- style/_pull.scss +1 -1
- style/_system.scss +0 -614
- style/main.scss +9 -149
crates/forge-core/migrations/0072_ember_anvil_default.sqladded+19 -0
| @@ -0,0 +1,19 @@ | |||
| 1 | +-- Ember on Anvil becomes the look of a new account. An account that never chose its colours moves | ||
| 2 | +-- with the default; one that chose keeps its choice. SQLite cannot change a column's default in | ||
| 3 | +-- place, so each column is replaced. | ||
| 4 | +ALTER TABLE users RENAME COLUMN accent TO accent_old; | ||
| 5 | +ALTER TABLE users RENAME COLUMN accent_dark TO accent_dark_old; | ||
| 6 | +ALTER TABLE users RENAME COLUMN base_light TO base_light_old; | ||
| 7 | +ALTER TABLE users RENAME COLUMN base_dark TO base_dark_old; | ||
| 8 | +ALTER TABLE users ADD COLUMN accent TEXT NOT NULL DEFAULT 'ember'; | ||
| 9 | +ALTER TABLE users ADD COLUMN accent_dark TEXT NOT NULL DEFAULT 'ember'; | ||
| 10 | +ALTER TABLE users ADD COLUMN base_light TEXT NOT NULL DEFAULT 'anvil'; | ||
| 11 | +ALTER TABLE users ADD COLUMN base_dark TEXT NOT NULL DEFAULT 'anvil'; | ||
| 12 | +UPDATE users SET accent = accent_old, accent_dark = accent_dark_old, | ||
| 13 | + base_light = base_light_old, base_dark = base_dark_old | ||
| 14 | +WHERE NOT (accent_old = 'sage' AND accent_dark_old = 'sage' | ||
| 15 | + AND base_light_old = 'fern' AND base_dark_old = 'fern'); | ||
| 16 | +ALTER TABLE users DROP COLUMN accent_old; | ||
| 17 | +ALTER TABLE users DROP COLUMN accent_dark_old; | ||
| 18 | +ALTER TABLE users DROP COLUMN base_light_old; | ||
| 19 | +ALTER TABLE users DROP COLUMN base_dark_old; | ||
crates/forge-core/src/model.rsmodified+4 -4
| @@ -48,13 +48,13 @@ pub struct User { | |||
| 48 | /// Language code, e.g. "en"; "auto" uses the instance default. | 48 | /// Language code, e.g. "en"; "auto" uses the instance default. |
| 49 | pub language: String, | 49 | pub language: String, |
| 50 | /// Accent colour for the light theme: the id of a palette in forge-web's `accent_palette.rs`. | 50 | /// Accent colour for the light theme: the id of a palette in forge-web's `accent_palette.rs`. |
| 51 | - /// "sage" is the default. | 51 | + /// "ember" is the default. |
| 52 | pub accent: String, | 52 | pub accent: String, |
| 53 | - /// Accent colour for the dark theme, chosen separately from `accent`. "sage" is the default. | 53 | + /// Accent colour for the dark theme, chosen separately from `accent`. "ember" is the default. |
| 54 | pub accent_dark: String, | 54 | pub accent_dark: String, |
| 55 | - /// Base (neutral background, surface and text) set for the light theme. "fern" is the default. | 55 | + /// Base (neutral background, surface and text) set for the light theme. "anvil" is the default. |
| 56 | pub base_light: String, | 56 | pub base_light: String, |
| 57 | - /// Base set for the dark theme. "fern" is the default. | 57 | + /// Base set for the dark theme. "anvil" is the default. |
| 58 | pub base_dark: String, | 58 | pub base_dark: String, |
| 59 | /// Which side the main shell sidebar sits on: "left" (the default) or "right". | 59 | /// Which side the main shell sidebar sits on: "left" (the default) or "right". |
| 60 | pub sidebar_side: String, | 60 | pub sidebar_side: String, |
crates/forge-core/src/server_settings.rsmodified+1 -1
| @@ -164,7 +164,7 @@ pub static FIELDS: &[Field] = &[ | |||
| 164 | L, | 164 | L, |
| 165 | Ty::Choice(BANNER_LEVEL), | 165 | Ty::Choice(BANNER_LEVEL), |
| 166 | "Banner level", | 166 | "Banner level", |
| 167 | - "info or warning.", | 167 | + "Info or warning.", |
| 168 | ), | 168 | ), |
| 169 | f( | 169 | f( |
| 170 | "banner.expires", | 170 | "banner.expires", |
crates/forge-core/src/store/migrate.rsmodified+1 -0
| @@ -117,6 +117,7 @@ pub const MIGRATIONS: &[(u32, &str)] = &[ | |||
| 117 | include_str!("../../migrations/0070_pull_viewed_files.sql"), | 117 | include_str!("../../migrations/0070_pull_viewed_files.sql"), |
| 118 | ), | 118 | ), |
| 119 | (71, include_str!("../../migrations/0071_ci_job_steps.sql")), | 119 | (71, include_str!("../../migrations/0071_ci_job_steps.sql")), |
| 120 | + (72, include_str!("../../migrations/0072_ember_anvil_default.sql")), | ||
| 120 | ]; | 121 | ]; |
| 121 | 122 | ||
| 122 | /// The highest migration version this binary knows about. | 123 | /// The highest migration version this binary knows about. |
crates/forge-core/src/store/ui_prefs.rsmodified+2 -2
| @@ -15,11 +15,11 @@ pub const AUTO: &str = "auto"; | |||
| 15 | 15 | ||
| 16 | /// The accent colour a new user gets. It must match the default palette in forge-web's | 16 | /// The accent colour a new user gets. It must match the default palette in forge-web's |
| 17 | /// `accent_palette.rs`, which a test there checks. | 17 | /// `accent_palette.rs`, which a test there checks. |
| 18 | -pub const DEFAULT_ACCENT: &str = "sage"; | 18 | +pub const DEFAULT_ACCENT: &str = "ember"; |
| 19 | 19 | ||
| 20 | /// The base colour set a new user gets, for both themes. It must match the default base in | 20 | /// The base colour set a new user gets, for both themes. It must match the default base in |
| 21 | /// forge-web's `accent_palette.rs`, which a test there checks. | 21 | /// forge-web's `accent_palette.rs`, which a test there checks. |
| 22 | -pub const DEFAULT_BASE: &str = "fern"; | 22 | +pub const DEFAULT_BASE: &str = "anvil"; |
| 23 | 23 | ||
| 24 | /// The sidebar sides, in the order the settings page lists them. | 24 | /// The sidebar sides, in the order the settings page lists them. |
| 25 | pub const SIDEBAR_SIDES: &[&str] = &["left", "right"]; | 25 | pub const SIDEBAR_SIDES: &[&str] = &["left", "right"]; |
crates/forge-e2e/tests/e2e/browse_e2e.rsmodified+12 -15
| @@ -124,25 +124,22 @@ fn element_texts(body: &str, selector: &str) -> Vec<String> { | |||
| 124 | .collect() | 124 | .collect() |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | -/// Checks the dock of a repo page: one dock, with the subject of the commit, its short sha, the | 127 | +/// Checks the latest commit in a repo page's head line: its short sha and subject, both linking to |
| 128 | -/// commit count label and the subject's absolute time in its title. | 128 | +/// the commit, and the commit count label. |
| 129 | fn assert_latest_bar(body: &str, what: &str, subject: &str, oid: &str, count: &str) { | 129 | fn assert_latest_bar(body: &str, what: &str, subject: &str, oid: &str, count: &str) { |
| 130 | - let docks = element_texts(body, ".canvas-dock"); | 130 | + assert_eq!(element_texts(body, ".head-sub").len(), 1, "{what}: one head line"); |
| 131 | - assert_eq!(docks.len(), 1, "{what}: exactly one dock"); | 131 | + let shas = element_texts(body, ".head-sub a.mono"); |
| 132 | - let subjects = element_texts(body, ".canvas-dock .dock-subject"); | 132 | + assert_eq!(shas.len(), 1, "{what}: the head line must show the sha"); |
| 133 | - assert_eq!(subjects.len(), 1, "{what}: dock must show the subject"); | 133 | + assert_eq!(shas[0].trim(), &oid[..7], "{what}: short sha"); |
| 134 | - assert_eq!(subjects[0].trim(), subject, "{what}: dock subject"); | 134 | + let links = element_texts(body, ".head-sub a[href*=\"/commit/\"]"); |
| 135 | - let shas = element_texts(body, ".canvas-dock .dock-sha"); | ||
| 136 | - assert_eq!(shas.len(), 1, "{what}: dock must show the sha"); | ||
| 137 | - assert_eq!(shas[0].trim(), &oid[..7], "{what}: dock short sha"); | ||
| 138 | - let counts = element_texts(body, ".canvas-dock .dock-count"); | ||
| 139 | assert!( | 135 | assert!( |
| 140 | - counts.iter().any(|c| c.trim() == count), | 136 | + links.iter().any(|l| l.trim() == subject), |
| 141 | - "{what}: dock must show {count:?}, got {counts:?}" | 137 | + "{what}: the head line must show {subject:?}, got {links:?}" |
| 142 | ); | 138 | ); |
| 139 | + let parts = element_texts(body, ".head-sub span"); | ||
| 143 | assert!( | 140 | assert!( |
| 144 | - !attr_values(body, ".canvas-dock .dock-subject", "title").is_empty(), | 141 | + parts.iter().any(|c| c.trim() == count), |
| 145 | - "{what}: dock subject needs an absolute time in its title" | 142 | + "{what}: the head line must show {count:?}, got {parts:?}" |
| 146 | ); | 143 | ); |
| 147 | } | 144 | } |
| 148 | 145 | ||
crates/forge-e2e/tests/e2e/ci_e2e.rsmodified+2 -2
| @@ -577,8 +577,8 @@ async fn run_page_lists_a_jobs_steps_and_a_step_opens_its_part_of_the_log() { | |||
| 577 | .await; | 577 | .await; |
| 578 | assert_eq!(page.status, 200, "GET run page"); | 578 | assert_eq!(page.status, 200, "GET run page"); |
| 579 | assert!( | 579 | assert!( |
| 580 | - page.body.contains("ci-tl-stepname") && page.body.contains("Compile"), | 580 | + page.body.contains("class=\"lab\"") && page.body.contains("Compile"), |
| 581 | - "the rail lists the step names: {}", | 581 | + "the strip lists the step names: {}", |
| 582 | page.body | 582 | page.body |
| 583 | ); | 583 | ); |
| 584 | assert!( | 584 | assert!( |
crates/forge-e2e/tests/e2e/community_i18n_e2e.rsmodified+2 -2
| @@ -51,7 +51,7 @@ async fn snippets_page_follows_the_browser_language() { | |||
| 51 | let body = turkish.text().await.expect("read body"); | 51 | let body = turkish.text().await.expect("read body"); |
| 52 | assert!(body.contains("<html lang=\"tr\""), "html lang is tr"); | 52 | assert!(body.contains("<html lang=\"tr\""), "html lang is tr"); |
| 53 | assert!( | 53 | assert!( |
| 54 | - body.contains("<h1 class=\"sr-only\">Parçacıklar</h1>"), | 54 | + body.contains("<h1>Parçacıklar</h1>"), |
| 55 | "Turkish heading" | 55 | "Turkish heading" |
| 56 | ); | 56 | ); |
| 57 | assert!( | 57 | assert!( |
| @@ -68,7 +68,7 @@ async fn snippets_page_follows_the_browser_language() { | |||
| 68 | .expect("GET /snippets (en)"); | 68 | .expect("GET /snippets (en)"); |
| 69 | let body = english.text().await.expect("read body"); | 69 | let body = english.text().await.expect("read body"); |
| 70 | assert!( | 70 | assert!( |
| 71 | - body.contains("<h1 class=\"sr-only\">Snippets</h1>"), | 71 | + body.contains("<h1>Snippets</h1>"), |
| 72 | "English heading" | 72 | "English heading" |
| 73 | ); | 73 | ); |
| 74 | assert!(body.contains("No snippets to show."), "English empty state"); | 74 | assert!(body.contains("No snippets to show."), "English empty state"); |
crates/forge-e2e/tests/e2e/i18n_e2e.rsmodified+1 -1
| @@ -168,7 +168,7 @@ async fn releases_page_follows_the_stored_turkish_language() { | |||
| 168 | .await; | 168 | .await; |
| 169 | assert_eq!(releases.status, 200, "releases page"); | 169 | assert_eq!(releases.status, 200, "releases page"); |
| 170 | assert!( | 170 | assert!( |
| 171 | - releases.body.contains("<h2>Sürümler</h2>"), | 171 | + releases.body.contains("<h1>Sürümler</h1>"), |
| 172 | "Turkish heading" | 172 | "Turkish heading" |
| 173 | ); | 173 | ); |
| 174 | assert!(releases.body.contains("Yeni sürüm"), "Turkish new button"); | 174 | assert!(releases.body.contains("Yeni sürüm"), "Turkish new button"); |
crates/forge-e2e/tests/e2e/pulls_e2e.rsmodified+1 -1
| @@ -23,7 +23,7 @@ const REPO_PATH: &str = "/tahinli/r"; | |||
| 23 | /// Text of the first state badge on a page, e.g. `Open`, `Closed` or `Merged`. | 23 | /// Text of the first state badge on a page, e.g. `Open`, `Closed` or `Merged`. |
| 24 | fn state_badge(body: &str) -> String { | 24 | fn state_badge(body: &str) -> String { |
| 25 | let doc = scraper::Html::parse_document(body); | 25 | let doc = scraper::Html::parse_document(body); |
| 26 | - let selector = scraper::Selector::parse(".issue-badge").expect("selector"); | 26 | + let selector = scraper::Selector::parse(".head-sub > .badge, .head-sub > .issue-badge").expect("selector"); |
| 27 | doc.select(&selector) | 27 | doc.select(&selector) |
| 28 | .next() | 28 | .next() |
| 29 | .map(|el| el.text().collect::<String>().trim().to_owned()) | 29 | .map(|el| el.text().collect::<String>().trim().to_owned()) |
crates/forge-e2e/tests/e2e/section_nav_e2e.rsmodified+3 -2
| @@ -216,9 +216,10 @@ async fn settings_pages_get_the_settings_tabs() { | |||
| 216 | assert_eq!(page.status, 200, "GET {path}"); | 216 | assert_eq!(page.status, 200, "GET {path}"); |
| 217 | assert_tabs(&page.body, current, &tabs); | 217 | assert_tabs(&page.body, current, &tabs); |
| 218 | } | 218 | } |
| 219 | - // GPG keys and tokens moved into the Keys tab; their old addresses go there. | 219 | + // GPG keys and tokens are kinds of the Keys tab, each at its own address. |
| 220 | for path in ["/settings/gpg", "/settings/tokens"] { | 220 | for path in ["/settings/gpg", "/settings/tokens"] { |
| 221 | let page = env.http.get(path, Some(&session)).await; | 221 | let page = env.http.get(path, Some(&session)).await; |
| 222 | - assert_eq!(page.status, 303, "GET {path}"); | 222 | + assert_eq!(page.status, 200, "GET {path}"); |
| 223 | + assert_tabs(&page.body, "/settings/keys", &tabs); | ||
| 223 | } | 224 | } |
| 224 | } | 225 | } |
crates/forge-e2e/tests/e2e/ui_prefs_e2e.rsmodified+6 -3
| @@ -59,8 +59,11 @@ fn checked_radio(body: &str, name: &str) -> Option<String> { | |||
| 59 | /// The option value that is selected in the `<select name="...">` on a page. | 59 | /// The option value that is selected in the `<select name="...">` on a page. |
| 60 | fn selected_option(body: &str, select: &str) -> Option<String> { | 60 | fn selected_option(body: &str, select: &str) -> Option<String> { |
| 61 | let doc = scraper::Html::parse_document(body); | 61 | let doc = scraper::Html::parse_document(body); |
| 62 | - let selector = scraper::Selector::parse(&format!("select[name=\"{select}\"] option[selected]")) | 62 | + // A select's chosen option, or the pressed button of a choice row. |
| 63 | - .expect("selector"); | 63 | + let selector = scraper::Selector::parse(&format!( |
| 64 | + "select[name=\"{select}\"] option[selected], button[name=\"{select}\"][aria-pressed=\"true\"]" | ||
| 65 | + )) | ||
| 66 | + .expect("selector"); | ||
| 64 | doc.select(&selector) | 67 | doc.select(&selector) |
| 65 | .next() | 68 | .next() |
| 66 | .and_then(|el| el.value().attr("value")) | 69 | .and_then(|el| el.value().attr("value")) |
| @@ -227,7 +230,7 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() { | |||
| 227 | let session = login(&env.http, "tahinli", PW).await; | 230 | let session = login(&env.http, "tahinli", PW).await; |
| 228 | 231 | ||
| 229 | let page = env.http.get("/settings/appearance", Some(&session)).await; | 232 | let page = env.http.get("/settings/appearance", Some(&session)).await; |
| 230 | - let defaults = ["sage", "sage", "fern", "fern"].map(str::to_owned); | 233 | + let defaults = ["ember", "ember", "anvil", "anvil"].map(str::to_owned); |
| 231 | assert_eq!(checked_colours(&page.body), defaults.clone().map(Some)); | 234 | assert_eq!(checked_colours(&page.body), defaults.clone().map(Some)); |
| 232 | assert_eq!(html_colours(&page.body), defaults.map(Some)); | 235 | assert_eq!(html_colours(&page.body), defaults.map(Some)); |
| 233 | let csrf = input_value(&page.body, "csrf"); | 236 | let csrf = input_value(&page.body, "csrf"); |
crates/forge-web-base/src/accent.rsmodified+4 -3
| @@ -310,11 +310,11 @@ mod tests { | |||
| 310 | fn the_presets_are_offered_in_picker_order_and_removed_ids_are_not() { | 310 | fn the_presets_are_offered_in_picker_order_and_removed_ids_are_not() { |
| 311 | assert_eq!( | 311 | assert_eq!( |
| 312 | ids().collect::<Vec<_>>(), | 312 | ids().collect::<Vec<_>>(), |
| 313 | - ["sage", "spark", "ocean", "plum", "rose", "gold", "ember"] | 313 | + ["ember", "sage", "spark", "ocean", "plum", "rose", "gold"] |
| 314 | ); | 314 | ); |
| 315 | assert_eq!( | 315 | assert_eq!( |
| 316 | base_ids().collect::<Vec<_>>(), | 316 | base_ids().collect::<Vec<_>>(), |
| 317 | - ["fern", "spark", "graphite", "dusk", "ink", "anvil"] | 317 | + ["anvil", "fern", "spark", "graphite", "dusk", "ink"] |
| 318 | ); | 318 | ); |
| 319 | for id in ["ochre", "teal", "Sage", "sage ", "terracotta"] { | 319 | for id in ["ochre", "teal", "Sage", "sage ", "terracotta"] { |
| 320 | assert!(!is_offered(id), "{id}"); | 320 | assert!(!is_offered(id), "{id}"); |
| @@ -389,7 +389,8 @@ mod tests { | |||
| 389 | accent_tokens(215, 50, false).accent | 389 | accent_tokens(215, 50, false).accent |
| 390 | ); | 390 | ); |
| 391 | assert_eq!(swatch("hue-215", true), accent_tokens(215, 50, true).accent); | 391 | assert_eq!(swatch("hue-215", true), accent_tokens(215, 50, true).accent); |
| 392 | - assert_eq!(swatch("terracotta", false), swatch("sage", false)); | 392 | + // A removed id falls back to the default, Ember. |
| 393 | + assert_eq!(swatch("terracotta", false), swatch("ember", false)); | ||
| 393 | let (bg, text) = base_swatch("fern", false); | 394 | let (bg, text) = base_swatch("fern", false); |
| 394 | assert_eq!((bg.as_str(), text.as_str()), ("#F6F8F5", "#1E2420")); | 395 | assert_eq!((bg.as_str(), text.as_str()), ("#F6F8F5", "#1E2420")); |
| 395 | let (bg, text) = base_swatch("hue-215", true); | 396 | let (bg, text) = base_swatch("hue-215", true); |
crates/forge-web-base/src/accent_palette.rsmodified+62 -62
| @@ -27,7 +27,7 @@ pub struct Palette { | |||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | /// The palette used when none is stored, and for anonymous visitors. It must be `PALETTES[0]`. | 29 | /// The palette used when none is stored, and for anonymous visitors. It must be `PALETTES[0]`. |
| 30 | -pub const DEFAULT: &str = "sage"; | 30 | +pub const DEFAULT: &str = "ember"; |
| 31 | 31 | ||
| 32 | /// One token: the custom property it becomes and the field of `Tokens` that holds its value. | 32 | /// One token: the custom property it becomes and the field of `Tokens` that holds its value. |
| 33 | pub struct TokenVar { | 33 | pub struct TokenVar { |
| @@ -83,6 +83,34 @@ pub const TOKEN_VARS: &[TokenVar] = &[ | |||
| 83 | /// here: style/_heatmap.scss mixes them from `--accent`/`--accent-ink` and the base's surface, | 83 | /// here: style/_heatmap.scss mixes them from `--accent`/`--accent-ink` and the base's surface, |
| 84 | /// so they follow every accent and base. | 84 | /// so they follow every accent and base. |
| 85 | pub const PALETTES: &[Palette] = &[ | 85 | pub const PALETTES: &[Palette] = &[ |
| 86 | + // Ember: iron at working heat, a soft red-orange; copper in light. | ||
| 87 | + Palette { | ||
| 88 | + id: "ember", | ||
| 89 | + light: Tokens { | ||
| 90 | + accent: "#B44D1A", | ||
| 91 | + accent_ink: "#8F3A12", | ||
| 92 | + accent_soft: "#F8E9DF", | ||
| 93 | + accent_text: "#FFFFFF", | ||
| 94 | + focus: "#8F3A12", | ||
| 95 | + public_bg: "#F9E4D6", | ||
| 96 | + public_text: "#8F3A12", | ||
| 97 | + note: "#8F3A12", | ||
| 98 | + hunk_bg: "#FBF0E8", | ||
| 99 | + hunk_text: "#883611", | ||
| 100 | + }, | ||
| 101 | + dark: Tokens { | ||
| 102 | + accent: "#E8894A", | ||
| 103 | + accent_ink: "#FFB27A", | ||
| 104 | + accent_soft: "#3A2518", | ||
| 105 | + accent_text: "#1A0E06", | ||
| 106 | + focus: "#FFB27A", | ||
| 107 | + public_bg: "#3A2416", | ||
| 108 | + public_text: "#FFC69A", | ||
| 109 | + note: "#FFB27A", | ||
| 110 | + hunk_bg: "#24180F", | ||
| 111 | + hunk_text: "#F0A066", | ||
| 112 | + }, | ||
| 113 | + }, | ||
| 86 | // Sage: the original forge colour. | 114 | // Sage: the original forge colour. |
| 87 | Palette { | 115 | Palette { |
| 88 | id: "sage", | 116 | id: "sage", |
| @@ -253,34 +281,6 @@ pub const PALETTES: &[Palette] = &[ | |||
| 253 | hunk_text: "#E8BC4A", | 281 | hunk_text: "#E8BC4A", |
| 254 | }, | 282 | }, |
| 255 | }, | 283 | }, |
| 256 | - // Ember: iron at working heat, a soft red-orange; copper in light. | ||
| 257 | - Palette { | ||
| 258 | - id: "ember", | ||
| 259 | - light: Tokens { | ||
| 260 | - accent: "#B44D1A", | ||
| 261 | - accent_ink: "#8F3A12", | ||
| 262 | - accent_soft: "#F9E4D6", | ||
| 263 | - accent_text: "#FFFFFF", | ||
| 264 | - focus: "#8F3A12", | ||
| 265 | - public_bg: "#F9E4D6", | ||
| 266 | - public_text: "#8F3A12", | ||
| 267 | - note: "#8F3A12", | ||
| 268 | - hunk_bg: "#FBF0E8", | ||
| 269 | - hunk_text: "#883611", | ||
| 270 | - }, | ||
| 271 | - dark: Tokens { | ||
| 272 | - accent: "#E8894A", | ||
| 273 | - accent_ink: "#FFB27A", | ||
| 274 | - accent_soft: "#3A2416", | ||
| 275 | - accent_text: "#1A0E06", | ||
| 276 | - focus: "#FFB27A", | ||
| 277 | - public_bg: "#3A2416", | ||
| 278 | - public_text: "#FFC69A", | ||
| 279 | - note: "#FFB27A", | ||
| 280 | - hunk_bg: "#24180F", | ||
| 281 | - hunk_text: "#F0A066", | ||
| 282 | - }, | ||
| 283 | - }, | ||
| 284 | ]; | 284 | ]; |
| 285 | 285 | ||
| 286 | /// The neutral colour tokens one base sets in one theme. The values are CSS colours; | 286 | /// The neutral colour tokens one base sets in one theme. The values are CSS colours; |
| @@ -309,7 +309,7 @@ pub struct Base { | |||
| 309 | } | 309 | } |
| 310 | 310 | ||
| 311 | /// The base used when none is stored, and for anonymous visitors. It must be `BASES[0]`. | 311 | /// The base used when none is stored, and for anonymous visitors. It must be `BASES[0]`. |
| 312 | -pub const BASE_DEFAULT: &str = "fern"; | 312 | +pub const BASE_DEFAULT: &str = "anvil"; |
| 313 | 313 | ||
| 314 | /// One base token: the custom property it becomes and the field of `BaseTokens` that holds its | 314 | /// One base token: the custom property it becomes and the field of `BaseTokens` that holds its |
| 315 | /// value. | 315 | /// value. |
| @@ -373,6 +373,38 @@ pub const BASE_TOKEN_VARS: &[BaseTokenVar] = &[ | |||
| 373 | /// Every base on offer, in the order the picker lists them. `fern` is the original forge | 373 | /// Every base on offer, in the order the picker lists them. `fern` is the original forge |
| 374 | /// neutral set. | 374 | /// neutral set. |
| 375 | pub const BASES: &[Base] = &[ | 375 | pub const BASES: &[Base] = &[ |
| 376 | + // Anvil: warm soot and cooled steel in dark, ash in light. | ||
| 377 | + Base { | ||
| 378 | + id: "anvil", | ||
| 379 | + light: BaseTokens { | ||
| 380 | + bg: "#F6F5F3", | ||
| 381 | + surface: "#FFFFFF", | ||
| 382 | + surface_2: "#EFEEEB", | ||
| 383 | + text: "#191816", | ||
| 384 | + text_2: "#3F3C37", | ||
| 385 | + muted: "#5F5C56", | ||
| 386 | + border: "#E3E1DD", | ||
| 387 | + border_strong: "#C9C6BF", | ||
| 388 | + code_bg: "#EFEEEB", | ||
| 389 | + private_bg: "#EFEEEB", | ||
| 390 | + private_text: "#3F3C37", | ||
| 391 | + ln_text: "#5F5C56", | ||
| 392 | + }, | ||
| 393 | + dark: BaseTokens { | ||
| 394 | + bg: "#141312", | ||
| 395 | + surface: "#1D1C1A", | ||
| 396 | + surface_2: "#292724", | ||
| 397 | + text: "#F2F0EB", | ||
| 398 | + text_2: "#D6D2CA", | ||
| 399 | + muted: "#AAA69D", | ||
| 400 | + border: "#2F2D2A", | ||
| 401 | + border_strong: "#55524C", | ||
| 402 | + code_bg: "#292724", | ||
| 403 | + private_bg: "#292724", | ||
| 404 | + private_text: "#D6D2CA", | ||
| 405 | + ln_text: "#AAA69D", | ||
| 406 | + }, | ||
| 407 | + }, | ||
| 376 | // Fern: the original forge neutrals, green-tinted in light and slate in dark. | 408 | // Fern: the original forge neutrals, green-tinted in light and slate in dark. |
| 377 | Base { | 409 | Base { |
| 378 | id: "fern", | 410 | id: "fern", |
| @@ -534,36 +566,4 @@ pub const BASES: &[Base] = &[ | |||
| 534 | ln_text: "#9C9C98", | 566 | ln_text: "#9C9C98", |
| 535 | }, | 567 | }, |
| 536 | }, | 568 | }, |
| 537 | - // Anvil: warm soot and cooled steel in dark, ash in light. | ||
| 538 | - Base { | ||
| 539 | - id: "anvil", | ||
| 540 | - light: BaseTokens { | ||
| 541 | - bg: "#F5F2EE", | ||
| 542 | - surface: "#FFFDFB", | ||
| 543 | - surface_2: "#ECE7E1", | ||
| 544 | - text: "#1C1916", | ||
| 545 | - text_2: "#3D3631", | ||
| 546 | - muted: "#6E645B", | ||
| 547 | - border: "#E2DBD3", | ||
| 548 | - border_strong: "#CDC3B8", | ||
| 549 | - code_bg: "#EFEAE4", | ||
| 550 | - private_bg: "#ECE7E1", | ||
| 551 | - private_text: "#3D3631", | ||
| 552 | - ln_text: "#6A6058", | ||
| 553 | - }, | ||
| 554 | - dark: BaseTokens { | ||
| 555 | - bg: "#131211", | ||
| 556 | - surface: "#1B1917", | ||
| 557 | - surface_2: "#24211E", | ||
| 558 | - text: "#ECE6DF", | ||
| 559 | - text_2: "#CFC6BC", | ||
| 560 | - muted: "#9C9187", | ||
| 561 | - border: "#2F2B27", | ||
| 562 | - border_strong: "#3E3934", | ||
| 563 | - code_bg: "#0E0D0C", | ||
| 564 | - private_bg: "#24211E", | ||
| 565 | - private_text: "#CFC6BC", | ||
| 566 | - ln_text: "#9C9187", | ||
| 567 | - }, | ||
| 568 | - }, | ||
| 569 | ]; | 569 | ]; |
crates/forge-web-base/src/i18n/accounts.rsmodified+15 -0
| @@ -236,6 +236,21 @@ pub fn meta_line(lang: Lang, uptime: &str, version: &str, build: &str, date: &st | |||
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | /// `3d 4h`, `5h 2m` or `7m`, for the uptime. | 238 | /// `3d 4h`, `5h 2m` or `7m`, for the uptime. |
| 239 | +/// [`duration_short`] in the viewer's language: Turkish says "1 sa 5 dk". | ||
| 240 | +pub fn duration_short_in(lang: Lang, secs: u64) -> String { | ||
| 241 | + if lang == Lang::En { | ||
| 242 | + return duration_short(secs); | ||
| 243 | + } | ||
| 244 | + let (d, h, m) = (secs / 86_400, secs % 86_400 / 3_600, secs % 3_600 / 60); | ||
| 245 | + if d > 0 { | ||
| 246 | + format!("{d} g {h} sa") | ||
| 247 | + } else if h > 0 { | ||
| 248 | + format!("{h} sa {m} dk") | ||
| 249 | + } else { | ||
| 250 | + format!("{m} dk") | ||
| 251 | + } | ||
| 252 | +} | ||
| 253 | + | ||
| 239 | pub fn duration_short(secs: u64) -> String { | 254 | pub fn duration_short(secs: u64) -> String { |
| 240 | let (d, h, m) = (secs / 86_400, secs % 86_400 / 3_600, secs % 3_600 / 60); | 255 | let (d, h, m) = (secs / 86_400, secs % 86_400 / 3_600, secs % 3_600 / 60); |
| 241 | if d > 0 { | 256 | if d > 0 { |
crates/forge-web-base/src/i18n/admin.rsmodified+2 -2
| @@ -560,8 +560,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 560 | (SecurityLogTitle, Tr) => "Güvenlik günlüğü", | 560 | (SecurityLogTitle, Tr) => "Güvenlik günlüğü", |
| 561 | (SecurityNone, En) => "None (plain text)", | 561 | (SecurityNone, En) => "None (plain text)", |
| 562 | (SecurityNone, Tr) => "Yok (düz metin)", | 562 | (SecurityNone, Tr) => "Yok (düz metin)", |
| 563 | - (SendMailCheckbox, En) => " Send mail", | 563 | + (SendMailCheckbox, En) => "Send mail", |
| 564 | - (SendMailCheckbox, Tr) => " E-posta gönder", | 564 | + (SendMailCheckbox, Tr) => "E-posta gönder", |
| 565 | (SendTestMailToMe, En) => "Send test mail to me", | 565 | (SendTestMailToMe, En) => "Send test mail to me", |
| 566 | (SendTestMailToMe, Tr) => "Bana test e-postası gönder", | 566 | (SendTestMailToMe, Tr) => "Bana test e-postası gönder", |
| 567 | (Settings, En) => "Settings", | 567 | (Settings, En) => "Settings", |
crates/forge-web-base/src/i18n/releases_ci.rsmodified+2 -2
| @@ -428,8 +428,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 428 | } | 428 | } |
| 429 | (Tag, En) => "Tag", | 429 | (Tag, En) => "Tag", |
| 430 | (Tag, Tr) => "Etiket", | 430 | (Tag, Tr) => "Etiket", |
| 431 | - (TargetBranch, En) => "Target branch (used only when the tag is created)", | 431 | + (TargetBranch, En) => "Target branch", |
| 432 | - (TargetBranch, Tr) => "Hedef dal (yalnızca etiket oluşturulurken kullanılır)", | 432 | + (TargetBranch, Tr) => "Hedef dal", |
| 433 | (Title, En) => "Title", | 433 | (Title, En) => "Title", |
| 434 | (Title, Tr) => "Başlık", | 434 | (Title, Tr) => "Başlık", |
| 435 | (ReleaseNotes, En) => "Release notes (Markdown)", | 435 | (ReleaseNotes, En) => "Release notes (Markdown)", |
crates/forge-web-base/src/i18n/server_settings.rsmodified+1 -1
| @@ -20,7 +20,7 @@ pub fn field_tr(key: &str) -> Option<(&'static str, &'static str)> { | |||
| 20 | "Duyuru bandı", | 20 | "Duyuru bandı", |
| 21 | "Her sayfada üst bilginin altında gösterilen tek satır. Boş bırakılırsa gizlenir.", | 21 | "Her sayfada üst bilginin altında gösterilen tek satır. Boş bırakılırsa gizlenir.", |
| 22 | ), | 22 | ), |
| 23 | - "banner.level" => ("Bant düzeyi", "info veya warning."), | 23 | + "banner.level" => ("Bant düzeyi", "Bilgi ya da uyarı."), |
| 24 | "banner.expires" => ( | 24 | "banner.expires" => ( |
| 25 | "Bant bitiş zamanı (UTC)", | 25 | "Bant bitiş zamanı (UTC)", |
| 26 | "YYYY-MM-DD HH:MM biçiminde. Boş bırakılırsa bant temizlenene kadar kalır.", | 26 | "YYYY-MM-DD HH:MM biçiminde. Boş bırakılırsa bant temizlenene kadar kalır.", |
crates/forge-web/assets/nav.jsmodified+34 -386
| @@ -223,6 +223,14 @@ | |||
| 223 | function followTail() { | 223 | function followTail() { |
| 224 | var pre = document.querySelector('[data-live-log]'); | 224 | var pre = document.querySelector('[data-live-log]'); |
| 225 | if (!pre || pre.querySelector('.ll-sel')) { return; } | 225 | if (!pre || pre.querySelector('.ll-sel')) { return; } |
| 226 | + // A failed run opens at its first error, a third of the way down the log. | ||
| 227 | + var fail = pre.getAttribute('data-fail-at'); | ||
| 228 | + var line = fail ? pre.querySelector('[id="L' + fail + '"]') : null; | ||
| 229 | + if (line) { | ||
| 230 | + line.classList.add('bad'); | ||
| 231 | + pre.scrollTop = line.getBoundingClientRect().top - pre.getBoundingClientRect().top + pre.scrollTop - pre.clientHeight / 3; | ||
| 232 | + return; | ||
| 233 | + } | ||
| 226 | pre.scrollTop = pre.hasAttribute('data-log-start') ? 0 : pre.scrollHeight; | 234 | pre.scrollTop = pre.hasAttribute('data-log-start') ? 0 : pre.scrollHeight; |
| 227 | } | 235 | } |
| 228 | 236 | ||
| @@ -863,202 +871,6 @@ | |||
| 863 | closeDropdowns(e.target && e.target.nodeType === 1 ? e.target : null); | 871 | closeDropdowns(e.target && e.target.nodeType === 1 ? e.target : null); |
| 864 | }, false); | 872 | }, false); |
| 865 | 873 | ||
| 866 | - // The profile corner can be dragged anywhere on the window. A press records its start; it becomes a | ||
| 867 | - // drag after CORNER_SLOP px of movement, and then the panel follows the pointer, clamped to the | ||
| 868 | - // window. The released position is kept as fractions of the free space, so it holds at any size. | ||
| 869 | - var CORNER_SLOP = 5; | ||
| 870 | - var cornerPress = null; // { el, id, x, y, left, top, dragging } from a press to its release | ||
| 871 | - var cornerSwallow = false; // the click that ends a drag must not open the menu or the bell | ||
| 872 | - | ||
| 873 | - function parseCorner(text) { | ||
| 874 | - var parts = String(text || '').split(','); | ||
| 875 | - if (parts.length !== 2) { return null; } | ||
| 876 | - var x = parseFloat(parts[0]), y = parseFloat(parts[1]); | ||
| 877 | - if (!isFinite(x) || !isFinite(y)) { return null; } | ||
| 878 | - return [Math.min(1, Math.max(0, x)), Math.min(1, Math.max(0, y))]; | ||
| 879 | - } | ||
| 880 | - // [x, y] fractions of the stored position, or null for the default corner. Kept current by drags and resets. | ||
| 881 | - var cornerSaved = parseCorner(document.body.dataset.cornerPos); | ||
| 882 | - | ||
| 883 | - // Registered before the bell's click listener below, so it runs first and stops the click that | ||
| 884 | - // follows a drag once. | ||
| 885 | - window.addEventListener('click', function (e) { | ||
| 886 | - if (!cornerSwallow) { return; } | ||
| 887 | - cornerSwallow = false; | ||
| 888 | - e.preventDefault(); | ||
| 889 | - e.stopImmediatePropagation(); | ||
| 890 | - }, true); | ||
| 891 | - | ||
| 892 | - function cornerEl() { return document.querySelector('.corner-float'); } | ||
| 893 | - | ||
| 894 | - // The menu opens down when the panel is in the top half of the window, and anchors to the right | ||
| 895 | - // edge when the panel is in the right half. The default corner (no attribute) opens up, as before. | ||
| 896 | - function cornerDirection(el, left, top, w, h) { | ||
| 897 | - if (top + h / 2 < window.innerHeight / 2) { el.setAttribute('data-open', 'down'); } else { el.removeAttribute('data-open'); } | ||
| 898 | - if (left + w / 2 > window.innerWidth / 2) { el.setAttribute('data-side', 'right'); } else { el.removeAttribute('data-side'); } | ||
| 899 | - } | ||
| 900 | - | ||
| 901 | - // Places the panel at (left, top) in px, clamped so the whole panel stays in the window. | ||
| 902 | - function cornerPlace(el, left, top) { | ||
| 903 | - var w = el.offsetWidth, h = el.offsetHeight; | ||
| 904 | - left = Math.max(0, Math.min(left, window.innerWidth - w)); | ||
| 905 | - top = Math.max(0, Math.min(top, window.innerHeight - h)); | ||
| 906 | - el.style.left = left + 'px'; | ||
| 907 | - el.style.top = top + 'px'; | ||
| 908 | - el.style.right = 'auto'; | ||
| 909 | - el.style.bottom = 'auto'; | ||
| 910 | - cornerDirection(el, left, top, w, h); | ||
| 911 | - } | ||
| 912 | - | ||
| 913 | - // Puts the panel where the stored position says, or in the default corner. It does nothing while a | ||
| 914 | - // drag runs, so a re-render or a resize does not pull the panel from under the pointer. | ||
| 915 | - function cornerApply() { | ||
| 916 | - var el = cornerEl(); | ||
| 917 | - if (!el || (cornerPress && cornerPress.dragging)) { return; } | ||
| 918 | - if (cornerSaved) { | ||
| 919 | - cornerPlace(el, cornerSaved[0] * (window.innerWidth - el.offsetWidth), cornerSaved[1] * (window.innerHeight - el.offsetHeight)); | ||
| 920 | - return; | ||
| 921 | - } | ||
| 922 | - el.style.left = ''; | ||
| 923 | - el.style.top = ''; | ||
| 924 | - el.style.right = ''; | ||
| 925 | - el.style.bottom = ''; | ||
| 926 | - var r = el.getBoundingClientRect(); | ||
| 927 | - cornerDirection(el, r.left, r.top, el.offsetWidth, el.offsetHeight); | ||
| 928 | - } | ||
| 929 | - | ||
| 930 | - // Saves one account preference through /-/prefs, signed in only (the CSRF token comes from the | ||
| 931 | - // panel). Saves go one after another, and `read` gives the value at the moment of sending, so the | ||
| 932 | - // last one sent holds the newest value. A failure is ignored: the next load shows what the server has. | ||
| 933 | - var prefsChain = Promise.resolve(); | ||
| 934 | - function prefSave(key, read) { | ||
| 935 | - prefsChain = prefsChain.then(function () { | ||
| 936 | - var el = document.querySelector('.corner-float[data-prefs-csrf]'); | ||
| 937 | - var body = new URLSearchParams({ csrf: el ? el.getAttribute('data-prefs-csrf') : '', key: key, value: read() }); | ||
| 938 | - return fetch('/-/prefs', { method: 'POST', credentials: 'same-origin', body: body }); | ||
| 939 | - }).catch(function () { }); | ||
| 940 | - } | ||
| 941 | - | ||
| 942 | - document.addEventListener('pointerdown', function (e) { | ||
| 943 | - cornerSwallow = false; | ||
| 944 | - var el = e.target && e.target.closest ? e.target.closest('.corner-float') : null; | ||
| 945 | - if (!el || e.button !== 0) { cornerPress = null; return; } | ||
| 946 | - var r = el.getBoundingClientRect(); | ||
| 947 | - cornerPress = { el: el, id: e.pointerId, x: e.clientX, y: e.clientY, left: r.left, top: r.top, dragging: false }; | ||
| 948 | - }); | ||
| 949 | - | ||
| 950 | - document.addEventListener('pointermove', function (e) { | ||
| 951 | - var p = cornerPress; | ||
| 952 | - if (!p || e.pointerId !== p.id) { return; } | ||
| 953 | - if (!p.dragging) { | ||
| 954 | - if (Math.hypot(e.clientX - p.x, e.clientY - p.y) < CORNER_SLOP) { return; } | ||
| 955 | - p.dragging = true; | ||
| 956 | - // A drag ends any hover the mouse started: the menu or the bell closes, and a pending open is dropped. | ||
| 957 | - clearTimeout(hoverTimer); | ||
| 958 | - hoverTimer = 0; | ||
| 959 | - hoverHide(); | ||
| 960 | - try { p.el.setPointerCapture(p.id); } catch (err) { } | ||
| 961 | - p.el.classList.add('dragging'); | ||
| 962 | - } | ||
| 963 | - cornerPlace(p.el, p.left + e.clientX - p.x, p.top + e.clientY - p.y); | ||
| 964 | - }); | ||
| 965 | - | ||
| 966 | - function cornerEnd(e) { | ||
| 967 | - var p = cornerPress; | ||
| 968 | - if (!p || e.pointerId !== p.id) { return; } | ||
| 969 | - cornerPress = null; | ||
| 970 | - if (!p.dragging) { return; } | ||
| 971 | - p.el.classList.remove('dragging'); | ||
| 972 | - if (e.type === 'pointercancel') { cornerApply(); return; } | ||
| 973 | - cornerSwallow = true; | ||
| 974 | - // A swap that replaced the panel during the drag leaves the new one to the stored position. | ||
| 975 | - if (!p.el.isConnected) { cornerApply(); return; } | ||
| 976 | - var room = { x: window.innerWidth - p.el.offsetWidth, y: window.innerHeight - p.el.offsetHeight }; | ||
| 977 | - var x = room.x > 0 ? Math.round(10000 * (parseFloat(p.el.style.left) || 0) / room.x) / 10000 : 0; | ||
| 978 | - var y = room.y > 0 ? Math.round(10000 * (parseFloat(p.el.style.top) || 0) / room.y) / 10000 : 0; | ||
| 979 | - x = Math.min(1, Math.max(0, x)); | ||
| 980 | - y = Math.min(1, Math.max(0, y)); | ||
| 981 | - cornerSaved = [x, y]; | ||
| 982 | - prefSave('corner_pos', function () { return x + ',' + y; }); | ||
| 983 | - } | ||
| 984 | - document.addEventListener('pointerup', cornerEnd); | ||
| 985 | - document.addEventListener('pointercancel', cornerEnd); | ||
| 986 | - | ||
| 987 | - // A double click on the panel, not on a link or a button, returns it to the default corner. | ||
| 988 | - document.addEventListener('dblclick', function (e) { | ||
| 989 | - var target = e.target; | ||
| 990 | - if (!target || !target.closest || target.closest('a, button, input, select, textarea, summary, label, [role="button"]')) { return; } | ||
| 991 | - var el = target.closest('.corner-float'); | ||
| 992 | - if (!el) { return; } | ||
| 993 | - cornerSaved = null; | ||
| 994 | - prefSave('corner_pos', function () { return ''; }); | ||
| 995 | - cornerApply(); | ||
| 996 | - }); | ||
| 997 | - | ||
| 998 | - document.addEventListener('forge:swapped', cornerApply); | ||
| 999 | - window.addEventListener('resize', cornerApply); | ||
| 1000 | - cornerApply(); | ||
| 1001 | - | ||
| 1002 | - // Below 900px the profile corner covers the page the reader is reading, so it steps aside | ||
| 1003 | - // (corner-away) while they scroll down and comes back when they scroll up, near the top or at the | ||
| 1004 | - // end. It stays put while its menu, the bell popover or a drag is open. The scroll listener is on | ||
| 1005 | - // the document in the capture phase, so it survives a swap that replaces the body. Inner lists and | ||
| 1006 | - // log tails scroll on their own: their events are skipped, as the window's scroll targets the document. | ||
| 1007 | - var cornerNarrow = window.matchMedia ? window.matchMedia('(max-width: 899px)') : null; | ||
| 1008 | - var cornerY = window.scrollY; // the scroll position last seen | ||
| 1009 | - var cornerRun = 0; // the distance scrolled since the direction last turned | ||
| 1010 | - var cornerWant = false; // whether the corner should step aside | ||
| 1011 | - var CORNER_STEP = 8; // the run that hides the corner, or brings it back | ||
| 1012 | - var CORNER_TOP = 40; // within this of the top the corner always shows | ||
| 1013 | - | ||
| 1014 | - // True while the corner must stay in view: its menu is open, a bell popover is open, or it is dragged. | ||
| 1015 | - function cornerBusy(el) { | ||
| 1016 | - if (el.classList.contains('dragging')) { return true; } | ||
| 1017 | - if (document.querySelector('details.corner[open]')) { return true; } | ||
| 1018 | - return Array.prototype.some.call(document.querySelectorAll('.bell-pop'), isPeekOpen); | ||
| 1019 | - } | ||
| 1020 | - | ||
| 1021 | - // Applies the wanted state to the corner as it is now (a swap replaces it). Only below 900px. | ||
| 1022 | - function cornerAway() { | ||
| 1023 | - var el = cornerEl(); | ||
| 1024 | - if (!el) { return; } | ||
| 1025 | - var on = cornerWant && cornerNarrow && cornerNarrow.matches && !cornerBusy(el); | ||
| 1026 | - el.classList.toggle('corner-away', !!on); | ||
| 1027 | - } | ||
| 1028 | - | ||
| 1029 | - function cornerScrolled(e) { | ||
| 1030 | - if (e.target !== document) { return; } | ||
| 1031 | - var y = window.scrollY; | ||
| 1032 | - var dy = y - cornerY; | ||
| 1033 | - cornerY = y; | ||
| 1034 | - if (y <= CORNER_TOP || y >= document.documentElement.scrollHeight - window.innerHeight - 2) { | ||
| 1035 | - cornerRun = 0; | ||
| 1036 | - cornerWant = false; | ||
| 1037 | - } else { | ||
| 1038 | - // A run keeps its direction; a turn starts a new one. | ||
| 1039 | - cornerRun = (dy > 0 && cornerRun >= 0) || (dy < 0 && cornerRun <= 0) ? cornerRun + dy : dy; | ||
| 1040 | - if (cornerRun > CORNER_STEP) { cornerWant = true; } | ||
| 1041 | - else if (cornerRun < -CORNER_STEP) { cornerWant = false; } | ||
| 1042 | - } | ||
| 1043 | - cornerAway(); | ||
| 1044 | - } | ||
| 1045 | - | ||
| 1046 | - // A page swap moves the scroll (to the top on a link) before this runs, so the anchor is taken now. | ||
| 1047 | - // The corner keeps its state across a live refresh, and shows again at the top. | ||
| 1048 | - document.addEventListener('forge:swapped', function () { | ||
| 1049 | - cornerY = window.scrollY; | ||
| 1050 | - cornerRun = 0; | ||
| 1051 | - if (cornerY <= CORNER_TOP) { cornerWant = false; } | ||
| 1052 | - cornerAway(); | ||
| 1053 | - }); | ||
| 1054 | - // A menu, popover or details opened or closed may make the corner busy: it is checked again. | ||
| 1055 | - document.addEventListener('toggle', cornerAway, true); | ||
| 1056 | - window.addEventListener('resize', function () { | ||
| 1057 | - if (!cornerNarrow || !cornerNarrow.matches) { cornerWant = false; } | ||
| 1058 | - cornerAway(); | ||
| 1059 | - }); | ||
| 1060 | - document.addEventListener('scroll', cornerScrolled, { capture: true, passive: true }); | ||
| 1061 | - | ||
| 1062 | // A mouse that rests on the profile corner opens its account menu, or the bell popover on the bell, | 874 | // A mouse that rests on the profile corner opens its account menu, or the bell popover on the bell, |
| 1063 | // after a short rest; when it leaves, the menu or popover it opened closes. Touch and keyboard | 875 | // after a short rest; when it leaves, the menu or popover it opened closes. Touch and keyboard |
| 1064 | // keep the click. hoverOn names what the mouse opened; hoverWait says whether the pending timer | 876 | // keep the click. hoverOn names what the mouse opened; hoverWait says whether the pending timer |
| @@ -1070,8 +882,8 @@ | |||
| 1070 | var hoverWait = ''; // 'show' or 'hide': what the pending timer does | 882 | var hoverWait = ''; // 'show' or 'hide': what the pending timer does |
| 1071 | var hoverMute = false; // a click on the bell: it stays shut until the mouse leaves the bell | 883 | var hoverMute = false; // a click on the bell: it stays shut until the mouse leaves the bell |
| 1072 | 884 | ||
| 1073 | - // The part of the corner a node belongs to: 'bell' for the bell and its popover (tested first, as | 885 | + // The part of the profile a node belongs to: 'bell' for the notifications row and its popover |
| 1074 | - // the popover sits inside the panel), 'menu' for the rest of the panel, null elsewhere. | 886 | + // (tested first, as they sit inside the menu), 'menu' for the rest, null elsewhere. |
| 1075 | function hoverKind(node) { | 887 | function hoverKind(node) { |
| 1076 | if (!node || !node.closest) { return null; } | 888 | if (!node || !node.closest) { return null; } |
| 1077 | if (node.closest('.corner-bell, .bell-pop')) { return 'bell'; } | 889 | if (node.closest('.corner-bell, .bell-pop')) { return 'bell'; } |
| @@ -1089,16 +901,16 @@ | |||
| 1089 | return !!(pop && isPeekOpen(pop)); | 901 | return !!(pop && isPeekOpen(pop)); |
| 1090 | } | 902 | } |
| 1091 | 903 | ||
| 1092 | - // Opens the menu or the bell popover for a resting mouse. One the reader opened by click or keyboard | 904 | + // Opens the menu, or the bell popover beside it, for a resting mouse. A menu the reader opened by |
| 1093 | - // is left alone. | 905 | + // click or keyboard is left alone. The popover sits inside the menu, so the menu stays open under it. |
| 1094 | function hoverShow(kind) { | 906 | function hoverShow(kind) { |
| 1095 | - if (hoverOn && hoverOn !== kind) { hoverHide(); } | 907 | + if (!hoverOn && hoverIsOpen(kind)) { return; } |
| 1096 | - if (hoverIsOpen(kind) && hoverOn !== kind) { return; } | 908 | + var details = document.querySelector('details.corner'); |
| 909 | + var pop = document.querySelector('.bell-pop'); | ||
| 1097 | if (kind === 'menu') { | 910 | if (kind === 'menu') { |
| 1098 | - var details = document.querySelector('details.corner'); | 911 | + try { if (pop) { pop.hidePopover(); } } catch (err) { } |
| 1099 | if (details) { details.open = true; } | 912 | if (details) { details.open = true; } |
| 1100 | } else { | 913 | } else { |
| 1101 | - var pop = document.querySelector('.bell-pop'); | ||
| 1102 | try { if (pop) { pop.showPopover(); } } catch (err) { } | 914 | try { if (pop) { pop.showPopover(); } } catch (err) { } |
| 1103 | } | 915 | } |
| 1104 | hoverOn = kind; | 916 | hoverOn = kind; |
| @@ -1106,12 +918,11 @@ | |||
| 1106 | 918 | ||
| 1107 | // Closes what the mouse opened, and forgets it. | 919 | // Closes what the mouse opened, and forgets it. |
| 1108 | function hoverHide() { | 920 | function hoverHide() { |
| 1109 | - if (hoverOn === 'menu') { | 921 | + if (hoverOn) { |
| 1110 | - var details = document.querySelector('details.corner'); | ||
| 1111 | - if (details) { details.open = false; } | ||
| 1112 | - } else if (hoverOn === 'bell') { | ||
| 1113 | var pop = document.querySelector('.bell-pop'); | 922 | var pop = document.querySelector('.bell-pop'); |
| 923 | + var details = document.querySelector('details.corner'); | ||
| 1114 | try { if (pop) { pop.hidePopover(); } } catch (err) { } | 924 | try { if (pop) { pop.hidePopover(); } } catch (err) { } |
| 925 | + if (details) { details.open = false; } | ||
| 1115 | } | 926 | } |
| 1116 | hoverOn = null; | 927 | hoverOn = null; |
| 1117 | } | 928 | } |
| @@ -1120,7 +931,7 @@ | |||
| 1120 | // corner cancels a pending show, and starts a hide only when nothing is pending, so moving across the | 931 | // corner cancels a pending show, and starts a hide only when nothing is pending, so moving across the |
| 1121 | // page does not keep pushing the hide back. | 932 | // page does not keep pushing the hide back. |
| 1122 | document.addEventListener('pointerover', function (e) { | 933 | document.addEventListener('pointerover', function (e) { |
| 1123 | - if (e.pointerType !== 'mouse' || cornerPress) { return; } | 934 | + if (e.pointerType !== 'mouse') { return; } |
| 1124 | var kind = hoverKind(e.target); | 935 | var kind = hoverKind(e.target); |
| 1125 | if (hoverMute) { | 936 | if (hoverMute) { |
| 1126 | if (kind === 'bell') { return; } | 937 | if (kind === 'bell') { return; } |
| @@ -1151,11 +962,9 @@ | |||
| 1151 | }); | 962 | }); |
| 1152 | 963 | ||
| 1153 | // A click on the menu's summary, while the mouse holds it open, does nothing: the menu stays open. | 964 | // A click on the menu's summary, while the mouse holds it open, does nothing: the menu stays open. |
| 1154 | - // A chip link inside the summary still goes where it leads. Registered after the drag's swallow | ||
| 1155 | - // listener, so that one runs first. | ||
| 1156 | window.addEventListener('click', function (e) { | 965 | window.addEventListener('click', function (e) { |
| 1157 | if (hoverOn !== 'menu' || !e.target || !e.target.closest) { return; } | 966 | if (hoverOn !== 'menu' || !e.target || !e.target.closest) { return; } |
| 1158 | - if (!e.target.closest('summary.corner-btn') || e.target.closest('a')) { return; } | 967 | + if (!e.target.closest('summary.corner-btn')) { return; } |
| 1159 | e.preventDefault(); | 968 | e.preventDefault(); |
| 1160 | }, true); | 969 | }, true); |
| 1161 | 970 | ||
| @@ -1171,22 +980,18 @@ | |||
| 1171 | try { return pop.matches(':popover-open'); } catch (err) { return false; } | 980 | try { return pop.matches(':popover-open'); } catch (err) { return false; } |
| 1172 | } | 981 | } |
| 1173 | 982 | ||
| 1174 | - // Under the bell, opening upward: the popover's bottom sits 6px above the bell's top, and its left | 983 | + // Beside the menu, level with the notifications row. When the window has no room for that, under |
| 1175 | - // edge follows the bell but stays inside the viewport. | 984 | + // the row. Either way it stays inside the window. |
| 1176 | - // When the panel sits in the top half (data-open="down" on it), the popover opens below the bell. | ||
| 1177 | function placePeek(bell, pop) { | 985 | function placePeek(bell, pop) { |
| 1178 | if (!bell) { return; } | 986 | if (!bell) { return; } |
| 1179 | var r = bell.getBoundingClientRect(); | 987 | var r = bell.getBoundingClientRect(); |
| 1180 | - var left = Math.max(8, Math.min(r.left, window.innerWidth - pop.offsetWidth - 8)); | 988 | + var menu = bell.closest('.corner-menu'); |
| 989 | + var right = (menu ? menu.getBoundingClientRect().right : r.right) + 8; | ||
| 990 | + var beside = right + pop.offsetWidth + 8 <= window.innerWidth; | ||
| 991 | + var left = beside ? right : Math.max(8, Math.min(r.left, window.innerWidth - pop.offsetWidth - 8)); | ||
| 1181 | pop.style.left = left + 'px'; | 992 | pop.style.left = left + 'px'; |
| 1182 | - var corner = bell.closest('.corner-float'); | 993 | + pop.style.top = (beside ? r.top - 8 : r.bottom + 6) + 'px'; |
| 1183 | - if (corner && corner.getAttribute('data-open') === 'down') { | 994 | + pop.style.bottom = 'auto'; |
| 1184 | - pop.style.top = (r.bottom + 6) + 'px'; | ||
| 1185 | - pop.style.bottom = 'auto'; | ||
| 1186 | - } else { | ||
| 1187 | - pop.style.top = 'auto'; | ||
| 1188 | - pop.style.bottom = (window.innerHeight - r.top + 6) + 'px'; | ||
| 1189 | - } | ||
| 1190 | } | 995 | } |
| 1191 | 996 | ||
| 1192 | // Fills the popover's list with the server's fragment. The popover stays invisible until then, so it | 997 | // Fills the popover's list with the server's fragment. The popover stays invisible until then, so it |
| @@ -1307,139 +1112,6 @@ | |||
| 1307 | if (hoverOn && !hoverIsOpen(hoverOn)) { hoverOn = null; } | 1112 | if (hoverOn && !hoverIsOpen(hoverOn)) { hoverOn = null; } |
| 1308 | }); | 1113 | }); |
| 1309 | 1114 | ||
| 1310 | - // Repo home resize: a drag on the separator between the file tree and the README sets the tree's | ||
| 1311 | - // width, the --tree-w property of the .repo-home grid. The width is kept in localStorage and applied | ||
| 1312 | - // to each repo home on load and after every swap. The README takes the rest of the row. | ||
| 1313 | - var TREE_KEY = 'forge-tree-w'; // signed-out visitors keep the width in localStorage | ||
| 1314 | - // Signed in, the width is the account's tree_width preference. The variable starts from the page's | ||
| 1315 | - // data-tree-w and follows every change, so a swap never reads back an older value. | ||
| 1316 | - var signedIn = document.body.dataset.signedIn === 'true'; | ||
| 1317 | - var treeAccount = parseFloat(document.body.dataset.treeW) || 0; | ||
| 1318 | - var treeTimer = null; | ||
| 1319 | - var TREE_MIN = 220; // px, the narrowest the tree goes | ||
| 1320 | - var README_MIN = 360; // px, room the drag always leaves for the README | ||
| 1321 | - var TREE_STEP = 16; // px per arrow key; Shift moves 64px | ||
| 1322 | - var treeDrag = null; // { grid, id, x, w, moved } while a pointer drag runs | ||
| 1323 | - | ||
| 1324 | - function treeLoad() { | ||
| 1325 | - if (signedIn) { return treeAccount; } | ||
| 1326 | - try { return parseFloat(localStorage.getItem(TREE_KEY)) || 0; } catch (err) { return 0; } | ||
| 1327 | - } | ||
| 1328 | - | ||
| 1329 | - function treeStore(px) { | ||
| 1330 | - if (signedIn) { | ||
| 1331 | - treeAccount = px ? Math.round(px) : 0; | ||
| 1332 | - // One save once the changes settle, not one per step of a drag or a key repeat. | ||
| 1333 | - clearTimeout(treeTimer); | ||
| 1334 | - treeTimer = setTimeout(function () { | ||
| 1335 | - treeTimer = null; | ||
| 1336 | - prefSave('tree_width', function () { return treeAccount ? String(treeAccount) : ''; }); | ||
| 1337 | - }, 300); | ||
| 1338 | - return; | ||
| 1339 | - } | ||
| 1340 | - try { | ||
| 1341 | - if (px) { localStorage.setItem(TREE_KEY, String(Math.round(px))); } else { localStorage.removeItem(TREE_KEY); } | ||
| 1342 | - } catch (err) { } | ||
| 1343 | - } | ||
| 1344 | - | ||
| 1345 | - // The widest the tree can be: the grid less the splitter, the two gaps and the README's minimum. | ||
| 1346 | - function treeMax(grid) { | ||
| 1347 | - var split = grid.querySelector('[data-repo-split]'); | ||
| 1348 | - var gap = parseFloat(getComputedStyle(grid).columnGap) || 0; | ||
| 1349 | - var max = grid.getBoundingClientRect().width - split.getBoundingClientRect().width - 2 * gap - README_MIN; | ||
| 1350 | - return Math.max(TREE_MIN, Math.floor(max)); | ||
| 1351 | - } | ||
| 1352 | - | ||
| 1353 | - // Sets the tree width (clamped) and keeps the separator's aria values in step with it. | ||
| 1354 | - function treeSet(grid, px) { | ||
| 1355 | - var split = grid.querySelector('[data-repo-split]'); | ||
| 1356 | - var max = treeMax(grid); | ||
| 1357 | - var w = Math.min(max, Math.max(TREE_MIN, Math.round(px))); | ||
| 1358 | - grid.style.setProperty('--tree-w', w + 'px'); | ||
| 1359 | - split.setAttribute('aria-valuemin', String(TREE_MIN)); | ||
| 1360 | - split.setAttribute('aria-valuemax', String(max)); | ||
| 1361 | - split.setAttribute('aria-valuenow', String(w)); | ||
| 1362 | - return w; | ||
| 1363 | - } | ||
| 1364 | - | ||
| 1365 | - function treeWidth(grid) { | ||
| 1366 | - return grid.querySelector('.repo-main').getBoundingClientRect().width; | ||
| 1367 | - } | ||
| 1368 | - | ||
| 1369 | - // Applies the stored width to one repo home (or the default when none is stored). Below 900px the | ||
| 1370 | - // splitter is hidden and the columns stack, so there is nothing to set. | ||
| 1371 | - function treeApply(grid) { | ||
| 1372 | - var split = grid && grid.querySelector('[data-repo-split]'); | ||
| 1373 | - if (!split || getComputedStyle(split).display === 'none') { return; } | ||
| 1374 | - var saved = treeLoad(); | ||
| 1375 | - if (saved) { treeSet(grid, saved); return; } | ||
| 1376 | - grid.style.removeProperty('--tree-w'); | ||
| 1377 | - split.setAttribute('aria-valuemin', String(TREE_MIN)); | ||
| 1378 | - split.setAttribute('aria-valuemax', String(treeMax(grid))); | ||
| 1379 | - split.setAttribute('aria-valuenow', String(Math.round(treeWidth(grid)))); | ||
| 1380 | - } | ||
| 1381 | - | ||
| 1382 | - function treeApplyAll() { | ||
| 1383 | - document.querySelectorAll('.repo-home').forEach(treeApply); | ||
| 1384 | - } | ||
| 1385 | - | ||
| 1386 | - treeApplyAll(); | ||
| 1387 | - document.addEventListener('forge:swapped', treeApplyAll); | ||
| 1388 | - | ||
| 1389 | - document.addEventListener('pointerdown', function (e) { | ||
| 1390 | - var split = e.target.closest && e.target.closest('[data-repo-split]'); | ||
| 1391 | - var grid = split && split.closest('.repo-home'); | ||
| 1392 | - if (!grid || e.button !== 0 || getComputedStyle(split).display === 'none') { return; } | ||
| 1393 | - e.preventDefault(); | ||
| 1394 | - split.setPointerCapture(e.pointerId); | ||
| 1395 | - treeDrag = { grid: grid, id: e.pointerId, x: e.clientX, w: treeWidth(grid), moved: false }; | ||
| 1396 | - root.classList.add('tree-resizing'); | ||
| 1397 | - }); | ||
| 1398 | - | ||
| 1399 | - document.addEventListener('pointermove', function (e) { | ||
| 1400 | - if (!treeDrag || e.pointerId !== treeDrag.id) { return; } | ||
| 1401 | - if (e.clientX !== treeDrag.x) { treeDrag.moved = true; } | ||
| 1402 | - treeSet(treeDrag.grid, treeDrag.w + e.clientX - treeDrag.x); | ||
| 1403 | - }); | ||
| 1404 | - | ||
| 1405 | - function treeEnd(e) { | ||
| 1406 | - if (!treeDrag || e.pointerId !== treeDrag.id) { return; } | ||
| 1407 | - var drag = treeDrag; | ||
| 1408 | - treeDrag = null; | ||
| 1409 | - root.classList.remove('tree-resizing'); | ||
| 1410 | - if (drag.moved) { treeStore(treeWidth(drag.grid)); } | ||
| 1411 | - } | ||
| 1412 | - document.addEventListener('pointerup', treeEnd); | ||
| 1413 | - document.addEventListener('pointercancel', treeEnd); | ||
| 1414 | - | ||
| 1415 | - // Double-click resets the split to the default. | ||
| 1416 | - document.addEventListener('dblclick', function (e) { | ||
| 1417 | - var split = e.target.closest && e.target.closest('[data-repo-split]'); | ||
| 1418 | - var grid = split && split.closest('.repo-home'); | ||
| 1419 | - if (!grid) { return; } | ||
| 1420 | - grid.style.removeProperty('--tree-w'); | ||
| 1421 | - treeStore(null); | ||
| 1422 | - treeApply(grid); | ||
| 1423 | - }); | ||
| 1424 | - | ||
| 1425 | - // Arrow keys move the separator; Home resets it. | ||
| 1426 | - document.addEventListener('keydown', function (e) { | ||
| 1427 | - var split = e.target.closest && e.target.closest('[data-repo-split]'); | ||
| 1428 | - var grid = split && split.closest('.repo-home'); | ||
| 1429 | - if (!grid) { return; } | ||
| 1430 | - if (e.key === 'Home') { | ||
| 1431 | - grid.style.removeProperty('--tree-w'); | ||
| 1432 | - treeStore(null); | ||
| 1433 | - treeApply(grid); | ||
| 1434 | - } else if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') { | ||
| 1435 | - var step = e.shiftKey ? 64 : TREE_STEP; | ||
| 1436 | - treeStore(treeSet(grid, treeWidth(grid) + (e.key === 'ArrowRight' ? step : -step))); | ||
| 1437 | - } else { | ||
| 1438 | - return; | ||
| 1439 | - } | ||
| 1440 | - e.preventDefault(); | ||
| 1441 | - }); | ||
| 1442 | - | ||
| 1443 | // Escape closes the open dropdowns and returns focus to the summary of the one that held it. | 1115 | // Escape closes the open dropdowns and returns focus to the summary of the one that held it. |
| 1444 | document.addEventListener('keydown', function (e) { | 1116 | document.addEventListener('keydown', function (e) { |
| 1445 | if (e.key !== 'Escape') { return; } | 1117 | if (e.key !== 'Escape') { return; } |
| @@ -2340,28 +2012,6 @@ | |||
| 2340 | // ends, so while any is listed the JSON is fetched again every 30 s. | 2012 | // ends, so while any is listed the JSON is fetched again every 30 s. |
| 2341 | var activitySeq = 0; // a fetch's number: only the newest answer is drawn | 2013 | var activitySeq = 0; // a fetch's number: only the newest answer is drawn |
| 2342 | var activityTimer = null; // the next refetch while finished runs are listed | 2014 | var activityTimer = null; // the next refetch while finished runs are listed |
| 2343 | - var SVG_NS = 'http://www.w3.org/2000/svg'; | ||
| 2344 | - // The icons the server draws in the chips, as [element, attributes] pairs. | ||
| 2345 | - var CHIP_ICONS = { | ||
| 2346 | - review: [['path', { d: 'M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z' }], ['circle', { cx: '12', cy: '12', r: '3' }]], | ||
| 2347 | - mention: [['circle', { cx: '12', cy: '12', r: '4' }], ['path', { d: 'M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94' }]], | ||
| 2348 | - failing: [['path', { d: 'M6 6l12 12M18 6 6 18' }]] | ||
| 2349 | - }; | ||
| 2350 | - | ||
| 2351 | - // An icon element built from CHIP_ICONS, the same markup the server writes. | ||
| 2352 | - function chipIcon(kind) { | ||
| 2353 | - var svg = document.createElementNS(SVG_NS, 'svg'); | ||
| 2354 | - svg.setAttribute('class', 'ico'); | ||
| 2355 | - svg.setAttribute('viewBox', '0 0 24 24'); | ||
| 2356 | - svg.setAttribute('aria-hidden', 'true'); | ||
| 2357 | - CHIP_ICONS[kind].forEach(function (part) { | ||
| 2358 | - var el = document.createElementNS(SVG_NS, part[0]); | ||
| 2359 | - Object.keys(part[1]).forEach(function (k) { el.setAttribute(k, part[1][k]); }); | ||
| 2360 | - svg.appendChild(el); | ||
| 2361 | - }); | ||
| 2362 | - return svg; | ||
| 2363 | - } | ||
| 2364 | - | ||
| 2365 | // A link target from the server, used only when it is a path on this site. | 2015 | // A link target from the server, used only when it is a path on this site. |
| 2366 | function localHref(href) { | 2016 | function localHref(href) { |
| 2367 | return typeof href === 'string' && href.charAt(0) === '/' && href.charAt(1) !== '/' ? href : ''; | 2017 | return typeof href === 'string' && href.charAt(0) === '/' && href.charAt(1) !== '/' ? href : ''; |
| @@ -2475,9 +2125,9 @@ | |||
| 2475 | return item ? item.href : '/notifications'; | 2125 | return item ? item.href : '/notifications'; |
| 2476 | }; | 2126 | }; |
| 2477 | var chips = [ | 2127 | var chips = [ |
| 2478 | - { kind: 'review', cls: 'chip chip-review', n: json.reviews, tpl: 'data-review', href: newest('review') }, | 2128 | + { kind: 'review', cls: 'corner-link chip-review', n: json.reviews, tpl: 'data-review', href: newest('review') }, |
| 2479 | - { kind: 'mention', cls: 'chip chip-mention', n: json.mentions, tpl: 'data-mention', href: newest('mention') }, | 2129 | + { kind: 'mention', cls: 'corner-link chip-mention', n: json.mentions, tpl: 'data-mention', href: newest('mention') }, |
| 2480 | - { kind: 'failing', cls: 'chip chip-failing', n: json.failing, tpl: 'data-failing', href: json.failing_href || '/notifications' } | 2130 | + { kind: 'failing', cls: 'corner-link chip-failing', n: json.failing, tpl: 'data-failing', href: json.failing_href || '/notifications' } |
| 2481 | ]; | 2131 | ]; |
| 2482 | box.textContent = ''; | 2132 | box.textContent = ''; |
| 2483 | chips.forEach(function (c) { | 2133 | chips.forEach(function (c) { |
| @@ -2487,9 +2137,7 @@ | |||
| 2487 | var chip = document.createElement('a'); | 2137 | var chip = document.createElement('a'); |
| 2488 | chip.className = c.cls; | 2138 | chip.className = c.cls; |
| 2489 | chip.setAttribute('href', c.href); | 2139 | chip.setAttribute('href', c.href); |
| 2490 | - chip.setAttribute('title', tpl.split('{n}').join(String(n))); | 2140 | + chip.textContent = tpl.split('{n}').join(String(n)); |
| 2491 | - chip.appendChild(chipIcon(c.kind)); | ||
| 2492 | - chip.appendChild(document.createTextNode(String(n))); | ||
| 2493 | box.appendChild(chip); | 2141 | box.appendChild(chip); |
| 2494 | }); | 2142 | }); |
| 2495 | } | 2143 | } |
| @@ -6630,7 +6278,7 @@ | |||
| 6630 | function (a) { return (a.getAttribute('href') || '').indexOf(base + '/') === 0; }); | 6278 | function (a) { return (a.getAttribute('href') || '').indexOf(base + '/') === 0; }); |
| 6631 | tab.classList.toggle('tab-live', going); | 6279 | tab.classList.toggle('tab-live', going); |
| 6632 | } | 6280 | } |
| 6633 | - setIcon(going || !!document.querySelector('.ci-run .ci-state.ci-running')); | 6281 | + setIcon(going || !!document.querySelector('.ci-run h1.live')); |
| 6634 | } | 6282 | } |
| 6635 | 6283 | ||
| 6636 | function queueSync() { | 6284 | function queueSync() { |
crates/forge-web/src/pages/admin_backups.rsmodified+16 -20
| @@ -24,7 +24,7 @@ use crate::live::{Topic, stream_changes}; | |||
| 24 | use crate::pages::admin_users::admin_only; | 24 | use crate::pages::admin_users::admin_only; |
| 25 | use crate::pages::issues_list::stamp_unix; | 25 | use crate::pages::issues_list::stamp_unix; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| 27 | -use crate::views::parts::post_act; | 27 | +use crate::views::parts::{SubPart, head, post_act}; |
| 28 | use crate::views::{enc, rel_time, shell}; | 28 | use crate::views::{enc, rel_time, shell}; |
| 29 | 29 | ||
| 30 | /// Runs shown on the page. | 30 | /// Runs shown on the page. |
| @@ -142,13 +142,25 @@ async fn backups_view( | |||
| 142 | matches!(running, Some(RunKind::Backup)).then(|| g::running_line(lang, RunKind::Backup)); | 142 | matches!(running, Some(RunKind::Backup)).then(|| g::running_line(lang, RunKind::Backup)); |
| 143 | let fsck_running = | 143 | let fsck_running = |
| 144 | matches!(running, Some(RunKind::Fsck)).then(|| g::running_line(lang, RunKind::Fsck)); | 144 | matches!(running, Some(RunKind::Fsck)).then(|| g::running_line(lang, RunKind::Fsck)); |
| 145 | + let sub = vec![SubPart::text(g::t(lang, K::BackupsIntro))]; | ||
| 145 | Ok(view! { | 146 | Ok(view! { |
| 146 | - <div data-live="/admin/backups/events"> | 147 | + head(title: g::t(lang, K::Backups), sub: sub, |
| 147 | - <h1 class="sr-only">(g::t(lang, K::Backups))</h1> | 148 | + <form id="run-backup" method="post" action="/admin/backups/run" class="act-form"> |
| 148 | - <p class="hint">(g::t(lang, K::BackupsIntro))</p> | 149 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 150 | + <button type="submit" class="button">(g::t(lang, K::RunBackupNow))</button> | ||
| 151 | + </form> | ||
| 152 | + post_act(label: g::t(lang, K::RunFsckNow), action: "/admin/backups/fsck", csrf: csrf.as_str()) | ||
| 153 | + ) | ||
| 149 | if let Some(message) = notice { | 154 | if let Some(message) = notice { |
| 150 | <p class="state" role="status">(message.as_str())</p> | 155 | <p class="state" role="status">(message.as_str())</p> |
| 151 | } | 156 | } |
| 157 | + <div class="sheet" data-live="/admin/backups/events"> | ||
| 158 | + if let Some(line) = backup_running { | ||
| 159 | + <p class="state">(line)</p> | ||
| 160 | + } | ||
| 161 | + if let Some(line) = fsck_running { | ||
| 162 | + <p class="state">(line)</p> | ||
| 163 | + } | ||
| 152 | <section class="sec"> | 164 | <section class="sec"> |
| 153 | if settings.enabled { | 165 | if settings.enabled { |
| 154 | <h2>(crate::pages::passkeys::s(lang, "Configuration", "Yapılandırma"))</h2> | 166 | <h2>(crate::pages::passkeys::s(lang, "Configuration", "Yapılandırma"))</h2> |
| @@ -177,22 +189,6 @@ async fn backups_view( | |||
| 177 | <p class="state">(g::t(lang, K::ScheduledBackupsOff))</p> | 189 | <p class="state">(g::t(lang, K::ScheduledBackupsOff))</p> |
| 178 | } | 190 | } |
| 179 | </section> | 191 | </section> |
| 180 | - <section class="sec"> | ||
| 181 | - <h2>(crate::pages::passkeys::s(lang, "Run now", "Şimdi çalıştır"))</h2> | ||
| 182 | - if let Some(line) = backup_running { | ||
| 183 | - <p class="state">(line)</p> | ||
| 184 | - } | ||
| 185 | - if let Some(line) = fsck_running { | ||
| 186 | - <p class="state">(line)</p> | ||
| 187 | - } | ||
| 188 | - <div class="acts"> | ||
| 189 | - <form id="run-backup" method="post" action="/admin/backups/run" class="act-form"> | ||
| 190 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 191 | - <button type="submit" class="act">(g::t(lang, K::RunBackupNow))</button> | ||
| 192 | - </form> | ||
| 193 | - post_act(label: g::t(lang, K::RunFsckNow), action: "/admin/backups/fsck", csrf: csrf.as_str()) | ||
| 194 | - </div> | ||
| 195 | - </section> | ||
| 196 | <section class="sec"> | 192 | <section class="sec"> |
| 197 | <h2>(g::t(lang, K::RecentRuns))</h2> | 193 | <h2>(g::t(lang, K::RecentRuns))</h2> |
| 198 | if rows.is_empty() { | 194 | if rows.is_empty() { |
crates/forge-web/src/pages/admin_health.rsmodified+68 -118
| @@ -1,8 +1,8 @@ | |||
| 1 | -//! Page: instance health for admins (`/admin/health`). A summary line, a storage topic with the data | 1 | +//! Page: instance health for admins (`/admin/health`). A summary line, then one sheet with the alerts, |
| 2 | -//! disk's usage bar, and a services topic. Every number is a cheap query or a short external probe | 2 | +//! a storage topic with the data disk's usage bar, and a services topic. Every number is a cheap query |
| 3 | -//! (`df`), so there is no polling; reloading the page, or opening it again, reads fresh values. The | 3 | +//! or a short external probe (`df`), so there is no polling; reloading the page, or opening it again, |
| 4 | -//! tree size of the repos (`du`) walks every repo, so a background task caches it (see | 4 | +//! reads fresh values. The tree size of the repos (`du`) walks every repo, so a background task caches |
| 5 | -//! [`spawn_repo_size`]) and the page only reads the cache. Non-admins get 404. | 5 | +//! it (see [`spawn_repo_size`]) and the page only reads the cache. Non-admins get 404. |
| 6 | 6 | ||
| 7 | use std::path::Path; | 7 | use std::path::Path; |
| 8 | use std::sync::Mutex; | 8 | use std::sync::Mutex; |
| @@ -19,16 +19,17 @@ use topcoat::router::response::Response; | |||
| 19 | use topcoat::router::{page, query_params, route}; | 19 | use topcoat::router::{page, query_params, route}; |
| 20 | use topcoat::view::{View, component, view}; | 20 | use topcoat::view::{View, component, view}; |
| 21 | 21 | ||
| 22 | -use crate::i18n::accounts::{A, duration_short, meta_line, needs_attention, on_disk, t as at}; | 22 | +use crate::i18n::accounts::{A, duration_short, duration_short_in, meta_line, needs_attention, on_disk, t as at}; |
| 23 | use crate::i18n::alerts as alert_text; | 23 | use crate::i18n::alerts as alert_text; |
| 24 | use crate::i18n::{self, Lang}; | 24 | use crate::i18n::{self, Lang}; |
| 25 | use crate::live::{Topic, stream_changes}; | 25 | use crate::live::{Topic, stream_changes}; |
| 26 | use crate::pages::admin_users::admin_only; | 26 | use crate::pages::admin_users::admin_only; |
| 27 | use crate::state::AppState; | 27 | use crate::state::AppState; |
| 28 | +use crate::views::parts::{SubPart, head}; | ||
| 28 | use crate::views::repo_list::{PageLink, pager, pager_links}; | 29 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 29 | use crate::views::{human_size, now_unix, rel_time, shell}; | 30 | use crate::views::{human_size, now_unix, rel_time, shell}; |
| 30 | 31 | ||
| 31 | -/// Active alerts per page of the alerts card. Each row is about 56px tall, so three keep the card | 32 | +/// Active alerts per page of the alerts topic. Each row is about 56px tall, so three keep the sheet |
| 32 | /// short enough to fit the window. | 33 | /// short enough to fit the window. |
| 33 | const ALERTS_PER_PAGE: usize = 3; | 34 | const ALERTS_PER_PAGE: usize = 3; |
| 34 | 35 | ||
| @@ -81,59 +82,17 @@ struct Usage { | |||
| 81 | bad: bool, | 82 | bad: bool, |
| 82 | } | 83 | } |
| 83 | 84 | ||
| 84 | -/// The icon a status row shows. | 85 | +/// One fact in the storage topic: one row. |
| 85 | -#[derive(Clone, Copy)] | ||
| 86 | -enum Glyph { | ||
| 87 | - Database, | ||
| 88 | - Folder, | ||
| 89 | - Archive, | ||
| 90 | - Queue, | ||
| 91 | - Mail, | ||
| 92 | - Clock, | ||
| 93 | - Sync, | ||
| 94 | -} | ||
| 95 | - | ||
| 96 | -/// The row icon for one glyph: a 24 grid stroke icon, 20px. | ||
| 97 | -#[component] | ||
| 98 | -async fn glyph(kind: Glyph) -> Result<impl View> { | ||
| 99 | - Ok(view! { | ||
| 100 | - if matches!(kind, Glyph::Database) { | ||
| 101 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><ellipse cx="12" cy="6" rx="8" ry="3"/><path d="M4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6"/><path d="M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3"/></svg> | ||
| 102 | - } | ||
| 103 | - if matches!(kind, Glyph::Folder) { | ||
| 104 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg> | ||
| 105 | - } | ||
| 106 | - if matches!(kind, Glyph::Archive) { | ||
| 107 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="5" rx="1"/><path d="M5 9v10h14V9M10 13h4"/></svg> | ||
| 108 | - } | ||
| 109 | - if matches!(kind, Glyph::Queue) { | ||
| 110 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01"/></svg> | ||
| 111 | - } | ||
| 112 | - if matches!(kind, Glyph::Mail) { | ||
| 113 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/></svg> | ||
| 114 | - } | ||
| 115 | - if matches!(kind, Glyph::Clock) { | ||
| 116 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg> | ||
| 117 | - } | ||
| 118 | - if matches!(kind, Glyph::Sync) { | ||
| 119 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h13l-3-3M20 17H7l3 3"/></svg> | ||
| 120 | - } | ||
| 121 | - }) | ||
| 122 | -} | ||
| 123 | - | ||
| 124 | -/// One fact in the storage pane: one row. | ||
| 125 | struct Fact { | 86 | struct Fact { |
| 126 | label: &'static str, | 87 | label: &'static str, |
| 127 | - glyph: Glyph, | ||
| 128 | value: String, | 88 | value: String, |
| 129 | detail: String, | 89 | detail: String, |
| 130 | dot: Dot, | 90 | dot: Dot, |
| 131 | } | 91 | } |
| 132 | 92 | ||
| 133 | -/// One row of the services pane. | 93 | +/// One row of the services topic. |
| 134 | struct Service { | 94 | struct Service { |
| 135 | label: &'static str, | 95 | label: &'static str, |
| 136 | - glyph: Glyph, | ||
| 137 | dot: Dot, | 96 | dot: Dot, |
| 138 | value: String, | 97 | value: String, |
| 139 | detail: String, | 98 | detail: String, |
| @@ -300,7 +259,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 300 | 259 | ||
| 301 | let mut facts = vec![Fact { | 260 | let mut facts = vec![Fact { |
| 302 | label: at(lang, A::DatabaseFile), | 261 | label: at(lang, A::DatabaseFile), |
| 303 | - glyph: Glyph::Database, | ||
| 304 | value: db_bytes.map_or_else( | 262 | value: db_bytes.map_or_else( |
| 305 | || at(lang, A::Unavailable).to_owned(), | 263 | || at(lang, A::Unavailable).to_owned(), |
| 306 | |b| human_size(lang, b), | 264 | |b| human_size(lang, b), |
| @@ -310,7 +268,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 310 | }]; | 268 | }]; |
| 311 | facts.push(Fact { | 269 | facts.push(Fact { |
| 312 | label: at(lang, A::Repositories), | 270 | label: at(lang, A::Repositories), |
| 313 | - glyph: Glyph::Folder, | ||
| 314 | value: counts.repos.to_string(), | 271 | value: counts.repos.to_string(), |
| 315 | detail: match repo_bytes { | 272 | detail: match repo_bytes { |
| 316 | Some(b) => on_disk(lang, &human_size(lang, b)), | 273 | Some(b) => on_disk(lang, &human_size(lang, b)), |
| @@ -325,7 +282,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 325 | let (pct, text) = space(lang, total, avail); | 282 | let (pct, text) = space(lang, total, avail); |
| 326 | Fact { | 283 | Fact { |
| 327 | label: at(lang, A::BackupDirectory), | 284 | label: at(lang, A::BackupDirectory), |
| 328 | - glyph: Glyph::Archive, | ||
| 329 | value: text, | 285 | value: text, |
| 330 | detail: backup, | 286 | detail: backup, |
| 331 | dot: if pct >= 90 { Dot::Bad } else { Dot::Neutral }, | 287 | dot: if pct >= 90 { Dot::Bad } else { Dot::Neutral }, |
| @@ -333,7 +289,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 333 | } | 289 | } |
| 334 | None => Fact { | 290 | None => Fact { |
| 335 | label: at(lang, A::BackupDirectory), | 291 | label: at(lang, A::BackupDirectory), |
| 336 | - glyph: Glyph::Archive, | ||
| 337 | value: at(lang, A::Unavailable).to_owned(), | 292 | value: at(lang, A::Unavailable).to_owned(), |
| 338 | detail: backup, | 293 | detail: backup, |
| 339 | dot: Dot::Neutral, | 294 | dot: Dot::Neutral, |
| @@ -342,7 +297,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 342 | } else { | 297 | } else { |
| 343 | Fact { | 298 | Fact { |
| 344 | label: at(lang, A::BackupDirectory), | 299 | label: at(lang, A::BackupDirectory), |
| 345 | - glyph: Glyph::Archive, | ||
| 346 | value: at(lang, A::NotConfigured).to_owned(), | 300 | value: at(lang, A::NotConfigured).to_owned(), |
| 347 | detail: String::new(), | 301 | detail: String::new(), |
| 348 | dot: Dot::Off, | 302 | dot: Dot::Off, |
| @@ -352,7 +306,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 352 | let mut services = vec![ | 306 | let mut services = vec![ |
| 353 | Service { | 307 | Service { |
| 354 | label: at(lang, A::CiQueue), | 308 | label: at(lang, A::CiQueue), |
| 355 | - glyph: Glyph::Queue, | ||
| 356 | dot: Dot::Neutral, | 309 | dot: Dot::Neutral, |
| 357 | value: format!("{} {}", counts.queued_jobs, at(lang, A::QueuedJobs)), | 310 | value: format!("{} {}", counts.queued_jobs, at(lang, A::QueuedJobs)), |
| 358 | detail: format!( | 311 | detail: format!( |
| @@ -365,7 +318,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 365 | }, | 318 | }, |
| 366 | Service { | 319 | Service { |
| 367 | label: at(lang, A::MailQueue), | 320 | label: at(lang, A::MailQueue), |
| 368 | - glyph: Glyph::Mail, | ||
| 369 | dot: if failed > 0 { Dot::Bad } else { Dot::Neutral }, | 321 | dot: if failed > 0 { Dot::Bad } else { Dot::Neutral }, |
| 370 | value: format!("{pending} {}", at(lang, A::Pending)), | 322 | value: format!("{pending} {}", at(lang, A::Pending)), |
| 371 | detail: format!("{failed} {}", at(lang, A::Failed)), | 323 | detail: format!("{failed} {}", at(lang, A::Failed)), |
| @@ -387,7 +339,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 387 | }; | 339 | }; |
| 388 | Service { | 340 | Service { |
| 389 | label: at(lang, A::LastBackup), | 341 | label: at(lang, A::LastBackup), |
| 390 | - glyph: Glyph::Clock, | ||
| 391 | dot, | 342 | dot, |
| 392 | value: value.to_owned(), | 343 | value: value.to_owned(), |
| 393 | detail: String::new(), | 344 | detail: String::new(), |
| @@ -396,7 +347,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 396 | } | 347 | } |
| 397 | None if backup_on => Service { | 348 | None if backup_on => Service { |
| 398 | label: at(lang, A::LastBackup), | 349 | label: at(lang, A::LastBackup), |
| 399 | - glyph: Glyph::Clock, | ||
| 400 | dot: Dot::Neutral, | 350 | dot: Dot::Neutral, |
| 401 | value: at(lang, A::Never).to_owned(), | 351 | value: at(lang, A::Never).to_owned(), |
| 402 | detail: String::new(), | 352 | detail: String::new(), |
| @@ -404,7 +354,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 404 | }, | 354 | }, |
| 405 | None => Service { | 355 | None => Service { |
| 406 | label: at(lang, A::LastBackup), | 356 | label: at(lang, A::LastBackup), |
| 407 | - glyph: Glyph::Clock, | ||
| 408 | dot: Dot::Off, | 357 | dot: Dot::Off, |
| 409 | value: at(lang, A::NotConfigured).to_owned(), | 358 | value: at(lang, A::NotConfigured).to_owned(), |
| 410 | detail: String::new(), | 359 | detail: String::new(), |
| @@ -429,7 +378,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 429 | }; | 378 | }; |
| 430 | Service { | 379 | Service { |
| 431 | label: at(lang, A::Replication), | 380 | label: at(lang, A::Replication), |
| 432 | - glyph: Glyph::Sync, | ||
| 433 | dot, | 381 | dot, |
| 434 | value: value.to_owned(), | 382 | value: value.to_owned(), |
| 435 | detail: if ok_unix.is_some() { | 383 | detail: if ok_unix.is_some() { |
| @@ -442,7 +390,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 442 | } | 390 | } |
| 443 | None => Service { | 391 | None => Service { |
| 444 | label: at(lang, A::Replication), | 392 | label: at(lang, A::Replication), |
| 445 | - glyph: Glyph::Sync, | ||
| 446 | dot: Dot::Neutral, | 393 | dot: Dot::Neutral, |
| 447 | value: at(lang, A::Never).to_owned(), | 394 | value: at(lang, A::Never).to_owned(), |
| 448 | detail: String::new(), | 395 | detail: String::new(), |
| @@ -452,7 +399,6 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 452 | } else { | 399 | } else { |
| 453 | Service { | 400 | Service { |
| 454 | label: at(lang, A::Replication), | 401 | label: at(lang, A::Replication), |
| 455 | - glyph: Glyph::Sync, | ||
| 456 | dot: Dot::Off, | 402 | dot: Dot::Off, |
| 457 | value: at(lang, A::NotConfigured).to_owned(), | 403 | value: at(lang, A::NotConfigured).to_owned(), |
| 458 | detail: String::new(), | 404 | detail: String::new(), |
| @@ -460,7 +406,10 @@ async fn gather(state: &AppState, lang: Lang) -> Result<Health> { | |||
| 460 | } | 406 | } |
| 461 | }); | 407 | }); |
| 462 | 408 | ||
| 463 | - let uptime = uptime_secs().map_or_else(|| at(lang, A::Unavailable).to_owned(), duration_short); | 409 | + let uptime = uptime_secs().map_or_else( |
| 410 | + || at(lang, A::Unavailable).to_owned(), | ||
| 411 | + |secs| duration_short_in(lang, secs), | ||
| 412 | + ); | ||
| 464 | let build = format!( | 413 | let build = format!( |
| 465 | "{}{}", | 414 | "{}{}", |
| 466 | forge_ci::build::commit(), | 415 | forge_ci::build::commit(), |
| @@ -535,7 +484,7 @@ async fn health_view( | |||
| 535 | pages: u64, | 484 | pages: u64, |
| 536 | nav: (Vec<PageLink>, Option<String>, Option<String>), | 485 | nav: (Vec<PageLink>, Option<String>, Option<String>), |
| 537 | ) -> Result<impl View> { | 486 | ) -> Result<impl View> { |
| 538 | - // The heading counts every active alert; the card lists the current page of them. | 487 | + // The heading counts every active alert; the sheet lists the current page of them. |
| 539 | let count = total; | 488 | let count = total; |
| 540 | let (links, prev, next) = nav; | 489 | let (links, prev, next) = nav; |
| 541 | let Health { | 490 | let Health { |
| @@ -545,6 +494,8 @@ async fn health_view( | |||
| 545 | meta, | 494 | meta, |
| 546 | attention, | 495 | attention, |
| 547 | } = health; | 496 | } = health; |
| 497 | + // An active alert needs attention as much as a failing service does. | ||
| 498 | + let attention = attention + count; | ||
| 548 | let summary_dot = if attention > 0 { Dot::Bad } else { Dot::Ok }; | 499 | let summary_dot = if attention > 0 { Dot::Bad } else { Dot::Ok }; |
| 549 | let summary = if attention > 0 { | 500 | let summary = if attention > 0 { |
| 550 | needs_attention(lang, attention) | 501 | needs_attention(lang, attention) |
| @@ -552,68 +503,67 @@ async fn health_view( | |||
| 552 | at(lang, A::Fine).to_owned() | 503 | at(lang, A::Fine).to_owned() |
| 553 | }; | 504 | }; |
| 554 | Ok(view! { | 505 | Ok(view! { |
| 555 | - <div data-live="/admin/health/events" class="health-page"> | 506 | + head(title: at(lang, A::Health), sub: vec![SubPart::text(at(lang, A::HealthIntro))], live: Some("/admin/health/events")) |
| 556 | - <h1 class="sr-only">(at(lang, A::Health))</h1> | ||
| 557 | <p class="state"> | 507 | <p class="state"> |
| 558 | <span class=(format!("health-dot {}", summary_dot.class()))></span> | 508 | <span class=(format!("health-dot {}", summary_dot.class()))></span> |
| 559 | " " (summary) | 509 | " " (summary) |
| 560 | </p> | 510 | </p> |
| 561 | - <p class="hint">(at(lang, A::HealthIntro))</p> | 511 | + <div class="sheet"> |
| 562 | - if count > 0 { | 512 | + if count > 0 { |
| 563 | - <section class="sec" role="alert"> | 513 | + <section class="sec" role="alert"> |
| 564 | - <h2>(alert_text::banner_heading(lang, count))</h2> | 514 | + <h2>(alert_text::banner_heading(lang, count))</h2> |
| 565 | - for a in alerts.into_iter() { | 515 | + for a in alerts.into_iter() { |
| 516 | + <div class="line" data-kb-row=""> | ||
| 517 | + <span class="name">(a.title.as_str())</span> | ||
| 518 | + <span class="val">since_line(lang: lang, stamp: a.stamp.as_str())</span> | ||
| 519 | + </div> | ||
| 520 | + if !a.body.is_empty() { | ||
| 521 | + <p class="hint">(a.body.as_str())</p> | ||
| 522 | + } | ||
| 523 | + } | ||
| 524 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | ||
| 525 | + <div class="acts"> | ||
| 526 | + <a class="act" href="/admin/server?tab=alerts">(alert_text::settings_link(lang))</a> | ||
| 527 | + </div> | ||
| 528 | + </section> | ||
| 529 | + } | ||
| 530 | + <section class="sec"> | ||
| 531 | + <h2>(at(lang, A::Storage))</h2> | ||
| 532 | + if let Some(u) = usage { | ||
| 533 | + <p class="state"><strong>(u.used.as_str())</strong> " " (at(lang, A::DiskUsed)) " · " (u.free_of_total.as_str())</p> | ||
| 534 | + <progress class=(if u.bad { "meter bad" } else { "meter" }) max="100" value=(u.pct.to_string())></progress> | ||
| 535 | + <p class="hint health-path">(u.path.as_str())</p> | ||
| 536 | + } else { | ||
| 537 | + <p class="state">(at(lang, A::Unavailable))</p> | ||
| 538 | + } | ||
| 539 | + for f in facts.into_iter() { | ||
| 566 | <div class="line" data-kb-row=""> | 540 | <div class="line" data-kb-row=""> |
| 567 | - <span class="name">(a.title.as_str())</span> | 541 | + <span class="name">(f.label)</span> |
| 568 | - <span class="val">since_line(lang: lang, stamp: a.stamp.as_str())</span> | 542 | + <span class=(format!("val {}", f.dot.value_class()))>(f.value.as_str())</span> |
| 569 | </div> | 543 | </div> |
| 570 | - if !a.body.is_empty() { | 544 | + if !f.detail.is_empty() { |
| 571 | - <p class="hint">(a.body.as_str())</p> | 545 | + <p class="hint health-path">(f.detail.as_str())</p> |
| 572 | } | 546 | } |
| 573 | } | 547 | } |
| 574 | - pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | 548 | + <p class="hint">(meta.as_str())</p> |
| 575 | - <div class="acts"> | ||
| 576 | - <a class="act" href="/admin/server?tab=alerts">(alert_text::settings_link(lang))</a> | ||
| 577 | - </div> | ||
| 578 | </section> | 549 | </section> |
| 579 | - } | 550 | + <section class="sec"> |
| 580 | - <section class="sec"> | 551 | + <h2>(at(lang, A::Services))</h2> |
| 581 | - <h2>(at(lang, A::Storage))</h2> | 552 | + for s in services.into_iter() { |
| 582 | - if let Some(u) = usage { | 553 | + <div class="line" data-kb-row=""> |
| 583 | - <p class="state"><strong>(u.used.as_str())</strong> " " (at(lang, A::DiskUsed)) " · " (u.free_of_total.as_str())</p> | 554 | + <span class="name">(s.label)</span> |
| 584 | - <progress class=(if u.bad { "meter bad" } else { "meter" }) max="100" value=(u.pct.to_string())></progress> | 555 | + <span class="val"> |
| 585 | - <p class="hint health-path">(u.path.as_str())</p> | 556 | + <span class=(format!("health-dot {}", s.dot.class()))></span> <span class=(s.dot.value_class())>(s.value.as_str())</span> |
| 586 | - } else { | 557 | + if !s.detail.is_empty() { |
| 587 | - <p class="state">(at(lang, A::Unavailable))</p> | 558 | + " · " (s.detail.as_str()) |
| 588 | - } | 559 | + } |
| 589 | - for f in facts.into_iter() { | 560 | + if let Some(stamp) = s.stamp.as_deref() { |
| 590 | - <div class="line" data-kb-row=""> | 561 | + " · " rel_time(lang: lang, stamp: stamp) |
| 591 | - <span class="name">glyph(kind: f.glyph) (f.label)</span> | 562 | + } |
| 592 | - <span class=(format!("val {}", f.dot.value_class()))>(f.value.as_str())</span> | 563 | + </span> |
| 593 | - </div> | 564 | + </div> |
| 594 | - if !f.detail.is_empty() { | ||
| 595 | - <p class="hint health-path">(f.detail.as_str())</p> | ||
| 596 | } | 565 | } |
| 597 | - } | 566 | + </section> |
| 598 | - <p class="hint">(meta.as_str())</p> | ||
| 599 | - </section> | ||
| 600 | - <section class="sec"> | ||
| 601 | - <h2>(at(lang, A::Services))</h2> | ||
| 602 | - for s in services.into_iter() { | ||
| 603 | - <div class="line" data-kb-row=""> | ||
| 604 | - <span class="name">glyph(kind: s.glyph) (s.label)</span> | ||
| 605 | - <span class="val"> | ||
| 606 | - <span class=(format!("health-dot {}", s.dot.class()))></span> <span class=(s.dot.value_class())>(s.value.as_str())</span> | ||
| 607 | - if !s.detail.is_empty() { | ||
| 608 | - " · " (s.detail.as_str()) | ||
| 609 | - } | ||
| 610 | - if let Some(stamp) = s.stamp.as_deref() { | ||
| 611 | - " · " rel_time(lang: lang, stamp: stamp) | ||
| 612 | - } | ||
| 613 | - </span> | ||
| 614 | - </div> | ||
| 615 | - } | ||
| 616 | - </section> | ||
| 617 | </div> | 567 | </div> |
| 618 | }) | 568 | }) |
| 619 | } | 569 | } |
crates/forge-web/src/pages/admin_mail.rsmodified+15 -15
| @@ -33,7 +33,7 @@ use crate::mail::{enqueue, live, templates}; | |||
| 33 | use crate::pages::admin_users::admin_only; | 33 | use crate::pages::admin_users::admin_only; |
| 34 | use crate::pages::ci_runs::{changed_event, events_response}; | 34 | use crate::pages::ci_runs::{changed_event, events_response}; |
| 35 | use crate::state::AppState; | 35 | use crate::state::AppState; |
| 36 | -use crate::views::parts::{confirm_act, post_act}; | 36 | +use crate::views::parts::{SubPart, confirm_act, head, post_act}; |
| 37 | use crate::views::{enc, rel_time, shell}; | 37 | use crate::views::{enc, rel_time, shell}; |
| 38 | 38 | ||
| 39 | /// Rows shown in the queue at most. | 39 | /// Rows shown in the queue at most. |
| @@ -218,20 +218,20 @@ async fn mail_view( | |||
| 218 | .as_ref() | 218 | .as_ref() |
| 219 | .map(|q| q.filter_param.clone()) | 219 | .map(|q| q.filter_param.clone()) |
| 220 | .unwrap_or_default(); | 220 | .unwrap_or_default(); |
| 221 | + let sub = vec![SubPart::text(g::t(lang, K::MailIntro))]; | ||
| 221 | Ok(view! { | 222 | Ok(view! { |
| 222 | - <h1 class="sr-only">(g::t(lang, K::Mail))</h1> | 223 | + head(title: g::t(lang, K::Mail), sub: sub) |
| 223 | - <nav class="sub" aria-label=(g::t(lang, K::Mail))> | ||
| 224 | - <a href="/admin/mail" aria-current=(settings_on.then_some("page"))>(g::t(lang, K::MailTabSettings))</a> | ||
| 225 | - <a href="/admin/mail?tab=queue" aria-current=((!settings_on).then_some("page"))>(g::t(lang, K::MailTabQueue))</a> | ||
| 226 | - </nav> | ||
| 227 | - <p class="hint">(g::t(lang, K::MailIntro))</p> | ||
| 228 | if let Some(message) = notice { | 224 | if let Some(message) = notice { |
| 229 | <p class="state" role="status">(message.as_str())</p> | 225 | <p class="state" role="status">(message.as_str())</p> |
| 230 | } | 226 | } |
| 227 | + <nav class="tabs" aria-label=(g::t(lang, K::Mail))> | ||
| 228 | + <a href="/admin/mail" aria-current=(settings_on.then_some("page"))>(g::t(lang, K::MailTabSettings))</a> | ||
| 229 | + <a href="/admin/mail?tab=queue" aria-current=((!settings_on).then_some("page"))>(g::t(lang, K::MailTabQueue))</a> | ||
| 230 | + </nav> | ||
| 231 | if settings_on { | 231 | if settings_on { |
| 232 | // Saved by any admin session: the stream re-renders the settings with the same signal | 232 | // Saved by any admin session: the stream re-renders the settings with the same signal |
| 233 | // as the queue (the save bumps it too), and the form keeps what was typed. | 233 | // as the queue (the save bumps it too), and the form keeps what was typed. |
| 234 | - <div data-live="/admin/mail/events"> | 234 | + <div class="sheet" data-live="/admin/mail/events"> |
| 235 | <form method="post" action="/admin/mail"> | 235 | <form method="post" action="/admin/mail"> |
| 236 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 236 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 237 | <section class="sec" id="smtp"> | 237 | <section class="sec" id="smtp"> |
| @@ -293,13 +293,13 @@ async fn mail_view( | |||
| 293 | </form> | 293 | </form> |
| 294 | </div> | 294 | </div> |
| 295 | } else if let Some(queue) = data.queue { | 295 | } else if let Some(queue) = data.queue { |
| 296 | - <nav class="sub" aria-label=(g::t(lang, K::MailTabQueue))> | 296 | + <div class="sheet" data-live="/admin/mail/events"> |
| 297 | - for chip in queue.chips.into_iter() { | 297 | + <div class="sheet-tools"> |
| 298 | - <a href=(chip.href.as_str()) aria-current=(chip.current.then_some("page"))>(chip.label) " (" (chip.count) ")"</a> | 298 | + for chip in queue.chips.into_iter() { |
| 299 | - } | 299 | + <a class="act" href=(chip.href.as_str()) aria-current=(chip.current.then_some("page"))>(chip.label) " (" (chip.count) ")"</a> |
| 300 | - </nav> | 300 | + } |
| 301 | - <p class="hint">(g::t(lang, K::MailQueueIntro))</p> | 301 | + </div> |
| 302 | - <div data-live="/admin/mail/events"> | 302 | + <p class="hint">(g::t(lang, K::MailQueueIntro))</p> |
| 303 | if queue.rows.is_empty() { | 303 | if queue.rows.is_empty() { |
| 304 | if queue.filter_param.is_empty() { | 304 | if queue.filter_param.is_empty() { |
| 305 | <p class="state">(g::t(lang, K::MailQueueEmpty))</p> | 305 | <p class="state">(g::t(lang, K::MailQueueEmpty))</p> |
crates/forge-web/src/pages/admin_replication.rsmodified+6 -10
| @@ -27,7 +27,7 @@ use crate::i18n::{self, Lang}; | |||
| 27 | use crate::live::{Topic, stream_changes}; | 27 | use crate::live::{Topic, stream_changes}; |
| 28 | use crate::pages::admin_users::admin_only; | 28 | use crate::pages::admin_users::admin_only; |
| 29 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| 30 | -use crate::views::parts::post_act; | 30 | +use crate::views::parts::{SubPart, head, post_act}; |
| 31 | use crate::views::{enc, rel_time_or_never, shell}; | 31 | use crate::views::{enc, rel_time_or_never, shell}; |
| 32 | 32 | ||
| 33 | #[query_params(error = bad_request)] | 33 | #[query_params(error = bad_request)] |
| @@ -188,13 +188,15 @@ async fn replication_view( | |||
| 188 | data: PageData, | 188 | data: PageData, |
| 189 | notice: Option<String>, | 189 | notice: Option<String>, |
| 190 | ) -> Result<impl View> { | 190 | ) -> Result<impl View> { |
| 191 | + let sub = vec![SubPart::text(g::t(lang, K::ReplicationIntro))]; | ||
| 191 | Ok(view! { | 192 | Ok(view! { |
| 192 | - <div data-live="/admin/replication/events"> | 193 | + head(title: g::t(lang, K::Replication), sub: sub, |
| 193 | - <h1 class="sr-only">(g::t(lang, K::Replication))</h1> | 194 | + post_act(label: g::t(lang, K::ReconcileNow), action: "/admin/replication/reconcile", csrf: csrf.as_str()) |
| 194 | - <p class="hint">(g::t(lang, K::ReplicationIntro))</p> | 195 | + ) |
| 195 | if let Some(message) = notice { | 196 | if let Some(message) = notice { |
| 196 | <p class="state" role="status">(message.as_str())</p> | 197 | <p class="state" role="status">(message.as_str())</p> |
| 197 | } | 198 | } |
| 199 | + <div class="sheet" data-live="/admin/replication/events"> | ||
| 198 | if data.enabled { | 200 | if data.enabled { |
| 199 | <section class="sec"> | 201 | <section class="sec"> |
| 200 | <h2>(crate::pages::passkeys::s(lang, "Target and schedule", "Hedef ve zamanlama"))</h2> | 202 | <h2>(crate::pages::passkeys::s(lang, "Target and schedule", "Hedef ve zamanlama"))</h2> |
| @@ -235,12 +237,6 @@ async fn replication_view( | |||
| 235 | <p class="state">(g::t(lang, K::ReplicationOff))</p> | 237 | <p class="state">(g::t(lang, K::ReplicationOff))</p> |
| 236 | </section> | 238 | </section> |
| 237 | } | 239 | } |
| 238 | - <section class="sec"> | ||
| 239 | - <h2>(g::t(lang, K::Standby))</h2> | ||
| 240 | - <div class="acts"> | ||
| 241 | - post_act(label: g::t(lang, K::ReconcileNow), action: "/admin/replication/reconcile", csrf: csrf.as_str()) | ||
| 242 | - </div> | ||
| 243 | - </section> | ||
| 244 | <section class="sec"> | 240 | <section class="sec"> |
| 245 | <h2>(g::t(lang, K::Repos))</h2> | 241 | <h2>(g::t(lang, K::Repos))</h2> |
| 246 | if data.repos.is_empty() { | 242 | if data.repos.is_empty() { |
crates/forge-web/src/pages/admin_runners.rsmodified+198 -316
| @@ -36,13 +36,13 @@ use crate::pages::admin_users::admin_only; | |||
| 36 | use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; | 36 | use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; |
| 37 | use crate::pages::repo_mirrors::stamp_in_tz; | 37 | use crate::pages::repo_mirrors::stamp_in_tz; |
| 38 | use crate::state::AppState; | 38 | use crate::state::AppState; |
| 39 | -use crate::views::parts::{confirm_act, post_act, reveal}; | 39 | +use crate::views::parts::{SubPart, confirm_act, head, post_act, reveal}; |
| 40 | use crate::views::repo_list::{PageLink, pager, pager_links}; | 40 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 41 | use crate::views::{alert, enc, now_unix, relative_time, shell}; | 41 | use crate::views::{alert, enc, now_unix, relative_time, shell}; |
| 42 | 42 | ||
| 43 | path_param!(runner_id); | 43 | path_param!(runner_id); |
| 44 | 44 | ||
| 45 | -/// Runners per page on the list. Six rows fit the window beside the "Add a runner" card. | 45 | +/// Runners per page on the list. |
| 46 | const PER_PAGE: usize = 6; | 46 | const PER_PAGE: usize = 6; |
| 47 | 47 | ||
| 48 | /// The list's query: the page, and the notice word that a paging link keeps. | 48 | /// The list's query: the page, and the notice word that a paging link keeps. |
| @@ -179,11 +179,8 @@ struct RunnerRow { | |||
| 179 | can_restart: bool, | 179 | can_restart: bool, |
| 180 | /// A restart that was asked for and has not happened yet. | 180 | /// A restart that was asked for and has not happened yet. |
| 181 | restart_pending: Option<RestartMode>, | 181 | restart_pending: Option<RestartMode>, |
| 182 | - /// The concurrency shown in the input: the admin's override, else what the runner reports. | 182 | + /// The concurrency: the admin's override, else what the runner reports. Empty when neither. |
| 183 | concurrency: String, | 183 | concurrency: String, |
| 184 | - /// "UI", "runner.toml" or empty when the runner has not reported. | ||
| 185 | - concurrency_source: &'static str, | ||
| 186 | - has_override: bool, | ||
| 187 | running: u32, | 184 | running: u32, |
| 188 | /// The build the runner reported, or empty for an older runner. | 185 | /// The build the runner reported, or empty for an older runner. |
| 189 | build: String, | 186 | build: String, |
| @@ -192,24 +189,16 @@ struct RunnerRow { | |||
| 192 | /// "up to date", "outdated" or "unknown", with the `.ci-state` class the detail page colours it with. | 189 | /// "up to date", "outdated" or "unknown", with the `.ci-state` class the detail page colours it with. |
| 193 | build_label: &'static str, | 190 | build_label: &'static str, |
| 194 | build_class: &'static str, | 191 | build_class: &'static str, |
| 195 | - /// "ok", "warn" or "muted": how the version status is coloured on the list. | 192 | + /// What it is doing now, and restart pending when that applies, joined with " · ". |
| 196 | - build_tone: &'static str, | ||
| 197 | - /// The concurrency the admin set or the runner reported, for the load meter's maximum. | ||
| 198 | - /// Empty when the runner has not reported one. | ||
| 199 | - concurrency_max: u32, | ||
| 200 | - /// What it is doing now, then disabled and restart-pending when they apply, joined with " · ". | ||
| 201 | status: String, | 193 | status: String, |
| 202 | - /// The id of the concurrency input, unique per runner on the list. | ||
| 203 | - field_id: String, | ||
| 204 | } | 194 | } |
| 205 | 195 | ||
| 206 | -/// How the runner's reported build compares with this server's: the label, the `.ci-state` class | 196 | +/// How the runner's reported build compares with this server's: the label and the `.ci-state` class. |
| 207 | -/// and the list tone. | 197 | +fn build_badge(lang: Lang, runner: &CiRunner) -> (&'static str, &'static str) { |
| 208 | -fn build_badge(lang: Lang, runner: &CiRunner) -> (&'static str, &'static str, &'static str) { | ||
| 209 | match build::compare(runner.reported.build.as_deref(), &build::display()) { | 198 | match build::compare(runner.reported.build.as_deref(), &build::display()) { |
| 210 | - Freshness::UpToDate => (s(lang, "up to date", "güncel"), "ci-success", "ok"), | 199 | + Freshness::UpToDate => (s(lang, "up to date", "güncel"), "ci-success"), |
| 211 | - Freshness::Outdated => (s(lang, "outdated", "eski"), "ci-queued", "warn"), | 200 | + Freshness::Outdated => (s(lang, "outdated", "eski"), "ci-queued"), |
| 212 | - Freshness::Unknown => (s(lang, "unknown", "bilinmiyor"), "runner-disabled", "muted"), | 201 | + Freshness::Unknown => (s(lang, "unknown", "bilinmiyor"), "runner-disabled"), |
| 213 | } | 202 | } |
| 214 | } | 203 | } |
| 215 | 204 | ||
| @@ -226,10 +215,10 @@ fn dot_of(lang: Lang, runner: &CiRunner, now: i64) -> (&'static str, &'static st | |||
| 226 | } | 215 | } |
| 227 | } | 216 | } |
| 228 | 217 | ||
| 229 | -/// The effective concurrency as a number to show, and where it comes from. | 218 | +/// The effective concurrency as a number to show. Empty when neither the admin nor the runner set one. |
| 230 | -fn concurrency_of(runner: &CiRunner) -> (String, &'static str) { | 219 | +fn concurrency_of(runner: &CiRunner) -> String { |
| 231 | if let Some(n) = runner.concurrency_override { | 220 | if let Some(n) = runner.concurrency_override { |
| 232 | - return (n.to_string(), "UI"); | 221 | + return n.to_string(); |
| 233 | } | 222 | } |
| 234 | let base = runner | 223 | let base = runner |
| 235 | .reported | 224 | .reported |
| @@ -242,10 +231,7 @@ fn concurrency_of(runner: &CiRunner) -> (String, &'static str) { | |||
| 242 | .and_then(|n| u32::try_from(n).ok()) | 231 | .and_then(|n| u32::try_from(n).ok()) |
| 243 | }) | 232 | }) |
| 244 | .map(|n| n.to_string()); | 233 | .map(|n| n.to_string()); |
| 245 | - match base { | 234 | + base.unwrap_or_default() |
| 246 | - Some(n) => (n, "runner.toml"), | ||
| 247 | - None => (String::new(), ""), | ||
| 248 | - } | ||
| 249 | } | 235 | } |
| 250 | 236 | ||
| 251 | fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { | 237 | fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { |
| @@ -260,10 +246,9 @@ fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { | |||
| 260 | } | 246 | } |
| 261 | None => (i18n::t(lang, Key::Never).to_owned(), String::new()), | 247 | None => (i18n::t(lang, Key::Never).to_owned(), String::new()), |
| 262 | }; | 248 | }; |
| 263 | - let (concurrency, concurrency_source) = concurrency_of(runner); | 249 | + let concurrency = concurrency_of(runner); |
| 264 | - let (build_label, build_class, build_tone) = build_badge(lang, runner); | 250 | + let (build_label, build_class) = build_badge(lang, runner); |
| 265 | let (dot_class, state_text) = dot_of(lang, runner, now); | 251 | let (dot_class, state_text) = dot_of(lang, runner, now); |
| 266 | - let concurrency_max = concurrency.parse().unwrap_or(0); | ||
| 267 | let doing = if runner.running_jobs == 0 { | 252 | let doing = if runner.running_jobs == 0 { |
| 268 | s(lang, "idle", "boşta").to_owned() | 253 | s(lang, "idle", "boşta").to_owned() |
| 269 | } else { | 254 | } else { |
| @@ -273,13 +258,9 @@ fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { | |||
| 273 | } | 258 | } |
| 274 | }; | 259 | }; |
| 275 | let mut parts = vec![doing]; | 260 | let mut parts = vec![doing]; |
| 276 | - if runner.disabled { | ||
| 277 | - parts.push(g::t(lang, K::Disabled).to_owned()); | ||
| 278 | - } | ||
| 279 | if runner.restart.is_some() { | 261 | if runner.restart.is_some() { |
| 280 | parts.push(s(lang, "restart pending", "yeniden başlatma bekliyor").to_owned()); | 262 | parts.push(s(lang, "restart pending", "yeniden başlatma bekliyor").to_owned()); |
| 281 | } | 263 | } |
| 282 | - let field_id = format!("conc-{}", enc(&runner.id)); | ||
| 283 | RunnerRow { | 264 | RunnerRow { |
| 284 | name: runner.name.clone(), | 265 | name: runner.name.clone(), |
| 285 | labels: runner.labels.join(" · "), | 266 | labels: runner.labels.join(" · "), |
| @@ -297,8 +278,6 @@ fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { | |||
| 297 | can_restart: runner.supports_restart(), | 278 | can_restart: runner.supports_restart(), |
| 298 | restart_pending: runner.restart.as_ref().map(|r| r.mode), | 279 | restart_pending: runner.restart.as_ref().map(|r| r.mode), |
| 299 | concurrency, | 280 | concurrency, |
| 300 | - concurrency_source, | ||
| 301 | - has_override: runner.concurrency_override.is_some(), | ||
| 302 | running: runner.running_jobs, | 281 | running: runner.running_jobs, |
| 303 | build_short: runner | 282 | build_short: runner |
| 304 | .reported | 283 | .reported |
| @@ -309,10 +288,7 @@ fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { | |||
| 309 | build: runner.reported.build.clone().unwrap_or_default(), | 288 | build: runner.reported.build.clone().unwrap_or_default(), |
| 310 | build_label, | 289 | build_label, |
| 311 | build_class, | 290 | build_class, |
| 312 | - build_tone, | ||
| 313 | - concurrency_max, | ||
| 314 | status: parts.join(" · "), | 291 | status: parts.join(" · "), |
| 315 | - field_id, | ||
| 316 | } | 292 | } |
| 317 | } | 293 | } |
| 318 | 294 | ||
| @@ -357,8 +333,12 @@ async fn runners_view( | |||
| 357 | ) -> Result<impl View> { | 333 | ) -> Result<impl View> { |
| 358 | let (links, prev, next) = nav; | 334 | let (links, prev, next) = nav; |
| 359 | Ok(view! { | 335 | Ok(view! { |
| 360 | - <div data-live="/admin/runners/events"> | 336 | + head(title: g::t(lang, K::CiRunners), live: Some("/admin/runners/events"), |
| 361 | - <h1 class="sr-only">(g::t(lang, K::CiRunners))</h1> | 337 | + <form method="post" action="/admin/runners/tokens"> |
| 338 | + <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 339 | + <button type="submit" class="primary">(g::t(lang, K::CreateRegistrationToken))</button> | ||
| 340 | + </form> | ||
| 341 | + ) | ||
| 362 | if let Some((text, is_error)) = notice { | 342 | if let Some((text, is_error)) = notice { |
| 363 | if is_error { | 343 | if is_error { |
| 364 | alert(message: text) | 344 | alert(message: text) |
| @@ -366,69 +346,33 @@ async fn runners_view( | |||
| 366 | <p class="state" role="status">(text)</p> | 346 | <p class="state" role="status">(text)</p> |
| 367 | } | 347 | } |
| 368 | } | 348 | } |
| 369 | - <section class="sec"> | 349 | + <div class="sheet"> |
| 370 | - <h2>(g::t(lang, K::AddARunner))</h2> | 350 | + <section class="sec"> |
| 371 | - if rows.is_empty() { | 351 | + if rows.is_empty() { |
| 372 | - <p class="state">(g::t(lang, K::NoRunnersYet))</p> | 352 | + <p class="state">(g::t(lang, K::NoRunnersYet))</p> |
| 373 | - } | 353 | + } |
| 374 | - <div class="acts"> | 354 | + for row in rows.iter() { |
| 375 | - reveal(label: g::t(lang, K::CreateRegistrationToken), id: Some("add-runner"), | 355 | + <a class="line" data-kb-row="" href=(row.detail_href.as_str())> |
| 376 | - <p class="hint">(note.as_str())</p> | ||
| 377 | - if rows.is_empty() { | ||
| 378 | - <p class="hint">(g::t(lang, K::RunnersEmptyHint))</p> | ||
| 379 | - <pre><code>"forge runner register --url <forge-url> --token <token> --name <name> --labels linux,x86_64"</code></pre> | ||
| 380 | - } | ||
| 381 | - <form method="post" action="/admin/runners/tokens" class="fields"> | ||
| 382 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 383 | - <button type="submit" class="primary">(g::t(lang, K::CreateRegistrationToken))</button> | ||
| 384 | - </form> | ||
| 385 | - ) | ||
| 386 | - </div> | ||
| 387 | - </section> | ||
| 388 | - <section class="sec"> | ||
| 389 | - for row in rows.iter() { | ||
| 390 | - <details class="row-open"> | ||
| 391 | - <summary class="line" data-kb-row=""> | ||
| 392 | - <span class=(row.dot_class) role="img" aria-label=(row.state_text) title=(row.state_text)></span> | ||
| 393 | <span class="name">(row.name.as_str())</span> | 356 | <span class="name">(row.name.as_str())</span> |
| 357 | + if !row.labels.is_empty() { | ||
| 358 | + <span class="val"><span class="runner-labels">(row.labels.as_str())</span></span> | ||
| 359 | + } | ||
| 360 | + <span class="val"><span class=(row.dot_class) role="img" aria-label=(row.state_text) title=(row.state_text)></span>" "(row.state_text)</span> | ||
| 394 | <span class="val">(row.status.as_str())</span> | 361 | <span class="val">(row.status.as_str())</span> |
| 395 | - </summary> | 362 | + </a> |
| 396 | - <div class="opened"> | 363 | + } |
| 397 | - <p class="hint"> | 364 | + if !rows.is_empty() { |
| 398 | - if !row.labels.is_empty() { | 365 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 399 | - <span class="runner-labels">(row.labels.as_str())</span> | 366 | + } |
| 400 | - " · " | 367 | + </section> |
| 401 | - } | 368 | + <section class="sec"> |
| 402 | - (s(lang, "seen", "görüldü"))" "<time data-rel="true" datetime=(row.last_seen_at.as_str()) title=(row.last_seen_full.as_str())>(row.last_seen.as_str())</time> | 369 | + <h2>(g::t(lang, K::AddARunner))</h2> |
| 403 | - </p> | 370 | + <p class="hint">(note.as_str())</p> |
| 404 | - <div class="runner-version" title=(row.build.as_str())> | 371 | + if rows.is_empty() { |
| 405 | - if !row.build_short.is_empty() { | 372 | + <p class="hint">(g::t(lang, K::RunnersEmptyHint))</p> |
| 406 | - <code class="runner-hash">(row.build_short.as_str())</code> | 373 | + <pre><code>"forge runner register --url <forge-url> --token <token> --name <name> --labels linux,x86_64"</code></pre> |
| 407 | - } | 374 | + } |
| 408 | - if row.build_tone == "ok" { | 375 | + </section> |
| 409 | - <span class="runner-status"><span class="runner-tick" aria-hidden="true">"✓"</span>" "(row.build_label)</span> | ||
| 410 | - } else { | ||
| 411 | - <span class=(format!("runner-status {}", row.build_tone))>(row.build_label)</span> | ||
| 412 | - } | ||
| 413 | - </div> | ||
| 414 | - concurrency_form(lang: lang, csrf: csrf.as_str(), action: row.config_action.as_str(), id: row.field_id.as_str(), key: "concurrency", value: row.concurrency.as_str(), source: row.concurrency_source, has_override: row.has_override, back: "list", running: row.running, max: row.concurrency_max) | ||
| 415 | - <div class="acts"> | ||
| 416 | - <a class="act" href=(row.detail_href.as_str())>(s(lang, "Open", "Aç"))</a> | ||
| 417 | - if row.disabled { | ||
| 418 | - post_act(label: g::t(lang, K::Enable), action: row.toggle_action.as_str(), csrf: csrf.as_str(), fields: vec![("disabled".to_owned(), "0".to_owned())]) | ||
| 419 | - } else { | ||
| 420 | - confirm_post(lang: lang, csrf: csrf.as_str(), action: row.toggle_action.as_str(), label: g::t(lang, K::Disable), message: disable_message(lang, row.name.as_str()), confirm: s(lang, "Yes, disable", "Evet, devre dışı bırak"), danger: false, fields: vec![("disabled", "1".into())]) | ||
| 421 | - } | ||
| 422 | - restart_control(lang: lang, csrf: csrf.as_str(), action: row.restart_action.as_str(), back: "list", can_restart: row.can_restart, pending: row.restart_pending) | ||
| 423 | - confirm_post(lang: lang, csrf: csrf.as_str(), action: row.delete_action.as_str(), label: i18n::t(lang, Key::Delete), message: delete_message(lang, row.name.as_str()), confirm: s(lang, "Yes, delete", "Evet, sil"), danger: true, fields: vec![]) | ||
| 424 | - </div> | ||
| 425 | - </div> | ||
| 426 | - </details> | ||
| 427 | - } | ||
| 428 | - if !rows.is_empty() { | ||
| 429 | - pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | ||
| 430 | - } | ||
| 431 | - </section> | ||
| 432 | </div> | 376 | </div> |
| 433 | }) | 377 | }) |
| 434 | } | 378 | } |
| @@ -443,7 +387,8 @@ fn list_href(page: u64, notice: &str) -> String { | |||
| 443 | } | 387 | } |
| 444 | } | 388 | } |
| 445 | 389 | ||
| 446 | -/// A text link that asks first, in place; the POST only fires from the confirm button. | 390 | +/// A text link that asks first, in place; the POST only fires from the confirm button. For actions |
| 391 | +/// that are not destructive, so the confirm button is soft. | ||
| 447 | #[component] | 392 | #[component] |
| 448 | pub(crate) async fn confirm_post( | 393 | pub(crate) async fn confirm_post( |
| 449 | lang: Lang, | 394 | lang: Lang, |
| @@ -452,12 +397,11 @@ pub(crate) async fn confirm_post( | |||
| 452 | label: &'static str, | 397 | label: &'static str, |
| 453 | message: String, | 398 | message: String, |
| 454 | confirm: &'static str, | 399 | confirm: &'static str, |
| 455 | - danger: bool, | ||
| 456 | fields: Vec<(&'static str, String)>, | 400 | fields: Vec<(&'static str, String)>, |
| 457 | ) -> Result<impl View> { | 401 | ) -> Result<impl View> { |
| 458 | Ok(view! { | 402 | Ok(view! { |
| 459 | <details class="reveal"> | 403 | <details class="reveal"> |
| 460 | - <summary class=(if danger { "act danger" } else { "act" })>(label)</summary> | 404 | + <summary class="act">(label)</summary> |
| 461 | <form class="opened" method="post" action=(action)> | 405 | <form class="opened" method="post" action=(action)> |
| 462 | <input type="hidden" name="csrf" value=(csrf)> | 406 | <input type="hidden" name="csrf" value=(csrf)> |
| 463 | for (name, value) in fields.iter() { | 407 | for (name, value) in fields.iter() { |
| @@ -465,25 +409,14 @@ pub(crate) async fn confirm_post( | |||
| 465 | } | 409 | } |
| 466 | <p class="hint">(message)</p> | 410 | <p class="hint">(message)</p> |
| 467 | <div class="acts"> | 411 | <div class="acts"> |
| 468 | - <button type="submit" class=(if danger { "act danger" } else { "act" })>(confirm)</button> | 412 | + <button type="submit" class="small">(confirm)</button> |
| 469 | - <button type="button" class="act quiet" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> | 413 | + <button type="button" class="act" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> |
| 470 | </div> | 414 | </div> |
| 471 | </form> | 415 | </form> |
| 472 | </details> | 416 | </details> |
| 473 | }) | 417 | }) |
| 474 | } | 418 | } |
| 475 | 419 | ||
| 476 | -/// The tooltip of the concurrency input: where the shown value comes from. | ||
| 477 | -fn source_title(lang: Lang, source: &str) -> String { | ||
| 478 | - match (source, lang) { | ||
| 479 | - ("", _) => String::new(), | ||
| 480 | - ("UI", Lang::Tr) => "Değer arayüzden ayarlandı".to_owned(), | ||
| 481 | - ("UI", _) => "Value set in the UI".to_owned(), | ||
| 482 | - (other, Lang::Tr) => format!("Değer {other} dosyasından"), | ||
| 483 | - (other, _) => format!("Value from {other}"), | ||
| 484 | - } | ||
| 485 | -} | ||
| 486 | - | ||
| 487 | fn delete_message(lang: Lang, name: &str) -> String { | 420 | fn delete_message(lang: Lang, name: &str) -> String { |
| 488 | match lang { | 421 | match lang { |
| 489 | Lang::Tr => format!("{name} silinsin mi? Makinenin sonrasında yeniden kaydolması gerekir."), | 422 | Lang::Tr => format!("{name} silinsin mi? Makinenin sonrasında yeniden kaydolması gerekir."), |
| @@ -512,19 +445,16 @@ async fn restart_control( | |||
| 512 | ) -> Result<impl View> { | 445 | ) -> Result<impl View> { |
| 513 | Ok(view! { | 446 | Ok(view! { |
| 514 | if pending.is_some() { | 447 | if pending.is_some() { |
| 515 | - <p class="state">(if pending == Some(RestartMode::Now) { s(lang, "Restarting now...", "Şimdi yeniden başlatılıyor...") } else { s(lang, "Restarting after the current jobs...", "Mevcut işlerden sonra yeniden başlatılıyor...") })</p> | 448 | + <p class="hint">(if pending == Some(RestartMode::Now) { s(lang, "Restarting now...", "Şimdi yeniden başlatılıyor...") } else { s(lang, "Restarting after the current jobs...", "Mevcut işlerden sonra yeniden başlatılıyor...") })</p> |
| 516 | } else if can_restart { | 449 | } else if can_restart { |
| 517 | - <details class="reveal"> | 450 | + reveal(label: s(lang, "Restart", "Yeniden başlat"), |
| 518 | - <summary class="act">(s(lang, "Restart", "Yeniden başlat"))</summary> | 451 | + <p class="hint">(s(lang, "Restart this runner? It stops taking new jobs first.", "Bu çalıştırıcı yeniden başlatılsın mı? Önce yeni iş almayı bırakır."))</p> |
| 519 | - <div class="opened"> | 452 | + <p class="hint">(s(lang, "The running jobs finish, then it restarts.", "Çalışan işler biter, sonra yeniden başlar."))</p> |
| 520 | - <p class="hint">(s(lang, "Restart this runner? It stops taking new jobs first.", "Bu çalıştırıcı yeniden başlatılsın mı? Önce yeni iş almayı bırakır."))</p> | 453 | + <div class="acts"> |
| 521 | - <p class="hint">(s(lang, "The running jobs finish, then it restarts.", "Çalışan işler biter, sonra yeniden başlar."))</p> | 454 | + post_act(label: s(lang, "Restart after current jobs", "Mevcut işlerden sonra yeniden başlat"), action: action, csrf: csrf, fields: vec![("mode".to_owned(), "drain".to_owned()), ("back".to_owned(), back.to_owned())]) |
| 522 | - <div class="acts"> | 455 | + confirm_act(lang: lang, label: s(lang, "Restart now", "Şimdi yeniden başlat"), action: action, csrf: csrf, fields: vec![("mode".to_owned(), "now".to_owned()), ("back".to_owned(), back.to_owned())], note: Some(s(lang, "The running jobs end as cancelled and can be run again.", "Çalışan işler iptal edilmiş olarak biter ve yeniden çalıştırılabilir.").to_owned())) |
| 523 | - post_act(label: s(lang, "Restart after current jobs", "Mevcut işlerden sonra yeniden başlat"), action: action, csrf: csrf, fields: vec![("mode".to_owned(), "drain".to_owned()), ("back".to_owned(), back.to_owned())]) | ||
| 524 | - confirm_act(lang: lang, label: s(lang, "Restart now", "Şimdi yeniden başlat"), action: action, csrf: csrf, fields: vec![("mode".to_owned(), "now".to_owned()), ("back".to_owned(), back.to_owned())], note: Some(s(lang, "The running jobs end as cancelled and can be run again.", "Çalışan işler iptal edilmiş olarak biter ve yeniden çalıştırılabilir.").to_owned())) | ||
| 525 | - </div> | ||
| 526 | </div> | 456 | </div> |
| 527 | - </details> | 457 | + ) |
| 528 | } else { | 458 | } else { |
| 529 | <p class="hint">(s(lang, "Runner too old, update it first", "Çalıştırıcı çok eski, önce güncelleyin"))</p> | 459 | <p class="hint">(s(lang, "Runner too old, update it first", "Çalıştırıcı çok eski, önce güncelleyin"))</p> |
| 530 | } | 460 | } |
| @@ -534,24 +464,9 @@ async fn restart_control( | |||
| 534 | /// Above this many slots the running jobs show as a meter, not as one pip per slot. | 464 | /// Above this many slots the running jobs show as a meter, not as one pip per slot. |
| 535 | const PIP_MAX: u32 = 16; | 465 | const PIP_MAX: u32 = 16; |
| 536 | 466 | ||
| 537 | -/// The load cell of a runner, in two parts: the jobs running, as a pip per concurrency slot (a | 467 | +/// The load of a runner: the jobs running, as a pip per concurrency slot, or a meter past `PIP_MAX`. |
| 538 | -/// meter past `PIP_MAX`), and the concurrency as a stepper. The − and + buttons step the input | ||
| 539 | -/// (nav.js); Save shows only once the value has changed, and stays visible without JavaScript. A | ||
| 540 | -/// reset button shows while an override is set. | ||
| 541 | #[component] | 468 | #[component] |
| 542 | -async fn concurrency_form( | 469 | +async fn load_meter(lang: Lang, running: u32, max: u32) -> Result<impl View> { |
| 543 | - lang: Lang, | ||
| 544 | - csrf: &str, | ||
| 545 | - action: &str, | ||
| 546 | - id: &str, | ||
| 547 | - key: &str, | ||
| 548 | - value: &str, | ||
| 549 | - source: &'static str, | ||
| 550 | - has_override: bool, | ||
| 551 | - back: &'static str, | ||
| 552 | - running: u32, | ||
| 553 | - max: u32, | ||
| 554 | -) -> Result<impl View> { | ||
| 555 | let running_text = running.to_string(); | 470 | let running_text = running.to_string(); |
| 556 | let meter_max = max.max(1).to_string(); | 471 | let meter_max = max.max(1).to_string(); |
| 557 | let use_pips = (1..=PIP_MAX).contains(&max); | 472 | let use_pips = (1..=PIP_MAX).contains(&max); |
| @@ -569,35 +484,15 @@ async fn concurrency_form( | |||
| 569 | Lang::Tr => format!("{running}/{max} iş çalışıyor"), | 484 | Lang::Tr => format!("{running}/{max} iş çalışıyor"), |
| 570 | }; | 485 | }; |
| 571 | Ok(view! { | 486 | Ok(view! { |
| 572 | - <form method="post" action=(action) class="fields runner-load" data-dirty-form=""> | 487 | + if use_pips { |
| 573 | - <input type="hidden" name="csrf" value=(csrf)> | 488 | + <span class="runner-pips" role="img" aria-label=(pips_label.as_str())> |
| 574 | - <input type="hidden" name="key" value=(key)> | 489 | + for pip in pips.iter() { |
| 575 | - <input type="hidden" name="back" value=(back)> | 490 | + <span class=(*pip)></span> |
| 576 | - <div class="field"> | 491 | + } |
| 577 | - <label for=(id)>(s(lang, "Concurrency", "Eşzamanlılık"))</label> | 492 | + </span> |
| 578 | - <div class="runner-stepper"> | 493 | + } else { |
| 579 | - <button type="button" class="runner-step" data-step="-1" aria-label=(s(lang, "Fewer", "Azalt"))>"−"</button> | 494 | + <progress class="runner-meter" value=(running_text.as_str()) max=(meter_max.as_str()) aria-label=(s(lang, "Running jobs", "Çalışan işler"))></progress> |
| 580 | - <input id=(id) type="number" name="value" value=(value) min="1" max="64" step="1" inputmode="numeric" required="required" title=(source_title(lang, source))> | 495 | + } |
| 581 | - <button type="button" class="runner-step" data-step="1" aria-label=(s(lang, "More", "Artır"))>"+"</button> | ||
| 582 | - </div> | ||
| 583 | - <div class="runner-running"> | ||
| 584 | - <span class="runner-count"><span class="runner-n">(running_text.as_str())</span>" "<span class="muted">(s(lang, "running", "çalışıyor"))</span></span> | ||
| 585 | - if use_pips { | ||
| 586 | - <span class="runner-pips" role="img" aria-label=(pips_label.as_str())> | ||
| 587 | - for pip in pips.iter() { | ||
| 588 | - <span class=(*pip)></span> | ||
| 589 | - } | ||
| 590 | - </span> | ||
| 591 | - } else { | ||
| 592 | - <progress class="runner-meter" value=(running_text.as_str()) max=(meter_max.as_str()) aria-label=(s(lang, "Running jobs", "Çalışan işler"))></progress> | ||
| 593 | - } | ||
| 594 | - </div> | ||
| 595 | - </div> | ||
| 596 | - <button type="submit" class="primary runner-save">(s(lang, "Save", "Kaydet"))</button> | ||
| 597 | - if has_override { | ||
| 598 | - <button type="submit" name="reset" value="1" class="act" formnovalidate="formnovalidate" title=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan"))>(s(lang, "Use the runner.toml value", "runner.toml değerini kullan"))</button> | ||
| 599 | - } | ||
| 600 | - </form> | ||
| 601 | }) | 496 | }) |
| 602 | } | 497 | } |
| 603 | 498 | ||
| @@ -609,23 +504,24 @@ async fn token_view( | |||
| 609 | expiry: String, | 504 | expiry: String, |
| 610 | ) -> Result<impl View> { | 505 | ) -> Result<impl View> { |
| 611 | Ok(view! { | 506 | Ok(view! { |
| 612 | - <h1 class="sr-only">(g::t(lang, K::RegistrationToken))</h1> | 507 | + head(title: g::t(lang, K::RegistrationToken)) |
| 613 | <p class="state" role="status"><strong>(g::t(lang, K::CopyTokenNow))</strong></p> | 508 | <p class="state" role="status"><strong>(g::t(lang, K::CopyTokenNow))</strong></p> |
| 614 | <p class="hint">(expiry.as_str())</p> | 509 | <p class="hint">(expiry.as_str())</p> |
| 615 | - <section class="sec" data-once=""> | 510 | + <div class="sheet"> |
| 616 | - <h2>(g::t(lang, K::Token))</h2> | 511 | + <div class="sheet-tools"><strong>(g::t(lang, K::Token))</strong> <a class="act" href="/admin/runners">(g::t(lang, K::BackToRunners))</a></div> |
| 617 | - <div class="copy-box"> | 512 | + <section class="sec" data-once=""> |
| 618 | - <code id="reg-token">(token.as_str())</code> | 513 | + <div class="copy-box"> |
| 619 | - <button type="button" class="act" data-copy="reg-token" data-copied=(s(lang, "Copied", "Kopyalandı")) data-failed=(s(lang, "Failed", "Başarısız"))>(s(lang, "Copy", "Kopyala"))</button> | 514 | + <code id="reg-token">(token.as_str())</code> |
| 620 | - </div> | 515 | + <button type="button" class="act" data-copy="reg-token" data-copied=(s(lang, "Copied", "Kopyalandı")) data-failed=(s(lang, "Failed", "Başarısız"))>(s(lang, "Copy", "Kopyala"))</button> |
| 621 | - <h2>(g::t(lang, K::RegisterARunner))</h2> | 516 | + </div> |
| 622 | - <p class="hint">(g::t(lang, K::ReplacePrefix))<code>"<name>"</code>(g::t(lang, K::ReplaceSuffix))</p> | 517 | + <h2>(g::t(lang, K::RegisterARunner))</h2> |
| 623 | - <div class="copy-box"> | 518 | + <p class="hint">(g::t(lang, K::ReplacePrefix))<code>"<name>"</code>(g::t(lang, K::ReplaceSuffix))</p> |
| 624 | - <code id="reg-command">(command.as_str())</code> | 519 | + <div class="copy-box"> |
| 625 | - <button type="button" class="act" data-copy="reg-command" data-copied=(s(lang, "Copied", "Kopyalandı")) data-failed=(s(lang, "Failed", "Başarısız"))>(s(lang, "Copy", "Kopyala"))</button> | 520 | + <code id="reg-command">(command.as_str())</code> |
| 626 | - </div> | 521 | + <button type="button" class="act" data-copy="reg-command" data-copied=(s(lang, "Copied", "Kopyalandı")) data-failed=(s(lang, "Failed", "Başarısız"))>(s(lang, "Copy", "Kopyala"))</button> |
| 627 | - <p class="sub"><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p> | 522 | + </div> |
| 628 | - </section> | 523 | + </section> |
| 524 | + </div> | ||
| 629 | }) | 525 | }) |
| 630 | } | 526 | } |
| 631 | 527 | ||
| @@ -847,8 +743,10 @@ fn sel(on: bool) -> Option<&'static str> { | |||
| 847 | on.then_some("selected") | 743 | on.then_some("selected") |
| 848 | } | 744 | } |
| 849 | 745 | ||
| 850 | -/// The detail page tabs: slug and the config keys on it. `jobs`, `identity` and `logs` are read-only. | 746 | +/// The detail page tabs: slug and the config keys on it. `overview`, `jobs`, `identity` and `logs` |
| 851 | -const TABS: [(&str, &[&str]); 7] = [ | 747 | +/// are read-only. |
| 748 | +const TABS: [(&str, &[&str]); 8] = [ | ||
| 749 | + ("overview", &[]), | ||
| 852 | ( | 750 | ( |
| 853 | "general", | 751 | "general", |
| 854 | &["concurrency", "labels", "executor", "auto_update"], | 752 | &["concurrency", "labels", "executor", "auto_update"], |
| @@ -882,6 +780,7 @@ const TABS: [(&str, &[&str]); 7] = [ | |||
| 882 | /// The tab's label in the page's own tab row. | 780 | /// The tab's label in the page's own tab row. |
| 883 | fn tab_label(lang: Lang, slug: &str) -> &'static str { | 781 | fn tab_label(lang: Lang, slug: &str) -> &'static str { |
| 884 | match slug { | 782 | match slug { |
| 783 | + "overview" => s(lang, "Overview", "Özet"), | ||
| 885 | "general" => s(lang, "General", "Genel"), | 784 | "general" => s(lang, "General", "Genel"), |
| 886 | "limits" => s(lang, "Limits", "Sınırlar"), | 785 | "limits" => s(lang, "Limits", "Sınırlar"), |
| 887 | "storage" => s(lang, "Storage", "Depolama"), | 786 | "storage" => s(lang, "Storage", "Depolama"), |
| @@ -900,11 +799,11 @@ fn tab_keys(tab: &str) -> Vec<&'static str> { | |||
| 900 | .collect() | 799 | .collect() |
| 901 | } | 800 | } |
| 902 | 801 | ||
| 903 | -/// The tab a name stands for; anything unknown is the first tab. | 802 | +/// The tab a name stands for; anything unknown is the overview. |
| 904 | fn tab_slug(wanted: Option<&str>) -> &'static str { | 803 | fn tab_slug(wanted: Option<&str>) -> &'static str { |
| 905 | TABS.iter() | 804 | TABS.iter() |
| 906 | .find(|(slug, _)| Some(*slug) == wanted) | 805 | .find(|(slug, _)| Some(*slug) == wanted) |
| 907 | - .map_or("general", |(slug, _)| *slug) | 806 | + .map_or("overview", |(slug, _)| *slug) |
| 908 | } | 807 | } |
| 909 | 808 | ||
| 910 | /// The tab slug from `?tab=`. | 809 | /// The tab slug from `?tab=`. |
| @@ -1636,7 +1535,12 @@ async fn runner_detail_view( | |||
| 1636 | }; | 1535 | }; |
| 1637 | let shown = detail_fields(lang, tab, &fields); | 1536 | let shown = detail_fields(lang, tab, &fields); |
| 1638 | let identity = identity_rows(lang, &fields); | 1537 | let identity = identity_rows(lang, &fields); |
| 1639 | - let editing = !matches!(tab, "logs" | "jobs"); | 1538 | + let editing = !matches!(tab, "overview" | "logs" | "jobs"); |
| 1539 | + let slots = row.concurrency.parse::<u32>().unwrap_or(0); | ||
| 1540 | + let mut sub = vec![SubPart::text(row.state_text)]; | ||
| 1541 | + if row.restart_pending.is_some() { | ||
| 1542 | + sub.push(SubPart::text(s(lang, "restart pending", "yeniden başlatma bekliyor"))); | ||
| 1543 | + } | ||
| 1640 | let jobs_href = format!("{}?tab=jobs", row.detail_href); | 1544 | let jobs_href = format!("{}?tab=jobs", row.detail_href); |
| 1641 | let save_action = format!("{}/settings", row.detail_href); | 1545 | let save_action = format!("{}/settings", row.detail_href); |
| 1642 | let reset_action = row.config_action.clone(); | 1546 | let reset_action = row.config_action.clone(); |
| @@ -1658,15 +1562,15 @@ async fn runner_detail_view( | |||
| 1658 | // A runner that has reported nothing has no figures to show, only the note below. | 1562 | // A runner that has reported nothing has no figures to show, only the note below. |
| 1659 | let has_host = !metrics.empty || runner.reported.cpus.is_some(); | 1563 | let has_host = !metrics.empty || runner.reported.cpus.is_some(); |
| 1660 | Ok(view! { | 1564 | Ok(view! { |
| 1661 | - <div data-live="/admin/runners/events" class="runner-detail"> | 1565 | + head(title: runner.name.as_str(), sub: sub, live: Some("/admin/runners/events"), |
| 1662 | - <h1 class="h1">(runner.name.as_str())</h1> | 1566 | + restart_control(lang: lang, csrf: csrf.as_str(), action: row.restart_action.as_str(), back: "detail", can_restart: row.can_restart, pending: row.restart_pending) |
| 1663 | - <p class="hint runner-state"><span class=(row.dot_class)></span>(row.state_text) | 1567 | + if row.disabled { |
| 1664 | - if row.restart_pending.is_some() { | 1568 | + post_act(label: g::t(lang, K::Enable), action: row.toggle_action.as_str(), csrf: csrf.as_str(), fields: vec![("disabled".to_owned(), "0".to_owned())]) |
| 1665 | - " · " | 1569 | + } else { |
| 1666 | - <span class="runner-off">(s(lang, "restart pending", "yeniden başlatma bekliyor"))</span> | 1570 | + confirm_post(lang: lang, csrf: csrf.as_str(), action: row.toggle_action.as_str(), label: g::t(lang, K::Disable), message: disable_message(lang, row.name.as_str()), confirm: s(lang, "Yes, disable", "Evet, devre dışı bırak"), fields: vec![("disabled", "1".into())]) |
| 1667 | } | 1571 | } |
| 1668 | - </p> | 1572 | + confirm_act(lang: lang, label: i18n::t(lang, Key::Delete), action: row.delete_action.as_str(), csrf: csrf.as_str(), note: Some(delete_message(lang, row.name.as_str()))) |
| 1669 | - <p class="sub"><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p> | 1573 | + ) |
| 1670 | if let Some((text, is_error)) = notice { | 1574 | if let Some((text, is_error)) = notice { |
| 1671 | if is_error { | 1575 | if is_error { |
| 1672 | alert(message: text) | 1576 | alert(message: text) |
| @@ -1674,30 +1578,26 @@ async fn runner_detail_view( | |||
| 1674 | <p class="state" role="status">(text)</p> | 1578 | <p class="state" role="status">(text)</p> |
| 1675 | } | 1579 | } |
| 1676 | } | 1580 | } |
| 1677 | - <section class="sec"> | 1581 | + <nav class="tabs" aria-label=(s(lang, "Configuration", "Yapılandırma"))> |
| 1678 | - <h2>(s(lang, "Status", "Durum"))</h2> | 1582 | + for (slug, _) in TABS.iter() { |
| 1679 | - <p class="state">(s(lang, "Running jobs", "Çalışan işler")) " " <a href=(jobs_href.as_str())>(in_use.as_str())</a></p> | 1583 | + <a href=(format!("{}?tab={}", row.detail_href, slug)) aria-current=(current(*slug == tab))>(tab_label(lang, slug))</a> |
| 1680 | - <p class="hint">(g::t(lang, K::LastSeen)) " " <time data-rel="true" datetime=(row.last_seen_at.as_str()) title=(row.last_seen_full.as_str())>(row.last_seen.as_str())</time></p> | 1584 | + } |
| 1681 | - <p class="hint">(s(lang, "Build", "Derleme")) " " <span title=(row.build.as_str())>(if row.build_short.is_empty() { "-" } else { row.build_short.as_str() })</span> " " <span class=(format!("ci-state {}", row.build_class))>(row.build_label)</span></p> | 1585 | + </nav> |
| 1682 | - <p class="hint">(s(lang, "Runner version", "Çalıştırıcı sürümü")) " " (version.as_str())</p> | 1586 | + <div class="sheet"> |
| 1683 | - <div class="acts"> | 1587 | + if tab == "overview" { |
| 1684 | - restart_control(lang: lang, csrf: csrf.as_str(), action: row.restart_action.as_str(), back: "detail", can_restart: row.can_restart, pending: row.restart_pending) | 1588 | + <section class="sec"> |
| 1685 | - if row.disabled { | 1589 | + <h2>(s(lang, "Status", "Durum"))</h2> |
| 1686 | - post_act(label: g::t(lang, K::Enable), action: row.toggle_action.as_str(), csrf: csrf.as_str(), fields: vec![("disabled".to_owned(), "0".to_owned())]) | 1590 | + <div class="line"><span class="name">(s(lang, "Running jobs", "Çalışan işler"))</span><span class="val"><a href=(jobs_href.as_str())>(in_use.as_str())</a> " " load_meter(lang: lang, running: row.running, max: slots)</span></div> |
| 1687 | - } else { | 1591 | + <div class="line"><span class="name">(g::t(lang, K::LastSeen))</span><span class="val"><time data-rel="true" datetime=(row.last_seen_at.as_str()) title=(row.last_seen_full.as_str())>(row.last_seen.as_str())</time></span></div> |
| 1688 | - confirm_post(lang: lang, csrf: csrf.as_str(), action: row.toggle_action.as_str(), label: g::t(lang, K::Disable), message: disable_message(lang, row.name.as_str()), confirm: s(lang, "Yes, disable", "Evet, devre dışı bırak"), danger: false, fields: vec![("disabled", "1".into())]) | 1592 | + <div class="line"><span class="name">(s(lang, "Build", "Derleme"))</span><span class="val"><span title=(row.build.as_str())>(if row.build_short.is_empty() { "-" } else { row.build_short.as_str() })</span> " " <span class=(format!("ci-state {}", row.build_class))>(row.build_label)</span></span></div> |
| 1689 | - } | 1593 | + <div class="line"><span class="name">(s(lang, "Runner version", "Çalıştırıcı sürümü"))</span><span class="val">(version.as_str())</span></div> |
| 1690 | - confirm_post(lang: lang, csrf: csrf.as_str(), action: row.delete_action.as_str(), label: i18n::t(lang, Key::Delete), message: delete_message(lang, row.name.as_str()), confirm: s(lang, "Yes, delete", "Evet, sil"), danger: true, fields: vec![]) | 1594 | + </section> |
| 1691 | - </div> | ||
| 1692 | - </section> | ||
| 1693 | - <section class="sec"> | ||
| 1694 | - <h2>(s(lang, "Last hour", "Son bir saat"))</h2> | ||
| 1695 | if has_host { | 1595 | if has_host { |
| 1696 | <div class="mx-panels"> | 1596 | <div class="mx-panels"> |
| 1697 | for (c, fact) in metrics.charts.iter().zip(facts.iter()) { | 1597 | for (c, fact) in metrics.charts.iter().zip(facts.iter()) { |
| 1698 | - <div class="mx-panel"> | 1598 | + <section class="sec mx-panel"> |
| 1699 | <div class="mx-head"> | 1599 | <div class="mx-head"> |
| 1700 | - <p class="mx-caption">(c.caption.as_str())</p> | 1600 | + <h2 class="mx-caption">(c.caption.as_str())</h2> |
| 1701 | if !fact.is_empty() { | 1601 | if !fact.is_empty() { |
| 1702 | <p class="hint mx-facts">(fact.as_str())</p> | 1602 | <p class="hint mx-facts">(fact.as_str())</p> |
| 1703 | } | 1603 | } |
| @@ -1741,40 +1641,46 @@ async fn runner_detail_view( | |||
| 1741 | } | 1641 | } |
| 1742 | </svg> | 1642 | </svg> |
| 1743 | } | 1643 | } |
| 1744 | - </div> | 1644 | + </section> |
| 1745 | } | 1645 | } |
| 1746 | </div> | 1646 | </div> |
| 1747 | } | 1647 | } |
| 1748 | if metrics.empty { | 1648 | if metrics.empty { |
| 1749 | - <p class="hint">(s(lang, "No metrics yet. A runner sends them from this version on; an older one sends nothing.", "Henüz ölçüm yok. Ölçümleri bu sürümden itibaren çalıştırıcı gönderir; eski sürüm hiçbir şey göndermez."))</p> | 1649 | + <section class="sec"> |
| 1650 | + <p class="hint">(s(lang, "No metrics yet. A runner sends them from this version on; an older one sends nothing.", "Henüz ölçüm yok. Ölçümleri bu sürümden itibaren çalıştırıcı gönderir; eski sürüm hiçbir şey göndermez."))</p> | ||
| 1651 | + </section> | ||
| 1750 | } else { | 1652 | } else { |
| 1751 | - <details class="mx-table"> | 1653 | + <section class="sec"> |
| 1752 | - <summary>(s(lang, "Show as table", "Tablo olarak göster"))</summary> | 1654 | + <details class="mx-table"> |
| 1753 | - <div class="table-wrap mx-table-scroll"> | 1655 | + <summary class="act">(s(lang, "Show as table", "Tablo olarak göster"))</summary> |
| 1754 | - <table class="table"> | 1656 | + <div class="table-wrap mx-table-scroll"> |
| 1755 | - <thead><tr><th>(s(lang, "Time (UTC)", "Saat (UTC)"))</th><th>(s(lang, "CPU", "CPU"))</th><th>(s(lang, "Memory", "Bellek"))</th><th>(s(lang, "Received", "Alınan"))</th><th>(s(lang, "Sent", "Gönderilen"))</th></tr></thead> | 1657 | + <table class="table"> |
| 1756 | - <tbody> | 1658 | + <thead><tr><th>(s(lang, "Time (UTC)", "Saat (UTC)"))</th><th>(s(lang, "CPU", "CPU"))</th><th>(s(lang, "Memory", "Bellek"))</th><th>(s(lang, "Received", "Alınan"))</th><th>(s(lang, "Sent", "Gönderilen"))</th></tr></thead> |
| 1757 | - for row in metrics.rows.iter() { | 1659 | + <tbody> |
| 1758 | - <tr> | 1660 | + for row in metrics.rows.iter() { |
| 1759 | - <td class="nowrap">(row.time.as_str())</td> | 1661 | + <tr> |
| 1760 | - <td class="nowrap">(row.cpu.as_str())</td> | 1662 | + <td class="nowrap">(row.time.as_str())</td> |
| 1761 | - <td class="nowrap">(row.mem.as_str())</td> | 1663 | + <td class="nowrap">(row.cpu.as_str())</td> |
| 1762 | - <td class="nowrap">(row.rx.as_str())</td> | 1664 | + <td class="nowrap">(row.mem.as_str())</td> |
| 1763 | - <td class="nowrap">(row.tx.as_str())</td> | 1665 | + <td class="nowrap">(row.rx.as_str())</td> |
| 1764 | - </tr> | 1666 | + <td class="nowrap">(row.tx.as_str())</td> |
| 1765 | - } | 1667 | + </tr> |
| 1766 | - </tbody> | 1668 | + } |
| 1767 | - </table> | 1669 | + </tbody> |
| 1768 | - </div> | 1670 | + </table> |
| 1769 | - </details> | 1671 | + </div> |
| 1770 | - } | 1672 | + </details> |
| 1771 | - </section> | 1673 | + </section> |
| 1772 | - <nav class="tabs" aria-label=(s(lang, "Configuration", "Yapılandırma"))> | ||
| 1773 | - for (slug, _) in TABS.iter() { | ||
| 1774 | - <a href=(format!("{}?tab={}", row.detail_href, slug)) aria-current=(current(*slug == tab))>(tab_label(lang, slug))</a> | ||
| 1775 | } | 1674 | } |
| 1776 | - </nav> | 1675 | + } else if tab == "identity" { |
| 1777 | - if editing { | 1676 | + <section class="sec"> |
| 1677 | + for (label, value) in identity.iter() { | ||
| 1678 | + <div class="line"><span class="name">(*label)</span><span class="val"><code class="srv-fixed">(value.as_str())</code></span></div> | ||
| 1679 | + } | ||
| 1680 | + <p class="hint">(g::t(lang, K::SrvKindReadOnly))</p> | ||
| 1681 | + <p class="hint">(s(lang, "Set when the runner registered. These cannot be changed from the forge.", "Çalıştırıcı kaydolurken belirlenir. Forge üzerinden değiştirilemez."))</p> | ||
| 1682 | + </section> | ||
| 1683 | + } else if editing { | ||
| 1778 | <section class="sec"> | 1684 | <section class="sec"> |
| 1779 | <form method="post" action=(save_action.as_str()) class="fields"> | 1685 | <form method="post" action=(save_action.as_str()) class="fields"> |
| 1780 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 1686 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| @@ -1806,18 +1712,7 @@ async fn runner_detail_view( | |||
| 1806 | } | 1712 | } |
| 1807 | </div> | 1713 | </div> |
| 1808 | } | 1714 | } |
| 1809 | - for (i, (label, value)) in identity.iter().enumerate().filter(|_| tab == "identity") { | 1715 | + <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> |
| 1810 | - <div class="field"> | ||
| 1811 | - <p class="state">(*label) " " <code class="srv-fixed">(value.as_str())</code></p> | ||
| 1812 | - <p class="hint">(g::t(lang, K::SrvKindReadOnly))</p> | ||
| 1813 | - if i == 0 { | ||
| 1814 | - <p class="hint">(s(lang, "Set when the runner registered. These cannot be changed from the forge.", "Çalıştırıcı kaydolurken belirlenir. Forge üzerinden değiştirilemez."))</p> | ||
| 1815 | - } | ||
| 1816 | - </div> | ||
| 1817 | - } | ||
| 1818 | - if tab != "identity" { | ||
| 1819 | - <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> | ||
| 1820 | - } | ||
| 1821 | </form> | 1716 | </form> |
| 1822 | <form id="rn-reset" method="post" action=(reset_action.as_str())> | 1717 | <form id="rn-reset" method="post" action=(reset_action.as_str())> |
| 1823 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 1718 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| @@ -1826,68 +1721,40 @@ async fn runner_detail_view( | |||
| 1826 | <input type="hidden" name="reset" value="1"> | 1721 | <input type="hidden" name="reset" value="1"> |
| 1827 | </form> | 1722 | </form> |
| 1828 | </section> | 1723 | </section> |
| 1829 | - } else { | 1724 | + } else if tab == "logs" { |
| 1830 | - <section class="sec"> | 1725 | + if !log.is_empty() { |
| 1831 | - if tab == "logs" { | 1726 | + <div class="sheet-tools"><strong>(s(lang, "Runner log", "Çalıştırıcı günlüğü"))</strong> <button type="button" class="act" data-copy="runner-log" data-copied=(rc::t(lang, rc::K::CopyDone)) data-failed=(rc::t(lang, rc::K::CopyFailed))>(s(lang, "Copy all", "Tümünü kopyala"))</button></div> |
| 1727 | + } | ||
| 1728 | + <section class="sec"> | ||
| 1832 | if log.is_empty() { | 1729 | if log.is_empty() { |
| 1833 | <p class="hint">(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."))</p> | 1730 | <p class="hint">(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."))</p> |
| 1834 | } else { | 1731 | } else { |
| 1835 | - <div class="runner-log-bar"> | ||
| 1836 | - <button type="button" class="act" data-copy="runner-log" data-copied=(rc::t(lang, rc::K::CopyDone)) data-failed=(rc::t(lang, rc::K::CopyFailed))>(s(lang, "Copy all", "Tümünü kopyala"))</button> | ||
| 1837 | - </div> | ||
| 1838 | <pre id="runner-log" class="ci-log runner-log" role="log" aria-label=(s(lang, "Runner log", "Çalıştırıcı günlüğü"))> | 1732 | <pre id="runner-log" class="ci-log runner-log" role="log" aria-label=(s(lang, "Runner log", "Çalıştırıcı günlüğü"))> |
| 1839 | for row in log.iter() { | 1733 | for row in log.iter() { |
| 1840 | <span class=(row.class)><span class="runner-log-time">(row.time.as_str())</span>" "<span class="runner-log-level">(row.level.as_str())</span>" "<span class="runner-log-chip">(row.chip)</span>" "(row.text.as_str())"\n"</span> | 1734 | <span class=(row.class)><span class="runner-log-time">(row.time.as_str())</span>" "<span class="runner-log-level">(row.level.as_str())</span>" "<span class="runner-log-chip">(row.chip)</span>" "(row.text.as_str())"\n"</span> |
| 1841 | } | 1735 | } |
| 1842 | </pre> | 1736 | </pre> |
| 1843 | } | 1737 | } |
| 1844 | - } else if tab == "jobs" { | 1738 | + </section> |
| 1739 | + } else { | ||
| 1740 | + <section class="sec"> | ||
| 1845 | <h2>(s(lang, "Running now", "Şu an çalışan"))</h2> | 1741 | <h2>(s(lang, "Running now", "Şu an çalışan"))</h2> |
| 1846 | if running_jobs.is_empty() { | 1742 | if running_jobs.is_empty() { |
| 1847 | <p class="hint">(s(lang, "Not running any job.", "Hiçbir iş çalıştırmıyor."))</p> | 1743 | <p class="hint">(s(lang, "Not running any job.", "Hiçbir iş çalıştırmıyor."))</p> |
| 1848 | - } else { | ||
| 1849 | - <div class="table-wrap"> | ||
| 1850 | - <table class="table queue-table"> | ||
| 1851 | - <thead><tr><th>(s(lang, "Job", "İş"))</th><th>(s(lang, "Repo", "Depo"))</th><th>(s(lang, "Run", "Çalıştırma"))</th><th>(s(lang, "Running for", "Çalışma süresi"))</th><th>(s(lang, "Waited", "Bekleme"))</th></tr></thead> | ||
| 1852 | - <tbody> | ||
| 1853 | - for job in running_jobs.iter() { | ||
| 1854 | - <tr> | ||
| 1855 | - <td>(job.name.as_str())</td> | ||
| 1856 | - <td class="nowrap">(job.repo.as_str())</td> | ||
| 1857 | - <td class="nowrap"><a href=(job.run_href.as_str())>(job.run_text.as_str())</a></td> | ||
| 1858 | - <td class="nowrap">(job.duration.as_str())</td> | ||
| 1859 | - <td class="nowrap">(job.waited.as_str())</td> | ||
| 1860 | - </tr> | ||
| 1861 | - } | ||
| 1862 | - </tbody> | ||
| 1863 | - </table> | ||
| 1864 | - </div> | ||
| 1865 | } | 1744 | } |
| 1745 | + for job in running_jobs.iter() { | ||
| 1746 | + <div class="line"><span class="name">(job.name.as_str())</span><span class="val">(job.repo.as_str())</span><span class="val"><a href=(job.run_href.as_str())>(job.run_text.as_str())</a></span><span class="val">(job.duration.as_str()) " · " (s(lang, "waited", "bekleme")) " " (job.waited.as_str())</span></div> | ||
| 1747 | + } | ||
| 1748 | + </section> | ||
| 1749 | + <section class="sec"> | ||
| 1866 | <h2>(s(lang, "Recent", "Son"))</h2> | 1750 | <h2>(s(lang, "Recent", "Son"))</h2> |
| 1867 | if recent_jobs.is_empty() { | 1751 | if recent_jobs.is_empty() { |
| 1868 | <p class="hint">(s(lang, "No finished jobs yet.", "Henüz biten iş yok."))</p> | 1752 | <p class="hint">(s(lang, "No finished jobs yet.", "Henüz biten iş yok."))</p> |
| 1869 | - } else { | ||
| 1870 | - <div class="table-wrap"> | ||
| 1871 | - <table class="table queue-table"> | ||
| 1872 | - <thead><tr><th>(s(lang, "Job", "İş"))</th><th>(s(lang, "Repo", "Depo"))</th><th>(s(lang, "Run", "Çalıştırma"))</th><th>(s(lang, "State", "Durum"))</th><th>(s(lang, "Took", "Süre"))</th><th>(s(lang, "Waited", "Bekleme"))</th><th>(s(lang, "Finished", "Bitiş"))</th></tr></thead> | ||
| 1873 | - <tbody> | ||
| 1874 | - for job in recent_jobs.iter() { | ||
| 1875 | - <tr> | ||
| 1876 | - <td>(job.name.as_str())</td> | ||
| 1877 | - <td class="nowrap">(job.repo.as_str())</td> | ||
| 1878 | - <td class="nowrap"><a href=(job.run_href.as_str())>(job.run_text.as_str())</a></td> | ||
| 1879 | - <td><span class=(job.state_class.as_str())>(job.state_text.as_str())</span></td> | ||
| 1880 | - <td class="nowrap">(job.duration.as_str())</td> | ||
| 1881 | - <td class="nowrap">(job.waited.as_str())</td> | ||
| 1882 | - <td class="nowrap"><time data-rel="true" datetime=(job.finished_at.as_str())>(job.finished_ago.as_str())</time></td> | ||
| 1883 | - </tr> | ||
| 1884 | - } | ||
| 1885 | - </tbody> | ||
| 1886 | - </table> | ||
| 1887 | - </div> | ||
| 1888 | } | 1753 | } |
| 1889 | - } | 1754 | + for job in recent_jobs.iter() { |
| 1890 | - </section> | 1755 | + <div class="line"><span class="name">(job.name.as_str())</span><span class="val">(job.repo.as_str())</span><span class="val"><a href=(job.run_href.as_str())>(job.run_text.as_str())</a></span><span class="val"><span class=(job.state_class.as_str())>(job.state_text.as_str())</span></span><span class="val">(job.duration.as_str()) " · " (s(lang, "waited", "bekleme")) " " (job.waited.as_str())</span><span class="val"><time data-rel="true" datetime=(job.finished_at.as_str())>(job.finished_ago.as_str())</time></span></div> |
| 1756 | + } | ||
| 1757 | + </section> | ||
| 1891 | } | 1758 | } |
| 1892 | </div> | 1759 | </div> |
| 1893 | }) | 1760 | }) |
| @@ -2351,7 +2218,7 @@ mod tests { | |||
| 2351 | .expect("disable"); | 2218 | .expect("disable"); |
| 2352 | let (_, page) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; | 2219 | let (_, page) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; |
| 2353 | assert!(page.contains(r#"class="runner-dot is-disabled""#)); | 2220 | assert!(page.contains(r#"class="runner-dot is-disabled""#)); |
| 2354 | - assert!(page.contains(r#"<span class="val">idle · disabled</span>"#)); | 2221 | + assert!(page.contains(r#"<span class="val">idle</span>"#)); |
| 2355 | } | 2222 | } |
| 2356 | 2223 | ||
| 2357 | // Scenario: restart is capability-gated and audited, then the runner is disabled, enabled and deleted. | 2224 | // Scenario: restart is capability-gated and audited, then the runner is disabled, enabled and deleted. |
| @@ -2376,7 +2243,8 @@ mod tests { | |||
| 2376 | assert_eq!(status, 403); | 2243 | assert_eq!(status, 403); |
| 2377 | 2244 | ||
| 2378 | // A runner that never advertised the capability: the button is off and the post refused. | 2245 | // A runner that never advertised the capability: the button is off and the post refused. |
| 2379 | - let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; | 2246 | + let runner_page = format!("/admin/runners/{}", runner.id); |
| 2247 | + let (_, list) = send(&router, "GET", &runner_page, Some(ADMIN_TOKEN), None).await; | ||
| 2380 | assert!(list.contains("Runner too old, update it first"), "{list}"); | 2248 | assert!(list.contains("Runner too old, update it first"), "{list}"); |
| 2381 | let (status, _) = send( | 2249 | let (status, _) = send( |
| 2382 | &router, | 2250 | &router, |
| @@ -2401,7 +2269,7 @@ mod tests { | |||
| 2401 | ) | 2269 | ) |
| 2402 | .await | 2270 | .await |
| 2403 | .unwrap(); | 2271 | .unwrap(); |
| 2404 | - let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; | 2272 | + let (_, list) = send(&router, "GET", &runner_page, Some(ADMIN_TOKEN), None).await; |
| 2405 | assert!(list.contains("Restart after current jobs")); | 2273 | assert!(list.contains("Restart after current jobs")); |
| 2406 | assert!(list.contains("Restart now")); | 2274 | assert!(list.contains("Restart now")); |
| 2407 | let (status, _) = send( | 2275 | let (status, _) = send( |
| @@ -2417,7 +2285,7 @@ mod tests { | |||
| 2417 | store.runner_restart(&runner.id).await.unwrap(), | 2285 | store.runner_restart(&runner.id).await.unwrap(), |
| 2418 | Some(RestartMode::Drain) | 2286 | Some(RestartMode::Drain) |
| 2419 | ); | 2287 | ); |
| 2420 | - let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; | 2288 | + let (_, list) = send(&router, "GET", &runner_page, Some(ADMIN_TOKEN), None).await; |
| 2421 | assert!(list.contains("restart pending")); | 2289 | assert!(list.contains("restart pending")); |
| 2422 | let entries = store | 2290 | let entries = store |
| 2423 | .list_audit(&Default::default(), None, 50) | 2291 | .list_audit(&Default::default(), None, 50) |
| @@ -2441,7 +2309,7 @@ mod tests { | |||
| 2441 | ) | 2309 | ) |
| 2442 | .await | 2310 | .await |
| 2443 | .unwrap(); | 2311 | .unwrap(); |
| 2444 | - let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; | 2312 | + let (_, list) = send(&router, "GET", &runner_page, Some(ADMIN_TOKEN), None).await; |
| 2445 | assert!(!list.contains("restart pending")); | 2313 | assert!(!list.contains("restart pending")); |
| 2446 | 2314 | ||
| 2447 | // Disable, then enable again. | 2315 | // Disable, then enable again. |
| @@ -2580,9 +2448,16 @@ mod tests { | |||
| 2580 | store.list_runners().await.unwrap()[0].concurrency_override, | 2448 | store.list_runners().await.unwrap()[0].concurrency_override, |
| 2581 | Some(3) | 2449 | Some(3) |
| 2582 | ); | 2450 | ); |
| 2583 | - let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; | 2451 | + let (_, list) = send( |
| 2452 | + &router, | ||
| 2453 | + "GET", | ||
| 2454 | + &format!("{detail_uri}?tab=general"), | ||
| 2455 | + Some(ADMIN_TOKEN), | ||
| 2456 | + None, | ||
| 2457 | + ) | ||
| 2458 | + .await; | ||
| 2584 | assert!(list.contains(r#"value="3""#)); | 2459 | assert!(list.contains(r#"value="3""#)); |
| 2585 | - assert!(list.contains("Use the runner.toml value")); | 2460 | + assert!(list.contains("Reset to runner.toml")); |
| 2586 | assert!(list.contains(r#"data-live="/admin/runners/events""#)); | 2461 | assert!(list.contains(r#"data-live="/admin/runners/events""#)); |
| 2587 | 2462 | ||
| 2588 | // Out of range, wrong kind of field and a read-only field change nothing. | 2463 | // Out of range, wrong kind of field and a read-only field change nothing. |
| @@ -2612,7 +2487,14 @@ mod tests { | |||
| 2612 | ) | 2487 | ) |
| 2613 | .await; | 2488 | .await; |
| 2614 | assert_eq!(status, 303); | 2489 | assert_eq!(status, 303); |
| 2615 | - let (status, detail) = send(&router, "GET", &detail_uri, Some(ADMIN_TOKEN), None).await; | 2490 | + let (status, detail) = send( |
| 2491 | + &router, | ||
| 2492 | + "GET", | ||
| 2493 | + &format!("{detail_uri}?tab=general"), | ||
| 2494 | + Some(ADMIN_TOKEN), | ||
| 2495 | + None, | ||
| 2496 | + ) | ||
| 2497 | + .await; | ||
| 2616 | assert_eq!(status, 200); | 2498 | assert_eq!(status, 200); |
| 2617 | assert!(detail.contains("Concurrency")); | 2499 | assert!(detail.contains("Concurrency")); |
| 2618 | assert!(detail.contains(r#"data-live="/admin/runners/events""#)); | 2500 | assert!(detail.contains(r#"data-live="/admin/runners/events""#)); |
crates/forge-web/src/pages/admin_server.rsmodified+96 -72
| @@ -38,7 +38,7 @@ use crate::pages::ci_runs::{changed_event, events_response}; | |||
| 38 | use crate::pages::passkeys::s; | 38 | use crate::pages::passkeys::s; |
| 39 | use crate::self_update; | 39 | use crate::self_update; |
| 40 | use crate::state::AppState; | 40 | use crate::state::AppState; |
| 41 | -use crate::views::parts::{confirm_act, reveal}; | 41 | +use crate::views::parts::{RailItem, SubPart, confirm_act, head, rail, reveal}; |
| 42 | use crate::views::{enc, shell}; | 42 | use crate::views::{enc, shell}; |
| 43 | 43 | ||
| 44 | #[query_params(error = bad_request)] | 44 | #[query_params(error = bad_request)] |
| @@ -128,6 +128,22 @@ pub(crate) fn tab_label(lang: Lang, group: Group) -> &'static str { | |||
| 128 | ) | 128 | ) |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | +/// The words for a choice's stored value. Values that are names (smtp, s3, eu) read as they are. | ||
| 132 | +fn option_label(lang: Lang, option: &str) -> String { | ||
| 133 | + let (en, tr) = match option { | ||
| 134 | + "" => return g::t(lang, K::SrvEmpty).to_owned(), | ||
| 135 | + "closed" => ("Closed", "Kapalı"), | ||
| 136 | + "invite" => ("Invite only", "Yalnızca davetle"), | ||
| 137 | + "open" => ("Open", "Açık"), | ||
| 138 | + "all" => ("Everyone", "Herkes"), | ||
| 139 | + "admin" => ("Admins only", "Yalnızca yöneticiler"), | ||
| 140 | + "info" => ("Info", "Bilgi"), | ||
| 141 | + "warning" => ("Warning", "Uyarı"), | ||
| 142 | + other => return other.to_owned(), | ||
| 143 | + }; | ||
| 144 | + s(lang, en, tr).to_owned() | ||
| 145 | +} | ||
| 146 | + | ||
| 131 | fn row(lang: Lang, view: &FieldView) -> Row { | 147 | fn row(lang: Lang, view: &FieldView) -> Row { |
| 132 | let field: &Field = view.field; | 148 | let field: &Field = view.field; |
| 133 | let kind_label = match field.kind { | 149 | let kind_label = match field.kind { |
| @@ -145,11 +161,7 @@ fn row(lang: Lang, view: &FieldView) -> Row { | |||
| 145 | .iter() | 161 | .iter() |
| 146 | .map(|option| OptionRow { | 162 | .map(|option| OptionRow { |
| 147 | value: (*option).to_owned(), | 163 | value: (*option).to_owned(), |
| 148 | - label: if option.is_empty() { | 164 | + label: option_label(lang, option), |
| 149 | - g::t(lang, K::SrvEmpty).to_owned() | ||
| 150 | - } else { | ||
| 151 | - (*option).to_owned() | ||
| 152 | - }, | ||
| 153 | selected: *option == view.value, | 165 | selected: *option == view.value, |
| 154 | }) | 166 | }) |
| 155 | .collect(), | 167 | .collect(), |
| @@ -385,25 +397,26 @@ async fn server_view( | |||
| 385 | ), | 397 | ), |
| 386 | _ => "/admin/server/events".to_owned(), | 398 | _ => "/admin/server/events".to_owned(), |
| 387 | }; | 399 | }; |
| 400 | + let items: Vec<RailItem> = Group::ALL | ||
| 401 | + .into_iter() | ||
| 402 | + .map(|g_tab| RailItem { | ||
| 403 | + name: tab_label(lang, g_tab).to_owned(), | ||
| 404 | + val: String::new(), | ||
| 405 | + href: format!("/admin/server?cat={}", g_tab.slug()), | ||
| 406 | + current: g_tab == group, | ||
| 407 | + }) | ||
| 408 | + .collect(); | ||
| 409 | + let sub = vec![ | ||
| 410 | + SubPart::text(g::t(lang, K::ServerSettingsIntro)), | ||
| 411 | + SubPart::mono(format!( | ||
| 412 | + "{} {}", | ||
| 413 | + s(lang, "Version", "Sürüm"), | ||
| 414 | + forge_ci::build::display() | ||
| 415 | + )), | ||
| 416 | + ]; | ||
| 388 | Ok(view! { | 417 | Ok(view! { |
| 418 | + head(title: g::t(lang, K::ServerSettings), sub: sub) | ||
| 389 | <div data-live=(live.as_str())> | 419 | <div data-live=(live.as_str())> |
| 390 | - <h1 class="sr-only">(g::t(lang, K::ServerSettings))</h1> | ||
| 391 | - <form class="plain-search" method="get" action="/admin/server" role="search"> | ||
| 392 | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> | ||
| 393 | - <label class="sr-only" for="server-search">(search_label)</label> | ||
| 394 | - <input id="server-search" type="search" name="q" value=(q.as_str()) placeholder=(search_label) data-live-search="" autocomplete="off"> | ||
| 395 | - </form> | ||
| 396 | - <nav class="sub" aria-label=(g::t(lang, K::ServerSettings))> | ||
| 397 | - for g_tab in Group::ALL.into_iter() { | ||
| 398 | - if g_tab == group { | ||
| 399 | - <a aria-current="page" href=(format!("/admin/server?cat={}", g_tab.slug()))>(tab_label(lang, g_tab))</a> | ||
| 400 | - } else { | ||
| 401 | - <a href=(format!("/admin/server?cat={}", g_tab.slug()))>(tab_label(lang, g_tab))</a> | ||
| 402 | - } | ||
| 403 | - } | ||
| 404 | - </nav> | ||
| 405 | - <p class="hint">(g::t(lang, K::ServerSettingsIntro))</p> | ||
| 406 | - <p class="hint">(s(lang, "Version", "Sürüm")) " " (forge_ci::build::display())</p> | ||
| 407 | if restart == Restart::Pending { | 420 | if restart == Restart::Pending { |
| 408 | <p class="state" role="status" aria-live="polite"><strong>(s(lang, "Restarting...", "Yeniden başlatılıyor..."))</strong> " " (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."))</p> | 421 | <p class="state" role="status" aria-live="polite"><strong>(s(lang, "Restarting...", "Yeniden başlatılıyor..."))</strong> " " (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."))</p> |
| 409 | } else if restart == Restart::Done { | 422 | } else if restart == Restart::Done { |
| @@ -412,60 +425,71 @@ async fn server_view( | |||
| 412 | if let Some(message) = notice { | 425 | if let Some(message) = notice { |
| 413 | <p class="state" role="status">(message.as_str())</p> | 426 | <p class="state" role="status">(message.as_str())</p> |
| 414 | } | 427 | } |
| 415 | - if let Some(hits) = search { | 428 | + <div class="work"> |
| 416 | - <section class="sec"> | 429 | + rail(label: g::t(lang, K::ServerSettings), items: items, |
| 417 | - <h2>(s(lang, "Results", "Sonuçlar"))</h2> | 430 | + <form class="plain-search" method="get" action="/admin/server" role="search"> |
| 418 | - if hits.is_empty() { | 431 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> |
| 419 | - <p class="state">(s(lang, "No setting matches.", "Eşleşen ayar yok."))</p> | 432 | + <label class="sr-only" for="server-search">(search_label)</label> |
| 420 | - } | 433 | + <input id="server-search" type="search" name="q" value=(q.as_str()) placeholder=(search_label) data-live-search="" autocomplete="off"> |
| 421 | - for hit in hits.iter() { | 434 | + </form> |
| 422 | - <a class="line" href=(format!("/admin/server?cat={}#srv-{}", hit.group.slug(), hit.key))> | 435 | + ) |
| 423 | - <span class="name">(hit.label)</span> | 436 | + <div class="sheet"> |
| 424 | - <span class="val">(tab_label(lang, hit.group))</span> | 437 | + if let Some(hits) = search { |
| 425 | - </a> | 438 | + <section class="sec"> |
| 439 | + <h2>(s(lang, "Results", "Sonuçlar"))</h2> | ||
| 440 | + if hits.is_empty() { | ||
| 441 | + <p class="state">(s(lang, "No setting matches.", "Eşleşen ayar yok."))</p> | ||
| 442 | + } | ||
| 443 | + for hit in hits.iter() { | ||
| 444 | + <a class="line" href=(format!("/admin/server?cat={}#srv-{}", hit.group.slug(), hit.key))> | ||
| 445 | + <span class="name">(hit.label)</span> | ||
| 446 | + <span class="val">(tab_label(lang, hit.group))</span> | ||
| 447 | + </a> | ||
| 448 | + } | ||
| 449 | + </section> | ||
| 450 | + } else { | ||
| 451 | + <section class="sec"> | ||
| 452 | + <h2>(tab_label(lang, group))</h2> | ||
| 453 | + <form method="post" action="/admin/server" class="fields"> | ||
| 454 | + <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 455 | + <input type="hidden" name="tab" value=(tab)> | ||
| 456 | + for block in blocks.iter() { | ||
| 457 | + if block.len() > 1 { | ||
| 458 | + <div class="field-pair"> | ||
| 459 | + for r in block.iter() { | ||
| 460 | + srv_row(lang: lang, row: r) | ||
| 461 | + } | ||
| 462 | + </div> | ||
| 463 | + } else { | ||
| 464 | + for r in block.iter() { | ||
| 465 | + srv_row(lang: lang, row: r) | ||
| 466 | + } | ||
| 467 | + } | ||
| 468 | + } | ||
| 469 | + if any_editable { | ||
| 470 | + <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> | ||
| 471 | + } | ||
| 472 | + </form> | ||
| 473 | + </section> | ||
| 426 | } | 474 | } |
| 427 | - </section> | 475 | + <form id="srv-reset" method="post" action="/admin/server/reset"> |
| 428 | - } else { | ||
| 429 | - <section class="sec"> | ||
| 430 | - <h2>(tab_label(lang, group))</h2> | ||
| 431 | - <form method="post" action="/admin/server" class="fields"> | ||
| 432 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 476 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 433 | <input type="hidden" name="tab" value=(tab)> | 477 | <input type="hidden" name="tab" value=(tab)> |
| 434 | - for block in blocks.iter() { | 478 | + </form> |
| 435 | - if block.len() > 1 { | 479 | + <section class="sec"> |
| 436 | - <div class="field-pair"> | 480 | + <h2>(s(lang, "Restart server", "Sunucuyu yeniden başlat"))</h2> |
| 437 | - for r in block.iter() { | 481 | + <p class="hint">(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."))</p> |
| 438 | - srv_row(lang: lang, row: r) | 482 | + if restart == Restart::Pending { |
| 439 | - } | 483 | + <p class="state">(s(lang, "A restart is in progress.", "Yeniden başlatma sürüyor."))</p> |
| 440 | - </div> | ||
| 441 | - } else { | ||
| 442 | - for r in block.iter() { | ||
| 443 | - srv_row(lang: lang, row: r) | ||
| 444 | - } | ||
| 445 | - } | ||
| 446 | } | 484 | } |
| 447 | - if any_editable { | 485 | + if restart != Restart::Pending { |
| 448 | - <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> | 486 | + <div class="acts"> |
| 487 | + 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())) | ||
| 488 | + </div> | ||
| 449 | } | 489 | } |
| 450 | - </form> | 490 | + </section> |
| 451 | - </section> | 491 | + </div> |
| 452 | - } | 492 | + </div> |
| 453 | - <form id="srv-reset" method="post" action="/admin/server/reset"> | ||
| 454 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 455 | - <input type="hidden" name="tab" value=(tab)> | ||
| 456 | - </form> | ||
| 457 | - <section class="sec"> | ||
| 458 | - <h2>(s(lang, "Restart server", "Sunucuyu yeniden başlat"))</h2> | ||
| 459 | - <p class="hint">(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."))</p> | ||
| 460 | - if restart == Restart::Pending { | ||
| 461 | - <p class="state">(s(lang, "A restart is in progress.", "Yeniden başlatma sürüyor."))</p> | ||
| 462 | - } | ||
| 463 | - if restart != Restart::Pending { | ||
| 464 | - <div class="acts"> | ||
| 465 | - 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())) | ||
| 466 | - </div> | ||
| 467 | - } | ||
| 468 | - </section> | ||
| 469 | </div> | 493 | </div> |
| 470 | }) | 494 | }) |
| 471 | } | 495 | } |
crates/forge-web/src/pages/admin_user_detail.rsmodified+20 -24
| @@ -26,7 +26,7 @@ use crate::live::{Topic, stream_changes}; | |||
| 26 | use crate::pages::admin_users::admin_only; | 26 | use crate::pages::admin_users::admin_only; |
| 27 | use crate::pages::passkeys::s; | 27 | use crate::pages::passkeys::s; |
| 28 | use crate::state::AppState; | 28 | use crate::state::AppState; |
| 29 | -use crate::views::parts::{confirm_act, post_act, reveal}; | 29 | +use crate::views::parts::{confirm_act, head, post_act, reveal}; |
| 30 | use crate::views::{alert, enc, rel_time, rel_time_or_never, shell, user_facing_message}; | 30 | use crate::views::{alert, enc, rel_time, rel_time_or_never, shell, user_facing_message}; |
| 31 | 31 | ||
| 32 | #[query_params(error = bad_request)] | 32 | #[query_params(error = bad_request)] |
| @@ -198,9 +198,12 @@ async fn detail_body( | |||
| 198 | passkey_count | 198 | passkey_count |
| 199 | ); | 199 | ); |
| 200 | Ok(view! { | 200 | Ok(view! { |
| 201 | - <div data-live=(live.as_str())> | 201 | + head(title: target.username.as_str()) |
| 202 | - <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> | 202 | + <div class="sheet" data-live=(live.as_str())> |
| 203 | - <h1 class="h1">(target.username.as_str())</h1> | 203 | + <div class="sheet-tools"> |
| 204 | + <a class="act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> | ||
| 205 | + <a class="act" href=(profile.as_str())>(profile_label)</a> | ||
| 206 | + </div> | ||
| 204 | <p class="hint"> | 207 | <p class="hint"> |
| 205 | if !email.is_empty() { | 208 | if !email.is_empty() { |
| 206 | (email.as_str()) " · " | 209 | (email.as_str()) " · " |
| @@ -216,9 +219,6 @@ async fn detail_body( | |||
| 216 | <section class="sec"> | 219 | <section class="sec"> |
| 217 | <h2>(access_title)</h2> | 220 | <h2>(access_title)</h2> |
| 218 | <p class="state">(access_state.as_str())</p> | 221 | <p class="state">(access_state.as_str())</p> |
| 219 | - <div class="acts"> | ||
| 220 | - <a class="act" href=(profile.as_str())>(profile_label)</a> | ||
| 221 | - </div> | ||
| 222 | if suspended { | 222 | if suspended { |
| 223 | <p class="hint">(suspended_note.as_str())</p> | 223 | <p class="hint">(suspended_note.as_str())</p> |
| 224 | <div class="acts"> | 224 | <div class="acts"> |
| @@ -238,9 +238,7 @@ async fn detail_body( | |||
| 238 | <label for="suspend-reason">(at(lang, A::SuspendReason))</label> | 238 | <label for="suspend-reason">(at(lang, A::SuspendReason))</label> |
| 239 | <input id="suspend-reason" type="text" name="reason" maxlength="300" autocomplete="off"> | 239 | <input id="suspend-reason" type="text" name="reason" maxlength="300" autocomplete="off"> |
| 240 | </div> | 240 | </div> |
| 241 | - <div class="acts"> | 241 | + <button type="submit" class="danger small">(suspend_title)</button> |
| 242 | - <button type="submit" class="act danger">(suspend_title)</button> | ||
| 243 | - </div> | ||
| 244 | </form> | 242 | </form> |
| 245 | ) | 243 | ) |
| 246 | </div> | 244 | </div> |
| @@ -310,24 +308,22 @@ async fn org_body(lang: Lang, csrf: &str, org: User, members: usize) -> Result<i | |||
| 310 | let delete_action = format!("{base}/delete"); | 308 | let delete_action = format!("{base}/delete"); |
| 311 | let profile = format!("/{}", enc(&org.username)); | 309 | let profile = format!("/{}", enc(&org.username)); |
| 312 | let members = members.to_string(); | 310 | let members = members.to_string(); |
| 313 | - let access_title = s(lang, "Access", "Erişim"); | ||
| 314 | let profile_label = s(lang, "Open profile", "Profili aç"); | 311 | let profile_label = s(lang, "Open profile", "Profili aç"); |
| 315 | Ok(view! { | 312 | Ok(view! { |
| 316 | - <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> | 313 | + head(title: org.username.as_str()) |
| 317 | - <h1 class="h1">(org.username.as_str())</h1> | 314 | + <div class="sheet"> |
| 318 | - <p class="hint">(og::t(lang, OG::Members)) " " (members.as_str())</p> | 315 | + <div class="sheet-tools"> |
| 319 | - <section class="sec"> | 316 | + <a class="act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 320 | - <h2>(access_title)</h2> | ||
| 321 | - <div class="acts"> | ||
| 322 | <a class="act" href=(profile.as_str())>(profile_label)</a> | 317 | <a class="act" href=(profile.as_str())>(profile_label)</a> |
| 323 | </div> | 318 | </div> |
| 324 | - </section> | 319 | + <p class="hint">(og::t(lang, OG::Members)) " " (members.as_str())</p> |
| 325 | - <section class="sec"> | 320 | + <section class="sec"> |
| 326 | - <h2>(i18n::t(lang, Key::Delete))</h2> | 321 | + <h2>(i18n::t(lang, Key::Delete))</h2> |
| 327 | - <div class="acts"> | 322 | + <div class="acts"> |
| 328 | - confirm_act(lang: lang, label: g::t(lang, K::DeleteOrgTitle), action: delete_action.as_str(), csrf: csrf) | 323 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteOrgTitle), action: delete_action.as_str(), csrf: csrf) |
| 329 | - </div> | 324 | + </div> |
| 330 | - </section> | 325 | + </section> |
| 326 | + </div> | ||
| 331 | }) | 327 | }) |
| 332 | } | 328 | } |
| 333 | 329 | ||
crates/forge-web/src/pages/admin_users.rsmodified+111 -98
| @@ -22,7 +22,7 @@ use crate::i18n::{self, Key, Lang}; | |||
| 22 | use crate::live::{Topic, stream_changes}; | 22 | use crate::live::{Topic, stream_changes}; |
| 23 | use crate::pages::passkeys::s; | 23 | use crate::pages::passkeys::s; |
| 24 | use crate::state::AppState; | 24 | use crate::state::AppState; |
| 25 | -use crate::views::parts::reveal; | 25 | +use crate::views::parts::{head, reveal}; |
| 26 | use crate::views::repo_list::{pager, pager_links}; | 26 | use crate::views::repo_list::{pager, pager_links}; |
| 27 | use crate::views::{alert, enc, rel_time, shell, user_facing_message}; | 27 | use crate::views::{alert, enc, rel_time, shell, user_facing_message}; |
| 28 | 28 | ||
| @@ -221,18 +221,7 @@ async fn users_view( | |||
| 221 | let people_href = users_href(&q, Kind::People, 1); | 221 | let people_href = users_href(&q, Kind::People, 1); |
| 222 | let orgs_href = users_href(&q, Kind::Organizations, 1); | 222 | let orgs_href = users_href(&q, Kind::Organizations, 1); |
| 223 | Ok(view! { | 223 | Ok(view! { |
| 224 | - <div data-live="/admin/users/events"> | 224 | + head(title: g::t(lang, K::Users), |
| 225 | - <h1 class="sr-only">(g::t(lang, K::Users))</h1> | ||
| 226 | - <form class="plain-search" method="get" action="/admin/users" role="search"> | ||
| 227 | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> | ||
| 228 | - <label class="sr-only" for="user-search">(search_label)</label> | ||
| 229 | - <input id="user-search" type="search" name="q" value=(q.as_str()) placeholder=(search_label) data-live-search="" autocomplete="off"> | ||
| 230 | - <input type="hidden" name="kind" value=(kind.key())> | ||
| 231 | - </form> | ||
| 232 | - <nav class="sub" aria-label=(filter_label)> | ||
| 233 | - <a href=(all_href.as_str()) aria-current=((kind == Kind::All).then_some("page"))>(all_label.as_str())</a> | ||
| 234 | - <a href=(people_href.as_str()) aria-current=((kind == Kind::People).then_some("page"))>(people_label.as_str())</a> | ||
| 235 | - <a href=(orgs_href.as_str()) aria-current=((kind == Kind::Organizations).then_some("page"))>(orgs_label.as_str())</a> | ||
| 236 | reveal(label: g::t(lang, K::CreateUser), id: Some("create-user"), open: open, | 225 | reveal(label: g::t(lang, K::CreateUser), id: Some("create-user"), open: open, |
| 237 | if let Some(message) = error { | 226 | if let Some(message) = error { |
| 238 | alert(message: message.as_str()) | 227 | alert(message: message.as_str()) |
| @@ -259,34 +248,48 @@ async fn users_view( | |||
| 259 | <button type="submit" class="primary">(g::t(lang, K::CreateUser))</button> | 248 | <button type="submit" class="primary">(g::t(lang, K::CreateUser))</button> |
| 260 | </form> | 249 | </form> |
| 261 | ) | 250 | ) |
| 251 | + ) | ||
| 252 | + <nav class="tabs" aria-label=(filter_label)> | ||
| 253 | + <a href=(all_href.as_str()) aria-current=((kind == Kind::All).then_some("page"))>(all_label.as_str())</a> | ||
| 254 | + <a href=(people_href.as_str()) aria-current=((kind == Kind::People).then_some("page"))>(people_label.as_str())</a> | ||
| 255 | + <a href=(orgs_href.as_str()) aria-current=((kind == Kind::Organizations).then_some("page"))>(orgs_label.as_str())</a> | ||
| 262 | </nav> | 256 | </nav> |
| 263 | - if empty { | 257 | + <div class="sheet" data-live="/admin/users/events"> |
| 264 | - <p class="state">(s(lang, "No account matches.", "Eşleşen hesap yok."))</p> | 258 | + <div class="sheet-tools"> |
| 265 | - } | 259 | + <form class="plain-search" method="get" action="/admin/users" role="search"> |
| 266 | - for row in rows.into_iter() { | 260 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> |
| 267 | - if row.linkable { | 261 | + <label class="sr-only" for="user-search">(search_label)</label> |
| 268 | - <a class="line" href=(row.href.as_str()) data-kb-row=""> | 262 | + <input id="user-search" type="search" name="q" value=(q.as_str()) placeholder=(search_label) data-live-search="" autocomplete="off"> |
| 269 | - <span class="name">(row.username.as_str())</span> | 263 | + <input type="hidden" name="kind" value=(kind.key())> |
| 270 | - <span class="val"> | 264 | + </form> |
| 271 | - if !row.email.is_empty() { | 265 | + </div> |
| 272 | - (row.email.as_str()) " · " | 266 | + if empty { |
| 273 | - } | 267 | + <p class="state">(s(lang, "No account matches.", "Eşleşen hesap yok."))</p> |
| 274 | - (row.role.as_str()) " · " rel_time(lang: lang, stamp: row.created_at.as_str()) | ||
| 275 | - </span> | ||
| 276 | - </a> | ||
| 277 | - } else { | ||
| 278 | - <div class="line" data-kb-row=""> | ||
| 279 | - <span class="name">(row.username.as_str())</span> | ||
| 280 | - <span class="val"> | ||
| 281 | - if !row.email.is_empty() { | ||
| 282 | - (row.email.as_str()) " · " | ||
| 283 | - } | ||
| 284 | - (row.role.as_str()) " · " rel_time(lang: lang, stamp: row.created_at.as_str()) | ||
| 285 | - </span> | ||
| 286 | - </div> | ||
| 287 | } | 268 | } |
| 288 | - } | 269 | + for row in rows.into_iter() { |
| 289 | - pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | 270 | + if row.linkable { |
| 271 | + <a class="line" href=(row.href.as_str()) data-kb-row=""> | ||
| 272 | + <span class="name">(row.username.as_str())</span> | ||
| 273 | + <span class="val"> | ||
| 274 | + if !row.email.is_empty() { | ||
| 275 | + (row.email.as_str()) " · " | ||
| 276 | + } | ||
| 277 | + (row.role.as_str()) " · " rel_time(lang: lang, stamp: row.created_at.as_str()) | ||
| 278 | + </span> | ||
| 279 | + </a> | ||
| 280 | + } else { | ||
| 281 | + <div class="line" data-kb-row=""> | ||
| 282 | + <span class="name">(row.username.as_str())</span> | ||
| 283 | + <span class="val"> | ||
| 284 | + if !row.email.is_empty() { | ||
| 285 | + (row.email.as_str()) " · " | ||
| 286 | + } | ||
| 287 | + (row.role.as_str()) " · " rel_time(lang: lang, stamp: row.created_at.as_str()) | ||
| 288 | + </span> | ||
| 289 | + </div> | ||
| 290 | + } | ||
| 291 | + } | ||
| 292 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | ||
| 290 | </div> | 293 | </div> |
| 291 | }) | 294 | }) |
| 292 | } | 295 | } |
| @@ -481,50 +484,56 @@ async fn delete_body( | |||
| 481 | let action = format!("/admin/users/{}/delete", enc(&target.id)); | 484 | let action = format!("/admin/users/{}/delete", enc(&target.id)); |
| 482 | let prompt = g::type_to_confirm(lang, &target.username); | 485 | let prompt = g::type_to_confirm(lang, &target.username); |
| 483 | Ok(view! { | 486 | Ok(view! { |
| 484 | - <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> | 487 | + head(title: g::t(lang, K::DeleteUser)) |
| 485 | - <h1 class="sr-only">(g::t(lang, K::DeleteUser))</h1> | 488 | + <div class="sheet"> |
| 486 | - if let Some(message) = error { | 489 | + <div class="sheet-tools"> |
| 487 | - alert(message: message.as_str()) | 490 | + <a class="act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 488 | - } | 491 | + </div> |
| 489 | - if let Some(message) = refusal { | 492 | + if let Some(message) = error { |
| 490 | - alert(message: message.as_str()) | 493 | + alert(message: message.as_str()) |
| 491 | - } | 494 | + } |
| 492 | - <p class="state">(g::t(lang, K::DeletesAccount))<strong>(target.username.as_str())</strong>(g::t(lang, K::DeleteAccountRest))</p> | 495 | + if let Some(message) = refusal { |
| 493 | - if has_repos { | 496 | + alert(message: message.as_str()) |
| 494 | - <p class="hint">(g::t(lang, K::TransferOrDeleteFirst))</p> | 497 | + } |
| 495 | - <ul class="item-list"> | 498 | + <p class="state">(g::t(lang, K::DeletesAccount))<strong>(target.username.as_str())</strong>(g::t(lang, K::DeleteAccountRest))</p> |
| 496 | - for name in repos.into_iter() { | 499 | + if has_repos { |
| 497 | - <li>(name)</li> | 500 | + <section class="sec"> |
| 498 | - } | 501 | + <p class="hint">(g::t(lang, K::TransferOrDeleteFirst))</p> |
| 499 | - </ul> | 502 | + <ul class="item-list"> |
| 500 | - } | 503 | + for name in repos.into_iter() { |
| 501 | - if let Some(impact) = impact { | 504 | + <li>(name)</li> |
| 502 | - <section class="sec"> | 505 | + } |
| 503 | - <h2>(g::t(lang, K::WhatHappens))</h2> | 506 | + </ul> |
| 504 | - <p class="hint">(g::t(lang, K::MovedToGhost))</p> | 507 | + </section> |
| 505 | - <ul class="item-list"> | 508 | + } |
| 506 | - for line in impact.moved.into_iter() { | 509 | + if let Some(impact) = impact { |
| 507 | - <li>(line)</li> | 510 | + <section class="sec"> |
| 508 | - } | 511 | + <h2>(g::t(lang, K::WhatHappens))</h2> |
| 509 | - </ul> | 512 | + <p class="hint">(g::t(lang, K::MovedToGhost))</p> |
| 510 | - <p class="hint">(g::t(lang, K::RemovedWithAccount))</p> | 513 | + <ul class="item-list"> |
| 511 | - <ul class="item-list"> | 514 | + for line in impact.moved.into_iter() { |
| 512 | - for line in impact.removed.into_iter() { | 515 | + <li>(line)</li> |
| 513 | - <li>(line)</li> | 516 | + } |
| 514 | - } | 517 | + </ul> |
| 515 | - </ul> | 518 | + <p class="hint">(g::t(lang, K::RemovedWithAccount))</p> |
| 516 | - </section> | 519 | + <ul class="item-list"> |
| 517 | - <form method="post" action=(action.as_str()) class="fields"> | 520 | + for line in impact.removed.into_iter() { |
| 518 | - <input type="hidden" name="csrf" value=(csrf)> | 521 | + <li>(line)</li> |
| 519 | - <div class="field"> | 522 | + } |
| 520 | - <label for="confirm-username">(prompt.as_str())</label> | 523 | + </ul> |
| 521 | - <input id="confirm-username" type="text" name="confirm_username" autocomplete="off" required=(true)> | 524 | + </section> |
| 522 | - </div> | 525 | + <section class="sec"> |
| 523 | - <div class="acts"> | 526 | + <form method="post" action=(action.as_str()) class="fields"> |
| 524 | - <button type="submit" class="act danger">(g::t(lang, K::DeleteUser))</button> | 527 | + <input type="hidden" name="csrf" value=(csrf)> |
| 525 | - </div> | 528 | + <div class="field"> |
| 526 | - </form> | 529 | + <label for="confirm-username">(prompt.as_str())</label> |
| 527 | - } | 530 | + <input id="confirm-username" type="text" name="confirm_username" autocomplete="off" required=(true)> |
| 531 | + </div> | ||
| 532 | + <button type="submit" class="danger small">(g::t(lang, K::DeleteUser))</button> | ||
| 533 | + </form> | ||
| 534 | + </section> | ||
| 535 | + } | ||
| 536 | + </div> | ||
| 528 | }) | 537 | }) |
| 529 | } | 538 | } |
| 530 | 539 | ||
| @@ -540,22 +549,26 @@ async fn org_delete_note( | |||
| 540 | let settings = format!("/org/{}/settings", enc(&target.username)); | 549 | let settings = format!("/org/{}/settings", enc(&target.username)); |
| 541 | let profile = format!("/{}", enc(&target.username)); | 550 | let profile = format!("/{}", enc(&target.username)); |
| 542 | Ok(view! { | 551 | Ok(view! { |
| 543 | - <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> | 552 | + head(title: g::t(lang, K::DeleteOrgTitle)) |
| 544 | - <h1 class="sr-only">(g::t(lang, K::DeleteOrgTitle))</h1> | 553 | + <div class="sheet"> |
| 545 | - <p class="state"><strong>(target.username.as_str())</strong>(g::t(lang, K::OrgNotAUser))</p> | 554 | + <div class="sheet-tools"> |
| 546 | - if has_repos { | 555 | + <a class="act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 547 | - <p class="hint">(g::t(lang, K::OrgReposFirst))</p> | 556 | + if is_owner { |
| 548 | - <ul class="item-list"> | 557 | + <a class="act" href=(settings.as_str())>(g::t(lang, K::OpenOrgSettings))</a> |
| 549 | - for name in repos.into_iter() { | 558 | + } else { |
| 550 | - <li>(name)</li> | 559 | + <a class="act" href=(profile.as_str())>(g::t(lang, K::ViewOrg))</a> |
| 551 | } | 560 | } |
| 552 | - </ul> | 561 | + </div> |
| 553 | - } | 562 | + <p class="state"><strong>(target.username.as_str())</strong>(g::t(lang, K::OrgNotAUser))</p> |
| 554 | - <div class="acts"> | 563 | + if has_repos { |
| 555 | - if is_owner { | 564 | + <section class="sec"> |
| 556 | - <a class="act" href=(settings.as_str())>(g::t(lang, K::OpenOrgSettings))</a> | 565 | + <p class="hint">(g::t(lang, K::OrgReposFirst))</p> |
| 557 | - } else { | 566 | + <ul class="item-list"> |
| 558 | - <a class="act" href=(profile.as_str())>(g::t(lang, K::ViewOrg))</a> | 567 | + for name in repos.into_iter() { |
| 568 | + <li>(name)</li> | ||
| 569 | + } | ||
| 570 | + </ul> | ||
| 571 | + </section> | ||
| 559 | } | 572 | } |
| 560 | </div> | 573 | </div> |
| 561 | }) | 574 | }) |
crates/forge-web/src/pages/audit_log.rsmodified+72 -52
| @@ -17,6 +17,7 @@ use crate::live::{Topic, stream_changes}; | |||
| 17 | use crate::pages::admin_users::admin_only; | 17 | use crate::pages::admin_users::admin_only; |
| 18 | use crate::pages::issues_list::list_href; | 18 | use crate::pages::issues_list::list_href; |
| 19 | use crate::state::AppState; | 19 | use crate::state::AppState; |
| 20 | +use crate::views::parts::{SubPart, head}; | ||
| 20 | use crate::views::{rel_time, shell}; | 21 | use crate::views::{rel_time, shell}; |
| 21 | 22 | ||
| 22 | /// Entries per page of the admin audit log, under its filter bar. | 23 | /// Entries per page of the admin audit log, under its filter bar. |
| @@ -101,21 +102,38 @@ async fn audit_table(lang: Lang, rows: Vec<RowView>, show_actor: bool) -> Result | |||
| 101 | <p class="state">(g::t(lang, K::NoEntries))</p> | 102 | <p class="state">(g::t(lang, K::NoEntries))</p> |
| 102 | } else { | 103 | } else { |
| 103 | for row in rows.into_iter() { | 104 | for row in rows.into_iter() { |
| 104 | - <div class="line" data-kb-row=""> | 105 | + if row.ip.is_empty() && row.details.is_empty() { |
| 105 | - <span class="name"><code>(row.action.as_str())</code></span> | 106 | + <div class="line" data-kb-row=""> |
| 106 | - <span class="val"> | 107 | + <span class="name"><code>(row.action.as_str())</code></span> |
| 107 | - rel_time(lang: lang, stamp: row.when.as_str()) | 108 | + <span class="val"> |
| 108 | - if show_actor { | 109 | + rel_time(lang: lang, stamp: row.when.as_str()) |
| 109 | - " · " (row.actor.as_str()) | 110 | + if show_actor { |
| 110 | - } | 111 | + " · " (row.actor.as_str()) |
| 111 | - " · " (row.target.as_str()) | 112 | + } |
| 112 | - </span> | 113 | + " · " (row.target.as_str()) |
| 113 | - </div> | 114 | + </span> |
| 114 | - if !row.ip.is_empty() { | 115 | + </div> |
| 115 | - <p class="hint">"IP " (row.ip.as_str())</p> | 116 | + } else { |
| 116 | - } | 117 | + <details class="row-open" data-kb-row=""> |
| 117 | - if !row.details.is_empty() { | 118 | + <summary class="line"> |
| 118 | - <p class="hint"><code>(row.details.as_str())</code></p> | 119 | + <span class="name"><code>(row.action.as_str())</code></span> |
| 120 | + <span class="val"> | ||
| 121 | + rel_time(lang: lang, stamp: row.when.as_str()) | ||
| 122 | + if show_actor { | ||
| 123 | + " · " (row.actor.as_str()) | ||
| 124 | + } | ||
| 125 | + " · " (row.target.as_str()) | ||
| 126 | + </span> | ||
| 127 | + </summary> | ||
| 128 | + <div class="opened"> | ||
| 129 | + if !row.ip.is_empty() { | ||
| 130 | + <p class="hint">"IP " (row.ip.as_str())</p> | ||
| 131 | + } | ||
| 132 | + if !row.details.is_empty() { | ||
| 133 | + <p class="hint"><code>(row.details.as_str())</code></p> | ||
| 134 | + } | ||
| 135 | + </div> | ||
| 136 | + </details> | ||
| 119 | } | 137 | } |
| 120 | } | 138 | } |
| 121 | } | 139 | } |
| @@ -132,37 +150,37 @@ async fn admin_audit_view( | |||
| 132 | rows: Vec<RowView>, | 150 | rows: Vec<RowView>, |
| 133 | older_href: Option<String>, | 151 | older_href: Option<String>, |
| 134 | ) -> Result<impl View> { | 152 | ) -> Result<impl View> { |
| 153 | + let sub = vec![SubPart::text(g::t(lang, K::AuditIntro))]; | ||
| 135 | Ok(view! { | 154 | Ok(view! { |
| 136 | - <div data-live=(live.as_str())> | 155 | + head(title: g::t(lang, K::AuditLog), sub: sub) |
| 137 | - <h1 class="sr-only">(g::t(lang, K::AuditLog))</h1> | 156 | + <div class="sheet" data-live=(live.as_str())> |
| 138 | - <p class="hint">(g::t(lang, K::AuditIntro))</p> | 157 | + <div class="sheet-tools"> |
| 139 | - <form method="get" action="/admin/audit"> | 158 | + <form method="get" action="/admin/audit"> |
| 140 | - <div class="plain-search"> | 159 | + <div class="plain-search"> |
| 141 | - <label class="sr-only" for="audit-actor">(g::t(lang, K::ActorUsername))</label> | 160 | + <label class="sr-only" for="audit-actor">(g::t(lang, K::ActorUsername))</label> |
| 142 | - <input id="audit-actor" type="search" name="actor" value=(actor.as_str()) placeholder=(g::t(lang, K::ActorUsername)) data-live-search="" autocomplete="off"> | 161 | + <input id="audit-actor" type="search" name="actor" value=(actor.as_str()) placeholder=(g::t(lang, K::ActorUsername)) data-live-search="" autocomplete="off"> |
| 143 | - <button type="submit" class="sr-only">(g::t(lang, K::Filter))</button> | 162 | + <button type="submit" class="sr-only">(g::t(lang, K::Filter))</button> |
| 144 | - </div> | 163 | + </div> |
| 145 | - <div class="sub"> | 164 | + <label> |
| 146 | - <label> | 165 | + (g::t(lang, K::ActionLabel)) " " |
| 147 | - (g::t(lang, K::ActionLabel)) " " | 166 | + <select name="action" data-autosubmit="true"> |
| 148 | - <select name="action" data-autosubmit="true"> | 167 | + <option value="" selected=(action.is_empty())>(g::t(lang, K::AllActions))</option> |
| 149 | - <option value="" selected=(action.is_empty())>(g::t(lang, K::AllActions))</option> | 168 | + for known in AuditAction::ALL.iter().copied() { |
| 150 | - for known in AuditAction::ALL.iter().copied() { | 169 | + <option value=(known.as_str()) selected=(known.as_str() == action.as_str())>(known.as_str())</option> |
| 151 | - <option value=(known.as_str()) selected=(known.as_str() == action.as_str())>(known.as_str())</option> | 170 | + } |
| 152 | - } | 171 | + </select> |
| 153 | - </select> | 172 | + </label> |
| 154 | - </label> | 173 | + </form> |
| 155 | </div> | 174 | </div> |
| 156 | - </form> | 175 | + if let Some(message) = notice { |
| 157 | - if let Some(message) = notice { | 176 | + <p class="state" role="status">(message.as_str())</p> |
| 158 | - <p class="state" role="status">(message.as_str())</p> | 177 | + } |
| 159 | - } | 178 | + audit_table(lang: lang, rows: rows, show_actor: true) |
| 160 | - audit_table(lang: lang, rows: rows, show_actor: true) | 179 | + if let Some(href) = older_href { |
| 161 | - if let Some(href) = older_href { | 180 | + <div class="acts"> |
| 162 | - <nav class="sub"> | 181 | + <a class="act" href=(href.as_str())>(g::t(lang, K::Older))</a> |
| 163 | - <a href=(href.as_str())>(g::t(lang, K::Older))</a> | 182 | + </div> |
| 164 | - </nav> | 183 | + } |
| 165 | - } | ||
| 166 | </div> | 184 | </div> |
| 167 | }) | 185 | }) |
| 168 | } | 186 | } |
| @@ -173,15 +191,17 @@ async fn own_log_view( | |||
| 173 | rows: Vec<RowView>, | 191 | rows: Vec<RowView>, |
| 174 | older_href: Option<String>, | 192 | older_href: Option<String>, |
| 175 | ) -> Result<impl View> { | 193 | ) -> Result<impl View> { |
| 194 | + let sub = vec![SubPart::text(g::t(lang, K::OwnLogIntro))]; | ||
| 176 | Ok(view! { | 195 | Ok(view! { |
| 177 | - <h1 class="sr-only">(g::t(lang, K::SecurityLogTitle))</h1> | 196 | + head(title: g::t(lang, K::SecurityLogTitle), sub: sub) |
| 178 | - <p class="hint">(g::t(lang, K::OwnLogIntro))</p> | 197 | + <div class="sheet"> |
| 179 | - audit_table(lang: lang, rows: rows, show_actor: false) | 198 | + audit_table(lang: lang, rows: rows, show_actor: false) |
| 180 | - if let Some(href) = older_href { | 199 | + if let Some(href) = older_href { |
| 181 | - <nav class="sub"> | 200 | + <div class="acts"> |
| 182 | - <a href=(href.as_str())>(g::t(lang, K::Older))</a> | 201 | + <a class="act" href=(href.as_str())>(g::t(lang, K::Older))</a> |
| 183 | - </nav> | 202 | + </div> |
| 184 | - } | 203 | + } |
| 204 | + </div> | ||
| 185 | }) | 205 | }) |
| 186 | } | 206 | } |
| 187 | 207 | ||
crates/forge-web/src/pages/blame.rsmodified+20 -24
| @@ -19,13 +19,12 @@ use crate::pages::blob::{Line, text_lines}; | |||
| 19 | use crate::pages::ref_live; | 19 | use crate::pages::ref_live; |
| 20 | use crate::pages::repo::repo_head; | 20 | use crate::pages::repo::repo_head; |
| 21 | use crate::pages::repo_ctx::load_repo; | 21 | use crate::pages::repo_ctx::load_repo; |
| 22 | -use crate::pages::tree::{MAX_BLOB_BYTES, path_crumbs, read_file, resolve}; | 22 | +use crate::pages::passkeys::s; |
| 23 | +use crate::pages::tree::{MAX_BLOB_BYTES, read_file, resolve}; | ||
| 23 | use crate::render::emoji::emojify; | 24 | use crate::render::emoji::emojify; |
| 24 | use crate::state::AppState; | 25 | use crate::state::AppState; |
| 25 | use crate::views::commit_line::commit_line; | 26 | use crate::views::commit_line::commit_line; |
| 26 | -use crate::views::{ | 27 | +use crate::views::{human_size, iso_time, now_unix, relative_time, repo_href, shell, short_oid}; |
| 27 | - Crumb, breadcrumb, human_size, iso_time, now_unix, relative_time, repo_href, shell, short_oid, | ||
| 28 | -}; | ||
| 29 | 28 | ||
| 30 | path_param!(owner); | 29 | path_param!(owner); |
| 31 | path_param!(repo); | 30 | path_param!(repo); |
| @@ -116,9 +115,9 @@ async fn blame_table(rows: Vec<Row>, lang: Lang) -> Result<impl View> { | |||
| 116 | <div class="blame-top"> | 115 | <div class="blame-top"> |
| 117 | <a class="mono" href=(meta.commit_href.as_str())>(meta.short.as_str())</a> | 116 | <a class="mono" href=(meta.commit_href.as_str())>(meta.short.as_str())</a> |
| 118 | <span class="blame-author">(meta.author.as_str())</span> | 117 | <span class="blame-author">(meta.author.as_str())</span> |
| 119 | - <time class="muted" data-rel="true" datetime=(meta.iso.as_str())>(meta.age.as_str())</time> | 118 | + <time class="hint" data-rel="true" datetime=(meta.iso.as_str())>(meta.age.as_str())</time> |
| 120 | if let Some(prior) = meta.prior_href { | 119 | if let Some(prior) = meta.prior_href { |
| 121 | - <a class="blame-prior" href=(prior.as_str()) title=(b::t(lang, b::K::BlamePrior)) aria-label=(b::t(lang, b::K::BlamePrior))>"↶"</a> | 120 | + <a class="blame-prior" href=(prior.as_str()) title=(b::t(lang, b::K::BlamePrior)) aria-label=(b::t(lang, b::K::BlamePrior))>(s(lang, "Prior", "Önceki"))</a> |
| 122 | } | 121 | } |
| 123 | </div> | 122 | </div> |
| 124 | <a class="blame-summary" href=(meta.commit_href.as_str()) title=(meta.summary.as_str())>commit_line(subject: meta.summary.clone())</a> | 123 | <a class="blame-summary" href=(meta.commit_href.as_str()) title=(meta.summary.as_str())>commit_line(subject: meta.summary.clone())</a> |
| @@ -204,7 +203,6 @@ async fn blame_page(cx: &Cx) -> Result<impl View> { | |||
| 204 | "commits", | 203 | "commits", |
| 205 | &format!("{ref_name}/{file}"), | 204 | &format!("{ref_name}/{file}"), |
| 206 | ); | 205 | ); |
| 207 | - let crumbs: Vec<Crumb> = path_crumbs(repo, &ref_name, "blob", &file); | ||
| 208 | let title = format!( | 206 | let title = format!( |
| 209 | "{}/{} \u{b7} {} \u{b7} {file}", | 207 | "{}/{} \u{b7} {} \u{b7} {file}", |
| 210 | repo.owner_name, | 208 | repo.owner_name, |
| @@ -225,24 +223,22 @@ async fn blame_page(cx: &Cx) -> Result<impl View> { | |||
| 225 | Ok(view! { | 223 | Ok(view! { |
| 226 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 224 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 227 | repo_head(head: header) | 225 | repo_head(head: header) |
| 228 | - <div class="browse-bar"> | 226 | + <div class="sheet"> |
| 229 | - breadcrumb(lang: lang, crumbs: crumbs) | 227 | + <div class="sheet-tools"> |
| 228 | + <strong>(file_name)</strong> | ||
| 229 | + <span class="mono">(size)</span> | ||
| 230 | + <a class="act" href=(blob_href.as_str())>(b::t(lang, b::K::BlameBackToFile))</a> | ||
| 231 | + <a class="act" href=(history.as_str())>(g::t(lang, K::HistoryLink))</a> | ||
| 232 | + </div> | ||
| 233 | + <section class="file" data-lines=""> | ||
| 234 | + if let Some(text) = message { | ||
| 235 | + <p class="state">(text)</p> | ||
| 236 | + } | ||
| 237 | + if has_rows { | ||
| 238 | + blame_table(rows: rows, lang: lang) | ||
| 239 | + } | ||
| 240 | + </section> | ||
| 230 | </div> | 241 | </div> |
| 231 | - <section class="file" data-lines=""> | ||
| 232 | - <header class="file-head"> | ||
| 233 | - <span class="hint">(b::t(lang, b::K::BlameTitle)) " \u{b7} " (size)</span> | ||
| 234 | - <nav class="acts file-actions" aria-label=(g::t(lang, K::FileNav))> | ||
| 235 | - <a class="act" href=(blob_href.as_str())>(b::t(lang, b::K::BlameBackToFile))</a> | ||
| 236 | - <a class="act" href=(history.as_str())>(g::t(lang, K::HistoryLink))</a> | ||
| 237 | - </nav> | ||
| 238 | - </header> | ||
| 239 | - if let Some(text) = message { | ||
| 240 | - <p class="state">(text)</p> | ||
| 241 | - } | ||
| 242 | - if has_rows { | ||
| 243 | - blame_table(rows: rows, lang: lang) | ||
| 244 | - } | ||
| 245 | - </section> | ||
| 246 | ) | 242 | ) |
| 247 | }) | 243 | }) |
| 248 | } | 244 | } |
crates/forge-web/src/pages/blob.rsmodified+98 -43
| @@ -11,21 +11,26 @@ use topcoat::view::{Unescaped, View, component, view}; | |||
| 11 | 11 | ||
| 12 | use crate::i18n::browse as b; | 12 | use crate::i18n::browse as b; |
| 13 | use crate::i18n::code::{self as g, K}; | 13 | use crate::i18n::code::{self as g, K}; |
| 14 | +use crate::i18n::misc::{self as mi, K as MK}; | ||
| 14 | use crate::i18n::{self}; | 15 | use crate::i18n::{self}; |
| 15 | use crate::lfs::has_object; | 16 | use crate::lfs::has_object; |
| 16 | use crate::lfs_pointer; | 17 | use crate::lfs_pointer; |
| 17 | use crate::pages::code_live::{follows_branch, live_url}; | 18 | use crate::pages::code_live::{follows_branch, live_url}; |
| 18 | use crate::pages::finder::file_finder; | 19 | use crate::pages::finder::file_finder; |
| 19 | use crate::pages::media::media_url; | 20 | use crate::pages::media::media_url; |
| 20 | -use crate::pages::refs::load_refs; | 21 | +use crate::pages::passkeys::s; |
| 22 | +use crate::pages::refs::{load_refs, ref_links}; | ||
| 21 | use crate::pages::repo::repo_head; | 23 | use crate::pages::repo::repo_head; |
| 22 | use crate::pages::repo_ctx::load_repo; | 24 | use crate::pages::repo_ctx::load_repo; |
| 23 | -use crate::pages::tree::{link_context, path_crumbs, read_file, resolve}; | 25 | +use crate::pages::repo_side::{code_sub, commit_strip, run_pips, run_rows, tree_facts}; |
| 26 | +use crate::pages::tree::{ | ||
| 27 | + entry_rows, last_commits, latest_bar, link_context, read_dir, read_file, resolve, tree_table, | ||
| 28 | +}; | ||
| 24 | use crate::raw::raw_url; | 29 | use crate::raw::raw_url; |
| 25 | use crate::render::highlight::highlight_lines; | 30 | use crate::render::highlight::highlight_lines; |
| 26 | use crate::render::markdown::render_markdown; | 31 | use crate::render::markdown::render_markdown; |
| 27 | use crate::state::AppState; | 32 | use crate::state::AppState; |
| 28 | -use crate::views::{Crumb, breadcrumb, human_size, repo_href, shell}; | 33 | +use crate::views::{human_size, now_unix, ref_selector, repo_href, shell}; |
| 29 | 34 | ||
| 30 | const IMAGE_EXTS: [&str; 8] = ["png", "jpg", "jpeg", "gif", "webp", "avif", "svg", "ico"]; | 35 | const IMAGE_EXTS: [&str; 8] = ["png", "jpg", "jpeg", "gif", "webp", "avif", "svg", "ico"]; |
| 31 | const MARKDOWN_EXTS: [&str; 2] = ["md", "markdown"]; | 36 | const MARKDOWN_EXTS: [&str; 2] = ["md", "markdown"]; |
| @@ -255,9 +260,7 @@ async fn blob_page(cx: &Cx) -> Result<impl View> { | |||
| 255 | let finder_owner = repo.owner_name.clone(); | 260 | let finder_owner = repo.owner_name.clone(); |
| 256 | let finder_repo = repo.name.clone(); | 261 | let finder_repo = repo.name.clone(); |
| 257 | let finder_ref = ref_name.clone(); | 262 | let finder_ref = ref_name.clone(); |
| 258 | - let crumbs: Vec<Crumb> = path_crumbs(repo, &ref_name, "blob", &file); | ||
| 259 | let title = format!("{}/{} \u{b7} {file}", repo.owner_name, repo.name); | 263 | let title = format!("{}/{} \u{b7} {file}", repo.owner_name, repo.name); |
| 260 | - let size = human_size(lang, blob.size); | ||
| 261 | 264 | ||
| 262 | let kind = viewer.kind; | 265 | let kind = viewer.kind; |
| 263 | let is_text = kind == "text"; | 266 | let is_text = kind == "text"; |
| @@ -271,19 +274,69 @@ async fn blob_page(cx: &Cx) -> Result<impl View> { | |||
| 271 | 274 | ||
| 272 | let refs = load_refs(ctx.path.clone()).await?; | 275 | let refs = load_refs(ctx.path.clone()).await?; |
| 273 | let follows = follows_branch(&refs, &ref_name); | 276 | let follows = follows_branch(&refs, &ref_name); |
| 277 | + // The head and the rail describe the folder the file sits in, as the folder page does. | ||
| 278 | + let siblings = read_dir(ctx.path.clone(), commit.clone(), dir.clone()) | ||
| 279 | + .await? | ||
| 280 | + .unwrap_or_default(); | ||
| 281 | + let names: Vec<String> = siblings.iter().map(|e| e.name.clone()).collect(); | ||
| 282 | + let root_names: Vec<String> = if dir.is_empty() { | ||
| 283 | + names.clone() | ||
| 284 | + } else { | ||
| 285 | + read_dir(ctx.path.clone(), commit.clone(), String::new()) | ||
| 286 | + .await? | ||
| 287 | + .unwrap_or_default() | ||
| 288 | + .into_iter() | ||
| 289 | + .map(|e| e.name) | ||
| 290 | + .collect() | ||
| 291 | + }; | ||
| 292 | + let (last, bar, strip, runs) = tokio::join!( | ||
| 293 | + last_commits(state, &ctx.path, &commit, &dir, &names), | ||
| 294 | + latest_bar(state, repo, &ctx.path, &commit, "", lang, ctx.viewer_tz()), | ||
| 295 | + commit_strip(state, repo, &ctx.path, &commit), | ||
| 296 | + run_rows(state, lang, repo), | ||
| 297 | + ); | ||
| 298 | + let runs = runs?; | ||
| 299 | + let facts = tree_facts(state, repo, &ctx.path, &commit, &root_names).await?; | ||
| 300 | + let pips = run_pips(&runs); | ||
| 301 | + let sub = code_sub(lang, bar, Some(facts), None, Vec::new(), strip.total); | ||
| 302 | + let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo); | ||
| 303 | + let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", ""); | ||
| 304 | + let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", ""); | ||
| 305 | + let rows = entry_rows( | ||
| 306 | + lang, | ||
| 307 | + repo, | ||
| 308 | + &ref_name, | ||
| 309 | + &dir, | ||
| 310 | + siblings, | ||
| 311 | + &last, | ||
| 312 | + now_unix(), | ||
| 313 | + ctx.viewer_tz(), | ||
| 314 | + ); | ||
| 274 | let mut header = ctx.head(state, "code").await?; | 315 | let mut header = ctx.head(state, "code").await?; |
| 275 | header.live = live_url(&repo.owner_name, &repo.name, &refs, &ref_name); | 316 | header.live = live_url(&repo.owner_name, &repo.name, &refs, &ref_name); |
| 317 | + let size = human_size(lang, blob.size); | ||
| 318 | + let size_line = if is_text { | ||
| 319 | + format!("{} {}, {size}", lines.len(), s(lang, "lines", "satır")) | ||
| 320 | + } else { | ||
| 321 | + size | ||
| 322 | + }; | ||
| 276 | Ok(view! { | 323 | Ok(view! { |
| 277 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 324 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 278 | - repo_head(head: header) | 325 | + repo_head(head: header, sub: sub, pips: pips) |
| 279 | - <div class="browse-bar" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> | 326 | + <div class="work"> |
| 280 | - breadcrumb(lang: lang, crumbs: crumbs) | 327 | + <nav class="rail" aria-label=(s(lang, "Files", "Dosyalar"))> |
| 281 | - file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) | 328 | + <div class="rail-head browse-bar" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> |
| 282 | - </div> | 329 | + <h2>(s(lang, "Files", "Dosyalar"))</h2> |
| 283 | - <section class="file" data-lines="" data-permalink=(permalink.as_str())> | 330 | + ref_selector(lang: lang, label: mi::t(lang, MK::RefLabel), current: ref_name.clone(), branches: branches, tags: tags, |
| 284 | - <header class="file-head"> | 331 | + branches_href: branches_href, tags_href: tags_href) |
| 285 | - <span class="hint">(size)</span> | 332 | + file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) |
| 286 | - <nav class="acts file-actions" aria-label=(g::t(lang, K::FileNav))> | 333 | + </div> |
| 334 | + tree_table(rows: rows, lang: lang, current: Some(file_name.clone())) | ||
| 335 | + </nav> | ||
| 336 | + <div class="sheet"> | ||
| 337 | + <div class="sheet-tools"> | ||
| 338 | + <strong>(file_name.clone())</strong> | ||
| 339 | + <span class="mono">(size_line)</span> | ||
| 287 | if let Some((label, href)) = toggle { | 340 | if let Some((label, href)) = toggle { |
| 288 | <a class="act" href=(href)>(label)</a> | 341 | <a class="act" href=(href)>(label)</a> |
| 289 | } | 342 | } |
| @@ -295,36 +348,38 @@ async fn blob_page(cx: &Cx) -> Result<impl View> { | |||
| 295 | <a class="act" href=(history)>(g::t(lang, K::HistoryLink))</a> | 348 | <a class="act" href=(history)>(g::t(lang, K::HistoryLink))</a> |
| 296 | <a class="act" href=(raw.clone())>(g::t(lang, K::RawLink))</a> | 349 | <a class="act" href=(raw.clone())>(g::t(lang, K::RawLink))</a> |
| 297 | <a class="act" href=(download_href) download=(download_name)>(g::t(lang, K::DownloadLink))</a> | 350 | <a class="act" href=(download_href) download=(download_name)>(g::t(lang, K::DownloadLink))</a> |
| 298 | - </nav> | ||
| 299 | - </header> | ||
| 300 | - if kind == "image" { | ||
| 301 | - <div class="file-image"> | ||
| 302 | - <img src=(raw.clone()) alt=(image_alt)> | ||
| 303 | </div> | 351 | </div> |
| 304 | - } | 352 | + <section class="file" data-lines="" data-permalink=(permalink.as_str())> |
| 305 | - if kind == "markdown" { | 353 | + if kind == "image" { |
| 306 | - <div class="markdown-body">(Unescaped::new_unchecked(html))</div> | 354 | + <div class="file-image"> |
| 307 | - } | 355 | + <img src=(raw.clone()) alt=(image_alt)> |
| 308 | - if kind == "text" { | 356 | + </div> |
| 309 | - file_table(lines: lines) | 357 | + } |
| 310 | - } | 358 | + if kind == "markdown" { |
| 311 | - if kind == "lfs" { | 359 | + <div class="markdown-body">(Unescaped::new_unchecked(html))</div> |
| 312 | - <p class="state">(note.clone())</p> | 360 | + } |
| 313 | - } | 361 | + if kind == "text" { |
| 314 | - if kind == "binary" { | 362 | + file_table(lines: lines) |
| 315 | - <p class="state">(note.clone())</p> | 363 | + } |
| 316 | - } | 364 | + if kind == "lfs" { |
| 317 | - if kind == "symlink" { | 365 | + <p class="state">(note.clone())</p> |
| 318 | - <p class="state">(g::t(lang, K::SymlinkPrefix)) <code>(note.clone())</code></p> | 366 | + } |
| 319 | - } | 367 | + if kind == "binary" { |
| 320 | - if kind == "submodule" { | 368 | + <p class="state">(note.clone())</p> |
| 321 | - <p class="state">(g::t(lang, K::SubmodulePrefix)) <code>(note.clone())</code> (g::t(lang, K::SubmoduleSuffix))</p> | 369 | + } |
| 322 | - } | 370 | + if kind == "symlink" { |
| 323 | - if truncated { | 371 | + <p class="state">(g::t(lang, K::SymlinkPrefix)) <code>(note.clone())</code></p> |
| 324 | - <p class="hint">(g::t(lang, K::TruncatedPrefix)) | 372 | + } |
| 325 | - <a href=(raw)>(g::t(lang, K::ViewFullRaw))</a> "."</p> | 373 | + if kind == "submodule" { |
| 326 | - } | 374 | + <p class="state">(g::t(lang, K::SubmodulePrefix)) <code>(note.clone())</code> (g::t(lang, K::SubmoduleSuffix))</p> |
| 327 | - </section> | 375 | + } |
| 376 | + if truncated { | ||
| 377 | + <p class="hint">(g::t(lang, K::TruncatedPrefix)) | ||
| 378 | + <a href=(raw)>(g::t(lang, K::ViewFullRaw))</a> "."</p> | ||
| 379 | + } | ||
| 380 | + </section> | ||
| 381 | + </div> | ||
| 382 | + </div> | ||
| 328 | ) | 383 | ) |
| 329 | }) | 384 | }) |
| 330 | } | 385 | } |
crates/forge-web/src/pages/branches.rsmodified+11 -10
| @@ -147,7 +147,7 @@ async fn branch_table( | |||
| 147 | <summary class="line"> | 147 | <summary class="line"> |
| 148 | <a class="name" href=(row.href.as_str())>(row.name.as_str())</a> | 148 | <a class="name" href=(row.href.as_str())>(row.name.as_str())</a> |
| 149 | if row.is_default { | 149 | if row.is_default { |
| 150 | - <span class="badge public">(g::t(lang, K::DefaultBadge))</span> | 150 | + <span class="hint">(g::t(lang, K::DefaultBadge))</span> |
| 151 | } | 151 | } |
| 152 | <span class="val">(row.author.as_str()) " · " <time data-rel="true" datetime=(row.iso.as_str())>(row.age.as_str())</time> | 152 | <span class="val">(row.author.as_str()) " · " <time data-rel="true" datetime=(row.iso.as_str())>(row.age.as_str())</time> |
| 153 | if let Some(counts) = row.counts { | 153 | if let Some(counts) = row.counts { |
| @@ -159,7 +159,7 @@ async fn branch_table( | |||
| 159 | </summary> | 159 | </summary> |
| 160 | <div class="opened"> | 160 | <div class="opened"> |
| 161 | if let Some(last) = row.last { | 161 | if let Some(last) = row.last { |
| 162 | - <p class="state"><a href=(last.href.as_str())>commit_line(subject: last.summary.clone())</a></p> | 162 | + <p><a href=(last.href.as_str())>commit_line(subject: last.summary.clone())</a></p> |
| 163 | } | 163 | } |
| 164 | <div class="acts"> | 164 | <div class="acts"> |
| 165 | if let Some(pr) = row.pr_href { | 165 | if let Some(pr) = row.pr_href { |
| @@ -274,7 +274,12 @@ async fn branches_page(cx: &Cx) -> Result<impl View> { | |||
| 274 | header.live = ref_live::live_url(&ctx.repo.owner_name, &ctx.repo.name); | 274 | header.live = ref_live::live_url(&ctx.repo.owner_name, &ctx.repo.name); |
| 275 | Ok(view! { | 275 | Ok(view! { |
| 276 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 276 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 277 | - repo_head(head: header) | 277 | + repo_head(head: header, |
| 278 | + if can_write { | ||
| 279 | + new_branch_form(lang: lang, action: action.clone(), csrf: csrf.clone(), | ||
| 280 | + default_branch: default_branch, options: options) | ||
| 281 | + } | ||
| 282 | + ) | ||
| 278 | if let Some((key, is_error)) = notice { | 283 | if let Some((key, is_error)) = notice { |
| 279 | if is_error { | 284 | if is_error { |
| 280 | alert(message: b::t(lang, key)) | 285 | alert(message: b::t(lang, key)) |
| @@ -282,16 +287,12 @@ async fn branches_page(cx: &Cx) -> Result<impl View> { | |||
| 282 | <p class="state" role="status">(b::t(lang, key))</p> | 287 | <p class="state" role="status">(b::t(lang, key))</p> |
| 283 | } | 288 | } |
| 284 | } | 289 | } |
| 285 | - if can_write { | ||
| 286 | - <div class="acts"> | ||
| 287 | - new_branch_form(lang: lang, action: action.clone(), csrf: csrf.clone(), | ||
| 288 | - default_branch: default_branch, options: options) | ||
| 289 | - </div> | ||
| 290 | - } | ||
| 291 | if empty { | 290 | if empty { |
| 292 | <p class="state">(g::t(lang, K::NothingHere))</p> | 291 | <p class="state">(g::t(lang, K::NothingHere))</p> |
| 293 | } else { | 292 | } else { |
| 294 | - branch_table(rows: rows, lang: lang, csrf: csrf.clone(), delete_action: delete_action, can_delete: can_write) | 293 | + <div class="sheet"> |
| 294 | + branch_table(rows: rows, lang: lang, csrf: csrf.clone(), delete_action: delete_action, can_delete: can_write) | ||
| 295 | + </div> | ||
| 295 | } | 296 | } |
| 296 | ) | 297 | ) |
| 297 | }) | 298 | }) |
crates/forge-web/src/pages/ci_estimate.rsmodified+0 -13
| @@ -7,7 +7,6 @@ | |||
| 7 | use std::collections::{HashMap, HashSet}; | 7 | use std::collections::{HashMap, HashSet}; |
| 8 | 8 | ||
| 9 | use forge_core::ci::{JobSample, JobState, StepSample}; | 9 | use forge_core::ci::{JobSample, JobState, StepSample}; |
| 10 | -use serde::Deserialize; | ||
| 11 | 10 | ||
| 12 | use crate::i18n::Lang; | 11 | use crate::i18n::Lang; |
| 13 | use crate::i18n::releases_ci as rc; | 12 | use crate::i18n::releases_ci as rc; |
| @@ -24,18 +23,6 @@ pub struct Step { | |||
| 24 | pub finished: Option<i64>, | 23 | pub finished: Option<i64>, |
| 25 | } | 24 | } |
| 26 | 25 | ||
| 27 | -/// The `needs` of a job spec, read from its JSON. A spec that does not read has none. | ||
| 28 | -pub fn needs_of(spec_json: &str) -> Vec<String> { | ||
| 29 | - #[derive(Deserialize, Default)] | ||
| 30 | - #[serde(default)] | ||
| 31 | - struct Needs { | ||
| 32 | - needs: Vec<String>, | ||
| 33 | - } | ||
| 34 | - serde_json::from_str::<Needs>(spec_json) | ||
| 35 | - .map(|spec| spec.needs) | ||
| 36 | - .unwrap_or_default() | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | /// The expected duration of `job` on `git_ref`, in seconds: the median of its durations in the newest | 26 | /// The expected duration of `job` on `git_ref`, in seconds: the median of its durations in the newest |
| 40 | /// five successful runs on that branch, or in the newest five on any branch when the branch has fewer | 27 | /// five successful runs on that branch, or in the newest five on any branch when the branch has fewer |
| 41 | /// than `MIN_SAMPLES`. None when neither has enough. | 28 | /// than `MIN_SAMPLES`. None when neither has enough. |
crates/forge-web/src/pages/ci_fail.rsmodified+64 -94
| @@ -2,8 +2,6 @@ | |||
| 2 | //! its log around the first error, and a link to that line in the job page's numbered log. Steps are | 2 | //! its log around the first error, and a link to that line in the job page's numbered log. Steps are |
| 3 | //! not stored, so the failed job is the unit. The log is untrusted: its lines are rendered as text. | 3 | //! not stored, so the failed job is the unit. The log is untrusted: its lines are rendered as text. |
| 4 | 4 | ||
| 5 | -use std::ops::Range; | ||
| 6 | - | ||
| 7 | use topcoat::Result; | 5 | use topcoat::Result; |
| 8 | use topcoat::view::{View, component, view}; | 6 | use topcoat::view::{View, component, view}; |
| 9 | 7 | ||
| @@ -16,12 +14,8 @@ use crate::pages::ci_job::log_tail; | |||
| 16 | use crate::pages::ci_runs::{job_href, strip_ansi}; | 14 | use crate::pages::ci_runs::{job_href, strip_ansi}; |
| 17 | use crate::state::AppState; | 15 | use crate::state::AppState; |
| 18 | 16 | ||
| 19 | -/// Most lines the block shows. | 17 | +/// How far after the first error line its reason and place are looked for. |
| 20 | const WINDOW: usize = 30; | 18 | const WINDOW: usize = 30; |
| 21 | -/// Lines kept before the first error. | ||
| 22 | -const BEFORE: usize = 5; | ||
| 23 | -/// Lines shown when no line matches an error pattern. | ||
| 24 | -const FALLBACK: usize = 20; | ||
| 25 | /// Patterns that mark an error line. Matching is case-sensitive, which keeps prose such as "error | 19 | /// Patterns that mark an error line. Matching is case-sensitive, which keeps prose such as "error |
| 26 | /// handling" out. `FAILED` also covers `test result: FAILED`. | 20 | /// handling" out. `FAILED` also covers `test result: FAILED`. |
| 27 | const PATTERNS: [&str; 6] = [ | 21 | const PATTERNS: [&str; 6] = [ |
| @@ -40,28 +34,6 @@ fn first_error(lines: &[String]) -> Option<usize> { | |||
| 40 | .position(|line| PATTERNS.iter().any(|pattern| line.contains(pattern))) | 34 | .position(|line| PATTERNS.iter().any(|pattern| line.contains(pattern))) |
| 41 | } | 35 | } |
| 42 | 36 | ||
| 43 | -/// The indices of the lines to show for a failed step's log: at most 30 lines, starting 5 lines before | ||
| 44 | -/// the first line that matches an error pattern. With no match, the last 20 lines. | ||
| 45 | -pub(crate) fn error_range(lines: &[String]) -> Range<usize> { | ||
| 46 | - let len = lines.len(); | ||
| 47 | - match first_error(lines) { | ||
| 48 | - Some(hit) => { | ||
| 49 | - let start = hit.saturating_sub(BEFORE).min(len.saturating_sub(WINDOW)); | ||
| 50 | - start..(start + WINDOW).min(len) | ||
| 51 | - } | ||
| 52 | - None => len.saturating_sub(FALLBACK)..len, | ||
| 53 | - } | ||
| 54 | -} | ||
| 55 | - | ||
| 56 | -/// One shown line: its number in the whole job log, its text without ANSI codes, and whether it is | ||
| 57 | -/// the first error. | ||
| 58 | -#[derive(Clone)] | ||
| 59 | -pub(crate) struct FailLine { | ||
| 60 | - no: u64, | ||
| 61 | - text: String, | ||
| 62 | - hit: bool, | ||
| 63 | -} | ||
| 64 | - | ||
| 65 | /// The values of the failure block, read once per run page. | 37 | /// The values of the failure block, read once per run page. |
| 66 | #[derive(Clone)] | 38 | #[derive(Clone)] |
| 67 | pub(crate) struct FailFirst { | 39 | pub(crate) struct FailFirst { |
| @@ -71,7 +43,30 @@ pub(crate) struct FailFirst { | |||
| 71 | has_log: bool, | 43 | has_log: bool, |
| 72 | /// The job's number for the first error line, when a line matched. | 44 | /// The job's number for the first error line, when a line matched. |
| 73 | line_no: Option<u64>, | 45 | line_no: Option<u64>, |
| 74 | - lines: Vec<FailLine>, | 46 | + /// The first error line itself, when the job has no message of its own. |
| 47 | + error: Option<String>, | ||
| 48 | + /// Where the error points, `file:line`, from the lines right after it. | ||
| 49 | + place: Option<String>, | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +impl FailFirst { | ||
| 53 | + /// The log line the page opens at. | ||
| 54 | + pub(crate) fn line_no(&self) -> Option<u64> { | ||
| 55 | + self.line_no | ||
| 56 | + } | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +/// The `file:line` in a compiler's or test's lines around an error: the first word that ends in | ||
| 60 | +/// digits after a colon and holds a dot. | ||
| 61 | +fn place_in(lines: &[String]) -> Option<String> { | ||
| 62 | + lines.iter().flat_map(|line| line.split_whitespace()).find_map(|word| { | ||
| 63 | + let word = word.trim_matches(|c: char| matches!(c, '(' | ')' | ',')); | ||
| 64 | + let mut parts = word.split(':'); | ||
| 65 | + let file = parts.next()?; | ||
| 66 | + let line = parts.next()?; | ||
| 67 | + (file.contains('.') && !file.contains("::") && !line.is_empty() && line.bytes().all(|b| b.is_ascii_digit())) | ||
| 68 | + .then(|| format!("{}:{line}", file.rsplit('/').next().unwrap_or(file))) | ||
| 69 | + }) | ||
| 75 | } | 70 | } |
| 76 | 71 | ||
| 77 | /// Reads the failed job's log tail (the same bounded read as the job page) and picks the lines to show. | 72 | /// 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( | |||
| 88 | all.pop(); | 83 | all.pop(); |
| 89 | } | 84 | } |
| 90 | let hit = first_error(&all); | 85 | let hit = first_error(&all); |
| 91 | - let range = error_range(&all); | 86 | + // A test's FAILED line is followed by the error that says why, so the later `error:` reads better. |
| 92 | - let start = range.start; | 87 | + let reason = hit.map(|index| { |
| 93 | - let lines = all[range] | 88 | + all[index..] |
| 94 | - .iter() | 89 | + .iter() |
| 95 | - .enumerate() | 90 | + .take(WINDOW) |
| 96 | - .map(|(k, text)| { | 91 | + .find(|line| line.trim_start().starts_with("error")) |
| 97 | - let index = start + k; | 92 | + .unwrap_or(&all[index]) |
| 98 | - FailLine { | 93 | + .trim() |
| 99 | - no: tail.first_line + index as u64, | 94 | + .to_owned() |
| 100 | - text: text.clone(), | 95 | + }); |
| 101 | - hit: hit == Some(index), | 96 | + let place = hit.and_then(|index| place_in(&all[index..(index + WINDOW).min(all.len())])); |
| 102 | - } | ||
| 103 | - }) | ||
| 104 | - .collect(); | ||
| 105 | Ok(FailFirst { | 97 | Ok(FailFirst { |
| 106 | job_name: job_name.to_owned(), | 98 | job_name: job_name.to_owned(), |
| 107 | job_href: job_href(title, job_id), | 99 | job_href: job_href(title, job_id), |
| 108 | message: message.to_owned(), | 100 | message: message.to_owned(), |
| 109 | has_log: !all.is_empty(), | 101 | has_log: !all.is_empty(), |
| 110 | line_no: hit.map(|index| tail.first_line + index as u64), | 102 | line_no: hit.map(|index| tail.first_line + index as u64), |
| 111 | - lines, | 103 | + error: reason, |
| 104 | + place, | ||
| 112 | }) | 105 | }) |
| 113 | } | 106 | } |
| 114 | 107 | ||
| 115 | -/// The failure block. The job's name links to its page; the first error links to its line there. | 108 | +/// The failure row, pinned above the log, which opens at the first error line: why it failed, the |
| 109 | +/// place in the code, and a link to that line in the job's log. | ||
| 116 | #[component] | 110 | #[component] |
| 117 | pub(crate) async fn fail_first_block(lang: Lang, fail: FailFirst) -> Result<impl View> { | 111 | pub(crate) async fn fail_first_block(lang: Lang, fail: FailFirst) -> Result<impl View> { |
| 118 | let line_href = fail.line_no.map(|no| format!("{}#L{no}", fail.job_href)); | 112 | let line_href = fail.line_no.map(|no| format!("{}#L{no}", fail.job_href)); |
| 113 | + let why = if fail.message.is_empty() { | ||
| 114 | + fail.error.clone().unwrap_or_else(|| fail.job_name.clone()) | ||
| 115 | + } else { | ||
| 116 | + fail.message.clone() | ||
| 117 | + }; | ||
| 119 | Ok(view! { | 118 | Ok(view! { |
| 120 | - <section class="fail-first" data-fail-first="true"> | 119 | + <div class="why" data-fail-first="true"> |
| 121 | - <p class="fail-first-head"> | 120 | + <span>(why.as_str())</span> |
| 122 | - <span class="fail-first-tag">(g::t(lang, K::FailHeading))</span> | 121 | + if let Some(place) = fail.place.as_ref() { |
| 123 | - " " <a href=(fail.job_href.as_str())>(fail.job_name.as_str())</a> | 122 | + <code>(place.as_str())</code> |
| 124 | - </p> | 123 | + } |
| 125 | - if !fail.message.is_empty() { | 124 | + if let Some(href) = line_href.as_ref() { |
| 126 | - <p class="fail-first-msg">(fail.message.as_str())</p> | 125 | + <a class="act danger" href=(href.as_str())>(g::t(lang, K::FailOpenLog))</a> |
| 127 | } | 126 | } |
| 128 | if !fail.has_log { | 127 | if !fail.has_log { |
| 129 | - <p class="muted small">(g::t(lang, K::FailNoLog))</p> | 128 | + <span class="hint">(g::t(lang, K::FailNoLog))</span> |
| 130 | - } else { | 129 | + } else if line_href.is_none() { |
| 131 | - if let (Some(href), Some(no)) = (line_href.as_ref(), fail.line_no) { | 130 | + <span class="hint">(g::t(lang, K::FailNoError))</span> |
| 132 | - <p class="small"><a href=(href.as_str())>(g::t(lang, K::FailOpenLog))</a> " \u{b7} " (g::t(lang, K::FailLine)) " " (no)</p> | ||
| 133 | - } else { | ||
| 134 | - <p class="muted small">(g::t(lang, K::FailNoError))</p> | ||
| 135 | - } | ||
| 136 | - <div class="fail-first-log"> | ||
| 137 | - for line in fail.lines.iter() { | ||
| 138 | - <div class=(if line.hit { "fail-first-ln fail-first-hit" } else { "fail-first-ln" })><i>(line.no)</i><span>(line.text.as_str())</span></div> | ||
| 139 | - } | ||
| 140 | - </div> | ||
| 141 | } | 131 | } |
| 142 | - </section> | 132 | + </div> |
| 143 | }) | 133 | }) |
| 144 | } | 134 | } |
| 145 | 135 | ||
| 146 | #[cfg(test)] | 136 | #[cfg(test)] |
| 147 | mod tests { | 137 | mod tests { |
| 148 | - use super::{FALLBACK, WINDOW, error_range}; | 138 | + use super::place_in; |
| 149 | - | ||
| 150 | - fn lines(count: usize) -> Vec<String> { | ||
| 151 | - (0..count).map(|i| format!("line {i}")).collect() | ||
| 152 | - } | ||
| 153 | - | ||
| 154 | - #[test] | ||
| 155 | - fn the_first_error_opens_a_window_of_at_most_thirty_lines() { | ||
| 156 | - let mut log = lines(40); | ||
| 157 | - log[12] = "error[E0425]: cannot find value".to_owned(); | ||
| 158 | - log[20] = "error: later one".to_owned(); | ||
| 159 | - let range = error_range(&log); | ||
| 160 | - assert_eq!(range, 7..37); | ||
| 161 | - assert!(range.len() <= WINDOW); | ||
| 162 | - assert!(range.contains(&12)); | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | - #[test] | ||
| 166 | - fn a_match_near_the_end_keeps_a_full_window() { | ||
| 167 | - let mut log = lines(40); | ||
| 168 | - log[39] = "thread 'x' panicked at src/lib.rs:3".to_owned(); | ||
| 169 | - assert_eq!(error_range(&log), 10..40); | ||
| 170 | - } | ||
| 171 | 139 | ||
| 172 | #[test] | 140 | #[test] |
| 173 | - fn without_an_error_the_last_lines_are_shown() { | 141 | + fn the_place_of_an_error_is_its_file_and_line() { |
| 174 | - let log = lines(100); | 142 | + let lines = [ |
| 175 | - assert_eq!(error_range(&log), (100 - FALLBACK)..100); | 143 | + "error: stream closed".to_owned(), |
| 176 | - assert_eq!(error_range(&lines(5)), 0..5); | 144 | + " --> crates/forge-e2e/tests/e2e/wiki_e2e.rs:212:9".to_owned(), |
| 177 | - assert_eq!(error_range(&[]), 0..0); | 145 | + ]; |
| 146 | + assert_eq!(place_in(&lines).as_deref(), Some("wiki_e2e.rs:212")); | ||
| 147 | + assert_eq!(place_in(&["test a::b::c ... FAILED".to_owned()]), None); | ||
| 178 | } | 148 | } |
| 179 | } | 149 | } |
crates/forge-web/src/pages/ci_job.rsmodified+79 -81
| @@ -38,7 +38,6 @@ use crate::pages::ci_runs::{ | |||
| 38 | age_text, can_write, changed_event, commit_reachable_for, dock_bars, duration_text, | 38 | age_text, can_write, changed_event, commit_reachable_for, dock_bars, duration_text, |
| 39 | events_response, job_href, run_href, state_text, strip_ansi, | 39 | events_response, job_href, run_href, state_text, strip_ansi, |
| 40 | }; | 40 | }; |
| 41 | -use crate::pages::repo::repo_head; | ||
| 42 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable}; | 41 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable}; |
| 43 | use crate::state::AppState; | 42 | use crate::state::AppState; |
| 44 | use crate::views::timeline::{StripBar, history_strip}; | 43 | use crate::views::timeline::{StripBar, history_strip}; |
| @@ -433,93 +432,92 @@ async fn job_body( | |||
| 433 | repo: String, | 432 | repo: String, |
| 434 | bars: Vec<StripBar>, | 433 | bars: Vec<StripBar>, |
| 435 | ) -> Result<impl View> { | 434 | ) -> Result<impl View> { |
| 435 | + let archived = head.archived; | ||
| 436 | Ok(view! { | 436 | Ok(view! { |
| 437 | - repo_head(head: RepoHead { live: String::new(), ..head }) | 437 | + if archived { |
| 438 | - <div data-live=(live.as_str()) data-live-state=(job.fingerprint.as_str()) class="ci-job fit-pane"> | 438 | + <p class="state" role="status">(crate::i18n::code::t(lang, crate::i18n::code::K::ArchivedNotice))</p> |
| 439 | - <header class="ci-tl-head"> | 439 | + } |
| 440 | - <div class="ci-tl-headmain"> | 440 | + <div data-live=(live.as_str()) data-live-state=(job.fingerprint.as_str()) class="ci-job"> |
| 441 | - <div class="ci-tl-line"> | 441 | + <section class="head"> |
| 442 | - <span class="ci-tl-no"><a href=(job.run_href.as_str())>(g::t(lang, K::RunNumber)) (job.run_number)</a></span> | 442 | + <div class="head-title"> |
| 443 | - <h2 class="ci-tl-title ci-job-title">(job.name.as_str())</h2> | 443 | + <h1>(job.name.as_str())</h1> |
| 444 | - if let Some((action, csrf)) = job.rerun.as_ref() { | 444 | + if let Some((action, csrf)) = job.rerun.as_ref() { |
| 445 | - <div class="acts ci-tl-actions"> | 445 | + <form method="post" action=(action.as_str()) class="act-form"> |
| 446 | - <form method="post" action=(action.as_str()) class="act-form"> | 446 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 447 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 447 | + <button type="submit" class="primary" data-palette-action="post">(g::t(lang, K::RerunJob))</button> |
| 448 | - <button type="submit" class="act" data-palette-action="post">(g::t(lang, K::RerunJob))</button> | 448 | + </form> |
| 449 | - </form> | 449 | + } |
| 450 | - </div> | 450 | + </div> |
| 451 | - } | 451 | + <p class="head-sub"> |
| 452 | - </div> | 452 | + <a href=(job.run_href.as_str())>(g::t(lang, K::RunNumber)) " " (job.run_number)</a> |
| 453 | - <div class="ci-tl-meta"> | 453 | + <span class="sep" aria-hidden="true">"·"</span> |
| 454 | - <span class=(job.state_class.as_str())>(job.state.as_str())</span> | 454 | + <span class=(job.state_class.as_str())>(job.state.as_str())</span> |
| 455 | - if !job.runner.is_empty() { | 455 | + if !job.runner.is_empty() { |
| 456 | - <span class="muted">(g::t(lang, K::Runner)) " " (job.runner.as_str())</span> | 456 | + <span class="sep" aria-hidden="true">"·"</span> |
| 457 | - } | 457 | + <span>(g::t(lang, K::Runner)) " " (job.runner.as_str())</span> |
| 458 | - if !job.exit_code.is_empty() { | 458 | + } |
| 459 | - <span class="muted">(g::t(lang, K::Exit)) " " (job.exit_code.as_str())</span> | 459 | + if !job.exit_code.is_empty() { |
| 460 | - } | 460 | + <span class="sep" aria-hidden="true">"·"</span> |
| 461 | - if !job.duration.is_empty() { | 461 | + <span>(g::t(lang, K::Exit)) " " (job.exit_code.as_str())</span> |
| 462 | - <span class="ci-tl-dur">(g::t(lang, K::Duration)) " " (job.duration.as_str())</span> | 462 | + } |
| 463 | - } | 463 | + if !job.duration.is_empty() { |
| 464 | + <span class="sep" aria-hidden="true">"·"</span> | ||
| 465 | + <span class="ci-tl-dur">(g::t(lang, K::Duration)) " " (job.duration.as_str())</span> | ||
| 466 | + } | ||
| 467 | + if !job.started.is_empty() { | ||
| 468 | + <span class="sep" aria-hidden="true">"·"</span> | ||
| 469 | + <span>(g::t(lang, K::Started)) " " <time datetime=(job.started_full.as_str()) data-rel="true" title=(full_date(job.started_full.as_str()))>(job.started.as_str())</time></span> | ||
| 470 | + } | ||
| 471 | + if !job.finished.is_empty() { | ||
| 472 | + <span class="sep" aria-hidden="true">"·"</span> | ||
| 473 | + <span>(g::t(lang, K::Finished)) " " <time datetime=(job.finished_full.as_str()) data-rel="true" title=(full_date(job.finished_full.as_str()))>(job.finished.as_str())</time></span> | ||
| 474 | + } | ||
| 475 | + </p> | ||
| 476 | + </section> | ||
| 477 | + <div class="sheet ci-tl-log"> | ||
| 478 | + <div class="sheet-tools ci-logbar ci-tl-logbar"> | ||
| 479 | + <strong>(g::t(lang, K::Log))</strong> | ||
| 480 | + <div class="ci-tl-tools"> | ||
| 481 | + <input type="search" class="ci-logsearch" data-log-q="true" placeholder=(g::t(lang, K::LogSearch)) aria-label=(g::t(lang, K::LogSearch)) autocomplete="off" spellcheck="false"> | ||
| 482 | + <span class="ci-logcount" data-log-count="true" data-none=(g::t(lang, K::LogNoMatches)) aria-live="polite"></span> | ||
| 483 | + <button type="button" class="act" data-log-prev="true" aria-label=(g::t(lang, K::LogPrev)) title=(g::t(lang, K::LogPrev))>"\u{2191}"</button> | ||
| 484 | + <button type="button" class="act" data-log-next="true" aria-label=(g::t(lang, K::LogNext)) title=(g::t(lang, K::LogNext))>"\u{2193}"</button> | ||
| 485 | + <button type="button" class="act" data-copy-log=(job.log_href.as_str()) data-palette-action="click" data-copied=(g::t(lang, K::CopyDone)) data-failed=(g::t(lang, K::CopyFailed))>(g::t(lang, K::CopyLog))</button> | ||
| 486 | + <a class="act" href=(job.log_href.as_str())>(g::t(lang, K::FullLog))</a> | ||
| 487 | + <span class="ci-logfold" data-log-fold-box="true" hidden="hidden"> | ||
| 488 | + <button type="button" class="act" data-log-fold="close">(g::t(lang, K::LogCollapseAll))</button> | ||
| 489 | + <button type="button" class="act" data-log-fold="open">(g::t(lang, K::LogExpandAll))</button> | ||
| 490 | + </span> | ||
| 464 | </div> | 491 | </div> |
| 465 | </div> | 492 | </div> |
| 466 | - </header> | 493 | + if !job.message.is_empty() { |
| 467 | - <div class="ci-tl-main"> | 494 | + <p class="why"><span>(job.message.as_str())</span></p> |
| 468 | - <section class="ci-pane ci-tl-jobs"> | 495 | + } |
| 469 | - <h2 class="ci-tl-label">(crate::pages::passkeys::s(lang, "Details", "Ayrıntılar"))</h2> | 496 | + if let Some(kills) = job.oom_kills { |
| 470 | - <div class="ci-tl-pad ci-tl-facts"> | 497 | + <p class="alert" title=(format!("oom_kill {kills}"))>(if matches!(lang, Lang::Tr) { "sonlandırıldı: bellek yetersiz" } else { "killed: out of memory" })</p> |
| 471 | - if !job.started.is_empty() { | 498 | + } |
| 472 | - <p class="muted small">(g::t(lang, K::Started)) " " <time datetime=(job.started_full.as_str()) data-rel="true" title=(full_date(job.started_full.as_str()))>(job.started.as_str())</time></p> | 499 | + if truncated { |
| 473 | - } | 500 | + <p class="hint">(g::t(lang, K::LogTruncated))</p> |
| 474 | - if !job.finished.is_empty() { | 501 | + } |
| 475 | - <p class="muted small">(g::t(lang, K::Finished)) " " <time datetime=(job.finished_full.as_str()) data-rel="true" title=(full_date(job.finished_full.as_str()))>(job.finished.as_str())</time></p> | 502 | + <pre class="ci-log ci-tl-code" data-live-log="true" data-offset=(log_offset.as_str()) data-first=(first_line.as_str())>(log.as_str())</pre> |
| 476 | - } | 503 | + if !artifacts.is_empty() { |
| 477 | - if !job.message.is_empty() { | 504 | + <div class="sec"> |
| 478 | - <p>(job.message.as_str())</p> | 505 | + <h2>(g::t(lang, K::Artifacts))</h2> |
| 479 | - } | 506 | + for artifact in artifacts.iter() { |
| 480 | - if let Some(kills) = job.oom_kills { | 507 | + <div class="line"> |
| 481 | - <p class="alert" title=(format!("oom_kill {kills}"))>(if matches!(lang, Lang::Tr) { "sonlandırıldı: bellek yetersiz" } else { "killed: out of memory" })</p> | 508 | + <span class="name"><a href=(artifact.href.as_str())>(artifact.name.as_str())</a></span> |
| 509 | + <span class="val">(artifact.size.as_str())</span> | ||
| 510 | + </div> | ||
| 482 | } | 511 | } |
| 483 | </div> | 512 | </div> |
| 484 | - if !artifacts.is_empty() { | 513 | + } |
| 485 | - <h3 class="ci-tl-label ci-tl-pad">(g::t(lang, K::Artifacts))</h3> | 514 | + <div class="sec ci-dock"> |
| 486 | - <ul class="ci-artifacts ci-tl-pad"> | 515 | + <p class="hint">(crate::pages::passkeys::s(lang, "bar height is lines changed", "çubuk yüksekliği değişen satır sayısıdır"))</p> |
| 487 | - for artifact in artifacts.iter() { | 516 | + <div class="dock-history"> |
| 488 | - <li><a href=(artifact.href.as_str())>(artifact.name.as_str())</a> " (" (artifact.size.as_str()) ")"</li> | 517 | + history_strip(lang: lang, owner: owner, repo: repo, bars: bars) |
| 489 | - } | ||
| 490 | - </ul> | ||
| 491 | - } | ||
| 492 | - </section> | ||
| 493 | - <section class="ci-pane ci-tl-log"> | ||
| 494 | - <div class="ci-logbar ci-tl-logbar"> | ||
| 495 | - <div class="ci-tl-tabs"> | ||
| 496 | - <span class="ci-tl-label ci-tl-tab-log">(g::t(lang, K::Log))</span> | ||
| 497 | - </div> | ||
| 498 | - <div class="ci-tl-tools"> | ||
| 499 | - <input type="search" class="ci-logsearch" data-log-q="true" placeholder=(g::t(lang, K::LogSearch)) aria-label=(g::t(lang, K::LogSearch)) autocomplete="off" spellcheck="false"> | ||
| 500 | - <span class="ci-logcount" data-log-count="true" data-none=(g::t(lang, K::LogNoMatches)) aria-live="polite"></span> | ||
| 501 | - <button type="button" class="act" data-log-prev="true" aria-label=(g::t(lang, K::LogPrev)) title=(g::t(lang, K::LogPrev))>"\u{2191}"</button> | ||
| 502 | - <button type="button" class="act" data-log-next="true" aria-label=(g::t(lang, K::LogNext)) title=(g::t(lang, K::LogNext))>"\u{2193}"</button> | ||
| 503 | - <button type="button" class="act" data-copy-log=(job.log_href.as_str()) data-palette-action="click" data-copied=(g::t(lang, K::CopyDone)) data-failed=(g::t(lang, K::CopyFailed))>(g::t(lang, K::CopyLog))</button> | ||
| 504 | - <a class="act" href=(job.log_href.as_str())>(g::t(lang, K::FullLog))</a> | ||
| 505 | - <span class="ci-logfold" data-log-fold-box="true" hidden="hidden"> | ||
| 506 | - <button type="button" class="act" data-log-fold="close">(g::t(lang, K::LogCollapseAll))</button> | ||
| 507 | - <button type="button" class="act" data-log-fold="open">(g::t(lang, K::LogExpandAll))</button> | ||
| 508 | - </span> | ||
| 509 | - </div> | ||
| 510 | </div> | 518 | </div> |
| 511 | - if truncated { | ||
| 512 | - <p class="muted small ci-tl-pad">(g::t(lang, K::LogTruncated))</p> | ||
| 513 | - } | ||
| 514 | - <pre class="ci-log ci-tl-code" data-live-log="true" data-offset=(log_offset.as_str()) data-first=(first_line.as_str())>(log.as_str())</pre> | ||
| 515 | - </section> | ||
| 516 | - </div> | ||
| 517 | - <section class="ci-pane ci-dock"> | ||
| 518 | - <p class="ci-dock-note">(crate::pages::passkeys::s(lang, "bar height is lines changed", "çubuk yüksekliği değişen satır sayısıdır"))</p> | ||
| 519 | - <div class="dock-history"> | ||
| 520 | - history_strip(lang: lang, owner: owner, repo: repo, bars: bars) | ||
| 521 | </div> | 519 | </div> |
| 522 | - </section> | 520 | + </div> |
| 523 | </div> | 521 | </div> |
| 524 | }) | 522 | }) |
| 525 | } | 523 | } |
crates/forge-web/src/pages/ci_runs.rsmodified+411 -369
| @@ -48,7 +48,7 @@ use crate::pages::repo::repo_head; | |||
| 48 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable}; | 48 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable}; |
| 49 | use crate::pages::repo_side::{commit_strip, run_states, strip_bars}; | 49 | use crate::pages::repo_side::{commit_strip, run_states, strip_bars}; |
| 50 | use crate::state::AppState; | 50 | use crate::state::AppState; |
| 51 | -use crate::views::commit_line::{commit_line, headline}; | 51 | +use crate::views::commit_line::commit_line; |
| 52 | use crate::views::timeline::{StripBar, history_strip}; | 52 | use crate::views::timeline::{StripBar, history_strip}; |
| 53 | use crate::views::{ | 53 | use crate::views::{ |
| 54 | alert, empty_state, enc, human_size, now_unix, rel_time, relative_time, shell, short_oid, | 54 | 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< | |||
| 203 | return String::new(); | 203 | return String::new(); |
| 204 | }; | 204 | }; |
| 205 | let end = finished.and_then(unix_of).unwrap_or_else(now_unix); | 205 | let end = finished.and_then(unix_of).unwrap_or_else(now_unix); |
| 206 | - let secs = (end - start).max(0); | 206 | + secs_text(lang, (end - start).max(0)) |
| 207 | +} | ||
| 208 | + | ||
| 209 | +/// A length of time as the CI pages write it: minutes and seconds, or seconds alone under a minute. | ||
| 210 | +fn secs_text(lang: Lang, secs: i64) -> String { | ||
| 207 | if secs >= 60 { | 211 | if secs >= 60 { |
| 208 | g::duration_minutes(lang, secs / 60, secs % 60) | 212 | g::duration_minutes(lang, secs / 60, secs % 60) |
| 209 | } else { | 213 | } else { |
| @@ -249,6 +253,48 @@ pub fn run_finished(state: &RunState) -> bool { | |||
| 249 | ) | 253 | ) |
| 250 | } | 254 | } |
| 251 | 255 | ||
| 256 | +/// The run page's headline, a sentence about the state: `Failed in <job>`, `Running <job>`, `Passed in | ||
| 257 | +/// <took>`. Returns the class it takes: `bad` for a failure, `live` while running, else none. | ||
| 258 | +fn run_headline(lang: Lang, state: RunState, job: &str, took: &str) -> (String, &'static str) { | ||
| 259 | + let (text, class) = run_headline_text(lang, state, job, took); | ||
| 260 | + // A state word alone is a sentence here, so it starts with a capital: `Queued`, not `queued`. | ||
| 261 | + let mut chars = text.chars(); | ||
| 262 | + let text = match chars.next() { | ||
| 263 | + Some(first) => first.to_uppercase().chain(chars).collect(), | ||
| 264 | + None => text, | ||
| 265 | + }; | ||
| 266 | + (text, class) | ||
| 267 | +} | ||
| 268 | + | ||
| 269 | +fn run_headline_text(lang: Lang, state: RunState, job: &str, took: &str) -> (String, &'static str) { | ||
| 270 | + match state { | ||
| 271 | + RunState::Failure | RunState::Error => { | ||
| 272 | + let text = match (lang, job.is_empty()) { | ||
| 273 | + (_, true) => state_text(lang, state.as_str()), | ||
| 274 | + (Lang::Tr, false) => format!("{job} başarısız"), | ||
| 275 | + (Lang::En, false) => format!("Failed in {job}"), | ||
| 276 | + }; | ||
| 277 | + (text, "bad") | ||
| 278 | + } | ||
| 279 | + RunState::Running => { | ||
| 280 | + let text = match (lang, job.is_empty()) { | ||
| 281 | + (_, true) => state_text(lang, state.as_str()), | ||
| 282 | + (Lang::Tr, false) => format!("{job} çalışıyor"), | ||
| 283 | + (Lang::En, false) => format!("Running {job}"), | ||
| 284 | + }; | ||
| 285 | + (text, "live") | ||
| 286 | + } | ||
| 287 | + RunState::Success if !took.is_empty() => { | ||
| 288 | + let text = match lang { | ||
| 289 | + Lang::Tr => format!("{took} içinde geçti"), | ||
| 290 | + Lang::En => format!("Passed in {took}"), | ||
| 291 | + }; | ||
| 292 | + (text, "") | ||
| 293 | + } | ||
| 294 | + _ => (state_text(lang, state.as_str()), ""), | ||
| 295 | + } | ||
| 296 | +} | ||
| 297 | + | ||
| 252 | /// A ref as the lists show it: `refs/heads/main` reads `main`, and so does a tag without its prefix. | 298 | /// A ref as the lists show it: `refs/heads/main` reads `main`, and so does a tag without its prefix. |
| 253 | fn short_ref(git_ref: &str) -> &str { | 299 | fn short_ref(git_ref: &str) -> &str { |
| 254 | git_ref | 300 | git_ref |
| @@ -350,6 +396,8 @@ struct RunRow { | |||
| 350 | duration: String, | 396 | duration: String, |
| 351 | /// Unix seconds the duration counts from while the run is live, for the client's local ticker. | 397 | /// Unix seconds the duration counts from while the run is live, for the client's local ticker. |
| 352 | since: Option<String>, | 398 | since: Option<String>, |
| 399 | + /// The state tone of the row's tick: `bad`, `live`, `skip`, `wait` or empty for passed. | ||
| 400 | + tick: &'static str, | ||
| 353 | /// The run's start and the list's scale, which the ticker needs to grow the running segments. | 401 | /// The run's start and the list's scale, which the ticker needs to grow the running segments. |
| 354 | origin: String, | 402 | origin: String, |
| 355 | scale: String, | 403 | scale: String, |
| @@ -424,15 +472,13 @@ struct JobLine { | |||
| 424 | /// The job's steps, a dropdown under its row. Every job has its lines; only the selected job's | 472 | /// The job's steps, a dropdown under its row. Every job has its lines; only the selected job's |
| 425 | /// step carries the log's mark. | 473 | /// step carries the log's mark. |
| 426 | steps: Vec<StepLine>, | 474 | steps: Vec<StepLine>, |
| 427 | - /// The job's bar along the bottom of its row: one segment per step. Empty for a job with no steps. | 475 | + /// The state tone of the job's tick: `bad`, `live`, `done` or empty. |
| 428 | - step_bar: Vec<Rect>, | 476 | + tick: &'static str, |
| 429 | } | 477 | } |
| 430 | 478 | ||
| 431 | /// One step of a job, drawn as a line under its row in the jobs pane. | 479 | /// One step of a job, drawn as a line under its row in the jobs pane. |
| 432 | struct StepLine { | 480 | struct StepLine { |
| 433 | name: String, | 481 | name: String, |
| 434 | - /// The classes of the step's mark, which carry its state's colour. | ||
| 435 | - mark: &'static str, | ||
| 436 | duration: String, | 482 | duration: String, |
| 437 | /// Unix seconds a running step's duration counts from. | 483 | /// Unix seconds a running step's duration counts from. |
| 438 | since: Option<String>, | 484 | since: Option<String>, |
| @@ -450,6 +496,10 @@ struct StepLine { | |||
| 450 | expected_secs: Option<String>, | 496 | expected_secs: Option<String>, |
| 451 | /// The state class of the step's progress bar, which sets its fill colour. | 497 | /// The state class of the step's progress bar, which sets its fill colour. |
| 452 | state_class: &'static str, | 498 | state_class: &'static str, |
| 499 | + /// The strip segment's tone: `bad`, `live`, `skip` or empty for a passed step. | ||
| 500 | + seg: &'static str, | ||
| 501 | + /// The segment's share of the job's strip, as `fr1`..`fr40`, by the step's duration. | ||
| 502 | + fr: String, | ||
| 453 | } | 503 | } |
| 454 | 504 | ||
| 455 | /// One artifact of the run: its download link, the job that made it, its name and size. | 505 | /// One artifact of the run: its download link, the job that made it, its name and size. |
| @@ -464,8 +514,9 @@ struct ArtifactLine { | |||
| 464 | struct RunDetail { | 514 | struct RunDetail { |
| 465 | number: i64, | 515 | number: i64, |
| 466 | title: String, | 516 | title: String, |
| 467 | - state: String, | 517 | + /// The head's sentence about the state, and its class (`bad`, `live` or empty). |
| 468 | - state_class: String, | 518 | + headline: String, |
| 519 | + headline_class: &'static str, | ||
| 469 | trigger: String, | 520 | trigger: String, |
| 470 | branch: String, | 521 | branch: String, |
| 471 | /// The commit's page. None when a force push overwrote the commit. | 522 | /// The commit's page. None when a force push overwrote the commit. |
| @@ -743,8 +794,6 @@ const STEP_H: i64 = 20; | |||
| 743 | const BAR_DY: i64 = 9; | 794 | const BAR_DY: i64 = 9; |
| 744 | const BAR_H: i64 = 22; | 795 | const BAR_H: i64 = 22; |
| 745 | /// The narrowest segment of a job's step bar, and the gap between segments, in its SVG units. | 796 | /// The narrowest segment of a job's step bar, and the gap between segments, in its SVG units. |
| 746 | -const STEP_BAR_MIN: i64 = 8; | ||
| 747 | -const STEP_BAR_GAP: i64 = 6; | ||
| 748 | /// The narrowest a box is drawn, so a short lead-in or job still shows. | 797 | /// The narrowest a box is drawn, so a short lead-in or job still shows. |
| 749 | const MIN_BOX_W: i64 = 3; | 798 | const MIN_BOX_W: i64 = 3; |
| 750 | /// The most intervals an axis has, so its ticks stay readable. | 799 | /// The most intervals an axis has, so its ticks stay readable. |
| @@ -1318,7 +1367,7 @@ fn step_job_state(state: StepState) -> JobState { | |||
| 1318 | } | 1367 | } |
| 1319 | 1368 | ||
| 1320 | /// The steps of a job as the timeline draws them. A step whose start does not read is left out. | 1369 | /// The steps of a job as the timeline draws them. A step whose start does not read is left out. |
| 1321 | -fn step_spans(steps: &[JobStep], job: JobState) -> Vec<StepSpan> { | 1370 | +fn step_spans(steps: &[JobStep], job: JobState, job_end: Option<i64>) -> Vec<StepSpan> { |
| 1322 | steps | 1371 | steps |
| 1323 | .iter() | 1372 | .iter() |
| 1324 | .filter_map(|step| { | 1373 | .filter_map(|step| { |
| @@ -1326,49 +1375,13 @@ fn step_spans(steps: &[JobStep], job: JobState) -> Vec<StepSpan> { | |||
| 1326 | name: step.name.clone(), | 1375 | name: step.name.clone(), |
| 1327 | state: step_job_state(step.state(job)), | 1376 | state: step_job_state(step.state(job)), |
| 1328 | start: unix_of(&step.started_at)?, | 1377 | start: unix_of(&step.started_at)?, |
| 1329 | - end: step.finished_at.as_deref().and_then(unix_of), | 1378 | + // A step left open ends with its job. |
| 1379 | + end: step.finished_at.as_deref().and_then(unix_of).or(job_end), | ||
| 1330 | }) | 1380 | }) |
| 1331 | }) | 1381 | }) |
| 1332 | .collect() | 1382 | .collect() |
| 1333 | } | 1383 | } |
| 1334 | 1384 | ||
| 1335 | -/// A step's share of its job's bar: its state, its elapsed seconds and, while it runs, its expected ones. | ||
| 1336 | -struct BarStep { | ||
| 1337 | - state: StepState, | ||
| 1338 | - elapsed: i64, | ||
| 1339 | - expected: Option<i64>, | ||
| 1340 | -} | ||
| 1341 | - | ||
| 1342 | -/// The bar along a job's row: one segment per step, as wide as its seconds (a running step counts the | ||
| 1343 | -/// larger of its elapsed and expected seconds), with a gap between segments. A running step with an | ||
| 1344 | -/// estimate is a track of its full width with its elapsed share filled in the accent. | ||
| 1345 | -fn step_bar(steps: &[BarStep]) -> Vec<Rect> { | ||
| 1346 | - let weight = |step: &BarStep| step.expected.unwrap_or(0).max(step.elapsed).max(1); | ||
| 1347 | - let total: i64 = steps.iter().map(weight).sum(); | ||
| 1348 | - let gaps = STEP_BAR_GAP * (steps.len() as i64 - 1).max(0); | ||
| 1349 | - // Every segment gets its least first, so 32 short steps beside a long one still all fit. | ||
| 1350 | - let room = (LIST_BAR_W - gaps - STEP_BAR_MIN * steps.len() as i64).max(0); | ||
| 1351 | - let mut rects = Vec::with_capacity(steps.len() + 1); | ||
| 1352 | - let mut x = 0; | ||
| 1353 | - for step in steps { | ||
| 1354 | - let weight = weight(step); | ||
| 1355 | - let w = STEP_BAR_MIN + weight * room / total; | ||
| 1356 | - match (step.state, step.expected) { | ||
| 1357 | - (StepState::Running, Some(expected)) => { | ||
| 1358 | - rects.push(Rect::new("ci-sbar-track", x, 0, w, 3)); | ||
| 1359 | - let done = step.elapsed.min(expected) * w / weight; | ||
| 1360 | - rects.push(Rect::new("ci-sbar-run", x, 0, done, 3)); | ||
| 1361 | - } | ||
| 1362 | - (StepState::Running, None) => rects.push(Rect::new("ci-sbar-run", x, 0, w, 3)), | ||
| 1363 | - (StepState::Passed, _) => rects.push(Rect::new("ci-sbar-pass", x, 0, w, 3)), | ||
| 1364 | - (StepState::Failed, _) => rects.push(Rect::new("ci-sbar-fail", x, 0, w, 3)), | ||
| 1365 | - (StepState::Cancelled, _) => rects.push(Rect::new("ci-sbar-off", x, 0, w, 3)), | ||
| 1366 | - } | ||
| 1367 | - x += w + STEP_BAR_GAP; | ||
| 1368 | - } | ||
| 1369 | - rects | ||
| 1370 | -} | ||
| 1371 | - | ||
| 1372 | /// The rail's step lines of a job and the bar under its row. Every job gets its lines, the dropdown | 1385 | /// The rail's step lines of a job and the bar under its row. Every job gets its lines, the dropdown |
| 1373 | /// under its row; `wanted` marks the step the log shows and is passed for the selected job only. A | 1386 | /// under its row; `wanted` marks the step the log shows and is passed for the selected job only. A |
| 1374 | /// running step's expected time comes from the repo's step samples. | 1387 | /// running step's expected time comes from the repo's step samples. |
| @@ -1381,25 +1394,31 @@ fn job_steps( | |||
| 1381 | wanted: Option<i64>, | 1394 | wanted: Option<i64>, |
| 1382 | now: i64, | 1395 | now: i64, |
| 1383 | lang: Lang, | 1396 | lang: Lang, |
| 1384 | -) -> (Vec<StepLine>, Vec<Rect>) { | 1397 | +) -> Vec<StepLine> { |
| 1385 | let mut lines = Vec::with_capacity(steps.len()); | 1398 | let mut lines = Vec::with_capacity(steps.len()); |
| 1386 | - let mut bar = Vec::with_capacity(steps.len()); | 1399 | + // A step left open ends with its job: only a step of a job still going runs until now. |
| 1387 | - for step in steps { | 1400 | + let elapsed_of: Vec<i64> = steps |
| 1401 | + .iter() | ||
| 1402 | + .map(|step| { | ||
| 1403 | + unix_of(&step.started_at).map_or(0, |at| { | ||
| 1404 | + let end = step | ||
| 1405 | + .finished_at | ||
| 1406 | + .as_deref() | ||
| 1407 | + .and_then(unix_of) | ||
| 1408 | + .or(job.finished) | ||
| 1409 | + .unwrap_or(now); | ||
| 1410 | + (end - at).max(0) | ||
| 1411 | + }) | ||
| 1412 | + }) | ||
| 1413 | + .collect(); | ||
| 1414 | + let total: u64 = elapsed_of.iter().map(|secs| u64::try_from(*secs).unwrap_or(0)).sum(); | ||
| 1415 | + for (step, elapsed) in steps.iter().zip(elapsed_of) { | ||
| 1388 | let state = step.state(job.state); | 1416 | let state = step.state(job.state); |
| 1389 | let running = state == StepState::Running; | 1417 | let running = state == StepState::Running; |
| 1390 | let started = unix_of(&step.started_at); | 1418 | let started = unix_of(&step.started_at); |
| 1391 | - let elapsed = started.map_or(0, |at| { | ||
| 1392 | - let end = step.finished_at.as_deref().and_then(unix_of).unwrap_or(now); | ||
| 1393 | - (end - at).max(0) | ||
| 1394 | - }); | ||
| 1395 | let expected = running | 1419 | let expected = running |
| 1396 | .then(|| ci_estimate::step_expected(samples, &run.git_ref, &job.name, &step.name)) | 1420 | .then(|| ci_estimate::step_expected(samples, &run.git_ref, &job.name, &step.name)) |
| 1397 | .flatten(); | 1421 | .flatten(); |
| 1398 | - bar.push(BarStep { | ||
| 1399 | - state, | ||
| 1400 | - elapsed, | ||
| 1401 | - expected, | ||
| 1402 | - }); | ||
| 1403 | // A step of a job whose log was pruned has no part of the log to open. | 1422 | // A step of a job whose log was pruned has no part of the log to open. |
| 1404 | let href = (job.log_bytes != 0).then(|| format!("{pick}&step={}", step.seq)); | 1423 | let href = (job.log_bytes != 0).then(|| format!("{pick}&step={}", step.seq)); |
| 1405 | // Only a running step with an estimate has a share; one without is indeterminate, never a guess. | 1424 | // Only a running step with an estimate has a share; one without is indeterminate, never a guess. |
| @@ -1408,17 +1427,11 @@ fn job_steps( | |||
| 1408 | .map(|secs| (elapsed * 100 / secs).min(99).to_string()); | 1427 | .map(|secs| (elapsed * 100 / secs).min(99).to_string()); |
| 1409 | lines.push(StepLine { | 1428 | lines.push(StepLine { |
| 1410 | name: step.name.clone(), | 1429 | name: step.name.clone(), |
| 1411 | - mark: match state { | 1430 | + duration: if started.is_some() { |
| 1412 | - StepState::Passed => "ci-st-pass", | 1431 | + secs_text(lang, elapsed) |
| 1413 | - StepState::Running => "ci-st-run", | 1432 | + } else { |
| 1414 | - StepState::Failed => "ci-st-fail", | 1433 | + String::new() |
| 1415 | - StepState::Cancelled => "ci-st-off", | ||
| 1416 | }, | 1434 | }, |
| 1417 | - duration: duration_text( | ||
| 1418 | - lang, | ||
| 1419 | - Some(step.started_at.as_str()), | ||
| 1420 | - step.finished_at.as_deref(), | ||
| 1421 | - ), | ||
| 1422 | since: started.filter(|_| running).map(|at| at.to_string()), | 1435 | since: started.filter(|_| running).map(|at| at.to_string()), |
| 1423 | expected: expected.map(|secs| format!("~{}", span_text(secs))), | 1436 | expected: expected.map(|secs| format!("~{}", span_text(secs))), |
| 1424 | selected: href.is_some() && wanted == Some(step.seq), | 1437 | selected: href.is_some() && wanted == Some(step.seq), |
| @@ -1438,9 +1451,16 @@ fn job_steps( | |||
| 1438 | StepState::Failed => "ci-sp-fail", | 1451 | StepState::Failed => "ci-sp-fail", |
| 1439 | StepState::Cancelled => "ci-sp-off", | 1452 | StepState::Cancelled => "ci-sp-off", |
| 1440 | }, | 1453 | }, |
| 1454 | + seg: match state { | ||
| 1455 | + StepState::Passed => "", | ||
| 1456 | + StepState::Running => "live", | ||
| 1457 | + StepState::Failed => "bad", | ||
| 1458 | + StepState::Cancelled => "skip", | ||
| 1459 | + }, | ||
| 1460 | + fr: crate::views::parts::seg_fr(u64::try_from(elapsed).unwrap_or(0), total), | ||
| 1441 | }); | 1461 | }); |
| 1442 | } | 1462 | } |
| 1443 | - (lines, step_bar(&bar)) | 1463 | + lines |
| 1444 | } | 1464 | } |
| 1445 | 1465 | ||
| 1446 | /// "test OOM" for a failed run: the first failed job's message, or its name and state. | 1466 | /// "test OOM" for a failed run: the first failed job's message, or its name and state. |
| @@ -1575,11 +1595,16 @@ async fn usernames( | |||
| 1575 | 1595 | ||
| 1576 | /// A small form that POSTs the CSRF token to `action`, with one button. | 1596 | /// A small form that POSTs the CSRF token to `action`, with one button. |
| 1577 | #[component] | 1597 | #[component] |
| 1578 | -async fn action_button(action: String, csrf: String, label: &'static str) -> Result<impl View> { | 1598 | +async fn action_button( |
| 1599 | + action: String, | ||
| 1600 | + csrf: String, | ||
| 1601 | + label: &'static str, | ||
| 1602 | + primary: bool, | ||
| 1603 | +) -> Result<impl View> { | ||
| 1579 | Ok(view! { | 1604 | Ok(view! { |
| 1580 | <form method="post" action=(action.as_str()) class="act-form"> | 1605 | <form method="post" action=(action.as_str()) class="act-form"> |
| 1581 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 1606 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1582 | - <button type="submit" class="act" data-palette-action="post">(label)</button> | 1607 | + <button type="submit" class=(primary.then_some("primary")) data-palette-action="post">(label)</button> |
| 1583 | </form> | 1608 | </form> |
| 1584 | }) | 1609 | }) |
| 1585 | } | 1610 | } |
| @@ -1712,8 +1737,16 @@ async fn runs_split( | |||
| 1712 | names.get(&run.actor_id).cloned().unwrap_or_default() | 1737 | names.get(&run.actor_id).cloned().unwrap_or_default() |
| 1713 | }; | 1738 | }; |
| 1714 | RunRow { | 1739 | RunRow { |
| 1740 | + tick: match run.state { | ||
| 1741 | + RunState::Failure | RunState::Error => "bad", | ||
| 1742 | + RunState::Running => "live", | ||
| 1743 | + RunState::Cancelled => "skip", | ||
| 1744 | + RunState::Queued | RunState::WaitingApproval => "wait", | ||
| 1745 | + _ => "done", | ||
| 1746 | + }, | ||
| 1715 | href: row_href(run.number), | 1747 | href: row_href(run.number), |
| 1716 | - current: if selected.as_ref().is_some_and(|sel| sel.id == run.id) { | 1748 | + // The list page alone draws no run, so it marks none. |
| 1749 | + current: if number.is_some() && selected.as_ref().is_some_and(|sel| sel.id == run.id) { | ||
| 1717 | "true" | 1750 | "true" |
| 1718 | } else { | 1751 | } else { |
| 1719 | "false" | 1752 | "false" |
| @@ -1774,7 +1807,8 @@ async fn runs_split( | |||
| 1774 | } else { | 1807 | } else { |
| 1775 | None | 1808 | None |
| 1776 | }; | 1809 | }; |
| 1777 | - let detail = match selected.as_ref() { | 1810 | + // The list page shows rows only; a run's detail is on its own page. |
| 1811 | + let detail = match number.and(selected.as_ref()) { | ||
| 1778 | Some(run) => { | 1812 | Some(run) => { |
| 1779 | let actor = if run.trigger == "schedule" { | 1813 | let actor = if run.trigger == "schedule" { |
| 1780 | String::new() | 1814 | String::new() |
| @@ -1886,7 +1920,7 @@ async fn run_detail( | |||
| 1886 | for job in jobs.iter_mut() { | 1920 | for job in jobs.iter_mut() { |
| 1887 | let spans = steps_of | 1921 | let spans = steps_of |
| 1888 | .get(&job.id) | 1922 | .get(&job.id) |
| 1889 | - .map_or_else(Vec::new, |steps| step_spans(steps, job.state)); | 1923 | + .map_or_else(Vec::new, |steps| step_spans(steps, job.state, job.finished)); |
| 1890 | job.steps = spans; | 1924 | job.steps = spans; |
| 1891 | } | 1925 | } |
| 1892 | // A running step's expected time is judged from the samples of the run's branch. | 1926 | // A running step's expected time is judged from the samples of the run's branch. |
| @@ -1928,7 +1962,7 @@ async fn run_detail( | |||
| 1928 | } | 1962 | } |
| 1929 | let tail = log_last_lines(&log_path(&state.config.data_dir, &job.id)).await; | 1963 | let tail = log_last_lines(&log_path(&state.config.data_dir, &job.id)).await; |
| 1930 | let pick = format!("{}?job={}", run_href(title, run.number), job.id); | 1964 | let pick = format!("{}?job={}", run_href(title, run.number), job.id); |
| 1931 | - let (steps, step_bar) = job_steps( | 1965 | + let steps = job_steps( |
| 1932 | job, | 1966 | job, |
| 1933 | steps_of.get(&job.id).map(Vec::as_slice).unwrap_or_default(), | 1967 | steps_of.get(&job.id).map(Vec::as_slice).unwrap_or_default(), |
| 1934 | &step_samples, | 1968 | &step_samples, |
| @@ -1960,7 +1994,6 @@ async fn run_detail( | |||
| 1960 | id: job.id.clone(), | 1994 | id: job.id.clone(), |
| 1961 | selected: picked == Some(index), | 1995 | selected: picked == Some(index), |
| 1962 | steps, | 1996 | steps, |
| 1963 | - step_bar, | ||
| 1964 | pick, | 1997 | pick, |
| 1965 | expanded: !tail.is_empty() && starts_expanded(job.state, jobs.len()), | 1998 | expanded: !tail.is_empty() && starts_expanded(job.state, jobs.len()), |
| 1966 | preview, | 1999 | preview, |
| @@ -1971,6 +2004,12 @@ async fn run_detail( | |||
| 1971 | href: job_href(title, &job.id), | 2004 | href: job_href(title, &job.id), |
| 1972 | name: variant.unwrap_or(job.name.as_str()).to_owned(), | 2005 | name: variant.unwrap_or(job.name.as_str()).to_owned(), |
| 1973 | dot: format!("ci-dot ci-{}", job.state.as_str()), | 2006 | dot: format!("ci-dot ci-{}", job.state.as_str()), |
| 2007 | + tick: match job.state { | ||
| 2008 | + JobState::Failure | JobState::Error => "bad", | ||
| 2009 | + JobState::Running => "live", | ||
| 2010 | + JobState::Success => "done", | ||
| 2011 | + _ => "", | ||
| 2012 | + }, | ||
| 1974 | detail: job.image.clone(), | 2013 | detail: job.image.clone(), |
| 1975 | rerun: (rerunnable && job.state.is_terminal()) | 2014 | rerun: (rerunnable && job.state.is_terminal()) |
| 1976 | .then(|| format!("{}/rerun", job_href(title, &job.id))), | 2015 | .then(|| format!("{}/rerun", job_href(title, &job.id))), |
| @@ -2046,11 +2085,24 @@ async fn run_detail( | |||
| 2046 | } | 2085 | } |
| 2047 | _ => None, | 2086 | _ => None, |
| 2048 | }; | 2087 | }; |
| 2088 | + let (headline, headline_class) = run_headline( | ||
| 2089 | + lang, | ||
| 2090 | + run.state, | ||
| 2091 | + // The step that failed or runs says more than its job does. | ||
| 2092 | + picked.map_or("", |index| { | ||
| 2093 | + let job = &lines[index]; | ||
| 2094 | + job.steps | ||
| 2095 | + .iter() | ||
| 2096 | + .find(|step| matches!(step.seg, "bad" | "live")) | ||
| 2097 | + .map_or(job.name.as_str(), |step| step.name.as_str()) | ||
| 2098 | + }), | ||
| 2099 | + &duration_text(lang, Some(run.created_at.as_str()), run.finished_at.as_deref()), | ||
| 2100 | + ); | ||
| 2049 | Ok(RunDetail { | 2101 | Ok(RunDetail { |
| 2050 | number: run.number, | 2102 | number: run.number, |
| 2051 | title: header.title, | 2103 | title: header.title, |
| 2052 | - state: state_text(lang, run.state.as_str()), | 2104 | + headline, |
| 2053 | - state_class: format!("ci-state ci-{}", run.state.as_str()), | 2105 | + headline_class, |
| 2054 | trigger: trigger_text(lang, &run.trigger), | 2106 | trigger: trigger_text(lang, &run.trigger), |
| 2055 | branch: short_ref(&run.git_ref).to_owned(), | 2107 | branch: short_ref(&run.git_ref).to_owned(), |
| 2056 | commit_href: header | 2108 | commit_href: header |
| @@ -2124,13 +2176,50 @@ fn query_value(cx: &Cx, key: &str) -> Option<String> { | |||
| 2124 | .map(|(_, value)| value.into_owned()) | 2176 | .map(|(_, value)| value.into_owned()) |
| 2125 | } | 2177 | } |
| 2126 | 2178 | ||
| 2127 | -/// The runs list: its head with the Run workflow and badge menus, the rows and the pager. The list page | 2179 | +/// The Run workflow and badge menus of the runs list. They sit in the list's head, beside its title. |
| 2128 | -/// and a run's page both keep it at the left, so moving between runs never loses it. | ||
| 2129 | #[component] | 2180 | #[component] |
| 2130 | -async fn run_side(lang: Lang, list: ListView) -> Result<impl View> { | 2181 | +async fn ci_menus(lang: Lang, list: &ListView) -> Result<impl View> { |
| 2182 | + let badge = &list.badge; | ||
| 2183 | + Ok(view! { | ||
| 2184 | + if let Some(form) = list.manual.as_ref() { | ||
| 2185 | + <details class="menu ci-tool"> | ||
| 2186 | + <summary>(g::t(lang, K::RunWorkflow))</summary> | ||
| 2187 | + <div class="menu-list ci-pop"> | ||
| 2188 | + <p class="muted small">(g::t(lang, K::RunWorkflowHelp))</p> | ||
| 2189 | + <form method="post" action=(form.action.as_str()) class="ci-manual-form"> | ||
| 2190 | + <input type="hidden" name="csrf" value=(form.csrf.as_str())> | ||
| 2191 | + <label> | ||
| 2192 | + (g::t(lang, K::Branch)) " " | ||
| 2193 | + <select name="branch"> | ||
| 2194 | + for branch in form.branches.iter() { | ||
| 2195 | + <option value=(branch.as_str())>(branch.as_str())</option> | ||
| 2196 | + } | ||
| 2197 | + </select> | ||
| 2198 | + </label> | ||
| 2199 | + <button type="submit" class="primary">(g::t(lang, K::RunWorkflow))</button> | ||
| 2200 | + </form> | ||
| 2201 | + </div> | ||
| 2202 | + </details> | ||
| 2203 | + } | ||
| 2204 | + <details class="menu ci-tool"> | ||
| 2205 | + <summary>(g::t(lang, K::BadgeHeading))</summary> | ||
| 2206 | + <div class="menu-list ci-pop"> | ||
| 2207 | + <p class="muted small">(g::t(lang, K::BadgeHelp))</p> | ||
| 2208 | + <p><img src=(badge.image.as_str()) alt="build"></p> | ||
| 2209 | + <label class="small"> | ||
| 2210 | + (g::t(lang, K::BadgeSnippet)) | ||
| 2211 | + <textarea readonly="readonly" rows="2" class="ci-badge-snippet">(badge.snippet.as_str())</textarea> | ||
| 2212 | + </label> | ||
| 2213 | + </div> | ||
| 2214 | + </details> | ||
| 2215 | + }) | ||
| 2216 | +} | ||
| 2217 | + | ||
| 2218 | +/// The runs list: one sheet with its tools row, one line per run (each opens the run's page) and the | ||
| 2219 | +/// pager. The live list keeps its classes for the page script. | ||
| 2220 | +#[component] | ||
| 2221 | +async fn runs_sheet(lang: Lang, list: &ListView) -> Result<impl View> { | ||
| 2131 | let ListView { | 2222 | let ListView { |
| 2132 | - manual, | ||
| 2133 | - badge, | ||
| 2134 | total, | 2223 | total, |
| 2135 | scale, | 2224 | scale, |
| 2136 | rows, | 2225 | rows, |
| @@ -2138,99 +2227,66 @@ async fn run_side(lang: Lang, list: ListView) -> Result<impl View> { | |||
| 2138 | older_href, | 2227 | older_href, |
| 2139 | page_label, | 2228 | page_label, |
| 2140 | next_scheduled, | 2229 | next_scheduled, |
| 2230 | + .. | ||
| 2141 | } = list; | 2231 | } = list; |
| 2142 | Ok(view! { | 2232 | Ok(view! { |
| 2143 | - <section class="ci-side"> | 2233 | + <div class="sheet ci-side"> |
| 2144 | - <div class="ci-side-head"> | 2234 | + <div class="sheet-tools"> |
| 2145 | - <h2 class="ci-side-title">(g::t(lang, K::Runs)) <span class="ci-count">(total)</span></h2> | 2235 | + <strong>(g::t(lang, K::Runs))</strong> |
| 2146 | - <div class="ci-tools"> | 2236 | + <span class="hint ci-count">(total)</span> |
| 2147 | - if let Some(form) = manual { | 2237 | + <span class="hint ci-scale">(scale.as_str())</span> |
| 2148 | - <details class="menu ci-tool"> | 2238 | + </div> |
| 2149 | - <summary>(g::t(lang, K::RunWorkflow))</summary> | 2239 | + if let Some(next) = next_scheduled.as_ref() { |
| 2150 | - <div class="menu-list ci-pop"> | 2240 | + <p class="ci-next hint">(g::t(lang, K::NextScheduledRun)) ": " rel_time(lang: lang, stamp: next.as_str())</p> |
| 2151 | - <p class="muted small">(g::t(lang, K::RunWorkflowHelp))</p> | 2241 | + } |
| 2152 | - <form method="post" action=(form.action.as_str()) class="ci-manual-form"> | 2242 | + if rows.is_empty() { |
| 2153 | - <input type="hidden" name="csrf" value=(form.csrf.as_str())> | 2243 | + empty_state(title: g::t(lang, K::NoRunsYet), hint: Some(g::t(lang, K::NoRunsHint))) |
| 2154 | - <label> | 2244 | + } else { |
| 2155 | - (g::t(lang, K::Branch)) " " | 2245 | + <div class="ci-run-list"> |
| 2156 | - <select name="branch"> | 2246 | + for row in rows.iter() { |
| 2157 | - for branch in form.branches.iter() { | 2247 | + <div class="ci-run-item"> |
| 2158 | - <option value=(branch.as_str())>(branch.as_str())</option> | 2248 | + <a class="line ci-row" href=(row.href.as_str()) aria-current=(row.current) data-kb-row=""> |
| 2159 | - } | 2249 | + <span class=(format!("tick {}", row.tick))></span> |
| 2160 | - </select> | 2250 | + <span class="name">commit_line(subject: row.title.clone())</span> |
| 2161 | - </label> | 2251 | + <svg class="ci-bar" viewBox="0 0 1000 6" preserveAspectRatio="none" aria-hidden="true" data-origin=(row.origin.as_str()) data-scale=(row.scale.as_str())> |
| 2162 | - <button type="submit" class="primary">(g::t(lang, K::RunWorkflow))</button> | 2252 | + for seg in row.bar.iter() { |
| 2163 | - </form> | 2253 | + <rect class=(seg.class.as_str()) x=(seg.x.as_str()) y=(seg.y.as_str()) width=(seg.w.as_str()) height=(seg.h.as_str()) data-tick=(seg.tick.as_deref()) data-key=(seg.key.as_deref())/> |
| 2164 | - </div> | 2254 | + } |
| 2165 | - </details> | 2255 | + </svg> |
| 2166 | - } | 2256 | + if let Some(est) = row.est.as_ref() { |
| 2167 | - <details class="menu ci-tool"> | 2257 | + <progress class="ci-est" max="100" value=(est.pct.as_str()) data-est="true" data-since=(row.since.as_deref()) data-expected=(est.expected.as_str())></progress> |
| 2168 | - <summary>(g::t(lang, K::BadgeHeading))</summary> | 2258 | + <span class="val"><span class="ci-row-meta">(row.meta.head.as_str())<time datetime=(row.meta.at.as_str()) data-rel="true">(row.meta.age.as_str())</time>(row.meta.hint.as_str())</span> " · " <span class="ci-row-dur" data-since=(row.since.as_deref()) data-expected=(est.expected.as_str()) data-left=(est.left.as_str()) data-over=(est.over.as_str()) data-lm=(est.minutes.as_str())>(row.duration.as_str())</span></span> |
| 2169 | - <div class="menu-list ci-pop"> | 2259 | + } else { |
| 2170 | - <p class="muted small">(g::t(lang, K::BadgeHelp))</p> | 2260 | + <span class="val"><span class="ci-row-meta">(row.meta.head.as_str())<time datetime=(row.meta.at.as_str()) data-rel="true">(row.meta.age.as_str())</time>(row.meta.hint.as_str())</span> " · " <span class="ci-row-dur" data-since=(row.since.as_deref())>(row.duration.as_str())</span></span> |
| 2171 | - <p><img src=(badge.image.as_str()) alt="build"></p> | ||
| 2172 | - <label class="small"> | ||
| 2173 | - (g::t(lang, K::BadgeSnippet)) | ||
| 2174 | - <textarea readonly="readonly" rows="2" class="ci-badge-snippet">(badge.snippet.as_str())</textarea> | ||
| 2175 | - </label> | ||
| 2176 | - </div> | ||
| 2177 | - </details> | ||
| 2178 | - </div> | ||
| 2179 | - </div> | ||
| 2180 | - if let Some(next) = next_scheduled.as_ref() { | ||
| 2181 | - <p class="ci-next muted small">(g::t(lang, K::NextScheduledRun)) ": " rel_time(lang: lang, stamp: next.as_str())</p> | ||
| 2182 | - } | ||
| 2183 | - if rows.is_empty() { | ||
| 2184 | - empty_state(title: g::t(lang, K::NoRunsYet), hint: Some(g::t(lang, K::NoRunsHint))) | ||
| 2185 | - } else { | ||
| 2186 | - <p class="ci-scale">(scale.as_str())</p> | ||
| 2187 | - <ul class="ci-run-list"> | ||
| 2188 | - for row in rows.iter() { | ||
| 2189 | - <li data-kb-row=""> | ||
| 2190 | - <a class="ci-row" href=(row.href.as_str()) aria-current=(row.current)> | ||
| 2191 | - <span class="ci-row-title">commit_line(subject: row.title.clone())</span> | ||
| 2192 | - <span class="ci-row-line"> | ||
| 2193 | - <svg class="ci-bar" viewBox="0 0 1000 6" preserveAspectRatio="none" aria-hidden="true" data-origin=(row.origin.as_str()) data-scale=(row.scale.as_str())> | ||
| 2194 | - for seg in row.bar.iter() { | ||
| 2195 | - <rect class=(seg.class.as_str()) x=(seg.x.as_str()) y=(seg.y.as_str()) width=(seg.w.as_str()) height=(seg.h.as_str()) data-tick=(seg.tick.as_deref()) data-key=(seg.key.as_deref())/> | ||
| 2196 | - } | ||
| 2197 | - </svg> | ||
| 2198 | - if let Some(est) = row.est.as_ref() { | ||
| 2199 | - <progress class="ci-est" max="100" value=(est.pct.as_str()) data-est="true" data-since=(row.since.as_deref()) data-expected=(est.expected.as_str())></progress> | ||
| 2200 | - <span class="ci-row-dur" data-since=(row.since.as_deref()) data-expected=(est.expected.as_str()) data-left=(est.left.as_str()) data-over=(est.over.as_str()) data-lm=(est.minutes.as_str())>(row.duration.as_str())</span> | ||
| 2201 | - } else { | ||
| 2202 | - <span class="ci-row-dur" data-since=(row.since.as_deref())>(row.duration.as_str())</span> | ||
| 2203 | - } | ||
| 2204 | - </span> | ||
| 2205 | - <span class="ci-row-meta">(row.meta.head.as_str())<time datetime=(row.meta.at.as_str()) data-rel="true">(row.meta.age.as_str())</time>(row.meta.hint.as_str())</span> | ||
| 2206 | - </a> | ||
| 2207 | - if let Some((action, token)) = row.rerun.as_ref() { | ||
| 2208 | - <form method="post" action=(action.as_str()) class="ci-row-rerun-form" data-kb-rerun=""> | ||
| 2209 | - <input type="hidden" name="csrf" value=(token.as_str())> | ||
| 2210 | - <button type="submit" class="act ci-row-rerun">(g::t(lang, K::Rerun))</button> | ||
| 2211 | - </form> | ||
| 2212 | } | 2261 | } |
| 2213 | - </li> | 2262 | + </a> |
| 2214 | - } | 2263 | + if let Some((action, token)) = row.rerun.as_ref() { |
| 2215 | - </ul> | 2264 | + <form method="post" action=(action.as_str()) class="act-form ci-row-rerun-form" data-kb-rerun=""> |
| 2216 | - } | 2265 | + <input type="hidden" name="csrf" value=(token.as_str())> |
| 2217 | - if newer_href.is_some() || older_href.is_some() { | 2266 | + <button type="submit" class="act ci-row-rerun">(g::t(lang, K::Rerun))</button> |
| 2218 | - <nav class="pager"> | 2267 | + </form> |
| 2219 | - if let Some(href) = newer_href { | 2268 | + } |
| 2220 | - <a href=(href.as_str())>(g::t(lang, K::Newer))</a> | 2269 | + </div> |
| 2221 | - } | 2270 | + } |
| 2222 | - <span class="muted small">(page_label.as_str())</span> | 2271 | + </div> |
| 2223 | - if let Some(href) = older_href { | 2272 | + } |
| 2224 | - <a href=(href.as_str())>(g::t(lang, K::Older))</a> | 2273 | + if newer_href.is_some() || older_href.is_some() { |
| 2225 | - } | 2274 | + <nav class="pager"> |
| 2226 | - </nav> | 2275 | + if let Some(href) = newer_href { |
| 2227 | - } | 2276 | + <a href=(href.as_str())>(g::t(lang, K::Newer))</a> |
| 2228 | - </section> | 2277 | + } |
| 2278 | + <span class="muted small">(page_label.as_str())</span> | ||
| 2279 | + if let Some(href) = older_href { | ||
| 2280 | + <a href=(href.as_str())>(g::t(lang, K::Older))</a> | ||
| 2281 | + } | ||
| 2282 | + </nav> | ||
| 2283 | + } | ||
| 2284 | + </div> | ||
| 2229 | }) | 2285 | }) |
| 2230 | } | 2286 | } |
| 2231 | 2287 | ||
| 2232 | -/// The runs page body. The header (the Run workflow and badge menus, the count) is the list's, and the | 2288 | +/// The runs page body: the repo head with the Run workflow and badge menus beside its title, then the |
| 2233 | -/// split view sits in the live region. The selected run is marked in the list and drawn on the right. | 2289 | +/// runs sheet. The live region is the list's stream, so the list re-renders when a run changes. |
| 2234 | #[component] | 2290 | #[component] |
| 2235 | async fn runs_body( | 2291 | async fn runs_body( |
| 2236 | head: RepoHead, | 2292 | head: RepoHead, |
| @@ -2238,11 +2294,10 @@ async fn runs_body( | |||
| 2238 | notice: Option<(&'static str, bool)>, | 2294 | notice: Option<(&'static str, bool)>, |
| 2239 | live: Option<String>, | 2295 | live: Option<String>, |
| 2240 | list: ListView, | 2296 | list: ListView, |
| 2241 | - detail: Option<RunDetail>, | ||
| 2242 | ) -> Result<impl View> { | 2297 | ) -> Result<impl View> { |
| 2243 | let (fm, fs) = duration_templates(lang); | 2298 | let (fm, fs) = duration_templates(lang); |
| 2244 | Ok(view! { | 2299 | Ok(view! { |
| 2245 | - repo_head(head: RepoHead { live: String::new(), ..head }) | 2300 | + repo_head(head: RepoHead { live: String::new(), ..head }, ci_menus(lang: lang, list: &list)) |
| 2246 | if let Some((text, is_error)) = notice { | 2301 | if let Some((text, is_error)) = notice { |
| 2247 | if is_error { | 2302 | if is_error { |
| 2248 | alert(message: text) | 2303 | alert(message: text) |
| @@ -2250,7 +2305,7 @@ async fn runs_body( | |||
| 2250 | <p class="state" role="status">(text)</p> | 2305 | <p class="state" role="status">(text)</p> |
| 2251 | } | 2306 | } |
| 2252 | } | 2307 | } |
| 2253 | - <div data-live=(live.as_deref()) class="ci-split fit-pane" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())> | 2308 | + <div data-live=(live.as_deref()) class="work ci-split" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())> |
| 2254 | <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true"> | 2309 | <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true"> |
| 2255 | <defs> | 2310 | <defs> |
| 2256 | <pattern id="ci-hatch" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"> | 2311 | <pattern id="ci-hatch" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"> |
| @@ -2258,18 +2313,7 @@ async fn runs_body( | |||
| 2258 | </pattern> | 2313 | </pattern> |
| 2259 | </defs> | 2314 | </defs> |
| 2260 | </svg> | 2315 | </svg> |
| 2261 | - run_side(lang: lang, list: list) | 2316 | + runs_sheet(lang: lang, list: &list) |
| 2262 | - <section class="ci-detail"> | ||
| 2263 | - if let Some(run) = detail { | ||
| 2264 | - run_head(lang: lang, run: &run, all_href: None) | ||
| 2265 | - <div class="ci-tl-main"> | ||
| 2266 | - run_jobs(lang: lang, run: &run) | ||
| 2267 | - run_log(lang: lang, run: &run, timeline: false) | ||
| 2268 | - </div> | ||
| 2269 | - } else { | ||
| 2270 | - empty_state(title: g::t(lang, K::NoRunsYet), hint: Some(g::t(lang, K::NoRunsHint))) | ||
| 2271 | - } | ||
| 2272 | - </section> | ||
| 2273 | </div> | 2317 | </div> |
| 2274 | }) | 2318 | }) |
| 2275 | } | 2319 | } |
| @@ -2380,191 +2424,190 @@ async fn run_timeline(lang: Lang, run: &RunDetail) -> Result<impl View> { | |||
| 2380 | #[component] | 2424 | #[component] |
| 2381 | async fn run_head(lang: Lang, run: &RunDetail, all_href: Option<String>) -> Result<impl View> { | 2425 | async fn run_head(lang: Lang, run: &RunDetail, all_href: Option<String>) -> Result<impl View> { |
| 2382 | let cancel_action = format!("{}/cancel", run.action_base); | 2426 | let cancel_action = format!("{}/cancel", run.action_base); |
| 2427 | + let rerun_failed_shown = run.writer_csrf.is_some() | ||
| 2428 | + && run.can_rerun_failed | ||
| 2429 | + && !run.can_approve | ||
| 2430 | + && !run.can_cancel; | ||
| 2383 | Ok(view! { | 2431 | Ok(view! { |
| 2384 | - <header class="ci-tl-head" data-run=(run.number)> | 2432 | + <section class="head"> |
| 2385 | - <div class="ci-tl-headmain"> | 2433 | + <div class="head-title"> |
| 2386 | - <div class="ci-tl-line"> | 2434 | + <h1 class=(run.headline_class)>(run.headline.as_str())</h1> |
| 2387 | - <span class="ci-tl-no">(g::t(lang, K::RunNumber)) (run.number)</span> | 2435 | + if let Some(csrf) = run.writer_csrf.as_ref() { |
| 2388 | - <h2 class="ci-tl-title">(headline(run.title.as_str()))</h2> | 2436 | + if run.can_approve { |
| 2389 | - <details class="ci-tl-more"> | 2437 | + action_button(action: format!("{}/approve", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::ApproveAndRun), primary: true) |
| 2390 | - <summary>(crate::i18n::code::t(lang, crate::i18n::code::K::ShowFullMessage))</summary> | ||
| 2391 | - <p class="small">(run.title.as_str())</p> | ||
| 2392 | - </details> | ||
| 2393 | - if let Some(csrf) = run.writer_csrf.as_ref() { | ||
| 2394 | - <div class="acts ci-tl-actions"> | ||
| 2395 | - if run.can_approve { | ||
| 2396 | - action_button(action: format!("{}/approve", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::ApproveAndRun)) | ||
| 2397 | - } | ||
| 2398 | - if run.can_cancel && run.stopping { | ||
| 2399 | - <button type="button" class="ci-stopping" disabled="disabled">(g::t(lang, K::StoppingButton))</button> | ||
| 2400 | - } else if run.can_cancel { | ||
| 2401 | - 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![]) | ||
| 2402 | - } | ||
| 2403 | - if run.can_rerun_failed && !run.can_approve && !run.can_cancel { | ||
| 2404 | - action_button(action: format!("{}/rerun-failed", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::RerunFailed)) | ||
| 2405 | - } | ||
| 2406 | - if !run.can_approve && run.reachable { | ||
| 2407 | - action_button(action: format!("{}/rerun", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Rerun)) | ||
| 2408 | - } | ||
| 2409 | - </div> | ||
| 2410 | } | 2438 | } |
| 2411 | - </div> | 2439 | + if run.can_cancel && run.stopping { |
| 2412 | - <div class="ci-tl-meta"> | 2440 | + <button type="button" class="ci-stopping" disabled="disabled">(g::t(lang, K::StoppingButton))</button> |
| 2413 | - <span class=(run.state_class.as_str())>(run.state.as_str())</span> | 2441 | + } else if run.can_cancel { |
| 2414 | - <span class="muted">(run.trigger.as_str()) " \u{b7} " (run.branch.as_str())</span> | 2442 | + 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![]) |
| 2415 | - if let Some(href) = run.commit_href.as_ref() { | ||
| 2416 | - <a href=(href.as_str())><code>(run.commit.as_str())</code></a> | ||
| 2417 | - } else { | ||
| 2418 | - <code class="muted" title=(g::t(lang, K::CiCommitOverwritten))>(run.commit.as_str())</code> | ||
| 2419 | } | 2443 | } |
| 2420 | - if !run.actor.is_empty() { | 2444 | + if rerun_failed_shown { |
| 2421 | - <span class="muted">(run.actor.as_str())</span> | 2445 | + action_button(action: format!("{}/rerun-failed", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::RerunFailed), primary: true) |
| 2422 | } | 2446 | } |
| 2423 | - if !run.duration.is_empty() { | 2447 | + if !run.can_approve && run.reachable { |
| 2424 | - if let Some(est) = run.est.as_ref() { | 2448 | + action_button(action: format!("{}/rerun", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Rerun), primary: !rerun_failed_shown) |
| 2425 | - <span class="ci-tl-dur" data-since=(run.since.as_deref()) data-expected=(est.expected.as_str()) data-left=(est.left.as_str()) data-over=(est.over.as_str()) data-lm=(est.minutes.as_str())>(run.duration.as_str())</span> | ||
| 2426 | - } else { | ||
| 2427 | - <span class="ci-tl-dur" data-since=(run.since.as_deref())>(run.duration.as_str())</span> | ||
| 2428 | - } | ||
| 2429 | - } | ||
| 2430 | - <time class="muted" datetime=(run.when_at.as_str()) data-rel="true">(run.when.as_str())</time> | ||
| 2431 | - if let Some(href) = all_href { | ||
| 2432 | - <a class="small ci-all-runs" href=(href.as_str())>(tl::t(lang, TK::AllRuns))</a> | ||
| 2433 | } | 2449 | } |
| 2434 | - </div> | ||
| 2435 | - if let Some(est) = run.est.as_ref() { | ||
| 2436 | - <progress class="ci-est ci-est-run" max="100" value=(est.pct.as_str()) data-est="true" data-since=(run.since.as_deref()) data-expected=(est.expected.as_str())></progress> | ||
| 2437 | } | 2450 | } |
| 2438 | </div> | 2451 | </div> |
| 2439 | - </header> | 2452 | + <p class="head-sub"> |
| 2453 | + <span class="b" data-run=(run.number)>(run.title.as_str())</span> | ||
| 2454 | + <span class="sep" aria-hidden="true">"·"</span> | ||
| 2455 | + <span>(run.trigger.as_str()) " \u{b7} " (run.branch.as_str())</span> | ||
| 2456 | + <span class="sep" aria-hidden="true">"·"</span> | ||
| 2457 | + if let Some(href) = run.commit_href.as_ref() { | ||
| 2458 | + <a class="mono" href=(href.as_str())>(run.commit.as_str())</a> | ||
| 2459 | + } else { | ||
| 2460 | + <span class="mono" title=(g::t(lang, K::CiCommitOverwritten))>(run.commit.as_str())</span> | ||
| 2461 | + } | ||
| 2462 | + if !run.actor.is_empty() { | ||
| 2463 | + <span class="sep" aria-hidden="true">"·"</span> | ||
| 2464 | + <span>(run.actor.as_str())</span> | ||
| 2465 | + } | ||
| 2466 | + <span class="sep" aria-hidden="true">"·"</span> | ||
| 2467 | + <time datetime=(run.when_at.as_str()) data-rel="true">(run.when.as_str())</time> | ||
| 2468 | + if !run.duration.is_empty() { | ||
| 2469 | + <span class="sep" aria-hidden="true">"·"</span> | ||
| 2470 | + if let Some(est) = run.est.as_ref() { | ||
| 2471 | + <span class="ci-tl-dur" data-since=(run.since.as_deref()) data-expected=(est.expected.as_str()) data-left=(est.left.as_str()) data-over=(est.over.as_str()) data-lm=(est.minutes.as_str())>(run.duration.as_str())</span> | ||
| 2472 | + } else { | ||
| 2473 | + <span class="ci-tl-dur" data-since=(run.since.as_deref())>(run.duration.as_str())</span> | ||
| 2474 | + } | ||
| 2475 | + } | ||
| 2476 | + if let Some(href) = all_href { | ||
| 2477 | + <span class="sep" aria-hidden="true">"·"</span> | ||
| 2478 | + <a href=(href.as_str())>(tl::t(lang, TK::AllRuns))</a> | ||
| 2479 | + } | ||
| 2480 | + </p> | ||
| 2481 | + if let Some(est) = run.est.as_ref() { | ||
| 2482 | + <progress class="ci-est ci-est-run" max="100" value=(est.pct.as_str()) data-est="true" data-since=(run.since.as_deref()) data-expected=(est.expected.as_str())></progress> | ||
| 2483 | + } | ||
| 2484 | + </section> | ||
| 2440 | }) | 2485 | }) |
| 2441 | } | 2486 | } |
| 2442 | 2487 | ||
| 2443 | -/// The class of a job's row: `ci-tl-sub` for a matrix combination, `ci-tl-hassteps` when its steps | 2488 | +/// The jobs of a run with more than one job: one `.job-row` each, its name, its tick and a mini strip |
| 2444 | -/// dropdown sits under the row. | 2489 | +/// of its steps. The selected job's row is marked; its steps are the strip under the head. |
| 2445 | -fn job_row_class(job: &JobLine) -> Option<&'static str> { | ||
| 2446 | - match (job.sub, job.steps.is_empty()) { | ||
| 2447 | - (true, false) => Some("ci-tl-sub ci-tl-hassteps"), | ||
| 2448 | - (true, true) => Some("ci-tl-sub"), | ||
| 2449 | - (false, false) => Some("ci-tl-hassteps"), | ||
| 2450 | - (false, true) => None, | ||
| 2451 | - } | ||
| 2452 | -} | ||
| 2453 | - | ||
| 2454 | -/// The class of a step's row under its job: a matrix combination's steps sit one level in. | ||
| 2455 | -fn step_class(sub: bool) -> &'static str { | ||
| 2456 | - if sub { | ||
| 2457 | - "ci-tl-step ci-tl-step-sub" | ||
| 2458 | - } else { | ||
| 2459 | - "ci-tl-step" | ||
| 2460 | - } | ||
| 2461 | -} | ||
| 2462 | - | ||
| 2463 | -/// The jobs pane (300 px): `Jobs`, one 36 px row per job with its dot, name, image and time at the right, | ||
| 2464 | -/// then the run's artifacts. Each job's steps are a dropdown under its row, open for the selected job. | ||
| 2465 | #[component] | 2490 | #[component] |
| 2466 | async fn run_jobs(lang: Lang, run: &RunDetail) -> Result<impl View> { | 2491 | async fn run_jobs(lang: Lang, run: &RunDetail) -> Result<impl View> { |
| 2467 | - let steps_label = crate::pages::passkeys::s(lang, "Steps", "Adımlar"); | ||
| 2468 | Ok(view! { | 2492 | Ok(view! { |
| 2469 | - <section class="ci-pane ci-tl-jobs"> | 2493 | + if run.jobs.len() > 1 { |
| 2470 | - <h2 class="ci-tl-label">(g::t(lang, K::Jobs))</h2> | 2494 | + <div class="jobs ci-tl-list"> |
| 2471 | - if run.jobs.is_empty() { | 2495 | + for job in run.jobs.iter() { |
| 2472 | - <p class="muted small ci-tl-pad">(g::t(lang, K::NoJobs))</p> | 2496 | + if let Some(group) = job.group.as_ref() { |
| 2473 | - } else { | 2497 | + <p class="hint ci-tl-group">(group.as_str())</p> |
| 2474 | - <ul class="ci-tl-list"> | 2498 | + } |
| 2475 | - for job in run.jobs.iter() { | 2499 | + <a class=(if job.selected { "job-row sel ci-tl-job" } else { "job-row ci-tl-job" }) href=(job.pick.as_str()) aria-current=(if job.selected { "true" } else { "false" }) data-kb-row=""> |
| 2476 | - if let Some(group) = job.group.as_ref() { | 2500 | + <span class=(format!("tick {}", job.tick))></span> |
| 2477 | - <li class="ci-tl-group">(group.as_str())</li> | 2501 | + <span class="name">(job.name.as_str())</span> |
| 2502 | + if !job.detail.is_empty() { | ||
| 2503 | + <span class="hint">(job.detail.as_str())</span> | ||
| 2478 | } | 2504 | } |
| 2479 | - <li class=(job_row_class(job)) data-kb-row=""> | 2505 | + if job.stopping { |
| 2480 | - <a class="ci-tl-job" href=(job.pick.as_str()) aria-current=(if job.selected { "true" } else { "false" })> | 2506 | + <span class="hint">(g::t(lang, K::StateStopping))</span> |
| 2481 | - <span class=(job.dot.as_str())></span> | 2507 | + } |
| 2482 | - <span class="ci-tl-name">(job.name.as_str())</span> | 2508 | + if job.duration.is_empty() { |
| 2483 | - if !job.detail.is_empty() { | 2509 | + <span class="hint ci-tl-dur">(g::t(lang, K::Waiting))</span> |
| 2484 | - <span class="ci-tl-tag">(job.detail.as_str())</span> | 2510 | + } else { |
| 2485 | - } | 2511 | + <span class="ci-tl-dur" data-since=(job.since.as_deref())>(job.duration.as_str())</span> |
| 2486 | - if job.stopping { | 2512 | + } |
| 2487 | - <span class="muted small">(g::t(lang, K::StateStopping))</span> | 2513 | + if !job.steps.is_empty() { |
| 2488 | - } | 2514 | + <span class="strip"> |
| 2489 | - if job.duration.is_empty() { | 2515 | + for step in job.steps.iter() { |
| 2490 | - <span class="ci-tl-dur muted">(g::t(lang, K::Waiting))</span> | 2516 | + <span class=(format!("seg {} {}", step.seg, step.fr))><span class="bar"></span></span> |
| 2491 | - } else { | ||
| 2492 | - <span class="ci-tl-dur" data-since=(job.since.as_deref())>(job.duration.as_str())</span> | ||
| 2493 | - } | ||
| 2494 | - if !job.step_bar.is_empty() { | ||
| 2495 | - <svg class="ci-tl-stepbar" viewBox="0 0 1000 3" preserveAspectRatio="none" aria-hidden="true" focusable="false"> | ||
| 2496 | - for r in job.step_bar.iter() { | ||
| 2497 | - <rect class=(r.class.as_str()) x=(r.x.as_str()) y=(r.y.as_str()) width=(r.w.as_str()) height=(r.h.as_str())/> | ||
| 2498 | - } | ||
| 2499 | - </svg> | ||
| 2500 | } | 2517 | } |
| 2518 | + </span> | ||
| 2519 | + } | ||
| 2520 | + </a> | ||
| 2521 | + } | ||
| 2522 | + </div> | ||
| 2523 | + } | ||
| 2524 | + }) | ||
| 2525 | +} | ||
| 2526 | + | ||
| 2527 | +/// The steps of the selected job, one `.seg` each: a step's name, its time and its state. A step the | ||
| 2528 | +/// URL picks is marked, and a step with its log opens that part of the log. | ||
| 2529 | +#[component] | ||
| 2530 | +async fn run_strip(run: &RunDetail) -> Result<impl View> { | ||
| 2531 | + let job = run.jobs.iter().find(|job| job.selected); | ||
| 2532 | + Ok(view! { | ||
| 2533 | + if let Some(job) = job { | ||
| 2534 | + if !job.steps.is_empty() { | ||
| 2535 | + <div class="strip"> | ||
| 2536 | + for step in job.steps.iter() { | ||
| 2537 | + if let Some(href) = step.href.as_ref() { | ||
| 2538 | + <a class=(format!("seg {} {}{}", step.seg, step.fr, if step.selected { " sel" } else { "" })) href=(href.as_str()) aria-current=(if step.selected { "true" } else { "false" })> | ||
| 2539 | + <span class="bar"> | ||
| 2540 | + if step.pct.is_some() || step.value.is_some() { | ||
| 2541 | + <progress class=(format!("ci-est ci-tl-stepprog {}", step.state_class)) max="100" value=(step.value.as_deref()) data-est=(step.pct.as_ref().map(|_| "true")) data-since=(step.pct.as_ref().and_then(|_| step.since.as_deref())) data-expected=(step.expected_secs.as_deref())></progress> | ||
| 2542 | + } | ||
| 2543 | + </span> | ||
| 2544 | + <span class="lab">(step.name.as_str())<em class="ci-tl-dur" data-since=(step.since.as_deref())>(step.duration.as_str())</em> | ||
| 2545 | + if let Some(expected) = step.expected.as_ref() { | ||
| 2546 | + <em class="ci-tl-stepexp">(expected.as_str())</em> | ||
| 2547 | + } | ||
| 2548 | + </span> | ||
| 2501 | </a> | 2549 | </a> |
| 2502 | - if !job.steps.is_empty() { | 2550 | + } else { |
| 2503 | - <details class="ci-tl-steps" data-steps-job=(job.id.as_str()) open=(job.selected)> | 2551 | + <span class=(format!("seg {} {}", step.seg, step.fr))> |
| 2504 | - <summary class="ci-tl-steptoggle" aria-label=(steps_label)><span class="ci-chev" aria-hidden="true"></span></summary> | 2552 | + <span class="bar"></span> |
| 2505 | - <ul class="ci-tl-steplist"> | 2553 | + <span class="lab">(step.name.as_str())<em class="ci-tl-dur" data-since=(step.since.as_deref())>(step.duration.as_str())</em></span> |
| 2506 | - for step in job.steps.iter() { | 2554 | + </span> |
| 2507 | - <li> | 2555 | + } |
| 2508 | - if let Some(href) = step.href.as_ref() { | ||
| 2509 | - <a class=(step_class(job.sub)) href=(href.as_str()) aria-current=(if step.selected { "true" } else { "false" })> | ||
| 2510 | - <span class=(format!("ci-tl-stepmark {}", step.mark))></span> | ||
| 2511 | - <span class="ci-tl-stepname">(step.name.as_str())</span> | ||
| 2512 | - <span class="ci-tl-dur" data-since=(step.since.as_deref())>(step.duration.as_str())</span> | ||
| 2513 | - if let Some(expected) = step.expected.as_ref() { | ||
| 2514 | - <span class="ci-tl-stepexp">(expected.as_str())</span> | ||
| 2515 | - } | ||
| 2516 | - <progress class=(format!("ci-est ci-tl-stepprog {}", step.state_class)) max="100" value=(step.value.as_deref()) data-est=(step.pct.as_ref().map(|_| "true")) data-since=(step.pct.as_ref().and_then(|_| step.since.as_deref())) data-expected=(step.expected_secs.as_deref())></progress> | ||
| 2517 | - </a> | ||
| 2518 | - } else { | ||
| 2519 | - <div class=(step_class(job.sub))> | ||
| 2520 | - <span class=(format!("ci-tl-stepmark {}", step.mark))></span> | ||
| 2521 | - <span class="ci-tl-stepname">(step.name.as_str())</span> | ||
| 2522 | - <span class="ci-tl-dur" data-since=(step.since.as_deref())>(step.duration.as_str())</span> | ||
| 2523 | - if let Some(expected) = step.expected.as_ref() { | ||
| 2524 | - <span class="ci-tl-stepexp">(expected.as_str())</span> | ||
| 2525 | - } | ||
| 2526 | - <progress class=(format!("ci-est ci-tl-stepprog {}", step.state_class)) max="100" value=(step.value.as_deref()) data-est=(step.pct.as_ref().map(|_| "true")) data-since=(step.pct.as_ref().and_then(|_| step.since.as_deref())) data-expected=(step.expected_secs.as_deref())></progress> | ||
| 2527 | - </div> | ||
| 2528 | - } | ||
| 2529 | - </li> | ||
| 2530 | - } | ||
| 2531 | - </ul> | ||
| 2532 | - </details> | ||
| 2533 | - } | ||
| 2534 | - </li> | ||
| 2535 | } | 2556 | } |
| 2536 | - </ul> | 2557 | + </div> |
| 2537 | } | 2558 | } |
| 2538 | - if !run.artifacts.is_empty() { | 2559 | + } |
| 2539 | - <div class="ci-tl-artline"> | 2560 | + }) |
| 2540 | - <h3 class="ci-tl-label">(g::t(lang, K::Artifacts))</h3> | 2561 | +} |
| 2562 | + | ||
| 2563 | +/// The run's artifacts: the zip of all of them and one download line each. | ||
| 2564 | +#[component] | ||
| 2565 | +async fn run_artifacts(lang: Lang, run: &RunDetail) -> Result<impl View> { | ||
| 2566 | + Ok(view! { | ||
| 2567 | + if !run.artifacts.is_empty() { | ||
| 2568 | + <div class="sec"> | ||
| 2569 | + <div class="acts"> | ||
| 2570 | + <h2>(g::t(lang, K::Artifacts))</h2> | ||
| 2541 | if let Some(href) = run.zip_href.as_ref() { | 2571 | if let Some(href) = run.zip_href.as_ref() { |
| 2542 | <a class="act" href=(href.as_str()) download="">(g::t(lang, K::DownloadAll))</a> | 2572 | <a class="act" href=(href.as_str()) download="">(g::t(lang, K::DownloadAll))</a> |
| 2543 | } | 2573 | } |
| 2544 | </div> | 2574 | </div> |
| 2545 | - <ul class="ci-art-list"> | 2575 | + for artifact in run.artifacts.iter() { |
| 2546 | - for artifact in run.artifacts.iter() { | 2576 | + <div class="line"> |
| 2547 | - <li> | 2577 | + <span class="name">(artifact.name.as_str())</span> |
| 2548 | - <span class="ci-art-name">(artifact.name.as_str())</span> | 2578 | + <span class="val">(artifact.job.as_str()) " \u{b7} " (artifact.size.as_str()) " " <a class="act" href=(artifact.href.as_str()) download="">(g::t(lang, K::Download))</a></span> |
| 2549 | - <span class="muted small">(artifact.job.as_str()) " \u{b7} " (artifact.size.as_str())</span> | 2579 | + </div> |
| 2550 | - <a class="ci-art-dl" href=(artifact.href.as_str()) download="">(g::t(lang, K::Download))</a> | 2580 | + } |
| 2551 | - </li> | 2581 | + </div> |
| 2552 | - } | 2582 | + } |
| 2553 | - </ul> | ||
| 2554 | - } | ||
| 2555 | - </section> | ||
| 2556 | }) | 2583 | }) |
| 2557 | } | 2584 | } |
| 2558 | 2585 | ||
| 2559 | /// The log pane: a 48 px bar with the Log and Timeline tabs and the log's tools, then the selected job's | 2586 | /// The log pane: a 48 px bar with the Log and Timeline tabs and the log's tools, then the selected job's |
| 2560 | /// log on `--bg` (or the config errors and the fail-first block above it). The timeline is the other tab. | 2587 | /// log on `--bg` (or the config errors and the fail-first block above it). The timeline is the other tab. |
| 2561 | #[component] | 2588 | #[component] |
| 2562 | -async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result<impl View> { | 2589 | +async fn run_log( |
| 2590 | + lang: Lang, | ||
| 2591 | + run: &RunDetail, | ||
| 2592 | + timeline: bool, | ||
| 2593 | + owner: String, | ||
| 2594 | + repo: String, | ||
| 2595 | + bars: Vec<StripBar>, | ||
| 2596 | +) -> Result<impl View> { | ||
| 2597 | + let job_name = run | ||
| 2598 | + .jobs | ||
| 2599 | + .iter() | ||
| 2600 | + .find(|job| job.selected) | ||
| 2601 | + .map(|job| job.name.clone()) | ||
| 2602 | + .unwrap_or_default(); | ||
| 2563 | Ok(view! { | 2603 | Ok(view! { |
| 2564 | - <section class="ci-pane ci-tl-log"> | 2604 | + <section class="sheet ci-tl-log"> |
| 2565 | <input type="radio" name="ci-view" id="ci-view-log" class="ci-tl-radio" checked=(if timeline { None } else { Some("checked") })> | 2605 | <input type="radio" name="ci-view" id="ci-view-log" class="ci-tl-radio" checked=(if timeline { None } else { Some("checked") })> |
| 2566 | <input type="radio" name="ci-view" id="ci-view-timeline" class="ci-tl-radio" checked=(if timeline { Some("checked") } else { None })> | 2606 | <input type="radio" name="ci-view" id="ci-view-timeline" class="ci-tl-radio" checked=(if timeline { Some("checked") } else { None })> |
| 2567 | - <div class="ci-logbar ci-tl-logbar"> | 2607 | + <div class="sheet-tools ci-logbar ci-tl-logbar"> |
| 2608 | + if !job_name.is_empty() { | ||
| 2609 | + <strong>(job_name.as_str())</strong> | ||
| 2610 | + } | ||
| 2568 | <div class="tabs ci-tl-tabs"> | 2611 | <div class="tabs ci-tl-tabs"> |
| 2569 | <label for="ci-view-log" class="ci-tl-tab ci-tl-tab-log">(g::t(lang, K::Log))</label> | 2612 | <label for="ci-view-log" class="ci-tl-tab ci-tl-tab-log">(g::t(lang, K::Log))</label> |
| 2570 | <label for="ci-view-timeline" class="ci-tl-tab ci-tl-tab-timeline">(g::t(lang, K::Timeline))</label> | 2613 | <label for="ci-view-timeline" class="ci-tl-tab ci-tl-tab-timeline">(g::t(lang, K::Timeline))</label> |
| @@ -2597,7 +2640,7 @@ async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result<impl Vie | |||
| 2597 | if !run.warnings.is_empty() { | 2640 | if !run.warnings.is_empty() { |
| 2598 | <section class="ci-warnings" role="status"> | 2641 | <section class="ci-warnings" role="status"> |
| 2599 | <p class="ci-warnings-title">(g::t(lang, K::ConfigWarnings))</p> | 2642 | <p class="ci-warnings-title">(g::t(lang, K::ConfigWarnings))</p> |
| 2600 | - <p class="muted small">(g::t(lang, K::ConfigWarningsHint))</p> | 2643 | + <p class="hint">(g::t(lang, K::ConfigWarningsHint))</p> |
| 2601 | <ul> | 2644 | <ul> |
| 2602 | for warning in run.warnings.iter() { | 2645 | for warning in run.warnings.iter() { |
| 2603 | <li><code>(warning.as_str())</code></li> | 2646 | <li><code>(warning.as_str())</code></li> |
| @@ -2611,25 +2654,32 @@ async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result<impl Vie | |||
| 2611 | } | 2654 | } |
| 2612 | if let Some(log) = run.log.as_ref() { | 2655 | if let Some(log) = run.log.as_ref() { |
| 2613 | if log.truncated { | 2656 | if log.truncated { |
| 2614 | - <p class="muted small ci-tl-pad"> | 2657 | + <p class="hint"> |
| 2615 | (crate::pages::passkeys::s(lang, "Showing the end of this log.", "Günlüğün sonu gösteriliyor.")) | 2658 | (crate::pages::passkeys::s(lang, "Showing the end of this log.", "Günlüğün sonu gösteriliyor.")) |
| 2616 | " " <a href=(log.log_href.as_str())>(crate::pages::passkeys::s(lang, "Full log", "Tam günlük"))</a> | 2659 | " " <a href=(log.log_href.as_str())>(crate::pages::passkeys::s(lang, "Full log", "Tam günlük"))</a> |
| 2617 | </p> | 2660 | </p> |
| 2618 | } | 2661 | } |
| 2619 | - <pre class="ci-log ci-tl-code" data-empty=(crate::pages::passkeys::s(lang, "No output yet.", "Henüz çıktı yok.")) data-live=(log.live.as_deref()) data-live-log="true" data-offset=(log.offset.as_str()) data-first=(log.first_line.as_str()) data-log-start=(log.at_step.then_some("true"))>(log.text.as_str())</pre> | 2662 | + <pre class="ci-log ci-tl-code" data-fail-at=(run.failing.as_ref().filter(|_| !log.at_step).and_then(FailFirst::line_no).map(|no| no.to_string())) data-empty=(crate::pages::passkeys::s(lang, "No output yet.", "Henüz çıktı yok.")) data-live=(log.live.as_deref()) data-live-log="true" data-offset=(log.offset.as_str()) data-first=(log.first_line.as_str()) data-log-start=(log.at_step.then_some("true"))>(log.text.as_str())</pre> |
| 2620 | } else { | 2663 | } else { |
| 2621 | - <p class="muted ci-tl-pad">(g::t(lang, K::NoJobs))</p> | 2664 | + <p class="hint">(g::t(lang, K::NoJobs))</p> |
| 2622 | } | 2665 | } |
| 2623 | </div> | 2666 | </div> |
| 2624 | <div class="ci-tl-panel ci-tl-panel-timeline"> | 2667 | <div class="ci-tl-panel ci-tl-panel-timeline"> |
| 2625 | run_timeline(lang: lang, run: run) | 2668 | run_timeline(lang: lang, run: run) |
| 2669 | + run_artifacts(lang: lang, run: run) | ||
| 2670 | + <div class="sec ci-dock"> | ||
| 2671 | + <p class="hint">(crate::pages::passkeys::s(lang, "bar height is lines changed", "çubuk yüksekliği değişen satır sayısıdır"))</p> | ||
| 2672 | + <div class="dock-history"> | ||
| 2673 | + history_strip(lang: lang, owner: owner, repo: repo, bars: bars) | ||
| 2674 | + </div> | ||
| 2675 | + </div> | ||
| 2626 | </div> | 2676 | </div> |
| 2627 | </section> | 2677 | </section> |
| 2628 | }) | 2678 | }) |
| 2629 | } | 2679 | } |
| 2630 | -/// The run page body: a one-line header with the run's actions, the jobs (left) and the selected job's | 2680 | +/// The run page body, with no repo tabs: the run's head (its state as the title, its actions, its commit |
| 2631 | -/// log (right), and the history dock under them. The page fits the window: the panes scroll inside. | 2681 | +/// line), the jobs of the run, the strip of the selected job's steps and the sheet with its log and the |
| 2632 | -/// The live region is the run list's stream, so the page re-renders when a run or a job changes. | 2682 | +/// history. The live region wraps all of it, so the page re-renders when a run or a job changes. |
| 2633 | #[component] | 2683 | #[component] |
| 2634 | async fn run_body( | 2684 | async fn run_body( |
| 2635 | head: RepoHead, | 2685 | head: RepoHead, |
| @@ -2642,11 +2692,13 @@ async fn run_body( | |||
| 2642 | bars: Vec<StripBar>, | 2692 | bars: Vec<StripBar>, |
| 2643 | timeline: bool, | 2693 | timeline: bool, |
| 2644 | all_href: String, | 2694 | all_href: String, |
| 2645 | - list: ListView, | ||
| 2646 | ) -> Result<impl View> { | 2695 | ) -> Result<impl View> { |
| 2647 | let (fm, fs) = duration_templates(lang); | 2696 | let (fm, fs) = duration_templates(lang); |
| 2697 | + let archived = head.archived; | ||
| 2648 | Ok(view! { | 2698 | Ok(view! { |
| 2649 | - repo_head(head: RepoHead { live: String::new(), ..head }) | 2699 | + if archived { |
| 2700 | + <p class="state" role="status">(crate::i18n::code::t(lang, crate::i18n::code::K::ArchivedNotice))</p> | ||
| 2701 | + } | ||
| 2650 | if let Some((text, is_error)) = notice { | 2702 | if let Some((text, is_error)) = notice { |
| 2651 | if is_error { | 2703 | if is_error { |
| 2652 | alert(message: text) | 2704 | alert(message: text) |
| @@ -2654,7 +2706,7 @@ async fn run_body( | |||
| 2654 | <p class="state" role="status">(text)</p> | 2706 | <p class="state" role="status">(text)</p> |
| 2655 | } | 2707 | } |
| 2656 | } | 2708 | } |
| 2657 | - <div data-live=(live.as_deref()) class="ci-split fit-pane" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())> | 2709 | + <div data-live=(live.as_deref()) class="ci-split ci-run" data-run=(run.number) data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())> |
| 2658 | <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true"> | 2710 | <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true"> |
| 2659 | <defs> | 2711 | <defs> |
| 2660 | <pattern id="ci-hatch" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"> | 2712 | <pattern id="ci-hatch" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"> |
| @@ -2662,20 +2714,10 @@ async fn run_body( | |||
| 2662 | </pattern> | 2714 | </pattern> |
| 2663 | </defs> | 2715 | </defs> |
| 2664 | </svg> | 2716 | </svg> |
| 2665 | - run_side(lang: lang, list: list) | ||
| 2666 | - <div class="ci-run" data-run=(run.number)> | ||
| 2667 | run_head(lang: lang, run: &run, all_href: Some(all_href)) | 2717 | run_head(lang: lang, run: &run, all_href: Some(all_href)) |
| 2668 | - <div class="ci-tl-main"> | 2718 | + run_jobs(lang: lang, run: &run) |
| 2669 | - run_jobs(lang: lang, run: &run) | 2719 | + run_strip(run: &run) |
| 2670 | - run_log(lang: lang, run: &run, timeline: timeline) | 2720 | + run_log(lang: lang, run: &run, timeline: timeline, owner: owner, repo: repo, bars: bars) |
| 2671 | - </div> | ||
| 2672 | - <section class="ci-pane ci-dock"> | ||
| 2673 | - <p class="ci-dock-note">(crate::pages::passkeys::s(lang, "bar height is lines changed", "çubuk yüksekliği değişen satır sayısıdır"))</p> | ||
| 2674 | - <div class="dock-history"> | ||
| 2675 | - history_strip(lang: lang, owner: owner, repo: repo, bars: bars) | ||
| 2676 | - </div> | ||
| 2677 | - </section> | ||
| 2678 | - </div> | ||
| 2679 | </div> | 2721 | </div> |
| 2680 | }) | 2722 | }) |
| 2681 | } | 2723 | } |
| @@ -2692,11 +2734,11 @@ async fn runs_list_page(cx: &Cx) -> Result<impl View> { | |||
| 2692 | live, | 2734 | live, |
| 2693 | page_title, | 2735 | page_title, |
| 2694 | list, | 2736 | list, |
| 2695 | - detail, | 2737 | + .. |
| 2696 | } = runs_split(cx, None, None, None).await?; | 2738 | } = runs_split(cx, None, None, None).await?; |
| 2697 | Ok(view! { | 2739 | Ok(view! { |
| 2698 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 2740 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 2699 | - runs_body(head: head, lang: lang, notice: notice, live: live, list: list, detail: detail)) | 2741 | + runs_body(head: head, lang: lang, notice: notice, live: live, list: list)) |
| 2700 | }) | 2742 | }) |
| 2701 | } | 2743 | } |
| 2702 | 2744 | ||
| @@ -2714,8 +2756,8 @@ async fn run_page(cx: &Cx) -> Result<impl View> { | |||
| 2714 | notice, | 2756 | notice, |
| 2715 | live, | 2757 | live, |
| 2716 | page_title, | 2758 | page_title, |
| 2717 | - list, | ||
| 2718 | detail, | 2759 | detail, |
| 2760 | + .. | ||
| 2719 | } = runs_split(cx, Some(&number), wanted.as_deref(), wanted_step).await?; | 2761 | } = runs_split(cx, Some(&number), wanted.as_deref(), wanted_step).await?; |
| 2720 | let Some(run) = detail else { | 2762 | let Some(run) = detail else { |
| 2721 | return Err(not_found().into()); | 2763 | return Err(not_found().into()); |
| @@ -2728,7 +2770,7 @@ async fn run_page(cx: &Cx) -> Result<impl View> { | |||
| 2728 | let all_href = ci_href(&title_of(&ctx)); | 2770 | let all_href = ci_href(&title_of(&ctx)); |
| 2729 | Ok(view! { | 2771 | Ok(view! { |
| 2730 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 2772 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 2731 | - 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)) | 2773 | + run_body(head: head, lang: lang, notice: notice, live: live, run: run, owner: owner, repo: repo, bars: bars, timeline: timeline, all_href: all_href)) |
| 2732 | }) | 2774 | }) |
| 2733 | } | 2775 | } |
| 2734 | 2776 | ||
crates/forge-web/src/pages/ci_tests.rsmodified+18 -14
| @@ -549,8 +549,8 @@ fn current_href(html: &str) -> Option<&str> { | |||
| 549 | link[at..].split('"').next() | 549 | link[at..].split('"').next() |
| 550 | } | 550 | } |
| 551 | 551 | ||
| 552 | -/// `/ci` draws the newest run and `/ci/runs/n` draws run n. The drawn run is marked in the list. A run | 552 | +/// `/ci` is the run list alone, each row opening its run; `/ci/runs/n` draws run n. A run that is not |
| 553 | -/// that is not on the list page is still drawn, and no row of the list is marked for it. | 553 | +/// on the list page is still drawn, and no row of the list is marked for it. |
| 554 | #[tokio::test] | 554 | #[tokio::test] |
| 555 | async fn split_view_draws_the_newest_run_or_the_one_named() { | 555 | async fn split_view_draws_the_newest_run_or_the_one_named() { |
| 556 | let dir = tempfile::tempdir().expect("tempdir"); | 556 | let dir = tempfile::tempdir().expect("tempdir"); |
| @@ -558,12 +558,12 @@ async fn split_view_draws_the_newest_run_or_the_one_named() { | |||
| 558 | let first = run_with(&fx, &["build"], false).await; | 558 | let first = run_with(&fx, &["build"], false).await; |
| 559 | let second = run_with(&fx, &["build"], false).await; | 559 | let second = run_with(&fx, &["build"], false).await; |
| 560 | let tahinli = Some(cookie_for("tahinli-token")); | 560 | let tahinli = Some(cookie_for("tahinli-token")); |
| 561 | - let newest = get(&fx.app, RUN_BASE, tahinli.as_deref()).await.text(); | 561 | + let list = get(&fx.app, RUN_BASE, tahinli.as_deref()).await.text(); |
| 562 | - assert!(newest.contains(&format!("data-run=\"{}\"", second.number))); | 562 | + for run in [&first, &second] { |
| 563 | - assert_eq!( | 563 | + assert!(list.contains(&format!("href=\"{RUN_BASE}/runs/{}\"", run.number))); |
| 564 | - current_href(&newest), | 564 | + } |
| 565 | - Some(format!("{RUN_BASE}/runs/{}", second.number).as_str()) | 565 | + assert!(!list.contains("data-run="), "the list draws no run"); |
| 566 | - ); | 566 | + assert_eq!(current_href(&list), None); |
| 567 | let named = get( | 567 | let named = get( |
| 568 | &fx.app, | 568 | &fx.app, |
| 569 | &format!("{RUN_BASE}/runs/{}", first.number), | 569 | &format!("{RUN_BASE}/runs/{}", first.number), |
| @@ -572,13 +572,14 @@ async fn split_view_draws_the_newest_run_or_the_one_named() { | |||
| 572 | .await | 572 | .await |
| 573 | .text(); | 573 | .text(); |
| 574 | assert!(named.contains(&format!("data-run=\"{}\"", first.number))); | 574 | assert!(named.contains(&format!("data-run=\"{}\"", first.number))); |
| 575 | - // The run page keeps the list beside it, so the run row and the selected job are both marked. On a | 575 | + // The run page is the run alone: the All runs link goes back to the list, and a one-job run has |
| 576 | - // phone the list gives way to the All runs link. | 576 | + // no job list to mark. |
| 577 | assert!( | 577 | assert!( |
| 578 | named.contains(&format!("href=\"{RUN_BASE}\"")), | 578 | named.contains(&format!("href=\"{RUN_BASE}\"")), |
| 579 | "All runs link" | 579 | "All runs link" |
| 580 | ); | 580 | ); |
| 581 | - assert_eq!(named.matches("aria-current=\"true\"").count(), 2); | 581 | + assert!(!named.contains("ci-run-list")); |
| 582 | + assert_eq!(named.matches("aria-current=\"true\"").count(), 0); | ||
| 582 | 583 | ||
| 583 | // Thirty runs make two pages. Run 1 is on page 2, so page 1 marks no row and draws run 1. | 584 | // Thirty runs make two pages. Run 1 is on page 2, so page 1 marks no row and draws run 1. |
| 584 | for _ in 0..28 { | 585 | for _ in 0..28 { |
| @@ -592,9 +593,7 @@ async fn split_view_draws_the_newest_run_or_the_one_named() { | |||
| 592 | .await | 593 | .await |
| 593 | .text(); | 594 | .text(); |
| 594 | assert!(off_page.contains(&format!("data-run=\"{}\"", first.number))); | 595 | assert!(off_page.contains(&format!("data-run=\"{}\"", first.number))); |
| 595 | - // The list shows the newest page, which does not hold this run: only its selected job is marked. | 596 | + // A run off the list's first page opens all the same. |
| 596 | - assert!(off_page.contains("ci-run-list")); | ||
| 597 | - assert_eq!(off_page.matches("aria-current=\"true\"").count(), 1); | ||
| 598 | assert!(off_page.contains(&format!("data-live=\"{RUN_BASE}/events\""))); | 597 | assert!(off_page.contains(&format!("data-live=\"{RUN_BASE}/events\""))); |
| 599 | let rows = get(&fx.app, &format!("{RUN_BASE}?page=2"), tahinli.as_deref()) | 598 | let rows = get(&fx.app, &format!("{RUN_BASE}?page=2"), tahinli.as_deref()) |
| 600 | .await | 599 | .await |
| @@ -1482,6 +1481,11 @@ async fn running_runs_and_run_page_previews() { | |||
| 1482 | html.contains("data-tick=\"rest\""), | 1481 | html.contains("data-tick=\"rest\""), |
| 1483 | "the hatched remainder follows the clock" | 1482 | "the hatched remainder follows the clock" |
| 1484 | ); | 1483 | ); |
| 1484 | + // The timeline is on the run's own page. | ||
| 1485 | + let html = get(&fx.app, &format!("{RUN_BASE}/runs/1"), Some(&cookie)) | ||
| 1486 | + .await | ||
| 1487 | + .text() | ||
| 1488 | + .to_owned(); | ||
| 1485 | assert!( | 1489 | assert!( |
| 1486 | html.contains("data-live-gantt=\"true\""), | 1490 | html.contains("data-live-gantt=\"true\""), |
| 1487 | "the timeline is live" | 1491 | "the timeline is live" |
crates/forge-web/src/pages/code_search.rsmodified+48 -49
| @@ -203,57 +203,57 @@ async fn search_page(cx: &Cx) -> Result<impl View> { | |||
| 203 | let ref_label = ref_name.clone(); | 203 | let ref_label = ref_name.clone(); |
| 204 | 204 | ||
| 205 | let mut header = ctx.head(state, "code").await?; | 205 | let mut header = ctx.head(state, "code").await?; |
| 206 | - header.hide_search = true; | ||
| 207 | // Results of a branch go stale when it moves: the header's stream follows that branch's head. | 206 | // Results of a branch go stale when it moves: the header's stream follows that branch's head. |
| 208 | header.live = branch_live_url(&owner_name, &repo_name, &ref_name); | 207 | header.live = branch_live_url(&owner_name, &repo_name, &ref_name); |
| 209 | Ok(view! { | 208 | Ok(view! { |
| 210 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 209 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 211 | repo_head(head: header) | 210 | repo_head(head: header) |
| 212 | - <div class="search-page"> | 211 | + <form method="get" action=(action.as_str()) class="sheet search-form" role="search"> |
| 213 | - <form method="get" action=(action.as_str()) class="search-form" role="search"> | 212 | + <div class="sheet-tools"> |
| 214 | - <div class="plain-search"> | 213 | + <div class="plain-search"> |
| 215 | - <input type="search" name="q" value=(q.as_str()) data-live-search="" autocomplete="off" placeholder=(g::t(lang, K::SearchCodePlaceholder)) aria-label=(g::t(lang, K::SearchCodePlaceholder))> | 214 | + <input type="search" name="q" value=(q.as_str()) data-live-search="" autocomplete="off" placeholder=(g::t(lang, K::SearchCodePlaceholder)) aria-label=(g::t(lang, K::SearchCodePlaceholder))> |
| 216 | - <button type="submit" class="sr-only">(g::t(lang, K::SearchButton))</button> | 215 | + <button type="submit" class="sr-only">(g::t(lang, K::SearchButton))</button> |
| 217 | - </div> | ||
| 218 | - <div class="field-pair"> | ||
| 219 | - <div class="field"> | ||
| 220 | - <label for="search-ref">(g::t(lang, K::RefField))</label> | ||
| 221 | - // Not live: a half-typed branch name is a 404 page. It searches on leaving the field. | ||
| 222 | - <input id="search-ref" type="text" name="ref" value=(ref_value.as_str()) placeholder=(ctx.repo.default_branch.as_str()) data-autosubmit=(true)> | ||
| 223 | - </div> | ||
| 224 | - <div class="field"> | ||
| 225 | - <label for="search-path">(g::t(lang, K::PathField))</label> | ||
| 226 | - <input id="search-path" type="text" name="path" value=(path_value.as_str()) placeholder="src/**/*.rs" data-live-search=""> | ||
| 227 | </div> | 216 | </div> |
| 228 | </div> | 217 | </div> |
| 229 | - <label class="switch"> | 218 | + <section class="sec"> |
| 230 | - <input type="checkbox" name="case" value="1" checked=(match_case) data-autosubmit=(true)> | 219 | + <div class="fields"> |
| 231 | - <span>(g::t(lang, K::MatchCase))</span> | 220 | + <div class="field"> |
| 232 | - </label> | 221 | + <label for="search-ref">(g::t(lang, K::RefField))</label> |
| 233 | - <label class="switch"> | 222 | + // Not live: a half-typed branch name is a 404 page. It searches on leaving the field. |
| 234 | - <input type="checkbox" name="regex" value="1" checked=(regex) data-autosubmit=(true)> | 223 | + <input id="search-ref" type="text" name="ref" value=(ref_value.as_str()) placeholder=(ctx.repo.default_branch.as_str()) data-autosubmit=(true)> |
| 235 | - <span>(g::t(lang, K::RegexOption))</span> | 224 | + </div> |
| 236 | - </label> | 225 | + <div class="field"> |
| 237 | - </form> | 226 | + <label for="search-path">(g::t(lang, K::PathField))</label> |
| 238 | - if empty_repo { | 227 | + <input id="search-path" type="text" name="path" value=(path_value.as_str()) placeholder="src/**/*.rs" data-live-search=""> |
| 239 | - <p class="state">(empty_message.as_str())</p> | 228 | + </div> |
| 240 | - } else if no_query { | 229 | + <label class="switch"> |
| 241 | - <p class="state">(g::t(lang, K::SearchFilesAt)) <code>(ref_label.as_str())</code> "."</p> | 230 | + <input type="checkbox" name="case" value="1" checked=(match_case) data-autosubmit=(true)> |
| 242 | - } | 231 | + <span>(g::t(lang, K::MatchCase))</span> |
| 243 | - if let Some(msg) = notice { | 232 | + </label> |
| 244 | - <p class="state" role="alert">(msg.as_str())</p> | 233 | + <label class="switch"> |
| 245 | - } | 234 | + <input type="checkbox" name="regex" value="1" checked=(regex) data-autosubmit=(true)> |
| 246 | - if !no_query && !empty_repo { | 235 | + <span>(g::t(lang, K::RegexOption))</span> |
| 247 | - if has_results { | 236 | + </label> |
| 248 | - <p class="hint">(summary.as_str()) | 237 | + </div> |
| 249 | - if truncated { | 238 | + </section> |
| 250 | - (g::t(lang, K::ShowingFirst)) (shown.as_str()) (g::t(lang, K::ShowingFirstEnd)) | 239 | + if empty_repo { |
| 251 | - } | 240 | + <p class="state">(empty_message.as_str())</p> |
| 252 | - </p> | 241 | + } else if no_query { |
| 253 | - <section class="search-results"> | 242 | + <p class="state">(g::t(lang, K::SearchFilesAt)) <code>(ref_label.as_str())</code> "."</p> |
| 243 | + } | ||
| 244 | + if let Some(msg) = notice { | ||
| 245 | + <p class="state" role="alert">(msg.as_str())</p> | ||
| 246 | + } | ||
| 247 | + if !no_query && !empty_repo { | ||
| 248 | + if has_results { | ||
| 249 | + <p class="hint">(summary.as_str()) | ||
| 250 | + if truncated { | ||
| 251 | + (g::t(lang, K::ShowingFirst)) (shown.as_str()) (g::t(lang, K::ShowingFirstEnd)) | ||
| 252 | + } | ||
| 253 | + </p> | ||
| 254 | for group in groups.iter() { | 254 | for group in groups.iter() { |
| 255 | - <div class="search-file"> | 255 | + <section class="sec search-file"> |
| 256 | - <h3 class="search-file-name"><a href=(group.href.as_str())>(group.path.as_str())</a></h3> | 256 | + <h2><a href=(group.href.as_str())>(group.path.as_str())</a></h2> |
| 257 | <ul class="search-hits"> | 257 | <ul class="search-hits"> |
| 258 | for line in group.lines.iter() { | 258 | for line in group.lines.iter() { |
| 259 | <li> | 259 | <li> |
| @@ -270,14 +270,13 @@ async fn search_page(cx: &Cx) -> Result<impl View> { | |||
| 270 | </li> | 270 | </li> |
| 271 | } | 271 | } |
| 272 | </ul> | 272 | </ul> |
| 273 | - </div> | 273 | + </section> |
| 274 | } | 274 | } |
| 275 | - </section> | 275 | + } else if searched { |
| 276 | - } else if searched { | 276 | + empty_state(title: g::t(lang, K::NoMatches)) |
| 277 | - empty_state(title: g::t(lang, K::NoMatches)) | 277 | + } |
| 278 | } | 278 | } |
| 279 | - } | 279 | + </form> |
| 280 | - </div> | ||
| 281 | ) | 280 | ) |
| 282 | }) | 281 | }) |
| 283 | } | 282 | } |
crates/forge-web/src/pages/commit.rsmodified+92 -87
| @@ -172,7 +172,9 @@ async fn commit_page(cx: &Cx) -> Result<impl View> { | |||
| 172 | .collect(); | 172 | .collect(); |
| 173 | let is_root = parents.is_empty(); | 173 | let is_root = parents.is_empty(); |
| 174 | let body = trailers::strip_co_authors(&info.message); | 174 | let body = trailers::strip_co_authors(&info.message); |
| 175 | - let has_body = !body.trim().is_empty(); | 175 | + // The first line is the head's title, so only what follows it is shown as the message. |
| 176 | + let body_rest = body.split_once('\n').map_or("", |(_, rest)| rest).trim(); | ||
| 177 | + let has_body = !body_rest.is_empty(); | ||
| 176 | let mut coauthors: Vec<CoAuthorView> = Vec::new(); | 178 | let mut coauthors: Vec<CoAuthorView> = Vec::new(); |
| 177 | for co in trailers::co_authors(&info.message) { | 179 | for co in trailers::co_authors(&info.message) { |
| 178 | if co.email.eq_ignore_ascii_case(&info.author_email) { | 180 | if co.email.eq_ignore_ascii_case(&info.author_email) { |
| @@ -224,6 +226,7 @@ async fn commit_page(cx: &Cx) -> Result<impl View> { | |||
| 224 | let show_full = g::t(lang, K::ShowFullMessage); | 226 | let show_full = g::t(lang, K::ShowFullMessage); |
| 225 | let full_oid = info.oid.clone(); | 227 | let full_oid = info.oid.clone(); |
| 226 | let message = emojify(&body).into_owned(); | 228 | let message = emojify(&body).into_owned(); |
| 229 | + let rest_message = emojify(body_rest).into_owned(); | ||
| 227 | let statuses = state.store.statuses_for(&ctx.repo.id, &full_oid).await?; | 230 | let statuses = state.store.statuses_for(&ctx.repo.id, &full_oid).await?; |
| 228 | let checks = (!statuses.is_empty()).then(|| StatusSummary::from_rows(&statuses)); | 231 | let checks = (!statuses.is_empty()).then(|| StatusSummary::from_rows(&statuses)); |
| 229 | let sig = signatures::badges(state, &ctx.repo, std::slice::from_ref(&full_oid)) | 232 | let sig = signatures::badges(state, &ctx.repo, std::slice::from_ref(&full_oid)) |
| @@ -257,98 +260,100 @@ async fn commit_page(cx: &Cx) -> Result<impl View> { | |||
| 257 | header.live = ref_live::live_url(&owner_name, &repo_name); | 260 | header.live = ref_live::live_url(&owner_name, &repo_name); |
| 258 | Ok(view! { | 261 | Ok(view! { |
| 259 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 262 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 260 | - repo_head(head: header) | 263 | + repo_head(head: header, title: Some(heading.clone()), |
| 261 | - <h1 class="h1 commit-summary-title">(heading.as_str())</h1> | 264 | + <a class="act" href=(tree_href.as_str())>(g::t(lang, K::BrowseFiles))</a> |
| 262 | - <div class="hint commit-facts"> | 265 | + ) |
| 263 | - <button type="button" class="act quiet commit-hash" data-copy="commit-oid" data-copied=(copied) data-failed=(copy_failed) title=(full_oid.as_str())>(short.as_str())</button> | 266 | + <div class="sheet"> |
| 264 | - <code id="commit-oid" class="sr-only">(full_oid.as_str())</code> | 267 | + <div class="sheet-tools"> |
| 265 | - if let Some(badge) = sig { | 268 | + <button type="button" class="act commit-hash" data-copy="commit-oid" data-copied=(copied) data-failed=(copy_failed) title=(full_oid.as_str())>(short.as_str())</button> |
| 266 | - <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> | 269 | + <code id="commit-oid" class="sr-only">(full_oid.as_str())</code> |
| 267 | - } | 270 | + if let Some(badge) = sig { |
| 268 | - <span class="commit-author-line" title=(who_title.as_str())> | 271 | + <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> |
| 269 | - <strong>(author.name.as_str())</strong> | ||
| 270 | - if has_coauthors { | ||
| 271 | - (g::t(lang, K::CoAuthorAnd)) | ||
| 272 | - for c in coauthors.iter() { | ||
| 273 | - if c.sep { ", " } | ||
| 274 | - if let Some(href) = c.href.as_ref() { | ||
| 275 | - <a class="coauthor" href=(href.as_str())> | ||
| 276 | - if let Some(src) = c.avatar.as_ref() { | ||
| 277 | - <img class="avatar coauthor-avatar" src=(src.as_str()) alt="" width="16" height="16"> | ||
| 278 | - } | ||
| 279 | - (c.name.as_str()) | ||
| 280 | - </a> | ||
| 281 | - } else { | ||
| 282 | - <span class="coauthor" title=(c.email.as_str())>(c.name.as_str())</span> | ||
| 283 | - } | ||
| 284 | - } | ||
| 285 | - if folded { | ||
| 286 | - ", " | ||
| 287 | - <details class="coauthors-more"> | ||
| 288 | - <summary class="act">(others.as_str())</summary> | ||
| 289 | - <ul class="coauthors-list" aria-label=(coauthors_label)> | ||
| 290 | - for c in rest.iter() { | ||
| 291 | - <li> | ||
| 292 | - if let Some(href) = c.href.as_ref() { | ||
| 293 | - <a class="coauthor" href=(href.as_str())> | ||
| 294 | - if let Some(src) = c.avatar.as_ref() { | ||
| 295 | - <img class="avatar coauthor-avatar" src=(src.as_str()) alt="" width="16" height="16"> | ||
| 296 | - } | ||
| 297 | - (c.name.as_str()) | ||
| 298 | - </a> | ||
| 299 | - } else { | ||
| 300 | - <span class="coauthor" title=(c.email.as_str())>(c.name.as_str())</span> | ||
| 301 | - } | ||
| 302 | - </li> | ||
| 303 | - } | ||
| 304 | - </ul> | ||
| 305 | - </details> | ||
| 306 | - } | ||
| 307 | } | 272 | } |
| 308 | - </span> | 273 | + <span class="commit-author-line" title=(who_title.as_str())> |
| 309 | - <time data-rel="true" datetime=(author.iso.as_str()) title=(author.absolute.as_str())>(author.relative.as_str())</time> | 274 | + <strong>(author.name.as_str())</strong> |
| 310 | - if is_root { | 275 | + if has_coauthors { |
| 311 | - <span>(g::t(lang, K::RootCommit))</span> | 276 | + (g::t(lang, K::CoAuthorAnd)) |
| 312 | - } else { | 277 | + for c in coauthors.iter() { |
| 313 | - <span>(g::t(lang, K::ParentLabel)) | 278 | + if c.sep { ", " } |
| 314 | - for p in parents.iter() { | 279 | + if let Some(href) = c.href.as_ref() { |
| 315 | - <a class="mono" href=(p.href.as_str())>(p.short.as_str())</a> | 280 | + <a class="coauthor" href=(href.as_str())> |
| 281 | + if let Some(src) = c.avatar.as_ref() { | ||
| 282 | + <img class="avatar coauthor-avatar" src=(src.as_str()) alt="" width="16" height="16"> | ||
| 283 | + } | ||
| 284 | + (c.name.as_str()) | ||
| 285 | + </a> | ||
| 286 | + } else { | ||
| 287 | + <span class="coauthor" title=(c.email.as_str())>(c.name.as_str())</span> | ||
| 288 | + } | ||
| 289 | + } | ||
| 290 | + if folded { | ||
| 291 | + ", " | ||
| 292 | + <details class="coauthors-more"> | ||
| 293 | + <summary class="act">(others.as_str())</summary> | ||
| 294 | + <ul class="coauthors-list" aria-label=(coauthors_label)> | ||
| 295 | + for c in rest.iter() { | ||
| 296 | + <li> | ||
| 297 | + if let Some(href) = c.href.as_ref() { | ||
| 298 | + <a class="coauthor" href=(href.as_str())> | ||
| 299 | + if let Some(src) = c.avatar.as_ref() { | ||
| 300 | + <img class="avatar coauthor-avatar" src=(src.as_str()) alt="" width="16" height="16"> | ||
| 301 | + } | ||
| 302 | + (c.name.as_str()) | ||
| 303 | + </a> | ||
| 304 | + } else { | ||
| 305 | + <span class="coauthor" title=(c.email.as_str())>(c.name.as_str())</span> | ||
| 306 | + } | ||
| 307 | + </li> | ||
| 308 | + } | ||
| 309 | + </ul> | ||
| 310 | + </details> | ||
| 311 | + } | ||
| 316 | } | 312 | } |
| 317 | </span> | 313 | </span> |
| 314 | + <time data-rel="true" datetime=(author.iso.as_str()) title=(author.absolute.as_str())>(author.relative.as_str())</time> | ||
| 315 | + if is_root { | ||
| 316 | + <span>(g::t(lang, K::RootCommit))</span> | ||
| 317 | + } else { | ||
| 318 | + <span>(g::t(lang, K::ParentLabel)) | ||
| 319 | + for p in parents.iter() { | ||
| 320 | + <a class="mono" href=(p.href.as_str())>(p.short.as_str())</a> | ||
| 321 | + } | ||
| 322 | + </span> | ||
| 323 | + } | ||
| 324 | + if let Some(summary) = checks { | ||
| 325 | + checks_summary(summary: summary, lang: StatusLang(lang)) | ||
| 326 | + } | ||
| 327 | + </div> | ||
| 328 | + if let Some(msg) = parsed.as_ref() { | ||
| 329 | + <section class="sec"> | ||
| 330 | + <ul class="commit-groups" aria-label=(changes_label)> | ||
| 331 | + for group in msg.groups.iter() { | ||
| 332 | + <li class="commit-group"> | ||
| 333 | + <span class="mono commit-kind">(group.kind.as_str())</span> | ||
| 334 | + <ul class="commit-clauses"> | ||
| 335 | + for clause in group.clauses.iter() { | ||
| 336 | + <li>(clause.as_str())</li> | ||
| 337 | + } | ||
| 338 | + </ul> | ||
| 339 | + </li> | ||
| 340 | + } | ||
| 341 | + </ul> | ||
| 342 | + <details class="reveal commit-full-message"> | ||
| 343 | + <summary class="act">(show_full)</summary> | ||
| 344 | + <div class="opened"> | ||
| 345 | + <pre class="code commit-message"><code>(message.as_str())</code></pre> | ||
| 346 | + </div> | ||
| 347 | + </details> | ||
| 348 | + </section> | ||
| 318 | } | 349 | } |
| 319 | - if let Some(summary) = checks { | 350 | + if parsed.is_none() && has_body { |
| 320 | - checks_summary(summary: summary, lang: StatusLang(lang)) | 351 | + <section class="sec"> |
| 352 | + <pre class="code commit-message"><code>(rest_message.as_str())</code></pre> | ||
| 353 | + </section> | ||
| 321 | } | 354 | } |
| 322 | </div> | 355 | </div> |
| 323 | - <div class="acts"> | 356 | + 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) |
| 324 | - <a class="act" href=(tree_href.as_str())>(g::t(lang, K::BrowseFiles))</a> | ||
| 325 | - </div> | ||
| 326 | - if let Some(msg) = parsed.as_ref() { | ||
| 327 | - <ul class="commit-groups" aria-label=(changes_label)> | ||
| 328 | - for group in msg.groups.iter() { | ||
| 329 | - <li class="commit-group"> | ||
| 330 | - <span class="mono commit-kind">(group.kind.as_str())</span> | ||
| 331 | - <ul class="commit-clauses"> | ||
| 332 | - for clause in group.clauses.iter() { | ||
| 333 | - <li>(clause.as_str())</li> | ||
| 334 | - } | ||
| 335 | - </ul> | ||
| 336 | - </li> | ||
| 337 | - } | ||
| 338 | - </ul> | ||
| 339 | - <details class="reveal commit-full-message"> | ||
| 340 | - <summary class="act">(show_full)</summary> | ||
| 341 | - <div class="opened"> | ||
| 342 | - <pre class="code commit-message"><code>(message.as_str())</code></pre> | ||
| 343 | - </div> | ||
| 344 | - </details> | ||
| 345 | - } | ||
| 346 | - if parsed.is_none() && has_body { | ||
| 347 | - <pre class="code commit-message"><code>(message.as_str())</code></pre> | ||
| 348 | - } | ||
| 349 | - <div class="commit-diff"> | ||
| 350 | - 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) | ||
| 351 | - </div> | ||
| 352 | ) | 357 | ) |
| 353 | }) | 358 | }) |
| 354 | } | 359 | } |
crates/forge-web/src/pages/commits.rsmodified+62 -72
| @@ -5,7 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; | |||
| 5 | 5 | ||
| 6 | use std::collections::HashMap; | 6 | use std::collections::HashMap; |
| 7 | 7 | ||
| 8 | -use forge_core::store::commit_status::{CommitStatus, StatusState}; | 8 | +use forge_core::store::commit_status::CommitStatus; |
| 9 | use forge_core::tz::{format_in_tz, local_date}; | 9 | use forge_core::tz::{format_in_tz, local_date}; |
| 10 | use forge_git::browse::{self, CommitInfo}; | 10 | use forge_git::browse::{self, CommitInfo}; |
| 11 | use forge_git::history; | 11 | use forge_git::history; |
| @@ -152,18 +152,6 @@ fn day_label( | |||
| 152 | } | 152 | } |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | -impl CommitRow { | ||
| 156 | - /// The CI dot's class: none without statuses, ok, bad, or live while a status is pending. | ||
| 157 | - pub(crate) fn dot(&self) -> &'static str { | ||
| 158 | - match self.status.state { | ||
| 159 | - None => "commits-dot none", | ||
| 160 | - Some(StatusState::Success) => "commits-dot ok", | ||
| 161 | - Some(StatusState::Failure | StatusState::Error) => "commits-dot bad", | ||
| 162 | - Some(StatusState::Pending) => "commits-dot live", | ||
| 163 | - } | ||
| 164 | - } | ||
| 165 | -} | ||
| 166 | - | ||
| 167 | /// A signature badge prepared for display: the CSS classes, the visible label and the title. | 155 | /// A signature badge prepared for display: the CSS classes, the visible label and the title. |
| 168 | #[derive(Clone)] | 156 | #[derive(Clone)] |
| 169 | pub(crate) struct SigBadgeView { | 157 | pub(crate) struct SigBadgeView { |
| @@ -355,74 +343,76 @@ async fn commits_page(cx: &Cx) -> Result<impl View> { | |||
| 355 | Ok(view! { | 343 | Ok(view! { |
| 356 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 344 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 357 | repo_head(head: header) | 345 | repo_head(head: header) |
| 358 | - <p class="hint">(g::t(lang, K::CommitsOn)) <code>(ref_name.as_str())</code></p> | 346 | + <div class="sheet"> |
| 359 | - if has_filter { | 347 | + <div class="sheet-tools"> |
| 360 | - <p class="sub">(g::t(lang, K::FilteredTo)) <code>(filter_text.as_str())</code> <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilter))</a></p> | 348 | + <strong>(g::t(lang, K::CommitsOn))</strong> <code>(ref_name.as_str())</code> |
| 361 | - } | 349 | + if has_filter { |
| 362 | - if empty { | 350 | + <span class="hint">(g::t(lang, K::FilteredTo)) <code>(filter_text.as_str())</code></span> |
| 363 | - <p class="state">(g::t(lang, K::NoCommits))</p> | 351 | + <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilter))</a> |
| 364 | - if has_filter { | 352 | + } |
| 365 | - <div class="acts"><a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilter))</a></div> | 353 | + </div> |
| 366 | - } | 354 | + if empty { |
| 367 | - } else { | 355 | + <p class="state">(g::t(lang, K::NoCommits))</p> |
| 368 | - for group in groups.iter() { | 356 | + if has_filter { |
| 369 | - <section class="sec"> | 357 | + <div class="acts"><a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilter))</a></div> |
| 370 | - <h2>(group.label.as_str())</h2> | 358 | + } |
| 371 | - <div class="commits-list"> | 359 | + } else { |
| 372 | - for row in group.rows.iter() { | 360 | + for group in groups.iter() { |
| 373 | - if let Some(body) = row.body.clone() { | 361 | + <section class="sec"> |
| 374 | - <details class="row-open commits-d" data-kb-row="" data-arrive=(row.oid.as_str())> | 362 | + <h2>(group.label.as_str())</h2> |
| 375 | - <summary class="line commits-r"> | 363 | + <div class="commits-list"> |
| 376 | - <span class="commits-chev" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg></span> | 364 | + for row in group.rows.iter() { |
| 377 | - <span class=(row.dot())></span> | 365 | + if let Some(body) = row.body.clone() { |
| 366 | + <details class="row-open commits-d" data-kb-row="" data-arrive=(row.oid.as_str())> | ||
| 367 | + <summary class="line commits-r"> | ||
| 368 | + <a class="name commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> | ||
| 369 | + <span class="val"><span title=(row.email.as_str())>(row.author.as_str())</span> " · " <time class="commits-age" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time></span> | ||
| 370 | + if let Some(badge) = row.sig.clone() { | ||
| 371 | + <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> | ||
| 372 | + } | ||
| 373 | + <a class="sha commits-sha" href=(row.commit_href.as_str())>(row.short.as_str())</a> | ||
| 374 | + </summary> | ||
| 375 | + <div class="opened"> | ||
| 376 | + <pre class="code commits-x">(body.as_str())</pre> | ||
| 377 | + if !row.status.items.is_empty() { | ||
| 378 | + <div class="commit-status"> | ||
| 379 | + status_list(items: row.status.items.clone(), lang: lang) | ||
| 380 | + </div> | ||
| 381 | + } | ||
| 382 | + <div class="acts"> | ||
| 383 | + <a class="act" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFilesShort))</a> | ||
| 384 | + </div> | ||
| 385 | + </div> | ||
| 386 | + </details> | ||
| 387 | + } else { | ||
| 388 | + <div class="line commits-r" data-kb-row="" data-arrive=(row.oid.as_str())> | ||
| 378 | <a class="name commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> | 389 | <a class="name commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> |
| 379 | <span class="val"><span title=(row.email.as_str())>(row.author.as_str())</span> " · " <time class="commits-age" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time></span> | 390 | <span class="val"><span title=(row.email.as_str())>(row.author.as_str())</span> " · " <time class="commits-age" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time></span> |
| 380 | if let Some(badge) = row.sig.clone() { | 391 | if let Some(badge) = row.sig.clone() { |
| 381 | <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> | 392 | <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> |
| 382 | } | 393 | } |
| 383 | <a class="sha commits-sha" href=(row.commit_href.as_str())>(row.short.as_str())</a> | 394 | <a class="sha commits-sha" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 384 | - </summary> | 395 | + commit_status(summary: row.status.clone(), lang: StatusLang(lang)) |
| 385 | - <div class="opened"> | 396 | + <a class="act" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFilesShort))</a> |
| 386 | - <pre class="code commits-x">(body.as_str())</pre> | ||
| 387 | - if !row.status.items.is_empty() { | ||
| 388 | - <div class="commit-status"> | ||
| 389 | - status_list(items: row.status.items.clone(), lang: lang) | ||
| 390 | - </div> | ||
| 391 | - } | ||
| 392 | - <div class="acts"> | ||
| 393 | - <a class="act quiet" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFilesShort))</a> | ||
| 394 | - </div> | ||
| 395 | </div> | 397 | </div> |
| 396 | - </details> | 398 | + } |
| 397 | - } else { | ||
| 398 | - <div class="line commits-r" data-kb-row="" data-arrive=(row.oid.as_str())> | ||
| 399 | - <span class=(row.dot())></span> | ||
| 400 | - <a class="name commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> | ||
| 401 | - <span class="val"><span title=(row.email.as_str())>(row.author.as_str())</span> " · " <time class="commits-age" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time></span> | ||
| 402 | - if let Some(badge) = row.sig.clone() { | ||
| 403 | - <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> | ||
| 404 | - } | ||
| 405 | - <a class="sha commits-sha" href=(row.commit_href.as_str())>(row.short.as_str())</a> | ||
| 406 | - commit_status(summary: row.status.clone(), lang: StatusLang(lang)) | ||
| 407 | - <a class="act quiet" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFilesShort))</a> | ||
| 408 | - </div> | ||
| 409 | } | 399 | } |
| 410 | - } | 400 | + </div> |
| 411 | - </div> | 401 | + </section> |
| 412 | - </section> | ||
| 413 | - } | ||
| 414 | - } | ||
| 415 | - if has_newer || has_older { | ||
| 416 | - <nav class="sub"> | ||
| 417 | - if has_newer { | ||
| 418 | - <a href=(newer_href.as_str())>(g::t(lang, K::NewerLink))</a> | ||
| 419 | - } | ||
| 420 | - <span>(page_label.as_str())</span> | ||
| 421 | - if has_older { | ||
| 422 | - <a href=(older_href.as_str())>(g::t(lang, K::OlderLink))</a> | ||
| 423 | } | 402 | } |
| 424 | - </nav> | 403 | + } |
| 425 | - } | 404 | + if has_newer || has_older { |
| 405 | + <nav class="sub"> | ||
| 406 | + if has_newer { | ||
| 407 | + <a href=(newer_href.as_str())>(g::t(lang, K::NewerLink))</a> | ||
| 408 | + } | ||
| 409 | + <span>(page_label.as_str())</span> | ||
| 410 | + if has_older { | ||
| 411 | + <a href=(older_href.as_str())>(g::t(lang, K::OlderLink))</a> | ||
| 412 | + } | ||
| 413 | + </nav> | ||
| 414 | + } | ||
| 415 | + </div> | ||
| 426 | ) | 416 | ) |
| 427 | }) | 417 | }) |
| 428 | } | 418 | } |
crates/forge-web/src/pages/compare.rsmodified+67 -66
| @@ -324,81 +324,81 @@ async fn compare_view( | |||
| 324 | let error_text = error.unwrap_or_default(); | 324 | let error_text = error.unwrap_or_default(); |
| 325 | let csrf = csrf_of(&ctx); | 325 | let csrf = csrf_of(&ctx); |
| 326 | let pulls_action = repo_href(&owner, &name, "pulls", ""); | 326 | let pulls_action = repo_href(&owner, &name, "pulls", ""); |
| 327 | - let heading_base = base.clone(); | 327 | + let compare_title = format!("{}{base}...{head}", g::t(lang, K::ComparingPrefix)); |
| 328 | - let heading_head = head.clone(); | ||
| 329 | 328 | ||
| 330 | let mut header = ctx.head(state, "commits").await?; | 329 | let mut header = ctx.head(state, "commits").await?; |
| 331 | header.live = ref_live::live_url(&ctx.repo.owner_name, &ctx.repo.name); | 330 | header.live = ref_live::live_url(&ctx.repo.owner_name, &ctx.repo.name); |
| 332 | let __cx = cx; | 331 | let __cx = cx; |
| 333 | Ok(view! { | 332 | Ok(view! { |
| 334 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 333 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 335 | - repo_head(head: header) | 334 | + repo_head(head: header, title: Some(compare_title)) |
| 336 | - if has_commits { | 335 | + <div class="sheet"> |
| 337 | - <section class="sec"> | 336 | + if has_commits { |
| 338 | - <h2>(commits_label.as_str())</h2> | 337 | + <section class="sec"> |
| 339 | - <div> | 338 | + <h2>(commits_label.as_str())</h2> |
| 340 | - for row in rows.iter() { | 339 | + <div> |
| 341 | - <div class="line" data-kb-row=""> | 340 | + for row in rows.iter() { |
| 342 | - <a class="name commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> | 341 | + <div class="line" data-kb-row=""> |
| 343 | - <span class="val"> | 342 | + <a class="name commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> |
| 344 | - (row.author.as_str()) | 343 | + <span class="val"> |
| 345 | - if !row.email.is_empty() { | 344 | + (row.author.as_str()) |
| 346 | - " · " (row.email.as_str()) | 345 | + if !row.email.is_empty() { |
| 347 | - } | 346 | + " · " (row.email.as_str()) |
| 348 | - if lang == i18n::Lang::Tr { | 347 | + } |
| 349 | - " · " <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> " " (g::t(lang, K::Committed)) | 348 | + if lang == i18n::Lang::Tr { |
| 350 | - } else { | 349 | + " · " <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> " " (g::t(lang, K::Committed)) |
| 351 | - " · " (g::t(lang, K::Committed)) " " <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | 350 | + } else { |
| 352 | - } | 351 | + " · " (g::t(lang, K::Committed)) " " <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 353 | - </span> | 352 | + } |
| 354 | - <a class="sha commit-oid" href=(row.commit_href.as_str())>(row.short.as_str())</a> | 353 | + </span> |
| 355 | - <a class="act quiet" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFiles))</a> | 354 | + <a class="sha commit-oid" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 355 | + <a class="act" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFiles))</a> | ||
| 356 | + </div> | ||
| 357 | + } | ||
| 356 | </div> | 358 | </div> |
| 359 | + </section> | ||
| 360 | + } | ||
| 361 | + <section class="sec"> | ||
| 362 | + if unrelated { | ||
| 363 | + <p class="state">(g::t(lang, K::Unrelated))</p> | ||
| 357 | } | 364 | } |
| 358 | - </div> | 365 | + if nothing { |
| 359 | - </section> | 366 | + <p class="state">(g::t(lang, K::NothingToCompare))</p> |
| 360 | - } | ||
| 361 | - <section class="sec"> | ||
| 362 | - <h2>(g::t(lang, K::ComparingPrefix)) <code>(heading_base.as_str())</code> "..." <code>(heading_head.as_str())</code></h2> | ||
| 363 | - if unrelated { | ||
| 364 | - <p class="state">(g::t(lang, K::Unrelated))</p> | ||
| 365 | - } | ||
| 366 | - if nothing { | ||
| 367 | - <p class="state">(g::t(lang, K::NothingToCompare))</p> | ||
| 368 | - } | ||
| 369 | - if show_form { | ||
| 370 | - <div class="acts"> | ||
| 371 | - reveal(label: g::t(lang, K::OpenPullRequest), id: Some("open-pull"), open: has_error, | ||
| 372 | - if has_error { | ||
| 373 | - alert(message: error_text.as_str()) | ||
| 374 | } | 367 | } |
| 375 | - <form method="post" action=(pulls_action.as_str()) class="fields"> | 368 | + if show_form { |
| 376 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 377 | - <input type="hidden" name="base" value=(base.as_str())> | ||
| 378 | - <input type="hidden" name="head" value=(head_for_form.as_str())> | ||
| 379 | - <div class="field"> | ||
| 380 | - <label for="pull-title">(g::t(lang, K::TitleLabel))</label> | ||
| 381 | - <input id="pull-title" type="text" name="title" value=(form_title.as_str())> | ||
| 382 | - </div> | ||
| 383 | - <div class="field"> | ||
| 384 | - <label for="pull-body">(g::t(lang, K::DescriptionLabel))</label> | ||
| 385 | - <textarea id="pull-body" name="body" rows="8">(form_body.as_str())</textarea> | ||
| 386 | - </div> | ||
| 387 | <div class="acts"> | 369 | <div class="acts"> |
| 388 | - <button type="submit" class="primary">(g::t(lang, K::CreatePullRequest))</button> | 370 | + reveal(label: g::t(lang, K::OpenPullRequest), id: Some("open-pull"), open: has_error, |
| 389 | - <button type="submit" class="act" name="draft" value="1">(g::t(lang, K::CreateDraftPullRequest))</button> | 371 | + if has_error { |
| 372 | + alert(message: error_text.as_str()) | ||
| 373 | + } | ||
| 374 | + <form method="post" action=(pulls_action.as_str()) class="fields"> | ||
| 375 | + <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 376 | + <input type="hidden" name="base" value=(base.as_str())> | ||
| 377 | + <input type="hidden" name="head" value=(head_for_form.as_str())> | ||
| 378 | + <div class="field"> | ||
| 379 | + <label for="pull-title">(g::t(lang, K::TitleLabel))</label> | ||
| 380 | + <input id="pull-title" type="text" name="title" value=(form_title.as_str())> | ||
| 381 | + </div> | ||
| 382 | + <div class="field"> | ||
| 383 | + <label for="pull-body">(g::t(lang, K::DescriptionLabel))</label> | ||
| 384 | + <textarea id="pull-body" name="body" rows="8">(form_body.as_str())</textarea> | ||
| 385 | + </div> | ||
| 386 | + <div class="acts"> | ||
| 387 | + <button type="submit" class="primary">(g::t(lang, K::CreatePullRequest))</button> | ||
| 388 | + <button type="submit" class="act" name="draft" value="1">(g::t(lang, K::CreateDraftPullRequest))</button> | ||
| 389 | + </div> | ||
| 390 | + </form> | ||
| 391 | + ) | ||
| 390 | </div> | 392 | </div> |
| 391 | - </form> | 393 | + } |
| 392 | - ) | 394 | + if has_existing { |
| 393 | - </div> | 395 | + <p class="state">(g::t(lang, K::AlreadyOpen)) <a class="act" href=(existing_href.as_str())>(g::t(lang, K::ViewIt))</a></p> |
| 394 | - } | 396 | + } |
| 395 | - if has_existing { | 397 | + if archived_note { |
| 396 | - <p class="state">(g::t(lang, K::AlreadyOpen)) <a class="act" href=(existing_href.as_str())>(g::t(lang, K::ViewIt))</a></p> | 398 | + <p class="state">(g::t(lang, K::ArchivedNoPulls))</p> |
| 397 | - } | 399 | + } |
| 398 | - if archived_note { | 400 | + </section> |
| 399 | - <p class="state">(g::t(lang, K::ArchivedNoPulls))</p> | 401 | + </div> |
| 400 | - } | ||
| 401 | - </section> | ||
| 402 | if show_diff { | 402 | if show_diff { |
| 403 | for d in diff.iter() { | 403 | for d in diff.iter() { |
| 404 | 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()) | 404 | 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 | |||
| 426 | let __cx = cx; | 426 | let __cx = cx; |
| 427 | Ok(view! { | 427 | Ok(view! { |
| 428 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 428 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 429 | - repo_head(head: header) | 429 | + repo_head(head: header, title: Some(g::t(lang, K::CompareBranches).to_owned())) |
| 430 | + <div class="sheet fit"> | ||
| 430 | <section class="sec"> | 431 | <section class="sec"> |
| 431 | - <h2>(g::t(lang, K::CompareBranches))</h2> | ||
| 432 | <form method="get" action=(action.as_str()) class="fields"> | 432 | <form method="get" action=(action.as_str()) class="fields"> |
| 433 | <div class="field"> | 433 | <div class="field"> |
| 434 | <label for="compare-base">(g::t(lang, K::BasePrefix))</label> | 434 | <label for="compare-base">(g::t(lang, K::BasePrefix))</label> |
| @@ -446,6 +446,7 @@ async fn picker_view(cx: &Cx, ctx: RepoCtx, base: String, head: String) -> Resul | |||
| 446 | <button type="submit" class="primary">(g::t(lang, K::Compare))</button> | 446 | <button type="submit" class="primary">(g::t(lang, K::Compare))</button> |
| 447 | </form> | 447 | </form> |
| 448 | </section> | 448 | </section> |
| 449 | + </div> | ||
| 449 | ) | 450 | ) |
| 450 | }) | 451 | }) |
| 451 | } | 452 | } |
crates/forge-web/src/pages/discussion_settings.rsmodified+2 -2
| @@ -23,7 +23,7 @@ use crate::views::repo_href; | |||
| 23 | path_param!(owner); | 23 | path_param!(owner); |
| 24 | path_param!(repo); | 24 | path_param!(repo); |
| 25 | 25 | ||
| 26 | -/// The Discussions topic: a hint, then one switch. `enabled` is the current state. The switch submits | 26 | +/// The Discussions topic: one switch, then its hint. `enabled` is the current state. The switch submits |
| 27 | /// the form on change (`data-autosubmit`); an unchecked box sends no `enabled`, which the handler reads as off. | 27 | /// the form on change (`data-autosubmit`); an unchecked box sends no `enabled`, which the handler reads as off. |
| 28 | #[component] | 28 | #[component] |
| 29 | pub(crate) async fn discussions_card( | 29 | pub(crate) async fn discussions_card( |
| @@ -40,13 +40,13 @@ pub(crate) async fn discussions_card( | |||
| 40 | Ok(view! { | 40 | Ok(view! { |
| 41 | <section class="sec" id="discussions"> | 41 | <section class="sec" id="discussions"> |
| 42 | <h2>(g::t(lang, K::Discussions))</h2> | 42 | <h2>(g::t(lang, K::Discussions))</h2> |
| 43 | - <p class="hint">(g::t(lang, K::DiscussionsDescription))</p> | ||
| 44 | <form method="post" action=(action.as_str())> | 43 | <form method="post" action=(action.as_str())> |
| 45 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 44 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 46 | <label class="switch"> | 45 | <label class="switch"> |
| 47 | <input type="checkbox" name="enabled" value="1" checked=(enabled) data-autosubmit="true"> | 46 | <input type="checkbox" name="enabled" value="1" checked=(enabled) data-autosubmit="true"> |
| 48 | <span>(switch_label)</span> | 47 | <span>(switch_label)</span> |
| 49 | </label> | 48 | </label> |
| 49 | + <p class="hint">(g::t(lang, K::DiscussionsDescription))</p> | ||
| 50 | </form> | 50 | </form> |
| 51 | </section> | 51 | </section> |
| 52 | }) | 52 | }) |
crates/forge-web/src/pages/discussion_view.rsmodified+30 -30
| @@ -25,7 +25,7 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo}; | |||
| 25 | use crate::pages::tree::link_context; | 25 | use crate::pages::tree::link_context; |
| 26 | use crate::render::markdown::{LinkContext, render_markdown}; | 26 | use crate::render::markdown::{LinkContext, render_markdown}; |
| 27 | use crate::state::AppState; | 27 | use crate::state::AppState; |
| 28 | -use crate::views::parts::{confirm_act, post_act, reveal}; | 28 | +use crate::views::parts::{SubPart, confirm_act, post_act, reveal}; |
| 29 | use crate::views::{avatar_url, display_name, now_unix, shell, user_href, user_link}; | 29 | use crate::views::{avatar_url, display_name, now_unix, shell, user_href, user_link}; |
| 30 | 30 | ||
| 31 | path_param!(owner); | 31 | path_param!(owner); |
| @@ -184,9 +184,9 @@ async fn comment_article(item: CommentView) -> Result<impl View> { | |||
| 184 | } = item; | 184 | } = item; |
| 185 | let profile = user_href(&login); | 185 | let profile = user_href(&login); |
| 186 | let class = if accepted { | 186 | let class = if accepted { |
| 187 | - "sec discussion-accepted" | 187 | + "sec thread-entry discussion-accepted" |
| 188 | } else { | 188 | } else { |
| 189 | - "sec" | 189 | + "sec thread-entry" |
| 190 | }; | 190 | }; |
| 191 | let answer_fields = vec![ | 191 | let answer_fields = vec![ |
| 192 | ("comment_id".to_owned(), id.clone()), | 192 | ("comment_id".to_owned(), id.clone()), |
| @@ -198,18 +198,18 @@ async fn comment_article(item: CommentView) -> Result<impl View> { | |||
| 198 | let edit_open = format!("edit-open-{id}"); | 198 | let edit_open = format!("edit-open-{id}"); |
| 199 | Ok(view! { | 199 | Ok(view! { |
| 200 | <article class=(class) id=(anchor.as_str())> | 200 | <article class=(class) id=(anchor.as_str())> |
| 201 | - <p class="state"> | 201 | + <header class="thread-head"> |
| 202 | if deleted { | 202 | if deleted { |
| 203 | (g::t(lang, K::CommentDeleted)) | 203 | (g::t(lang, K::CommentDeleted)) |
| 204 | } else { | 204 | } else { |
| 205 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> | 205 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> |
| 206 | - " " user_link(shown: author.as_str(), login: login.as_str()) | 206 | + <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> |
| 207 | - " " <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> | 207 | + <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> |
| 208 | } | 208 | } |
| 209 | if accepted { | 209 | if accepted { |
| 210 | " · " (g::t(lang, K::Answer)) | 210 | " · " (g::t(lang, K::Answer)) |
| 211 | } | 211 | } |
| 212 | - </p> | 212 | + </header> |
| 213 | if !deleted { | 213 | if !deleted { |
| 214 | <div class="markdown-body">(Unescaped::new_unchecked(html))</div> | 214 | <div class="markdown-body">(Unescaped::new_unchecked(html))</div> |
| 215 | if let Some(bar) = reactions { | 215 | if let Some(bar) = reactions { |
| @@ -414,31 +414,29 @@ async fn discussion_page( | |||
| 414 | let header = ctx.head(state, "discussions").await?; | 414 | let header = ctx.head(state, "discussions").await?; |
| 415 | 415 | ||
| 416 | let comments_label = g::comments_total(lang, discussion.comment_count); | 416 | let comments_label = g::comments_total(lang, discussion.comment_count); |
| 417 | + let mut sub = vec![SubPart::text(category)]; | ||
| 418 | + if answered { | ||
| 419 | + sub.push(SubPart::text(g::t(lang, K::Answered))); | ||
| 420 | + } | ||
| 421 | + if locked { | ||
| 422 | + sub.push(SubPart::text(g::t(lang, K::Locked))); | ||
| 423 | + } | ||
| 424 | + sub.push(SubPart::link(author.clone(), author_profile.clone())); | ||
| 425 | + sub.push(SubPart::text(opened.relative.clone())); | ||
| 426 | + sub.push(SubPart::text(comments_label)); | ||
| 417 | Ok(view! { cx => | 427 | Ok(view! { cx => |
| 418 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 428 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 419 | - repo_head(head: header) | 429 | + repo_head(head: header, title: Some(discussion.title.clone()), sub: sub, |
| 420 | - <section class="sec" data-live=(live_href.as_str()) data-live-now=""> | 430 | + <span class="num">(number_label.as_str())</span> |
| 421 | - <h1 class="h1">(discussion.title.as_str()) " " <span class="hint">(number_label.as_str())</span></h1> | 431 | + ) |
| 422 | - <p class="hint"> | 432 | + <div class="work" data-live=(live_href.as_str()) data-live-now=""> |
| 423 | - (category) | 433 | + <div class="sheet"> |
| 424 | - if answered { | 434 | + <article class="sec thread-entry" id="discussion-body"> |
| 425 | - " " (g::t(lang, K::Answered)) | 435 | + <header class="thread-head"> |
| 426 | - } | ||
| 427 | - if locked { | ||
| 428 | - " " (g::t(lang, K::Locked)) | ||
| 429 | - } | ||
| 430 | - " " user_link(shown: author.as_str(), login: author_login.as_str()) | ||
| 431 | - " " (g::t(lang, K::OpenedThis)) " " | ||
| 432 | - <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> | ||
| 433 | - " " (g::t(lang, K::OpenedSeparator)) " " | ||
| 434 | - (comments_label.as_str()) | ||
| 435 | - </p> | ||
| 436 | - </section> | ||
| 437 | - <article class="sec" id="discussion-body"> | ||
| 438 | - <p class="state"> | ||
| 439 | <a href=(author_profile.as_str()) aria-label=(author.as_str())><img class="avatar avatar-sm" src=(author_avatar.as_str()) alt="" width="24" height="24"></a> | 436 | <a href=(author_profile.as_str()) aria-label=(author.as_str())><img class="avatar avatar-sm" src=(author_avatar.as_str()) alt="" width="24" height="24"></a> |
| 440 | - " " user_link(shown: author.as_str(), login: author_login.as_str()) | 437 | + <strong>user_link(shown: author.as_str(), login: author_login.as_str())</strong> |
| 441 | - </p> | 438 | + <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> |
| 439 | + </header> | ||
| 442 | <div class="markdown-body">(Unescaped::new_unchecked(body_html))</div> | 440 | <div class="markdown-body">(Unescaped::new_unchecked(body_html))</div> |
| 443 | if let Some(bar) = body_bar { | 441 | if let Some(bar) = body_bar { |
| 444 | reaction_row(lang: lang, bar: bar) | 442 | reaction_row(lang: lang, bar: bar) |
| @@ -487,13 +485,15 @@ async fn discussion_page( | |||
| 487 | <p class="state">(g::t(lang, K::ArchivedDiscussions))</p> | 485 | <p class="state">(g::t(lang, K::ArchivedDiscussions))</p> |
| 488 | } | 486 | } |
| 489 | if triage && !archived { | 487 | if triage && !archived { |
| 490 | - <section class="sec"> | 488 | + <section class="sec meta"> |
| 491 | <h2>(g::t(lang, K::Conversation))</h2> | 489 | <h2>(g::t(lang, K::Conversation))</h2> |
| 492 | <div class="acts"> | 490 | <div class="acts"> |
| 493 | post_act(label: lock_label, action: lock_action.as_str(), csrf: csrf.as_str(), fields: vec![("locked".to_owned(), lock_value.to_owned())]) | 491 | post_act(label: lock_label, action: lock_action.as_str(), csrf: csrf.as_str(), fields: vec![("locked".to_owned(), lock_value.to_owned())]) |
| 494 | </div> | 492 | </div> |
| 495 | </section> | 493 | </section> |
| 496 | } | 494 | } |
| 495 | + </div> | ||
| 496 | + </div> | ||
| 497 | ) | 497 | ) |
| 498 | }) | 498 | }) |
| 499 | } | 499 | } |
crates/forge-web/src/pages/discussions.rsmodified+65 -64
| @@ -22,11 +22,12 @@ use crate::i18n::{self, Lang}; | |||
| 22 | use crate::pages::discussion_live::list_live_url; | 22 | use crate::pages::discussion_live::list_live_url; |
| 23 | use crate::pages::issue_meta::{can_triage, form_field, form_pairs, refusal_message}; | 23 | use crate::pages::issue_meta::{can_triage, form_field, form_pairs, refusal_message}; |
| 24 | use crate::pages::issue_parts::When; | 24 | use crate::pages::issue_parts::When; |
| 25 | -use crate::pages::issues_list::{list_href, state_tab}; | 25 | +use crate::pages::issues_list::list_href; |
| 26 | use crate::pages::repo::repo_head; | 26 | use crate::pages::repo::repo_head; |
| 27 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | 27 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 28 | use crate::render::markdown::mentioned_usernames; | 28 | use crate::render::markdown::mentioned_usernames; |
| 29 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| 30 | +use crate::views::parts::{RailItem, SubPart, rail}; | ||
| 30 | use crate::views::{alert, csrf_field, now_unix, repo_href, shell, user_link}; | 31 | use crate::views::{alert, csrf_field, now_unix, repo_href, shell, user_link}; |
| 31 | 32 | ||
| 32 | path_param!(owner); | 33 | path_param!(owner); |
| @@ -262,18 +263,28 @@ async fn discussions_list_page(cx: &Cx) -> Result<impl View> { | |||
| 262 | let selected = category.map_or("", |c| c.as_str()); | 263 | let selected = category.map_or("", |c| c.as_str()); |
| 263 | let all_on = category.is_none(); | 264 | let all_on = category.is_none(); |
| 264 | let all_href = list_href(&base, &[]); | 265 | let all_href = list_href(&base, &[]); |
| 265 | - let all_label = g::t(lang, K::AllCategories); | ||
| 266 | let nav_label = g::t(lang, K::CategoriesNav); | 266 | let nav_label = g::t(lang, K::CategoriesNav); |
| 267 | - let tabs: Vec<(&'static str, String, bool)> = DISCUSSION_CATEGORIES | 267 | + let list_title = match category { |
| 268 | - .iter() | 268 | + Some(c) => g::category_label(lang, c), |
| 269 | - .map(|c| { | 269 | + None => g::t(lang, K::AllCategories), |
| 270 | - ( | 270 | + }; |
| 271 | - g::category_label(lang, *c), | 271 | + let mut rail_items: Vec<RailItem> = vec![RailItem { |
| 272 | - list_href(&base, &[("category", c.as_str())]), | 272 | + name: g::t(lang, K::AllCategories).to_owned(), |
| 273 | - category == Some(*c), | 273 | + val: String::new(), |
| 274 | - ) | 274 | + href: all_href, |
| 275 | - }) | 275 | + current: all_on, |
| 276 | - .collect(); | 276 | + }]; |
| 277 | + rail_items.extend(DISCUSSION_CATEGORIES.iter().map(|c| RailItem { | ||
| 278 | + name: g::category_label(lang, *c).to_owned(), | ||
| 279 | + val: String::new(), | ||
| 280 | + href: list_href(&base, &[("category", c.as_str())]), | ||
| 281 | + current: category == Some(*c), | ||
| 282 | + })); | ||
| 283 | + let sub = vec![SubPart::text(match lang { | ||
| 284 | + Lang::En if total == 1 => "1 discussion".to_owned(), | ||
| 285 | + Lang::En => format!("{total} discussions"), | ||
| 286 | + Lang::Tr => format!("{total} tartışma"), | ||
| 287 | + })]; | ||
| 277 | 288 | ||
| 278 | let last_page = total.div_ceil(u64::from(PER_PAGE)).max(1); | 289 | let last_page = total.div_ceil(u64::from(PER_PAGE)).max(1); |
| 279 | let has_newer = page > 1; | 290 | let has_newer = page > 1; |
| @@ -302,62 +313,51 @@ async fn discussions_list_page(cx: &Cx) -> Result<impl View> { | |||
| 302 | let header = ctx.head(state, "discussions").await?; | 313 | let header = ctx.head(state, "discussions").await?; |
| 303 | Ok(view! { | 314 | Ok(view! { |
| 304 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 315 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 305 | - repo_head(head: header) | 316 | + repo_head(head: header, sub: sub, |
| 306 | - <div data-live=(live_href.as_str()) data-live-now=""> | ||
| 307 | - <h1 class="sr-only">(title.as_str())</h1> | ||
| 308 | - <nav class="tabs" aria-label=(nav_label)> | ||
| 309 | - state_tab(href: all_href.as_str(), text: all_label, current: all_on) | ||
| 310 | - for tab in tabs.iter() { | ||
| 311 | - state_tab(href: tab.1.as_str(), text: tab.0, current: tab.2) | ||
| 312 | - } | ||
| 313 | - </nav> | ||
| 314 | - if can_start { | ||
| 315 | - <div class="sub"> | ||
| 316 | - <a class="act" href=(new_href.as_str())>(new_label)</a> | ||
| 317 | - </div> | ||
| 318 | - } | ||
| 319 | - if rows.is_empty() { | ||
| 320 | - <p class="state">(empty_text)</p> | ||
| 321 | if can_start { | 317 | if can_start { |
| 322 | - <div class="acts"> | 318 | + <a class="button primary" href=(new_href.as_str())>(new_label)</a> |
| 323 | - <a class="act" href=(new_href.as_str())>(new_label)</a> | ||
| 324 | - </div> | ||
| 325 | } | 319 | } |
| 326 | - } else { | 320 | + ) |
| 327 | - <div> | 321 | + <div class="work" data-live=(live_href.as_str()) data-live-now=""> |
| 328 | - for row in rows.iter() { | 322 | + rail(label: nav_label, items: rail_items) |
| 329 | - <div class="line issue-row" data-kb-row=""> | 323 | + <div class="sheet"> |
| 330 | - <div class="issue-main"> | 324 | + <div class="sheet-tools"> |
| 331 | - <div class="issue-title-line"> | 325 | + <strong>(list_title)</strong> |
| 332 | - <a class="issue-title" href=(row.href.as_str())>(row.title.as_str())</a> | 326 | + </div> |
| 333 | - <span class="discussion-category">(row.category)</span> | 327 | + if rows.is_empty() { |
| 334 | - </div> | 328 | + <p class="state">(empty_text)</p> |
| 335 | - <div class="issue-meta muted small"> | 329 | + if can_start { |
| 336 | - <span>(by_before)</span> | 330 | + <div class="acts"> |
| 337 | - <span>user_link(shown: row.author.as_str(), login: row.author.as_str())</span> | 331 | + <a class="act" href=(new_href.as_str())>(new_label)</a> |
| 338 | - <span>(by_middle)</span> | 332 | + </div> |
| 333 | + } | ||
| 334 | + } else { | ||
| 335 | + for row in rows.iter() { | ||
| 336 | + <div class="line" data-kb-row=""> | ||
| 337 | + <a class="name" href=(row.href.as_str())>(row.title.as_str())</a> | ||
| 338 | + <span class="tag">(row.category)</span> | ||
| 339 | + <span class="val"> | ||
| 340 | + (by_before) user_link(shown: row.author.as_str(), login: row.author.as_str()) (by_middle) | ||
| 339 | <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | 341 | <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 340 | - if !by_after.is_empty() { | 342 | + (by_after) |
| 341 | - <span>(by_after)</span> | 343 | + " · " |
| 342 | - } | 344 | + <a href=(row.href.as_str())>(row.comments_text.as_str())</a> |
| 343 | - <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> | 345 | + </span> |
| 344 | - </div> | ||
| 345 | </div> | 346 | </div> |
| 346 | - </div> | 347 | + } |
| 347 | - } | ||
| 348 | - </div> | ||
| 349 | - } | ||
| 350 | - if has_newer || has_older { | ||
| 351 | - <nav class="sub"> | ||
| 352 | - if has_newer { | ||
| 353 | - <a href=(newer_href.as_str())>(newer_label)</a> | ||
| 354 | } | 348 | } |
| 355 | - <span>(page_label.as_str())</span> | 349 | + if has_newer || has_older { |
| 356 | - if has_older { | 350 | + <nav class="sub"> |
| 357 | - <a href=(older_href.as_str())>(older_label)</a> | 351 | + if has_newer { |
| 352 | + <a href=(newer_href.as_str())>(newer_label)</a> | ||
| 353 | + } | ||
| 354 | + <span>(page_label.as_str())</span> | ||
| 355 | + if has_older { | ||
| 356 | + <a href=(older_href.as_str())>(older_label)</a> | ||
| 357 | + } | ||
| 358 | + </nav> | ||
| 358 | } | 359 | } |
| 359 | - </nav> | 360 | + </div> |
| 360 | - } | ||
| 361 | </div> | 361 | </div> |
| 362 | ) | 362 | ) |
| 363 | }) | 363 | }) |
| @@ -382,8 +382,8 @@ async fn new_discussion_body( | |||
| 382 | let action = discussions_href(&head.owner, &head.name, "new"); | 382 | let action = discussions_href(&head.owner, &head.name, "new"); |
| 383 | let cancel = discussions_href(&head.owner, &head.name, ""); | 383 | let cancel = discussions_href(&head.owner, &head.name, ""); |
| 384 | Ok(view! { | 384 | Ok(view! { |
| 385 | - repo_head(head: head) | 385 | + repo_head(head: head, title: Some(g::t(lang, K::NewDiscussion).to_owned())) |
| 386 | - <h1 class="sr-only">(g::t(lang, K::NewDiscussion))</h1> | 386 | + <div class="sheet fit"> |
| 387 | if let Some(message) = draft.error { | 387 | if let Some(message) = draft.error { |
| 388 | alert(message: message.as_str()) | 388 | alert(message: message.as_str()) |
| 389 | } | 389 | } |
| @@ -411,6 +411,7 @@ async fn new_discussion_body( | |||
| 411 | <a class="act quiet" href=(cancel.as_str())>(g::t(lang, K::Cancel))</a> | 411 | <a class="act quiet" href=(cancel.as_str())>(g::t(lang, K::Cancel))</a> |
| 412 | </div> | 412 | </div> |
| 413 | </form> | 413 | </form> |
| 414 | + </div> | ||
| 414 | }) | 415 | }) |
| 415 | } | 416 | } |
| 416 | 417 | ||
crates/forge-web/src/pages/edit_history.rsmodified+16 -15
| @@ -23,6 +23,7 @@ use crate::pages::pull_live::pull_live_url; | |||
| 23 | use crate::pages::repo::repo_head; | 23 | use crate::pages::repo::repo_head; |
| 24 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; | 24 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 25 | use crate::state::AppState; | 25 | use crate::state::AppState; |
| 26 | +use crate::views::parts::SubPart; | ||
| 26 | use crate::views::{display_name, now_unix, repo_href, shell}; | 27 | use crate::views::{display_name, now_unix, repo_href, shell}; |
| 27 | 28 | ||
| 28 | path_param!(owner); | 29 | path_param!(owner); |
| @@ -228,6 +229,10 @@ async fn history_page( | |||
| 228 | let heading = g::history_heading(lang, what); | 229 | let heading = g::history_heading(lang, what); |
| 229 | let back_label = g::back_to_item(lang, number); | 230 | let back_label = g::back_to_item(lang, number); |
| 230 | let count_label = g::earlier_versions(lang, entries.len()); | 231 | let count_label = g::earlier_versions(lang, entries.len()); |
| 232 | + let sub = vec![ | ||
| 233 | + SubPart::link(back_label, back), | ||
| 234 | + SubPart::text(count_label), | ||
| 235 | + ]; | ||
| 231 | // A history follows its item: a new edit adds a version to the list. | 236 | // A history follows its item: a new edit adds a version to the list. |
| 232 | let live = match kind_item { | 237 | let live = match kind_item { |
| 233 | ItemKind::Issue => item_live_url(&owner, &name, number), | 238 | ItemKind::Issue => item_live_url(&owner, &name, number), |
| @@ -236,22 +241,18 @@ async fn history_page( | |||
| 236 | 241 | ||
| 237 | Ok(view! { cx => | 242 | Ok(view! { cx => |
| 238 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 243 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 239 | - repo_head(head: header) | 244 | + repo_head(head: header, title: Some(heading), sub: sub) |
| 240 | - <section class="sec" data-live=(live.as_str()) data-live-now=""> | 245 | + <div class="work" data-live=(live.as_str()) data-live-now=""> |
| 241 | - <h1 class="h1">(heading.as_str())</h1> | 246 | + <div class="sheet"> |
| 242 | - <p class="hint"> | ||
| 243 | - <a href=(back.as_str())>(back_label.as_str())</a> | ||
| 244 | - " · " | ||
| 245 | - (count_label.as_str()) | ||
| 246 | - </p> | ||
| 247 | - </section> | ||
| 248 | - <div class="issue-timeline"> | ||
| 249 | if entries.is_empty() { | 247 | if entries.is_empty() { |
| 250 | - <p class="hint">(g::t(lang, K::NoEarlierVersions))</p> | 248 | + <p class="state">(g::t(lang, K::NoEarlierVersions))</p> |
| 251 | - } | ||
| 252 | - for entry in entries.into_iter() { | ||
| 253 | - history_entry(lang: lang, entry: entry) | ||
| 254 | } | 249 | } |
| 250 | + <div class="issue-timeline"> | ||
| 251 | + for entry in entries.into_iter() { | ||
| 252 | + history_entry(lang: lang, entry: entry) | ||
| 253 | + } | ||
| 254 | + </div> | ||
| 255 | + </div> | ||
| 255 | </div> | 256 | </div> |
| 256 | ) | 257 | ) |
| 257 | }) | 258 | }) |
| @@ -270,7 +271,7 @@ async fn history_entry(lang: Lang, entry: HistoryEntry) -> Result<impl View> { | |||
| 270 | } = entry; | 271 | } = entry; |
| 271 | let title_text = title_change.map(|(from, to)| g::title_change(lang, &from, &to)); | 272 | let title_text = title_change.map(|(from, to)| g::title_change(lang, &from, &to)); |
| 272 | Ok(view! { | 273 | Ok(view! { |
| 273 | - <article class="thread-entry"> | 274 | + <article class="sec thread-entry"> |
| 274 | <header class="thread-head"> | 275 | <header class="thread-head"> |
| 275 | <strong>(editor.as_str())</strong> | 276 | <strong>(editor.as_str())</strong> |
| 276 | (g::t(lang, K::EditedBy)) | 277 | (g::t(lang, K::EditedBy)) |
crates/forge-web/src/pages/explore.rsmodified+15 -17
| @@ -15,6 +15,7 @@ use crate::i18n::orgs::{self as g, K}; | |||
| 15 | use crate::i18n::{self, Lang}; | 15 | use crate::i18n::{self, Lang}; |
| 16 | use crate::live::{Topic, stream_changes}; | 16 | use crate::live::{Topic, stream_changes}; |
| 17 | use crate::state::AppState; | 17 | use crate::state::AppState; |
| 18 | +use crate::views::parts::{SubPart, head}; | ||
| 18 | use crate::views::repo_list::{ | 19 | use crate::views::repo_list::{ |
| 19 | PageLink, RepoRow, SortLink, pager, pager_links, repo_rows, sort_chips, | 20 | PageLink, RepoRow, SortLink, pager, pager_links, repo_rows, sort_chips, |
| 20 | }; | 21 | }; |
| @@ -199,18 +200,17 @@ async fn explore_body( | |||
| 199 | let (links, prev, next) = nav; | 200 | let (links, prev, next) = nav; |
| 200 | let clear_href = explore_href("", sort, 1); | 201 | let clear_href = explore_href("", sort, 1); |
| 201 | Ok(view! { | 202 | Ok(view! { |
| 202 | - <h1 class="sr-only">(g::t(lang, K::Explore))</h1> | 203 | + head(title: g::t(lang, K::Explore), sub: vec![SubPart::text(g::t(lang, K::PublicReposIntro))]) |
| 203 | - <section class="explore" data-live=(live.as_str())> | 204 | + <div class="sheet" data-live=(live.as_str())> |
| 204 | - <p class="hint">(g::t(lang, K::PublicReposIntro))</p> | 205 | + <div class="sheet-tools"> |
| 205 | - <form method="get" action="/explore" class="plain-search" role="search"> | 206 | + <strong>(g::repo_count(lang, total))</strong> |
| 206 | - <input type="search" name="q" value=(q.as_str()) data-live-search="" | 207 | + <form method="get" action="/explore" class="plain-search" role="search"> |
| 207 | - placeholder=(g::t(lang, K::SearchPublicRepos)) aria-label=(g::t(lang, K::SearchPublicRepos))> | 208 | + <input type="search" name="q" value=(q.as_str()) data-live-search="" |
| 208 | - <input type="hidden" name="sort" value=(sort)> | 209 | + placeholder=(g::t(lang, K::SearchPublicRepos)) aria-label=(g::t(lang, K::SearchPublicRepos))> |
| 209 | - <button type="submit" class="act">(g::t(lang, K::Search))</button> | 210 | + <input type="hidden" name="sort" value=(sort)> |
| 210 | - </form> | 211 | + <button type="submit" class="act">(g::t(lang, K::Search))</button> |
| 211 | - <div class="sub"> | 212 | + </form> |
| 212 | sort_chips(links: sort_links, lang: lang) | 213 | sort_chips(links: sort_links, lang: lang) |
| 213 | - <span>(g::repo_count(lang, total))</span> | ||
| 214 | </div> | 214 | </div> |
| 215 | if empty { | 215 | if empty { |
| 216 | <p class="state">(g::t(lang, K::NoPublicReposMatch))</p> | 216 | <p class="state">(g::t(lang, K::NoPublicReposMatch))</p> |
| @@ -226,14 +226,12 @@ async fn explore_body( | |||
| 226 | if has_orgs { | 226 | if has_orgs { |
| 227 | <section class="sec"> | 227 | <section class="sec"> |
| 228 | <h2>(g::t(lang, K::Organizations))</h2> | 228 | <h2>(g::t(lang, K::Organizations))</h2> |
| 229 | - <div> | 229 | + for org in orgs.iter() { |
| 230 | - for org in orgs.iter() { | 230 | + <a class="line" href=(format!("/{}", org.as_str()))><span class="name">(org.as_str())</span></a> |
| 231 | - <a class="line" href=(format!("/{}", org.as_str()))><span class="name">(org.as_str())</span></a> | 231 | + } |
| 232 | - } | ||
| 233 | - </div> | ||
| 234 | </section> | 232 | </section> |
| 235 | } | 233 | } |
| 236 | - </section> | 234 | + </div> |
| 237 | }) | 235 | }) |
| 238 | } | 236 | } |
| 239 | 237 | ||
crates/forge-web/src/pages/forgot.rsmodified+15 -11
| @@ -22,6 +22,7 @@ use crate::mail::account; | |||
| 22 | use crate::pages::register::check_new_password; | 22 | use crate::pages::register::check_new_password; |
| 23 | use crate::state::AppState; | 23 | use crate::state::AppState; |
| 24 | use crate::throttle; | 24 | use crate::throttle; |
| 25 | +use crate::views::parts::{SubPart, head}; | ||
| 25 | use crate::views::{alert, shell}; | 26 | use crate::views::{alert, shell}; |
| 26 | 27 | ||
| 27 | /// Reset requests allowed per client IP inside the throttle window. | 28 | /// Reset requests allowed per client IP inside the throttle window. |
| @@ -58,9 +59,8 @@ enum ResetMode { | |||
| 58 | #[component] | 59 | #[component] |
| 59 | async fn forgot_form(lang: Lang, precsrf: &str) -> Result<impl View> { | 60 | async fn forgot_form(lang: Lang, precsrf: &str) -> Result<impl View> { |
| 60 | Ok(view! { | 61 | Ok(view! { |
| 61 | - <section> | 62 | + head(title: t(lang, Key::ForgotTitle), sub: vec![SubPart::text(t(lang, Key::ForgotSub))]) |
| 62 | - <h1>(t(lang, Key::ForgotTitle))</h1> | 63 | + <div class="sheet fit"> |
| 63 | - <p class="hint">(t(lang, Key::ForgotSub))</p> | ||
| 64 | <form data-hard="true" method="post" action="/forgot" class="fields"> | 64 | <form data-hard="true" method="post" action="/forgot" class="fields"> |
| 65 | <input type="hidden" name="precsrf" value=(precsrf)> | 65 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 66 | <div class="field"> | 66 | <div class="field"> |
| @@ -69,17 +69,17 @@ async fn forgot_form(lang: Lang, precsrf: &str) -> Result<impl View> { | |||
| 69 | </div> | 69 | </div> |
| 70 | <button type="submit" class="primary">(t(lang, Key::ForgotSubmit))</button> | 70 | <button type="submit" class="primary">(t(lang, Key::ForgotSubmit))</button> |
| 71 | </form> | 71 | </form> |
| 72 | - </section> | 72 | + </div> |
| 73 | }) | 73 | }) |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | #[component] | 76 | #[component] |
| 77 | async fn forgot_sent(lang: Lang) -> Result<impl View> { | 77 | async fn forgot_sent(lang: Lang) -> Result<impl View> { |
| 78 | Ok(view! { | 78 | Ok(view! { |
| 79 | - <section> | 79 | + head(title: t(lang, Key::ForgotTitle)) |
| 80 | - <h1>(t(lang, Key::ForgotTitle))</h1> | 80 | + <div class="sheet fit"> |
| 81 | <p class="state" role="status">(t(lang, Key::ForgotSent))</p> | 81 | <p class="state" role="status">(t(lang, Key::ForgotSent))</p> |
| 82 | - </section> | 82 | + </div> |
| 83 | }) | 83 | }) |
| 84 | } | 84 | } |
| 85 | 85 | ||
| @@ -149,11 +149,15 @@ async fn reset_body( | |||
| 149 | mode: ResetMode, | 149 | mode: ResetMode, |
| 150 | error: Option<String>, | 150 | error: Option<String>, |
| 151 | ) -> Result<impl View> { | 151 | ) -> Result<impl View> { |
| 152 | + let sub = if mode == ResetMode::Form { | ||
| 153 | + vec![SubPart::text(t(lang, Key::ResetSub))] | ||
| 154 | + } else { | ||
| 155 | + Vec::new() | ||
| 156 | + }; | ||
| 152 | Ok(view! { | 157 | Ok(view! { |
| 153 | - <section> | 158 | + head(title: t(lang, Key::ResetTitle), sub: sub) |
| 154 | - <h1>(t(lang, Key::ResetTitle))</h1> | 159 | + <div class="sheet fit"> |
| 155 | if mode == ResetMode::Form { | 160 | if mode == ResetMode::Form { |
| 156 | - <p class="hint">(t(lang, Key::ResetSub))</p> | ||
| 157 | <form data-hard="true" method="post" action=(format!("/reset/{token}")) class="fields"> | 161 | <form data-hard="true" method="post" action=(format!("/reset/{token}")) class="fields"> |
| 158 | if let Some(message) = error { | 162 | if let Some(message) = error { |
| 159 | alert(message: message.as_str()) | 163 | alert(message: message.as_str()) |
| @@ -183,7 +187,7 @@ async fn reset_body( | |||
| 183 | <a class="act" href="/login">(t(lang, Key::LogIn))</a> | 187 | <a class="act" href="/login">(t(lang, Key::LogIn))</a> |
| 184 | </div> | 188 | </div> |
| 185 | } | 189 | } |
| 186 | - </section> | 190 | + </div> |
| 187 | }) | 191 | }) |
| 188 | } | 192 | } |
| 189 | 193 | ||
crates/forge-web/src/pages/home.rsmodified+7 -10
| @@ -11,6 +11,7 @@ use crate::i18n::orgs::{self as g, K}; | |||
| 11 | use crate::i18n::{self, Lang}; | 11 | use crate::i18n::{self, Lang}; |
| 12 | use crate::pages::repo_settings::{notice_banner_for, take_notice}; | 12 | use crate::pages::repo_settings::{notice_banner_for, take_notice}; |
| 13 | use crate::state::AppState; | 13 | use crate::state::AppState; |
| 14 | +use crate::views::parts::{SubPart, head}; | ||
| 14 | use crate::views::{enc, shell}; | 15 | use crate::views::{enc, shell}; |
| 15 | 16 | ||
| 16 | #[page("/")] | 17 | #[page("/")] |
| @@ -33,15 +34,11 @@ async fn home(cx: &Cx) -> Result<impl View> { | |||
| 33 | #[component] | 34 | #[component] |
| 34 | async fn landing(has_users: bool, lang: Lang) -> Result<impl View> { | 35 | async fn landing(has_users: bool, lang: Lang) -> Result<impl View> { |
| 35 | Ok(view! { | 36 | Ok(view! { |
| 36 | - <section class="sec"> | 37 | + head(title: "forge", sub: vec![SubPart::text(g::t(lang, K::LandingTagline))], |
| 37 | - <h1 class="sr-only">"forge"</h1> | 38 | + <a class="button primary" href="/login">(g::t(lang, K::LogIn))</a> |
| 38 | - <p class="state">(g::t(lang, K::LandingTagline))</p> | 39 | + if !has_users { |
| 39 | - <div class="acts"> | 40 | + <a class="button" href="/setup">(g::t(lang, K::SetUpForge))</a> |
| 40 | - <a class="act" href="/login">(g::t(lang, K::LogIn))</a> | 41 | + } |
| 41 | - if !has_users { | 42 | + ) |
| 42 | - <a class="act" href="/setup">(g::t(lang, K::SetUpForge))</a> | ||
| 43 | - } | ||
| 44 | - </div> | ||
| 45 | - </section> | ||
| 46 | }) | 43 | }) |
| 47 | } | 44 | } |
crates/forge-web/src/pages/import.rsmodified+213 -207
| @@ -31,6 +31,7 @@ use crate::pages::ci_runs::{changed_event, events_response}; | |||
| 31 | use crate::pages::new_repo::{owner_choices, repo_owner}; | 31 | use crate::pages::new_repo::{owner_choices, repo_owner}; |
| 32 | use crate::pages::repo_ctx::still_readable; | 32 | use crate::pages::repo_ctx::still_readable; |
| 33 | use crate::state::AppState; | 33 | use crate::state::AppState; |
| 34 | +use crate::views::parts::{SubPart, head}; | ||
| 34 | use crate::views::{alert, csrf_field, rel_time, shell, user_facing_message}; | 35 | use crate::views::{alert, csrf_field, rel_time, shell, user_facing_message}; |
| 35 | 36 | ||
| 36 | path_param!(job_id); | 37 | path_param!(job_id); |
| @@ -179,7 +180,7 @@ async fn source_tabs(lang: Lang, base: &str, active: Source) -> Result<impl View | |||
| 179 | let gitlab = format!("{base}?source=gitlab"); | 180 | let gitlab = format!("{base}?source=gitlab"); |
| 180 | let forgejo = format!("{base}?source=forgejo"); | 181 | let forgejo = format!("{base}?source=forgejo"); |
| 181 | Ok(view! { | 182 | Ok(view! { |
| 182 | - <nav class="sub" aria-label=(g::t(lang, K::TabImport))> | 183 | + <nav class="tabs" aria-label=(g::t(lang, K::TabImport))> |
| 183 | <a href=(git.as_str()) aria-current=((active == Source::Git).then_some("page"))>(g::t(lang, K::SrcGit))</a> | 184 | <a href=(git.as_str()) aria-current=((active == Source::Git).then_some("page"))>(g::t(lang, K::SrcGit))</a> |
| 184 | <a href=(github.as_str()) aria-current=((active == Source::GitHub).then_some("page"))>(g::t(lang, K::SrcGitHub))</a> | 185 | <a href=(github.as_str()) aria-current=((active == Source::GitHub).then_some("page"))>(g::t(lang, K::SrcGitHub))</a> |
| 185 | <a href=(gitlab.as_str()) aria-current=((active == Source::GitLab).then_some("page"))>(g::t(lang, K::SrcGitLab))</a> | 186 | <a href=(gitlab.as_str()) aria-current=((active == Source::GitLab).then_some("page"))>(g::t(lang, K::SrcGitLab))</a> |
| @@ -192,33 +193,30 @@ async fn source_tabs(lang: Lang, base: &str, active: Source) -> Result<impl View | |||
| 192 | #[component] | 193 | #[component] |
| 193 | pub(crate) async fn visibility_pick(lang: Lang, private: bool) -> Result<impl View> { | 194 | pub(crate) async fn visibility_pick(lang: Lang, private: bool) -> Result<impl View> { |
| 194 | Ok(view! { | 195 | Ok(view! { |
| 195 | - <fieldset class="rule-group"> | 196 | + <div class="field"> |
| 196 | - <legend>(crate::i18n::misc::t(lang, crate::i18n::misc::K::VisibilityLegend))</legend> | 197 | + <span class="field-label">(crate::i18n::misc::t(lang, crate::i18n::misc::K::VisibilityLegend))</span> |
| 197 | - <label class="switch"> | 198 | + <div class="choice" role="radiogroup" aria-label=(crate::i18n::misc::t(lang, crate::i18n::misc::K::VisibilityLegend))> |
| 198 | - <input type="radio" name="visibility" value="private" checked=(private)> | 199 | + <label><input type="radio" name="visibility" value="private" checked=(private)><span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPrivate))</span></label> |
| 199 | - <span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPrivate))</span> | 200 | + <label><input type="radio" name="visibility" value="public" checked=(!private)><span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPublic))</span></label> |
| 200 | - </label> | 201 | + </div> |
| 201 | - <p class="hint">(crate::i18n::misc::t(lang, crate::i18n::misc::K::PrivateHelp))</p> | 202 | + <p class="hint">(crate::i18n::misc::t(lang, crate::i18n::misc::K::PrivateHelp)) ". " (crate::i18n::misc::t(lang, crate::i18n::misc::K::PublicHelp)) "."</p> |
| 202 | - <label class="switch"> | 203 | + </div> |
| 203 | - <input type="radio" name="visibility" value="public" checked=(!private)> | ||
| 204 | - <span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPublic))</span> | ||
| 205 | - </label> | ||
| 206 | - <p class="hint">(crate::i18n::misc::t(lang, crate::i18n::misc::K::PublicHelp))</p> | ||
| 207 | - </fieldset> | ||
| 208 | }) | 204 | }) |
| 209 | } | 205 | } |
| 210 | 206 | ||
| 211 | #[component] | 207 | #[component] |
| 212 | async fn option_boxes(lang: Lang, opts: ImportOptions) -> Result<impl View> { | 208 | async fn option_boxes(lang: Lang, opts: ImportOptions) -> Result<impl View> { |
| 213 | Ok(view! { | 209 | Ok(view! { |
| 214 | - <fieldset class="rule-group"> | 210 | + <div class="field" role="group" aria-labelledby="import-what"> |
| 215 | - <legend>(g::t(lang, K::WhatToImport))</legend> | 211 | + <span class="field-label" id="import-what">(g::t(lang, K::WhatToImport))</span> |
| 216 | - <label class="switch"><input type="checkbox" name="opt_labels" value="on" checked=(opts.labels)><span>(g::t(lang, K::OptLabels))</span></label> | 212 | + <div class="checks"> |
| 217 | - <label class="switch"><input type="checkbox" name="opt_issues" value="on" checked=(opts.issues)><span>(g::t(lang, K::OptIssues))</span></label> | 213 | + <label class="switch"><input type="checkbox" name="opt_labels" value="on" checked=(opts.labels)><span>(g::t(lang, K::OptLabels))</span></label> |
| 218 | - <label class="switch"><input type="checkbox" name="opt_pulls" value="on" checked=(opts.pulls)><span>(g::t(lang, K::OptPulls))</span></label> | 214 | + <label class="switch"><input type="checkbox" name="opt_issues" value="on" checked=(opts.issues)><span>(g::t(lang, K::OptIssues))</span></label> |
| 219 | - <label class="switch"><input type="checkbox" name="opt_releases" value="on" checked=(opts.releases)><span>(g::t(lang, K::OptReleases))</span></label> | 215 | + <label class="switch"><input type="checkbox" name="opt_pulls" value="on" checked=(opts.pulls)><span>(g::t(lang, K::OptPulls))</span></label> |
| 216 | + <label class="switch"><input type="checkbox" name="opt_releases" value="on" checked=(opts.releases)><span>(g::t(lang, K::OptReleases))</span></label> | ||
| 217 | + </div> | ||
| 220 | <p class="hint">(g::t(lang, K::OptionsNote))</p> | 218 | <p class="hint">(g::t(lang, K::OptionsNote))</p> |
| 221 | - </fieldset> | 219 | + </div> |
| 222 | }) | 220 | }) |
| 223 | } | 221 | } |
| 224 | 222 | ||
| @@ -318,69 +316,70 @@ async fn import_form( | |||
| 318 | let private = draft.private; | 316 | let private = draft.private; |
| 319 | let opts = draft.opts; | 317 | let opts = draft.opts; |
| 320 | Ok(view! { | 318 | Ok(view! { |
| 321 | - <h1 class="sr-only">(g::t(lang, K::ImportTitle))</h1> | 319 | + head(title: g::t(lang, K::ImportTitle), sub: vec![SubPart::text(g::t(lang, K::ImportIntro))]) |
| 322 | newrepo_tabs(lang: lang, active: "import") | 320 | newrepo_tabs(lang: lang, active: "import") |
| 323 | source_tabs(lang: lang, base: "/new/import", active: source) | 321 | source_tabs(lang: lang, base: "/new/import", active: source) |
| 324 | - if !is_git { | 322 | + <div class="sheet fit"> |
| 325 | - <section class="sec"> | 323 | + if !is_git { |
| 326 | - <h2>(g::t(lang, K::BulkLink))</h2> | 324 | + <section class="sec"> |
| 327 | - <p class="hint">(g::t(lang, K::BulkIntro))</p> | 325 | + <h2>(g::t(lang, K::BulkLink))</h2> |
| 328 | - <div class="acts"> | 326 | + <p class="hint">(g::t(lang, K::BulkIntro))</p> |
| 329 | - <a class="act" href=(bulk_href.as_str())>(g::t(lang, K::BulkLinkButton))</a> | 327 | + <div class="acts"> |
| 330 | - </div> | 328 | + <a class="act" href=(bulk_href.as_str())>(g::t(lang, K::BulkLinkButton))</a> |
| 331 | - </section> | 329 | + </div> |
| 332 | - } | 330 | + </section> |
| 333 | - <form method="post" action="/new/import" class="fields"> | ||
| 334 | - if let Some(message) = error { | ||
| 335 | - alert(message: message.as_str()) | ||
| 336 | } | 331 | } |
| 337 | - csrf_field(token: csrf) | 332 | + <form method="post" action="/new/import" class="fields"> |
| 338 | - <input type="hidden" name="source" value=(source_value)> | 333 | + if let Some(message) = error { |
| 339 | - <p class="hint">(g::t(lang, K::ImportIntro))</p> | 334 | + alert(message: message.as_str()) |
| 340 | - if has_instance { | 335 | + } |
| 336 | + csrf_field(token: csrf) | ||
| 337 | + <input type="hidden" name="source" value=(source_value)> | ||
| 338 | + if has_instance { | ||
| 339 | + <div class="field"> | ||
| 340 | + <label for="import-instance">(instance_label)</label> | ||
| 341 | + <input id="import-instance" type="url" name="instance" value=(draft.instance.as_str()) autocomplete="off" spellcheck="false" maxlength="2048"> | ||
| 342 | + </div> | ||
| 343 | + } | ||
| 341 | <div class="field"> | 344 | <div class="field"> |
| 342 | - <label for="import-instance">(instance_label)</label> | 345 | + <label for="import-remote">(remote_label)</label> |
| 343 | - <input id="import-instance" type="url" name="instance" value=(draft.instance.as_str()) autocomplete="off" spellcheck="false" maxlength="2048"> | 346 | + <input id="import-remote" type="text" name="remote" value=(draft.remote.as_str()) placeholder=(remote_placeholder) required=(true) autocomplete="off" spellcheck="false" maxlength="2048"> |
| 344 | </div> | 347 | </div> |
| 345 | - } | 348 | + if is_git { |
| 346 | - <div class="field"> | 349 | + <div class="field"> |
| 347 | - <label for="import-remote">(remote_label)</label> | 350 | + <label for="import-git-user">(g::t(lang, K::GitUser))</label> |
| 348 | - <input id="import-remote" type="text" name="remote" value=(draft.remote.as_str()) placeholder=(remote_placeholder) required=(true) autocomplete="off" spellcheck="false" maxlength="2048"> | 351 | + <input id="import-git-user" type="text" name="git_user" value=(draft.git_user.as_str()) autocomplete="off" maxlength="255"> |
| 349 | - </div> | 352 | + </div> |
| 350 | - if is_git { | 353 | + } |
| 351 | <div class="field"> | 354 | <div class="field"> |
| 352 | - <label for="import-git-user">(g::t(lang, K::GitUser))</label> | 355 | + <label for="import-token">(token_label)</label> |
| 353 | - <input id="import-git-user" type="text" name="git_user" value=(draft.git_user.as_str()) autocomplete="off" maxlength="255"> | 356 | + <input id="import-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 357 | + <p class="hint">(g::t(lang, K::TokenHelp))</p> | ||
| 354 | </div> | 358 | </div> |
| 355 | - } | 359 | + if !is_git { |
| 356 | - <div class="field"> | 360 | + option_boxes(lang: lang, opts: opts) |
| 357 | - <label for="import-token">(token_label)</label> | 361 | + } |
| 358 | - <input id="import-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> | 362 | + <div class="field"> |
| 359 | - <p class="hint">(g::t(lang, K::TokenHelp))</p> | 363 | + <label for="import-owner">(g::t(lang, K::TargetOwner))</label> |
| 360 | - </div> | 364 | + <select id="import-owner" name="owner"> |
| 361 | - if !is_git { | 365 | + for name in owners.iter() { |
| 362 | - option_boxes(lang: lang, opts: opts) | 366 | + <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> |
| 363 | - } | 367 | + } |
| 364 | - <div class="field"> | 368 | + </select> |
| 365 | - <label for="import-owner">(g::t(lang, K::TargetOwner))</label> | 369 | + </div> |
| 366 | - <select id="import-owner" name="owner"> | 370 | + <div class="field"> |
| 367 | - for name in owners.iter() { | 371 | + <label for="import-name">(g::t(lang, K::TargetName))</label> |
| 368 | - <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> | 372 | + <input id="import-name" type="text" name="name" value=(draft.name.as_str()) maxlength="64" autocomplete="off"> |
| 369 | - } | 373 | + <p class="hint">(g::t(lang, K::TargetNameHelp))</p> |
| 370 | - </select> | 374 | + </div> |
| 371 | - </div> | 375 | + <div class="field"> |
| 372 | - <div class="field"> | 376 | + <label for="import-description">(g::t(lang, K::Description))</label> |
| 373 | - <label for="import-name">(g::t(lang, K::TargetName))</label> | 377 | + <textarea id="import-description" name="description" rows="2" maxlength="350">(draft.description.as_str())</textarea> |
| 374 | - <input id="import-name" type="text" name="name" value=(draft.name.as_str()) maxlength="64" autocomplete="off"> | 378 | + </div> |
| 375 | - <p class="hint">(g::t(lang, K::TargetNameHelp))</p> | 379 | + visibility_pick(lang: lang, private: private) |
| 376 | - </div> | 380 | + <button type="submit" class="primary">(g::t(lang, K::StartImport))</button> |
| 377 | - <div class="field"> | 381 | + </form> |
| 378 | - <label for="import-description">(g::t(lang, K::Description))</label> | 382 | + </div> |
| 379 | - <textarea id="import-description" name="description" rows="2" maxlength="350">(draft.description.as_str())</textarea> | ||
| 380 | - </div> | ||
| 381 | - visibility_pick(lang: lang, private: private) | ||
| 382 | - <button type="submit" class="primary">(g::t(lang, K::StartImport))</button> | ||
| 383 | - </form> | ||
| 384 | }) | 383 | }) |
| 385 | } | 384 | } |
| 386 | 385 | ||
| @@ -611,35 +610,36 @@ async fn bulk_form( | |||
| 611 | // A Forgejo token can list its own repositories, so the owner may stay empty. | 610 | // A Forgejo token can list its own repositories, so the owner may stay empty. |
| 612 | let owner_required = source != Source::Forgejo; | 611 | let owner_required = source != Source::Forgejo; |
| 613 | Ok(view! { | 612 | Ok(view! { |
| 614 | - <h1 class="sr-only">(g::t(lang, K::BulkTitle))</h1> | 613 | + head(title: g::t(lang, K::BulkTitle), sub: vec![SubPart::text(g::t(lang, K::BulkIntro))]) |
| 615 | newrepo_tabs(lang: lang, active: "import") | 614 | newrepo_tabs(lang: lang, active: "import") |
| 616 | source_tabs(lang: lang, base: "/new/import/bulk", active: source) | 615 | source_tabs(lang: lang, base: "/new/import/bulk", active: source) |
| 617 | - <form method="post" action="/new/import/bulk" class="fields"> | 616 | + <div class="sheet fit"> |
| 618 | - if let Some(message) = error { | 617 | + <form method="post" action="/new/import/bulk" class="fields"> |
| 619 | - alert(message: message.as_str()) | 618 | + if let Some(message) = error { |
| 620 | - } | 619 | + alert(message: message.as_str()) |
| 621 | - csrf_field(token: csrf) | 620 | + } |
| 622 | - <input type="hidden" name="source" value=(source_value)> | 621 | + csrf_field(token: csrf) |
| 623 | - <input type="hidden" name="stage" value="list"> | 622 | + <input type="hidden" name="source" value=(source_value)> |
| 624 | - <p class="hint">(g::t(lang, K::BulkIntro))</p> | 623 | + <input type="hidden" name="stage" value="list"> |
| 625 | - if has_instance { | 624 | + if has_instance { |
| 625 | + <div class="field"> | ||
| 626 | + <label for="bulk-instance">(instance_label)</label> | ||
| 627 | + <input id="bulk-instance" type="url" name="instance" value=(instance) autocomplete="off" spellcheck="false" maxlength="2048"> | ||
| 628 | + </div> | ||
| 629 | + } | ||
| 626 | <div class="field"> | 630 | <div class="field"> |
| 627 | - <label for="bulk-instance">(instance_label)</label> | 631 | + <label for="bulk-from">(owner_label)</label> |
| 628 | - <input id="bulk-instance" type="url" name="instance" value=(instance) autocomplete="off" spellcheck="false" maxlength="2048"> | 632 | + <input id="bulk-from" type="text" name="from" required=(owner_required) autocomplete="off" spellcheck="false" maxlength="100"> |
| 629 | </div> | 633 | </div> |
| 630 | - } | 634 | + <div class="field"> |
| 631 | - <div class="field"> | 635 | + <label for="bulk-token">(g::t(lang, K::TokenOptional))</label> |
| 632 | - <label for="bulk-from">(owner_label)</label> | 636 | + <input id="bulk-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 633 | - <input id="bulk-from" type="text" name="from" required=(owner_required) autocomplete="off" spellcheck="false" maxlength="100"> | 637 | + <p class="hint">(g::t(lang, K::TokenHelp))</p> |
| 634 | - </div> | 638 | + </div> |
| 635 | - <div class="field"> | 639 | + <input type="hidden" name="owner" value=(owners.first().map(String::as_str).unwrap_or(""))> |
| 636 | - <label for="bulk-token">(g::t(lang, K::TokenOptional))</label> | 640 | + <button type="submit" class="primary">(g::t(lang, K::BulkListButton))</button> |
| 637 | - <input id="bulk-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> | 641 | + </form> |
| 638 | - <p class="hint">(g::t(lang, K::TokenHelp))</p> | 642 | + </div> |
| 639 | - </div> | ||
| 640 | - <input type="hidden" name="owner" value=(owners.first().map(String::as_str).unwrap_or(""))> | ||
| 641 | - <button type="submit" class="primary">(g::t(lang, K::BulkListButton))</button> | ||
| 642 | - </form> | ||
| 643 | }) | 643 | }) |
| 644 | } | 644 | } |
| 645 | 645 | ||
| @@ -670,59 +670,61 @@ async fn bulk_select( | |||
| 670 | form.owner.clone() | 670 | form.owner.clone() |
| 671 | }; | 671 | }; |
| 672 | Ok(view! { | 672 | Ok(view! { |
| 673 | - <h1 class="sr-only">(g::t(lang, K::BulkSelectHeading))</h1> | 673 | + head(title: g::t(lang, K::BulkSelectHeading)) |
| 674 | newrepo_tabs(lang: lang, active: "import") | 674 | newrepo_tabs(lang: lang, active: "import") |
| 675 | - <form method="post" action="/new/import/bulk" class="fields"> | 675 | + <div class="sheet"> |
| 676 | - csrf_field(token: csrf) | 676 | + <form method="post" action="/new/import/bulk" class="fields"> |
| 677 | - <input type="hidden" name="stage" value="run"> | 677 | + csrf_field(token: csrf) |
| 678 | - <input type="hidden" name="source" value=(form.source.as_str())> | 678 | + <input type="hidden" name="stage" value="run"> |
| 679 | - <input type="hidden" name="instance" value=(form.instance.as_str())> | 679 | + <input type="hidden" name="source" value=(form.source.as_str())> |
| 680 | - <input type="hidden" name="token" value=(form.token.as_str())> | 680 | + <input type="hidden" name="instance" value=(form.instance.as_str())> |
| 681 | - <input type="hidden" name="from" value=(form.from.as_str())> | 681 | + <input type="hidden" name="token" value=(form.token.as_str())> |
| 682 | - if empty { | 682 | + <input type="hidden" name="from" value=(form.from.as_str())> |
| 683 | - <p class="state">(g::t(lang, K::BulkNone))</p> | 683 | + if empty { |
| 684 | - } else { | 684 | + <p class="state">(g::t(lang, K::BulkNone))</p> |
| 685 | - <div class="field"> | 685 | + } else { |
| 686 | - <label for="bulk-owner">(g::t(lang, K::TargetOwner))</label> | 686 | + <div class="field"> |
| 687 | - <select id="bulk-owner" name="owner"> | 687 | + <label for="bulk-owner">(g::t(lang, K::TargetOwner))</label> |
| 688 | - for name in owners.iter() { | 688 | + <select id="bulk-owner" name="owner"> |
| 689 | - <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> | 689 | + for name in owners.iter() { |
| 690 | + <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> | ||
| 691 | + } | ||
| 692 | + </select> | ||
| 693 | + <p class="hint">(g::t(lang, K::BulkOwnerHelp))</p> | ||
| 694 | + </div> | ||
| 695 | + visibility_pick(lang: lang, private: private) | ||
| 696 | + if form.source != "git" { | ||
| 697 | + option_boxes(lang: lang, opts: opts) | ||
| 698 | + } | ||
| 699 | + <label class="line" data-kb-row=""> | ||
| 700 | + <input type="checkbox" data-select-all=".import-pick-list"> | ||
| 701 | + <span class="name">(g::t(lang, K::BulkSelectAll))</span> | ||
| 702 | + <span class="val">(count)</span> | ||
| 703 | + </label> | ||
| 704 | + <div class="import-pick-list"> | ||
| 705 | + for (i, repo) in repos.iter().enumerate() { | ||
| 706 | + <label class="line" data-kb-row=""> | ||
| 707 | + <input type="checkbox" name=(format!("sel_{i}")) value=(repo.full_name.as_str())> | ||
| 708 | + <span class="name">(repo.name.as_str())</span> | ||
| 709 | + <span class="val"> | ||
| 710 | + if repo.private { | ||
| 711 | + <span class="badge private">(g::t(lang, K::BulkPrivate))</span> | ||
| 712 | + } | ||
| 713 | + if repo.fork { | ||
| 714 | + <span class="badge">(g::t(lang, K::BulkFork))</span> | ||
| 715 | + } | ||
| 716 | + if repo.archived { | ||
| 717 | + <span class="badge">(g::t(lang, K::BulkArchived))</span> | ||
| 718 | + } | ||
| 719 | + (repo.description.as_str()) | ||
| 720 | + </span> | ||
| 721 | + </label> | ||
| 690 | } | 722 | } |
| 691 | - </select> | 723 | + </div> |
| 692 | - <p class="hint">(g::t(lang, K::BulkOwnerHelp))</p> | 724 | + <button type="submit" class="primary">(g::t(lang, K::BulkImportSelected))</button> |
| 693 | - </div> | ||
| 694 | - visibility_pick(lang: lang, private: private) | ||
| 695 | - if form.source != "git" { | ||
| 696 | - option_boxes(lang: lang, opts: opts) | ||
| 697 | } | 725 | } |
| 698 | - <label class="line" data-kb-row=""> | 726 | + </form> |
| 699 | - <input type="checkbox" data-select-all=".import-pick-list"> | 727 | + </div> |
| 700 | - <span class="name">(g::t(lang, K::BulkSelectAll))</span> | ||
| 701 | - <span class="val">(count)</span> | ||
| 702 | - </label> | ||
| 703 | - <div class="import-pick-list"> | ||
| 704 | - for (i, repo) in repos.iter().enumerate() { | ||
| 705 | - <label class="line" data-kb-row=""> | ||
| 706 | - <input type="checkbox" name=(format!("sel_{i}")) value=(repo.full_name.as_str())> | ||
| 707 | - <span class="name">(repo.name.as_str())</span> | ||
| 708 | - <span class="val"> | ||
| 709 | - if repo.private { | ||
| 710 | - <span class="badge private">(g::t(lang, K::BulkPrivate))</span> | ||
| 711 | - } | ||
| 712 | - if repo.fork { | ||
| 713 | - <span class="badge">(g::t(lang, K::BulkFork))</span> | ||
| 714 | - } | ||
| 715 | - if repo.archived { | ||
| 716 | - <span class="badge">(g::t(lang, K::BulkArchived))</span> | ||
| 717 | - } | ||
| 718 | - (repo.description.as_str()) | ||
| 719 | - </span> | ||
| 720 | - </label> | ||
| 721 | - } | ||
| 722 | - </div> | ||
| 723 | - <button type="submit" class="primary">(g::t(lang, K::BulkImportSelected))</button> | ||
| 724 | - } | ||
| 725 | - </form> | ||
| 726 | }) | 728 | }) |
| 727 | } | 729 | } |
| 728 | 730 | ||
| @@ -1054,20 +1056,18 @@ async fn recent_imports( | |||
| 1054 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); | 1056 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); |
| 1055 | Ok(view! { | 1057 | Ok(view! { |
| 1056 | if !empty { | 1058 | if !empty { |
| 1057 | - <section class="sec"> | 1059 | + <div class="sheet"> |
| 1058 | - <h2>(g::t(lang, K::RecentImports))</h2> | 1060 | + <div class="sheet-tools"> |
| 1061 | + <strong>(g::t(lang, K::RecentImports))</strong> | ||
| 1062 | + if more { | ||
| 1063 | + <a class="act" href="/import">(g::t(lang, K::ViewAll))</a> | ||
| 1064 | + } | ||
| 1065 | + if retry { | ||
| 1066 | + <a class="act" href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a> | ||
| 1067 | + } | ||
| 1068 | + </div> | ||
| 1059 | job_rows(lang: lang, jobs: jobs) | 1069 | job_rows(lang: lang, jobs: jobs) |
| 1060 | - if more || retry { | 1070 | + </div> |
| 1061 | - <div class="acts"> | ||
| 1062 | - if more { | ||
| 1063 | - <a class="act quiet" href="/import">(g::t(lang, K::ViewAll))</a> | ||
| 1064 | - } | ||
| 1065 | - if retry { | ||
| 1066 | - <a class="act" href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a> | ||
| 1067 | - } | ||
| 1068 | - </div> | ||
| 1069 | - } | ||
| 1070 | - </section> | ||
| 1071 | } | 1071 | } |
| 1072 | }) | 1072 | }) |
| 1073 | } | 1073 | } |
| @@ -1081,10 +1081,10 @@ async fn jobs_list( | |||
| 1081 | let empty = jobs.is_empty(); | 1081 | let empty = jobs.is_empty(); |
| 1082 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); | 1082 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); |
| 1083 | Ok(view! { | 1083 | Ok(view! { |
| 1084 | - <section data-live="/import/events"> | 1084 | + head(title: g::t(lang, K::JobsTitle), live: Some("/import/events")) |
| 1085 | - <h1 class="sr-only">(g::t(lang, K::JobsTitle))</h1> | 1085 | + <div class="sheet"> |
| 1086 | if retry { | 1086 | if retry { |
| 1087 | - <div class="acts"> | 1087 | + <div class="sheet-tools"> |
| 1088 | <a class="act" href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a> | 1088 | <a class="act" href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a> |
| 1089 | </div> | 1089 | </div> |
| 1090 | } | 1090 | } |
| @@ -1099,7 +1099,7 @@ async fn jobs_list( | |||
| 1099 | } else { | 1099 | } else { |
| 1100 | job_rows(lang: lang, jobs: jobs) | 1100 | job_rows(lang: lang, jobs: jobs) |
| 1101 | } | 1101 | } |
| 1102 | - </section> | 1102 | + </div> |
| 1103 | }) | 1103 | }) |
| 1104 | } | 1104 | } |
| 1105 | 1105 | ||
| @@ -1187,10 +1187,14 @@ async fn job_view( | |||
| 1187 | let error = job.error.clone(); | 1187 | let error = job.error.clone(); |
| 1188 | let state_word = job.state.as_str(); | 1188 | let state_word = job.state.as_str(); |
| 1189 | let empty_log = log.is_empty(); | 1189 | let empty_log = log.is_empty(); |
| 1190 | + let sub = vec![SubPart { | ||
| 1191 | + text: badge_text.to_owned(), | ||
| 1192 | + class: badge_class, | ||
| 1193 | + ..SubPart::default() | ||
| 1194 | + }]; | ||
| 1190 | Ok(view! { | 1195 | Ok(view! { |
| 1191 | - <section class="import-job" data-live=(live.as_deref()) data-live-state=(state_word)> | 1196 | + head(title: job.source_ref.as_str(), sub: sub, live: live.as_deref()) |
| 1192 | - <h1 class="h1">(job.source_ref.as_str())</h1> | 1197 | + <div class="sheet import-job" data-live-state=(state_word)> |
| 1193 | - <p class="state"><span class=(badge_class)>(badge_text)</span></p> | ||
| 1194 | <section class="sec"> | 1198 | <section class="sec"> |
| 1195 | if !stage.is_empty() { | 1199 | if !stage.is_empty() { |
| 1196 | <p class="state"> | 1200 | <p class="state"> |
| @@ -1241,7 +1245,7 @@ async fn job_view( | |||
| 1241 | </ol> | 1245 | </ol> |
| 1242 | } | 1246 | } |
| 1243 | </section> | 1247 | </section> |
| 1244 | - </section> | 1248 | + </div> |
| 1245 | }) | 1249 | }) |
| 1246 | } | 1250 | } |
| 1247 | 1251 | ||
| @@ -1409,40 +1413,42 @@ async fn retry_list(lang: Lang, csrf: &str, rows: Vec<(ImportJob, Repo)>) -> Res | |||
| 1409 | let count = rows.len(); | 1413 | let count = rows.len(); |
| 1410 | let empty = rows.is_empty(); | 1414 | let empty = rows.is_empty(); |
| 1411 | Ok(view! { | 1415 | Ok(view! { |
| 1412 | - <h1 class="sr-only">(g::t(lang, K::RetryFailedTitle))</h1> | 1416 | + head(title: g::t(lang, K::RetryFailedTitle)) |
| 1413 | - <form method="post" action="/import/retry" class="fields"> | 1417 | + <div class="sheet"> |
| 1414 | - csrf_field(token: csrf) | 1418 | + <form method="post" action="/import/retry" class="fields"> |
| 1415 | - if empty { | 1419 | + csrf_field(token: csrf) |
| 1416 | - <p class="state">(g::t(lang, K::RetryNone))</p> | 1420 | + if empty { |
| 1417 | - } else { | 1421 | + <p class="state">(g::t(lang, K::RetryNone))</p> |
| 1418 | - <div class="field"> | 1422 | + } else { |
| 1419 | - <label for="retry-token">(g::t(lang, K::TokenOptional))</label> | 1423 | + <div class="field"> |
| 1420 | - <input id="retry-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> | 1424 | + <label for="retry-token">(g::t(lang, K::TokenOptional))</label> |
| 1421 | - <p class="hint">(g::t(lang, K::RetryTokenHelp))</p> | 1425 | + <input id="retry-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 1422 | - </div> | 1426 | + <p class="hint">(g::t(lang, K::RetryTokenHelp))</p> |
| 1423 | - <label class="line" data-kb-row=""> | 1427 | + </div> |
| 1424 | - <input type="checkbox" data-select-all=".import-pick-list"> | 1428 | + <label class="line" data-kb-row=""> |
| 1425 | - <span class="name">(g::t(lang, K::BulkSelectAll))</span> | 1429 | + <input type="checkbox" data-select-all=".import-pick-list"> |
| 1426 | - <span class="val">(count)</span> | 1430 | + <span class="name">(g::t(lang, K::BulkSelectAll))</span> |
| 1427 | - </label> | 1431 | + <span class="val">(count)</span> |
| 1428 | - <div class="import-pick-list"> | 1432 | + </label> |
| 1429 | - for (i, (job, repo)) in rows.iter().enumerate() { | 1433 | + <div class="import-pick-list"> |
| 1430 | - <label class="line" data-kb-row=""> | 1434 | + for (i, (job, repo)) in rows.iter().enumerate() { |
| 1431 | - <input type="checkbox" name=(format!("sel_{i}")) value=(job.id.as_str())> | 1435 | + <label class="line" data-kb-row=""> |
| 1432 | - <span class="name">(format!("{}/{}", repo.owner_name, repo.name))</span> | 1436 | + <input type="checkbox" name=(format!("sel_{i}")) value=(job.id.as_str())> |
| 1433 | - <span class="val"> | 1437 | + <span class="name">(format!("{}/{}", repo.owner_name, repo.name))</span> |
| 1434 | - <span class="badge">(source_label(&job.source))</span> | 1438 | + <span class="val"> |
| 1435 | - " " (job.source_ref.as_str()) | 1439 | + <span class="badge">(source_label(&job.source))</span> |
| 1436 | - if let Some(message) = job.error.as_ref() { | 1440 | + " " (job.source_ref.as_str()) |
| 1437 | - " · " (message.as_str()) | 1441 | + if let Some(message) = job.error.as_ref() { |
| 1438 | - } | 1442 | + " · " (message.as_str()) |
| 1439 | - </span> | 1443 | + } |
| 1440 | - </label> | 1444 | + </span> |
| 1441 | - } | 1445 | + </label> |
| 1442 | - </div> | 1446 | + } |
| 1443 | - <button type="submit" class="primary">(g::t(lang, K::RetrySelected))</button> | 1447 | + </div> |
| 1444 | - } | 1448 | + <button type="submit" class="primary">(g::t(lang, K::RetrySelected))</button> |
| 1445 | - </form> | 1449 | + } |
| 1450 | + </form> | ||
| 1451 | + </div> | ||
| 1446 | }) | 1452 | }) |
| 1447 | } | 1453 | } |
| 1448 | 1454 | ||
crates/forge-web/src/pages/invites.rsmodified+20 -26
| @@ -16,9 +16,8 @@ use crate::auth::check_csrf; | |||
| 16 | use crate::i18n::{self, Key, Lang, t}; | 16 | use crate::i18n::{self, Key, Lang, t}; |
| 17 | use crate::mail::account; | 17 | use crate::mail::account; |
| 18 | use crate::pages::admin_users::admin_only; | 18 | use crate::pages::admin_users::admin_only; |
| 19 | -use crate::pages::passkeys::s; | ||
| 20 | use crate::state::AppState; | 19 | use crate::state::AppState; |
| 21 | -use crate::views::parts::reveal; | 20 | +use crate::views::parts::{SubPart, head}; |
| 22 | use crate::views::{alert, shell, user_facing_message}; | 21 | use crate::views::{alert, shell, user_facing_message}; |
| 23 | 22 | ||
| 24 | #[derive(Deserialize)] | 23 | #[derive(Deserialize)] |
| @@ -36,31 +35,26 @@ async fn invite_body( | |||
| 36 | notice: Option<&'static str>, | 35 | notice: Option<&'static str>, |
| 37 | error: Option<String>, | 36 | error: Option<String>, |
| 38 | ) -> Result<impl View> { | 37 | ) -> Result<impl View> { |
| 39 | - let open = error.is_some(); | ||
| 40 | Ok(view! { | 38 | Ok(view! { |
| 41 | - <h1 class="sr-only">(t(lang, Key::InvitesTitle))</h1> | 39 | + head(title: t(lang, Key::InvitesTitle), sub: vec![SubPart::text(t(lang, Key::InvitesSub))]) |
| 42 | - <section class="sec"> | 40 | + <div class="sheet"> |
| 43 | - <h2>(s(lang, "Invite by email", "E-posta ile davet et"))</h2> | 41 | + <section class="sec"> |
| 44 | - <p class="hint">(t(lang, Key::InvitesSub))</p> | 42 | + if let Some(message) = error { |
| 45 | - if let Some(message) = notice { | 43 | + alert(message: message.as_str()) |
| 46 | - <p class="state" role="status">(message)</p> | 44 | + } |
| 47 | - } | 45 | + <form method="post" action="/admin/invites" class="fields"> |
| 48 | - <div class="acts"> | 46 | + <input type="hidden" name="csrf" value=(csrf)> |
| 49 | - reveal(label: t(lang, Key::InvitesSubmit), id: Some("invite-email"), open: open, | 47 | + <div class="field"> |
| 50 | - if let Some(message) = error { | 48 | + <label for="invite-email">(t(lang, Key::Email))</label> |
| 51 | - alert(message: message.as_str()) | 49 | + <input id="invite-email" type="email" name="email" autocomplete="off" maxlength="254" required=(true)> |
| 52 | - } | 50 | + </div> |
| 53 | - <form method="post" action="/admin/invites" class="fields"> | 51 | + <button type="submit" class="primary">(t(lang, Key::InvitesSubmit))</button> |
| 54 | - <input type="hidden" name="csrf" value=(csrf)> | 52 | + </form> |
| 55 | - <div class="field"> | 53 | + </section> |
| 56 | - <label for="invite-email">(t(lang, Key::Email))</label> | 54 | + </div> |
| 57 | - <input id="invite-email" type="email" name="email" autocomplete="off" maxlength="254" required=(true)> | 55 | + if let Some(message) = notice { |
| 58 | - </div> | 56 | + <p class="state" role="status">(message)</p> |
| 59 | - <button type="submit" class="primary">(t(lang, Key::InvitesSubmit))</button> | 57 | + } |
| 60 | - </form> | ||
| 61 | - ) | ||
| 62 | - </div> | ||
| 63 | - </section> | ||
| 64 | }) | 58 | }) |
| 65 | } | 59 | } |
| 66 | 60 | ||
crates/forge-web/src/pages/issue_meta.rsmodified+7 -6
| @@ -22,6 +22,7 @@ use crate::notify; | |||
| 22 | use crate::pages::issue_parts::{ItemKind, bump_live}; | 22 | use crate::pages::issue_parts::{ItemKind, bump_live}; |
| 23 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | 23 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 24 | use crate::state::AppState; | 24 | use crate::state::AppState; |
| 25 | +use crate::views::parts::head; | ||
| 25 | use crate::views::{alert, shell, user_facing_message}; | 26 | use crate::views::{alert, shell, user_facing_message}; |
| 26 | use crate::webhooks::emit::{ | 27 | use crate::webhooks::emit::{ |
| 27 | Sender, emit_assignee_changes, emit_item_action, emit_label_changes, emit_milestone_change, | 28 | Sender, emit_assignee_changes, emit_item_action, emit_label_changes, emit_milestone_change, |
| @@ -58,13 +59,13 @@ impl RepoFrame { | |||
| 58 | .as_ref() | 59 | .as_ref() |
| 59 | .map(|(_, session)| session.csrf_token.clone()) | 60 | .map(|(_, session)| session.csrf_token.clone()) |
| 60 | .unwrap_or_default(); | 61 | .unwrap_or_default(); |
| 61 | - let head = ctx.head(state, active).await?; | 62 | + let repo_head = ctx.head(state, active).await?; |
| 62 | Ok(Self { | 63 | Ok(Self { |
| 63 | title: format!("{}/{}", ctx.repo.owner_name, ctx.repo.name), | 64 | title: format!("{}/{}", ctx.repo.owner_name, ctx.repo.name), |
| 64 | csrf, | 65 | csrf, |
| 65 | archived: ctx.repo.archived, | 66 | archived: ctx.repo.archived, |
| 66 | can_triage: can_triage(ctx), | 67 | can_triage: can_triage(ctx), |
| 67 | - head, | 68 | + head: repo_head, |
| 68 | }) | 69 | }) |
| 69 | } | 70 | } |
| 70 | } | 71 | } |
| @@ -94,7 +95,7 @@ pub(crate) async fn issue_subnav(lang: Lang, title: String, active: String) -> R | |||
| 94 | let on_labels = active == "labels"; | 95 | let on_labels = active == "labels"; |
| 95 | let on_milestones = active == "milestones"; | 96 | let on_milestones = active == "milestones"; |
| 96 | Ok(view! { | 97 | Ok(view! { |
| 97 | - <nav class="sub" aria-label=(g::t(lang, K::IssuePages)) data-live=(live.as_str()) data-live-now=""> | 98 | + <nav class="tabs" aria-label=(g::t(lang, K::IssuePages)) data-live=(live.as_str()) data-live-now=""> |
| 98 | if on_issues { | 99 | if on_issues { |
| 99 | <a href=(issues.as_str()) aria-current="page">(g::t(lang, K::Issues))</a> | 100 | <a href=(issues.as_str()) aria-current="page">(g::t(lang, K::Issues))</a> |
| 100 | } else { | 101 | } else { |
| @@ -201,13 +202,13 @@ pub(crate) async fn action_error_at( | |||
| 201 | back: String, | 202 | back: String, |
| 202 | ) -> Result<impl View> { | 203 | ) -> Result<impl View> { |
| 203 | Ok(view! { | 204 | Ok(view! { |
| 204 | - <section class="sec"> | 205 | + head(title: g::t(lang, K::CouldNotSave)) |
| 205 | - <h1 class="sr-only">(g::t(lang, K::CouldNotSave))</h1> | 206 | + <div class="sheet fit"> |
| 206 | alert(message: message.as_str()) | 207 | alert(message: message.as_str()) |
| 207 | <div class="acts"> | 208 | <div class="acts"> |
| 208 | <a class="act" href=(back.as_str())>(g::t(lang, K::GoBack))</a> | 209 | <a class="act" href=(back.as_str())>(g::t(lang, K::GoBack))</a> |
| 209 | </div> | 210 | </div> |
| 210 | - </section> | 211 | + </div> |
| 211 | }) | 212 | }) |
| 212 | } | 213 | } |
| 213 | 214 | ||
crates/forge-web/src/pages/issue_parts.rsmodified+82 -74
| @@ -437,7 +437,7 @@ pub(crate) async fn comment_item(lang: Lang, item: CommentView) -> Result<impl V | |||
| 437 | let profile = user_href(&login); | 437 | let profile = user_href(&login); |
| 438 | let has_acts = edit_href.is_some() || delete_href.is_some(); | 438 | let has_acts = edit_href.is_some() || delete_href.is_some(); |
| 439 | Ok(view! { | 439 | Ok(view! { |
| 440 | - <article class="thread-entry" id=(anchor.as_str())> | 440 | + <article class="sec thread-entry" id=(anchor.as_str())> |
| 441 | <header class="thread-head"> | 441 | <header class="thread-head"> |
| 442 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> | 442 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> |
| 443 | <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> | 443 | <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> |
| @@ -609,7 +609,7 @@ pub(crate) async fn review_item(lang: Lang, review: ReviewView) -> Result<impl V | |||
| 609 | "review-verb" | 609 | "review-verb" |
| 610 | }; | 610 | }; |
| 611 | Ok(view! { | 611 | Ok(view! { |
| 612 | - <article class="thread-entry review-item" id=(anchor.as_str())> | 612 | + <article class="sec thread-entry review-item" id=(anchor.as_str())> |
| 613 | <header class="thread-head"> | 613 | <header class="thread-head"> |
| 614 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> | 614 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> |
| 615 | <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> | 615 | <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> |
| @@ -1083,9 +1083,9 @@ pub(crate) async fn labels_box( | |||
| 1083 | ) -> Result<impl View> { | 1083 | ) -> Result<impl View> { |
| 1084 | let any_attached = labels.iter().any(|row| row.attached); | 1084 | let any_attached = labels.iter().any(|row| row.attached); |
| 1085 | Ok(view! { | 1085 | Ok(view! { |
| 1086 | - <div class="acts"> | 1086 | + <section class="sec meta"> |
| 1087 | - <span class="state"> | 1087 | + <h2>(g::t(lang, K::Labels))</h2> |
| 1088 | - (g::t(lang, K::Labels)) ": " | 1088 | + <p class="hint"> |
| 1089 | if !any_attached { | 1089 | if !any_attached { |
| 1090 | (g::t(lang, K::NoneYet)) | 1090 | (g::t(lang, K::NoneYet)) |
| 1091 | } | 1091 | } |
| @@ -1094,25 +1094,27 @@ pub(crate) async fn labels_box( | |||
| 1094 | <span class=(row.chip.as_str())>(row.name.as_str())</span> | 1094 | <span class=(row.chip.as_str())>(row.name.as_str())</span> |
| 1095 | } | 1095 | } |
| 1096 | } | 1096 | } |
| 1097 | - </span> | 1097 | + </p> |
| 1098 | if write { | 1098 | if write { |
| 1099 | - reveal(label: g::t(lang, K::Edit), | 1099 | + <div class="acts"> |
| 1100 | - <form method="post" action=(action.as_str()) class="fields" data-apply="true"> | 1100 | + reveal(label: g::t(lang, K::Edit), |
| 1101 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 1101 | + <form method="post" action=(action.as_str()) class="fields" data-apply="true"> |
| 1102 | - if labels.is_empty() { | 1102 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1103 | - <p class="hint">(g::t(lang, K::NoRepoLabels))</p> | 1103 | + if labels.is_empty() { |
| 1104 | - } | 1104 | + <p class="hint">(g::t(lang, K::NoRepoLabels))</p> |
| 1105 | - for row in labels.iter() { | 1105 | + } |
| 1106 | - <label class="switch"> | 1106 | + for row in labels.iter() { |
| 1107 | - <input type="checkbox" name="label" value=(row.id.as_str()) checked=(row.attached)> | 1107 | + <label class="switch"> |
| 1108 | - <span class=(row.chip.as_str())>(row.name.as_str())</span> | 1108 | + <input type="checkbox" name="label" value=(row.id.as_str()) checked=(row.attached)> |
| 1109 | - </label> | 1109 | + <span class=(row.chip.as_str())>(row.name.as_str())</span> |
| 1110 | - } | 1110 | + </label> |
| 1111 | - <noscript><div><button type="submit" class="primary">(g::t(lang, K::SaveLabels))</button></div></noscript> | 1111 | + } |
| 1112 | - </form> | 1112 | + <noscript><div><button type="submit" class="primary">(g::t(lang, K::SaveLabels))</button></div></noscript> |
| 1113 | - ) | 1113 | + </form> |
| 1114 | + ) | ||
| 1115 | + </div> | ||
| 1114 | } | 1116 | } |
| 1115 | - </div> | 1117 | + </section> |
| 1116 | }) | 1118 | }) |
| 1117 | } | 1119 | } |
| 1118 | 1120 | ||
| @@ -1127,16 +1129,17 @@ pub(crate) async fn assignees_box( | |||
| 1127 | ) -> Result<impl View> { | 1129 | ) -> Result<impl View> { |
| 1128 | let text = names.join(", "); | 1130 | let text = names.join(", "); |
| 1129 | Ok(view! { | 1131 | Ok(view! { |
| 1130 | - <div class="acts"> | 1132 | + <section class="sec meta"> |
| 1131 | - <span class="state"> | 1133 | + <h2>(g::t(lang, K::Assignees))</h2> |
| 1132 | - (g::t(lang, K::Assignees)) ": " | 1134 | + <p class="hint"> |
| 1133 | if names.is_empty() { | 1135 | if names.is_empty() { |
| 1134 | (g::t(lang, K::NoOneAssigned)) | 1136 | (g::t(lang, K::NoOneAssigned)) |
| 1135 | } else { | 1137 | } else { |
| 1136 | (text.as_str()) | 1138 | (text.as_str()) |
| 1137 | } | 1139 | } |
| 1138 | - </span> | 1140 | + </p> |
| 1139 | if write { | 1141 | if write { |
| 1142 | + <div class="acts"> | ||
| 1140 | reveal(label: g::t(lang, K::Edit), | 1143 | reveal(label: g::t(lang, K::Edit), |
| 1141 | if let Some(next) = assign_next { | 1144 | if let Some(next) = assign_next { |
| 1142 | <form method="post" action=(action.as_str()) class="act-form"> | 1145 | <form method="post" action=(action.as_str()) class="act-form"> |
| @@ -1155,8 +1158,9 @@ pub(crate) async fn assignees_box( | |||
| 1155 | <noscript><div><button type="submit" class="primary">(g::t(lang, K::SaveAssignees))</button></div></noscript> | 1158 | <noscript><div><button type="submit" class="primary">(g::t(lang, K::SaveAssignees))</button></div></noscript> |
| 1156 | </form> | 1159 | </form> |
| 1157 | ) | 1160 | ) |
| 1161 | + </div> | ||
| 1158 | } | 1162 | } |
| 1159 | - </div> | 1163 | + </section> |
| 1160 | }) | 1164 | }) |
| 1161 | } | 1165 | } |
| 1162 | 1166 | ||
| @@ -1171,33 +1175,35 @@ pub(crate) async fn milestone_box( | |||
| 1171 | none_selected: bool, | 1175 | none_selected: bool, |
| 1172 | ) -> Result<impl View> { | 1176 | ) -> Result<impl View> { |
| 1173 | Ok(view! { | 1177 | Ok(view! { |
| 1174 | - <div class="acts"> | 1178 | + <section class="sec meta"> |
| 1175 | - <span class="state"> | 1179 | + <h2>(g::t(lang, K::MilestoneBox))</h2> |
| 1176 | - (g::t(lang, K::MilestoneBox)) ": " | 1180 | + <p class="hint"> |
| 1177 | if current.is_empty() { | 1181 | if current.is_empty() { |
| 1178 | (g::t(lang, K::NoMilestone)) | 1182 | (g::t(lang, K::NoMilestone)) |
| 1179 | } else { | 1183 | } else { |
| 1180 | (current.as_str()) | 1184 | (current.as_str()) |
| 1181 | } | 1185 | } |
| 1182 | - </span> | 1186 | + </p> |
| 1183 | if write { | 1187 | if write { |
| 1184 | - reveal(label: g::t(lang, K::Edit), | 1188 | + <div class="acts"> |
| 1185 | - <form method="post" action=(action.as_str()) class="fields" data-apply="true"> | 1189 | + reveal(label: g::t(lang, K::Edit), |
| 1186 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 1190 | + <form method="post" action=(action.as_str()) class="fields" data-apply="true"> |
| 1187 | - <div class="field"> | 1191 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1188 | - <label for="issue-milestone">(g::t(lang, K::MilestoneBox))</label> | 1192 | + <div class="field"> |
| 1189 | - <select id="issue-milestone" name="milestone_id"> | 1193 | + <label for="issue-milestone">(g::t(lang, K::MilestoneBox))</label> |
| 1190 | - <option value="" selected=(none_selected)>(g::t(lang, K::NoneOption))</option> | 1194 | + <select id="issue-milestone" name="milestone_id"> |
| 1191 | - for row in options.iter() { | 1195 | + <option value="" selected=(none_selected)>(g::t(lang, K::NoneOption))</option> |
| 1192 | - <option value=(row.id.as_str()) selected=(row.selected)>(row.title.as_str())</option> | 1196 | + for row in options.iter() { |
| 1193 | - } | 1197 | + <option value=(row.id.as_str()) selected=(row.selected)>(row.title.as_str())</option> |
| 1194 | - </select> | 1198 | + } |
| 1195 | - </div> | 1199 | + </select> |
| 1196 | - <noscript><div><button type="submit" class="primary">(g::t(lang, K::SaveMilestone))</button></div></noscript> | 1200 | + </div> |
| 1197 | - </form> | 1201 | + <noscript><div><button type="submit" class="primary">(g::t(lang, K::SaveMilestone))</button></div></noscript> |
| 1198 | - ) | 1202 | + </form> |
| 1203 | + ) | ||
| 1204 | + </div> | ||
| 1199 | } | 1205 | } |
| 1200 | - </div> | 1206 | + </section> |
| 1201 | }) | 1207 | }) |
| 1202 | } | 1208 | } |
| 1203 | 1209 | ||
| @@ -1219,9 +1225,9 @@ pub(crate) async fn lock_box( | |||
| 1219 | .to_owned(); | 1225 | .to_owned(); |
| 1220 | let none = reason.is_none(); | 1226 | let none = reason.is_none(); |
| 1221 | Ok(view! { | 1227 | Ok(view! { |
| 1222 | - <div class="acts"> | 1228 | + <section class="sec meta"> |
| 1223 | - <span class="state"> | 1229 | + <h2>(g::t(lang, K::ConversationBox))</h2> |
| 1224 | - (g::t(lang, K::ConversationBox)) ": " | 1230 | + <p class="hint"> |
| 1225 | if locked { | 1231 | if locked { |
| 1226 | (g::t(lang, K::LockedToCollaborators)) | 1232 | (g::t(lang, K::LockedToCollaborators)) |
| 1227 | if !none { | 1233 | if !none { |
| @@ -1230,32 +1236,34 @@ pub(crate) async fn lock_box( | |||
| 1230 | } else { | 1236 | } else { |
| 1231 | (g::t(lang, K::OpenToEveryone)) | 1237 | (g::t(lang, K::OpenToEveryone)) |
| 1232 | } | 1238 | } |
| 1233 | - </span> | 1239 | + </p> |
| 1234 | if write { | 1240 | if write { |
| 1235 | - reveal(label: g::t(lang, K::Edit), | 1241 | + <div class="acts"> |
| 1236 | - <form method="post" action=(action.as_str()) class="fields"> | 1242 | + reveal(label: g::t(lang, K::Edit), |
| 1237 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 1243 | + <form method="post" action=(action.as_str()) class="fields"> |
| 1238 | - if locked { | 1244 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1239 | - <input type="hidden" name="locked" value="0"> | 1245 | + if locked { |
| 1240 | - <button type="submit" class="primary">(g::t(lang, K::UnlockConversation))</button> | 1246 | + <input type="hidden" name="locked" value="0"> |
| 1241 | - } else { | 1247 | + <button type="submit" class="primary">(g::t(lang, K::UnlockConversation))</button> |
| 1242 | - <div class="field"> | 1248 | + } else { |
| 1243 | - <label for="issue-lock-reason">(g::t(lang, K::Reason))</label> | 1249 | + <div class="field"> |
| 1244 | - <select id="issue-lock-reason" name="reason"> | 1250 | + <label for="issue-lock-reason">(g::t(lang, K::Reason))</label> |
| 1245 | - <option value="" selected=(true)>(g::t(lang, K::NoReason))</option> | 1251 | + <select id="issue-lock-reason" name="reason"> |
| 1246 | - <option value="off_topic">(g::t(lang, K::OptOffTopic))</option> | 1252 | + <option value="" selected=(true)>(g::t(lang, K::NoReason))</option> |
| 1247 | - <option value="too_heated">(g::t(lang, K::OptTooHeated))</option> | 1253 | + <option value="off_topic">(g::t(lang, K::OptOffTopic))</option> |
| 1248 | - <option value="resolved">(g::t(lang, K::OptResolved))</option> | 1254 | + <option value="too_heated">(g::t(lang, K::OptTooHeated))</option> |
| 1249 | - <option value="spam">(g::t(lang, K::OptSpam))</option> | 1255 | + <option value="resolved">(g::t(lang, K::OptResolved))</option> |
| 1250 | - </select> | 1256 | + <option value="spam">(g::t(lang, K::OptSpam))</option> |
| 1251 | - </div> | 1257 | + </select> |
| 1252 | - <input type="hidden" name="locked" value="1"> | 1258 | + </div> |
| 1253 | - <button type="submit" class="primary">(g::t(lang, K::LockConversation))</button> | 1259 | + <input type="hidden" name="locked" value="1"> |
| 1254 | - } | 1260 | + <button type="submit" class="primary">(g::t(lang, K::LockConversation))</button> |
| 1255 | - </form> | 1261 | + } |
| 1256 | - ) | 1262 | + </form> |
| 1263 | + ) | ||
| 1264 | + </div> | ||
| 1257 | } | 1265 | } |
| 1258 | - </div> | 1266 | + </section> |
| 1259 | }) | 1267 | }) |
| 1260 | } | 1268 | } |
| 1261 | 1269 | ||
crates/forge-web/src/pages/issue_pin.rsmodified+8 -6
| @@ -92,18 +92,20 @@ pub(crate) async fn pin_box( | |||
| 92 | g::t(lang, K::PinIssue) | 92 | g::t(lang, K::PinIssue) |
| 93 | }; | 93 | }; |
| 94 | Ok(view! { | 94 | Ok(view! { |
| 95 | - <div class="acts"> | 95 | + <section class="sec meta"> |
| 96 | - <span class="state"> | 96 | + <h2>(g::t(lang, K::Pinned))</h2> |
| 97 | - (g::t(lang, K::Pinned)) ": " | 97 | + <p class="hint"> |
| 98 | if pinned { | 98 | if pinned { |
| 99 | (g::t(lang, K::PinnedTopNote)) | 99 | (g::t(lang, K::PinnedTopNote)) |
| 100 | } else { | 100 | } else { |
| 101 | (g::t(lang, K::NotPinned)) | 101 | (g::t(lang, K::NotPinned)) |
| 102 | } | 102 | } |
| 103 | - </span> | 103 | + </p> |
| 104 | if write { | 104 | if write { |
| 105 | - post_act(label: label, action: action.as_str(), csrf: csrf.as_str(), fields: vec![("pinned".to_owned(), next.to_owned())]) | 105 | + <div class="acts"> |
| 106 | + post_act(label: label, action: action.as_str(), csrf: csrf.as_str(), fields: vec![("pinned".to_owned(), next.to_owned())]) | ||
| 107 | + </div> | ||
| 106 | } | 108 | } |
| 107 | - </div> | 109 | + </section> |
| 108 | }) | 110 | }) |
| 109 | } | 111 | } |
crates/forge-web/src/pages/issue_view.rsmodified+46 -49
| @@ -30,7 +30,8 @@ use crate::pages::notifications::notify_box_for; | |||
| 30 | use crate::pages::repo::repo_head; | 30 | use crate::pages::repo::repo_head; |
| 31 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; | 31 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 32 | use crate::state::AppState; | 32 | use crate::state::AppState; |
| 33 | -use crate::views::{alert, repo_href, shell, user_facing_message, user_link}; | 33 | +use crate::views::parts::SubPart; |
| 34 | +use crate::views::{alert, repo_href, shell, user_facing_message, user_href}; | ||
| 34 | use crate::webhooks::emit::{Sender, emit_comment, emit_item_action}; | 35 | use crate::webhooks::emit::{Sender, emit_comment, emit_item_action}; |
| 35 | 36 | ||
| 36 | path_param!(owner); | 37 | path_param!(owner); |
| @@ -83,6 +84,16 @@ async fn issue_page( | |||
| 83 | (IssueState::Closed, _) => ("issue-badge issue-badge-completed", g::t(lang, K::Closed)), | 84 | (IssueState::Closed, _) => ("issue-badge issue-badge-completed", g::t(lang, K::Closed)), |
| 84 | }; | 85 | }; |
| 85 | let comments_label = g::comment_count(lang, issue.comment_count); | 86 | let comments_label = g::comment_count(lang, issue.comment_count); |
| 87 | + let sub = vec![ | ||
| 88 | + SubPart { | ||
| 89 | + text: state_text.to_owned(), | ||
| 90 | + href: None, | ||
| 91 | + class: state_class, | ||
| 92 | + }, | ||
| 93 | + SubPart::link(author.clone(), user_href(&author_login)), | ||
| 94 | + SubPart::text(opened.relative.clone()), | ||
| 95 | + SubPart::text(comments_label), | ||
| 96 | + ]; | ||
| 86 | let page_title = format!("{} #{number} \u{b7} {owner}/{name}", issue.title); | 97 | let page_title = format!("{} #{number} \u{b7} {owner}/{name}", issue.title); |
| 87 | let number_label = format!("#{number}"); | 98 | let number_label = format!("#{number}"); |
| 88 | let login_href = "/login".to_owned(); | 99 | let login_href = "/login".to_owned(); |
| @@ -93,40 +104,28 @@ async fn issue_page( | |||
| 93 | let header = ctx.head(state, "issues").await?; | 104 | let header = ctx.head(state, "issues").await?; |
| 94 | Ok(view! { cx => | 105 | Ok(view! { cx => |
| 95 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), | 106 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), |
| 96 | - repo_head(head: header) | 107 | + repo_head(head: header, title: Some(issue.title.clone()), sub: sub, |
| 97 | - <section class="sec" data-live=(live_href.as_str()) data-live-now=""> | 108 | + <span class="num">(number_label.as_str())</span> |
| 98 | - <h1 class="h1">(issue.title.as_str()) " " <span class="hint">(number_label.as_str())</span></h1> | 109 | + ) |
| 99 | - <p class="hint"> | 110 | + <div class="work" data-live=(live_href.as_str()) data-live-now=""> |
| 100 | - <span class=(state_class)>(state_text)</span> | 111 | + <div class="sheet"> |
| 101 | - " · " | 112 | + discussion_timeline(lang: lang, discussion: discussion) |
| 102 | - <strong>user_link(shown: author.as_str(), login: author_login.as_str())</strong> | 113 | + if can_comment { |
| 103 | - " " | 114 | + comment_form(lang: lang, action: comment_action.clone(), state_action: comment_action.clone(), |
| 104 | - (g::t(lang, K::OpenedThis)) | 115 | + csrf: csrf.clone(), draft: draft, error: error, can_close: editable_issue, open: open) |
| 105 | - " " | 116 | + } |
| 106 | - <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> | 117 | + if archived { |
| 107 | - " " | 118 | + <p class="state">(g::t(lang, K::ArchivedIssuesReadOnly))</p> |
| 108 | - (g::opened_after(lang)) | 119 | + } |
| 109 | - " · " | 120 | + if locked_for_viewer { |
| 110 | - (comments_label.as_str()) | 121 | + <p class="state">(lock_notice.as_str())</p> |
| 111 | - </p> | 122 | + } else if !signed_in { |
| 112 | - </section> | 123 | + <p class="state">(g::comment_login_lead(lang))<a href=(login_href.as_str())>(g::t(lang, K::LogInLink))</a>(g::t(lang, K::ToComment))</p> |
| 113 | - <section class="sec"> | 124 | + } |
| 114 | pin_box(lang: lang, write: write_meta, pinned: pinned, action: pin_action.clone(), csrf: csrf.clone()) | 125 | pin_box(lang: lang, write: write_meta, pinned: pinned, action: pin_action.clone(), csrf: csrf.clone()) |
| 115 | item_sidebar(lang: lang, write: write_meta, base: issue_href.clone(), csrf: csrf.clone(), viewer: viewer_login, sidebar: sidebar, notify: notify) | 126 | item_sidebar(lang: lang, write: write_meta, base: issue_href.clone(), csrf: csrf.clone(), viewer: viewer_login, sidebar: sidebar, notify: notify) |
| 116 | - </section> | 127 | + </div> |
| 117 | - discussion_timeline(lang: lang, discussion: discussion) | 128 | + </div> |
| 118 | - if can_comment { | ||
| 119 | - comment_form(lang: lang, action: comment_action.clone(), state_action: comment_action.clone(), | ||
| 120 | - csrf: csrf.clone(), draft: draft, error: error, can_close: editable_issue, open: open) | ||
| 121 | - } | ||
| 122 | - if archived { | ||
| 123 | - <p class="hint">(g::t(lang, K::ArchivedIssuesReadOnly))</p> | ||
| 124 | - } | ||
| 125 | - if locked_for_viewer { | ||
| 126 | - <p class="hint">(lock_notice.as_str())</p> | ||
| 127 | - } else if !signed_in { | ||
| 128 | - <p class="hint">(g::comment_login_lead(lang))<a href=(login_href.as_str())>(g::t(lang, K::LogInLink))</a>(g::t(lang, K::ToComment))</p> | ||
| 129 | - } | ||
| 130 | ) | 129 | ) |
| 131 | }) | 130 | }) |
| 132 | } | 131 | } |
| @@ -216,9 +215,8 @@ async fn edit_item_page( | |||
| 216 | let header = ctx.head(state, kind_tab(kind)).await?; | 215 | let header = ctx.head(state, kind_tab(kind)).await?; |
| 217 | Ok(view! { cx => | 216 | Ok(view! { cx => |
| 218 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 217 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 219 | - repo_head(head: header) | 218 | + repo_head(head: header, title: Some(heading)) |
| 220 | - <section class="sec"> | 219 | + <div class="sheet fit"> |
| 221 | - <h1 class="h1">(heading.as_str())</h1> | ||
| 222 | if let Some(message) = error { | 220 | if let Some(message) = error { |
| 223 | alert(message: message.as_str()) | 221 | alert(message: message.as_str()) |
| 224 | } | 222 | } |
| @@ -232,12 +230,12 @@ async fn edit_item_page( | |||
| 232 | <label for="item-body">(g::t(lang, K::Description))</label> | 230 | <label for="item-body">(g::t(lang, K::Description))</label> |
| 233 | <textarea id="item-body" name="body" rows="12">(body.as_str())</textarea> | 231 | <textarea id="item-body" name="body" rows="12">(body.as_str())</textarea> |
| 234 | </div> | 232 | </div> |
| 235 | - <button type="submit" class="primary">(g::t(lang, K::SaveChanges))</button> | 233 | + <div class="acts"> |
| 234 | + <button type="submit" class="primary">(g::t(lang, K::SaveChanges))</button> | ||
| 235 | + <a class="act" href=(back.as_str())>(g::t(lang, K::Cancel))</a> | ||
| 236 | + </div> | ||
| 236 | </form> | 237 | </form> |
| 237 | - <div class="acts"> | 238 | + </div> |
| 238 | - <a class="act quiet" href=(back.as_str())>(g::t(lang, K::Cancel))</a> | ||
| 239 | - </div> | ||
| 240 | - </section> | ||
| 241 | ) | 239 | ) |
| 242 | }) | 240 | }) |
| 243 | } | 241 | } |
| @@ -332,9 +330,8 @@ async fn edit_comment_page( | |||
| 332 | let header = ctx.head(state, kind_tab(kind)).await?; | 330 | let header = ctx.head(state, kind_tab(kind)).await?; |
| 333 | Ok(view! { cx => | 331 | Ok(view! { cx => |
| 334 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 332 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 335 | - repo_head(head: header) | 333 | + repo_head(head: header, title: Some(g::t(lang, K::EditComment).to_owned())) |
| 336 | - <section class="sec"> | 334 | + <div class="sheet fit"> |
| 337 | - <h1 class="h1">(g::t(lang, K::EditComment))</h1> | ||
| 338 | if let Some(message) = error { | 335 | if let Some(message) = error { |
| 339 | alert(message: message.as_str()) | 336 | alert(message: message.as_str()) |
| 340 | } | 337 | } |
| @@ -344,12 +341,12 @@ async fn edit_comment_page( | |||
| 344 | <label for="comment-body">(g::t(lang, K::Comment))</label> | 341 | <label for="comment-body">(g::t(lang, K::Comment))</label> |
| 345 | <textarea id="comment-body" name="body" rows="10">(body.as_str())</textarea> | 342 | <textarea id="comment-body" name="body" rows="10">(body.as_str())</textarea> |
| 346 | </div> | 343 | </div> |
| 347 | - <button type="submit" class="primary">(g::t(lang, K::SaveComment))</button> | 344 | + <div class="acts"> |
| 345 | + <button type="submit" class="primary">(g::t(lang, K::SaveComment))</button> | ||
| 346 | + <a class="act" href=(back.as_str())>(g::t(lang, K::Cancel))</a> | ||
| 347 | + </div> | ||
| 348 | </form> | 348 | </form> |
| 349 | - <div class="acts"> | 349 | + </div> |
| 350 | - <a class="act quiet" href=(back.as_str())>(g::t(lang, K::Cancel))</a> | ||
| 351 | - </div> | ||
| 352 | - </section> | ||
| 353 | ) | 350 | ) |
| 354 | }) | 351 | }) |
| 355 | } | 352 | } |
crates/forge-web/src/pages/issues_list.rsmodified+189 -137
| @@ -21,10 +21,12 @@ use crate::i18n::{self, Lang}; | |||
| 21 | use crate::notify::{self, Activity}; | 21 | use crate::notify::{self, Activity}; |
| 22 | use crate::pages::issue_meta::{can_triage, form_all, form_field, form_pairs}; | 22 | use crate::pages::issue_meta::{can_triage, form_all, form_field, form_pairs}; |
| 23 | use crate::pages::issues_live::list_live_url; | 23 | use crate::pages::issues_live::list_live_url; |
| 24 | +use crate::pages::passkeys::s; | ||
| 24 | use crate::pages::repo::repo_head; | 25 | use crate::pages::repo::repo_head; |
| 25 | use crate::pages::repo_ctx::{RepoHead, load_repo}; | 26 | use crate::pages::repo_ctx::{RepoHead, load_repo}; |
| 26 | use crate::state::AppState; | 27 | use crate::state::AppState; |
| 27 | use crate::templates::{self, Template}; | 28 | use crate::templates::{self, Template}; |
| 29 | +use crate::views::parts::{RailItem, SubPart, rail}; | ||
| 28 | use crate::views::{ | 30 | use crate::views::{ |
| 29 | alert, avatar_url, csrf_field, enc, iso_time, now_unix, relative_time, repo_href, | 31 | alert, avatar_url, csrf_field, enc, iso_time, now_unix, relative_time, repo_href, |
| 30 | shell, user_facing_message, user_link, | 32 | shell, user_facing_message, user_link, |
| @@ -242,18 +244,6 @@ pub(crate) fn stamp_unix(stamp: &str) -> i64 { | |||
| 242 | .map_or(0, |t| t.unix_timestamp()) | 244 | .map_or(0, |t| t.unix_timestamp()) |
| 243 | } | 245 | } |
| 244 | 246 | ||
| 245 | -/// One link of a tab row. The current tab carries `aria-current`. | ||
| 246 | -#[component] | ||
| 247 | -pub(crate) async fn state_tab(href: &str, text: &str, current: bool) -> Result<impl View> { | ||
| 248 | - Ok(view! { | ||
| 249 | - if current { | ||
| 250 | - <a aria-current="page" href=(href)>(text)</a> | ||
| 251 | - } else { | ||
| 252 | - <a href=(href)>(text)</a> | ||
| 253 | - } | ||
| 254 | - }) | ||
| 255 | -} | ||
| 256 | - | ||
| 257 | pub(crate) struct AssigneeView { | 247 | pub(crate) struct AssigneeView { |
| 258 | pub(crate) name: String, | 248 | pub(crate) name: String, |
| 259 | pub(crate) avatar: String, | 249 | pub(crate) avatar: String, |
| @@ -275,7 +265,8 @@ pub(crate) struct MilestoneView { | |||
| 275 | struct RowView { | 265 | struct RowView { |
| 276 | /// The number, the `data-arrive` value that marks a row new after a live update. | 266 | /// The number, the `data-arrive` value that marks a row new after a live update. |
| 277 | arrive: String, | 267 | arrive: String, |
| 278 | - state_class: &'static str, | 268 | + /// `tick`, with `done` for a closed issue. |
| 269 | + tick_class: &'static str, | ||
| 279 | state_label: &'static str, | 270 | state_label: &'static str, |
| 280 | number_text: String, | 271 | number_text: String, |
| 281 | href: String, | 272 | href: String, |
| @@ -323,11 +314,7 @@ fn row_view(row: RowCtx<'_>, item: &IssueListItem) -> RowView { | |||
| 323 | let comments = issue.comment_count.max(0); | 314 | let comments = issue.comment_count.max(0); |
| 324 | RowView { | 315 | RowView { |
| 325 | arrive: issue.number.to_string(), | 316 | arrive: issue.number.to_string(), |
| 326 | - state_class: if open { | 317 | + tick_class: if open { "tick" } else { "tick done" }, |
| 327 | - "issue-state issue-state-open" | ||
| 328 | - } else { | ||
| 329 | - "issue-state issue-state-closed" | ||
| 330 | - }, | ||
| 331 | state_label: if open { | 318 | state_label: if open { |
| 332 | g::t(lang, K::OpenIssue) | 319 | g::t(lang, K::OpenIssue) |
| 333 | } else { | 320 | } else { |
| @@ -340,7 +327,7 @@ fn row_view(row: RowCtx<'_>, item: &IssueListItem) -> RowView { | |||
| 340 | .labels | 327 | .labels |
| 341 | .iter() | 328 | .iter() |
| 342 | .map(|label| LabelView { | 329 | .map(|label| LabelView { |
| 343 | - class: format!("label-chip label-{}", label.id), | 330 | + class: format!("tag label-chip label-{}", label.id), |
| 344 | name: label.name.clone(), | 331 | name: label.name.clone(), |
| 345 | href: list_href(&base, &[("state", state), ("label", label.name.as_str())]), | 332 | href: list_href(&base, &[("state", state), ("label", label.name.as_str())]), |
| 346 | }) | 333 | }) |
| @@ -379,7 +366,7 @@ pub(crate) fn tasks_text(lang: Lang, body: &str) -> Option<String> { | |||
| 379 | 366 | ||
| 380 | /// One pinned issue card, with the strings the template shows already built. | 367 | /// One pinned issue card, with the strings the template shows already built. |
| 381 | struct PinnedCard { | 368 | struct PinnedCard { |
| 382 | - state_class: &'static str, | 369 | + tick_class: &'static str, |
| 383 | state_label: &'static str, | 370 | state_label: &'static str, |
| 384 | number_text: String, | 371 | number_text: String, |
| 385 | href: String, | 372 | href: String, |
| @@ -391,11 +378,7 @@ fn pinned_card(lang: Lang, owner: &str, repo: &str, issue: &forge_core::Issue) - | |||
| 391 | let open = matches!(issue.state, IssueState::Open); | 378 | let open = matches!(issue.state, IssueState::Open); |
| 392 | let comments = issue.comment_count.max(0); | 379 | let comments = issue.comment_count.max(0); |
| 393 | PinnedCard { | 380 | PinnedCard { |
| 394 | - state_class: if open { | 381 | + tick_class: if open { "tick" } else { "tick done" }, |
| 395 | - "issue-state issue-state-open" | ||
| 396 | - } else { | ||
| 397 | - "issue-state issue-state-closed" | ||
| 398 | - }, | ||
| 399 | state_label: if open { | 382 | state_label: if open { |
| 400 | g::t(lang, K::OpenIssue) | 383 | g::t(lang, K::OpenIssue) |
| 401 | } else { | 384 | } else { |
| @@ -415,6 +398,45 @@ pub(crate) struct SortOption { | |||
| 415 | pub(crate) selected: bool, | 398 | pub(crate) selected: bool, |
| 416 | } | 399 | } |
| 417 | 400 | ||
| 401 | +/// How many open issues match one assignee or author, from the list's total with one row asked for. | ||
| 402 | +async fn open_matching( | ||
| 403 | + state: &AppState, | ||
| 404 | + repo_id: &str, | ||
| 405 | + assignee: Option<String>, | ||
| 406 | + author: Option<String>, | ||
| 407 | +) -> forge_core::Result<u64> { | ||
| 408 | + let filter = IssueFilter { | ||
| 409 | + state: Some(IssueState::Open), | ||
| 410 | + label: None, | ||
| 411 | + milestone: None, | ||
| 412 | + author, | ||
| 413 | + assignee, | ||
| 414 | + review_requested: None, | ||
| 415 | + query: None, | ||
| 416 | + draft: None, | ||
| 417 | + sort: IssueSort::Newest, | ||
| 418 | + page: 1, | ||
| 419 | + per_page: 1, | ||
| 420 | + }; | ||
| 421 | + Ok(state.store.list_issues(repo_id, &filter).await?.1) | ||
| 422 | +} | ||
| 423 | + | ||
| 424 | +/// The list's sub line: the open and closed counts, then the viewer's assigned count when signed in. | ||
| 425 | +fn list_sub(lang: Lang, open: u64, closed: u64, assigned: Option<u64>) -> Vec<SubPart> { | ||
| 426 | + let (open_text, closed_text) = match lang { | ||
| 427 | + Lang::En => (format!("{open} open"), format!("{closed} closed")), | ||
| 428 | + Lang::Tr => (format!("{open} açık"), format!("{closed} kapalı")), | ||
| 429 | + }; | ||
| 430 | + let mut parts = vec![SubPart::text(open_text), SubPart::text(closed_text)]; | ||
| 431 | + if let Some(n) = assigned { | ||
| 432 | + parts.push(SubPart::text(match lang { | ||
| 433 | + Lang::En => format!("{n} assigned to you"), | ||
| 434 | + Lang::Tr => format!("{n} sana atanmış"), | ||
| 435 | + })); | ||
| 436 | + } | ||
| 437 | + parts | ||
| 438 | +} | ||
| 439 | + | ||
| 418 | #[page("/{owner}/{repo}/issues")] | 440 | #[page("/{owner}/{repo}/issues")] |
| 419 | async fn issues_list_page(cx: &Cx) -> Result<impl View> { | 441 | async fn issues_list_page(cx: &Cx) -> Result<impl View> { |
| 420 | let owner = path_param::<Owner>(cx); | 442 | let owner = path_param::<Owner>(cx); |
| @@ -469,9 +491,15 @@ async fn issues_list_page(cx: &Cx) -> Result<impl View> { | |||
| 469 | let open_href = sel.href(&base, "open", 1); | 491 | let open_href = sel.href(&base, "open", 1); |
| 470 | let closed_href = sel.href(&base, "closed", 1); | 492 | let closed_href = sel.href(&base, "closed", 1); |
| 471 | let all_href = sel.href(&base, "all", 1); | 493 | let all_href = sel.href(&base, "all", 1); |
| 472 | - let open_text = g::tab_open(lang, open_count); | 494 | + let me = ctx.viewer.as_ref().map(|(u, _)| u.username.clone()); |
| 473 | - let closed_text = g::tab_closed(lang, closed_count); | 495 | + let (assigned_count, created_count) = match &me { |
| 474 | - let all_text = g::tab_all(lang, open_count + closed_count); | 496 | + Some(name) => ( |
| 497 | + open_matching(state, &ctx.repo.id, Some(name.clone()), None).await?, | ||
| 498 | + open_matching(state, &ctx.repo.id, None, Some(name.clone())).await?, | ||
| 499 | + ), | ||
| 500 | + None => (0, 0), | ||
| 501 | + }; | ||
| 502 | + let sub = list_sub(lang, open_count, closed_count, me.as_ref().map(|_| assigned_count)); | ||
| 475 | let clear_href = list_href(&base, &[("state", sel.state)]); | 503 | let clear_href = list_href(&base, &[("state", sel.state)]); |
| 476 | let has_filters = sel.has_filters(); | 504 | let has_filters = sel.has_filters(); |
| 477 | 505 | ||
| @@ -506,92 +534,115 @@ async fn issues_list_page(cx: &Cx) -> Result<impl View> { | |||
| 506 | 534 | ||
| 507 | let live_href = list_live_url(&owner_name, &repo_name); | 535 | let live_href = list_live_url(&owner_name, &repo_name); |
| 508 | let header = ctx.head(state, "issues").await?; | 536 | let header = ctx.head(state, "issues").await?; |
| 537 | + let tools_title = match sel.state { | ||
| 538 | + "closed" => s(lang, "Closed issues", "Kapalı sorunlar"), | ||
| 539 | + "all" => s(lang, "All issues", "Tüm sorunlar"), | ||
| 540 | + _ => s(lang, "Open issues", "Açık sorunlar"), | ||
| 541 | + }; | ||
| 542 | + let person_filter = sel.assignee.is_empty() && sel.author.is_empty(); | ||
| 543 | + let mut rail_items = vec![ | ||
| 544 | + RailItem { | ||
| 545 | + name: g::t(lang, K::Open).to_owned(), | ||
| 546 | + val: open_count.to_string(), | ||
| 547 | + href: open_href, | ||
| 548 | + current: open_on && person_filter, | ||
| 549 | + }, | ||
| 550 | + RailItem { | ||
| 551 | + name: g::t(lang, K::Closed).to_owned(), | ||
| 552 | + val: closed_count.to_string(), | ||
| 553 | + href: closed_href, | ||
| 554 | + current: closed_on && person_filter, | ||
| 555 | + }, | ||
| 556 | + RailItem { | ||
| 557 | + name: s(lang, "All", "Tümü").to_owned(), | ||
| 558 | + val: (open_count + closed_count).to_string(), | ||
| 559 | + href: all_href, | ||
| 560 | + current: all_on && person_filter, | ||
| 561 | + }, | ||
| 562 | + ]; | ||
| 563 | + if let Some(name) = &me { | ||
| 564 | + rail_items.push(RailItem { | ||
| 565 | + name: s(lang, "Assigned to you", "Sana atanmış").to_owned(), | ||
| 566 | + val: assigned_count.to_string(), | ||
| 567 | + href: list_href(&base, &[("state", "open"), ("assignee", name.as_str())]), | ||
| 568 | + current: sel.state == "open" && sel.assignee == *name, | ||
| 569 | + }); | ||
| 570 | + rail_items.push(RailItem { | ||
| 571 | + name: s(lang, "Created by you", "Sana ait").to_owned(), | ||
| 572 | + val: created_count.to_string(), | ||
| 573 | + href: list_href(&base, &[("state", "open"), ("author", name.as_str())]), | ||
| 574 | + current: sel.state == "open" && sel.author == *name, | ||
| 575 | + }); | ||
| 576 | + } | ||
| 509 | Ok(view! { | 577 | Ok(view! { |
| 510 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), | 578 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), |
| 511 | - repo_head(head: header) | 579 | + repo_head(head: header, sub: sub, |
| 512 | - <div data-live=(live_href.as_str()) data-live-now=""> | 580 | + if can_create { |
| 513 | - <h1 class="sr-only">(title.as_str())</h1> | 581 | + <a class="button primary" href=(new_href.as_str()) data-palette-action="go">(g::t(lang, K::NewIssue))</a> |
| 514 | - <nav class="tabs" aria-label=(g::t(lang, K::IssuesByState))> | 582 | + } |
| 515 | - state_tab(href: open_href.as_str(), text: open_text.as_str(), current: open_on) | 583 | + ) |
| 516 | - state_tab(href: closed_href.as_str(), text: closed_text.as_str(), current: closed_on) | 584 | + <div class="work" data-live=(live_href.as_str()) data-live-now=""> |
| 517 | - state_tab(href: all_href.as_str(), text: all_text.as_str(), current: all_on) | 585 | + rail(label: s(lang, "Filters", "Filtreler"), items: rail_items) |
| 518 | - </nav> | 586 | + <div class="sheet"> |
| 519 | - <form method="get" action=(base.as_str())> | 587 | + <form method="get" action=(base.as_str()) class="sheet-tools"> |
| 520 | - <input type="hidden" name="state" value=(sel.state)> | 588 | + <input type="hidden" name="state" value=(sel.state)> |
| 521 | - <input type="hidden" name="label" value=(sel.label.as_str())> | 589 | + <input type="hidden" name="label" value=(sel.label.as_str())> |
| 522 | - <input type="hidden" name="milestone" value=(sel.milestone.as_str())> | 590 | + <input type="hidden" name="milestone" value=(sel.milestone.as_str())> |
| 523 | - <input type="hidden" name="author" value=(sel.author.as_str())> | 591 | + <input type="hidden" name="author" value=(sel.author.as_str())> |
| 524 | - <input type="hidden" name="assignee" value=(sel.assignee.as_str())> | 592 | + <input type="hidden" name="assignee" value=(sel.assignee.as_str())> |
| 525 | - <div class="plain-search"> | 593 | + <strong>(tools_title)</strong> |
| 526 | - <input type="search" name="q" value=(search_value.as_str()) data-live-search="" autocomplete="off" placeholder=(g::t(lang, K::SearchTitles)) aria-label=(g::t(lang, K::SearchTitles)) maxlength="256"> | 594 | + <div class="plain-search"> |
| 527 | - <button type="submit" class="sr-only">(g::t(lang, K::Search))</button> | 595 | + <input type="search" name="q" value=(search_value.as_str()) data-live-search="" autocomplete="off" placeholder=(g::t(lang, K::SearchTitles)) aria-label=(g::t(lang, K::SearchTitles)) maxlength="256"> |
| 528 | - </div> | 596 | + <button type="submit" class="sr-only">(g::t(lang, K::Search))</button> |
| 529 | - <div class="sub"> | 597 | + </div> |
| 530 | - <select name="sort" aria-label=(g::t(lang, K::Sort)) data-autosubmit=(true)> | 598 | + <select name="sort" aria-label=(g::t(lang, K::Sort)) data-autosubmit=(true)> |
| 531 | - for option in sort_options.iter() { | 599 | + for option in sort_options.iter() { |
| 532 | - <option value=(option.value) selected=(option.selected)>(option.label)</option> | 600 | + <option value=(option.value) selected=(option.selected)>(option.label)</option> |
| 533 | - } | 601 | + } |
| 534 | - </select> | 602 | + </select> |
| 535 | - <a href=(labels_page_href.as_str())>(g::t(lang, K::Labels))</a> | 603 | + <a class="act" href=(labels_page_href.as_str())>(g::t(lang, K::Labels))</a> |
| 536 | - <a href=(milestones_href.as_str())>(g::t(lang, K::Milestones))</a> | 604 | + <a class="act" href=(milestones_href.as_str())>(g::t(lang, K::Milestones))</a> |
| 537 | - if can_create { | 605 | + </form> |
| 538 | - <a class="act" href=(new_href.as_str()) data-palette-action="go">(g::t(lang, K::NewIssue))</a> | 606 | + if has_filters { |
| 607 | + <p class="hint">(g::t(lang, K::FiltersApplied)) " " <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a></p> | ||
| 539 | } | 608 | } |
| 540 | - </div> | 609 | + if !pinned.is_empty() { |
| 541 | - </form> | 610 | + <section class="sec" aria-label=(g::t(lang, K::PinnedIssues))> |
| 542 | - if has_filters { | 611 | + <h2>(g::t(lang, K::Pinned))</h2> |
| 543 | - <p class="hint">(g::t(lang, K::FiltersApplied)) " " <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a></p> | 612 | + for card in pinned.iter() { |
| 544 | - } | 613 | + <a class="line" href=(card.href.as_str())> |
| 545 | - if !pinned.is_empty() { | 614 | + <span class=(card.tick_class) role="img" aria-label=(card.state_label)></span> |
| 546 | - <section class="sec" aria-label=(g::t(lang, K::PinnedIssues))> | 615 | + <span class="name">(card.title.as_str())</span> |
| 547 | - <h2>(g::t(lang, K::Pinned))</h2> | 616 | + <span class="val">(card.number_text.as_str()) " · " (card.comments_text.as_str())</span> |
| 548 | - for card in pinned.iter() { | 617 | + </a> |
| 549 | - <a class="line" href=(card.href.as_str())> | 618 | + } |
| 550 | - <span class=(card.state_class) role="img" aria-label=(card.state_label)></span> | 619 | + </section> |
| 551 | - <span class="name">(card.title.as_str())</span> | ||
| 552 | - <span class="val">(card.number_text.as_str()) " · " (card.comments_text.as_str())</span> | ||
| 553 | - </a> | ||
| 554 | } | 620 | } |
| 555 | - </section> | 621 | + if rows.is_empty() { |
| 556 | - } | 622 | + <p class="state">(empty_text)</p> |
| 557 | - if rows.is_empty() { | 623 | + if has_filters { |
| 558 | - <p class="state">(empty_text)</p> | 624 | + <div class="acts"> |
| 559 | - if has_filters { | 625 | + <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> |
| 560 | - <div class="acts"> | 626 | + </div> |
| 561 | - <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> | 627 | + } else if can_create { |
| 562 | - </div> | 628 | + <div class="acts"> |
| 563 | - } else if can_create { | 629 | + <a class="act" href=(new_href.as_str()) data-palette-action="go">(g::t(lang, K::NewIssue))</a> |
| 564 | - <div class="acts"> | 630 | + </div> |
| 565 | - <a class="act" href=(new_href.as_str()) data-palette-action="go">(g::t(lang, K::NewIssue))</a> | 631 | + } |
| 566 | - </div> | 632 | + } else { |
| 567 | - } | 633 | + for row in rows.iter() { |
| 568 | - } else { | 634 | + <div class="line issue-row" data-kb-row="" data-arrive=(row.arrive.as_str())> |
| 569 | - <div> | 635 | + <span class=(row.tick_class) role="img" aria-label=(row.state_label)></span> |
| 570 | - for row in rows.iter() { | 636 | + <a class="name" href=(row.href.as_str())>(row.title.as_str())</a> |
| 571 | - <div class="line issue-row" data-kb-row="" data-arrive=(row.arrive.as_str())> | 637 | + for chip in row.labels.iter() { |
| 572 | - <span class=(row.state_class) role="img" aria-label=(row.state_label)></span> | 638 | + <a class=(chip.class.as_str()) href=(chip.href.as_str())>(chip.name.as_str())</a> |
| 573 | - <div class="issue-main"> | 639 | + } |
| 574 | - <div class="issue-title-line"> | 640 | + <span class="val"> |
| 575 | - <a class="issue-title" href=(row.href.as_str())>(row.title.as_str())</a> | 641 | + (row.number_text.as_str()) " · " |
| 576 | - for chip in row.labels.iter() { | 642 | + user_link(shown: row.author.as_str(), login: row.author.as_str()) " · " |
| 577 | - <a class=(chip.class.as_str()) href=(chip.href.as_str())>(chip.name.as_str())</a> | 643 | + <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 578 | - } | ||
| 579 | - </div> | ||
| 580 | - <div class="issue-meta muted small"> | ||
| 581 | - <span>(row.number_text.as_str())</span> | ||
| 582 | - if lang == Lang::Tr { | ||
| 583 | - <span>user_link(shown: row.author.as_str(), login: row.author.as_str())</span> | ||
| 584 | - <span>(g::t(lang, K::By))</span> | ||
| 585 | - <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | ||
| 586 | - <span>(g::t(lang, K::Opened))</span> | ||
| 587 | - } else { | ||
| 588 | - <span>(g::t(lang, K::Opened))</span> | ||
| 589 | - <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | ||
| 590 | - <span>(g::t(lang, K::By))</span> | ||
| 591 | - <span>user_link(shown: row.author.as_str(), login: row.author.as_str())</span> | ||
| 592 | - } | ||
| 593 | if let Some(milestone) = row.milestone.clone() { | 644 | if let Some(milestone) = row.milestone.clone() { |
| 594 | - <a href=(milestone.href.as_str())>(milestone.title.as_str())</a> | 645 | + " · " <a href=(milestone.href.as_str())>(milestone.title.as_str())</a> |
| 595 | } | 646 | } |
| 596 | if let Some(tasks) = row.tasks_text.clone() { | 647 | if let Some(tasks) = row.tasks_text.clone() { |
| 597 | <span class="task-progress">(tasks.as_str())</span> | 648 | <span class="task-progress">(tasks.as_str())</span> |
| @@ -600,25 +651,24 @@ async fn issues_list_page(cx: &Cx) -> Result<impl View> { | |||
| 600 | <img class="avatar avatar-sm" src=(assignee.avatar.as_str()) alt=(assignee.name.as_str()) title=(assignee.name.as_str()) width="20" height="20"> | 651 | <img class="avatar avatar-sm" src=(assignee.avatar.as_str()) alt=(assignee.name.as_str()) title=(assignee.name.as_str()) width="20" height="20"> |
| 601 | } | 652 | } |
| 602 | if row.has_comments { | 653 | if row.has_comments { |
| 603 | - <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> | 654 | + " · " <a href=(row.href.as_str())>(row.comments_text.as_str())</a> |
| 604 | } | 655 | } |
| 605 | - </div> | 656 | + </span> |
| 606 | </div> | 657 | </div> |
| 607 | - </div> | 658 | + } |
| 608 | - } | ||
| 609 | - </div> | ||
| 610 | - } | ||
| 611 | - if has_newer || has_older { | ||
| 612 | - <nav class="sub"> | ||
| 613 | - if has_newer { | ||
| 614 | - <a href=(newer_href.as_str())>(g::t(lang, K::Newer))</a> | ||
| 615 | } | 659 | } |
| 616 | - <span>(page_label.as_str())</span> | 660 | + if has_newer || has_older { |
| 617 | - if has_older { | 661 | + <nav class="sub"> |
| 618 | - <a href=(older_href.as_str())>(g::t(lang, K::Older))</a> | 662 | + if has_newer { |
| 663 | + <a href=(newer_href.as_str())>(g::t(lang, K::Newer))</a> | ||
| 664 | + } | ||
| 665 | + <span>(page_label.as_str())</span> | ||
| 666 | + if has_older { | ||
| 667 | + <a href=(older_href.as_str())>(g::t(lang, K::Older))</a> | ||
| 668 | + } | ||
| 669 | + </nav> | ||
| 619 | } | 670 | } |
| 620 | - </nav> | 671 | + </div> |
| 621 | - } | ||
| 622 | </div> | 672 | </div> |
| 623 | ) | 673 | ) |
| 624 | }) | 674 | }) |
| @@ -709,8 +759,8 @@ async fn new_issue_body( | |||
| 709 | let rows = chooser.unwrap_or_default(); | 759 | let rows = chooser.unwrap_or_default(); |
| 710 | let has_labels = !labels.is_empty(); | 760 | let has_labels = !labels.is_empty(); |
| 711 | Ok(view! { | 761 | Ok(view! { |
| 712 | - repo_head(head: head) | 762 | + repo_head(head: head, title: Some(g::t(lang, K::NewIssue).to_owned())) |
| 713 | - <h1 class="sr-only">(g::t(lang, K::NewIssue))</h1> | 763 | + <div class="sheet fit"> |
| 714 | if chooser_mode { | 764 | if chooser_mode { |
| 715 | <p class="state">(g::t(lang, K::ChooseTemplate))</p> | 765 | <p class="state">(g::t(lang, K::ChooseTemplate))</p> |
| 716 | <div> | 766 | <div> |
| @@ -741,15 +791,17 @@ async fn new_issue_body( | |||
| 741 | <p class="hint">(g::t(lang, K::MarkdownSupported))</p> | 791 | <p class="hint">(g::t(lang, K::MarkdownSupported))</p> |
| 742 | </div> | 792 | </div> |
| 743 | if has_labels { | 793 | if has_labels { |
| 744 | - <fieldset class="field"> | 794 | + <div class="field"> |
| 745 | - <legend>(g::t(lang, K::Labels))</legend> | 795 | + <span class="field-label">(g::t(lang, K::Labels))</span> |
| 746 | - for label in labels.iter() { | 796 | + <div class="checks"> |
| 747 | - <label class="switch"> | 797 | + for label in labels.iter() { |
| 748 | - <input type="checkbox" name="label" value=(label.id.as_str()) checked=(label.checked)> | 798 | + <label class="switch"> |
| 749 | - <span>(label.name.as_str())</span> | 799 | + <input type="checkbox" name="label" value=(label.id.as_str()) checked=(label.checked)> |
| 750 | - </label> | 800 | + <span>(label.name.as_str())</span> |
| 751 | - } | 801 | + </label> |
| 752 | - </fieldset> | 802 | + } |
| 803 | + </div> | ||
| 804 | + </div> | ||
| 753 | } | 805 | } |
| 754 | <div class="acts"> | 806 | <div class="acts"> |
| 755 | <button type="submit" class="primary">(g::t(lang, K::SubmitNewIssue))</button> | 807 | <button type="submit" class="primary">(g::t(lang, K::SubmitNewIssue))</button> |
| @@ -757,6 +809,7 @@ async fn new_issue_body( | |||
| 757 | </div> | 809 | </div> |
| 758 | </form> | 810 | </form> |
| 759 | } | 811 | } |
| 812 | + </div> | ||
| 760 | }) | 813 | }) |
| 761 | } | 814 | } |
| 762 | 815 | ||
| @@ -1139,7 +1192,6 @@ mod tests { | |||
| 1139 | .await | 1192 | .await |
| 1140 | .text(); | 1193 | .text(); |
| 1141 | assert!(html.contains("az önce"), "{html}"); | 1194 | assert!(html.contains("az önce"), "{html}"); |
| 1142 | - assert!(html.contains("açıldı"), "{html}"); | ||
| 1143 | assert!(!html.contains("just now"), "{html}"); | 1195 | assert!(!html.contains("just now"), "{html}"); |
| 1144 | 1196 | ||
| 1145 | // [archived] last, because it changes the repo: creates and the form are 403. | 1197 | // [archived] last, because it changes the repo: creates and the form are 403. |
| @@ -1227,7 +1279,7 @@ mod tests { | |||
| 1227 | .text(); | 1279 | .text(); |
| 1228 | assert!(default.contains("still open")); | 1280 | assert!(default.contains("still open")); |
| 1229 | assert!(!default.contains("already done")); | 1281 | assert!(!default.contains("already done")); |
| 1230 | - assert!(default.contains("Closed 1"), "{default}"); | 1282 | + assert!(default.contains(">Closed</span>"), "{default}"); |
| 1231 | let closed = send( | 1283 | let closed = send( |
| 1232 | &fx.router, | 1284 | &fx.router, |
| 1233 | "GET", | 1285 | "GET", |
crates/forge-web/src/pages/labels_page.rsmodified+6 -7
| @@ -97,13 +97,12 @@ async fn labels_body( | |||
| 97 | let csrf = frame.csrf.clone(); | 97 | let csrf = frame.csrf.clone(); |
| 98 | let header = frame.head.clone(); | 98 | let header = frame.head.clone(); |
| 99 | Ok(view! { | 99 | Ok(view! { |
| 100 | - repo_head(head: header) | 100 | + repo_head(head: header, title: Some(g::t(lang, K::Labels).to_owned())) |
| 101 | - if archived { | ||
| 102 | - <p class="state" role="status">(g::t(lang, K::LabelsArchived))</p> | ||
| 103 | - } | ||
| 104 | issue_subnav(lang: lang, title: frame.title.clone(), active: "labels".to_owned()) | 101 | issue_subnav(lang: lang, title: frame.title.clone(), active: "labels".to_owned()) |
| 105 | - <div class="lang-list" data-live=(live.as_str()) data-live-now=""> | 102 | + <div class="sheet" data-live=(live.as_str()) data-live-now=""> |
| 106 | - <h2 class="sr-only">(g::t(lang, K::Labels))</h2> | 103 | + if archived { |
| 104 | + <p class="state" role="status">(g::t(lang, K::LabelsArchived))</p> | ||
| 105 | + } | ||
| 107 | if can_triage { | 106 | if can_triage { |
| 108 | <section class="sec"> | 107 | <section class="sec"> |
| 109 | <h2>(g::t(lang, K::NewLabel))</h2> | 108 | <h2>(g::t(lang, K::NewLabel))</h2> |
| @@ -149,7 +148,7 @@ async fn labels_body( | |||
| 149 | </span> | 148 | </span> |
| 150 | </summary> | 149 | </summary> |
| 151 | <div class="opened"> | 150 | <div class="opened"> |
| 152 | - <p class="state"><a class="label-open" href=(row.issues_href.as_str())>(row.open_text.as_str())</a></p> | 151 | + <p class="hint"><a class="label-open" href=(row.issues_href.as_str())>(row.open_text.as_str())</a></p> |
| 153 | if can_triage { | 152 | if can_triage { |
| 154 | <div class="acts"> | 153 | <div class="acts"> |
| 155 | reveal(label: g::t(lang, K::Edit), | 154 | reveal(label: g::t(lang, K::Edit), |
crates/forge-web/src/pages/login.rsmodified+19 -10
| @@ -22,9 +22,10 @@ use crate::auth::{ | |||
| 22 | }; | 22 | }; |
| 23 | use crate::client_ip::client_ip; | 23 | use crate::client_ip::client_ip; |
| 24 | use crate::i18n::{self, Key, Lang, t}; | 24 | use crate::i18n::{self, Key, Lang, t}; |
| 25 | -use crate::pages::passkeys::{available as passkeys_available, login_passkey}; | 25 | +use crate::pages::passkeys::{available as passkeys_available, login_passkey, s}; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| 27 | use crate::throttle::{self, LOGIN_IP_LIMIT, LOGIN_USER_LIMIT, TWO_FACTOR_USER_LIMIT}; | 27 | use crate::throttle::{self, LOGIN_IP_LIMIT, LOGIN_USER_LIMIT, TWO_FACTOR_USER_LIMIT}; |
| 28 | +use crate::views::parts::{SubPart, head}; | ||
| 28 | use crate::views::{alert, shell}; | 29 | use crate::views::{alert, shell}; |
| 29 | 30 | ||
| 30 | /// Hash checked when the username is unknown, so both paths spend one argon2 verify. | 31 | /// Hash checked when the username is unknown, so both paths spend one argon2 verify. |
| @@ -76,10 +77,11 @@ async fn login_form( | |||
| 76 | precsrf: &str, | 77 | precsrf: &str, |
| 77 | error: Option<String>, | 78 | error: Option<String>, |
| 78 | passkeys: bool, | 79 | passkeys: bool, |
| 80 | + can_register: bool, | ||
| 79 | ) -> Result<impl View> { | 81 | ) -> Result<impl View> { |
| 80 | Ok(view! { | 82 | Ok(view! { |
| 81 | - <section> | 83 | + head(title: t(lang, Key::LogIn)) |
| 82 | - <h1>(t(lang, Key::LogIn))</h1> | 84 | + <div class="sheet fit"> |
| 83 | <form data-hard="true" method="post" action="/login" class="fields"> | 85 | <form data-hard="true" method="post" action="/login" class="fields"> |
| 84 | if let Some(message) = error { | 86 | if let Some(message) = error { |
| 85 | alert(message: message.as_str()) | 87 | alert(message: message.as_str()) |
| @@ -95,11 +97,17 @@ async fn login_form( | |||
| 95 | <input id="login-password" type="password" name="password" autocomplete="current-password" required=(true)> | 97 | <input id="login-password" type="password" name="password" autocomplete="current-password" required=(true)> |
| 96 | </div> | 98 | </div> |
| 97 | <button type="submit" class="primary">(t(lang, Key::LogIn))</button> | 99 | <button type="submit" class="primary">(t(lang, Key::LogIn))</button> |
| 100 | + <p class="acts"> | ||
| 101 | + <a class="act" href="/forgot">(s(lang, "Forgot password", "Parolamı unuttum"))</a> | ||
| 102 | + if can_register { | ||
| 103 | + <a class="act" href="/register">(s(lang, "Create an account", "Hesap oluştur"))</a> | ||
| 104 | + } | ||
| 105 | + </p> | ||
| 98 | </form> | 106 | </form> |
| 99 | if passkeys { | 107 | if passkeys { |
| 100 | login_passkey(lang: lang) | 108 | login_passkey(lang: lang) |
| 101 | } | 109 | } |
| 102 | - </section> | 110 | + </div> |
| 103 | }) | 111 | }) |
| 104 | } | 112 | } |
| 105 | 113 | ||
| @@ -113,8 +121,9 @@ async fn login_page(cx: &Cx) -> Result<impl View> { | |||
| 113 | let precsrf = pre_csrf_token(cx); | 121 | let precsrf = pre_csrf_token(cx); |
| 114 | let lang = i18n::lang(cx, None); | 122 | let lang = i18n::lang(cx, None); |
| 115 | let passkeys = passkeys_available(app_context::<AppState>(cx)); | 123 | let passkeys = passkeys_available(app_context::<AppState>(cx)); |
| 124 | + let can_register = app_context::<AppState>(cx).live().registration == forge_core::Registration::Open; | ||
| 116 | Ok(view! { | 125 | Ok(view! { |
| 117 | - shell(title: t(lang, Key::LogIn), viewer: None, login_form(lang: lang, next: next.as_str(), username: "", precsrf: precsrf.as_str(), error: None, passkeys: passkeys)) | 126 | + shell(title: t(lang, Key::LogIn), viewer: None, login_form(lang: lang, next: next.as_str(), username: "", precsrf: precsrf.as_str(), error: None, passkeys: passkeys, can_register: can_register)) |
| 118 | }) | 127 | }) |
| 119 | } | 128 | } |
| 120 | 129 | ||
| @@ -258,20 +267,20 @@ async fn login_submit(cx: &Cx, Form(form): Form<LoginForm>) -> Result<impl View> | |||
| 258 | let username = form.username.clone(); | 267 | let username = form.username.clone(); |
| 259 | let precsrf = form.precsrf.clone(); | 268 | let precsrf = form.precsrf.clone(); |
| 260 | let passkeys = passkeys_available(state); | 269 | let passkeys = passkeys_available(state); |
| 270 | + let can_register = state.live().registration == forge_core::Registration::Open; | ||
| 261 | // The status and headers are view parts, so they apply to this page's response. | 271 | // The status and headers are view parts, so they apply to this page's response. |
| 262 | Ok(view! { | 272 | Ok(view! { |
| 263 | (status) | 273 | (status) |
| 264 | (headers) | 274 | (headers) |
| 265 | - shell(title: t(lang, Key::LogIn), viewer: None, login_form(lang: lang, next: next.as_str(), username: username.as_str(), precsrf: precsrf.as_str(), error: Some(message), passkeys: passkeys)) | 275 | + shell(title: t(lang, Key::LogIn), viewer: None, login_form(lang: lang, next: next.as_str(), username: username.as_str(), precsrf: precsrf.as_str(), error: Some(message), passkeys: passkeys, can_register: can_register)) |
| 266 | }) | 276 | }) |
| 267 | } | 277 | } |
| 268 | 278 | ||
| 269 | #[component] | 279 | #[component] |
| 270 | async fn two_factor_form(lang: Lang, precsrf: &str, error: Option<String>) -> Result<impl View> { | 280 | async fn two_factor_form(lang: Lang, precsrf: &str, error: Option<String>) -> Result<impl View> { |
| 271 | Ok(view! { | 281 | Ok(view! { |
| 272 | - <section> | 282 | + head(title: t(lang, Key::TwoFactorCheck), sub: vec![SubPart::text(t(lang, Key::TwoFactorCheckSub))]) |
| 273 | - <h1>(t(lang, Key::TwoFactorCheck))</h1> | 283 | + <div class="sheet fit"> |
| 274 | - <p class="hint">(t(lang, Key::TwoFactorCheckSub))</p> | ||
| 275 | <form data-hard="true" method="post" action="/login/2fa" class="fields"> | 284 | <form data-hard="true" method="post" action="/login/2fa" class="fields"> |
| 276 | if let Some(message) = error { | 285 | if let Some(message) = error { |
| 277 | alert(message: message.as_str()) | 286 | alert(message: message.as_str()) |
| @@ -283,7 +292,7 @@ async fn two_factor_form(lang: Lang, precsrf: &str, error: Option<String>) -> Re | |||
| 283 | </div> | 292 | </div> |
| 284 | <button type="submit" class="primary">(t(lang, Key::Verify))</button> | 293 | <button type="submit" class="primary">(t(lang, Key::Verify))</button> |
| 285 | </form> | 294 | </form> |
| 286 | - </section> | 295 | + </div> |
| 287 | }) | 296 | }) |
| 288 | } | 297 | } |
| 289 | 298 | ||
crates/forge-web/src/pages/merge_queue.rsmodified+49 -45
| @@ -359,7 +359,7 @@ async fn queue_body( | |||
| 359 | csrf: String, | 359 | csrf: String, |
| 360 | ) -> Result<impl View> { | 360 | ) -> Result<impl View> { |
| 361 | let remove_label = g::t(lang, K::RemoveFromQueue); | 361 | let remove_label = g::t(lang, K::RemoveFromQueue); |
| 362 | - let hint = g::t(lang, K::MergeQueueHint); | 362 | + let hint = g::t(lang, K::RequireMergeQueueHint); |
| 363 | let remove_note = crate::pages::passkeys::s( | 363 | let remove_note = crate::pages::passkeys::s( |
| 364 | lang, | 364 | lang, |
| 365 | "The pull request leaves the queue. It can join again later.", | 365 | "The pull request leaves the queue. It can join again later.", |
| @@ -367,49 +367,24 @@ async fn queue_body( | |||
| 367 | ) | 367 | ) |
| 368 | .to_owned(); | 368 | .to_owned(); |
| 369 | Ok(view! { | 369 | Ok(view! { |
| 370 | - repo_head(head: head) | 370 | + repo_head(head: head, title: Some(g::t(lang, K::MergeQueueTitle).to_owned())) |
| 371 | - if !protected { | 371 | + <nav class="tabs" aria-label=(g::t(lang, K::MergeQueueNav))> |
| 372 | - <p class="state" role="status">(g::t(lang, K::QueueNoBranch))</p> | 372 | + <a aria-current=(current_tab(!history)) href=(waiting_href.as_str())>(g::t(lang, K::QueueWaiting))</a> |
| 373 | - } | 373 | + <a aria-current=(current_tab(history)) href=(history_href.as_str())>(g::t(lang, K::QueueHistory))</a> |
| 374 | - <div data-live=(live.as_str())> | 374 | + </nav> |
| 375 | - <nav class="tabs" aria-label=(g::t(lang, K::MergeQueueNav))> | 375 | + <div class="sheet" data-live=(live.as_str())> |
| 376 | - <a aria-current=(current_tab(!history)) href=(waiting_href.as_str())>(g::t(lang, K::QueueWaiting))</a> | 376 | + if !protected { |
| 377 | - <a aria-current=(current_tab(history)) href=(history_href.as_str())>(g::t(lang, K::QueueHistory))</a> | 377 | + <p class="state" role="status">(g::t(lang, K::QueueNoBranch))</p> |
| 378 | - </nav> | 378 | + } |
| 379 | if empty { | 379 | if empty { |
| 380 | - <p class="state">(g::t(lang, K::QueueEmpty))</p> | 380 | + if protected { |
| 381 | + <p class="state">(g::t(lang, K::QueueEmpty))</p> | ||
| 382 | + } | ||
| 381 | } else { | 383 | } else { |
| 382 | - <div> | 384 | + for row in rows.iter() { |
| 383 | - for row in rows.iter() { | 385 | + if row.remove { |
| 384 | - if row.remove { | 386 | + <details class="row-open"> |
| 385 | - <details class="row-open"> | 387 | + <summary class="line" data-kb-row=""> |
| 386 | - <summary class="line" data-kb-row=""> | ||
| 387 | - <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> | ||
| 388 | - <span class="val"> | ||
| 389 | - if !row.position.is_empty() { | ||
| 390 | - (g::t(lang, K::QueueColPosition)) " " (row.position.as_str()) " · " | ||
| 391 | - } | ||
| 392 | - <span class=(row.state_class)>(row.state)</span> | ||
| 393 | - " · " <code>(row.branch.as_str())</code> | ||
| 394 | - " · " (row.by.as_str()) | ||
| 395 | - " · " rel_time(lang: lang, stamp: row.queued_at.as_str()) | ||
| 396 | - " · " | ||
| 397 | - if let Some(href) = row.run_href.as_ref() { | ||
| 398 | - <a href=(href.as_str())>(row.run_label.as_str())</a> | ||
| 399 | - } else { | ||
| 400 | - <span>(row.run_label.as_str())</span> | ||
| 401 | - } | ||
| 402 | - if !row.reason.is_empty() { | ||
| 403 | - " · " (row.reason.as_str()) | ||
| 404 | - } | ||
| 405 | - </span> | ||
| 406 | - </summary> | ||
| 407 | - <div class="opened"> | ||
| 408 | - confirm_act(lang: lang, label: remove_label, action: row.remove_action.as_str(), csrf: csrf.as_str(), note: Some(remove_note.clone())) | ||
| 409 | - </div> | ||
| 410 | - </details> | ||
| 411 | - } else { | ||
| 412 | - <div class="line" data-kb-row=""> | ||
| 413 | <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> | 388 | <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> |
| 414 | <span class="val"> | 389 | <span class="val"> |
| 415 | if !row.position.is_empty() { | 390 | if !row.position.is_empty() { |
| @@ -429,12 +404,41 @@ async fn queue_body( | |||
| 429 | " · " (row.reason.as_str()) | 404 | " · " (row.reason.as_str()) |
| 430 | } | 405 | } |
| 431 | </span> | 406 | </span> |
| 407 | + </summary> | ||
| 408 | + <div class="opened"> | ||
| 409 | + confirm_act(lang: lang, label: remove_label, action: row.remove_action.as_str(), csrf: csrf.as_str(), note: Some(remove_note.clone())) | ||
| 432 | </div> | 410 | </div> |
| 433 | - } | 411 | + </details> |
| 412 | + } else { | ||
| 413 | + <div class="line" data-kb-row=""> | ||
| 414 | + <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> | ||
| 415 | + <span class="val"> | ||
| 416 | + if !row.position.is_empty() { | ||
| 417 | + (g::t(lang, K::QueueColPosition)) " " (row.position.as_str()) " · " | ||
| 418 | + } | ||
| 419 | + <span class=(row.state_class)>(row.state)</span> | ||
| 420 | + " · " <code>(row.branch.as_str())</code> | ||
| 421 | + " · " (row.by.as_str()) | ||
| 422 | + " · " rel_time(lang: lang, stamp: row.queued_at.as_str()) | ||
| 423 | + " · " | ||
| 424 | + if let Some(href) = row.run_href.as_ref() { | ||
| 425 | + <a href=(href.as_str())>(row.run_label.as_str())</a> | ||
| 426 | + } else { | ||
| 427 | + <span>(row.run_label.as_str())</span> | ||
| 428 | + } | ||
| 429 | + if !row.reason.is_empty() { | ||
| 430 | + " · " (row.reason.as_str()) | ||
| 431 | + } | ||
| 432 | + </span> | ||
| 433 | + </div> | ||
| 434 | } | 434 | } |
| 435 | - </div> | 435 | + } |
| 436 | + } | ||
| 437 | + if protected { | ||
| 438 | + <section class="sec"> | ||
| 439 | + <p class="hint">(hint)</p> | ||
| 440 | + </section> | ||
| 436 | } | 441 | } |
| 437 | - <p class="hint">(hint)</p> | ||
| 438 | </div> | 442 | </div> |
| 439 | }) | 443 | }) |
| 440 | } | 444 | } |
crates/forge-web/src/pages/milestones_page.rsmodified+23 -21
| @@ -98,19 +98,19 @@ fn due_on_field(raw: &str) -> Option<&str> { | |||
| 98 | (!trimmed.is_empty()).then_some(trimmed) | 98 | (!trimmed.is_empty()).then_some(trimmed) |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | -/// The Open and Closed filter links, with the current one marked. | 101 | +/// The Open and Closed filter as the sheet's tools row: the shown state in bold, the other a link. |
| 102 | #[component] | 102 | #[component] |
| 103 | async fn state_tabs(lang: Lang, title: String, closed: bool) -> Result<impl View> { | 103 | async fn state_tabs(lang: Lang, title: String, closed: bool) -> Result<impl View> { |
| 104 | let open_href = format!("{}?state=open", milestones_href(&title)); | 104 | let open_href = format!("{}?state=open", milestones_href(&title)); |
| 105 | let closed_href = format!("{}?state=closed", milestones_href(&title)); | 105 | let closed_href = format!("{}?state=closed", milestones_href(&title)); |
| 106 | Ok(view! { | 106 | Ok(view! { |
| 107 | - <nav class="sub" aria-label=(g::t(lang, K::MilestoneState))> | 107 | + <nav class="sheet-tools" aria-label=(g::t(lang, K::MilestoneState))> |
| 108 | if closed { | 108 | if closed { |
| 109 | - <a href=(open_href.as_str())>(g::t(lang, K::Open))</a> | 109 | + <strong aria-current="page">(g::t(lang, K::Closed))</strong> |
| 110 | - <a href=(closed_href.as_str()) aria-current="page">(g::t(lang, K::Closed))</a> | 110 | + <a class="act" href=(open_href.as_str())>(g::t(lang, K::Open))</a> |
| 111 | } else { | 111 | } else { |
| 112 | - <a href=(open_href.as_str()) aria-current="page">(g::t(lang, K::Open))</a> | 112 | + <strong aria-current="page">(g::t(lang, K::Open))</strong> |
| 113 | - <a href=(closed_href.as_str())>(g::t(lang, K::Closed))</a> | 113 | + <a class="act" href=(closed_href.as_str())>(g::t(lang, K::Closed))</a> |
| 114 | } | 114 | } |
| 115 | </nav> | 115 | </nav> |
| 116 | }) | 116 | }) |
| @@ -136,7 +136,7 @@ async fn milestone_row( | |||
| 136 | <span class="val">(open_text.as_str()) " \u{b7} " (closed_text.as_str())</span> | 136 | <span class="val">(open_text.as_str()) " \u{b7} " (closed_text.as_str())</span> |
| 137 | </summary> | 137 | </summary> |
| 138 | <div class="opened"> | 138 | <div class="opened"> |
| 139 | - <p class="state"> | 139 | + <p class="hint"> |
| 140 | if let Some(due) = row.due.as_deref() { | 140 | if let Some(due) = row.due.as_deref() { |
| 141 | (g::due_text(lang, due)) | 141 | (g::due_text(lang, due)) |
| 142 | if row.overdue { | 142 | if row.overdue { |
| @@ -147,9 +147,9 @@ async fn milestone_row( | |||
| 147 | } | 147 | } |
| 148 | </p> | 148 | </p> |
| 149 | <progress value=(row.closed) max=(max)></progress> | 149 | <progress value=(row.closed) max=(max)></progress> |
| 150 | - <div class="sub"> | 150 | + <div class="acts"> |
| 151 | - <a href=(row.open_href.as_str())>(open_text.as_str())</a> | 151 | + <a class="act" href=(row.open_href.as_str())>(open_text.as_str())</a> |
| 152 | - <a href=(row.closed_href.as_str())>(closed_text.as_str())</a> | 152 | + <a class="act" href=(row.closed_href.as_str())>(closed_text.as_str())</a> |
| 153 | </div> | 153 | </div> |
| 154 | if !row.description_html.is_empty() { | 154 | if !row.description_html.is_empty() { |
| 155 | <div class="markdown-body">(Unescaped::new_unchecked(row.description_html.clone()))</div> | 155 | <div class="markdown-body">(Unescaped::new_unchecked(row.description_html.clone()))</div> |
| @@ -263,13 +263,13 @@ async fn milestones_body( | |||
| 263 | g::t(lang, K::NoOpenMilestones) | 263 | g::t(lang, K::NoOpenMilestones) |
| 264 | }; | 264 | }; |
| 265 | Ok(view! { | 265 | Ok(view! { |
| 266 | - repo_head(head: header) | 266 | + repo_head(head: header, title: Some(g::t(lang, K::Milestones).to_owned())) |
| 267 | - if frame.archived { | ||
| 268 | - <p class="state" role="status">(g::t(lang, K::MilestonesArchived))</p> | ||
| 269 | - } | ||
| 270 | issue_subnav(lang: lang, title: title.clone(), active: "milestones".to_owned()) | 267 | issue_subnav(lang: lang, title: title.clone(), active: "milestones".to_owned()) |
| 271 | - state_tabs(lang: lang, title: title.clone(), closed: closed) | 268 | + <div class="sheet" data-live=(live.as_str()) data-live-now=""> |
| 272 | - <div class="lang-list" data-live=(live.as_str()) data-live-now=""> | 269 | + state_tabs(lang: lang, title: title.clone(), closed: closed) |
| 270 | + if frame.archived { | ||
| 271 | + <p class="state" role="status">(g::t(lang, K::MilestonesArchived))</p> | ||
| 272 | + } | ||
| 273 | if can_create { | 273 | if can_create { |
| 274 | <section class="sec"> | 274 | <section class="sec"> |
| 275 | <h2>(g::t(lang, K::NewMilestone))</h2> | 275 | <h2>(g::t(lang, K::NewMilestone))</h2> |
| @@ -391,11 +391,13 @@ async fn milestone_edit_body( | |||
| 391 | let csrf = frame.csrf.clone(); | 391 | let csrf = frame.csrf.clone(); |
| 392 | let header = frame.head.clone(); | 392 | let header = frame.head.clone(); |
| 393 | Ok(view! { | 393 | Ok(view! { |
| 394 | - repo_head(head: header) | 394 | + repo_head(head: header, title: Some(g::t(lang, K::EditMilestone).to_owned())) |
| 395 | issue_subnav(lang: lang, title: frame.title.clone(), active: "milestones".to_owned()) | 395 | issue_subnav(lang: lang, title: frame.title.clone(), active: "milestones".to_owned()) |
| 396 | - <section class="sec"> | 396 | + <div class="sheet fit"> |
| 397 | - <h2>(g::t(lang, K::EditMilestone))</h2> | 397 | + <div class="sheet-tools"> |
| 398 | - <p class="sub"><a href=(back.as_str())>(g::t(lang, K::BackToMilestones))</a></p> | 398 | + <strong>(title_value.as_str())</strong> |
| 399 | + <a class="act" href=(back.as_str())>(g::t(lang, K::BackToMilestones))</a> | ||
| 400 | + </div> | ||
| 399 | <form method="post" action=(action.as_str()) class="fields"> | 401 | <form method="post" action=(action.as_str()) class="fields"> |
| 400 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 402 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 401 | <div class="field"> | 403 | <div class="field"> |
| @@ -419,7 +421,7 @@ async fn milestone_edit_body( | |||
| 419 | </div> | 421 | </div> |
| 420 | <button type="submit" class="primary">(g::t(lang, K::SaveMilestone))</button> | 422 | <button type="submit" class="primary">(g::t(lang, K::SaveMilestone))</button> |
| 421 | </form> | 423 | </form> |
| 422 | - </section> | 424 | + </div> |
| 423 | }) | 425 | }) |
| 424 | } | 426 | } |
| 425 | 427 | ||
crates/forge-web/src/pages/needs_you.rsmodified+26 -33
| @@ -20,7 +20,9 @@ use crate::i18n::needs::{self as ni, K}; | |||
| 20 | use crate::i18n::{self, Lang}; | 20 | use crate::i18n::{self, Lang}; |
| 21 | use crate::live::{Topic, stream_wakes}; | 21 | use crate::live::{Topic, stream_wakes}; |
| 22 | use crate::pages::ci_runs::run_href; | 22 | use crate::pages::ci_runs::run_href; |
| 23 | +use crate::pages::passkeys::s; | ||
| 23 | use crate::state::AppState; | 24 | use crate::state::AppState; |
| 25 | +use crate::views::parts::{SubPart, head}; | ||
| 24 | use crate::views::repo_list::{PageLink, pager, pager_links}; | 26 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 25 | use crate::views::{rel_time, repo_href, shell}; | 27 | use crate::views::{rel_time, repo_href, shell}; |
| 26 | 28 | ||
| @@ -360,18 +362,16 @@ pub(crate) async fn need_section(lang: Lang, section: NeedSection) -> Result<imp | |||
| 360 | Ok(view! { | 362 | Ok(view! { |
| 361 | <section class="sec"> | 363 | <section class="sec"> |
| 362 | <h2>(heading)</h2> | 364 | <h2>(heading)</h2> |
| 363 | - <div class="plain-rows"> | 365 | + for row in rows.iter() { |
| 364 | - for row in rows.iter() { | 366 | + <a class="line" href=(row.href.as_str()) data-kb-row=""> |
| 365 | - <a class="line" href=(row.href.as_str()) data-kb-row=""> | 367 | + <span class="name">(row.title.as_str())</span> |
| 366 | - <span class="name">(row.title.as_str())</span> | 368 | + if let Some(badge) = row.badge { |
| 367 | - if let Some(badge) = row.badge { | 369 | + <span class="badge">(badge)</span> |
| 368 | - <span class="badge">(badge)</span> | 370 | + } |
| 369 | - } | 371 | + <span class="val">(row.detail.as_str())</span> |
| 370 | - <span class="val">(row.detail.as_str())</span> | 372 | + <span class="val">rel_time(lang: lang, stamp: row.stamp.as_str())</span> |
| 371 | - <span class="val">rel_time(lang: lang, stamp: row.stamp.as_str())</span> | 373 | + </a> |
| 372 | - </a> | 374 | + } |
| 373 | - } | ||
| 374 | - </div> | ||
| 375 | if let Some((href, text)) = more { | 375 | if let Some((href, text)) = more { |
| 376 | <div class="acts"> | 376 | <div class="acts"> |
| 377 | <a class="act" href=(href)>(text)</a> | 377 | <a class="act" href=(href)>(text)</a> |
| @@ -407,35 +407,28 @@ async fn needs_you(cx: &Cx) -> Result<impl View> { | |||
| 407 | ), | 407 | ), |
| 408 | _ => "/needs-you/events".to_owned(), | 408 | _ => "/needs-you/events".to_owned(), |
| 409 | }; | 409 | }; |
| 410 | - let grid = full.is_none() && !sections.is_empty(); | ||
| 411 | let empty = full.is_none() && sections.is_empty(); | 410 | let empty = full.is_none() && sections.is_empty(); |
| 412 | let back = full.as_ref().map(|_| ni::t(lang, K::BackToNeedsYou)); | 411 | let back = full.as_ref().map(|_| ni::t(lang, K::BackToNeedsYou)); |
| 413 | let heading = ni::t(lang, K::NeedsYou); | 412 | let heading = ni::t(lang, K::NeedsYou); |
| 413 | + let sub = vec![SubPart::text(s(lang, "Waiting on you", "Senden beklenenler"))]; | ||
| 414 | Ok(view! { | 414 | Ok(view! { |
| 415 | shell(title: heading, viewer: Some(&viewer), | 415 | shell(title: heading, viewer: Some(&viewer), |
| 416 | - <section data-live=(live.as_str())> | 416 | + head(title: heading, sub: sub, live: Some(live.as_str()), |
| 417 | - <h1 class="sr-only">(heading)</h1> | ||
| 418 | if let Some(back) = back { | 417 | if let Some(back) = back { |
| 419 | - <div class="acts"> | 418 | + <a class="act" href="/needs-you">(back)</a> |
| 420 | - <a class="act" href="/needs-you">(back)</a> | ||
| 421 | - </div> | ||
| 422 | } | 419 | } |
| 423 | - </section> | 420 | + ) |
| 424 | - if empty { | 421 | + <div class="sheet"> |
| 425 | - <p class="state">(ni::t(lang, K::AllClear))</p> | 422 | + if empty { |
| 426 | - } | 423 | + <p class="state">(ni::t(lang, K::AllClear))</p> |
| 427 | - if grid { | 424 | + } |
| 428 | - <div class="needs-page"> | 425 | + for section in sections.into_iter() { |
| 429 | - for section in sections.into_iter() { | ||
| 430 | - need_section(lang: lang, section: section) | ||
| 431 | - } | ||
| 432 | - </div> | ||
| 433 | - } | ||
| 434 | - if let Some(section) = full { | ||
| 435 | - <div class="needs-page"> | ||
| 436 | need_section(lang: lang, section: section) | 426 | need_section(lang: lang, section: section) |
| 437 | - </div> | 427 | + } |
| 438 | - } | 428 | + if let Some(section) = full { |
| 429 | + need_section(lang: lang, section: section) | ||
| 430 | + } | ||
| 431 | + </div> | ||
| 439 | ) | 432 | ) |
| 440 | }) | 433 | }) |
| 441 | } | 434 | } |
crates/forge-web/src/pages/new_repo.rsmodified+62 -60
| @@ -23,7 +23,7 @@ use crate::i18n::{self, Key, Lang}; | |||
| 23 | use crate::pages::org_ctx::may_create_repo_in; | 23 | use crate::pages::org_ctx::may_create_repo_in; |
| 24 | use crate::pages::repo_mirrors::{Checked, check_form_in, redacted_url}; | 24 | use crate::pages::repo_mirrors::{Checked, check_form_in, redacted_url}; |
| 25 | use crate::state::AppState; | 25 | use crate::state::AppState; |
| 26 | -use crate::views::parts::reveal; | 26 | +use crate::views::parts::{head, reveal}; |
| 27 | use crate::views::{alert, csrf_field, shell, user_facing_message}; | 27 | use crate::views::{alert, csrf_field, shell, user_facing_message}; |
| 28 | 28 | ||
| 29 | const MAX_DESCRIPTION_CHARS: usize = 350; | 29 | const MAX_DESCRIPTION_CHARS: usize = 350; |
| @@ -234,74 +234,76 @@ async fn new_repo_form( | |||
| 234 | let draft_mirror_username = draft.mirror_username; | 234 | let draft_mirror_username = draft.mirror_username; |
| 235 | let draft_mirror_interval = draft.mirror_interval; | 235 | let draft_mirror_interval = draft.mirror_interval; |
| 236 | Ok(view! { | 236 | Ok(view! { |
| 237 | - <h1 class="sr-only">(i18n::t(lang, Key::NewRepository))</h1> | 237 | + head(title: i18n::t(lang, Key::NewRepository)) |
| 238 | crate::pages::import::newrepo_tabs(lang: lang, active: "create") | 238 | crate::pages::import::newrepo_tabs(lang: lang, active: "create") |
| 239 | - <form method="post" action="/new" class="fields"> | 239 | + <div class="sheet fit"> |
| 240 | - if let Some(message) = error { | 240 | + <form method="post" action="/new" class="fields"> |
| 241 | - alert(message: message.as_str()) | 241 | + if let Some(message) = error { |
| 242 | - } | 242 | + alert(message: message.as_str()) |
| 243 | - csrf_field(token: csrf) | 243 | + } |
| 244 | - <div class="field"> | 244 | + csrf_field(token: csrf) |
| 245 | - <label for="new-owner">(g::t(lang, K::NewOwner))</label> | ||
| 246 | - <select id="new-owner" name="owner"> | ||
| 247 | - for name in owners.iter() { | ||
| 248 | - <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> | ||
| 249 | - } | ||
| 250 | - </select> | ||
| 251 | - </div> | ||
| 252 | - <div class="field"> | ||
| 253 | - <label for="new-name">(g::t(lang, K::RepoName))</label> | ||
| 254 | - <input id="new-name" type="text" name="name" value=(draft.name) required=(true) maxlength="64" autocomplete="off" spellcheck="false"> | ||
| 255 | - </div> | ||
| 256 | - <div class="field"> | ||
| 257 | - <label for="new-description">(g::t(lang, K::DescriptionOptional))</label> | ||
| 258 | - <textarea id="new-description" name="description" rows="3" maxlength="350">(draft.description)</textarea> | ||
| 259 | - </div> | ||
| 260 | - <div class="field"> | ||
| 261 | - <label for="new-branch">(g::t(lang, K::DefaultBranch))</label> | ||
| 262 | - <input id="new-branch" type="text" name="default_branch" value=(branch) maxlength="255" autocomplete="off" spellcheck="false"> | ||
| 263 | - </div> | ||
| 264 | - <label class="switch"> | ||
| 265 | - <input type="checkbox" name="default_labels" value="on" checked=(default_labels)> | ||
| 266 | - <span>(g::t(lang, K::AddDefaultLabels))</span> | ||
| 267 | - </label> | ||
| 268 | - crate::pages::import::visibility_pick(lang: lang, private: private) | ||
| 269 | - <label class="switch"> | ||
| 270 | - <input type="checkbox" name="add_readme" value="on" checked=(add_readme)> | ||
| 271 | - <span>(g::t(lang, K::ReadmeLabel))</span> | ||
| 272 | - </label> | ||
| 273 | - <p class="hint">(g::t(lang, K::ReadmeHelp))</p> | ||
| 274 | - <div class="field"> | ||
| 275 | - <label for="new-license">(g::t(lang, K::LicenseLabel))</label> | ||
| 276 | - <select id="new-license" name="license"> | ||
| 277 | - <option value="" selected=(draft_license.is_empty())>(g::t(lang, K::LicenseNone))</option> | ||
| 278 | - for (id, label, _) in LICENSES.iter() { | ||
| 279 | - <option value=(*id) selected=(*id == draft_license.as_str())>(*label)</option> | ||
| 280 | - } | ||
| 281 | - </select> | ||
| 282 | - <p class="hint">(g::t(lang, K::LicenseHelp))</p> | ||
| 283 | - </div> | ||
| 284 | - reveal(label: g::t(lang, K::MirrorLegend), id: Some("new-mirror"), open: mirror_open, | ||
| 285 | - <p class="hint">(g::t(lang, K::MirrorIntro))</p> | ||
| 286 | <div class="field"> | 245 | <div class="field"> |
| 287 | - <label for="new-mirror-url">(g::t(lang, K::SourceUrl))</label> | 246 | + <label for="new-owner">(g::t(lang, K::NewOwner))</label> |
| 288 | - <input id="new-mirror-url" type="url" name="mirror_url" value=(draft_mirror_url.as_str()) autocomplete="off" spellcheck="false" maxlength="2048"> | 247 | + <select id="new-owner" name="owner"> |
| 248 | + for name in owners.iter() { | ||
| 249 | + <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> | ||
| 250 | + } | ||
| 251 | + </select> | ||
| 289 | </div> | 252 | </div> |
| 290 | <div class="field"> | 253 | <div class="field"> |
| 291 | - <label for="new-mirror-username">(g::t(lang, K::UsernameOptional))</label> | 254 | + <label for="new-name">(g::t(lang, K::RepoName))</label> |
| 292 | - <input id="new-mirror-username" type="text" name="mirror_username" value=(draft_mirror_username.as_str()) autocomplete="off" maxlength="255"> | 255 | + <input id="new-name" type="text" name="name" value=(draft.name) required=(true) maxlength="64" autocomplete="off" spellcheck="false"> |
| 293 | </div> | 256 | </div> |
| 294 | <div class="field"> | 257 | <div class="field"> |
| 295 | - <label for="new-mirror-secret">(g::t(lang, K::PasswordOrToken))</label> | 258 | + <label for="new-description">(g::t(lang, K::DescriptionOptional))</label> |
| 296 | - <input id="new-mirror-secret" type="password" name="mirror_secret" autocomplete="new-password" maxlength="1024"> | 259 | + <textarea id="new-description" name="description" rows="3" maxlength="350">(draft.description)</textarea> |
| 297 | </div> | 260 | </div> |
| 298 | <div class="field"> | 261 | <div class="field"> |
| 299 | - <label for="new-mirror-interval">(g::t(lang, K::SyncInterval))</label> | 262 | + <label for="new-branch">(g::t(lang, K::DefaultBranch))</label> |
| 300 | - <input id="new-mirror-interval" type="number" name="mirror_interval" value=(draft_mirror_interval.as_str()) min="0" max="525600" step="1"> | 263 | + <input id="new-branch" type="text" name="default_branch" value=(branch) maxlength="255" autocomplete="off" spellcheck="false"> |
| 301 | </div> | 264 | </div> |
| 302 | - ) | 265 | + <label class="switch"> |
| 303 | - <button type="submit" class="primary">(g::t(lang, K::CreateRepository))</button> | 266 | + <input type="checkbox" name="default_labels" value="on" checked=(default_labels)> |
| 304 | - </form> | 267 | + <span>(g::t(lang, K::AddDefaultLabels))</span> |
| 268 | + </label> | ||
| 269 | + crate::pages::import::visibility_pick(lang: lang, private: private) | ||
| 270 | + <label class="switch"> | ||
| 271 | + <input type="checkbox" name="add_readme" value="on" checked=(add_readme)> | ||
| 272 | + <span>(g::t(lang, K::ReadmeLabel))</span> | ||
| 273 | + </label> | ||
| 274 | + <p class="hint">(g::t(lang, K::ReadmeHelp))</p> | ||
| 275 | + <div class="field"> | ||
| 276 | + <label for="new-license">(g::t(lang, K::LicenseLabel))</label> | ||
| 277 | + <select id="new-license" name="license"> | ||
| 278 | + <option value="" selected=(draft_license.is_empty())>(g::t(lang, K::LicenseNone))</option> | ||
| 279 | + for (id, label, _) in LICENSES.iter() { | ||
| 280 | + <option value=(*id) selected=(*id == draft_license.as_str())>(*label)</option> | ||
| 281 | + } | ||
| 282 | + </select> | ||
| 283 | + <p class="hint">(g::t(lang, K::LicenseHelp))</p> | ||
| 284 | + </div> | ||
| 285 | + reveal(label: g::t(lang, K::MirrorLegend), id: Some("new-mirror"), open: mirror_open, | ||
| 286 | + <p class="hint">(g::t(lang, K::MirrorIntro))</p> | ||
| 287 | + <div class="field"> | ||
| 288 | + <label for="new-mirror-url">(g::t(lang, K::SourceUrl))</label> | ||
| 289 | + <input id="new-mirror-url" type="url" name="mirror_url" value=(draft_mirror_url.as_str()) autocomplete="off" spellcheck="false" maxlength="2048"> | ||
| 290 | + </div> | ||
| 291 | + <div class="field"> | ||
| 292 | + <label for="new-mirror-username">(g::t(lang, K::UsernameOptional))</label> | ||
| 293 | + <input id="new-mirror-username" type="text" name="mirror_username" value=(draft_mirror_username.as_str()) autocomplete="off" maxlength="255"> | ||
| 294 | + </div> | ||
| 295 | + <div class="field"> | ||
| 296 | + <label for="new-mirror-secret">(g::t(lang, K::PasswordOrToken))</label> | ||
| 297 | + <input id="new-mirror-secret" type="password" name="mirror_secret" autocomplete="new-password" maxlength="1024"> | ||
| 298 | + </div> | ||
| 299 | + <div class="field"> | ||
| 300 | + <label for="new-mirror-interval">(g::t(lang, K::SyncInterval))</label> | ||
| 301 | + <input id="new-mirror-interval" type="number" name="mirror_interval" value=(draft_mirror_interval.as_str()) min="0" max="525600" step="1"> | ||
| 302 | + </div> | ||
| 303 | + ) | ||
| 304 | + <button type="submit" class="primary">(g::t(lang, K::CreateRepository))</button> | ||
| 305 | + </form> | ||
| 306 | + </div> | ||
| 305 | }) | 307 | }) |
| 306 | } | 308 | } |
| 307 | 309 | ||
crates/forge-web/src/pages/not_found_page.rsmodified+72 -13
| @@ -1,18 +1,21 @@ | |||
| 1 | -//! The styled 404 page. Topcoat answers a `not_found()` error with a bare text body, so this layer | 1 | +//! The styled 404 and 403 pages. Topcoat answers `not_found()` and `forbidden()` with a bare text |
| 2 | -//! swaps that body for the regular shell plus a short message, for browser requests only. | 2 | +//! body, so this layer swaps that body for the regular shell plus a short message, for browser |
| 3 | +//! requests only. A signed-out visitor refused a page is sent to log in first, as every page that | ||
| 4 | +//! needs an account does. | ||
| 3 | 5 | ||
| 4 | use http::header::ACCEPT; | 6 | use http::header::ACCEPT; |
| 5 | use topcoat::Result; | 7 | use topcoat::Result; |
| 6 | use topcoat::context::Cx; | 8 | use topcoat::context::Cx; |
| 7 | -use topcoat::router::error::{NotFoundError, rewrite}; | 9 | +use topcoat::router::error::{ForbiddenError, NotFoundError, rewrite}; |
| 8 | use topcoat::router::page; | 10 | use topcoat::router::page; |
| 9 | use topcoat::router::request::headers; | 11 | use topcoat::router::request::headers; |
| 10 | use topcoat::router::response::Response; | 12 | use topcoat::router::response::Response; |
| 11 | use topcoat::router::{Body, Layer, LayerFuture, Method, Next, Path, StatusCode}; | 13 | use topcoat::router::{Body, Layer, LayerFuture, Method, Next, Path, StatusCode}; |
| 12 | use topcoat::view::{View, component, view}; | 14 | use topcoat::view::{View, component, view}; |
| 13 | 15 | ||
| 14 | -use crate::auth::current_user; | 16 | +use crate::auth::{current_user, percent_encode}; |
| 15 | use crate::i18n::{self, Lang}; | 17 | use crate::i18n::{self, Lang}; |
| 18 | +use crate::views::parts::{SubPart, head}; | ||
| 16 | use crate::views::shell; | 19 | use crate::views::shell; |
| 17 | 20 | ||
| 18 | pub struct NotFoundLayer; | 21 | pub struct NotFoundLayer; |
| @@ -46,30 +49,86 @@ fn texts(lang: Lang) -> (&'static str, &'static str, &'static str) { | |||
| 46 | async fn not_found_body(lang: Lang) -> Result<impl View> { | 49 | async fn not_found_body(lang: Lang) -> Result<impl View> { |
| 47 | let (title, hint, back) = texts(lang); | 50 | let (title, hint, back) = texts(lang); |
| 48 | Ok(view! { | 51 | Ok(view! { |
| 49 | - <section class="not-found"> | 52 | + head(title: title, sub: vec![SubPart::mono("404")]) |
| 50 | - <p class="not-found-code">"404"</p> | 53 | + <p class="state">(hint) " " <a class="act" href="/">(back)</a></p> |
| 51 | - <h1>(title)</h1> | ||
| 52 | - <p class="state">(hint)</p> | ||
| 53 | - <div class="acts"> | ||
| 54 | - <a class="act" href="/">(back)</a> | ||
| 55 | - </div> | ||
| 56 | - </section> | ||
| 57 | }) | 54 | }) |
| 58 | } | 55 | } |
| 59 | 56 | ||
| 60 | async fn styled_not_found(cx: &Cx, body: Body, next: Next<'_>) -> Result<Response> { | 57 | async fn styled_not_found(cx: &Cx, body: Body, next: Next<'_>) -> Result<Response> { |
| 58 | + let is_get = *topcoat::router::request::method(cx) == Method::GET; | ||
| 61 | let result = next.run(cx, body).await; | 59 | let result = next.run(cx, body).await; |
| 62 | let is_not_found = matches!(&result, Err(e) if e.downcast_ref::<NotFoundError>().is_some()); | 60 | let is_not_found = matches!(&result, Err(e) if e.downcast_ref::<NotFoundError>().is_some()); |
| 61 | + let is_forbidden = matches!(&result, Err(e) if e.downcast_ref::<ForbiddenError>().is_some()); | ||
| 63 | let wants_html = headers(cx) | 62 | let wants_html = headers(cx) |
| 64 | .get(ACCEPT) | 63 | .get(ACCEPT) |
| 65 | .and_then(|v| v.to_str().ok()) | 64 | .and_then(|v| v.to_str().ok()) |
| 66 | .is_some_and(|v| v.contains("text/html")); | 65 | .is_some_and(|v| v.contains("text/html")); |
| 67 | - if !is_not_found || !wants_html { | 66 | + if !wants_html || !(is_not_found || is_forbidden) { |
| 68 | return result; | 67 | return result; |
| 69 | } | 68 | } |
| 69 | + if is_forbidden { | ||
| 70 | + // The cookies are not readable out here, so the page itself decides whether the visitor | ||
| 71 | + // must log in first; a refused GET hands it the address to come back to. | ||
| 72 | + let target = if is_get { | ||
| 73 | + let path = topcoat::router::request::uri(cx) | ||
| 74 | + .path_and_query() | ||
| 75 | + .map_or("/", |p| p.as_str()); | ||
| 76 | + format!("{FORBIDDEN_PATH}?next={}", percent_encode(path)) | ||
| 77 | + } else { | ||
| 78 | + FORBIDDEN_PATH.to_owned() | ||
| 79 | + }; | ||
| 80 | + return Err(rewrite(target, Body::empty()).method(Method::GET).into()); | ||
| 81 | + } | ||
| 70 | Err(rewrite(PATH, Body::empty()).method(Method::GET).into()) | 82 | Err(rewrite(PATH, Body::empty()).method(Method::GET).into()) |
| 71 | } | 83 | } |
| 72 | 84 | ||
| 85 | +/// Where the layer sends a browser's 403. The page answers with status 403 itself. | ||
| 86 | +const FORBIDDEN_PATH: &str = "/-/forbidden"; | ||
| 87 | + | ||
| 88 | +fn forbidden_texts(lang: Lang) -> (&'static str, &'static str, &'static str) { | ||
| 89 | + match lang { | ||
| 90 | + Lang::En => ( | ||
| 91 | + "Not allowed", | ||
| 92 | + "Your account cannot do this here. Ask an owner for access, or go back to the start.", | ||
| 93 | + "Back to the start", | ||
| 94 | + ), | ||
| 95 | + Lang::Tr => ( | ||
| 96 | + "İzin yok", | ||
| 97 | + "Hesabınız burada bunu yapamaz. Bir sahibinden erişim isteyin ya da başa dönün.", | ||
| 98 | + "Başa dön", | ||
| 99 | + ), | ||
| 100 | + } | ||
| 101 | +} | ||
| 102 | + | ||
| 103 | +#[component] | ||
| 104 | +async fn forbidden_body(lang: Lang) -> Result<impl View> { | ||
| 105 | + let (title, hint, back) = forbidden_texts(lang); | ||
| 106 | + Ok(view! { | ||
| 107 | + head(title: title, sub: vec![SubPart::mono("403")]) | ||
| 108 | + <p class="state">(hint) " " <a class="act" href="/">(back)</a></p> | ||
| 109 | + }) | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | +#[page("/-/forbidden")] | ||
| 113 | +async fn forbidden_page(cx: &Cx) -> Result<impl View> { | ||
| 114 | + let viewer = current_user(cx).await?; | ||
| 115 | + if viewer.is_none() { | ||
| 116 | + let next = topcoat::router::request::uri(cx) | ||
| 117 | + .query() | ||
| 118 | + .and_then(|q| q.split('&').find_map(|pair| pair.strip_prefix("next="))) | ||
| 119 | + .filter(|next| next.starts_with('/') && !next.starts_with("//")); | ||
| 120 | + if let Some(next) = next { | ||
| 121 | + return Err(topcoat::router::error::see_other(format!("/login?next={next}")).into()); | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + let lang = i18n::lang(cx, viewer.as_ref().map(|(user, _)| user)); | ||
| 125 | + let title = forbidden_texts(lang).0; | ||
| 126 | + Ok(view! { | ||
| 127 | + (StatusCode::FORBIDDEN) | ||
| 128 | + shell(title: title, viewer: viewer.as_ref(), forbidden_body(lang: lang)) | ||
| 129 | + }) | ||
| 130 | +} | ||
| 131 | + | ||
| 73 | /// Where the layer sends a browser's 404. The page answers with status 404 itself. | 132 | /// Where the layer sends a browser's 404. The page answers with status 404 itself. |
| 74 | const PATH: &str = "/-/not-found"; | 133 | const PATH: &str = "/-/not-found"; |
| 75 | 134 | ||
crates/forge-web/src/pages/notifications.rsmodified+62 -39
| @@ -35,7 +35,7 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo}; | |||
| 35 | use crate::pages::repo_transfer::transfer_list_for; | 35 | use crate::pages::repo_transfer::transfer_list_for; |
| 36 | use crate::pages::star::return_path; | 36 | use crate::pages::star::return_path; |
| 37 | use crate::state::AppState; | 37 | use crate::state::AppState; |
| 38 | -use crate::views::parts::post_act; | 38 | +use crate::views::parts::{RailItem, head, post_act, rail}; |
| 39 | use crate::views::{csrf_field, display_name, iso_time, now_unix, relative_time, repo_href, shell}; | 39 | use crate::views::{csrf_field, display_name, iso_time, now_unix, relative_time, repo_href, shell}; |
| 40 | 40 | ||
| 41 | /// Rows per inbox page. Older rows come behind the older link, so one page stays short. | 41 | /// Rows per inbox page. Older rows come behind the older link, so one page stays short. |
| @@ -1099,7 +1099,8 @@ fn back(cx: &Cx) -> String { | |||
| 1099 | return_path(cx).unwrap_or_else(|| "/notifications".to_owned()) | 1099 | return_path(cx).unwrap_or_else(|| "/notifications".to_owned()) |
| 1100 | } | 1100 | } |
| 1101 | 1101 | ||
| 1102 | -/// The inbox body: heading, mark-all button, tabs, the repo groups and the older-rows link. | 1102 | +/// The inbox page: the head with Mark all read, the filter rail (Unread, All, Reviews), then one |
| 1103 | +/// sheet holding the transfers, the repo groups and the older-rows link. | ||
| 1103 | #[component] | 1104 | #[component] |
| 1104 | async fn inbox_list( | 1105 | async fn inbox_list( |
| 1105 | lang: Lang, | 1106 | lang: Lang, |
| @@ -1117,40 +1118,54 @@ async fn inbox_list( | |||
| 1117 | } else { | 1118 | } else { |
| 1118 | g::t(lang, K::NoUnreadNotifications) | 1119 | g::t(lang, K::NoUnreadNotifications) |
| 1119 | }; | 1120 | }; |
| 1120 | - let unread_current = if all { None } else { Some("page") }; | 1121 | + let filters = vec![ |
| 1121 | - let all_current = if all { Some("page") } else { None }; | 1122 | + RailItem { |
| 1122 | - let unread_text = format!("{} ({unread_count})", g::t(lang, K::Unread)); | 1123 | + name: g::t(lang, K::Unread).to_owned(), |
| 1124 | + val: unread_count.to_string(), | ||
| 1125 | + href: "/notifications".to_owned(), | ||
| 1126 | + current: !all, | ||
| 1127 | + }, | ||
| 1128 | + RailItem { | ||
| 1129 | + name: g::t(lang, K::AllTab).to_owned(), | ||
| 1130 | + val: String::new(), | ||
| 1131 | + href: "/notifications?all=1".to_owned(), | ||
| 1132 | + current: all, | ||
| 1133 | + }, | ||
| 1134 | + RailItem { | ||
| 1135 | + name: crate::i18n::authoring::t(lang, crate::i18n::authoring::K::ReviewRequestsTab) | ||
| 1136 | + .to_owned(), | ||
| 1137 | + val: String::new(), | ||
| 1138 | + href: "/review-requests".to_owned(), | ||
| 1139 | + current: false, | ||
| 1140 | + }, | ||
| 1141 | + ]; | ||
| 1123 | Ok(view! { | 1142 | Ok(view! { |
| 1124 | - <div data-live=(live.as_str())> | 1143 | + head(title: i18n::t(lang, Key::Notifications), |
| 1125 | - <h1 class="sr-only">(i18n::t(lang, Key::Notifications))</h1> | ||
| 1126 | - <nav class="tabs" aria-label=(g::t(lang, K::NotificationFilter))> | ||
| 1127 | - <a href="/notifications" aria-current=(unread_current)>(unread_text.as_str())</a> | ||
| 1128 | - <a href="/notifications?all=1" aria-current=(all_current)>(g::t(lang, K::AllTab))</a> | ||
| 1129 | - <a href="/review-requests">(crate::i18n::authoring::t(lang, crate::i18n::authoring::K::ReviewRequestsTab))</a> | ||
| 1130 | - </nav> | ||
| 1131 | if !empty { | 1144 | if !empty { |
| 1132 | - <div class="acts"> | 1145 | + <form method="post" action="/notifications/mark_all_read" class="act-form"> |
| 1133 | - post_act(label: g::t(lang, K::MarkAllAsRead), action: "/notifications/mark_all_read", csrf: csrf.as_str()) | 1146 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1134 | - </div> | 1147 | + <button type="submit" class="button">(g::t(lang, K::MarkAllAsRead))</button> |
| 1148 | + </form> | ||
| 1135 | } | 1149 | } |
| 1136 | - transfer_list_for(lang: lang, transfers: transfers, csrf: csrf.clone()) | 1150 | + ) |
| 1137 | - if empty { | 1151 | + <div class="work"> |
| 1138 | - <section class="sec"> | 1152 | + rail(label: g::t(lang, K::NotificationFilter), items: filters) |
| 1153 | + <div class="sheet" data-live=(live.as_str())> | ||
| 1154 | + transfer_list_for(lang: lang, transfers: transfers, csrf: csrf.clone()) | ||
| 1155 | + if empty { | ||
| 1139 | <p class="state">(empty_text)</p> | 1156 | <p class="state">(empty_text)</p> |
| 1140 | if !all { | 1157 | if !all { |
| 1141 | <div class="acts"> | 1158 | <div class="acts"> |
| 1142 | <a class="act" href="/notifications?all=1">(g::t(lang, K::ViewAllNotifications))</a> | 1159 | <a class="act" href="/notifications?all=1">(g::t(lang, K::ViewAllNotifications))</a> |
| 1143 | </div> | 1160 | </div> |
| 1144 | } | 1161 | } |
| 1145 | - </section> | 1162 | + } |
| 1146 | - } | 1163 | + for group in groups.into_iter() { |
| 1147 | - for group in groups.into_iter() { | 1164 | + <section class="sec"> |
| 1148 | - <section class="sec"> | 1165 | + <h2><a href=(group.href.as_str())>(group.heading.as_str())</a></h2> |
| 1149 | - <h2><a href=(group.href.as_str())>(group.heading.as_str())</a></h2> | 1166 | + <div class="acts"> |
| 1150 | - <div class="acts"> | 1167 | + post_act(label: g::t(lang, K::MarkAllRead), action: group.mark_action.as_str(), csrf: csrf.as_str()) |
| 1151 | - post_act(label: g::t(lang, K::MarkAllRead), action: group.mark_action.as_str(), csrf: csrf.as_str()) | 1168 | + </div> |
| 1152 | - </div> | ||
| 1153 | - <div class="notif-rows"> | ||
| 1154 | for row in group.rows.into_iter() { | 1169 | for row in group.rows.into_iter() { |
| 1155 | <div class=(row.item_class) data-kb-row=""> | 1170 | <div class=(row.item_class) data-kb-row=""> |
| 1156 | <a class="line" href=(row.open_href.as_str())> | 1171 | <a class="line" href=(row.open_href.as_str())> |
| @@ -1166,14 +1181,14 @@ async fn inbox_list( | |||
| 1166 | } | 1181 | } |
| 1167 | </div> | 1182 | </div> |
| 1168 | } | 1183 | } |
| 1169 | - </div> | 1184 | + </section> |
| 1170 | - </section> | 1185 | + } |
| 1171 | - } | 1186 | + if let Some(href) = more { |
| 1172 | - if let Some(href) = more { | 1187 | + <p class="state"> |
| 1173 | - <div class="acts"> | 1188 | + <a class="act" href=(href.as_str())>(g::t(lang, K::Older))</a> |
| 1174 | - <a class="act" href=(href.as_str())>(g::t(lang, K::Older))</a> | 1189 | + </p> |
| 1175 | - </div> | 1190 | + } |
| 1176 | - } | 1191 | + </div> |
| 1177 | </div> | 1192 | </div> |
| 1178 | }) | 1193 | }) |
| 1179 | } | 1194 | } |
| @@ -1194,9 +1209,9 @@ pub(crate) async fn notify_box( | |||
| 1194 | (g::t(lang, K::Subscribe), "subscribe") | 1209 | (g::t(lang, K::Subscribe), "subscribe") |
| 1195 | }; | 1210 | }; |
| 1196 | Ok(view! { | 1211 | Ok(view! { |
| 1197 | - <section class="sec"> | 1212 | + <section class="sec meta"> |
| 1198 | <h2>(i18n::t(lang, Key::Notifications))</h2> | 1213 | <h2>(i18n::t(lang, Key::Notifications))</h2> |
| 1199 | - <p class="state">(reason.as_str())</p> | 1214 | + <p class="hint">(reason.as_str())</p> |
| 1200 | <div class="acts"> | 1215 | <div class="acts"> |
| 1201 | post_act(label: label, action: action.as_str(), csrf: csrf.as_str(), fields: vec![("action".to_owned(), value_text.to_owned())]) | 1216 | post_act(label: label, action: action.as_str(), csrf: csrf.as_str(), fields: vec![("action".to_owned(), value_text.to_owned())]) |
| 1202 | </div> | 1217 | </div> |
| @@ -1270,7 +1285,7 @@ pub(crate) async fn watch_form( | |||
| 1270 | </li> | 1285 | </li> |
| 1271 | </ul> | 1286 | </ul> |
| 1272 | </details> | 1287 | </details> |
| 1273 | - <span class="muted small">(count.as_str())</span> | 1288 | + <span class="hint">(count.as_str())</span> |
| 1274 | </div> | 1289 | </div> |
| 1275 | }) | 1290 | }) |
| 1276 | } | 1291 | } |
| @@ -1289,6 +1304,7 @@ mod tests { | |||
| 1289 | struct Site { | 1304 | struct Site { |
| 1290 | router: Router, | 1305 | router: Router, |
| 1291 | store: Store, | 1306 | store: Store, |
| 1307 | + git: std::sync::Arc<forge_git::GitEnv>, | ||
| 1292 | _dir: tempfile::TempDir, | 1308 | _dir: tempfile::TempDir, |
| 1293 | } | 1309 | } |
| 1294 | 1310 | ||
| @@ -1302,10 +1318,12 @@ mod tests { | |||
| 1302 | let dir = tempfile::tempdir().expect("tempdir"); | 1318 | let dir = tempfile::tempdir().expect("tempdir"); |
| 1303 | let state = crate::test_support::test_state(dir.path()).await; | 1319 | let state = crate::test_support::test_state(dir.path()).await; |
| 1304 | let store = state.store.clone(); | 1320 | let store = state.store.clone(); |
| 1321 | + let git = state.git.clone(); | ||
| 1305 | let router = crate::test_support::app_router(state); | 1322 | let router = crate::test_support::app_router(state); |
| 1306 | Site { | 1323 | Site { |
| 1307 | router, | 1324 | router, |
| 1308 | store, | 1325 | store, |
| 1326 | + git, | ||
| 1309 | _dir: dir, | 1327 | _dir: dir, |
| 1310 | } | 1328 | } |
| 1311 | } | 1329 | } |
| @@ -1632,7 +1650,12 @@ mod tests { | |||
| 1632 | WatchLevel::Watching | 1650 | WatchLevel::Watching |
| 1633 | ); | 1651 | ); |
| 1634 | 1652 | ||
| 1635 | - let header = get(&site, "/tahinli/demo/issues/1", Some(&cookie)).await; | 1653 | + // The watch menu sits in the repo head on the code tab, which reads the repository. |
| 1654 | + let bare = forge_git::repo::repo_path(&site.git.data_dir, &w.repo.id).expect("repo path"); | ||
| 1655 | + forge_git::repo::init_bare(&site.git, &bare, "main") | ||
| 1656 | + .await | ||
| 1657 | + .expect("init bare"); | ||
| 1658 | + let header = get(&site, "/tahinli/demo", Some(&cookie)).await; | ||
| 1636 | assert!(header.body.contains("action=\"/tahinli/demo/watch\"")); | 1659 | assert!(header.body.contains("action=\"/tahinli/demo/watch\"")); |
| 1637 | assert!(header.body.contains("<details class=\"menu watch-menu\">")); | 1660 | assert!(header.body.contains("<details class=\"menu watch-menu\">")); |
| 1638 | assert!(!header.body.contains("<select")); | 1661 | assert!(!header.body.contains("<select")); |
crates/forge-web/src/pages/org_members.rsmodified+74 -73
| @@ -19,12 +19,12 @@ use crate::audit::{self, Actor, Target}; | |||
| 19 | use crate::i18n::orgs::{self as g, K}; | 19 | use crate::i18n::orgs::{self as g, K}; |
| 20 | use crate::i18n::{self, Lang}; | 20 | use crate::i18n::{self, Lang}; |
| 21 | use crate::pages::org_ctx::{ | 21 | use crate::pages::org_ctx::{ |
| 22 | - load_org, member_role_word, notice_href, org_head, org_notice, org_tab_counts, org_tabs, | 22 | + load_org, member_role_word, notice_href, org_notice, org_tab_counts, org_tabs, |
| 23 | parse_member_role, require_form_csrf, require_member, require_owner, take_notice, | 23 | parse_member_role, require_form_csrf, require_member, require_owner, take_notice, |
| 24 | }; | 24 | }; |
| 25 | use crate::pages::passkeys; | 25 | use crate::pages::passkeys; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| 27 | -use crate::views::parts::{confirm_act, reveal}; | 27 | +use crate::views::parts::{SubPart, confirm_act, head, reveal}; |
| 28 | use crate::views::{avatar_url, display_name, shell}; | 28 | use crate::views::{avatar_url, display_name, shell}; |
| 29 | 29 | ||
| 30 | path_param!(org); | 30 | path_param!(org); |
| @@ -86,81 +86,82 @@ async fn members_body( | |||
| 86 | let role_action = format!("{base}/members/role"); | 86 | let role_action = format!("{base}/members/role"); |
| 87 | let remove_action = format!("{base}/members/remove"); | 87 | let remove_action = format!("{base}/members/remove"); |
| 88 | let add_action = format!("{base}/members/add"); | 88 | let add_action = format!("{base}/members/add"); |
| 89 | + let sub = if description.is_empty() { | ||
| 90 | + Vec::new() | ||
| 91 | + } else { | ||
| 92 | + vec![SubPart::text(description)] | ||
| 93 | + }; | ||
| 89 | Ok(view! { | 94 | Ok(view! { |
| 90 | - <div data-live=(live.as_str())> | 95 | + head(title: name.as_str(), sub: sub, live: Some(live.as_str())) |
| 91 | - org_tabs(lang: lang, name: name.clone(), current: "members".to_owned(), owner: owner, repo_count: repo_count, package_count: package_count) | 96 | + org_tabs(lang: lang, name: name.clone(), current: "members".to_owned(), owner: owner, repo_count: repo_count, package_count: package_count) |
| 92 | - org_head(name: name, description: description) | 97 | + org_notice(notice: notice) |
| 93 | - org_notice(notice: notice) | 98 | + <div class="sheet"> |
| 94 | - <section class="sec"> | 99 | + <div class="sheet-tools"> |
| 95 | - <h2>(g::t(lang, K::Members))</h2> | 100 | + <strong>(g::t(lang, K::Members))</strong> |
| 96 | if owner { | 101 | if owner { |
| 97 | - <p class="hint">(g::t(lang, K::OwnersHelp))</p> | 102 | + reveal(label: g::t(lang, K::AddMemberButton), id: Some("add-member"), |
| 98 | - <div class="acts"> | 103 | + <form method="post" action=(add_action.as_str()) class="fields"> |
| 99 | - reveal(label: g::t(lang, K::AddMemberButton), id: Some("add-member"), | 104 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 100 | - <form method="post" action=(add_action.as_str()) class="fields"> | 105 | + <div class="field"> |
| 101 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 106 | + <label for="add-member-username">(g::t(lang, K::Username))</label> |
| 102 | - <div class="field"> | 107 | + <input id="add-member-username" type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 103 | - <label for="add-member-username">(g::t(lang, K::Username))</label> | 108 | + </div> |
| 104 | - <input id="add-member-username" type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> | 109 | + <div class="field"> |
| 105 | - </div> | 110 | + <label for="add-member-role">(g::t(lang, K::Role))</label> |
| 106 | - <div class="field"> | 111 | + <select id="add-member-role" name="role"> |
| 107 | - <label for="add-member-role">(g::t(lang, K::Role))</label> | 112 | + <option value="member" selected=(true)>(g::t(lang, K::RoleMember))</option> |
| 108 | - <select id="add-member-role" name="role"> | 113 | + <option value="owner">(g::t(lang, K::RoleOwner))</option> |
| 109 | - <option value="member" selected=(true)>(g::t(lang, K::RoleMember))</option> | 114 | + </select> |
| 110 | - <option value="owner">(g::t(lang, K::RoleOwner))</option> | 115 | + </div> |
| 111 | - </select> | 116 | + <button type="submit" class="primary">(g::t(lang, K::AddMemberButton))</button> |
| 112 | - </div> | 117 | + </form> |
| 113 | - <button type="submit" class="primary">(g::t(lang, K::AddMemberButton))</button> | 118 | + ) |
| 114 | - </form> | ||
| 115 | - ) | ||
| 116 | - </div> | ||
| 117 | } | 119 | } |
| 118 | - <div> | 120 | + </div> |
| 119 | - for row in rows.iter() { | 121 | + if owner { |
| 120 | - if owner || row.is_self { | 122 | + <p class="hint">(g::t(lang, K::OwnersHelp))</p> |
| 121 | - <details class="row-open"> | 123 | + } |
| 122 | - <summary class="line" data-kb-row=""> | 124 | + for row in rows.iter() { |
| 123 | - <span class="name org-who"> | 125 | + if owner || row.is_self { |
| 124 | - <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> | 126 | + <details class="row-open"> |
| 125 | - <span>(row.label.as_str())</span> | 127 | + <summary class="line" data-kb-row=""> |
| 126 | - </span> | 128 | + <span class="name org-who"> |
| 127 | - <span class="val">(if row.is_owner { g::t(lang, K::RoleOwner) } else { g::t(lang, K::RoleMember) })</span> | 129 | + <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> |
| 128 | - </summary> | 130 | + <span>(row.label.as_str())</span> |
| 129 | - <div class="opened"> | 131 | + </span> |
| 130 | - if owner { | 132 | + <span class="val">(if row.is_owner { g::t(lang, K::RoleOwner) } else { g::t(lang, K::RoleMember) })</span> |
| 131 | - <form method="post" action=(role_action.as_str()) class="fields"> | 133 | + </summary> |
| 132 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 134 | + <div class="opened"> |
| 133 | - <input type="hidden" name="user_id" value=(row.user_id.as_str())> | 135 | + if owner { |
| 134 | - <div class="field"> | 136 | + <form method="post" action=(role_action.as_str()) class="fields"> |
| 135 | - <label for=(format!("role-{}", row.user_id))>(g::t(lang, K::Role))</label> | 137 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 136 | - <select id=(format!("role-{}", row.user_id)) name="role"> | 138 | + <input type="hidden" name="user_id" value=(row.user_id.as_str())> |
| 137 | - <option value="owner" selected=(row.is_owner)>(g::t(lang, K::RoleOwner))</option> | 139 | + <div class="field"> |
| 138 | - <option value="member" selected=(!row.is_owner)>(g::t(lang, K::RoleMember))</option> | 140 | + <label for=(format!("role-{}", row.user_id))>(g::t(lang, K::Role))</label> |
| 139 | - </select> | 141 | + <select id=(format!("role-{}", row.user_id)) name="role"> |
| 140 | - </div> | 142 | + <option value="owner" selected=(row.is_owner)>(g::t(lang, K::RoleOwner))</option> |
| 141 | - <div class="acts"> | 143 | + <option value="member" selected=(!row.is_owner)>(g::t(lang, K::RoleMember))</option> |
| 142 | - <button type="submit" class="act">(g::t(lang, K::Save))</button> | 144 | + </select> |
| 143 | - </div> | ||
| 144 | - </form> | ||
| 145 | - } | ||
| 146 | - <a class="act quiet" href=(format!("/{}", row.username.as_str()))>(passkeys::s(lang, "Open profile", "Profili aç"))</a> | ||
| 147 | - <div class="acts"> | ||
| 148 | - confirm_act(lang: lang, label: g::t(lang, if row.is_self { K::Leave } else { K::Remove }), action: remove_action.as_str(), csrf: csrf.as_str(), fields: vec![("user_id".to_owned(), row.user_id.clone())]) | ||
| 149 | </div> | 145 | </div> |
| 150 | - </div> | 146 | + <button type="submit" class="primary small">(g::t(lang, K::Save))</button> |
| 151 | - </details> | 147 | + </form> |
| 152 | - } else { | 148 | + } |
| 153 | - <a class="line" href=(format!("/{}", row.username.as_str())) data-kb-row=""> | 149 | + <div class="acts"> |
| 154 | - <span class="name org-who"> | 150 | + <a class="act" href=(format!("/{}", row.username.as_str()))>(passkeys::s(lang, "Open profile", "Profili aç"))</a> |
| 155 | - <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> | 151 | + confirm_act(lang: lang, label: g::t(lang, if row.is_self { K::Leave } else { K::Remove }), action: remove_action.as_str(), csrf: csrf.as_str(), fields: vec![("user_id".to_owned(), row.user_id.clone())]) |
| 156 | - <span>(row.label.as_str())</span> | 152 | + </div> |
| 157 | - </span> | 153 | + </div> |
| 158 | - <span class="val">(if row.is_owner { g::t(lang, K::RoleOwner) } else { g::t(lang, K::RoleMember) })</span> | 154 | + </details> |
| 159 | - </a> | 155 | + } else { |
| 160 | - } | 156 | + <a class="line" href=(format!("/{}", row.username.as_str())) data-kb-row=""> |
| 161 | - } | 157 | + <span class="name org-who"> |
| 162 | - </div> | 158 | + <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> |
| 163 | - </section> | 159 | + <span>(row.label.as_str())</span> |
| 160 | + </span> | ||
| 161 | + <span class="val">(if row.is_owner { g::t(lang, K::RoleOwner) } else { g::t(lang, K::RoleMember) })</span> | ||
| 162 | + </a> | ||
| 163 | + } | ||
| 164 | + } | ||
| 164 | </div> | 165 | </div> |
| 165 | }) | 166 | }) |
| 166 | } | 167 | } |
crates/forge-web/src/pages/org_new.rsmodified+19 -17
| @@ -18,6 +18,7 @@ use crate::i18n::orgs::{self as g, K}; | |||
| 18 | use crate::i18n::{self, Lang}; | 18 | use crate::i18n::{self, Lang}; |
| 19 | use crate::live::Topic; | 19 | use crate::live::Topic; |
| 20 | use crate::state::AppState; | 20 | use crate::state::AppState; |
| 21 | +use crate::views::parts::{SubPart, head}; | ||
| 21 | use crate::views::{alert, csrf_field, shell, user_facing_message}; | 22 | use crate::views::{alert, csrf_field, shell, user_facing_message}; |
| 22 | 23 | ||
| 23 | const MAX_DESCRIPTION_CHARS: usize = 2000; | 24 | const MAX_DESCRIPTION_CHARS: usize = 2000; |
| @@ -49,23 +50,24 @@ async fn new_org_form( | |||
| 49 | lang: Lang, | 50 | lang: Lang, |
| 50 | ) -> Result<impl View> { | 51 | ) -> Result<impl View> { |
| 51 | Ok(view! { | 52 | Ok(view! { |
| 52 | - <h1 class="sr-only">(g::t(lang, K::NewOrganization))</h1> | 53 | + head(title: g::t(lang, K::NewOrganization), sub: vec![SubPart::text(g::t(lang, K::NewOrgIntro))]) |
| 53 | - <p class="hint">(g::t(lang, K::NewOrgIntro))</p> | 54 | + <div class="sheet fit"> |
| 54 | - if let Some(message) = error { | 55 | + if let Some(message) = error { |
| 55 | - alert(message: message.as_str()) | 56 | + alert(message: message.as_str()) |
| 56 | - } | 57 | + } |
| 57 | - <form method="post" action="/org/new" class="fields"> | 58 | + <form method="post" action="/org/new" class="fields"> |
| 58 | - csrf_field(token: csrf.as_str()) | 59 | + csrf_field(token: csrf.as_str()) |
| 59 | - <div class="field"> | 60 | + <div class="field"> |
| 60 | - <label for="org-new-name">(g::t(lang, K::OrgName))</label> | 61 | + <label for="org-new-name">(g::t(lang, K::OrgName))</label> |
| 61 | - <input id="org-new-name" type="text" name="name" value=(name.as_str()) required=(true) maxlength="64" autocomplete="off"> | 62 | + <input id="org-new-name" type="text" name="name" value=(name.as_str()) required=(true) maxlength="64" autocomplete="off"> |
| 62 | - </div> | 63 | + </div> |
| 63 | - <div class="field"> | 64 | + <div class="field"> |
| 64 | - <label for="org-new-description">(g::t(lang, K::DescriptionOptional))</label> | 65 | + <label for="org-new-description">(g::t(lang, K::DescriptionOptional))</label> |
| 65 | - <textarea id="org-new-description" name="description" rows="3" maxlength="2000">(description.as_str())</textarea> | 66 | + <textarea id="org-new-description" name="description" rows="3" maxlength="2000">(description.as_str())</textarea> |
| 66 | - </div> | 67 | + </div> |
| 67 | - <button type="submit" class="primary">(g::t(lang, K::CreateOrg))</button> | 68 | + <button type="submit" class="primary">(g::t(lang, K::CreateOrg))</button> |
| 68 | - </form> | 69 | + </form> |
| 70 | + </div> | ||
| 69 | }) | 71 | }) |
| 70 | } | 72 | } |
| 71 | 73 | ||
crates/forge-web/src/pages/org_settings.rsmodified+8 -8
| @@ -27,7 +27,7 @@ use crate::pages::org_ctx::{ | |||
| 27 | }; | 27 | }; |
| 28 | use crate::pages::settings_profile::store_avatar; | 28 | use crate::pages::settings_profile::store_avatar; |
| 29 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| 30 | -use crate::views::parts::{confirm_act, reveal}; | 30 | +use crate::views::parts::{confirm_act, head, reveal}; |
| 31 | use crate::views::{avatar_url, shell, user_facing_message}; | 31 | use crate::views::{avatar_url, shell, user_facing_message}; |
| 32 | 32 | ||
| 33 | path_param!(org); | 33 | path_param!(org); |
| @@ -88,10 +88,10 @@ async fn settings_body( | |||
| 88 | let delete_action = format!("{base}/settings/delete"); | 88 | let delete_action = format!("{base}/settings/delete"); |
| 89 | let confirm_label = g::type_to_confirm(lang, &name); | 89 | let confirm_label = g::type_to_confirm(lang, &name); |
| 90 | Ok(view! { | 90 | Ok(view! { |
| 91 | - <div data-live=(live.as_str())> | 91 | + head(title: name.as_str(), live: Some(live.as_str())) |
| 92 | - org_tabs(lang: lang, name: name.clone(), current: "settings".to_owned(), owner: true, repo_count: repo_count, package_count: package_count) | 92 | + org_tabs(lang: lang, name: name.clone(), current: "settings".to_owned(), owner: true, repo_count: repo_count, package_count: package_count) |
| 93 | - <h1 class="sr-only">(name.as_str())</h1> | 93 | + org_notice(notice: notice) |
| 94 | - org_notice(notice: notice) | 94 | + <div class="sheet"> |
| 95 | <form id="org-settings-form" method="post" action=(save_action.as_str())> | 95 | <form id="org-settings-form" method="post" action=(save_action.as_str())> |
| 96 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 96 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 97 | <section class="sec"> | 97 | <section class="sec"> |
| @@ -157,9 +157,9 @@ async fn settings_body( | |||
| 157 | <label for="org-delete-confirm">(confirm_label.as_str())</label> | 157 | <label for="org-delete-confirm">(confirm_label.as_str())</label> |
| 158 | <input id="org-delete-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> | 158 | <input id="org-delete-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 159 | </div> | 159 | </div> |
| 160 | - <div class="acts"> | 160 | + <div class="acts asks"> |
| 161 | - <button type="submit" class="act danger">(g::t(lang, K::DeleteOrg))</button> | 161 | + <button type="submit" class="danger small">(g::t(lang, K::DeleteOrg))</button> |
| 162 | - <button type="button" class="act quiet" data-close-details="">(crate::pages::passkeys::s(lang, "Cancel", "Vazgeç"))</button> | 162 | + <button type="button" class="act" data-close-details="">(crate::pages::passkeys::s(lang, "Cancel", "Vazgeç"))</button> |
| 163 | </div> | 163 | </div> |
| 164 | </form> | 164 | </form> |
| 165 | </details> | 165 | </details> |
crates/forge-web/src/pages/org_teams.rsmodified+128 -133
| @@ -19,12 +19,12 @@ use crate::audit::{self, Actor, Target}; | |||
| 19 | use crate::i18n::orgs::{self as g, K}; | 19 | use crate::i18n::orgs::{self as g, K}; |
| 20 | use crate::i18n::{self, Lang}; | 20 | use crate::i18n::{self, Lang}; |
| 21 | use crate::pages::org_ctx::{ | 21 | use crate::pages::org_ctx::{ |
| 22 | - OrgCtx, TEAM_ROLES, load_org, notice_href, org_head, org_notice, org_tab_counts, org_tabs, | 22 | + OrgCtx, TEAM_ROLES, load_org, notice_href, org_notice, org_tab_counts, org_tabs, |
| 23 | require_form_csrf, require_member, require_owner, take_notice, | 23 | require_form_csrf, require_member, require_owner, take_notice, |
| 24 | }; | 24 | }; |
| 25 | use crate::pages::passkeys; | 25 | use crate::pages::passkeys; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| 27 | -use crate::views::parts::{confirm_act, reveal}; | 27 | +use crate::views::parts::{SubPart, confirm_act, head, reveal}; |
| 28 | use crate::views::{avatar_url, display_name, repo_href, shell}; | 28 | use crate::views::{avatar_url, display_name, repo_href, shell}; |
| 29 | 29 | ||
| 30 | path_param!(org); | 30 | path_param!(org); |
| @@ -196,61 +196,62 @@ async fn teams_body( | |||
| 196 | package_count: usize, | 196 | package_count: usize, |
| 197 | ) -> Result<impl View> { | 197 | ) -> Result<impl View> { |
| 198 | let create_action = format!("{base}/teams/new"); | 198 | let create_action = format!("{base}/teams/new"); |
| 199 | + let sub = if description.is_empty() { | ||
| 200 | + Vec::new() | ||
| 201 | + } else { | ||
| 202 | + vec![SubPart::text(description)] | ||
| 203 | + }; | ||
| 199 | Ok(view! { | 204 | Ok(view! { |
| 200 | - <div data-live=(live.as_str())> | 205 | + head(title: name.as_str(), sub: sub, live: Some(live.as_str())) |
| 201 | - org_tabs(lang: lang, name: name.clone(), current: "teams".to_owned(), owner: owner, repo_count: repo_count, package_count: package_count) | 206 | + org_tabs(lang: lang, name: name.clone(), current: "teams".to_owned(), owner: owner, repo_count: repo_count, package_count: package_count) |
| 202 | - org_head(name: name, description: description) | 207 | + org_notice(notice: notice) |
| 203 | - org_notice(notice: notice) | 208 | + <div class="sheet"> |
| 204 | - <section class="sec"> | 209 | + <div class="sheet-tools"> |
| 205 | - <h2>(g::t(lang, K::Teams))</h2> | 210 | + <strong>(g::t(lang, K::Teams))</strong> |
| 206 | - <p class="hint">(g::t(lang, K::TeamsIntro))</p> | ||
| 207 | if owner { | 211 | if owner { |
| 208 | - <div class="acts"> | 212 | + reveal(label: g::t(lang, K::CreateTeam), id: Some("new-team"), |
| 209 | - reveal(label: g::t(lang, K::CreateTeam), id: Some("new-team"), | 213 | + <form method="post" action=(create_action.as_str()) class="fields"> |
| 210 | - <form method="post" action=(create_action.as_str()) class="fields"> | 214 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 211 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 215 | + <div class="field"> |
| 212 | - <div class="field"> | 216 | + <label for="new-team-name">(g::t(lang, K::Name))</label> |
| 213 | - <label for="new-team-name">(g::t(lang, K::Name))</label> | 217 | + <input id="new-team-name" type="text" name="name" autocomplete="off" required=(true) maxlength="64"> |
| 214 | - <input id="new-team-name" type="text" name="name" autocomplete="off" required=(true) maxlength="64"> | 218 | + </div> |
| 215 | - </div> | 219 | + <div class="field"> |
| 216 | - <div class="field"> | 220 | + <label for="new-team-description">(g::t(lang, K::DescriptionOptional))</label> |
| 217 | - <label for="new-team-description">(g::t(lang, K::DescriptionOptional))</label> | 221 | + <textarea id="new-team-description" name="description" rows="2" maxlength="350"></textarea> |
| 218 | - <textarea id="new-team-description" name="description" rows="2" maxlength="350"></textarea> | 222 | + </div> |
| 219 | - </div> | 223 | + <div class="field"> |
| 220 | - <div class="field"> | 224 | + <label for="new-team-role">(g::t(lang, K::Role))</label> |
| 221 | - <label for="new-team-role">(g::t(lang, K::Role))</label> | 225 | + <select id="new-team-role" name="role"> |
| 222 | - <select id="new-team-role" name="role"> | 226 | + for role in TEAM_ROLES.iter() { |
| 223 | - for role in TEAM_ROLES.iter() { | 227 | + <option value=(role.as_str()) selected=(*role == Role::Read)>(g::role_name(lang, role.as_str()))</option> |
| 224 | - <option value=(role.as_str()) selected=(*role == Role::Read)>(g::role_name(lang, role.as_str()))</option> | 228 | + } |
| 225 | - } | 229 | + </select> |
| 226 | - </select> | 230 | + </div> |
| 227 | - </div> | 231 | + <label class="switch"> |
| 228 | - <label class="switch"> | 232 | + <input type="checkbox" name="all_repos" value="on"> |
| 229 | - <input type="checkbox" name="all_repos" value="on"> | 233 | + <span>(g::t(lang, K::CoversAllRepos))</span> |
| 230 | - <span>(g::t(lang, K::CoversAllRepos))</span> | 234 | + </label> |
| 231 | - </label> | 235 | + <button type="submit" class="primary">(g::t(lang, K::CreateTeam))</button> |
| 232 | - <button type="submit" class="primary">(g::t(lang, K::CreateTeam))</button> | 236 | + </form> |
| 233 | - </form> | 237 | + ) |
| 234 | - ) | ||
| 235 | - </div> | ||
| 236 | } | 238 | } |
| 237 | - if rows.is_empty() { | 239 | + </div> |
| 238 | - <p class="state">(g::t(lang, K::NoTeamsYet))</p> | 240 | + <p class="hint">(g::t(lang, K::TeamsIntro))</p> |
| 239 | - } | 241 | + if rows.is_empty() { |
| 240 | - <div> | 242 | + <p class="state">(g::t(lang, K::NoTeamsYet))</p> |
| 241 | - for row in rows.iter() { | 243 | + } |
| 242 | - <a class="line" href=(row.href.as_str()) data-kb-row=""> | 244 | + for row in rows.iter() { |
| 243 | - <span class="name">(row.name.as_str())</span> | 245 | + <a class="line" href=(row.href.as_str()) data-kb-row=""> |
| 244 | - <span class="val"> | 246 | + <span class="name">(row.name.as_str())</span> |
| 245 | - (g::coverage_text(lang, row.role, row.all_repos)) | 247 | + <span class="val"> |
| 246 | - if !row.description.is_empty() { | 248 | + (g::coverage_text(lang, row.role, row.all_repos)) |
| 247 | - " · " (row.description.as_str()) | 249 | + if !row.description.is_empty() { |
| 248 | - } | 250 | + " · " (row.description.as_str()) |
| 249 | - </span> | 251 | + } |
| 250 | - </a> | 252 | + </span> |
| 251 | - } | 253 | + </a> |
| 252 | - </div> | 254 | + } |
| 253 | - </section> | ||
| 254 | </div> | 255 | </div> |
| 255 | }) | 256 | }) |
| 256 | } | 257 | } |
| @@ -307,108 +308,102 @@ async fn team_body( | |||
| 307 | let owner = data.owner; | 308 | let owner = data.owner; |
| 308 | let has_choices = !data.choices.is_empty(); | 309 | let has_choices = !data.choices.is_empty(); |
| 309 | let has_description = !data.team_description.is_empty(); | 310 | let has_description = !data.team_description.is_empty(); |
| 311 | + let mut sub = vec![SubPart::text(g::coverage_text( | ||
| 312 | + lang, | ||
| 313 | + data.team_role, | ||
| 314 | + data.team_all_repos, | ||
| 315 | + ))]; | ||
| 316 | + if has_description { | ||
| 317 | + sub.push(SubPart::text(data.team_description.clone())); | ||
| 318 | + } | ||
| 310 | Ok(view! { | 319 | Ok(view! { |
| 311 | - <div data-live=(data.live.as_str())> | 320 | + head(title: data.team_name.as_str(), sub: sub, live: Some(data.live.as_str())) |
| 312 | - org_tabs(lang: lang, name: data.org_name.clone(), current: "teams".to_owned(), owner: owner, repo_count: data.repo_count, package_count: data.package_count) | 321 | + org_tabs(lang: lang, name: data.org_name.clone(), current: "teams".to_owned(), owner: owner, repo_count: data.repo_count, package_count: data.package_count) |
| 313 | - org_notice(notice: notice) | 322 | + org_notice(notice: notice) |
| 314 | - <h1 class="h1">(data.team_name.as_str())</h1> | 323 | + <div class="sheet"> |
| 315 | - <p class="hint"> | ||
| 316 | - (g::coverage_text(lang, data.team_role, data.team_all_repos)) | ||
| 317 | - if has_description { | ||
| 318 | - " · " (data.team_description.as_str()) | ||
| 319 | - } | ||
| 320 | - </p> | ||
| 321 | <section class="sec"> | 324 | <section class="sec"> |
| 322 | <h2>(g::t(lang, K::Members))</h2> | 325 | <h2>(g::t(lang, K::Members))</h2> |
| 323 | if owner { | 326 | if owner { |
| 324 | - <div class="acts"> | 327 | + reveal(label: g::t(lang, K::AddToTeam), id: Some("add-member"), |
| 325 | - reveal(label: g::t(lang, K::AddToTeam), id: Some("add-member"), | 328 | + <form method="post" action=(add_member_action.as_str()) class="fields"> |
| 326 | - <form method="post" action=(add_member_action.as_str()) class="fields"> | 329 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 327 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 330 | + <div class="field"> |
| 328 | - <div class="field"> | 331 | + <label for="team-member-username">(g::t(lang, K::Username))</label> |
| 329 | - <label for="team-member-username">(g::t(lang, K::Username))</label> | 332 | + <input id="team-member-username" type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 330 | - <input id="team-member-username" type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> | 333 | + </div> |
| 331 | - </div> | 334 | + <button type="submit" class="primary">(g::t(lang, K::AddToTeam))</button> |
| 332 | - <button type="submit" class="primary">(g::t(lang, K::AddToTeam))</button> | 335 | + </form> |
| 333 | - </form> | 336 | + ) |
| 334 | - ) | ||
| 335 | - </div> | ||
| 336 | } | 337 | } |
| 337 | if data.members.is_empty() { | 338 | if data.members.is_empty() { |
| 338 | <p class="state">(g::t(lang, K::NoTeamMembers))</p> | 339 | <p class="state">(g::t(lang, K::NoTeamMembers))</p> |
| 339 | } | 340 | } |
| 340 | - <div> | 341 | + for member in data.members.iter() { |
| 341 | - for member in data.members.iter() { | 342 | + if owner { |
| 342 | - if owner { | 343 | + <details class="row-open"> |
| 343 | - <details class="row-open"> | 344 | + <summary class="line" data-kb-row=""> |
| 344 | - <summary class="line" data-kb-row=""> | ||
| 345 | - <span class="name org-who"> | ||
| 346 | - <img class="avatar avatar-sm" src=(member.avatar.as_str()) alt="" width="24" height="24"> | ||
| 347 | - <span>(member.label.as_str())</span> | ||
| 348 | - </span> | ||
| 349 | - </summary> | ||
| 350 | - <div class="opened"> | ||
| 351 | - <a class="act quiet" href=(format!("/{}", member.username.as_str()))>(passkeys::s(lang, "Open profile", "Profili aç"))</a> | ||
| 352 | - <div class="acts"> | ||
| 353 | - confirm_act(lang: lang, label: g::t(lang, K::Remove), action: remove_member_action.as_str(), csrf: csrf.as_str(), fields: vec![("user_id".to_owned(), member.user_id.clone())]) | ||
| 354 | - </div> | ||
| 355 | - </div> | ||
| 356 | - </details> | ||
| 357 | - } else { | ||
| 358 | - <a class="line" href=(format!("/{}", member.username.as_str())) data-kb-row=""> | ||
| 359 | <span class="name org-who"> | 345 | <span class="name org-who"> |
| 360 | <img class="avatar avatar-sm" src=(member.avatar.as_str()) alt="" width="24" height="24"> | 346 | <img class="avatar avatar-sm" src=(member.avatar.as_str()) alt="" width="24" height="24"> |
| 361 | <span>(member.label.as_str())</span> | 347 | <span>(member.label.as_str())</span> |
| 362 | </span> | 348 | </span> |
| 363 | - </a> | 349 | + </summary> |
| 364 | - } | 350 | + <div class="opened"> |
| 351 | + <div class="acts"> | ||
| 352 | + <a class="act" href=(format!("/{}", member.username.as_str()))>(passkeys::s(lang, "Open profile", "Profili aç"))</a> | ||
| 353 | + confirm_act(lang: lang, label: g::t(lang, K::Remove), action: remove_member_action.as_str(), csrf: csrf.as_str(), fields: vec![("user_id".to_owned(), member.user_id.clone())]) | ||
| 354 | + </div> | ||
| 355 | + </div> | ||
| 356 | + </details> | ||
| 357 | + } else { | ||
| 358 | + <a class="line" href=(format!("/{}", member.username.as_str())) data-kb-row=""> | ||
| 359 | + <span class="name org-who"> | ||
| 360 | + <img class="avatar avatar-sm" src=(member.avatar.as_str()) alt="" width="24" height="24"> | ||
| 361 | + <span>(member.label.as_str())</span> | ||
| 362 | + </span> | ||
| 363 | + </a> | ||
| 365 | } | 364 | } |
| 366 | - </div> | 365 | + } |
| 367 | </section> | 366 | </section> |
| 368 | <section class="sec"> | 367 | <section class="sec"> |
| 369 | <h2>(g::t(lang, K::Repositories))</h2> | 368 | <h2>(g::t(lang, K::Repositories))</h2> |
| 370 | if owner && has_choices { | 369 | if owner && has_choices { |
| 371 | - <div class="acts"> | 370 | + reveal(label: g::t(lang, K::LinkRepository), id: Some("link-repository"), |
| 372 | - reveal(label: g::t(lang, K::LinkRepository), id: Some("link-repository"), | 371 | + <form method="post" action=(add_repo_action.as_str()) class="fields"> |
| 373 | - <form method="post" action=(add_repo_action.as_str()) class="fields"> | 372 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 374 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 373 | + <div class="field"> |
| 375 | - <div class="field"> | 374 | + <label for="team-repo-id">(g::t(lang, K::Repository))</label> |
| 376 | - <label for="team-repo-id">(g::t(lang, K::Repository))</label> | 375 | + <select id="team-repo-id" name="repo_id"> |
| 377 | - <select id="team-repo-id" name="repo_id"> | 376 | + for choice in data.choices.iter() { |
| 378 | - for choice in data.choices.iter() { | 377 | + <option value=(choice.id.as_str())>(choice.title.as_str())</option> |
| 379 | - <option value=(choice.id.as_str())>(choice.title.as_str())</option> | 378 | + } |
| 380 | - } | 379 | + </select> |
| 381 | - </select> | 380 | + </div> |
| 382 | - </div> | 381 | + <button type="submit" class="primary">(g::t(lang, K::LinkRepository))</button> |
| 383 | - <button type="submit" class="primary">(g::t(lang, K::LinkRepository))</button> | 382 | + </form> |
| 384 | - </form> | 383 | + ) |
| 385 | - ) | ||
| 386 | - </div> | ||
| 387 | } | 384 | } |
| 388 | if data.repos.is_empty() { | 385 | if data.repos.is_empty() { |
| 389 | <p class="state">(g::t(lang, K::NoTeamRepos))</p> | 386 | <p class="state">(g::t(lang, K::NoTeamRepos))</p> |
| 390 | } | 387 | } |
| 391 | - <div> | 388 | + for repo in data.repos.iter() { |
| 392 | - for repo in data.repos.iter() { | 389 | + if owner { |
| 393 | - if owner { | 390 | + <details class="row-open"> |
| 394 | - <details class="row-open"> | 391 | + <summary class="line" data-kb-row=""> |
| 395 | - <summary class="line" data-kb-row=""> | ||
| 396 | - <span class="name">(repo.title.as_str())</span> | ||
| 397 | - </summary> | ||
| 398 | - <div class="opened"> | ||
| 399 | - <a class="act quiet" href=(repo.href.as_str())>(passkeys::s(lang, "Open repository", "Depoyu aç"))</a> | ||
| 400 | - <div class="acts"> | ||
| 401 | - confirm_act(lang: lang, label: g::t(lang, K::Unlink), action: remove_repo_action.as_str(), csrf: csrf.as_str(), fields: vec![("repo_id".to_owned(), repo.repo_id.clone())]) | ||
| 402 | - </div> | ||
| 403 | - </div> | ||
| 404 | - </details> | ||
| 405 | - } else { | ||
| 406 | - <a class="line" href=(repo.href.as_str()) data-kb-row=""> | ||
| 407 | <span class="name">(repo.title.as_str())</span> | 392 | <span class="name">(repo.title.as_str())</span> |
| 408 | - </a> | 393 | + </summary> |
| 409 | - } | 394 | + <div class="opened"> |
| 395 | + <div class="acts"> | ||
| 396 | + <a class="act" href=(repo.href.as_str())>(passkeys::s(lang, "Open repository", "Depoyu aç"))</a> | ||
| 397 | + confirm_act(lang: lang, label: g::t(lang, K::Unlink), action: remove_repo_action.as_str(), csrf: csrf.as_str(), fields: vec![("repo_id".to_owned(), repo.repo_id.clone())]) | ||
| 398 | + </div> | ||
| 399 | + </div> | ||
| 400 | + </details> | ||
| 401 | + } else { | ||
| 402 | + <a class="line" href=(repo.href.as_str()) data-kb-row=""> | ||
| 403 | + <span class="name">(repo.title.as_str())</span> | ||
| 404 | + </a> | ||
| 410 | } | 405 | } |
| 411 | - </div> | 406 | + } |
| 412 | </section> | 407 | </section> |
| 413 | if owner { | 408 | if owner { |
| 414 | <section class="sec"> | 409 | <section class="sec"> |
crates/forge-web/src/pages/packages.rsmodified+47 -38
| @@ -26,6 +26,7 @@ use crate::pages::ci_runs::{changed_event, events_response}; | |||
| 26 | use crate::pages::packages_oci::{self, oci_package_view}; | 26 | use crate::pages::packages_oci::{self, oci_package_view}; |
| 27 | use crate::render::markdown::render_markdown; | 27 | use crate::render::markdown::render_markdown; |
| 28 | use crate::state::AppState; | 28 | use crate::state::AppState; |
| 29 | +use crate::views::parts::{SubPart, head}; | ||
| 29 | use crate::views::{empty_state, enc, rel_time, shell}; | 30 | use crate::views::{empty_state, enc, rel_time, shell}; |
| 30 | 31 | ||
| 31 | path_param!(owner); | 32 | path_param!(owner); |
| @@ -304,67 +305,75 @@ async fn package_view(page: PackagePage) -> Result<impl View> { | |||
| 304 | let readme_label = pk::t(lang, K::Readme); | 305 | let readme_label = pk::t(lang, K::Readme); |
| 305 | let versions_label = pk::t(lang, K::PackageVersions); | 306 | let versions_label = pk::t(lang, K::PackageVersions); |
| 306 | let no_readme = pk::t(lang, K::NoReadme); | 307 | let no_readme = pk::t(lang, K::NoReadme); |
| 308 | + // The sub line: the owner, the private mark and the linked repo. | ||
| 309 | + let mut sub = vec![ | ||
| 310 | + SubPart::text(owner_name.as_str()), | ||
| 311 | + SubPart::text(pk::t(lang, K::TabPackages)), | ||
| 312 | + ]; | ||
| 313 | + if private { | ||
| 314 | + sub.push(SubPart::text(pk::t(lang, K::PackagePrivate))); | ||
| 315 | + } | ||
| 316 | + if has_repo { | ||
| 317 | + sub.push(SubPart::link( | ||
| 318 | + format!("{}: {}", pk::t(lang, K::PackageRepoLink), repo_text), | ||
| 319 | + repo_href.as_str(), | ||
| 320 | + )); | ||
| 321 | + } | ||
| 322 | + let heading = format!("{} {}", package.name, latest_text) | ||
| 323 | + .trim_end() | ||
| 324 | + .to_owned(); | ||
| 307 | Ok(view! { | 325 | Ok(view! { |
| 308 | - <div data-live=(events.as_str())> | 326 | + head(title: heading.as_str(), sub: sub) |
| 309 | - <h1 class="h1">(package.name.as_str()) " " <span class="muted">(latest_text.as_str())</span></h1> | 327 | + <nav class="tabs" aria-label=(package.name.as_str())> |
| 310 | - <p class="hint">(owner_name.as_str()) " / " (pk::t(lang, K::TabPackages))</p> | 328 | + <a href=(readme_href.as_str()) aria-current=(readme_current)>(readme_label)</a> |
| 311 | - if !description.is_empty() { | 329 | + <a href=(versions_href.as_str()) aria-current=(versions_current)>(versions_label)</a> |
| 312 | - <p class="state">(description.as_str())</p> | 330 | + </nav> |
| 313 | - } | 331 | + <div class="sheet" data-live=(events.as_str())> |
| 314 | - if private { | ||
| 315 | - <p class="hint"><span class="badge">(pk::t(lang, K::PackagePrivate))</span></p> | ||
| 316 | - } | ||
| 317 | - if has_repo { | ||
| 318 | - <p class="hint">(pk::t(lang, K::PackageRepoLink)) ": " <a href=(repo_href.as_str())>(repo_text.as_str())</a></p> | ||
| 319 | - } | ||
| 320 | <section class="sec"> | 332 | <section class="sec"> |
| 333 | + if !description.is_empty() { | ||
| 334 | + <p>(description.as_str())</p> | ||
| 335 | + } | ||
| 321 | <h2>(install)</h2> | 336 | <h2>(install)</h2> |
| 322 | <p class="hint">(pk::t(lang, K::InstallHelp))</p> | 337 | <p class="hint">(pk::t(lang, K::InstallHelp))</p> |
| 323 | - <p class="state">(pk::t(lang, K::InstallRegistryConfig))</p> | 338 | + <p class="hint">(pk::t(lang, K::InstallRegistryConfig))</p> |
| 324 | <div class="copy-box"> | 339 | <div class="copy-box"> |
| 325 | <code id="pkg-config">(config_block.as_str())</code> | 340 | <code id="pkg-config">(config_block.as_str())</code> |
| 326 | <button type="button" data-copy="pkg-config">(copy_label)</button> | 341 | <button type="button" data-copy="pkg-config">(copy_label)</button> |
| 327 | </div> | 342 | </div> |
| 328 | - <p class="state">(pk::t(lang, K::InstallAdd))</p> | 343 | + <p class="hint">(pk::t(lang, K::InstallAdd))</p> |
| 329 | <div class="copy-box"> | 344 | <div class="copy-box"> |
| 330 | <code id="pkg-add">(add_cmd.as_str())</code> | 345 | <code id="pkg-add">(add_cmd.as_str())</code> |
| 331 | <button type="button" data-copy="pkg-add">(copy_label)</button> | 346 | <button type="button" data-copy="pkg-add">(copy_label)</button> |
| 332 | </div> | 347 | </div> |
| 333 | - <p class="state">(pk::t(lang, K::InstallPublish))</p> | 348 | + <p class="hint">(pk::t(lang, K::InstallPublish))</p> |
| 334 | <div class="copy-box"> | 349 | <div class="copy-box"> |
| 335 | <code id="pkg-publish">(publish_cmd.as_str())</code> | 350 | <code id="pkg-publish">(publish_cmd.as_str())</code> |
| 336 | <button type="button" data-copy="pkg-publish">(copy_label)</button> | 351 | <button type="button" data-copy="pkg-publish">(copy_label)</button> |
| 337 | </div> | 352 | </div> |
| 338 | - <p class="state">(pk::t(lang, K::InstallLogin))</p> | 353 | + <p class="hint">(pk::t(lang, K::InstallLogin))</p> |
| 339 | <div class="copy-box"> | 354 | <div class="copy-box"> |
| 340 | <code id="pkg-login">(login_cmd.as_str())</code> | 355 | <code id="pkg-login">(login_cmd.as_str())</code> |
| 341 | <button type="button" data-copy="pkg-login">(copy_label)</button> | 356 | <button type="button" data-copy="pkg-login">(copy_label)</button> |
| 342 | </div> | 357 | </div> |
| 343 | </section> | 358 | </section> |
| 344 | - <nav class="tabs" aria-label=(package.name.as_str())> | ||
| 345 | - <a href=(readme_href.as_str()) aria-current=(readme_current)>(readme_label)</a> | ||
| 346 | - <a href=(versions_href.as_str()) aria-current=(versions_current)>(versions_label)</a> | ||
| 347 | - </nav> | ||
| 348 | if versions_tab { | 359 | if versions_tab { |
| 349 | if has_versions { | 360 | if has_versions { |
| 350 | - <div> | 361 | + for (version, date, yanked, checksum) in version_rows.iter() { |
| 351 | - for (version, date, yanked, checksum) in version_rows.iter() { | 362 | + <details class="row-open" data-kb-row=""> |
| 352 | - <details class="row-open" data-kb-row=""> | 363 | + <summary class="line"> |
| 353 | - <summary class="line"> | 364 | + <span class="name"> |
| 354 | - <span class="name"> | 365 | + (version.as_str()) |
| 355 | - (version.as_str()) | 366 | + if *yanked { |
| 356 | - if *yanked { | 367 | + " " <span class="badge">(pk::t(lang, K::VersionYanked))</span> |
| 357 | - " " <span class="badge">(pk::t(lang, K::VersionYanked))</span> | 368 | + } |
| 358 | - } | 369 | + </span> |
| 359 | - </span> | 370 | + <span class="val">rel_time(lang: lang, stamp: date.as_str())</span> |
| 360 | - <span class="val">rel_time(lang: lang, stamp: date.as_str())</span> | 371 | + </summary> |
| 361 | - </summary> | 372 | + <div class="opened"> |
| 362 | - <div class="opened"> | 373 | + <code class="hint">(checksum.as_str())</code> |
| 363 | - <code class="hint">(checksum.as_str())</code> | 374 | + </div> |
| 364 | - </div> | 375 | + </details> |
| 365 | - </details> | 376 | + } |
| 366 | - } | ||
| 367 | - </div> | ||
| 368 | } else { | 377 | } else { |
| 369 | empty_state(title: pk::t(lang, K::NoVersions)) | 378 | empty_state(title: pk::t(lang, K::NoVersions)) |
| 370 | } | 379 | } |
crates/forge-web/src/pages/packages_oci.rsmodified+15 -7
| @@ -11,7 +11,7 @@ use crate::i18n::Lang; | |||
| 11 | use crate::i18n::packages::{self as pk, K}; | 11 | use crate::i18n::packages::{self as pk, K}; |
| 12 | use crate::package_ops; | 12 | use crate::package_ops; |
| 13 | use crate::state::AppState; | 13 | use crate::state::AppState; |
| 14 | -use crate::views::parts::confirm_act; | 14 | +use crate::views::parts::{SubPart, confirm_act, head}; |
| 15 | use crate::views::{empty_state, enc, human_size, rel_time}; | 15 | use crate::views::{empty_state, enc, human_size, rel_time}; |
| 16 | 16 | ||
| 17 | /// What the container package page shows, prepared by the handler. | 17 | /// What the container package page shows, prepared by the handler. |
| @@ -110,13 +110,21 @@ pub async fn oci_package_view(page: OciPage) -> Result<impl View> { | |||
| 110 | ) | 110 | ) |
| 111 | }) | 111 | }) |
| 112 | .collect(); | 112 | .collect(); |
| 113 | + // The head holds the name, the owner, the newest tag and the private note; the install and tag | ||
| 114 | + // topics sit in one sheet below it. | ||
| 115 | + let mut sub = vec![SubPart::text(format!( | ||
| 116 | + "{owner_name} / {}", | ||
| 117 | + pk::t(lang, K::ContainerKind) | ||
| 118 | + ))]; | ||
| 119 | + if !newest_tag.is_empty() { | ||
| 120 | + sub.push(SubPart::mono(newest_tag.clone())); | ||
| 121 | + } | ||
| 122 | + if private { | ||
| 123 | + sub.push(SubPart::strong(pk::t(lang, K::PackagePrivate))); | ||
| 124 | + } | ||
| 113 | Ok(view! { | 125 | Ok(view! { |
| 114 | - <div data-live=(events.as_str())> | 126 | + head(title: package.name.as_str(), sub: sub, live: Some(events.as_str())) |
| 115 | - <h1 class="h1">(package.name.as_str()) " " <span class="muted">(newest_tag.as_str())</span></h1> | 127 | + <div class="sheet"> |
| 116 | - <p class="hint">(owner_name.as_str()) " / " (pk::t(lang, K::ContainerKind))</p> | ||
| 117 | - if private { | ||
| 118 | - <p class="hint"><span class="badge">(pk::t(lang, K::PackagePrivate))</span></p> | ||
| 119 | - } | ||
| 120 | <section class="sec"> | 128 | <section class="sec"> |
| 121 | <h2>(pk::t(lang, K::Install))</h2> | 129 | <h2>(pk::t(lang, K::Install))</h2> |
| 122 | <p class="hint">(pk::t(lang, K::ContainerInstallHelp))</p> | 130 | <p class="hint">(pk::t(lang, K::ContainerInstallHelp))</p> |
crates/forge-web/src/pages/passkeys.rsmodified+22 -26
| @@ -678,32 +678,28 @@ pub async fn passkeys_panel(lang: Lang, csrf: &str, panel: PasskeyPanel) -> Resu | |||
| 678 | } else { | 678 | } else { |
| 679 | <p class="hint">(s(lang, "Sign in with your fingerprint, face or device PIN. A passkey counts as two factors, so it skips the code step.", "Parmak izi, yüz veya cihaz PIN'inizle giriş yapın. Geçiş anahtarı iki doğrulama sayılır, bu yüzden kod adımı atlanır."))</p> | 679 | <p class="hint">(s(lang, "Sign in with your fingerprint, face or device PIN. A passkey counts as two factors, so it skips the code step.", "Parmak izi, yüz veya cihaz PIN'inizle giriş yapın. Geçiş anahtarı iki doğrulama sayılır, bu yüzden kod adımı atlanır."))</p> |
| 680 | } | 680 | } |
| 681 | - if !empty { | 681 | + for (item, rename_action, delete_action, field) in rows.into_iter() { |
| 682 | - <div> | 682 | + <details class="row-open"> |
| 683 | - for (item, rename_action, delete_action, field) in rows.into_iter() { | 683 | + <summary class="line"> |
| 684 | - <details class="row-open"> | 684 | + <span class="name">(item.name.as_str())</span> |
| 685 | - <summary class="line"> | 685 | + <span class="val">added_status(lang: lang, added: Some(item.created_at.as_str()), used: item.last_used_at.as_deref())</span> |
| 686 | - <span class="name">(item.name.as_str())</span> | 686 | + </summary> |
| 687 | - <span class="val">added_status(lang: lang, added: Some(item.created_at.as_str()), used: item.last_used_at.as_deref())</span> | 687 | + <div class="opened"> |
| 688 | - </summary> | 688 | + <div class="acts"> |
| 689 | - <div class="opened"> | 689 | + reveal(label: s(lang, "Rename", "Yeniden adlandır"), |
| 690 | - <div class="acts"> | 690 | + <form method="post" action=(rename_action.as_str()) class="fields"> |
| 691 | - reveal(label: s(lang, "Rename", "Yeniden adlandır"), | 691 | + <input type="hidden" name="csrf" value=(csrf)> |
| 692 | - <form method="post" action=(rename_action.as_str()) class="fields"> | 692 | + <div class="field"> |
| 693 | - <input type="hidden" name="csrf" value=(csrf)> | 693 | + <label for=(field.as_str())>(s(lang, "Name", "Ad"))</label> |
| 694 | - <div class="field"> | 694 | + <input id=(field.as_str()) type="text" name="name" value=(item.name.as_str()) maxlength="40" autocomplete="off" required=(true)> |
| 695 | - <label for=(field.as_str())>(s(lang, "Name", "Ad"))</label> | 695 | + </div> |
| 696 | - <input id=(field.as_str()) type="text" name="name" value=(item.name.as_str()) maxlength="40" autocomplete="off" required=(true)> | 696 | + <button type="submit" class="primary">(t(lang, Key::Save))</button> |
| 697 | - </div> | 697 | + </form> |
| 698 | - <button type="submit" class="primary">(t(lang, Key::Save))</button> | 698 | + ) |
| 699 | - </form> | 699 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: delete_action.as_str(), csrf: csrf, note: Some(s(lang, "Delete this passkey? You can no longer sign in with it.", "Bu geçiş anahtarı silinsin mi? Artık onunla giriş yapamazsınız.").to_owned())) |
| 700 | - ) | 700 | + </div> |
| 701 | - confirm_act(lang: lang, label: t(lang, Key::Delete), action: delete_action.as_str(), csrf: csrf, note: Some(s(lang, "Delete this passkey? You can no longer sign in with it.", "Bu geçiş anahtarı silinsin mi? Artık onunla giriş yapamazsınız.").to_owned())) | 701 | + </div> |
| 702 | - </div> | 702 | + </details> |
| 703 | - </div> | ||
| 704 | - </details> | ||
| 705 | - } | ||
| 706 | - </div> | ||
| 707 | } | 703 | } |
| 708 | if usable { | 704 | if usable { |
| 709 | <div class="acts"> | 705 | <div class="acts"> |
crates/forge-web/src/pages/profile.rsmodified+88 -91
| @@ -36,6 +36,7 @@ use crate::pages::snippets::{ListRow, list_row, snippet_rows}; | |||
| 36 | use crate::render::markdown::render_markdown; | 36 | use crate::render::markdown::render_markdown; |
| 37 | use crate::state::AppState; | 37 | use crate::state::AppState; |
| 38 | use crate::views::heatmap::{Calendar, DayDetail, contribution_calendar}; | 38 | use crate::views::heatmap::{Calendar, DayDetail, contribution_calendar}; |
| 39 | +use crate::views::parts::{SubPart, head}; | ||
| 39 | use crate::views::repo_list::{ | 40 | use crate::views::repo_list::{ |
| 40 | PageLink, RepoRow, SortLink, badge_class, pager, pager_links, repo_rows, sort_chips, | 41 | PageLink, RepoRow, SortLink, badge_class, pager, pager_links, repo_rows, sort_chips, |
| 41 | }; | 42 | }; |
| @@ -646,56 +647,54 @@ async fn profile_card( | |||
| 646 | let new_repo_href = format!("/new?owner={}", enc(&user.username)); | 647 | let new_repo_href = format!("/new?owner={}", enc(&user.username)); |
| 647 | let settings_href = format!("/org/{}/settings", enc(&user.username)); | 648 | let settings_href = format!("/org/{}/settings", enc(&user.username)); |
| 648 | let members_href = format!("/org/{}/members", enc(&user.username)); | 649 | let members_href = format!("/org/{}/members", enc(&user.username)); |
| 649 | - let has_acts = edit_profile || (is_org && (org_owner || org_can_create)); | ||
| 650 | let members_more = org | 650 | let members_more = org |
| 651 | .as_ref() | 651 | .as_ref() |
| 652 | .is_some_and(|summary| org_member && summary.total > summary.members.len()); | 652 | .is_some_and(|summary| org_member && summary.total > summary.members.len()); |
| 653 | + // The sub line: the username under a display name, then whether this is an organization or the | ||
| 654 | + // person's local time. | ||
| 655 | + let mut sub = Vec::new(); | ||
| 656 | + if has_name { | ||
| 657 | + sub.push(SubPart::text(user.username.as_str())); | ||
| 658 | + } | ||
| 659 | + if is_org { | ||
| 660 | + sub.push(SubPart::text(g::t(lang, K::Organization))); | ||
| 661 | + } else { | ||
| 662 | + sub.push(SubPart::text(format!( | ||
| 663 | + "{} {}", | ||
| 664 | + g::t(lang, K::LocalTime), | ||
| 665 | + local_time | ||
| 666 | + ))); | ||
| 667 | + } | ||
| 653 | Ok(view! { | 668 | Ok(view! { |
| 654 | - <article class="profile-page" data-live=(format!("/users/{}/events", user.username))> | 669 | + head(title: heading.as_str(), sub: sub, |
| 655 | - <header class="profile-head"> | 670 | + <img class=(avatar_class) src=(src) alt="" width=(avatar_px) height=(avatar_px)> |
| 656 | - <img class=(avatar_class) src=(src) alt="" width=(avatar_px) height=(avatar_px)> | 671 | + if edit_profile { |
| 657 | - <div class="profile-id"> | 672 | + <a class="button" href="/settings/profile">(edit_label)</a> |
| 658 | - <h1 class="h1">(heading)</h1> | 673 | + } |
| 659 | - if has_name { | 674 | + if org_owner { |
| 660 | - <p class="hint">(user.username.as_str())</p> | 675 | + <a class="button" href=(settings_href.as_str())>(org_edit_label)</a> |
| 661 | - } | 676 | + } |
| 662 | - if is_org { | 677 | + if org_can_create { |
| 663 | - <p class="hint">(g::t(lang, K::Organization))</p> | 678 | + <a class="button primary" href=(new_repo_href.as_str())>(g::t(lang, K::NewRepository))</a> |
| 664 | - } | 679 | + } |
| 665 | - if !is_org { | 680 | + ) |
| 666 | - <p class="hint">(g::t(lang, K::LocalTime)) (local_time.as_str())</p> | 681 | + profile_tabs(username: user.username.clone(), items: tab_items, current: tab.clone(), counts: tab_counts) |
| 667 | - } | 682 | + <div class="sheet" data-live=(format!("/users/{}/events", user.username))> |
| 668 | - if has_acts { | 683 | + if has_about { |
| 669 | - <div class="acts"> | 684 | + <section class="sec profile-about markdown-body">(Unescaped::new_unchecked(about_html))</section> |
| 670 | - if edit_profile { | 685 | + } |
| 671 | - <a class="act" href="/settings/profile">(edit_label)</a> | ||
| 672 | - } | ||
| 673 | - if org_owner { | ||
| 674 | - <a class="act" href=(settings_href.as_str())>(org_edit_label)</a> | ||
| 675 | - } | ||
| 676 | - if org_can_create { | ||
| 677 | - <a class="act" href=(new_repo_href.as_str())>(g::t(lang, K::NewRepository))</a> | ||
| 678 | - } | ||
| 679 | - </div> | ||
| 680 | - } | ||
| 681 | - </div> | ||
| 682 | - if has_about { | ||
| 683 | - <section class="profile-about markdown-body">(Unescaped::new_unchecked(about_html))</section> | ||
| 684 | - } | ||
| 685 | - </header> | ||
| 686 | - profile_tabs(username: user.username.clone(), items: tab_items, current: tab.clone(), counts: tab_counts) | ||
| 687 | if overview_on { | 686 | if overview_on { |
| 688 | if let Some((calendar, selected)) = heat { | 687 | if let Some((calendar, selected)) = heat { |
| 689 | - contribution_calendar(calendar: calendar, selected: selected, lang: lang, base: base.clone(), | 688 | + <section class="sec"> |
| 690 | - live: Some(format!("/users/{}/events", user.username))) | 689 | + contribution_calendar(calendar: calendar, selected: selected, lang: lang, base: base.clone(), |
| 690 | + live: Some(format!("/users/{}/events", user.username))) | ||
| 691 | + </section> | ||
| 691 | } | 692 | } |
| 692 | <section class="sec profile-pinned"> | 693 | <section class="sec profile-pinned"> |
| 693 | - <div class="topic-head"> | 694 | + <h2>(pinned_heading)</h2> |
| 694 | - <h2>(pinned_heading)</h2> | 695 | + if let Some(menu) = pins_menu_data { |
| 695 | - if let Some(menu) = pins_menu_data { | 696 | + pins_menu(lang: lang, action: menu.action, csrf: menu.csrf, options: menu.options) |
| 696 | - pins_menu(lang: lang, action: menu.action, csrf: menu.csrf, options: menu.options) | 697 | + } |
| 697 | - } | ||
| 698 | - </div> | ||
| 699 | if pins_error { | 698 | if pins_error { |
| 700 | <p class="alert" role="alert">(g::t(lang, K::PinsTooMany))</p> | 699 | <p class="alert" role="alert">(g::t(lang, K::PinsTooMany))</p> |
| 701 | } | 700 | } |
| @@ -743,16 +742,18 @@ async fn profile_card( | |||
| 743 | } | 742 | } |
| 744 | } | 743 | } |
| 745 | if list_on { | 744 | if list_on { |
| 746 | - <section class="repo-listing"> | 745 | + <section class="sec"> |
| 747 | - <form method="get" action=(base.as_str()) class="plain-search" role="search"> | 746 | + <div class="sheet-tools"> |
| 748 | - <input type="hidden" name="tab" value=(tab.as_str())> | 747 | + <strong>(count_text.as_str())</strong> |
| 749 | - <input type="hidden" name="sort" value=(sort)> | 748 | + <form method="get" action=(base.as_str()) class="plain-search" role="search"> |
| 750 | - <input type="search" name="q" value=(q.as_str()) data-live-search="" | 749 | + <input type="hidden" name="tab" value=(tab.as_str())> |
| 751 | - placeholder=(filter_label) aria-label=(filter_label)> | 750 | + <input type="hidden" name="sort" value=(sort)> |
| 752 | - <button type="submit" class="act">(g::t(lang, K::Search))</button> | 751 | + <input type="search" name="q" value=(q.as_str()) data-live-search="" |
| 753 | - </form> | 752 | + placeholder=(filter_label) aria-label=(filter_label)> |
| 754 | - sort_chips(links: sort_links, lang: lang) | 753 | + <button type="submit" class="act">(g::t(lang, K::Search))</button> |
| 755 | - <p class="hint repo-count">(count_text.as_str())</p> | 754 | + </form> |
| 755 | + sort_chips(links: sort_links, lang: lang) | ||
| 756 | + </div> | ||
| 756 | if has_rows { | 757 | if has_rows { |
| 757 | repo_rows(rows: rows, lang: lang) | 758 | repo_rows(rows: rows, lang: lang) |
| 758 | } else { | 759 | } else { |
| @@ -771,24 +772,22 @@ async fn profile_card( | |||
| 771 | <h2>(pk::t(lang, PK::PackagesHeading))</h2> | 772 | <h2>(pk::t(lang, PK::PackagesHeading))</h2> |
| 772 | <p class="hint">(pk::t(lang, PK::PackagesHelp))</p> | 773 | <p class="hint">(pk::t(lang, PK::PackagesHelp))</p> |
| 773 | if has_packages { | 774 | if has_packages { |
| 774 | - <div class="plain-rows"> | 775 | + for row in package_rows.into_iter() { |
| 775 | - for row in package_rows.into_iter() { | 776 | + <div class="line" data-kb-row=""> |
| 776 | - <div class="line" data-kb-row=""> | 777 | + <a class="name" href=(row.href.as_str())>(row.name.as_str())</a> |
| 777 | - <a class="name" href=(row.href.as_str())>(row.name.as_str())</a> | 778 | + if row.container { |
| 778 | - if row.container { | 779 | + <span class="badge">(pk::t(lang, PK::ContainerKind))</span> |
| 779 | - <span class="badge">(pk::t(lang, PK::ContainerKind))</span> | 780 | + } |
| 780 | - } | 781 | + <span class="val">(row.latest.as_str())</span> |
| 781 | - <span class="val">(row.latest.as_str())</span> | 782 | + <span class="val">(row.versions.to_string()) " " (pk::t(lang, match (row.container, row.versions == 1) { (true, true) => PK::PackageTagCountOne, (true, false) => PK::PackageTagCount, (false, true) => PK::PackageVersionCountOne, (false, false) => PK::PackageVersionCount }))</span> |
| 782 | - <span class="val">(row.versions.to_string()) " " (pk::t(lang, match (row.container, row.versions == 1) { (true, true) => PK::PackageTagCountOne, (true, false) => PK::PackageTagCount, (false, true) => PK::PackageVersionCountOne, (false, false) => PK::PackageVersionCount }))</span> | 783 | + if row.private { |
| 783 | - if row.private { | 784 | + <span class="badge">(pk::t(lang, PK::PackagePrivate))</span> |
| 784 | - <span class="badge">(pk::t(lang, PK::PackagePrivate))</span> | 785 | + } |
| 785 | - } | 786 | + if !row.description.is_empty() { |
| 786 | - if !row.description.is_empty() { | 787 | + <span class="val">(row.description.as_str())</span> |
| 787 | - <span class="val">(row.description.as_str())</span> | 788 | + } |
| 788 | - } | 789 | + </div> |
| 789 | - </div> | 790 | + } |
| 790 | - } | ||
| 791 | - </div> | ||
| 792 | } else { | 791 | } else { |
| 793 | <p class="state">(pk::t(lang, PK::NoPackages))</p> | 792 | <p class="state">(pk::t(lang, PK::NoPackages))</p> |
| 794 | } | 793 | } |
| @@ -818,24 +817,22 @@ async fn profile_card( | |||
| 818 | </div> | 817 | </div> |
| 819 | } | 818 | } |
| 820 | if has_orgs { | 819 | if has_orgs { |
| 821 | - <div class="plain-rows"> | 820 | + for org in orgs.into_iter() { |
| 822 | - for org in orgs.into_iter() { | 821 | + <div class="line" data-kb-row=""> |
| 823 | - <div class="line" data-kb-row=""> | 822 | + <img class="avatar avatar-sm" src=(org.avatar.as_str()) alt="" width="24" height="24"> |
| 824 | - <img class="avatar avatar-sm" src=(org.avatar.as_str()) alt="" width="24" height="24"> | 823 | + <a class="name" href=(org.href.as_str())>(org.name.as_str())</a> |
| 825 | - <a class="name" href=(org.href.as_str())>(org.name.as_str())</a> | 824 | + if !org.display_name.is_empty() { |
| 826 | - if !org.display_name.is_empty() { | 825 | + <span class="val">(org.display_name.as_str())</span> |
| 827 | - <span class="val">(org.display_name.as_str())</span> | 826 | + } |
| 828 | - } | 827 | + <span class="badge">(org.role)</span> |
| 829 | - <span class="badge">(org.role)</span> | 828 | + </div> |
| 830 | - </div> | 829 | + } |
| 831 | - } | ||
| 832 | - </div> | ||
| 833 | } else { | 830 | } else { |
| 834 | <p class="state">(g::t(lang, K::NoOrganizations))</p> | 831 | <p class="state">(g::t(lang, K::NoOrganizations))</p> |
| 835 | } | 832 | } |
| 836 | </section> | 833 | </section> |
| 837 | } | 834 | } |
| 838 | - </article> | 835 | + </div> |
| 839 | }) | 836 | }) |
| 840 | } | 837 | } |
| 841 | 838 | ||
| @@ -1045,7 +1042,7 @@ mod tests { | |||
| 1045 | assert!(owner.contains("tahinli/secret-repo"), "owner: private repo"); | 1042 | assert!(owner.contains("tahinli/secret-repo"), "owner: private repo"); |
| 1046 | assert!(owner.contains("tahinli/shared-repo"), "owner: shared repo"); | 1043 | assert!(owner.contains("tahinli/shared-repo"), "owner: shared repo"); |
| 1047 | assert!( | 1044 | assert!( |
| 1048 | - owner.contains("class=\"act\" href=\"/settings/profile\""), | 1045 | + owner.contains("class=\"button\" href=\"/settings/profile\""), |
| 1049 | "owner: edit button" | 1046 | "owner: edit button" |
| 1050 | ); | 1047 | ); |
| 1051 | 1048 | ||
| @@ -1084,7 +1081,7 @@ mod tests { | |||
| 1084 | ] { | 1081 | ] { |
| 1085 | let (_, body) = get(&site.router, uri, None).await; | 1082 | let (_, body) = get(&site.router, uri, None).await; |
| 1086 | assert!( | 1083 | assert!( |
| 1087 | - !body.contains("<article class=\"profile-page\""), | 1084 | + !body.contains("<div class=\"sheet\" data-live=\"/users/"), |
| 1088 | "{uri} was served by the profile page" | 1085 | "{uri} was served by the profile page" |
| 1089 | ); | 1086 | ); |
| 1090 | } | 1087 | } |
| @@ -1096,7 +1093,7 @@ mod tests { | |||
| 1096 | let (status, body) = get(&site.router, "/tahinli/missing", None).await; | 1093 | let (status, body) = get(&site.router, "/tahinli/missing", None).await; |
| 1097 | assert_eq!(status, 404, "missing repo"); | 1094 | assert_eq!(status, 404, "missing repo"); |
| 1098 | assert!( | 1095 | assert!( |
| 1099 | - !body.contains("<article class=\"profile-page\""), | 1096 | + !body.contains("<div class=\"sheet\" data-live=\"/users/"), |
| 1100 | "missing repo" | 1097 | "missing repo" |
| 1101 | ); | 1098 | ); |
| 1102 | } | 1099 | } |
| @@ -1212,7 +1209,7 @@ mod tests { | |||
| 1212 | "org pins: anonymous has no edit link" | 1209 | "org pins: anonymous has no edit link" |
| 1213 | ); | 1210 | ); |
| 1214 | assert!( | 1211 | assert!( |
| 1215 | - owner.contains("class=\"act\" href=\"/org/acme/settings\"") | 1212 | + owner.contains("class=\"button\" href=\"/org/acme/settings\"") |
| 1216 | && owner.contains("/new?owner=acme"), | 1213 | && owner.contains("/new?owner=acme"), |
| 1217 | "org profile: owner sees Edit organization and New repository" | 1214 | "org profile: owner sees Edit organization and New repository" |
| 1218 | ); | 1215 | ); |
| @@ -1296,22 +1293,22 @@ mod tests { | |||
| 1296 | let (status, body) = get(&site.router, "/tahinli", None).await; | 1293 | let (status, body) = get(&site.router, "/tahinli", None).await; |
| 1297 | assert_eq!(status, 200, "display name: page"); | 1294 | assert_eq!(status, 200, "display name: page"); |
| 1298 | assert!( | 1295 | assert!( |
| 1299 | - body.contains("<h1 class=\"h1\">Ahmet Kaan Gümüş</h1>"), | 1296 | + body.contains("<h1>Ahmet Kaan Gümüş</h1>"), |
| 1300 | "display name: heading {body}" | 1297 | "display name: heading {body}" |
| 1301 | ); | 1298 | ); |
| 1302 | assert!( | 1299 | assert!( |
| 1303 | - body.contains("<p class=\"hint\">tahinli</p>"), | 1300 | + body.contains("<p class=\"head-sub\"><span class=\"\">tahinli</span>"), |
| 1304 | "display name: username below {body}" | 1301 | "display name: username below {body}" |
| 1305 | ); | 1302 | ); |
| 1306 | 1303 | ||
| 1307 | site.store.set_display_name(&tahinli, " ").await.unwrap(); | 1304 | site.store.set_display_name(&tahinli, " ").await.unwrap(); |
| 1308 | let (_, body) = get(&site.router, "/tahinli", None).await; | 1305 | let (_, body) = get(&site.router, "/tahinli", None).await; |
| 1309 | assert!( | 1306 | assert!( |
| 1310 | - body.contains("<h1 class=\"h1\">tahinli</h1>"), | 1307 | + body.contains("<h1>tahinli</h1>"), |
| 1311 | "blank name: heading {body}" | 1308 | "blank name: heading {body}" |
| 1312 | ); | 1309 | ); |
| 1313 | assert!( | 1310 | assert!( |
| 1314 | - !body.contains("<p class=\"hint\">tahinli</p>"), | 1311 | + !body.contains("<p class=\"head-sub\"><span class=\"\">tahinli</span>"), |
| 1315 | "blank name: no username line {body}" | 1312 | "blank name: no username line {body}" |
| 1316 | ); | 1313 | ); |
| 1317 | } | 1314 | } |
crates/forge-web/src/pages/profile_pins.rsmodified+2 -2
| @@ -66,9 +66,9 @@ pub(crate) async fn pins_menu( | |||
| 66 | options: Vec<PinOption>, | 66 | options: Vec<PinOption>, |
| 67 | ) -> Result<impl View> { | 67 | ) -> Result<impl View> { |
| 68 | Ok(view! { | 68 | Ok(view! { |
| 69 | - <details class="pop pins-menu"> | 69 | + <details class="menu pins-menu"> |
| 70 | <summary class="act">(g::t(lang, K::CustomizePins))</summary> | 70 | <summary class="act">(g::t(lang, K::CustomizePins))</summary> |
| 71 | - <form method="post" action=(action.as_str()) class="pop-panel"> | 71 | + <form method="post" action=(action.as_str()) class="menu-list"> |
| 72 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 72 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 73 | <p class="hint">(g::t(lang, K::PinsIntro))</p> | 73 | <p class="hint">(g::t(lang, K::PinsIntro))</p> |
| 74 | <ul class="pin-options"> | 74 | <ul class="pin-options"> |
crates/forge-web/src/pages/pull_branch.rsmodified+6 -6
| @@ -370,8 +370,8 @@ pub(crate) fn branch_error_from(cx: &Cx, lang: Lang) -> Option<String> { | |||
| 370 | branch_error_text(lang, &code).map(str::to_owned) | 370 | branch_error_text(lang, &code).map(str::to_owned) |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | -/// The branch box on a finished pull request: an error line and, when the viewer may act, the | 373 | +/// The branch topic of a finished pull request, for the pull request's sheet: an error line and, |
| 374 | -/// delete or restore form. | 374 | +/// when the viewer may act, the delete or restore tool. |
| 375 | #[component] | 375 | #[component] |
| 376 | pub(crate) async fn branch_box( | 376 | pub(crate) async fn branch_box( |
| 377 | lang: Lang, | 377 | lang: Lang, |
| @@ -380,19 +380,19 @@ pub(crate) async fn branch_box( | |||
| 380 | ) -> Result<impl View> { | 380 | ) -> Result<impl View> { |
| 381 | let heading = crate::pages::passkeys::s(lang, "Branch", "Dal"); | 381 | let heading = crate::pages::passkeys::s(lang, "Branch", "Dal"); |
| 382 | Ok(view! { | 382 | Ok(view! { |
| 383 | - <section class="sec merge-box merge-muted"> | 383 | + <section class="sec"> |
| 384 | <h2>(heading)</h2> | 384 | <h2>(heading)</h2> |
| 385 | if let Some(text) = error { | 385 | if let Some(text) = error { |
| 386 | - <p class="alert merge-error" role="alert">(text.as_str())</p> | 386 | + <p class="alert" role="alert">(text.as_str())</p> |
| 387 | } | 387 | } |
| 388 | if let Some(a) = action { | 388 | if let Some(a) = action { |
| 389 | if a.restore { | 389 | if a.restore { |
| 390 | - <p class="state merge-headline">(g::t(lang, K::BranchPrefix)) <code>(a.branch.as_str())</code> (g::t(lang, K::BranchWasDeleted))</p> | 390 | + <p>(g::t(lang, K::BranchPrefix)) " " <code>(a.branch.as_str())</code> " " (g::t(lang, K::BranchWasDeleted))</p> |
| 391 | <div class="acts"> | 391 | <div class="acts"> |
| 392 | post_act(label: g::t(lang, K::RestoreBranch), action: a.action.as_str(), csrf: a.csrf.as_str()) | 392 | post_act(label: g::t(lang, K::RestoreBranch), action: a.action.as_str(), csrf: a.csrf.as_str()) |
| 393 | </div> | 393 | </div> |
| 394 | } else { | 394 | } else { |
| 395 | - <p class="state merge-headline">(g::t(lang, K::BranchPrefix)) <code>(a.branch.as_str())</code> (g::t(lang, K::BranchStillHere))</p> | 395 | + <p>(g::t(lang, K::BranchPrefix)) " " <code>(a.branch.as_str())</code> " " (g::t(lang, K::BranchStillHere))</p> |
| 396 | <div class="acts"> | 396 | <div class="acts"> |
| 397 | confirm_act(lang: lang, label: g::t(lang, K::DeleteBranch), action: a.action.as_str(), csrf: a.csrf.as_str(), | 397 | confirm_act(lang: lang, label: g::t(lang, K::DeleteBranch), action: a.action.as_str(), csrf: a.csrf.as_str(), |
| 398 | note: Some(crate::pages::passkeys::s(lang, "The branch is removed from the repo. Its commits stay in the pull request.", "Dal depodan kaldırılır. Commit'leri çekme isteğinde kalır.").to_owned())) | 398 | note: Some(crate::pages::passkeys::s(lang, "The branch is removed from the repo. Its commits stay in the pull request.", "Dal depodan kaldırılır. Commit'leri çekme isteğinde kalır.").to_owned())) |
crates/forge-web/src/pages/pull_files.rsmodified+271 -163
| @@ -1,13 +1,12 @@ | |||
| 1 | //! The Files changed tab of a pull request, `/{owner}/{repo}/pulls/{n}/files`. Each diff line has | 1 | //! The Files changed tab of a pull request, `/{owner}/{repo}/pulls/{n}/files`. Each diff line has |
| 2 | //! an anchor and a "+" link (`?comment=<file>:<old|new>:<line>`), which opens an inline comment | 2 | //! an anchor and a "+" link (`?comment=<file>:<old|new>:<line>`), which opens an inline comment |
| 3 | //! form under that line. Existing review threads render under their lines. Signed-in viewers see | 3 | //! form under that line. Existing review threads render under their lines. Signed-in viewers see |
| 4 | -//! the review bar at the top. The header and tabs come from `pull_view`. The review POST routes | 4 | +//! the decision pill under the diff. The header and tabs come from `pull_view`. The review POST |
| 5 | -//! are in `pull_reviews`. | 5 | +//! routes are in `pull_reviews`. |
| 6 | 6 | ||
| 7 | -use std::collections::HashMap; | 7 | +use std::collections::{HashMap, HashSet}; |
| 8 | use std::sync::Arc; | 8 | use std::sync::Arc; |
| 9 | 9 | ||
| 10 | -use forge_core::store::commit_status::StatusState; | ||
| 11 | use forge_core::{Action, IssueState, PullRequest, Side, Thread, authorize}; | 10 | use forge_core::{Action, IssueState, PullRequest, Side, Thread, authorize}; |
| 12 | use forge_git::command::ObjectSource; | 11 | use forge_git::command::ObjectSource; |
| 13 | use forge_git::history::{CommitDiff, DiffStatus, FileDiff}; | 12 | use forge_git::history::{CommitDiff, DiffStatus, FileDiff}; |
| @@ -23,23 +22,23 @@ use topcoat::view::{View, component, view}; | |||
| 23 | 22 | ||
| 24 | use crate::auth::require_user; | 23 | use crate::auth::require_user; |
| 25 | use crate::i18n::browse as b; | 24 | use crate::i18n::browse as b; |
| 25 | +use crate::i18n::pulls as review_strings; | ||
| 26 | use crate::i18n::pulls::{self as g, K}; | 26 | use crate::i18n::pulls::{self as g, K}; |
| 27 | use crate::i18n::{self, Lang}; | 27 | use crate::i18n::{self, Lang}; |
| 28 | use crate::pages::edit_history::thread_edit_counts; | 28 | use crate::pages::edit_history::thread_edit_counts; |
| 29 | use crate::pages::issue_parts::{ | 29 | use crate::pages::issue_parts::{ |
| 30 | - When, check_write, csrf_of, may_converse, parse_number, triage, viewer, | 30 | + check_write, csrf_of, may_converse, parse_number, triage, viewer, |
| 31 | }; | 31 | }; |
| 32 | use crate::pages::passkeys; | 32 | use crate::pages::passkeys; |
| 33 | use crate::pages::pull_reviews::{error_text_in, pull_diff, suggest_states}; | 33 | use crate::pages::pull_reviews::{error_text_in, pull_diff, suggest_states}; |
| 34 | -use crate::pages::pull_view::{commits_of, frame_in, is_merged, pull_header, pull_subnav_in}; | 34 | +use crate::pages::pull_view::{commits_of, frame_in, is_merged, pull_header}; |
| 35 | -use crate::pages::repo::repo_head; | ||
| 36 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; | 35 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 37 | use crate::pages::tree::link_context; | 36 | use crate::pages::tree::link_context; |
| 38 | use crate::state::AppState; | 37 | use crate::state::AppState; |
| 39 | use crate::views::diff::{DiffLang, DiffOpts, LIMITS, LineComments, diff_section}; | 38 | use crate::views::diff::{DiffLang, DiffOpts, LIMITS, LineComments, diff_section}; |
| 40 | -use crate::views::parts::confirm_act; | 39 | +use crate::views::parts::{confirm_act, seg_fr}; |
| 41 | use crate::views::review_thread::ThreadCtx; | 40 | use crate::views::review_thread::ThreadCtx; |
| 42 | -use crate::views::{alert, now_unix, repo_href, shell}; | 41 | +use crate::views::{alert, repo_href, shell}; |
| 43 | 42 | ||
| 44 | path_param!(owner); | 43 | path_param!(owner); |
| 45 | path_param!(repo); | 44 | path_param!(repo); |
| @@ -131,13 +130,14 @@ struct FileRow { | |||
| 131 | deletions: u32, | 130 | deletions: u32, |
| 132 | /// The file's index in the diff the page shows, when that diff lists it. | 131 | /// The file's index in the diff the page shows, when that diff lists it. |
| 133 | index: Option<usize>, | 132 | index: Option<usize>, |
| 133 | + /// A thread on this file is still open. | ||
| 134 | + commented: bool, | ||
| 134 | } | 135 | } |
| 135 | 136 | ||
| 136 | /// Where the viewed checkboxes post, for a signed-in viewer. | 137 | /// Where the viewed checkboxes post, for a signed-in viewer. |
| 137 | struct ViewedControls { | 138 | struct ViewedControls { |
| 138 | pr_href: String, | 139 | pr_href: String, |
| 139 | csrf: String, | 140 | csrf: String, |
| 140 | - archived: bool, | ||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | /// One row per file of the full diff. A mark counts only while its blob is the file's blob at the | 143 | /// One row per file of the full diff. A mark counts only while its blob is the file's blob at the |
| @@ -176,128 +176,78 @@ async fn file_rows( | |||
| 176 | additions: file.additions, | 176 | additions: file.additions, |
| 177 | deletions: file.deletions, | 177 | deletions: file.deletions, |
| 178 | index: file_index(shown, path), | 178 | index: file_index(shown, path), |
| 179 | + commented: false, | ||
| 179 | }); | 180 | }); |
| 180 | } | 181 | } |
| 181 | Ok(rows) | 182 | Ok(rows) |
| 182 | } | 183 | } |
| 183 | 184 | ||
| 184 | -/// What one Files pane row shows, with its classes and link worked out. | 185 | +/// One segment of the strip above the diff: one file, its size among the files, and its state. |
| 185 | -struct FileItem { | 186 | +struct SegView { |
| 186 | - path: String, | 187 | + class: String, |
| 188 | + href: String, | ||
| 187 | label: String, | 189 | label: String, |
| 188 | - class: &'static str, | 190 | +} |
| 191 | + | ||
| 192 | +/// One row of the Files rail, with its tick and counts worked out. | ||
| 193 | +struct RailFile { | ||
| 194 | + class: String, | ||
| 195 | + tick: String, | ||
| 189 | href: Option<String>, | 196 | href: Option<String>, |
| 197 | + path: String, | ||
| 198 | + label: String, | ||
| 190 | state: MarkState, | 199 | state: MarkState, |
| 191 | - additions: String, | 200 | + checked: bool, |
| 192 | - deletions: String, | 201 | + counts: String, |
| 193 | } | 202 | } |
| 194 | 203 | ||
| 195 | -/// The Files pane: `Files` with the viewer's `N of M viewed`, then one 36px row per file with its | 204 | +/// The Files rail: one row per file of the full diff, with its viewed tick, its name and its |
| 196 | -/// icon, its path, its counts and, for a signed-in viewer, the Viewed checkbox. A row links to its | 205 | +/// counts. A row links to its file in the diff. For a signed-in viewer the tick is the Viewed |
| 197 | -/// file in the diff pane. The checkbox posts to the pull's `viewed` route from nav.js and shows the | 206 | +/// toggle, and a changed file says so. |
| 198 | -/// new state only after the server answered; a changed file says so. | ||
| 199 | #[component] | 207 | #[component] |
| 200 | -async fn files_pane( | 208 | +async fn files_rail( |
| 201 | lang: Lang, | 209 | lang: Lang, |
| 202 | - rows: Vec<FileRow>, | 210 | + rows: Vec<RailFile>, |
| 203 | - selected: Option<usize>, | 211 | + done_text: String, |
| 204 | - controls: Option<ViewedControls>, | 212 | + signed_in: bool, |
| 213 | + archived: bool, | ||
| 205 | ) -> Result<impl View> { | 214 | ) -> Result<impl View> { |
| 206 | - let signed_in = controls.is_some(); | ||
| 207 | - let total = rows.len(); | ||
| 208 | - let done = rows | ||
| 209 | - .iter() | ||
| 210 | - .filter(|row| row.state == MarkState::Viewed) | ||
| 211 | - .count(); | ||
| 212 | - let count = if signed_in { | ||
| 213 | - g::viewed_count(lang, done, total) | ||
| 214 | - } else { | ||
| 215 | - String::new() | ||
| 216 | - }; | ||
| 217 | - let (action, csrf, archived) = match controls { | ||
| 218 | - Some(c) => (format!("{}/viewed", c.pr_href), c.csrf, c.archived), | ||
| 219 | - None => (String::new(), String::new(), false), | ||
| 220 | - }; | ||
| 221 | - let items: Vec<FileItem> = rows | ||
| 222 | - .into_iter() | ||
| 223 | - .map(|row| { | ||
| 224 | - let current = row.index.is_some() && row.index == selected; | ||
| 225 | - FileItem { | ||
| 226 | - href: row.index.map(|i| format!("?file={i}#file-{}", i + 1)), | ||
| 227 | - class: if current { | ||
| 228 | - "line pull-file current" | ||
| 229 | - } else { | ||
| 230 | - "line pull-file" | ||
| 231 | - }, | ||
| 232 | - additions: format!("+{}", row.additions), | ||
| 233 | - deletions: format!("\u{2212}{}", row.deletions), | ||
| 234 | - path: row.path, | ||
| 235 | - label: row.label, | ||
| 236 | - state: row.state, | ||
| 237 | - } | ||
| 238 | - }) | ||
| 239 | - .collect(); | ||
| 240 | let mark = g::t(lang, K::ViewedMark); | 215 | let mark = g::t(lang, K::ViewedMark); |
| 241 | let changed = g::t(lang, K::ChangedSinceViewed); | 216 | let changed = g::t(lang, K::ChangedSinceViewed); |
| 242 | - let heading = passkeys::s(lang, "Files", "Dosyalar"); | ||
| 243 | let hint = g::t(lang, K::ViewedHint); | 217 | let hint = g::t(lang, K::ViewedHint); |
| 244 | let viewed_files = g::t(lang, K::ViewedFiles); | 218 | let viewed_files = g::t(lang, K::ViewedFiles); |
| 219 | + let heading = passkeys::s(lang, "Files", "Dosyalar"); | ||
| 245 | Ok(view! { | 220 | Ok(view! { |
| 246 | - <section class="sec pull-files" data-viewed-panel="" data-action=(action.as_str()) data-csrf=(csrf.as_str()) aria-label=(viewed_files)> | 221 | + <nav class="rail" aria-label=(viewed_files)> |
| 247 | - <h2>(heading)</h2> | 222 | + <h2>(heading) " " <span title=(hint)>(done_text.as_str())</span></h2> |
| 248 | - if signed_in { | 223 | + <div class="rail-list"> |
| 249 | - <p class="hint" title=(hint)>(count.as_str())</p> | 224 | + for file in rows.into_iter() { |
| 250 | - } | 225 | + <div class=(file.class.as_str()) data-viewed-row="" data-state=(file.state.name()) data-label=(file.label.as_str())> |
| 251 | - <div> | 226 | + if signed_in && !archived { |
| 252 | - for item in items.into_iter() { | 227 | + <label class="tick-toggle" title=(mark)> |
| 253 | - <div class=(item.class) data-viewed-row="" data-state=(item.state.name()) data-label=(item.label.as_str())> | 228 | + if file.checked { |
| 254 | - if let Some(href) = item.href { | 229 | + <input class="sr-only" type="checkbox" checked="" data-viewed-toggle="" data-path=(file.path.as_str())> |
| 255 | - <a class="name pull-file-link" href=(href.as_str())><span class="mono clip">(item.path.as_str())</span></a> | 230 | + } else { |
| 231 | + <input class="sr-only" type="checkbox" data-viewed-toggle="" data-path=(file.path.as_str())> | ||
| 232 | + } | ||
| 233 | + <i class=(file.tick.as_str())></i> | ||
| 234 | + </label> | ||
| 256 | } else { | 235 | } else { |
| 257 | - <span class="name pull-file-link"><span class="mono clip">(item.path.as_str())</span></span> | 236 | + <i class=(file.tick.as_str())></i> |
| 258 | } | 237 | } |
| 259 | - <span class="val pull-counts"><span class="ok">(item.additions.as_str())</span> <span class="bad">(item.deletions.as_str())</span></span> | 238 | + if let Some(href) = file.href { |
| 260 | - if item.state == MarkState::Changed { | 239 | + <a class="nm" href=(href.as_str())>(file.path.as_str())</a> |
| 261 | - <span class="viewed-note">(changed)</span> | 240 | + } else { |
| 241 | + <span class="nm">(file.path.as_str())</span> | ||
| 262 | } | 242 | } |
| 263 | - if signed_in && !archived { | 243 | + <span class="val">(file.counts.as_str())</span> |
| 264 | - if item.state == MarkState::Viewed { | 244 | + if file.state == MarkState::Changed { |
| 265 | - <label class="switch"><input type="checkbox" checked="" data-viewed-toggle="" data-path=(item.path.as_str())><span>(mark)</span></label> | 245 | + <span class="hint">(changed)</span> |
| 266 | - } else { | ||
| 267 | - <label class="switch"><input type="checkbox" data-viewed-toggle="" data-path=(item.path.as_str())><span>(mark)</span></label> | ||
| 268 | - } | ||
| 269 | } | 246 | } |
| 270 | </div> | 247 | </div> |
| 271 | } | 248 | } |
| 272 | </div> | 249 | </div> |
| 273 | - </section> | 250 | + </nav> |
| 274 | - }) | ||
| 275 | -} | ||
| 276 | - | ||
| 277 | -/// One status context in the Checks pane: its dot, its name and how long ago it last reported. | ||
| 278 | -struct CheckItem { | ||
| 279 | - context: String, | ||
| 280 | - dot: &'static str, | ||
| 281 | - when: String, | ||
| 282 | -} | ||
| 283 | - | ||
| 284 | -/// The Checks pane: the head commit's contexts with a dot, the name and the time of the last report. | ||
| 285 | -#[component] | ||
| 286 | -async fn checks_pane(lang: Lang, items: Vec<CheckItem>) -> Result<impl View> { | ||
| 287 | - let heading = passkeys::s(lang, "Checks", "Kontroller"); | ||
| 288 | - Ok(view! { | ||
| 289 | - <section class="sec pull-checks"> | ||
| 290 | - <h2>(heading)</h2> | ||
| 291 | - <div> | ||
| 292 | - for item in items.into_iter() { | ||
| 293 | - <div class="line"> | ||
| 294 | - <span class=(item.dot)></span> | ||
| 295 | - <span class="name clip">(item.context.as_str())</span> | ||
| 296 | - <span class="val"><time class="pull-time">(item.when.as_str())</time></span> | ||
| 297 | - </div> | ||
| 298 | - } | ||
| 299 | - </div> | ||
| 300 | - </section> | ||
| 301 | }) | 251 | }) |
| 302 | } | 252 | } |
| 303 | 253 | ||
| @@ -380,41 +330,85 @@ async fn viewed_post(cx: &Cx, Form(form): Form<ViewedForm>) -> Result<SeeOther> | |||
| 380 | Ok(see_other(files)) | 330 | Ok(see_other(files)) |
| 381 | } | 331 | } |
| 382 | 332 | ||
| 383 | -/// The review compose box at the foot of the diff pane. It shows one line, the summary, and the | 333 | +/// The decision pill under the diff: the viewed count, the open threads, the next unviewed file and |
| 384 | -/// Comment button. Focusing the line opens the rest: the pending count and Discard. Approve and | 334 | +/// Finish review. Finish review opens the review form in a panel above the pill. Approve and |
| 385 | -/// Request changes are in the pull's head and submit this same form. | 335 | +/// Request changes in the pull's head submit the same form. |
| 386 | #[component] | 336 | #[component] |
| 387 | async fn review_bar( | 337 | async fn review_bar( |
| 388 | lang: Lang, | 338 | lang: Lang, |
| 389 | pr_href: String, | 339 | pr_href: String, |
| 390 | csrf: String, | 340 | csrf: String, |
| 391 | pending: usize, | 341 | pending: usize, |
| 342 | + viewed_text: String, | ||
| 343 | + open_threads: usize, | ||
| 344 | + next: Option<String>, | ||
| 345 | + is_author: bool, | ||
| 392 | ) -> Result<impl View> { | 346 | ) -> Result<impl View> { |
| 393 | let reviews_action = format!("{pr_href}/reviews"); | 347 | let reviews_action = format!("{pr_href}/reviews"); |
| 394 | let discard_action = format!("{pr_href}/reviews/discard"); | 348 | let discard_action = format!("{pr_href}/reviews/discard"); |
| 395 | - let pending_text = g::pending_comments(lang, pending); | 349 | + let pending_text = match (lang, pending) { |
| 350 | + (_, 0) => String::new(), | ||
| 351 | + (Lang::En, 1) => "1 comment included".to_owned(), | ||
| 352 | + (Lang::En, n) => format!("{n} comments included"), | ||
| 353 | + (Lang::Tr, n) => format!("{n} yorum dahil"), | ||
| 354 | + }; | ||
| 396 | let finish = g::t(lang, K::FinishReview); | 355 | let finish = g::t(lang, K::FinishReview); |
| 397 | let discard = g::t(lang, K::DiscardPending); | 356 | let discard = g::t(lang, K::DiscardPending); |
| 398 | let summary = g::t(lang, K::ReviewSummary); | 357 | let summary = g::t(lang, K::ReviewSummary); |
| 399 | let submit = g::t(lang, K::SubmitReview); | 358 | let submit = g::t(lang, K::SubmitReview); |
| 400 | let comment = g::t(lang, K::CommentChoice).trim(); | 359 | let comment = g::t(lang, K::CommentChoice).trim(); |
| 401 | - let placeholder = passkeys::s(lang, "Leave a comment", "Yorum bırakın"); | 360 | + let approve = review_strings::t(lang, review_strings::K::ApproveChoice).trim(); |
| 361 | + let changes = review_strings::t(lang, review_strings::K::RequestChangesChoice).trim(); | ||
| 362 | + let placeholder = passkeys::s(lang, "Optional", "İsteğe bağlı"); | ||
| 363 | + let next_text = passkeys::s(lang, "Next file", "Sonraki dosya"); | ||
| 364 | + let approve_hint = passkeys::s(lang, "Ready to merge", "Birleştirmeye hazır"); | ||
| 365 | + let changes_hint = passkeys::s( | ||
| 366 | + lang, | ||
| 367 | + "Blocks the merge until you approve", | ||
| 368 | + "Siz onaylayana kadar birleştirmeyi engeller", | ||
| 369 | + ); | ||
| 370 | + let comment_hint = passkeys::s(lang, "No decision", "Karar yok"); | ||
| 371 | + let threads_text = match lang { | ||
| 372 | + Lang::Tr => format!("{open_threads} açık konu"), | ||
| 373 | + Lang::En if open_threads == 1 => "1 open thread".to_owned(), | ||
| 374 | + Lang::En => format!("{open_threads} open threads"), | ||
| 375 | + }; | ||
| 402 | Ok(view! { | 376 | Ok(view! { |
| 403 | - <section class="sec pull-compose"> | 377 | + <div class="decide"> |
| 404 | - <h2>(finish)</h2> | 378 | + <span class="stat">(viewed_text.as_str())</span> |
| 405 | - <p class="hint">(pending_text.as_str())</p> | 379 | + <span class="stat">(threads_text.as_str())</span> |
| 406 | - <form id="review-form" method="post" action=(reviews_action.as_str()) class="fields" aria-label=(submit)> | 380 | + if let Some(href) = next { |
| 407 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 381 | + <a class="button small" href=(href.as_str())>(next_text)</a> |
| 408 | - <div class="field"> | 382 | + } |
| 409 | - <label for="review-body">(summary)</label> | 383 | + <details class="decide-open"> |
| 410 | - <input id="review-body" class="pull-input" type="text" name="body" placeholder=(placeholder)> | 384 | + <summary class="button primary">(finish)</summary> |
| 385 | + <div class="decide-panel"> | ||
| 386 | + <h3>(finish)</h3> | ||
| 387 | + <form id="review-form" method="post" action=(reviews_action.as_str()) class="fields" aria-label=(submit)> | ||
| 388 | + <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 389 | + <div class="field"> | ||
| 390 | + <label for="review-body">(summary)</label> | ||
| 391 | + <textarea id="review-body" name="body" rows="3" placeholder=(placeholder)></textarea> | ||
| 392 | + </div> | ||
| 393 | + // An author cannot approve or block their own pull, so they only comment. | ||
| 394 | + if !is_author { | ||
| 395 | + <label class="opt"><input type="radio" name="state" value="approve"><span>(approve)<small>(approve_hint)</small></span></label> | ||
| 396 | + <label class="opt"><input type="radio" name="state" value="request_changes"><span>(changes)<small>(changes_hint)</small></span></label> | ||
| 397 | + } | ||
| 398 | + <label class="opt"><input type="radio" name="state" value="comment" checked=(true)><span>(comment)<small>(comment_hint)</small></span></label> | ||
| 399 | + <div class="acts decide-send"> | ||
| 400 | + <button type="submit" class="primary">(submit)</button> | ||
| 401 | + <span class="hint">(pending_text.as_str())</span> | ||
| 402 | + </div> | ||
| 403 | + </form> | ||
| 404 | + if pending > 0 { | ||
| 405 | + <div class="acts"> | ||
| 406 | + confirm_act(lang: lang, label: discard, action: discard_action.as_str(), csrf: csrf.as_str()) | ||
| 407 | + </div> | ||
| 408 | + } | ||
| 411 | </div> | 409 | </div> |
| 412 | - <button type="submit" class="primary" name="state" value="comment">(comment)</button> | 410 | + </details> |
| 413 | - </form> | 411 | + </div> |
| 414 | - <div class="acts"> | ||
| 415 | - confirm_act(lang: lang, label: discard, action: discard_action.as_str(), csrf: csrf.as_str()) | ||
| 416 | - </div> | ||
| 417 | - </section> | ||
| 418 | }) | 412 | }) |
| 419 | } | 413 | } |
| 420 | 414 | ||
| @@ -459,7 +453,6 @@ async fn pull_files(cx: &Cx) -> Result<impl View> { | |||
| 459 | let controls = viewer_user.as_ref().map(|_| ViewedControls { | 453 | let controls = viewer_user.as_ref().map(|_| ViewedControls { |
| 460 | pr_href: frame.href.clone(), | 454 | pr_href: frame.href.clone(), |
| 461 | csrf: csrf_of(&ctx), | 455 | csrf: csrf_of(&ctx), |
| 462 | - archived: ctx.repo.archived, | ||
| 463 | }); | 456 | }); |
| 464 | // With whitespace ignored the file list can shrink, so file indexes differ from the comment | 457 | // With whitespace ignored the file list can shrink, so file indexes differ from the comment |
| 465 | // routes' view. Existing threads still show; new inline comments wait for the full diff. | 458 | // routes' view. Existing threads still show; new inline comments wait for the full diff. |
| @@ -480,21 +473,10 @@ async fn pull_files(cx: &Cx) -> Result<impl View> { | |||
| 480 | None | 473 | None |
| 481 | }; | 474 | }; |
| 482 | let diff: &CommitDiff = shown_ws.as_ref().unwrap_or(&full_diff); | 475 | let diff: &CommitDiff = shown_ws.as_ref().unwrap_or(&full_diff); |
| 483 | - let rows = file_rows(state, &ctx, &pr, &full_diff, diff, marks.as_ref()).await?; | 476 | + let mut rows = file_rows(state, &ctx, &pr, &full_diff, diff, marks.as_ref()).await?; |
| 484 | - let selected = file_param(cx).or((!diff.files.is_empty()).then_some(0)); | 477 | + let selected = file_param(cx) |
| 485 | - let statuses = state.store.statuses_for(&ctx.repo.id, &pr.head_oid).await?; | 478 | + .or(comment_target(cx).map(|(index, ..)| index)) |
| 486 | - let checks: Vec<CheckItem> = statuses | 479 | + .or((!diff.files.is_empty()).then_some(0)); |
| 487 | - .iter() | ||
| 488 | - .map(|status| CheckItem { | ||
| 489 | - context: status.context.clone(), | ||
| 490 | - dot: match status.state { | ||
| 491 | - StatusState::Success => "dot ok", | ||
| 492 | - StatusState::Failure | StatusState::Error => "dot bad", | ||
| 493 | - StatusState::Pending => "dot live", | ||
| 494 | - }, | ||
| 495 | - when: When::new(lang, &status.updated_at, ctx.viewer_tz(), now_unix()).relative, | ||
| 496 | - }) | ||
| 497 | - .collect(); | ||
| 498 | 480 | ||
| 499 | let viewer_id = viewer_user.as_ref().map(|user| user.id.clone()); | 481 | let viewer_id = viewer_user.as_ref().map(|user| user.id.clone()); |
| 500 | let signed_in = viewer_id.is_some(); | 482 | let signed_in = viewer_id.is_some(); |
| @@ -514,7 +496,6 @@ async fn pull_files(cx: &Cx) -> Result<impl View> { | |||
| 514 | // Comments and replies stay open on a closed pull request; new reviews do not. | 496 | // Comments and replies stay open on a closed pull request; new reviews do not. |
| 515 | let can_review = can_comment && open; | 497 | let can_review = can_comment && open; |
| 516 | // Approve and request changes are offered to every viewer who may review but did not open it. | 498 | // Approve and request changes are offered to every viewer who may review but did not open it. |
| 517 | - frame.head_review = can_review && !is_author; | ||
| 518 | let href = frame.href.clone(); | 499 | let href = frame.href.clone(); |
| 519 | let csrf = csrf_of(&ctx); | 500 | let csrf = csrf_of(&ctx); |
| 520 | 501 | ||
| @@ -525,6 +506,18 @@ async fn pull_files(cx: &Cx) -> Result<impl View> { | |||
| 525 | .review_threads(&pr.issue.id, viewer_id.as_deref()) | 506 | .review_threads(&pr.issue.id, viewer_id.as_deref()) |
| 526 | .await?; | 507 | .await?; |
| 527 | let pending = threads.iter().filter(|t| t.root.pending).count(); | 508 | let pending = threads.iter().filter(|t| t.root.pending).count(); |
| 509 | + let open_threads = threads | ||
| 510 | + .iter() | ||
| 511 | + .filter(|t| !t.root.outdated && !t.root.resolved) | ||
| 512 | + .count(); | ||
| 513 | + let commented: HashSet<String> = threads | ||
| 514 | + .iter() | ||
| 515 | + .filter(|t| !t.root.outdated) | ||
| 516 | + .map(|t| t.root.path.clone()) | ||
| 517 | + .collect(); | ||
| 518 | + for row in rows.iter_mut() { | ||
| 519 | + row.commented = commented.contains(&row.path); | ||
| 520 | + } | ||
| 528 | let edits = thread_edit_counts(state, &threads).await?; | 521 | let edits = thread_edit_counts(state, &threads).await?; |
| 529 | let suggest = suggest_states(state, &ctx, &pr, viewer(&ctx), &threads).await?; | 522 | let suggest = suggest_states(state, &ctx, &pr, viewer(&ctx), &threads).await?; |
| 530 | let mut by_line: HashMap<(usize, Side, u32), Vec<Thread>> = HashMap::new(); | 523 | let mut by_line: HashMap<(usize, Side, u32), Vec<Thread>> = HashMap::new(); |
| @@ -566,6 +559,7 @@ async fn pull_files(cx: &Cx) -> Result<impl View> { | |||
| 566 | // The diff pane has its own top row, so the section's toolbar is left off. | 559 | // The diff pane has its own top row, so the section's toolbar is left off. |
| 567 | let mut section_opts = opts.clone(); | 560 | let mut section_opts = opts.clone(); |
| 568 | section_opts.enabled = false; | 561 | section_opts.enabled = false; |
| 562 | + section_opts.only = selected; | ||
| 569 | let unified_href = opts.href(false, opts.ignore_ws); | 563 | let unified_href = opts.href(false, opts.ignore_ws); |
| 570 | let split_href = opts.href(true, opts.ignore_ws); | 564 | let split_href = opts.href(true, opts.ignore_ws); |
| 571 | let ws_href = opts.href(opts.split, !opts.ignore_ws); | 565 | let ws_href = opts.href(opts.split, !opts.ignore_ws); |
| @@ -579,28 +573,141 @@ async fn pull_files(cx: &Cx) -> Result<impl View> { | |||
| 579 | let name = ctx.repo.name.clone(); | 573 | let name = ctx.repo.name.clone(); |
| 580 | let parent = pr.merge_base.clone(); | 574 | let parent = pr.merge_base.clone(); |
| 581 | let page_title = frame.page_title.clone(); | 575 | let page_title = frame.page_title.clone(); |
| 582 | - let header = ctx.head(state, "pulls").await?; | 576 | + let panel_action = controls |
| 577 | + .as_ref() | ||
| 578 | + .map(|c| format!("{}/viewed", c.pr_href)) | ||
| 579 | + .unwrap_or_default(); | ||
| 580 | + let panel_csrf = controls.as_ref().map(|c| c.csrf.clone()).unwrap_or_default(); | ||
| 581 | + | ||
| 582 | + let done = rows | ||
| 583 | + .iter() | ||
| 584 | + .filter(|row| row.state == MarkState::Viewed) | ||
| 585 | + .count(); | ||
| 586 | + let total = rows.len(); | ||
| 587 | + let viewed_text = g::viewed_count(lang, done, total); | ||
| 588 | + let mark_text = g::t(lang, K::ViewedMark); | ||
| 589 | + let total_changed: u64 = rows | ||
| 590 | + .iter() | ||
| 591 | + .map(|row| u64::from(row.additions) + u64::from(row.deletions)) | ||
| 592 | + .sum(); | ||
| 593 | + let current = rows | ||
| 594 | + .iter() | ||
| 595 | + .find(|row| row.index.is_some() && row.index == selected); | ||
| 596 | + let current_head = current.map(|row| { | ||
| 597 | + ( | ||
| 598 | + row.path.clone(), | ||
| 599 | + format!("+{} \u{2212}{}", row.additions, row.deletions), | ||
| 600 | + ) | ||
| 601 | + }); | ||
| 602 | + let current_path = current.map(|row| row.path.clone()).unwrap_or_default(); | ||
| 603 | + let current_viewed = current.is_some_and(|row| row.state == MarkState::Viewed); | ||
| 604 | + let mark_shown = signed_in && !archived && current.is_some(); | ||
| 605 | + // The next file after the current one that is not viewed, wrapping round. | ||
| 606 | + let next = { | ||
| 607 | + let start = rows | ||
| 608 | + .iter() | ||
| 609 | + .position(|row| row.index.is_some() && row.index == selected) | ||
| 610 | + .map_or(0, |p| p + 1); | ||
| 611 | + rows.iter() | ||
| 612 | + .cycle() | ||
| 613 | + .skip(start) | ||
| 614 | + .take(total) | ||
| 615 | + .find(|row| { | ||
| 616 | + row.index.is_some() && row.index != selected && row.state != MarkState::Viewed | ||
| 617 | + }) | ||
| 618 | + .and_then(|row| row.index) | ||
| 619 | + .map(|i| format!("?file={i}#file-{}", i + 1)) | ||
| 620 | + }; | ||
| 621 | + // The strip above the diff: one segment per file, sized by its changed lines. | ||
| 622 | + let segs: Vec<SegView> = rows | ||
| 623 | + .iter() | ||
| 624 | + .map(|row| { | ||
| 625 | + let is_current = row.index.is_some() && row.index == selected; | ||
| 626 | + let fr = seg_fr( | ||
| 627 | + u64::from(row.additions) + u64::from(row.deletions), | ||
| 628 | + total_changed, | ||
| 629 | + ); | ||
| 630 | + let state = if is_current { | ||
| 631 | + "sel" | ||
| 632 | + } else if row.state == MarkState::Viewed { | ||
| 633 | + "" | ||
| 634 | + } else { | ||
| 635 | + "wait" | ||
| 636 | + }; | ||
| 637 | + SegView { | ||
| 638 | + class: format!("seg {fr} {state}").trim_end().to_owned(), | ||
| 639 | + href: row | ||
| 640 | + .index | ||
| 641 | + .map_or_else(|| "#".to_owned(), |i| format!("?file={i}#file-{}", i + 1)), | ||
| 642 | + label: row.path.clone(), | ||
| 643 | + } | ||
| 644 | + }) | ||
| 645 | + .collect(); | ||
| 646 | + let rail: Vec<RailFile> = rows | ||
| 647 | + .into_iter() | ||
| 648 | + .map(|row| { | ||
| 649 | + let is_current = row.index.is_some() && row.index == selected; | ||
| 650 | + let mut tick = String::from("tick"); | ||
| 651 | + if row.state == MarkState::Viewed { | ||
| 652 | + tick.push_str(" on"); | ||
| 653 | + } | ||
| 654 | + if row.commented { | ||
| 655 | + tick.push_str(" cm"); | ||
| 656 | + } | ||
| 657 | + RailFile { | ||
| 658 | + class: if is_current { | ||
| 659 | + "rail-item file sel" | ||
| 660 | + } else { | ||
| 661 | + "rail-item file" | ||
| 662 | + } | ||
| 663 | + .to_owned(), | ||
| 664 | + tick, | ||
| 665 | + href: row | ||
| 666 | + .index | ||
| 667 | + .map(|i| format!("?file={i}#file-{}", i + 1)), | ||
| 668 | + path: row.path, | ||
| 669 | + label: row.label, | ||
| 670 | + state: row.state, | ||
| 671 | + checked: row.state == MarkState::Viewed, | ||
| 672 | + counts: format!("+{} \u{2212}{}", row.additions, row.deletions), | ||
| 673 | + } | ||
| 674 | + }) | ||
| 675 | + .collect(); | ||
| 676 | + | ||
| 583 | Ok(view! { | 677 | Ok(view! { |
| 584 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 678 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 585 | - repo_head(head: header) | 679 | + pull_header(frame: frame.clone(), active: "files".to_owned()) |
| 586 | - pull_header(frame: frame.clone()) | 680 | + <div class="strip files"> |
| 587 | - pull_subnav_in(lang: lang, href: href.clone(), active: "files".to_owned(), | 681 | + for seg in segs.into_iter() { |
| 588 | - commits: frame.commit_count, files: frame.file_count) | 682 | + <a class=(seg.class.as_str()) href=(seg.href.as_str()) aria-label=(seg.label.as_str())><span class="bar"></span></a> |
| 683 | + } | ||
| 684 | + </div> | ||
| 589 | if let Some(message) = error { | 685 | if let Some(message) = error { |
| 590 | alert(message: message.as_str()) | 686 | alert(message: message.as_str()) |
| 591 | } | 687 | } |
| 592 | - <div class="pull-page" data-live=(live.as_str())> | 688 | + <div class="work" data-live=(live.as_str()) data-viewed-panel="" data-action=(panel_action.as_str()) data-csrf=(panel_csrf.as_str())> |
| 593 | - files_pane(lang: lang, rows: rows, selected: selected, controls: controls) | 689 | + files_rail(lang: lang, rows: rail, done_text: viewed_text.clone(), signed_in: signed_in, archived: archived) |
| 594 | - checks_pane(lang: lang, items: checks) | 690 | + <div class="work-main"> |
| 595 | - diff_top(lang: lang, unified: unified_href, split: split_href, ws: ws_href, split_on: split_on, ws_on: ws_on) | 691 | + <div class="sheet"> |
| 596 | - <div class="pull-diff"> | 692 | + <div class="sheet-tools"> |
| 597 | - diff_section(diff: &diff, owner: owner.as_str(), repo: name.as_str(), | 693 | + if let Some((path, counts)) = current_head { |
| 598 | - oid: pr.head_oid.as_str(), parent: parent.as_deref(), | 694 | + <strong>(path.as_str())</strong> |
| 599 | - subject: g::t(lang, K::ThisPullRequest), lang: DiffLang(lang), comments: comments, opts: section_opts) | 695 | + <span class="mono">(counts.as_str())</span> |
| 696 | + } | ||
| 697 | + if mark_shown { | ||
| 698 | + <label class="switch"><input type="checkbox" checked=(current_viewed) data-viewed-toggle="" data-path=(current_path.as_str())><span>(mark_text)</span></label> | ||
| 699 | + } | ||
| 700 | + diff_top(lang: lang, unified: unified_href, split: split_href, ws: ws_href, split_on: split_on, ws_on: ws_on) | ||
| 701 | + </div> | ||
| 702 | + diff_section(diff: &diff, owner: owner.as_str(), repo: name.as_str(), | ||
| 703 | + oid: pr.head_oid.as_str(), parent: parent.as_deref(), | ||
| 704 | + subject: g::t(lang, K::ThisPullRequest), lang: DiffLang(lang), comments: comments, opts: section_opts) | ||
| 705 | + </div> | ||
| 706 | + if can_review { | ||
| 707 | + review_bar(lang: lang, pr_href: href.clone(), csrf: csrf.clone(), pending: pending, | ||
| 708 | + viewed_text: viewed_text, open_threads: open_threads, next: next, is_author: is_author) | ||
| 709 | + } | ||
| 600 | </div> | 710 | </div> |
| 601 | - if can_review { | ||
| 602 | - review_bar(lang: lang, pr_href: href.clone(), csrf: csrf.clone(), pending: pending) | ||
| 603 | - } | ||
| 604 | </div> | 711 | </div> |
| 605 | ) | 712 | ) |
| 606 | }) | 713 | }) |
| @@ -757,8 +864,9 @@ mod tests { | |||
| 757 | let bytes = to_bytes(res.into_body(), usize::MAX).await.unwrap(); | 864 | let bytes = to_bytes(res.into_body(), usize::MAX).await.unwrap(); |
| 758 | let body = String::from_utf8_lossy(&bytes).into_owned(); | 865 | let body = String::from_utf8_lossy(&bytes).into_owned(); |
| 759 | assert!(body.contains("İncelemeyi tamamla"), "turkish bar: {body}"); | 866 | assert!(body.contains("İncelemeyi tamamla"), "turkish bar: {body}"); |
| 867 | + // With nothing pending there is nothing to discard. | ||
| 760 | assert!( | 868 | assert!( |
| 761 | - body.contains("Bekleyen yorumları sil"), | 869 | + !body.contains("Bekleyen yorumları sil"), |
| 762 | "turkish bar: {body}" | 870 | "turkish bar: {body}" |
| 763 | ); | 871 | ); |
| 764 | 872 | ||
| @@ -883,7 +991,7 @@ mod tests { | |||
| 883 | assert_eq!(status, 200, "outdated"); | 991 | assert_eq!(status, 200, "outdated"); |
| 884 | assert!(!body.contains("Stale remark"), "outdated: {body}"); | 992 | assert!(!body.contains("Stale remark"), "outdated: {body}"); |
| 885 | assert!( | 993 | assert!( |
| 886 | - !body.contains("class=\"review-thread\""), | 994 | + !body.contains("class=\"row-open review-thread\""), |
| 887 | "outdated: {body}" | 995 | "outdated: {body}" |
| 888 | ); | 996 | ); |
| 889 | 997 | ||
| @@ -910,7 +1018,7 @@ mod tests { | |||
| 910 | assert!(author.contains("Draft secret"), "pending author: {author}"); | 1018 | assert!(author.contains("Draft secret"), "pending author: {author}"); |
| 911 | assert!(author.contains("Pending"), "pending author: {author}"); | 1019 | assert!(author.contains("Pending"), "pending author: {author}"); |
| 912 | assert!( | 1020 | assert!( |
| 913 | - author.contains("1 pending comment."), | 1021 | + author.contains("1 comment included"), |
| 914 | "pending author: {author}" | 1022 | "pending author: {author}" |
| 915 | ); | 1023 | ); |
| 916 | 1024 | ||
| @@ -933,7 +1041,7 @@ mod tests { | |||
| 933 | assert_eq!(status, 200, "thread"); | 1041 | assert_eq!(status, 200, "thread"); |
| 934 | assert!(body.contains("Looks good"), "thread: {body}"); | 1042 | assert!(body.contains("Looks good"), "thread: {body}"); |
| 935 | let line = body.find("id=\"L-0-new-1\"").unwrap(); | 1043 | let line = body.find("id=\"L-0-new-1\"").unwrap(); |
| 936 | - let thread = body.find("class=\"review-thread\"").unwrap(); | 1044 | + let thread = body.find("class=\"row-open review-thread\"").unwrap(); |
| 937 | assert!(thread > line, "the thread sits after its line"); | 1045 | assert!(thread > line, "the thread sits after its line"); |
| 938 | } | 1046 | } |
| 939 | 1047 | ||
crates/forge-web/src/pages/pull_reviews.rsmodified+11 -12
| @@ -483,24 +483,23 @@ async fn edit_page( | |||
| 483 | let header = ctx.head(state, "pulls").await?; | 483 | let header = ctx.head(state, "pulls").await?; |
| 484 | Ok(view! { cx => | 484 | Ok(view! { cx => |
| 485 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 485 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 486 | - repo_head(head: header) | 486 | + repo_head(head: header, title: Some(heading.to_owned())) |
| 487 | - <section class="sec"> | 487 | + <div class="sheet fit"> |
| 488 | - <h2>(heading)</h2> | ||
| 489 | if let Some(message) = error { | 488 | if let Some(message) = error { |
| 490 | alert(message: message) | 489 | alert(message: message) |
| 491 | } | 490 | } |
| 492 | <form method="post" action=(action.as_str()) class="fields"> | 491 | <form method="post" action=(action.as_str()) class="fields"> |
| 493 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 492 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 494 | - <label class="field"> | 493 | + <div class="field"> |
| 495 | - <span>(comment_label)</span> | 494 | + <label for="review-body">(comment_label)</label> |
| 496 | - <textarea name="body" rows="10">(comment.body.as_str())</textarea> | 495 | + <textarea id="review-body" name="body" rows="10">(comment.body.as_str())</textarea> |
| 497 | - </label> | 496 | + </div> |
| 498 | - <button type="submit" class="primary">(save_label)</button> | 497 | + <div class="acts"> |
| 498 | + <button type="submit" class="primary">(save_label)</button> | ||
| 499 | + <a class="act" href=(back.as_str())>(cancel_label)</a> | ||
| 500 | + </div> | ||
| 499 | </form> | 501 | </form> |
| 500 | - <div class="acts"> | 502 | + </div> |
| 501 | - <a class="act quiet" href=(back.as_str())>(cancel_label)</a> | ||
| 502 | - </div> | ||
| 503 | - </section> | ||
| 504 | ) | 503 | ) |
| 505 | }) | 504 | }) |
| 506 | } | 505 | } |
crates/forge-web/src/pages/pull_view.rsmodified+68 -104
| @@ -20,7 +20,6 @@ use topcoat::router::{page, path_param}; | |||
| 20 | use topcoat::view::{View, component, view}; | 20 | use topcoat::view::{View, component, view}; |
| 21 | 21 | ||
| 22 | use crate::auth::require_user; | 22 | use crate::auth::require_user; |
| 23 | -use crate::i18n::pulls as review_strings; | ||
| 24 | use crate::i18n::pulls_review::{self as g, K}; | 23 | use crate::i18n::pulls_review::{self as g, K}; |
| 25 | use crate::i18n::{self, Lang}; | 24 | use crate::i18n::{self, Lang}; |
| 26 | use crate::pages::commits::{CommitRow, now_secs}; | 25 | use crate::pages::commits::{CommitRow, now_secs}; |
| @@ -40,7 +39,6 @@ use crate::pages::pulls_merge::{ | |||
| 40 | ERR_NOT_UP_TO_DATE, ERR_QUEUE_ALREADY, ERR_QUEUE_REQUIRED, ERR_REBASE_CONFLICT, ERR_UP_TO_DATE, | 39 | ERR_NOT_UP_TO_DATE, ERR_QUEUE_ALREADY, ERR_QUEUE_REQUIRED, ERR_REBASE_CONFLICT, ERR_UP_TO_DATE, |
| 41 | merge_gate, | 40 | merge_gate, |
| 42 | }; | 41 | }; |
| 43 | -use crate::pages::repo::repo_head; | ||
| 44 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; | 42 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 45 | use crate::pages::review_requests::{load_reviewers, reviewers_box}; | 43 | use crate::pages::review_requests::{load_reviewers, reviewers_box}; |
| 46 | use crate::state::AppState; | 44 | use crate::state::AppState; |
| @@ -120,11 +118,10 @@ pub(crate) struct Frame { | |||
| 120 | pub(crate) file_count: usize, | 118 | pub(crate) file_count: usize, |
| 121 | base_branch: String, | 119 | base_branch: String, |
| 122 | head_label: String, | 120 | head_label: String, |
| 123 | - state_class: &'static str, | ||
| 124 | state_text: &'static str, | 121 | state_text: &'static str, |
| 122 | + /// The state badge's classes: the same colours an issue's state uses. | ||
| 123 | + state_class: &'static str, | ||
| 125 | lang: Lang, | 124 | lang: Lang, |
| 126 | - /// The Files tab's review buttons: they submit the review form on that tab. | ||
| 127 | - pub(crate) head_review: bool, | ||
| 128 | /// Lines added and removed across the whole diff, shown on the Files tab. | 125 | /// Lines added and removed across the whole diff, shown on the Files tab. |
| 129 | pub(crate) totals: Option<(u32, u32)>, | 126 | pub(crate) totals: Option<(u32, u32)>, |
| 130 | } | 127 | } |
| @@ -162,14 +159,14 @@ pub(crate) async fn frame_in( | |||
| 162 | }, | 159 | }, |
| 163 | }; | 160 | }; |
| 164 | 161 | ||
| 165 | - let (state_class, state_text) = if is_merged(pr) { | 162 | + let (state_text, state_class) = if is_merged(pr) { |
| 166 | - ("issue-badge issue-badge-merged", g::t(lang, K::StateMerged)) | 163 | + (g::t(lang, K::StateMerged), "issue-badge issue-badge-merged") |
| 167 | } else if matches!(pr.issue.state, IssueState::Open) && pr.draft { | 164 | } else if matches!(pr.issue.state, IssueState::Open) && pr.draft { |
| 168 | - ("issue-badge issue-badge-draft", g::t(lang, K::DraftBadge)) | 165 | + (g::t(lang, K::DraftBadge), "issue-badge") |
| 169 | } else if matches!(pr.issue.state, IssueState::Open) { | 166 | } else if matches!(pr.issue.state, IssueState::Open) { |
| 170 | - ("issue-badge issue-badge-open", g::t(lang, K::StateOpen)) | 167 | + (g::t(lang, K::StateOpen), "issue-badge issue-badge-open") |
| 171 | } else { | 168 | } else { |
| 172 | - ("issue-badge issue-badge-closed", g::t(lang, K::StateClosed)) | 169 | + (g::t(lang, K::StateClosed), "issue-badge issue-badge-closed") |
| 173 | }; | 170 | }; |
| 174 | 171 | ||
| 175 | Ok(Frame { | 172 | Ok(Frame { |
| @@ -185,21 +182,22 @@ pub(crate) async fn frame_in( | |||
| 185 | file_count, | 182 | file_count, |
| 186 | base_branch: pr.base_branch.clone(), | 183 | base_branch: pr.base_branch.clone(), |
| 187 | head_label, | 184 | head_label, |
| 188 | - state_class, | ||
| 189 | state_text, | 185 | state_text, |
| 190 | - head_review: false, | 186 | + state_class, |
| 191 | totals: None, | 187 | totals: None, |
| 192 | }) | 188 | }) |
| 193 | } | 189 | } |
| 194 | 190 | ||
| 191 | +/// The head of every pull request tab: the title with the review buttons beside it, the byline, | ||
| 192 | +/// then the pull request's tabs. `active` names the tab that is open. | ||
| 195 | #[component] | 193 | #[component] |
| 196 | -pub(crate) async fn pull_header(frame: Frame) -> Result<impl View> { | 194 | +pub(crate) async fn pull_header(frame: Frame, active: String) -> Result<impl View> { |
| 197 | let Frame { | 195 | let Frame { |
| 198 | title, | 196 | title, |
| 199 | number, | 197 | number, |
| 200 | href, | 198 | href, |
| 201 | - state_class, | ||
| 202 | state_text, | 199 | state_text, |
| 200 | + state_class, | ||
| 203 | author, | 201 | author, |
| 204 | author_known, | 202 | author_known, |
| 205 | opened, | 203 | opened, |
| @@ -208,22 +206,25 @@ pub(crate) async fn pull_header(frame: Frame) -> Result<impl View> { | |||
| 208 | base_branch, | 206 | base_branch, |
| 209 | head_label, | 207 | head_label, |
| 210 | lang, | 208 | lang, |
| 211 | - head_review, | ||
| 212 | totals, | 209 | totals, |
| 213 | .. | 210 | .. |
| 214 | } = frame; | 211 | } = frame; |
| 215 | let number_label = format!("#{number}"); | 212 | let number_label = format!("#{number}"); |
| 216 | // The header is on every pull tab, so each tab follows the pull's stream. | 213 | // The header is on every pull tab, so each tab follows the pull's stream. |
| 217 | let live_url = format!("{href}/events"); | 214 | let live_url = format!("{href}/events"); |
| 215 | + let commits_href = format!("{href}/commits"); | ||
| 216 | + let files_href = format!("{href}/files"); | ||
| 218 | let commits_text = g::commit_count_line(lang, commit_count); | 217 | let commits_text = g::commit_count_line(lang, commit_count); |
| 218 | + let commits_label = g::commits_tab(lang, commit_count); | ||
| 219 | + let files_label = g::files_tab(lang, file_count); | ||
| 220 | + let conversation = g::t(lang, K::TabConversation); | ||
| 221 | + let aria = g::t(lang, K::PullPages); | ||
| 219 | let wants = g::t(lang, K::ByWantsToMerge); | 222 | let wants = g::t(lang, K::ByWantsToMerge); |
| 220 | let into = g::t(lang, K::ByInto); | 223 | let into = g::t(lang, K::ByInto); |
| 221 | let from = g::t(lang, K::ByFrom); | 224 | let from = g::t(lang, K::ByFrom); |
| 222 | let byline_end = g::t(lang, K::BylineEnd); | 225 | let byline_end = g::t(lang, K::BylineEnd); |
| 223 | // Turkish puts the source branch first and the commit count before the verb. | 226 | // Turkish puts the source branch first and the commit count before the verb. |
| 224 | let turkish = matches!(lang, Lang::Tr); | 227 | let turkish = matches!(lang, Lang::Tr); |
| 225 | - let changes_label = review_strings::t(lang, review_strings::K::RequestChangesChoice).trim(); | ||
| 226 | - let approve_label = review_strings::t(lang, review_strings::K::ApproveChoice).trim(); | ||
| 227 | let totals_text = totals.map(|(add, del)| { | 228 | let totals_text = totals.map(|(add, del)| { |
| 228 | format!( | 229 | format!( |
| 229 | "{} \u{b7} +{add} \u{2212}{del}", | 230 | "{} \u{b7} +{add} \u{2212}{del}", |
| @@ -231,18 +232,18 @@ pub(crate) async fn pull_header(frame: Frame) -> Result<impl View> { | |||
| 231 | ) | 232 | ) |
| 232 | }); | 233 | }); |
| 233 | Ok(view! { | 234 | Ok(view! { |
| 234 | - <section class="pull-head" data-live=(live_url.as_str())> | 235 | + <section class="head" data-live=(live_url.as_str())> |
| 235 | - <h1 class="h1">(title.as_str()) " " <span class="issue-number">(number_label.as_str())</span></h1> | 236 | + <div class="head-title"> |
| 236 | - <p class="hint"> | 237 | + <h1>(title.as_str()) " " <span class="num">(number_label.as_str())</span></h1> |
| 238 | + </div> | ||
| 239 | + <p class="head-sub"> | ||
| 237 | <span class=(state_class)>(state_text)</span> | 240 | <span class=(state_class)>(state_text)</span> |
| 238 | " " | 241 | " " |
| 239 | - <strong> | 242 | + if author_known { |
| 240 | - if author_known { | 243 | + user_link(shown: author.as_str(), login: author.as_str()) |
| 241 | - user_link(shown: author.as_str(), login: author.as_str()) | 244 | + } else { |
| 242 | - } else { | 245 | + (author.as_str()) |
| 243 | - (author.as_str()) | 246 | + } |
| 244 | - } | ||
| 245 | - </strong> | ||
| 246 | " " | 247 | " " |
| 247 | if turkish { | 248 | if turkish { |
| 248 | (wants) <code>(head_label.as_str())</code> | 249 | (wants) <code>(head_label.as_str())</code> |
| @@ -256,16 +257,15 @@ pub(crate) async fn pull_header(frame: Frame) -> Result<impl View> { | |||
| 256 | " " | 257 | " " |
| 257 | <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> | 258 | <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> |
| 258 | if let Some(text) = totals_text { | 259 | if let Some(text) = totals_text { |
| 259 | - " " | 260 | + " · " |
| 260 | - <span class="pull-totals">(text.as_str())</span> | 261 | + <span class="mono">(text.as_str())</span> |
| 261 | } | 262 | } |
| 262 | </p> | 263 | </p> |
| 263 | - if head_review { | 264 | + <nav class="tabs" aria-label=(aria)> |
| 264 | - <div class="acts" role="group" aria-label=(review_strings::t(lang, review_strings::K::ReviewType))> | 265 | + <a aria-current=(current_tab(&active, "conversation")) href=(href.as_str())>(conversation)</a> |
| 265 | - <button type="submit" class="act" form="review-form" name="state" value="request_changes">(changes_label)</button> | 266 | + <a aria-current=(current_tab(&active, "commits")) href=(commits_href.as_str())>(commits_label.as_str())</a> |
| 266 | - <button type="submit" class="act" form="review-form" name="state" value="approve">(approve_label)</button> | 267 | + <a aria-current=(current_tab(&active, "files")) href=(files_href.as_str())>(files_label.as_str())</a> |
| 267 | - </div> | 268 | + </nav> |
| 268 | - } | ||
| 269 | </section> | 269 | </section> |
| 270 | }) | 270 | }) |
| 271 | } | 271 | } |
| @@ -275,30 +275,6 @@ fn current_tab(active: &str, tab: &str) -> Option<&'static str> { | |||
| 275 | (active == tab).then_some("page") | 275 | (active == tab).then_some("page") |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | -/// The pull request's sub-tabs, with their labels in `lang`. | ||
| 279 | -#[component] | ||
| 280 | -pub(crate) async fn pull_subnav_in( | ||
| 281 | - lang: Lang, | ||
| 282 | - href: String, | ||
| 283 | - active: String, | ||
| 284 | - commits: usize, | ||
| 285 | - files: usize, | ||
| 286 | -) -> Result<impl View> { | ||
| 287 | - let commits_href = format!("{href}/commits"); | ||
| 288 | - let files_href = format!("{href}/files"); | ||
| 289 | - let commits_label = g::commits_tab(lang, commits); | ||
| 290 | - let files_label = g::files_tab(lang, files); | ||
| 291 | - let conversation = g::t(lang, K::TabConversation); | ||
| 292 | - let aria = g::t(lang, K::PullPages); | ||
| 293 | - Ok(view! { | ||
| 294 | - <nav class="tabs" aria-label=(aria)> | ||
| 295 | - <a aria-current=(current_tab(&active, "conversation")) href=(href.as_str())>(conversation)</a> | ||
| 296 | - <a aria-current=(current_tab(&active, "commits")) href=(commits_href.as_str())>(commits_label.as_str())</a> | ||
| 297 | - <a aria-current=(current_tab(&active, "files")) href=(files_href.as_str())>(files_label.as_str())</a> | ||
| 298 | - </nav> | ||
| 299 | - }) | ||
| 300 | -} | ||
| 301 | - | ||
| 302 | // Merge box | 278 | // Merge box |
| 303 | 279 | ||
| 304 | /// Where the merge form posts, and whether fast-forward is offered. | 280 | /// Where the merge form posts, and whether fast-forward is offered. |
| @@ -349,7 +325,7 @@ async fn merge_box( | |||
| 349 | flow: FlowView, | 325 | flow: FlowView, |
| 350 | lang: Lang, | 326 | lang: Lang, |
| 351 | ) -> Result<impl View> { | 327 | ) -> Result<impl View> { |
| 352 | - let class = format!("sec merge-box merge-{tone}"); | 328 | + let class = format!("sec merge-{tone}"); |
| 353 | let heading = crate::pages::passkeys::s(lang, "Merge", "Birleştirme"); | 329 | let heading = crate::pages::passkeys::s(lang, "Merge", "Birleştirme"); |
| 354 | let required_heading = g::t(lang, K::RequiredChecksHeading); | 330 | let required_heading = g::t(lang, K::RequiredChecksHeading); |
| 355 | let style_rebase = g::t(lang, K::StyleRebase); | 331 | let style_rebase = g::t(lang, K::StyleRebase); |
| @@ -389,13 +365,11 @@ async fn merge_box( | |||
| 389 | checks_summary(summary: summary, lang: StatusLang(lang)) | 365 | checks_summary(summary: summary, lang: StatusLang(lang)) |
| 390 | } | 366 | } |
| 391 | if !required.is_empty() { | 367 | if !required.is_empty() { |
| 392 | - <div class="required-checks"> | 368 | + <div> |
| 393 | <p class="hint">(required_heading)</p> | 369 | <p class="hint">(required_heading)</p> |
| 394 | - <ul class="required-check-list"> | 370 | + for row in required.iter() { |
| 395 | - for row in required.iter() { | 371 | + <div class=(format!("line {}", row.class))><span class="name"><code>(row.context.as_str())</code></span><span class="val">(row.label)</span></div> |
| 396 | - <li class=(row.class)><code>(row.context.as_str())</code><span>(row.label)</span></li> | 372 | + } |
| 397 | - } | ||
| 398 | - </ul> | ||
| 399 | </div> | 373 | </div> |
| 400 | } | 374 | } |
| 401 | if let Some(text) = approvals { | 375 | if let Some(text) = approvals { |
| @@ -405,11 +379,11 @@ async fn merge_box( | |||
| 405 | <p class="hint merge-blocked">(text.as_str())</p> | 379 | <p class="hint merge-blocked">(text.as_str())</p> |
| 406 | } | 380 | } |
| 407 | if !conflicts.is_empty() { | 381 | if !conflicts.is_empty() { |
| 408 | - <ul class="merge-files"> | 382 | + <div> |
| 409 | for file in conflicts.iter() { | 383 | for file in conflicts.iter() { |
| 410 | - <li><code>(file.as_str())</code></li> | 384 | + <div class="line"><span class="name"><code>(file.as_str())</code></span></div> |
| 411 | } | 385 | } |
| 412 | - </ul> | 386 | + </div> |
| 413 | } | 387 | } |
| 414 | if let Some(href) = reload { | 388 | if let Some(href) = reload { |
| 415 | <div class="acts"> | 389 | <div class="acts"> |
| @@ -420,14 +394,16 @@ async fn merge_box( | |||
| 420 | <form method="post" action=(f.action.as_str()) class="fields merge-form"> | 394 | <form method="post" action=(f.action.as_str()) class="fields merge-form"> |
| 421 | <input type="hidden" name="csrf" value=(f.csrf.as_str())> | 395 | <input type="hidden" name="csrf" value=(f.csrf.as_str())> |
| 422 | <input type="hidden" name="head" value=(f.head.as_str())> | 396 | <input type="hidden" name="head" value=(f.head.as_str())> |
| 423 | - <fieldset class="merge-styles"> | 397 | + <fieldset> |
| 424 | <legend>(style_legend)</legend> | 398 | <legend>(style_legend)</legend> |
| 425 | - <label class="switch"><input type="radio" name="style" value="merge" checked=(true)><span>(style_merge)</span></label> | 399 | + <div class="choice"> |
| 426 | - <label class="switch"><input type="radio" name="style" value="squash"><span>(style_squash)</span></label> | 400 | + <label><input type="radio" name="style" value="merge" checked=(true)><span>(style_merge)</span></label> |
| 427 | - <label class="switch"><input type="radio" name="style" value="rebase"><span>(style_rebase)</span></label> | 401 | + <label><input type="radio" name="style" value="squash"><span>(style_squash)</span></label> |
| 428 | - if f.ff { | 402 | + <label><input type="radio" name="style" value="rebase"><span>(style_rebase)</span></label> |
| 429 | - <label class="switch"><input type="radio" name="style" value="ff"><span>(style_ff)</span></label> | 403 | + if f.ff { |
| 430 | - } | 404 | + <label><input type="radio" name="style" value="ff"><span>(style_ff)</span></label> |
| 405 | + } | ||
| 406 | + </div> | ||
| 431 | </fieldset> | 407 | </fieldset> |
| 432 | <div class="field"> | 408 | <div class="field"> |
| 433 | <label for="merge-message">(message_label)</label> | 409 | <label for="merge-message">(message_label)</label> |
| @@ -502,7 +478,7 @@ async fn merged_notice( | |||
| 502 | let as_sep = g::t(lang, K::MergedAsSep); | 478 | let as_sep = g::t(lang, K::MergedAsSep); |
| 503 | let heading = g::t(lang, K::StateMerged); | 479 | let heading = g::t(lang, K::StateMerged); |
| 504 | Ok(view! { | 480 | Ok(view! { |
| 505 | - <section class="sec merge-box merge-merged"> | 481 | + <section class="sec merge-merged"> |
| 506 | <h2>(heading)</h2> | 482 | <h2>(heading)</h2> |
| 507 | <p class="state merge-headline"> | 483 | <p class="state merge-headline"> |
| 508 | (prefix) <strong>user_link(shown: who.as_str(), login: who.as_str())</strong> (middle) | 484 | (prefix) <strong>user_link(shown: who.as_str(), login: who.as_str())</strong> (middle) |
| @@ -542,7 +518,7 @@ async fn review_box( | |||
| 542 | let dismiss_text = g::t(lang, K::DismissButton); | 518 | let dismiss_text = g::t(lang, K::DismissButton); |
| 543 | let heading = crate::pages::passkeys::s(lang, "Reviews", "İncelemeler"); | 519 | let heading = crate::pages::passkeys::s(lang, "Reviews", "İncelemeler"); |
| 544 | Ok(view! { | 520 | Ok(view! { |
| 545 | - <section class="sec review-box"> | 521 | + <section class="sec"> |
| 546 | <h2>(heading)</h2> | 522 | <h2>(heading)</h2> |
| 547 | if let Some(text) = approved { | 523 | if let Some(text) = approved { |
| 548 | <p class="state">(text.as_str())</p> | 524 | <p class="state">(text.as_str())</p> |
| @@ -557,10 +533,9 @@ async fn review_box( | |||
| 557 | reveal(label: dismiss_text, | 533 | reveal(label: dismiss_text, |
| 558 | <form method="post" action=(row.action.as_str()) class="fields review-dismiss"> | 534 | <form method="post" action=(row.action.as_str()) class="fields review-dismiss"> |
| 559 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 535 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 560 | - <label class="field"> | 536 | + <div class="field"> |
| 561 | - <span>(row.label.as_str())</span> | 537 | + <label><span>(row.label.as_str())</span><input type="text" name="reason" required=(true)></label> |
| 562 | - <input type="text" name="reason" required=(true)> | 538 | + </div> |
| 563 | - </label> | ||
| 564 | <button type="submit" class="primary">(dismiss_text)</button> | 539 | <button type="submit" class="primary">(dismiss_text)</button> |
| 565 | </form> | 540 | </form> |
| 566 | ) | 541 | ) |
| @@ -934,24 +909,16 @@ async fn pull_conversation( | |||
| 934 | let branch_shown = !open && (branch.is_some() || branch_error.is_some()); | 909 | let branch_shown = !open && (branch.is_some() || branch_error.is_some()); |
| 935 | 910 | ||
| 936 | let page_title = frame.page_title.clone(); | 911 | let page_title = frame.page_title.clone(); |
| 937 | - let header = ctx.head(state, "pulls").await?; | ||
| 938 | let labels_href = repo_href(&owner, &name, "labels.css", ""); | 912 | let labels_href = repo_href(&owner, &name, "labels.css", ""); |
| 939 | // The conversation follows the pull request's event stream: a change re-renders it. | 913 | // The conversation follows the pull request's event stream: a change re-renders it. |
| 940 | let live = format!("{href}/events"); | 914 | let live = format!("{href}/events"); |
| 941 | Ok(view! { cx => | 915 | Ok(view! { cx => |
| 942 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), | 916 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), |
| 943 | - repo_head(head: header) | 917 | + pull_header(frame: frame.clone(), active: "conversation".to_owned()) |
| 944 | - pull_header(frame: frame.clone()) | ||
| 945 | - pull_subnav_in(lang: lang, href: href.clone(), active: "conversation".to_owned(), | ||
| 946 | - commits: commit_count, files: file_count) | ||
| 947 | if let Some(message) = review_error { | 918 | if let Some(message) = review_error { |
| 948 | alert(message: message) | 919 | alert(message: message) |
| 949 | } | 920 | } |
| 950 | - <div data-live=(live.as_str())> | 921 | + <div class="sheet" data-live=(live.as_str())> |
| 951 | - <div class="pull-topics"> | ||
| 952 | - item_sidebar(lang: lang, write: write_meta, base: href.clone(), csrf: csrf.clone(), viewer: viewer_login, sidebar: sidebar, notify: notify) | ||
| 953 | - reviewers_box(lang: lang, reviewers: reviewers) | ||
| 954 | - </div> | ||
| 955 | discussion_timeline(lang: lang, discussion: discussion) | 922 | discussion_timeline(lang: lang, discussion: discussion) |
| 956 | if review_box_shown { | 923 | if review_box_shown { |
| 957 | review_box(approved: approved, approved_before: approved_before, changes: changes, dismiss: dismiss, | 924 | review_box(approved: approved, approved_before: approved_before, changes: changes, dismiss: dismiss, |
| @@ -974,6 +941,9 @@ async fn pull_conversation( | |||
| 974 | comment_form(lang: lang, action: comment_action, state_action: state_action, | 941 | comment_form(lang: lang, action: comment_action, state_action: state_action, |
| 975 | csrf: csrf.clone(), draft: draft, error: error, can_close: can_close, open: open) | 942 | csrf: csrf.clone(), draft: draft, error: error, can_close: can_close, open: open) |
| 976 | } | 943 | } |
| 944 | + // What the pull request is filed under comes after the conversation, as on an issue. | ||
| 945 | + reviewers_box(lang: lang, reviewers: reviewers) | ||
| 946 | + item_sidebar(lang: lang, write: write_meta, base: href.clone(), csrf: csrf.clone(), viewer: viewer_login, sidebar: sidebar, notify: notify) | ||
| 977 | if archived { | 947 | if archived { |
| 978 | <p class="hint">(archived_text)</p> | 948 | <p class="hint">(archived_text)</p> |
| 979 | } | 949 | } |
| @@ -1070,15 +1040,12 @@ async fn pull_commits(cx: &Cx) -> Result<impl View> { | |||
| 1070 | .collect(); | 1040 | .collect(); |
| 1071 | 1041 | ||
| 1072 | let page_title = frame.page_title.clone(); | 1042 | let page_title = frame.page_title.clone(); |
| 1073 | - let href = frame.href.clone(); | ||
| 1074 | - let header = ctx.head(state, "pulls").await?; | ||
| 1075 | Ok(view! { | 1043 | Ok(view! { |
| 1076 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 1044 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 1077 | - repo_head(head: header) | 1045 | + pull_header(frame: frame.clone(), active: "commits".to_owned()) |
| 1078 | - pull_header(frame: frame.clone()) | 1046 | + <div class="sheet"> |
| 1079 | - pull_subnav_in(lang: lang, href: href, active: "commits".to_owned(), | 1047 | + commit_list(rows: rows, lang: lang) |
| 1080 | - commits: frame.commit_count, files: frame.file_count) | 1048 | + </div> |
| 1081 | - commit_list(rows: rows, lang: lang) | ||
| 1082 | ) | 1049 | ) |
| 1083 | }) | 1050 | }) |
| 1084 | } | 1051 | } |
| @@ -1345,10 +1312,7 @@ mod tests { | |||
| 1345 | let (status, _, body) = send(&fx.router, "GET", &uri, Some("tahinli"), None).await; | 1312 | let (status, _, body) = send(&fx.router, "GET", &uri, Some("tahinli"), None).await; |
| 1346 | assert_eq!(status, 200, "clean"); | 1313 | assert_eq!(status, 200, "clean"); |
| 1347 | assert!(body.contains("Add feature"), "clean: {body}"); | 1314 | assert!(body.contains("Add feature"), "clean: {body}"); |
| 1348 | - assert!( | 1315 | + assert!(body.contains("issue-badge-open\">Open<"), "clean: {body}"); |
| 1349 | - body.contains("issue-badge issue-badge-open"), | ||
| 1350 | - "clean: {body}" | ||
| 1351 | - ); | ||
| 1352 | assert!( | 1316 | assert!( |
| 1353 | body.contains("This branch has no conflicts with the base branch"), | 1317 | body.contains("This branch has no conflicts with the base branch"), |
| 1354 | "clean: {body}" | 1318 | "clean: {body}" |
| @@ -1771,7 +1735,7 @@ mod tests { | |||
| 1771 | assert!(body.contains("Please rename this"), "approval: {body}"); | 1735 | assert!(body.contains("Please rename this"), "approval: {body}"); |
| 1772 | assert!(body.contains("feat.txt:1"), "approval: {body}"); | 1736 | assert!(body.contains("feat.txt:1"), "approval: {body}"); |
| 1773 | assert!(body.contains("@@ -0,0 +1 @@"), "approval: {body}"); | 1737 | assert!(body.contains("@@ -0,0 +1 @@"), "approval: {body}"); |
| 1774 | - assert!(body.contains("review-badge-outdated"), "approval: {body}"); | 1738 | + assert!(body.contains("<span class=\"badge\">Outdated</span>"), "approval: {body}"); |
| 1775 | assert!(body.contains("Approved by bob"), "approval: {body}"); | 1739 | assert!(body.contains("Approved by bob"), "approval: {body}"); |
| 1776 | 1740 | ||
| 1777 | fx.store | 1741 | fx.store |
crates/forge-web/src/pages/pulls_list.rsmodified+141 -128
| @@ -17,11 +17,13 @@ use crate::i18n::pulls::{self as g, K}; | |||
| 17 | use crate::i18n::{self, Lang}; | 17 | use crate::i18n::{self, Lang}; |
| 18 | use crate::pages::issues_list::{ | 18 | use crate::pages::issues_list::{ |
| 19 | AssigneeView, LabelView, ListQuery, MilestoneView, Selection, SortOption, list_href, | 19 | AssigneeView, LabelView, ListQuery, MilestoneView, Selection, SortOption, list_href, |
| 20 | - stamp_unix, state_tab, | 20 | + stamp_unix, |
| 21 | }; | 21 | }; |
| 22 | use crate::pages::repo::repo_head; | 22 | use crate::pages::repo::repo_head; |
| 23 | use crate::pages::repo_ctx::load_repo; | 23 | use crate::pages::repo_ctx::load_repo; |
| 24 | use crate::state::AppState; | 24 | use crate::state::AppState; |
| 25 | +use crate::pages::passkeys::s; | ||
| 26 | +use crate::views::parts::{RailItem, SubPart, rail}; | ||
| 25 | use crate::views::{ | 27 | use crate::views::{ |
| 26 | avatar_url, iso_time, now_unix, relative_time, repo_href, shell, user_link, | 28 | avatar_url, iso_time, now_unix, relative_time, repo_href, shell, user_link, |
| 27 | }; | 29 | }; |
| @@ -36,9 +38,8 @@ const PER_PAGE: u32 = 25; | |||
| 36 | struct PullRowView { | 38 | struct PullRowView { |
| 37 | /// The number, the `data-arrive` value that marks a row new after a live update. | 39 | /// The number, the `data-arrive` value that marks a row new after a live update. |
| 38 | arrive: String, | 40 | arrive: String, |
| 39 | - state_class: &'static str, | 41 | + open: bool, |
| 40 | state_label: &'static str, | 42 | state_label: &'static str, |
| 41 | - badge_class: &'static str, | ||
| 42 | badge_label: &'static str, | 43 | badge_label: &'static str, |
| 43 | number_text: String, | 44 | number_text: String, |
| 44 | href: String, | 45 | href: String, |
| @@ -58,33 +59,14 @@ struct PullRowView { | |||
| 58 | reviewers_text: Option<String>, | 59 | reviewers_text: Option<String>, |
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | -/// The row's icon and badge: green for open, purple for merged, red for closed without a merge. | 62 | +/// The row's icon label and badge: open, merged (purple) or closed without a merge. |
| 62 | -fn state_parts( | 63 | +fn state_parts(lang: Lang, open: bool, merged: bool) -> (&'static str, &'static str) { |
| 63 | - lang: Lang, | ||
| 64 | - open: bool, | ||
| 65 | - merged: bool, | ||
| 66 | -) -> (&'static str, &'static str, &'static str, &'static str) { | ||
| 67 | if open { | 64 | if open { |
| 68 | - ( | 65 | + (g::t(lang, K::PrStateOpenLabel), g::t(lang, K::StateOpen)) |
| 69 | - "issue-state issue-state-open", | ||
| 70 | - g::t(lang, K::PrStateOpenLabel), | ||
| 71 | - "issue-badge issue-badge-open", | ||
| 72 | - g::t(lang, K::StateOpen), | ||
| 73 | - ) | ||
| 74 | } else if merged { | 66 | } else if merged { |
| 75 | - ( | 67 | + (g::t(lang, K::PrStateMergedLabel), g::t(lang, K::StateMerged)) |
| 76 | - "issue-state pull-state-merged", | ||
| 77 | - g::t(lang, K::PrStateMergedLabel), | ||
| 78 | - "issue-badge issue-badge-merged", | ||
| 79 | - g::t(lang, K::StateMerged), | ||
| 80 | - ) | ||
| 81 | } else { | 68 | } else { |
| 82 | - ( | 69 | + (g::t(lang, K::PrStateClosedLabel), g::t(lang, K::StateClosed)) |
| 83 | - "issue-state pull-state-closed", | ||
| 84 | - g::t(lang, K::PrStateClosedLabel), | ||
| 85 | - "issue-badge issue-badge-closed", | ||
| 86 | - g::t(lang, K::StateClosed), | ||
| 87 | - ) | ||
| 88 | } | 70 | } |
| 89 | } | 71 | } |
| 90 | 72 | ||
| @@ -119,11 +101,10 @@ fn row_view( | |||
| 119 | let unix = stamp_unix(&issue.created_at); | 101 | let unix = stamp_unix(&issue.created_at); |
| 120 | let open = matches!(issue.state, IssueState::Open); | 102 | let open = matches!(issue.state, IssueState::Open); |
| 121 | let comments = issue.comment_count.max(0); | 103 | let comments = issue.comment_count.max(0); |
| 122 | - let (state_class, state_label, badge_class, badge_label) = state_parts(lang, open, merged); | 104 | + let (state_label, badge_label) = state_parts(lang, open, merged); |
| 123 | PullRowView { | 105 | PullRowView { |
| 124 | - state_class, | 106 | + open, |
| 125 | state_label, | 107 | state_label, |
| 126 | - badge_class, | ||
| 127 | badge_label, | 108 | badge_label, |
| 128 | arrive: issue.number.to_string(), | 109 | arrive: issue.number.to_string(), |
| 129 | number_text: format!("#{}", issue.number), | 110 | number_text: format!("#{}", issue.number), |
| @@ -233,7 +214,6 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> { | |||
| 233 | let all_href = sel.href(&base, "all", 1); | 214 | let all_href = sel.href(&base, "all", 1); |
| 234 | let open_text = g::tab_open(lang, open_count); | 215 | let open_text = g::tab_open(lang, open_count); |
| 235 | let closed_text = g::tab_closed(lang, closed_count); | 216 | let closed_text = g::tab_closed(lang, closed_count); |
| 236 | - let all_text = g::tab_all(lang, open_count + closed_count); | ||
| 237 | let clear_href = list_href(&base, &[("state", sel.state)]); | 217 | let clear_href = list_href(&base, &[("state", sel.state)]); |
| 238 | let has_filters = sel.has_filters(); | 218 | let has_filters = sel.has_filters(); |
| 239 | 219 | ||
| @@ -270,88 +250,122 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> { | |||
| 270 | 250 | ||
| 271 | let header = ctx.head(state, "pulls").await?; | 251 | let header = ctx.head(state, "pulls").await?; |
| 272 | let live_url = format!("/{owner}/{name}/pulls/events"); | 252 | let live_url = format!("/{owner}/{name}/pulls/events"); |
| 253 | + let open_label = g::t(lang, K::StateOpen); | ||
| 254 | + let closed_label = g::t(lang, K::StateClosed); | ||
| 255 | + let total_count = (open_count + closed_count).to_string(); | ||
| 256 | + let mut items = vec![ | ||
| 257 | + RailItem { | ||
| 258 | + name: open_label.to_owned(), | ||
| 259 | + val: open_count.to_string(), | ||
| 260 | + href: open_href, | ||
| 261 | + current: open_on, | ||
| 262 | + }, | ||
| 263 | + RailItem { | ||
| 264 | + name: closed_label.to_owned(), | ||
| 265 | + val: closed_count.to_string(), | ||
| 266 | + href: closed_href, | ||
| 267 | + current: closed_on, | ||
| 268 | + }, | ||
| 269 | + RailItem { | ||
| 270 | + name: s(lang, "All", "Tümü").to_owned(), | ||
| 271 | + val: total_count, | ||
| 272 | + href: all_href, | ||
| 273 | + current: all_on, | ||
| 274 | + }, | ||
| 275 | + ]; | ||
| 276 | + if let Some(me) = ctx.viewer.as_ref().map(|(user, _)| user.username.as_str()) { | ||
| 277 | + items.push(RailItem { | ||
| 278 | + name: s(lang, "Assigned to you", "Size atanan").to_owned(), | ||
| 279 | + val: String::new(), | ||
| 280 | + href: list_href(&base, &[("state", "open"), ("assignee", me)]), | ||
| 281 | + current: sel.assignee == me, | ||
| 282 | + }); | ||
| 283 | + items.push(RailItem { | ||
| 284 | + name: s(lang, "Created by you", "Sizin açtıklarınız").to_owned(), | ||
| 285 | + val: String::new(), | ||
| 286 | + href: list_href(&base, &[("state", "open"), ("author", me)]), | ||
| 287 | + current: sel.author == me, | ||
| 288 | + }); | ||
| 289 | + items.push(RailItem { | ||
| 290 | + name: s(lang, "Review requests", "İnceleme istekleri").to_owned(), | ||
| 291 | + val: String::new(), | ||
| 292 | + href: list_href(&base, &[("state", "open"), ("review_requested", "@me")]), | ||
| 293 | + current: sel.review_requested == me, | ||
| 294 | + }); | ||
| 295 | + } | ||
| 296 | + let shown_name = items | ||
| 297 | + .iter() | ||
| 298 | + .find(|item| item.current) | ||
| 299 | + .map_or_else(String::new, |item| item.name.clone()); | ||
| 273 | Ok(view! { | 300 | Ok(view! { |
| 274 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), | 301 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), |
| 275 | - repo_head(head: header) | 302 | + repo_head(head: header, sub: vec![SubPart::text(open_text), SubPart::text(closed_text)], |
| 276 | - <div data-live=(live_url.as_str())> | 303 | + if can_create { |
| 277 | - <h1 class="sr-only">(title.as_str())</h1> | 304 | + <a class="button primary" href=(compare_href.as_str()) data-palette-action="go">(g::t(lang, K::NewPullRequest))</a> |
| 278 | - <nav class="tabs" aria-label=(g::t(lang, K::ListStateNavLabel))> | ||
| 279 | - state_tab(href: open_href.as_str(), text: open_text.as_str(), current: open_on) | ||
| 280 | - state_tab(href: closed_href.as_str(), text: closed_text.as_str(), current: closed_on) | ||
| 281 | - state_tab(href: all_href.as_str(), text: all_text.as_str(), current: all_on) | ||
| 282 | - </nav> | ||
| 283 | - <form method="get" action=(base.as_str())> | ||
| 284 | - <input type="hidden" name="state" value=(sel.state)> | ||
| 285 | - <input type="hidden" name="label" value=(sel.label.as_str())> | ||
| 286 | - <input type="hidden" name="milestone" value=(sel.milestone.as_str())> | ||
| 287 | - <input type="hidden" name="author" value=(sel.author.as_str())> | ||
| 288 | - <input type="hidden" name="assignee" value=(sel.assignee.as_str())> | ||
| 289 | - <div class="plain-search"> | ||
| 290 | - <input type="search" name="q" value=(search_value.as_str()) data-live-search="" autocomplete="off" placeholder=(g::t(lang, K::SearchTitles)) aria-label=(g::t(lang, K::SearchTitles)) maxlength="256"> | ||
| 291 | - <button type="submit" class="sr-only">(g::t(lang, K::Search))</button> | ||
| 292 | - </div> | ||
| 293 | - <div class="sub"> | ||
| 294 | - <select name="draft" aria-label=(g::t(lang, K::DraftFilterLabel)) data-autosubmit=(true)> | ||
| 295 | - <option value="" selected=(draft_sel.is_empty())>(g::t(lang, K::DraftAny))</option> | ||
| 296 | - <option value="true" selected=(draft_sel == "true")>(g::t(lang, K::DraftOnly))</option> | ||
| 297 | - <option value="false" selected=(draft_sel == "false")>(g::t(lang, K::DraftReadyOnly))</option> | ||
| 298 | - </select> | ||
| 299 | - <select name="sort" aria-label=(g::t(lang, K::SortLabel)) data-autosubmit=(true)> | ||
| 300 | - for option in sort_options.iter() { | ||
| 301 | - <option value=(option.value) selected=(option.selected)>(option.label)</option> | ||
| 302 | - } | ||
| 303 | - </select> | ||
| 304 | - <a href=(queue_href.as_str())>(mq::t(lang, mq::K::MergeQueueTitle))</a> | ||
| 305 | - if can_create { | ||
| 306 | - <a class="act" href=(compare_href.as_str()) data-palette-action="go">(g::t(lang, K::NewPullRequest))</a> | ||
| 307 | - } | ||
| 308 | - </div> | ||
| 309 | - </form> | ||
| 310 | - if has_filters { | ||
| 311 | - <p class="hint">(g::t(lang, K::FiltersApplied)) " " <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a></p> | ||
| 312 | - } | ||
| 313 | - if rows.is_empty() { | ||
| 314 | - <p class="state">(empty_text)</p> | ||
| 315 | - if has_filters { | ||
| 316 | - <div class="acts"> | ||
| 317 | - <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> | ||
| 318 | - </div> | ||
| 319 | - } else if no_pulls_yet && can_create { | ||
| 320 | - <div class="acts"> | ||
| 321 | - <a class="act" href=(compare_href.as_str()) data-palette-action="go">(g::t(lang, K::NewPullRequest))</a> | ||
| 322 | - </div> | ||
| 323 | } | 305 | } |
| 324 | - } else { | 306 | + ) |
| 325 | - <div> | 307 | + <div class="work" data-live=(live_url.as_str())> |
| 326 | - for row in rows.iter() { | 308 | + rail(label: title.as_str(), items: items) |
| 327 | - <div class="line issue-row" data-kb-row="" data-arrive=(row.arrive.as_str())> | 309 | + <div class="sheet"> |
| 328 | - <span class=(row.state_class) role="img" aria-label=(row.state_label)></span> | 310 | + <form method="get" action=(base.as_str())> |
| 329 | - <div class="issue-main"> | 311 | + <input type="hidden" name="state" value=(sel.state)> |
| 330 | - <div class="issue-title-line"> | 312 | + <input type="hidden" name="label" value=(sel.label.as_str())> |
| 331 | - <a class="issue-title" href=(row.href.as_str())>(row.title.as_str())</a> | 313 | + <input type="hidden" name="milestone" value=(sel.milestone.as_str())> |
| 332 | - <span class=(row.badge_class)>(row.badge_label)</span> | 314 | + <input type="hidden" name="author" value=(sel.author.as_str())> |
| 333 | - if row.draft { | 315 | + <input type="hidden" name="assignee" value=(sel.assignee.as_str())> |
| 334 | - <span class="issue-badge issue-badge-draft">(draft_label)</span> | 316 | + <div class="sheet-tools"> |
| 335 | - } | 317 | + <strong>(shown_name.as_str())</strong> |
| 336 | - for chip in row.labels.iter() { | 318 | + <div class="plain-search"> |
| 337 | - <a class=(chip.class.as_str()) href=(chip.href.as_str())>(chip.name.as_str())</a> | 319 | + <input type="search" name="q" value=(search_value.as_str()) data-live-search="" autocomplete="off" placeholder=(g::t(lang, K::SearchTitles)) aria-label=(g::t(lang, K::SearchTitles)) maxlength="256"> |
| 320 | + <button type="submit" class="sr-only">(g::t(lang, K::Search))</button> | ||
| 321 | + </div> | ||
| 322 | + <select name="draft" aria-label=(g::t(lang, K::DraftFilterLabel)) data-autosubmit=(true)> | ||
| 323 | + <option value="" selected=(draft_sel.is_empty())>(g::t(lang, K::DraftAny))</option> | ||
| 324 | + <option value="true" selected=(draft_sel == "true")>(g::t(lang, K::DraftOnly))</option> | ||
| 325 | + <option value="false" selected=(draft_sel == "false")>(g::t(lang, K::DraftReadyOnly))</option> | ||
| 326 | + </select> | ||
| 327 | + <select name="sort" aria-label=(g::t(lang, K::SortLabel)) data-autosubmit=(true)> | ||
| 328 | + for option in sort_options.iter() { | ||
| 329 | + <option value=(option.value) selected=(option.selected)>(option.label)</option> | ||
| 330 | + } | ||
| 331 | + </select> | ||
| 332 | + <a class="act" href=(queue_href.as_str())>(mq::t(lang, mq::K::MergeQueueTitle))</a> | ||
| 333 | + </div> | ||
| 334 | + </form> | ||
| 335 | + if has_filters { | ||
| 336 | + <p class="hint">(g::t(lang, K::FiltersApplied)) " " <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a></p> | ||
| 337 | + } | ||
| 338 | + if rows.is_empty() { | ||
| 339 | + <p class="state">(empty_text)</p> | ||
| 340 | + if has_filters { | ||
| 341 | + <div class="acts"> | ||
| 342 | + <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> | ||
| 343 | + </div> | ||
| 344 | + } else if no_pulls_yet && can_create { | ||
| 345 | + <div class="acts"> | ||
| 346 | + <a class="act" href=(compare_href.as_str()) data-palette-action="go">(g::t(lang, K::NewPullRequest))</a> | ||
| 347 | + </div> | ||
| 348 | + } | ||
| 349 | + } else { | ||
| 350 | + for row in rows.iter() { | ||
| 351 | + <div class="line issue-row" data-kb-row="" data-arrive=(row.arrive.as_str())> | ||
| 352 | + <span class=(if row.open { "tick" } else { "tick done" }) role="img" aria-label=(row.state_label)></span> | ||
| 353 | + <a class="name" href=(row.href.as_str())>(row.title.as_str())</a> | ||
| 354 | + for chip in row.labels.iter() { | ||
| 355 | + <a class=(chip.class.as_str()) href=(chip.href.as_str())>(chip.name.as_str())</a> | ||
| 356 | + } | ||
| 357 | + <span class="val"> | ||
| 358 | + (row.number_text.as_str()) " · " | ||
| 359 | + if !row.open { | ||
| 360 | + (row.badge_label) " · " | ||
| 338 | } | 361 | } |
| 339 | - </div> | 362 | + if row.draft { |
| 340 | - <div class="issue-meta muted small"> | 363 | + (draft_label) " · " |
| 341 | - <span>(row.number_text.as_str())</span> | ||
| 342 | - if lang == Lang::Tr { | ||
| 343 | - <span>(g::t(lang, K::MetaBeforeTime))</span> | ||
| 344 | - <span>user_link(shown: row.author.as_str(), login: row.author.as_str())</span> | ||
| 345 | - <span>(g::t(lang, K::MetaAfterTime))</span> | ||
| 346 | - <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | ||
| 347 | - } else { | ||
| 348 | - <span>(g::t(lang, K::MetaBeforeTime))</span> | ||
| 349 | - <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | ||
| 350 | - <span>(g::t(lang, K::MetaAfterTime))</span> | ||
| 351 | - <span>user_link(shown: row.author.as_str(), login: row.author.as_str())</span> | ||
| 352 | } | 364 | } |
| 365 | + user_link(shown: row.author.as_str(), login: row.author.as_str()) " · " | ||
| 366 | + <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | ||
| 353 | if let Some(milestone) = row.milestone.clone() { | 367 | if let Some(milestone) = row.milestone.clone() { |
| 354 | - <a href=(milestone.href.as_str())>(milestone.title.as_str())</a> | 368 | + " · " <a href=(milestone.href.as_str())>(milestone.title.as_str())</a> |
| 355 | } | 369 | } |
| 356 | if let Some(tasks) = row.tasks_text.clone() { | 370 | if let Some(tasks) = row.tasks_text.clone() { |
| 357 | <span class="task-progress">(tasks.as_str())</span> | 371 | <span class="task-progress">(tasks.as_str())</span> |
| @@ -363,25 +377,24 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> { | |||
| 363 | <img class="avatar avatar-sm" src=(assignee.avatar.as_str()) alt=(assignee.name.as_str()) title=(assignee.name.as_str()) width="20" height="20"> | 377 | <img class="avatar avatar-sm" src=(assignee.avatar.as_str()) alt=(assignee.name.as_str()) title=(assignee.name.as_str()) width="20" height="20"> |
| 364 | } | 378 | } |
| 365 | if row.has_comments { | 379 | if row.has_comments { |
| 366 | - <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> | 380 | + " · " <a href=(row.href.as_str())>(row.comments_text.as_str())</a> |
| 367 | } | 381 | } |
| 368 | - </div> | 382 | + </span> |
| 369 | </div> | 383 | </div> |
| 370 | - </div> | 384 | + } |
| 371 | - } | ||
| 372 | - </div> | ||
| 373 | - } | ||
| 374 | - if has_newer || has_older { | ||
| 375 | - <nav class="sub"> | ||
| 376 | - if has_newer { | ||
| 377 | - <a href=(newer_href.as_str())>(g::t(lang, K::Newer))</a> | ||
| 378 | } | 385 | } |
| 379 | - <span>(page_label.as_str())</span> | 386 | + if has_newer || has_older { |
| 380 | - if has_older { | 387 | + <nav class="sub"> |
| 381 | - <a href=(older_href.as_str())>(g::t(lang, K::Older))</a> | 388 | + if has_newer { |
| 389 | + <a href=(newer_href.as_str())>(g::t(lang, K::Newer))</a> | ||
| 390 | + } | ||
| 391 | + <span>(page_label.as_str())</span> | ||
| 392 | + if has_older { | ||
| 393 | + <a href=(older_href.as_str())>(g::t(lang, K::Older))</a> | ||
| 394 | + } | ||
| 395 | + </nav> | ||
| 382 | } | 396 | } |
| 383 | - </nav> | 397 | + </div> |
| 384 | - } | ||
| 385 | </div> | 398 | </div> |
| 386 | ) | 399 | ) |
| 387 | }) | 400 | }) |
| @@ -398,7 +411,7 @@ mod tests { | |||
| 398 | } | 411 | } |
| 399 | 412 | ||
| 400 | fn rows(html: &str) -> usize { | 413 | fn rows(html: &str) -> usize { |
| 401 | - html.matches("class=\"line issue-row\"").count() | 414 | + html.matches("class=\"line issue-row\" data-kb-row=\"\"").count() |
| 402 | } | 415 | } |
| 403 | 416 | ||
| 404 | const HEAD_OID: &str = "1111111111111111111111111111111111111111"; | 417 | const HEAD_OID: &str = "1111111111111111111111111111111111111111"; |
| @@ -448,7 +461,7 @@ mod tests { | |||
| 448 | html.contains(&format!("href=\"/{OWNER}/{REPO}/pulls/2\"")), | 461 | html.contains(&format!("href=\"/{OWNER}/{REPO}/pulls/2\"")), |
| 449 | "{html}" | 462 | "{html}" |
| 450 | ); | 463 | ); |
| 451 | - assert!(html.contains("issue-badge-open\">Open<")); | 464 | + assert!(!html.contains("badge\">Open<"), "open rows carry no badge"); |
| 452 | assert!(html.contains(&format!("href=\"/{OWNER}/{REPO}/compare\""))); | 465 | assert!(html.contains(&format!("href=\"/{OWNER}/{REPO}/compare\""))); |
| 453 | assert!(html.contains("New pull request"), "case signed in"); | 466 | assert!(html.contains("New pull request"), "case signed in"); |
| 454 | let anon = send(&fx.router, "GET", &base(), false, None, &[]) | 467 | let anon = send(&fx.router, "GET", &base(), false, None, &[]) |
| @@ -547,16 +560,16 @@ mod tests { | |||
| 547 | assert!(closed.contains("merged pull"), "{closed}"); | 560 | assert!(closed.contains("merged pull"), "{closed}"); |
| 548 | assert!(closed.contains("dropped pull"), "{closed}"); | 561 | assert!(closed.contains("dropped pull"), "{closed}"); |
| 549 | assert!(!closed.contains("still open pull"), "{closed}"); | 562 | assert!(!closed.contains("still open pull"), "{closed}"); |
| 550 | - assert!(closed.contains("issue-badge-merged\">Merged<"), "{closed}"); | 563 | + assert!(closed.contains("· Merged ·"), "{closed}"); |
| 551 | - assert!(closed.contains("issue-badge-closed\">Closed<"), "{closed}"); | 564 | + assert!(closed.contains("· Closed ·"), "{closed}"); |
| 552 | - assert_eq!(closed.matches("issue-badge-merged\">Merged<").count(), 1); | 565 | + assert_eq!(closed.matches("· Merged ·").count(), 1); |
| 553 | 566 | ||
| 554 | let open = send(&fx.router, "GET", &base(), true, None, &[]) | 567 | let open = send(&fx.router, "GET", &base(), true, None, &[]) |
| 555 | .await | 568 | .await |
| 556 | .text(); | 569 | .text(); |
| 557 | assert!(open.contains("still open pull")); | 570 | assert!(open.contains("still open pull")); |
| 558 | assert!(!open.contains("merged pull")); | 571 | assert!(!open.contains("merged pull")); |
| 559 | - assert!(!open.contains("issue-badge-merged")); | 572 | + assert!(!open.contains("badge\">Merged<")); |
| 560 | } | 573 | } |
| 561 | 574 | ||
| 562 | #[tokio::test] | 575 | #[tokio::test] |
crates/forge-web/src/pages/refs.rsmodified+4 -4
| @@ -111,26 +111,26 @@ async fn refs_table(rows: Vec<RefRow>, lang: Lang) -> Result<impl View> { | |||
| 111 | if empty { | 111 | if empty { |
| 112 | <p class="state">(g::t(lang, K::NothingHere))</p> | 112 | <p class="state">(g::t(lang, K::NothingHere))</p> |
| 113 | } else { | 113 | } else { |
| 114 | - <div> | 114 | + <div class="sheet"> |
| 115 | for row in rows.into_iter() { | 115 | for row in rows.into_iter() { |
| 116 | if let Some(last) = row.last { | 116 | if let Some(last) = row.last { |
| 117 | <details class="row-open" data-kb-row=""> | 117 | <details class="row-open" data-kb-row=""> |
| 118 | <summary class="line"> | 118 | <summary class="line"> |
| 119 | <a class="name" href=(row.href)>(row.name)</a> | 119 | <a class="name" href=(row.href)>(row.name)</a> |
| 120 | if row.is_default { | 120 | if row.is_default { |
| 121 | - <span class="badge public">(g::t(lang, K::DefaultBadge))</span> | 121 | + <span class="hint">(g::t(lang, K::DefaultBadge))</span> |
| 122 | } | 122 | } |
| 123 | <span class="val"><time datetime=(last.iso.clone()) title=(last.absolute)>(last.age)</time></span> | 123 | <span class="val"><time datetime=(last.iso.clone()) title=(last.absolute)>(last.age)</time></span> |
| 124 | </summary> | 124 | </summary> |
| 125 | <div class="opened"> | 125 | <div class="opened"> |
| 126 | - <p class="state"><a href=(last.href)>commit_line(subject: last.summary.clone())</a></p> | 126 | + <p><a href=(last.href)>commit_line(subject: last.summary.clone())</a></p> |
| 127 | </div> | 127 | </div> |
| 128 | </details> | 128 | </details> |
| 129 | } else { | 129 | } else { |
| 130 | <div class="line" data-kb-row=""> | 130 | <div class="line" data-kb-row=""> |
| 131 | <a class="name" href=(row.href)>(row.name)</a> | 131 | <a class="name" href=(row.href)>(row.name)</a> |
| 132 | if row.is_default { | 132 | if row.is_default { |
| 133 | - <span class="badge public">(g::t(lang, K::DefaultBadge))</span> | 133 | + <span class="hint">(g::t(lang, K::DefaultBadge))</span> |
| 134 | } | 134 | } |
| 135 | </div> | 135 | </div> |
| 136 | } | 136 | } |
crates/forge-web/src/pages/register.rsmodified+18 -14
| @@ -25,6 +25,7 @@ use crate::i18n::{self, Key, Lang, password_too_long, password_too_short, t}; | |||
| 25 | use crate::mail::account; | 25 | use crate::mail::account; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| 27 | use crate::throttle; | 27 | use crate::throttle; |
| 28 | +use crate::views::parts::{SubPart, head}; | ||
| 28 | use crate::views::{alert, shell, user_facing_message}; | 29 | use crate::views::{alert, shell, user_facing_message}; |
| 29 | 30 | ||
| 30 | const MIN_PASSWORD_CHARS: usize = 12; | 31 | const MIN_PASSWORD_CHARS: usize = 12; |
| @@ -127,9 +128,14 @@ async fn register_form( | |||
| 127 | precsrf: &str, | 128 | precsrf: &str, |
| 128 | error: Option<String>, | 129 | error: Option<String>, |
| 129 | ) -> Result<impl View> { | 130 | ) -> Result<impl View> { |
| 131 | + let sub = match (gate, invited) { | ||
| 132 | + (Gate::Form, true) => vec![SubPart::text(t(lang, Key::RegisterInviteSub))], | ||
| 133 | + (Gate::Form, false) => vec![SubPart::text(t(lang, Key::RegisterSub))], | ||
| 134 | + _ => Vec::new(), | ||
| 135 | + }; | ||
| 130 | Ok(view! { | 136 | Ok(view! { |
| 131 | - <section> | 137 | + head(title: t(lang, Key::RegisterTitle), sub: sub) |
| 132 | - <h1>(t(lang, Key::RegisterTitle))</h1> | 138 | + <div class="sheet fit"> |
| 133 | if gate == Gate::NeedsInvite { | 139 | if gate == Gate::NeedsInvite { |
| 134 | <p class="state">(t(lang, Key::RegisterNeedsInvite))</p> | 140 | <p class="state">(t(lang, Key::RegisterNeedsInvite))</p> |
| 135 | } | 141 | } |
| @@ -137,12 +143,6 @@ async fn register_form( | |||
| 137 | <p class="state">(t(lang, Key::RegisterInvalidInvite))</p> | 143 | <p class="state">(t(lang, Key::RegisterInvalidInvite))</p> |
| 138 | } | 144 | } |
| 139 | if gate == Gate::Form { | 145 | if gate == Gate::Form { |
| 140 | - if invited { | ||
| 141 | - <p class="hint">(t(lang, Key::RegisterInviteSub))</p> | ||
| 142 | - } | ||
| 143 | - if !invited { | ||
| 144 | - <p class="hint">(t(lang, Key::RegisterSub))</p> | ||
| 145 | - } | ||
| 146 | <form data-hard="true" method="post" action="/register" class="fields"> | 146 | <form data-hard="true" method="post" action="/register" class="fields"> |
| 147 | if let Some(message) = error { | 147 | if let Some(message) = error { |
| 148 | alert(message: message.as_str()) | 148 | alert(message: message.as_str()) |
| @@ -177,7 +177,7 @@ async fn register_form( | |||
| 177 | <button type="submit" class="primary">(t(lang, Key::RegisterSubmit))</button> | 177 | <button type="submit" class="primary">(t(lang, Key::RegisterSubmit))</button> |
| 178 | </form> | 178 | </form> |
| 179 | } | 179 | } |
| 180 | - </section> | 180 | + </div> |
| 181 | }) | 181 | }) |
| 182 | } | 182 | } |
| 183 | 183 | ||
| @@ -352,12 +352,16 @@ async fn verify_body( | |||
| 352 | precsrf: &str, | 352 | precsrf: &str, |
| 353 | mode: VerifyMode, | 353 | mode: VerifyMode, |
| 354 | ) -> Result<impl View> { | 354 | ) -> Result<impl View> { |
| 355 | + let sub = if mode == VerifyMode::Confirm { | ||
| 356 | + vec![SubPart::text(t(lang, Key::VerifyConfirmSub))] | ||
| 357 | + } else { | ||
| 358 | + Vec::new() | ||
| 359 | + }; | ||
| 355 | Ok(view! { | 360 | Ok(view! { |
| 356 | - <section> | 361 | + head(title: t(lang, Key::VerifyTitle), sub: sub) |
| 357 | - <h1>(t(lang, Key::VerifyTitle))</h1> | 362 | + <div class="sheet fit"> |
| 358 | if mode == VerifyMode::Confirm { | 363 | if mode == VerifyMode::Confirm { |
| 359 | - <p class="hint">(t(lang, Key::VerifyConfirmSub))</p> | 364 | + <form data-hard="true" method="post" action=(format!("/verify/{token}")) class="sec"> |
| 360 | - <form data-hard="true" method="post" action=(format!("/verify/{token}")) class="fields"> | ||
| 361 | <input type="hidden" name="precsrf" value=(precsrf)> | 365 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 362 | <button type="submit" class="primary">(t(lang, Key::VerifyConfirm))</button> | 366 | <button type="submit" class="primary">(t(lang, Key::VerifyConfirm))</button> |
| 363 | </form> | 367 | </form> |
| @@ -368,7 +372,7 @@ async fn verify_body( | |||
| 368 | if mode == VerifyMode::Invalid { | 372 | if mode == VerifyMode::Invalid { |
| 369 | <p class="state">(t(lang, Key::VerifyInvalid))</p> | 373 | <p class="state">(t(lang, Key::VerifyInvalid))</p> |
| 370 | } | 374 | } |
| 371 | - </section> | 375 | + </div> |
| 372 | }) | 376 | }) |
| 373 | } | 377 | } |
| 374 | 378 | ||
crates/forge-web/src/pages/releases.rsmodified+143 -156
| @@ -203,10 +203,8 @@ pub struct ReleaseCard { | |||
| 203 | 203 | ||
| 204 | /// The "latest release" summary shown on the repo home page. | 204 | /// The "latest release" summary shown on the repo home page. |
| 205 | pub struct LatestRelease { | 205 | pub struct LatestRelease { |
| 206 | - pub title: String, | ||
| 207 | pub tag: String, | 206 | pub tag: String, |
| 208 | pub href: String, | 207 | pub href: String, |
| 209 | - pub(crate) when: When, | ||
| 210 | pub assets: Vec<AssetLink>, | 208 | pub assets: Vec<AssetLink>, |
| 211 | } | 209 | } |
| 212 | 210 | ||
| @@ -249,15 +247,9 @@ pub async fn latest_release_for_home( | |||
| 249 | }; | 247 | }; |
| 250 | let title = title_of(ctx); | 248 | let title = title_of(ctx); |
| 251 | let assets = state.store.list_release_assets(&release.id).await?; | 249 | let assets = state.store.list_release_assets(&release.id).await?; |
| 252 | - let when = release | ||
| 253 | - .published_at | ||
| 254 | - .as_deref() | ||
| 255 | - .unwrap_or(&release.created_at); | ||
| 256 | Ok(Some(LatestRelease { | 250 | Ok(Some(LatestRelease { |
| 257 | - title: release.title.clone(), | ||
| 258 | tag: release.tag.clone(), | 251 | tag: release.tag.clone(), |
| 259 | href: tag_href(&title, &release.tag), | 252 | href: tag_href(&title, &release.tag), |
| 260 | - when: When::new(ctx.lang, when, ctx.viewer_tz(), now_unix()), | ||
| 261 | assets: assets | 253 | assets: assets |
| 262 | .iter() | 254 | .iter() |
| 263 | .map(|asset| asset_link(&title, &release.tag, asset)) | 255 | .map(|asset| asset_link(&title, &release.tag, asset)) |
| @@ -370,22 +362,20 @@ async fn release_form( | |||
| 370 | } | 362 | } |
| 371 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 363 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 372 | if is_new { | 364 | if is_new { |
| 373 | - // The tag and the target branch are short, so they share a row. | 365 | + <div class="field"> |
| 374 | - <div class="field-pair"> | 366 | + <label for="release-tag">(g::t(lang, K::Tag))</label> |
| 375 | - <div class="field"> | 367 | + <input id="release-tag" type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> |
| 376 | - <label for="release-tag">(g::t(lang, K::Tag))</label> | 368 | + <p class="hint">(tag_hint)</p> |
| 377 | - <input id="release-tag" type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> | 369 | + </div> |
| 378 | - </div> | 370 | + <div class="field"> |
| 379 | - <div class="field"> | 371 | + <label for="release-target">(g::t(lang, K::TargetBranch))</label> |
| 380 | - <label for="release-target">(g::t(lang, K::TargetBranch))</label> | 372 | + <select id="release-target" name="target"> |
| 381 | - <select id="release-target" name="target"> | 373 | + for branch in branches.iter() { |
| 382 | - for branch in branches.iter() { | 374 | + <option value=(branch.as_str()) selected=(branch.as_str() == draft.target.as_str())>(branch.as_str())</option> |
| 383 | - <option value=(branch.as_str()) selected=(branch.as_str() == draft.target.as_str())>(branch.as_str())</option> | 375 | + } |
| 384 | - } | 376 | + </select> |
| 385 | - </select> | 377 | + <p class="hint">(crate::pages::passkeys::s(lang, "Used only when the tag is created.", "Yalnızca etiket oluşturulurken kullanılır."))</p> |
| 386 | - </div> | ||
| 387 | </div> | 378 | </div> |
| 388 | - <p class="hint">(tag_hint)</p> | ||
| 389 | } else { | 379 | } else { |
| 390 | <div class="field"> | 380 | <div class="field"> |
| 391 | <label for="release-tag">(g::t(lang, K::Tag))</label> | 381 | <label for="release-tag">(g::t(lang, K::Tag))</label> |
| @@ -494,7 +484,11 @@ async fn list_body( | |||
| 494 | ) -> Result<impl View> { | 484 | ) -> Result<impl View> { |
| 495 | let (links, prev, next) = nav; | 485 | let (links, prev, next) = nav; |
| 496 | Ok(view! { | 486 | Ok(view! { |
| 497 | - repo_head(head: head) | 487 | + repo_head(head: head, |
| 488 | + if let Some(href) = &new_href { | ||
| 489 | + <a class="button primary" href=(href.as_str())>(g::t(lang, K::NewRelease))</a> | ||
| 490 | + } | ||
| 491 | + ) | ||
| 498 | if let Some((text, is_error)) = notice { | 492 | if let Some((text, is_error)) = notice { |
| 499 | if is_error { | 493 | if is_error { |
| 500 | alert(message: text) | 494 | alert(message: text) |
| @@ -502,56 +496,48 @@ async fn list_body( | |||
| 502 | <p class="state" role="status">(text)</p> | 496 | <p class="state" role="status">(text)</p> |
| 503 | } | 497 | } |
| 504 | } | 498 | } |
| 505 | - <div data-live=(live.as_str())> | 499 | + <div class="sheet" data-live=(live.as_str())> |
| 506 | - <section class="sec"> | 500 | + if cards.is_empty() { |
| 507 | - <h2>(g::t(lang, K::Releases))</h2> | 501 | + empty_state(title: g::t(lang, K::NoReleasesYet)) |
| 508 | - if let Some(href) = &new_href { | ||
| 509 | - <div class="acts"> | ||
| 510 | - <a class="act" href=(href.as_str())>(g::t(lang, K::NewRelease))</a> | ||
| 511 | - </div> | ||
| 512 | } | 502 | } |
| 513 | - </section> | 503 | + for card in cards.iter() { |
| 514 | - if cards.is_empty() { | 504 | + <details class="row-open" data-kb-row="" title=(card.body.as_str())> |
| 515 | - empty_state(title: g::t(lang, K::NoReleasesYet)) | 505 | + <summary class="line"> |
| 516 | - } | 506 | + <span class="name"> |
| 517 | - for card in cards.iter() { | 507 | + (card.title.as_str()) |
| 518 | - <details class="row-open" data-kb-row="" title=(card.body.as_str())> | 508 | + if card.latest { |
| 519 | - <summary class="line"> | 509 | + " " <span class="hint">(g::t(lang, K::Latest))</span> |
| 520 | - <span class="name"> | 510 | + } |
| 521 | - (card.title.as_str()) | 511 | + if card.prerelease { |
| 522 | - if card.latest { | 512 | + " " <span class="hint">(g::t(lang, K::PreRelease))</span> |
| 523 | - " " <span class="badge latest">(g::t(lang, K::Latest))</span> | 513 | + } |
| 524 | - } | 514 | + if card.draft { |
| 525 | - if card.prerelease { | 515 | + " " <span class="hint">(g::t(lang, K::Draft))</span> |
| 526 | - " " <span class="badge">(g::t(lang, K::PreRelease))</span> | 516 | + } |
| 517 | + </span> | ||
| 518 | + <span class="val"> | ||
| 519 | + <code>(card.tag.as_str())</code> " · " <time data-rel="true" datetime=(card.when.iso.as_str()) title=(card.when.absolute.as_str())>(card.when.relative.as_str())</time> | ||
| 520 | + </span> | ||
| 521 | + </summary> | ||
| 522 | + <div class="opened"> | ||
| 523 | + if !card.author.is_empty() { | ||
| 524 | + <p class="hint">user_link(shown: card.author.as_str(), login: card.author.as_str())</p> | ||
| 527 | } | 525 | } |
| 528 | - if card.draft { | 526 | + if !card.assets.is_empty() { |
| 529 | - " " <span class="badge draft">(g::t(lang, K::Draft))</span> | 527 | + <div class="sub"> |
| 528 | + for asset in card.assets.iter() { | ||
| 529 | + <a href=(asset.href.as_str())>(asset.name.as_str()) " (" (asset.size.as_str()) ", " (g::download_count(lang, asset.downloads)) ")"</a> | ||
| 530 | + } | ||
| 531 | + </div> | ||
| 530 | } | 532 | } |
| 531 | - </span> | 533 | + <div class="acts"> |
| 532 | - <span class="val"> | 534 | + <a class="act" href=(card.href.as_str())>(card.tag.as_str())</a> |
| 533 | - <code>(card.tag.as_str())</code> " · " <time data-rel="true" datetime=(card.when.iso.as_str()) title=(card.when.absolute.as_str())>(card.when.relative.as_str())</time> | 535 | + <a class="act" href=(card.edit_href.as_str())>(g::t(lang, K::Edit))</a> |
| 534 | - </span> | ||
| 535 | - </summary> | ||
| 536 | - <div class="opened"> | ||
| 537 | - if !card.author.is_empty() { | ||
| 538 | - <p class="hint">user_link(shown: card.author.as_str(), login: card.author.as_str())</p> | ||
| 539 | - } | ||
| 540 | - if !card.assets.is_empty() { | ||
| 541 | - <div class="sub"> | ||
| 542 | - for asset in card.assets.iter() { | ||
| 543 | - <a href=(asset.href.as_str())>(asset.name.as_str()) " (" (asset.size.as_str()) ", " (g::download_count(lang, asset.downloads)) ")"</a> | ||
| 544 | - } | ||
| 545 | </div> | 536 | </div> |
| 546 | - } | ||
| 547 | - <div class="acts"> | ||
| 548 | - <a class="act" href=(card.href.as_str())>(card.tag.as_str())</a> | ||
| 549 | - <a class="act" href=(card.edit_href.as_str())>(g::t(lang, K::Edit))</a> | ||
| 550 | </div> | 537 | </div> |
| 551 | - </div> | 538 | + </details> |
| 552 | - </details> | 539 | + } |
| 553 | - } | 540 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 554 | - pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | ||
| 555 | </div> | 541 | </div> |
| 556 | }) | 542 | }) |
| 557 | } | 543 | } |
| @@ -636,10 +622,12 @@ async fn new_form_body( | |||
| 636 | ) -> Result<impl View> { | 622 | ) -> Result<impl View> { |
| 637 | Ok(view! { | 623 | Ok(view! { |
| 638 | repo_head(head: head) | 624 | repo_head(head: head) |
| 639 | - <section class="sec"> | 625 | + <div class="sheet fit"> |
| 640 | - <h2>(g::t(lang, K::NewRelease))</h2> | 626 | + <section class="sec"> |
| 641 | - release_form(action: action, csrf: csrf, lang: lang, is_new: true, move_target: true, draft: draft, branches: branches, submit: g::t(lang, K::SaveRelease)) | 627 | + <h2>(g::t(lang, K::NewRelease))</h2> |
| 642 | - </section> | 628 | + release_form(action: action, csrf: csrf, lang: lang, is_new: true, move_target: true, draft: draft, branches: branches, submit: g::t(lang, K::SaveRelease)) |
| 629 | + </section> | ||
| 630 | + </div> | ||
| 643 | }) | 631 | }) |
| 644 | } | 632 | } |
| 645 | 633 | ||
| @@ -806,7 +794,11 @@ async fn release_tag_page(cx: &Cx) -> Result<impl View> { | |||
| 806 | }; | 794 | }; |
| 807 | Ok(view! { | 795 | Ok(view! { |
| 808 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 796 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 809 | - repo_head(head: head) | 797 | + repo_head(head: head, title: Some(card.title.clone()), |
| 798 | + if writer { | ||
| 799 | + <a class="act" href=(edit_href.as_str())>(g::t(lang, K::Edit))</a> | ||
| 800 | + } | ||
| 801 | + ) | ||
| 810 | if let Some((text, is_error)) = notice { | 802 | if let Some((text, is_error)) = notice { |
| 811 | if is_error { | 803 | if is_error { |
| 812 | alert(message: text) | 804 | alert(message: text) |
| @@ -814,68 +806,62 @@ async fn release_tag_page(cx: &Cx) -> Result<impl View> { | |||
| 814 | <p class="state" role="status">(text)</p> | 806 | <p class="state" role="status">(text)</p> |
| 815 | } | 807 | } |
| 816 | } | 808 | } |
| 817 | - <div data-live=(live.as_str())> | 809 | + <div class="sheet" data-live=(live.as_str())> |
| 818 | - <nav class="sub"> | 810 | + <div class="sheet-tools"> |
| 819 | - <a href=(all_href.as_str())>(g::t(lang, K::AllReleases))</a> | 811 | + <strong>(card.tag.as_str())</strong> |
| 820 | - </nav> | 812 | + if card.prerelease { |
| 821 | - <h1 class="h1"> | 813 | + <span class="hint">(g::t(lang, K::PreRelease))</span> |
| 822 | - (card.title.as_str()) | 814 | + } |
| 823 | - if card.prerelease { | 815 | + if card.draft { |
| 824 | - " " <span class="badge">(g::t(lang, K::PreRelease))</span> | 816 | + <span class="hint">(g::t(lang, K::Draft))</span> |
| 825 | - } | 817 | + } |
| 826 | - if card.draft { | 818 | + <a class="act" href=(all_href.as_str())>(g::t(lang, K::AllReleases))</a> |
| 827 | - " " <span class="badge draft">(g::t(lang, K::Draft))</span> | 819 | + </div> |
| 828 | - } | ||
| 829 | - </h1> | ||
| 830 | - <p class="hint"> | ||
| 831 | - <code>(card.tag.as_str())</code> | ||
| 832 | - " \u{b7} " <time data-rel="true" datetime=(card.when.iso.as_str()) title=(card.when.absolute.as_str())>(card.when.relative.as_str())</time> | ||
| 833 | - if !card.author.is_empty() { | ||
| 834 | - " \u{b7} " user_link(shown: card.author.as_str(), login: card.author.as_str()) | ||
| 835 | - } | ||
| 836 | - </p> | ||
| 837 | - if !body_html.is_empty() { | ||
| 838 | <section class="sec"> | 820 | <section class="sec"> |
| 839 | - <div class="markdown-body release-body">(Unescaped::new_unchecked(body_html))</div> | 821 | + <p class="hint"> |
| 822 | + <time data-rel="true" datetime=(card.when.iso.as_str()) title=(card.when.absolute.as_str())>(card.when.relative.as_str())</time> | ||
| 823 | + if !card.author.is_empty() { | ||
| 824 | + " \u{b7} " user_link(shown: card.author.as_str(), login: card.author.as_str()) | ||
| 825 | + } | ||
| 826 | + </p> | ||
| 827 | + if !body_html.is_empty() { | ||
| 828 | + <div class="markdown-body release-body">(Unescaped::new_unchecked(body_html))</div> | ||
| 829 | + } | ||
| 840 | </section> | 830 | </section> |
| 841 | - } | 831 | + <section class="sec"> |
| 842 | - <section class="sec"> | 832 | + <h2>(g::t(lang, K::Assets))</h2> |
| 843 | - <h2>(g::t(lang, K::Assets))</h2> | 833 | + if card.assets.is_empty() { |
| 844 | - if card.assets.is_empty() { | 834 | + <p class="state">(g::t(lang, K::NoAssets))</p> |
| 845 | - <p class="state">(g::t(lang, K::NoAssets))</p> | 835 | + } else { |
| 846 | - } else { | 836 | + for asset in card.assets.iter() { |
| 847 | - for asset in card.assets.iter() { | 837 | + <details class="row-open" data-kb-row=""> |
| 848 | - <details class="row-open" data-kb-row=""> | 838 | + <summary class="line"> |
| 849 | - <summary class="line"> | 839 | + <span class="name">(asset.name.as_str())</span> |
| 850 | - <span class="name">(asset.name.as_str())</span> | 840 | + <span class="val">(asset.size.as_str()) " · " (g::download_count(lang, asset.downloads))</span> |
| 851 | - <span class="val">(asset.size.as_str()) " · " (g::download_count(lang, asset.downloads))</span> | 841 | + </summary> |
| 852 | - </summary> | 842 | + <div class="opened"> |
| 853 | - <div class="opened"> | 843 | + <code class="hint">(asset.sha256.as_str())</code> |
| 854 | - <code class="hint">(asset.sha256.as_str())</code> | 844 | + <div class="acts"> |
| 855 | - <div class="acts"> | 845 | + <a class="act" href=(asset.href.as_str())>(g::t(lang, K::Download))</a> |
| 856 | - <a class="act" href=(asset.href.as_str())>(g::t(lang, K::Download))</a> | 846 | + </div> |
| 857 | </div> | 847 | </div> |
| 858 | - </div> | 848 | + </details> |
| 859 | - </details> | 849 | + } |
| 860 | } | 850 | } |
| 861 | - } | 851 | + </section> |
| 862 | - </section> | ||
| 863 | - <section class="sec"> | ||
| 864 | - <h2>(g::t(lang, K::SourceCode))</h2> | ||
| 865 | - <div class="acts"> | ||
| 866 | - <a class="act" href=(archive_tar.as_str())>"tar.gz"</a> | ||
| 867 | - <a class="act" href=(archive_zip.as_str())>"zip"</a> | ||
| 868 | - </div> | ||
| 869 | - </section> | ||
| 870 | - if writer { | ||
| 871 | <section class="sec"> | 852 | <section class="sec"> |
| 853 | + <h2>(g::t(lang, K::SourceCode))</h2> | ||
| 872 | <div class="acts"> | 854 | <div class="acts"> |
| 873 | - <a class="act" href=(edit_href.as_str())>(g::t(lang, K::Edit))</a> | 855 | + <a class="act" href=(archive_tar.as_str())>"tar.gz"</a> |
| 874 | - confirm_act(lang: lang, label: g::t(lang, K::DeleteRelease), action: delete_href.as_str(), csrf: csrf.as_str(), | 856 | + <a class="act" href=(archive_zip.as_str())>"zip"</a> |
| 875 | - fields: vec![("confirm".to_owned(), "on".to_owned())], note: Some(g::t(lang, K::DeleteReleaseHelp).to_owned())) | ||
| 876 | </div> | 857 | </div> |
| 877 | </section> | 858 | </section> |
| 878 | - } | 859 | + if writer { |
| 860 | + <section class="sec"> | ||
| 861 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteRelease), action: delete_href.as_str(), csrf: csrf.as_str(), | ||
| 862 | + fields: vec![("confirm".to_owned(), "on".to_owned())], note: Some(g::t(lang, K::DeleteReleaseHelp).to_owned())) | ||
| 863 | + </section> | ||
| 864 | + } | ||
| 879 | </div> | 865 | </div> |
| 880 | ) | 866 | ) |
| 881 | }) | 867 | }) |
| @@ -902,7 +888,9 @@ async fn edit_body( | |||
| 902 | delete_href: String, | 888 | delete_href: String, |
| 903 | ) -> Result<impl View> { | 889 | ) -> Result<impl View> { |
| 904 | Ok(view! { | 890 | Ok(view! { |
| 905 | - repo_head(head: head) | 891 | + repo_head(head: head, |
| 892 | + <a class="act" href=(view_tag.as_str())>(g::t(lang, K::BackToRelease))</a> | ||
| 893 | + ) | ||
| 906 | if let Some((text, is_error)) = notice { | 894 | if let Some((text, is_error)) = notice { |
| 907 | if is_error { | 895 | if is_error { |
| 908 | alert(message: text) | 896 | alert(message: text) |
| @@ -910,34 +898,33 @@ async fn edit_body( | |||
| 910 | <p class="state" role="status">(text)</p> | 898 | <p class="state" role="status">(text)</p> |
| 911 | } | 899 | } |
| 912 | } | 900 | } |
| 913 | - <nav class="sub"> | 901 | + <div class="sheet"> |
| 914 | - <a href=(view_tag.as_str())>(g::t(lang, K::BackToRelease))</a> | 902 | + <section class="sec"> |
| 915 | - </nav> | 903 | + <h2>(g::t(lang, K::EditRelease))</h2> |
| 916 | - <section class="sec"> | 904 | + release_form(action: action, csrf: csrf.clone(), lang: lang, is_new: false, move_target: move_target, draft: draft, branches: branches, submit: g::t(lang, K::SaveRelease)) |
| 917 | - <h2>(g::t(lang, K::EditRelease))</h2> | 905 | + </section> |
| 918 | - release_form(action: action, csrf: csrf.clone(), lang: lang, is_new: false, move_target: move_target, draft: draft, branches: branches, submit: g::t(lang, K::SaveRelease)) | 906 | + <section class="sec"> |
| 919 | - </section> | 907 | + <h2>(g::t(lang, K::Assets))</h2> |
| 920 | - <section class="sec"> | 908 | + <p class="hint">(upload_hint.as_str())</p> |
| 921 | - <h2>(g::t(lang, K::Assets))</h2> | 909 | + asset_rows(assets: assets, delete_actions: delete_actions, upload_action: upload_action.clone(), csrf: csrf.clone(), lang: lang) |
| 922 | - <p class="hint">(upload_hint.as_str())</p> | 910 | + <form method="post" action=(upload_action.as_str()) enctype="multipart/form-data" class="fields"> |
| 923 | - asset_rows(assets: assets, delete_actions: delete_actions, upload_action: upload_action.clone(), csrf: csrf.clone(), lang: lang) | 911 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 924 | - <form method="post" action=(upload_action.as_str()) enctype="multipart/form-data" class="fields"> | 912 | + <div class="field"> |
| 925 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 913 | + <label for="upload-file">(g::t(lang, K::File))</label> |
| 926 | - <div class="field"> | 914 | + <input id="upload-file" type="file" name="file" required="required"> |
| 927 | - <label for="upload-file">(g::t(lang, K::File))</label> | 915 | + </div> |
| 928 | - <input id="upload-file" type="file" name="file" required="required"> | 916 | + <button type="submit" class="primary">(g::t(lang, K::UploadAsset))</button> |
| 917 | + </form> | ||
| 918 | + </section> | ||
| 919 | + <section class="sec"> | ||
| 920 | + <h2>(g::t(lang, K::DeleteRelease))</h2> | ||
| 921 | + <p class="hint">(g::t(lang, K::DeleteReleaseHelp))</p> | ||
| 922 | + <div class="acts"> | ||
| 923 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteRelease), action: delete_href.as_str(), csrf: csrf.as_str(), | ||
| 924 | + fields: vec![("confirm".to_owned(), "on".to_owned())]) | ||
| 929 | </div> | 925 | </div> |
| 930 | - <button type="submit" class="primary">(g::t(lang, K::UploadAsset))</button> | 926 | + </section> |
| 931 | - </form> | 927 | + </div> |
| 932 | - </section> | ||
| 933 | - <section class="sec"> | ||
| 934 | - <h2>(g::t(lang, K::DeleteRelease))</h2> | ||
| 935 | - <p class="hint">(g::t(lang, K::DeleteReleaseHelp))</p> | ||
| 936 | - <div class="acts"> | ||
| 937 | - confirm_act(lang: lang, label: g::t(lang, K::DeleteRelease), action: delete_href.as_str(), csrf: csrf.as_str(), | ||
| 938 | - fields: vec![("confirm".to_owned(), "on".to_owned())]) | ||
| 939 | - </div> | ||
| 940 | - </section> | ||
| 941 | }) | 928 | }) |
| 942 | } | 929 | } |
| 943 | 930 | ||
crates/forge-web/src/pages/releases_tests.rsmodified+2 -2
| @@ -384,12 +384,12 @@ async fn drafts_and_permissions_share_one_repo() { | |||
| 384 | assert!(fx.store.release(&rel.id).await.expect("read").is_some()); | 384 | assert!(fx.store.release(&rel.id).await.expect("read").is_some()); |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | - // The repo home shows the latest release card and links to the releases tab. | 387 | + // The repo home's head names the latest release and links to it and to the releases tab. |
| 388 | { | 388 | { |
| 389 | fx.release("v0.9-beta", false).await; | 389 | fx.release("v0.9-beta", false).await; |
| 390 | let home = send(&fx.app, "GET", "/tahinli/proj", None, None, Vec::new()).await; | 390 | let home = send(&fx.app, "GET", "/tahinli/proj", None, None, Vec::new()).await; |
| 391 | assert_eq!(home.status, 200); | 391 | assert_eq!(home.status, 200); |
| 392 | - assert!(home.text().contains("Latest release")); | 392 | + assert!(home.text().contains("/tahinli/proj/releases/tag/v0.9-beta")); |
| 393 | assert!( | 393 | assert!( |
| 394 | home.text().contains("/tahinli/proj/releases"), | 394 | home.text().contains("/tahinli/proj/releases"), |
| 395 | "the tabs link to releases" | 395 | "the tabs link to releases" |
crates/forge-web/src/pages/repo.rsmodified+125 -174
| @@ -1,6 +1,5 @@ | |||
| 1 | -//! Page: repository home at `/{owner}/{repo}`. Shows the default branch's root tree, a Clone | 1 | +//! Page: repository home at `/{owner}/{repo}`. Shows the default branch's root folder in the rail |
| 2 | -//! popover and the README, with a branch aside. An empty repo shows the clone popover and push | 2 | +//! and the README in the sheet. An empty repo shows push instructions instead. |
| 3 | -//! instructions instead. | ||
| 4 | 3 | ||
| 5 | use std::collections::{HashMap, HashSet}; | 4 | use std::collections::{HashMap, HashSet}; |
| 6 | use std::path::PathBuf; | 5 | use std::path::PathBuf; |
| @@ -16,7 +15,7 @@ use topcoat::Result; | |||
| 16 | use topcoat::context::{Cx, app_context}; | 15 | use topcoat::context::{Cx, app_context}; |
| 17 | use topcoat::router::error::not_found; | 16 | use topcoat::router::error::not_found; |
| 18 | use topcoat::router::{page, path_param, route}; | 17 | use topcoat::router::{page, path_param, route}; |
| 19 | -use topcoat::view::{View, component, view}; | 18 | +use topcoat::view::{Child, View, ViewExt, component, view}; |
| 20 | 19 | ||
| 21 | use crate::i18n::code::{self as g, K}; | 20 | use crate::i18n::code::{self as g, K}; |
| 22 | use crate::i18n::{self, Lang}; | 21 | use crate::i18n::{self, Lang}; |
| @@ -28,17 +27,15 @@ use crate::pages::packages; | |||
| 28 | use crate::pages::passkeys::s; | 27 | use crate::pages::passkeys::s; |
| 29 | use crate::pages::refs::{load_refs, ref_links}; | 28 | use crate::pages::refs::{load_refs, ref_links}; |
| 30 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | 29 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 31 | -use crate::pages::repo_side::{ | 30 | +use crate::pages::repo_side::{StripFacts, code_sub, commit_strip, run_pips, run_rows, tree_facts}; |
| 32 | - StripFacts, TreeFacts, commit_strip, readme_meta, repo_dock, repo_strip, run_rows, run_states, | ||
| 33 | - strip_bars, tree_facts, | ||
| 34 | -}; | ||
| 35 | use crate::pages::tree::{ | 31 | use crate::pages::tree::{ |
| 36 | - entry_rows, last_commits, latest_bar, load_readme, read_dir, readme_card, tree_table, | 32 | + entry_rows, last_commits, latest_bar, load_readme, read_dir, readme_sheet, tree_table, |
| 37 | }; | 33 | }; |
| 38 | use crate::state::AppState; | 34 | use crate::state::AppState; |
| 35 | +use crate::views::parts::{SubPart, head_sub}; | ||
| 39 | use crate::views::repo_list::badge_class; | 36 | use crate::views::repo_list::badge_class; |
| 40 | use crate::views::{ | 37 | use crate::views::{ |
| 41 | - empty_state, now_unix, ref_selector, rel_time, relative_time, repo_href, repo_tabs, shell, | 38 | + now_unix, ref_selector, relative_time, repo_href, repo_tabs, shell, |
| 42 | }; | 39 | }; |
| 43 | 40 | ||
| 44 | path_param!(owner); | 41 | path_param!(owner); |
| @@ -65,11 +62,37 @@ pub fn ssh_clone_url(config: &Config, owner: &str, name: &str) -> String { | |||
| 65 | } | 62 | } |
| 66 | } | 63 | } |
| 67 | 64 | ||
| 68 | -/// Header shared by the repo pages: title, visibility, the fork line, the fork and star controls, | 65 | +/// The title a repo page shows when it gives none: the tab it is on. |
| 69 | -/// the archived notice, description and the header tabs. Built by `RepoCtx::head`; every repo page | 66 | +fn tab_title(lang: Lang, active: &str, repo: &str) -> String { |
| 70 | -/// passes one. | 67 | + match active { |
| 68 | + "issues" => g::t(lang, K::TabIssues).to_owned(), | ||
| 69 | + "pulls" => g::t(lang, K::TabPulls).to_owned(), | ||
| 70 | + "ci" => g::t(lang, K::TabCi).to_owned(), | ||
| 71 | + "commits" => g::t(lang, K::TabCommits).to_owned(), | ||
| 72 | + "branches" => g::t(lang, K::BranchesTitle).to_owned(), | ||
| 73 | + "tags" => g::t(lang, K::TagsTitle).to_owned(), | ||
| 74 | + "releases" => g::t(lang, K::TabReleases).to_owned(), | ||
| 75 | + "discussions" => g::t(lang, K::TabDiscussions).to_owned(), | ||
| 76 | + "wiki" => g::t(lang, K::TabWiki).to_owned(), | ||
| 77 | + "security" => i18n::t(lang, i18n::Key::Security).to_owned(), | ||
| 78 | + "settings" => g::t(lang, K::TabSettings).to_owned(), | ||
| 79 | + _ => repo.to_owned(), | ||
| 80 | + } | ||
| 81 | +} | ||
| 82 | + | ||
| 83 | +/// Head of every repo page: the title with its actions right beside it, the sub line and the tabs. | ||
| 84 | +/// The Code tab's head is the repo itself: its name, Clone, Star, Fork and the rest in a menu. Any | ||
| 85 | +/// other tab's head is that tab (or `title`), and `child` holds the page's own actions. `sub` is | ||
| 86 | +/// added to the sub line; the Code tab starts it with the description and the visibility. Built by | ||
| 87 | +/// `RepoCtx::head`; every repo page passes one. | ||
| 71 | #[component] | 88 | #[component] |
| 72 | -pub async fn repo_head(head: RepoHead) -> Result<impl View> { | 89 | +pub async fn repo_head( |
| 90 | + head: RepoHead, | ||
| 91 | + #[default] title: Option<String>, | ||
| 92 | + #[default] sub: Vec<SubPart>, | ||
| 93 | + #[default] pips: Vec<(String, String, &'static str)>, | ||
| 94 | + #[default] child: Child<'_>, | ||
| 95 | +) -> Result<impl View> { | ||
| 73 | let RepoHead { | 96 | let RepoHead { |
| 74 | owner, | 97 | owner, |
| 75 | name, | 98 | name, |
| @@ -78,9 +101,7 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> { | |||
| 78 | description, | 101 | description, |
| 79 | archived, | 102 | archived, |
| 80 | active, | 103 | active, |
| 81 | - hide_search, | ||
| 82 | can_admin, | 104 | can_admin, |
| 83 | - can_delete: _, | ||
| 84 | open_issues, | 105 | open_issues, |
| 85 | open_pulls, | 106 | open_pulls, |
| 86 | forked_from, | 107 | forked_from, |
| @@ -96,23 +117,20 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> { | |||
| 96 | wiki, | 117 | wiki, |
| 97 | security, | 118 | security, |
| 98 | lang, | 119 | lang, |
| 120 | + clone, | ||
| 99 | .. | 121 | .. |
| 100 | } = head; | 122 | } = head; |
| 123 | + let is_code = active == "code"; | ||
| 101 | let badge = badge_class(visibility); | 124 | let badge = badge_class(visibility); |
| 102 | let private = matches!(visibility, forge_core::Visibility::Private); | 125 | let private = matches!(visibility, forge_core::Visibility::Private); |
| 103 | let vis = i18n::visibility_label(lang, visibility); | 126 | let vis = i18n::visibility_label(lang, visibility); |
| 127 | + let shown_title = title.unwrap_or_else(|| tab_title(lang, active, &name)); | ||
| 104 | let active = active.to_owned(); | 128 | let active = active.to_owned(); |
| 105 | // The fork button posts with the same session CSRF token as the star form. | 129 | // The fork button posts with the same session CSRF token as the star form. |
| 106 | let fork_control = match (can_fork, star.as_ref()) { | 130 | let fork_control = match (can_fork, star.as_ref()) { |
| 107 | (true, Some(star)) => Some((repo_href(&owner, &name, "fork", ""), star.csrf.clone())), | 131 | (true, Some(star)) => Some((repo_href(&owner, &name, "fork", ""), star.csrf.clone())), |
| 108 | _ => None, | 132 | _ => None, |
| 109 | }; | 133 | }; |
| 110 | - let fork_line = forked_from.map(|(source_owner, source_name)| { | ||
| 111 | - ( | ||
| 112 | - repo_href(&source_owner, &source_name, "", ""), | ||
| 113 | - format!("{source_owner}/{source_name}"), | ||
| 114 | - ) | ||
| 115 | - }); | ||
| 116 | // Signed-in viewers get a button that stars or unstars; anonymous viewers see the count only. | 134 | // Signed-in viewers get a button that stars or unstars; anonymous viewers see the count only. |
| 117 | let star_control = match star { | 135 | let star_control = match star { |
| 118 | Some(star) => { | 136 | Some(star) => { |
| @@ -137,96 +155,82 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> { | |||
| 137 | }); | 155 | }); |
| 138 | let watch_count = g::watching_count(lang, watchers); | 156 | let watch_count = g::watching_count(lang, watchers); |
| 139 | let fork_count = g::forks_count(lang, forks); | 157 | let fork_count = g::forks_count(lang, forks); |
| 140 | - let mirror_line = mirror.as_ref().map(|source| source.url.clone()); | 158 | + // The sub line: on the Code tab what the repo is, then what the page adds. |
| 141 | - // A stamp is shown as a live relative time between the two words; without one, the status is plain text. | 159 | + let mut parts: Vec<SubPart> = Vec::new(); |
| 142 | - let (mirror_before, mirror_after, mirror_at, mirror_status) = match mirror { | 160 | + if is_code { |
| 143 | - Some(source) => match (source.last_sync, source.last_ok) { | 161 | + if !description.is_empty() { |
| 144 | - (Some(at), Some(true)) => { | 162 | + parts.push(SubPart::text(description.as_str())); |
| 145 | - let (before, after) = g::mirror_synced(lang); | 163 | + } |
| 146 | - (before, after, Some(at), String::new()) | 164 | + parts.push(SubPart::text(vis)); |
| 147 | - } | 165 | + if let Some((source_owner, source_name)) = forked_from { |
| 148 | - (Some(at), _) => { | 166 | + parts.push(SubPart::link( |
| 149 | - let (before, after) = g::mirror_sync_failed(lang); | 167 | + format!("{} {source_owner}/{source_name}", g::t(lang, K::ForkedFrom)), |
| 150 | - (before, after, Some(at), String::new()) | 168 | + repo_href(&source_owner, &source_name, "", ""), |
| 151 | - } | 169 | + )); |
| 152 | - (None, _) => ("", "", None, g::t(lang, K::NotSyncedYet).to_owned()), | 170 | + } |
| 153 | - }, | 171 | + if let Some(source) = mirror { |
| 154 | - None => ("", "", None, String::new()), | 172 | + let status = match (source.last_sync, source.last_ok) { |
| 155 | - }; | 173 | + (Some(_), Some(true)) => g::mirror_synced(lang).0, |
| 174 | + (Some(_), _) => g::mirror_sync_failed(lang).0, | ||
| 175 | + (None, _) => g::t(lang, K::NotSyncedYet), | ||
| 176 | + }; | ||
| 177 | + parts.push(SubPart::text(format!( | ||
| 178 | + "{} {}, {}", | ||
| 179 | + g::t(lang, K::MirrorOf), | ||
| 180 | + source.url, | ||
| 181 | + status.trim() | ||
| 182 | + ))); | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + parts.extend(sub); | ||
| 156 | let live_attr = (!live.is_empty()).then(|| live.clone()); | 186 | let live_attr = (!live.is_empty()).then(|| live.clone()); |
| 157 | - // The head: the path bar names the repo; the actions sit as text links under it, then the tabs, | ||
| 158 | - // then the code search entry. | ||
| 159 | - let has_origin = fork_line.is_some() || mirror_line.is_some(); | ||
| 160 | - let search_action = repo_href(&owner, &name, "search", ""); | ||
| 161 | - let search_label = g::t(lang, K::SearchCodePlaceholder); | ||
| 162 | Ok(view! { | 187 | Ok(view! { |
| 163 | - <section class="repo-head" data-live=(live_attr.as_deref())> | 188 | + <section class="head repo-head" data-live=(live_attr.as_deref())> |
| 164 | - <h1 class="sr-only">(owner.as_str()) "/" (name.as_str())</h1> | 189 | + <div class="head-title"> |
| 165 | - if has_origin { | 190 | + <h1>(shown_title.as_str())</h1> |
| 166 | - <div> | 191 | + if is_code { |
| 167 | - if let Some((href, label)) = fork_line { | 192 | + clone_popover(https: clone.https, ssh: clone.ssh, downloads: clone.downloads, lang: lang) |
| 168 | - <p class="hint">(g::t(lang, K::ForkedFrom)) <a href=(href.as_str())>(label.as_str())</a></p> | 193 | + if let Some((action, label, csrf)) = star_control { |
| 169 | - } | 194 | + <form method="post" action=(action.as_str()) class="act-form"> |
| 170 | - if let Some(source) = mirror_line { | 195 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 171 | - <p class="hint mirror-line">(g::t(lang, K::MirrorOf)) <code>(source.as_str())</code> ", " | 196 | + <button type="submit" data-palette-action="post">(label.as_str())</button> |
| 172 | - if let Some(at) = mirror_at.as_deref() { | 197 | + </form> |
| 173 | - (mirror_before) rel_time(lang: lang, stamp: at) (mirror_after) | ||
| 174 | } else { | 198 | } else { |
| 175 | - (mirror_status.as_str()) | 199 | + <span class="hint" aria-label=(g::t(lang, K::StarsAria))>(anon_count.as_str())</span> |
| 176 | } | 200 | } |
| 177 | - </p> | 201 | + if let Some((action, csrf)) = fork_control { |
| 178 | - } | 202 | + <form method="post" action=(action.as_str()) class="act-form"> |
| 179 | - </div> | 203 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 180 | - } | 204 | + <button type="submit">(g::t(lang, K::ForkButton))</button> |
| 181 | - <div class="acts"> | 205 | + </form> |
| 182 | - // A private repo says so beside the star; public needs no mark outside the menu. | 206 | + } |
| 183 | - if private { | 207 | + <details class="menu head-more"> |
| 208 | + <summary class="button" aria-label=(s(lang, "Repository actions", "Depo işlemleri"))> | ||
| 209 | + <span aria-hidden="true">"…"</span> | ||
| 210 | + </summary> | ||
| 211 | + <div class="menu-list head-more-list"> | ||
| 212 | + if let Some((action, csrf, level)) = watch_control { | ||
| 213 | + watch_form(lang: lang, action: action, csrf: csrf, level: level, watchers: watchers) | ||
| 214 | + } else { | ||
| 215 | + <span class="hint">(watch_count.as_str())</span> | ||
| 216 | + } | ||
| 217 | + <span class="hint">(fork_count.as_str())</span> | ||
| 218 | + </div> | ||
| 219 | + </details> | ||
| 220 | + } else if private { | ||
| 184 | <span class=(badge)>(vis)</span> | 221 | <span class=(badge)>(vis)</span> |
| 185 | } | 222 | } |
| 186 | - if let Some((action, label, csrf)) = star_control { | 223 | + (child) |
| 187 | - <form method="post" action=(action.as_str()) class="act-form"> | ||
| 188 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 189 | - <button type="submit" class="act" data-palette-action="post">(label.as_str())</button> | ||
| 190 | - </form> | ||
| 191 | - } else { | ||
| 192 | - <span class="hint" aria-label=(g::t(lang, K::StarsAria))>(anon_count.as_str())</span> | ||
| 193 | - } | ||
| 194 | - <details class="menu head-more"> | ||
| 195 | - <summary class="act" aria-label=(s(lang, "Repository actions", "Depo işlemleri"))> | ||
| 196 | - <span aria-hidden="true">"…"</span> | ||
| 197 | - </summary> | ||
| 198 | - <div class="menu-list head-more-list"> | ||
| 199 | - <span class=(badge)>(vis)</span> | ||
| 200 | - if let Some((action, csrf)) = fork_control { | ||
| 201 | - <form method="post" action=(action.as_str()) class="act-form"> | ||
| 202 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 203 | - <button type="submit" class="act">(g::t(lang, K::ForkButton))</button> | ||
| 204 | - </form> | ||
| 205 | - } | ||
| 206 | - if let Some((action, csrf, level)) = watch_control { | ||
| 207 | - watch_form(lang: lang, action: action, csrf: csrf, level: level, watchers: watchers) | ||
| 208 | - } else { | ||
| 209 | - <span class="hint">(watch_count.as_str())</span> | ||
| 210 | - } | ||
| 211 | - <span class="hint">(fork_count.as_str())</span> | ||
| 212 | - </div> | ||
| 213 | - </details> | ||
| 214 | </div> | 224 | </div> |
| 225 | + head_sub(parts: parts, pips: pips) | ||
| 215 | repo_tabs(owner: owner.clone(), repo: name.clone(), default_branch: default_branch.clone(), active: active.clone(), can_admin: can_admin, lang: lang, open_issues: Some(open_issues), open_pulls: Some(open_pulls), discussions: discussions, wiki: wiki, security: security) | 226 | repo_tabs(owner: owner.clone(), repo: name.clone(), default_branch: default_branch.clone(), active: active.clone(), can_admin: can_admin, lang: lang, open_issues: Some(open_issues), open_pulls: Some(open_pulls), discussions: discussions, wiki: wiki, security: security) |
| 216 | - if !hide_search && active == "code" { | ||
| 217 | - <form method="get" action=(search_action.as_str()) class="plain-search" role="search"> | ||
| 218 | - <input type="search" name="q" data-live-search="" placeholder=(search_label) aria-label=(search_label) autocomplete="off"> | ||
| 219 | - </form> | ||
| 220 | - } | ||
| 221 | </section> | 227 | </section> |
| 222 | if archived { | 228 | if archived { |
| 223 | <p class="state" role="status">(g::t(lang, K::ArchivedNotice))</p> | 229 | <p class="state" role="status">(g::t(lang, K::ArchivedNotice))</p> |
| 224 | } | 230 | } |
| 225 | - // The description belongs to the Code tab only; sub-pages keep the compact head. | 231 | + } |
| 226 | - if active == "code" && !description.is_empty() { | 232 | + // Boxed: this head is part of nearly every repo page's view. |
| 227 | - <p class="lead">(description.as_str())</p> | 233 | + .boxed()) |
| 228 | - } | ||
| 229 | - }) | ||
| 230 | } | 234 | } |
| 231 | 235 | ||
| 232 | /// Clone button that opens a popover with both clone URLs as selectable read-only fields and, when | 236 | /// Clone button that opens a popover with both clone URLs as selectable read-only fields and, when |
| @@ -240,7 +244,7 @@ async fn clone_popover( | |||
| 240 | ) -> Result<impl View> { | 244 | ) -> Result<impl View> { |
| 241 | Ok(view! { | 245 | Ok(view! { |
| 242 | <details class="clone pop"> | 246 | <details class="clone pop"> |
| 243 | - <summary class="act">(g::t(lang, K::CloneTitle))</summary> | 247 | + <summary class="button primary">(g::t(lang, K::CloneTitle))</summary> |
| 244 | <div class="pop-panel"> | 248 | <div class="pop-panel"> |
| 245 | <label for="clone-https">"HTTPS"</label> | 249 | <label for="clone-https">"HTTPS"</label> |
| 246 | <input id="clone-https" class="mono" type="text" readonly=(true) value=(https.as_str())> | 250 | <input id="clone-https" class="mono" type="text" readonly=(true) value=(https.as_str())> |
| @@ -260,26 +264,6 @@ async fn clone_popover( | |||
| 260 | }) | 264 | }) |
| 261 | } | 265 | } |
| 262 | 266 | ||
| 263 | -/// Head of the README pane, shared by the repo home and the tree pages: the file name, then the repo | ||
| 264 | -/// facts (licence, size, top language) and the Clone popover as text links on the same line. | ||
| 265 | -#[component] | ||
| 266 | -pub(crate) async fn readme_head( | ||
| 267 | - label: String, | ||
| 268 | - facts: Option<TreeFacts>, | ||
| 269 | - https: String, | ||
| 270 | - ssh: String, | ||
| 271 | - downloads: Option<(String, String)>, | ||
| 272 | - lang: Lang, | ||
| 273 | -) -> Result<impl View> { | ||
| 274 | - Ok(view! { | ||
| 275 | - <div class="acts"> | ||
| 276 | - <span class="name">(label.as_str())</span> | ||
| 277 | - readme_meta(lang: lang, facts: facts) | ||
| 278 | - clone_popover(https: https, ssh: ssh, downloads: downloads, lang: lang) | ||
| 279 | - </div> | ||
| 280 | - }) | ||
| 281 | -} | ||
| 282 | - | ||
| 283 | /// Shown for an empty repo (or one whose default branch is missing): the branches that exist, | 267 | /// Shown for an empty repo (or one whose default branch is missing): the branches that exist, |
| 284 | /// or push instructions when there are none. | 268 | /// or push instructions when there are none. |
| 285 | #[component] | 269 | #[component] |
| @@ -292,7 +276,9 @@ async fn branches_card( | |||
| 292 | let empty = branches.is_empty(); | 276 | let empty = branches.is_empty(); |
| 293 | Ok(view! { | 277 | Ok(view! { |
| 294 | <section class="sec"> | 278 | <section class="sec"> |
| 295 | - <h2>(g::t(lang, K::BranchesTitle))</h2> | 279 | + if !empty { |
| 280 | + <h2>(g::t(lang, K::BranchesTitle))</h2> | ||
| 281 | + } | ||
| 296 | if empty { | 282 | if empty { |
| 297 | <p class="state">(g::t(lang, K::EmptyRepoPush))</p> | 283 | <p class="state">(g::t(lang, K::EmptyRepoPush))</p> |
| 298 | <p class="hint">(g::t(lang, K::OverHttps))</p> | 284 | <p class="hint">(g::t(lang, K::OverHttps))</p> |
| @@ -511,75 +497,41 @@ async fn repo_page(cx: &Cx) -> Result<impl View> { | |||
| 511 | let viewer_user = ctx.viewer.as_ref().map(|(user, _)| user); | 497 | let viewer_user = ctx.viewer.as_ref().map(|(user, _)| user); |
| 512 | let packages = packages::repo_package_links(state, viewer_user, &repo.id).await?; | 498 | let packages = packages::repo_package_links(state, viewer_user, &repo.id).await?; |
| 513 | let now = now_unix(); | 499 | let now = now_unix(); |
| 514 | - let downloads = ( | 500 | + if head.is_none() { |
| 515 | - repo_href(&owner_name, &repo_name, "archive", &format!("{branch}.zip")), | 501 | + header.clone.downloads = None; |
| 516 | - repo_href( | 502 | + } |
| 517 | - &owner_name, | ||
| 518 | - &repo_name, | ||
| 519 | - "archive", | ||
| 520 | - &format!("{branch}.tar.gz"), | ||
| 521 | - ), | ||
| 522 | - ); | ||
| 523 | - // The dock: the history strip of the newest commits (cached per head), the newest run and the | ||
| 524 | - // head commit's subject. Empty repos have no tree, so they have no dock. | ||
| 525 | let strip = match &head { | 503 | let strip = match &head { |
| 526 | Some(commit) if tree.is_some() => commit_strip(state, repo, &ctx.path, commit).await, | 504 | Some(commit) if tree.is_some() => commit_strip(state, repo, &ctx.path, commit).await, |
| 527 | _ => StripFacts::default(), | 505 | _ => StripFacts::default(), |
| 528 | }; | 506 | }; |
| 529 | - let ci_states = run_states(state, &repo.id).await?; | 507 | + let readme_file = readme.as_ref().map(|readme| readme.name.clone()); |
| 530 | - let bars = strip_bars(&strip.commits, &ci_states); | 508 | + let pips = run_pips(&runs); |
| 531 | - let total = strip.total; | 509 | + let sub = code_sub(lang, bar, facts, latest, packages, strip.total); |
| 532 | - let ci_href = repo_href(&owner_name, &repo_name, "ci", ""); | ||
| 533 | - let has_chips = latest.is_some() || !packages.is_empty(); | ||
| 534 | - let readme_label = readme | ||
| 535 | - .as_ref() | ||
| 536 | - .map(|readme| readme.name.clone()) | ||
| 537 | - .unwrap_or_else(|| "README".to_owned()); | ||
| 538 | Ok(view! { | 510 | Ok(view! { |
| 539 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 511 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 540 | - repo_head(head: header) | 512 | + repo_head(head: header, sub: sub, pips: pips) |
| 541 | if !banners.is_empty() { | 513 | if !banners.is_empty() { |
| 542 | recent_pushes(banners: banners, now: now, lang: lang) | 514 | recent_pushes(banners: banners, now: now, lang: lang) |
| 543 | } | 515 | } |
| 544 | if let Some(rows) = tree { | 516 | if let Some(rows) = tree { |
| 545 | - // Two panes over the dock: the tree on the left, the README on the right. | 517 | + <div class="work"> |
| 546 | - <div class="repo-grid repo-home canvas-repo"> | 518 | + <nav class="rail" aria-label=(s(lang, "Files", "Dosyalar"))> |
| 547 | - <div class="repo-main canvas-files"> | 519 | + <div class="rail-head browse-bar" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> |
| 548 | - <div class="browse-bar" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> | 520 | + <h2>(s(lang, "Files", "Dosyalar"))</h2> |
| 549 | ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags, | 521 | ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags, |
| 550 | branches_href: branches_href, tags_href: tags_href) | 522 | branches_href: branches_href, tags_href: tags_href) |
| 551 | file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), | 523 | file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), |
| 552 | ref_name: branch.clone()) | 524 | ref_name: branch.clone()) |
| 553 | </div> | 525 | </div> |
| 554 | - tree_table(rows: rows, lang: lang) | 526 | + tree_table(rows: rows, lang: lang, current: readme_file) |
| 555 | - </div> | 527 | + </nav> |
| 556 | - <div class="repo-split" role="separator" aria-orientation="vertical" | 528 | + readme_sheet(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), ref_name: branch.clone(), dir: String::new(), readme: readme, |
| 557 | - aria-label=(s(lang, "Resize file tree", "Dosya ağacını boyutlandır")) tabindex="0" | 529 | + none: s(lang, "No README yet", "Henüz README yok")) |
| 558 | - data-repo-split=""></div> | ||
| 559 | - <div class="repo-readme canvas-readme"> | ||
| 560 | - readme_head(label: readme_label, facts: facts, https: https, ssh: ssh, downloads: Some(downloads), lang: lang) | ||
| 561 | - <div class="canvas-body"> | ||
| 562 | - if has_chips { | ||
| 563 | - repo_strip(lang: lang, facts: None, release: latest, packages: packages) | ||
| 564 | - } | ||
| 565 | - if let Some(readme) = readme { | ||
| 566 | - readme_card(name: readme.name, markdown: readme.markdown, body: readme.body) | ||
| 567 | - } else { | ||
| 568 | - empty_state(title: s(lang, "No README yet", "Henüz README yok")) | ||
| 569 | - } | ||
| 570 | - </div> | ||
| 571 | - </div> | ||
| 572 | </div> | 530 | </div> |
| 573 | - repo_dock(lang: lang, runs: runs, total: total, ci_href: ci_href, | ||
| 574 | - owner: owner_name.clone(), repo: repo_name.clone(), bars: bars, latest: bar) | ||
| 575 | } else { | 531 | } else { |
| 576 | - if has_chips { | 532 | + <div class="sheet"> |
| 577 | - repo_strip(lang: lang, facts: None, release: latest, packages: packages) | 533 | + branches_card(branches: branch_names, push_https: push_https, push_ssh: push_ssh, lang: lang) |
| 578 | - } | ||
| 579 | - <div class="browse-bar"> | ||
| 580 | - clone_popover(https: https, ssh: ssh, downloads: None, lang: lang) | ||
| 581 | </div> | 534 | </div> |
| 582 | - branches_card(branches: branch_names, push_https: push_https, push_ssh: push_ssh, lang: lang) | ||
| 583 | } | 535 | } |
| 584 | ) | 536 | ) |
| 585 | }) | 537 | }) |
| @@ -727,7 +679,6 @@ mod tests { | |||
| 727 | assert!(body.contains("/tahinli/demo/archive/main.tar.gz")); | 679 | assert!(body.contains("/tahinli/demo/archive/main.tar.gz")); |
| 728 | assert!(body.contains("/tahinli/demo/branches")); | 680 | assert!(body.contains("/tahinli/demo/branches")); |
| 729 | assert!(body.contains("data-ref-filter"), "branch switcher rendered"); | 681 | assert!(body.contains("data-ref-filter"), "branch switcher rendered"); |
| 730 | - assert!(body.contains("canvas-dock"), "dock under the two panes"); | ||
| 731 | 682 | ||
| 732 | // Trees list their entries and link to subtrees and blobs. | 683 | // Trees list their entries and link to subtrees and blobs. |
| 733 | let (status, body) = get(&router, "/tahinli/demo/tree/main/src").await; | 684 | let (status, body) = get(&router, "/tahinli/demo/tree/main/src").await; |
crates/forge-web/src/pages/repo_collaborators.rsmodified+3 -2
| @@ -202,7 +202,7 @@ async fn collaborators_pane( | |||
| 202 | } | 202 | } |
| 203 | </select> | 203 | </select> |
| 204 | </div> | 204 | </div> |
| 205 | - <button type="submit">(g::t(lang, K::SaveRole))</button> | 205 | + <button type="submit" class="primary">(g::t(lang, K::SaveRole))</button> |
| 206 | </form> | 206 | </form> |
| 207 | <div class="acts"> | 207 | <div class="acts"> |
| 208 | confirm_act(lang: lang, label: g::t(lang, K::Remove), action: remove_action.as_str(), csrf: csrf.as_str(), | 208 | confirm_act(lang: lang, label: g::t(lang, K::Remove), action: remove_action.as_str(), csrf: csrf.as_str(), |
| @@ -281,8 +281,9 @@ async fn collaborators_body( | |||
| 281 | let add_open = matches!(notice, Some((key, true)) if !matches!(key, K::NotCollaborator)); | 281 | let add_open = matches!(notice, Some((key, true)) if !matches!(key, K::NotCollaborator)); |
| 282 | let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error)); | 282 | let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error)); |
| 283 | let can_delete = header.can_delete; | 283 | let can_delete = header.can_delete; |
| 284 | + let section_name = g::t(lang, K::Collaborators).to_owned(); | ||
| 284 | Ok(view! { | 285 | Ok(view! { |
| 285 | - repo_head(head: header) | 286 | + repo_head(head: header, title: Some(section_name)) |
| 286 | settings_frame(lang: lang, title: nav_title, current: "collaborators", can_delete: can_delete, | 287 | settings_frame(lang: lang, title: nav_title, current: "collaborators", can_delete: can_delete, |
| 287 | if let Some((text, is_error)) = notice { | 288 | if let Some((text, is_error)) = notice { |
| 288 | if is_error { | 289 | if is_error { |
crates/forge-web/src/pages/repo_ctx.rsmodified+31 -3
| @@ -18,8 +18,10 @@ use topcoat::router::{Body, Layer, LayerFuture, Next, Path, StatusCode}; | |||
| 18 | 18 | ||
| 19 | use crate::auth::current_user; | 19 | use crate::auth::current_user; |
| 20 | use crate::i18n::{self, Lang}; | 20 | use crate::i18n::{self, Lang}; |
| 21 | +use crate::pages::repo::{https_clone_url, ssh_clone_url}; | ||
| 21 | use crate::pages::repo_mirrors::redacted_url; | 22 | use crate::pages::repo_mirrors::redacted_url; |
| 22 | use crate::state::AppState; | 23 | use crate::state::AppState; |
| 24 | +use crate::views::repo_href; | ||
| 23 | 25 | ||
| 24 | pub struct RepoCtx { | 26 | pub struct RepoCtx { |
| 25 | pub repo: Repo, | 27 | pub repo: Repo, |
| @@ -58,8 +60,6 @@ pub struct RepoHead { | |||
| 58 | /// The current header tab: `code`, `issues`, `pulls`, `commits`, `branches`, `tags` or | 60 | /// The current header tab: `code`, `issues`, `pulls`, `commits`, `branches`, `tags` or |
| 59 | /// `settings`, or `security`. | 61 | /// `settings`, or `security`. |
| 60 | pub active: &'static str, | 62 | pub active: &'static str, |
| 61 | - /// Hide the header's code-search box (the code search page draws its own). | ||
| 62 | - pub hide_search: bool, | ||
| 63 | /// Whether the viewer may open the Settings tab. | 63 | /// Whether the viewer may open the Settings tab. |
| 64 | pub can_admin: bool, | 64 | pub can_admin: bool, |
| 65 | /// Whether the viewer may delete the repo: the settings nav lists Danger zone only then. | 65 | /// Whether the viewer may delete the repo: the settings nav lists Danger zone only then. |
| @@ -95,6 +95,17 @@ pub struct RepoHead { | |||
| 95 | pub wiki: bool, | 95 | pub wiki: bool, |
| 96 | /// Whether the Security tab shows: advisories are enabled and the viewer may manage alerts. | 96 | /// Whether the Security tab shows: advisories are enabled and the viewer may manage alerts. |
| 97 | pub security: bool, | 97 | pub security: bool, |
| 98 | + /// What the Code tab's Clone popover offers. | ||
| 99 | + pub clone: CloneLinks, | ||
| 100 | +} | ||
| 101 | + | ||
| 102 | +/// The repo's clone URLs and the default branch's archives. `downloads` is `None` before the first | ||
| 103 | +/// commit. | ||
| 104 | +#[derive(Clone)] | ||
| 105 | +pub struct CloneLinks { | ||
| 106 | + pub https: String, | ||
| 107 | + pub ssh: String, | ||
| 108 | + pub downloads: Option<(String, String)>, | ||
| 98 | } | 109 | } |
| 99 | 110 | ||
| 100 | /// The "Mirror of" line's values: the redacted source URL and the last sync, already formatted in the | 111 | /// The "Mirror of" line's values: the redacted source URL and the last sync, already formatted in the |
| @@ -246,7 +257,6 @@ impl RepoCtx { | |||
| 246 | description: self.repo.description.clone(), | 257 | description: self.repo.description.clone(), |
| 247 | archived: self.repo.archived, | 258 | archived: self.repo.archived, |
| 248 | active, | 259 | active, |
| 249 | - hide_search: false, | ||
| 250 | can_admin: self.can_admin(), | 260 | can_admin: self.can_admin(), |
| 251 | can_delete: self.can_delete(), | 261 | can_delete: self.can_delete(), |
| 252 | open_issues: self.open_issues(state).await?, | 262 | open_issues: self.open_issues(state).await?, |
| @@ -260,6 +270,24 @@ impl RepoCtx { | |||
| 260 | forks, | 270 | forks, |
| 261 | live: format!("/{}/{}/events", self.repo.owner_name, self.repo.name), | 271 | live: format!("/{}/{}/events", self.repo.owner_name, self.repo.name), |
| 262 | mirror, | 272 | mirror, |
| 273 | + clone: CloneLinks { | ||
| 274 | + https: https_clone_url(&state.config, &self.repo.owner_name, &self.repo.name), | ||
| 275 | + ssh: ssh_clone_url(&state.config, &self.repo.owner_name, &self.repo.name), | ||
| 276 | + downloads: Some(( | ||
| 277 | + repo_href( | ||
| 278 | + &self.repo.owner_name, | ||
| 279 | + &self.repo.name, | ||
| 280 | + "archive", | ||
| 281 | + &format!("{}.zip", self.repo.default_branch), | ||
| 282 | + ), | ||
| 283 | + repo_href( | ||
| 284 | + &self.repo.owner_name, | ||
| 285 | + &self.repo.name, | ||
| 286 | + "archive", | ||
| 287 | + &format!("{}.tar.gz", self.repo.default_branch), | ||
| 288 | + ), | ||
| 289 | + )), | ||
| 290 | + }, | ||
| 263 | discussions, | 291 | discussions, |
| 264 | wiki, | 292 | wiki, |
| 265 | security, | 293 | security, |
crates/forge-web/src/pages/repo_mirrors.rsmodified+10 -12
| @@ -387,11 +387,13 @@ async fn rows_of(state: &AppState, ctx: &RepoCtx, frame: &Frame) -> Result<Vec<M | |||
| 387 | .collect()) | 387 | .collect()) |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | -/// Header, sub-navigation and the one-line notice. | 390 | +/// Header, the rail and the one-line notice. `heading` is the page's title: the list's name, or the |
| 391 | +/// mirror's redacted URL on its own page. | ||
| 391 | #[component] | 392 | #[component] |
| 392 | async fn frame_top( | 393 | async fn frame_top( |
| 393 | head: RepoHead, | 394 | head: RepoHead, |
| 394 | title: String, | 395 | title: String, |
| 396 | + heading: String, | ||
| 395 | notice: Option<(&'static str, bool)>, | 397 | notice: Option<(&'static str, bool)>, |
| 396 | archived: bool, | 398 | archived: bool, |
| 397 | lang: Lang, | 399 | lang: Lang, |
| @@ -399,7 +401,7 @@ async fn frame_top( | |||
| 399 | ) -> Result<impl View> { | 401 | ) -> Result<impl View> { |
| 400 | let can_delete = head.can_delete; | 402 | let can_delete = head.can_delete; |
| 401 | Ok(view! { | 403 | Ok(view! { |
| 402 | - repo_head(head: head) | 404 | + repo_head(head: head, title: Some(heading)) |
| 403 | settings_frame(lang: lang, title: title, current: "mirrors", can_delete: can_delete, | 405 | settings_frame(lang: lang, title: title, current: "mirrors", can_delete: can_delete, |
| 404 | if let Some((text, is_error)) = notice { | 406 | if let Some((text, is_error)) = notice { |
| 405 | if is_error { | 407 | if is_error { |
| @@ -521,10 +523,9 @@ async fn mirrors_list_body( | |||
| 521 | let pull_open = pull_form.as_ref().is_some_and(|pull| pull.error.is_some()); | 523 | let pull_open = pull_form.as_ref().is_some_and(|pull| pull.error.is_some()); |
| 522 | let push_open = draft.error.is_some(); | 524 | let push_open = draft.error.is_some(); |
| 523 | Ok(view! { | 525 | Ok(view! { |
| 524 | - frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, | 526 | + frame_top(head: head, title: title.clone(), heading: g::t(lang, K::Mirrors).to_owned(), notice: notice, archived: archived, lang: lang, |
| 525 | <section class="sec"> | 527 | <section class="sec"> |
| 526 | - <h2>(g::t(lang, K::Mirrors))</h2> | 528 | + if empty { |
| 527 | - if archived && empty { | ||
| 528 | <p class="state">(g::t(lang, K::NoMirrors))</p> | 529 | <p class="state">(g::t(lang, K::NoMirrors))</p> |
| 529 | } | 530 | } |
| 530 | for row in rows.iter() { | 531 | for row in rows.iter() { |
| @@ -562,9 +563,7 @@ async fn mirrors_list_body( | |||
| 562 | <section class="sec" id="add-pull-mirror"> | 563 | <section class="sec" id="add-pull-mirror"> |
| 563 | <h2>(g::t(lang, K::AddPullMirror))</h2> | 564 | <h2>(g::t(lang, K::AddPullMirror))</h2> |
| 564 | <p class="hint">(g::t(lang, K::MirrorsIntro))</p> | 565 | <p class="hint">(g::t(lang, K::MirrorsIntro))</p> |
| 565 | - if empty { | 566 | + if !empty { |
| 566 | - <p class="state">(g::t(lang, K::NoMirrors))</p> | ||
| 567 | - } else { | ||
| 568 | <p class="hint">(g::t(lang, K::AddPullIntro))</p> | 567 | <p class="hint">(g::t(lang, K::AddPullIntro))</p> |
| 569 | } | 568 | } |
| 570 | <div class="acts"> | 569 | <div class="acts"> |
| @@ -578,9 +577,7 @@ async fn mirrors_list_body( | |||
| 578 | } | 577 | } |
| 579 | <section class="sec" id="add-push-mirror"> | 578 | <section class="sec" id="add-push-mirror"> |
| 580 | <h2>(g::t(lang, K::AddPushMirror))</h2> | 579 | <h2>(g::t(lang, K::AddPushMirror))</h2> |
| 581 | - if empty && !can_pull { | 580 | + if !empty || can_pull { |
| 582 | - <p class="state">(g::t(lang, K::NoMirrors))</p> | ||
| 583 | - } else { | ||
| 584 | <p class="hint">(g::t(lang, K::AddPushIntro))</p> | 581 | <p class="hint">(g::t(lang, K::AddPushIntro))</p> |
| 585 | } | 582 | } |
| 586 | <div class="acts"> | 583 | <div class="acts"> |
| @@ -812,8 +809,9 @@ async fn mirror_body( | |||
| 812 | g::t(lang, K::DeleteTextPush) | 809 | g::t(lang, K::DeleteTextPush) |
| 813 | }; | 810 | }; |
| 814 | let current_url = redacted_url(&mirror.url); | 811 | let current_url = redacted_url(&mirror.url); |
| 812 | + let heading = current_url.clone(); | ||
| 815 | Ok(view! { | 813 | Ok(view! { |
| 816 | - frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, | 814 | + frame_top(head: head, title: title.clone(), heading: heading, notice: notice, archived: archived, lang: lang, |
| 817 | if archived { | 815 | if archived { |
| 818 | <section class="sec"> | 816 | <section class="sec"> |
| 819 | <h2>(mirror_kind(lang, mirror.direction))</h2> | 817 | <h2>(mirror_kind(lang, mirror.direction))</h2> |
crates/forge-web/src/pages/repo_rename.rsmodified+2 -2
| @@ -123,7 +123,7 @@ async fn rename_body( | |||
| 123 | let rename_open = rename_error.is_some(); | 123 | let rename_open = rename_error.is_some(); |
| 124 | let transfer_open = transfer_error.is_some(); | 124 | let transfer_open = transfer_error.is_some(); |
| 125 | Ok(view! { | 125 | Ok(view! { |
| 126 | - repo_head(head: head) | 126 | + repo_head(head: head, title: Some(g::t(lang, K::RenameTransferNav).to_owned())) |
| 127 | settings_frame(lang: lang, title: nav_title, current: "rename", can_delete: can_delete, | 127 | settings_frame(lang: lang, title: nav_title, current: "rename", can_delete: can_delete, |
| 128 | if let Some(key) = notice { | 128 | if let Some(key) = notice { |
| 129 | <p class="state" role="status">(g::t(lang, key))</p> | 129 | <p class="state" role="status">(g::t(lang, key))</p> |
| @@ -166,7 +166,7 @@ async fn rename_body( | |||
| 166 | <label for="transfer-confirm">(g::t(lang, K::TypeToConfirmBefore))<code>(title.clone())</code>(g::t(lang, K::TypeToConfirmAfter))</label> | 166 | <label for="transfer-confirm">(g::t(lang, K::TypeToConfirmBefore))<code>(title.clone())</code>(g::t(lang, K::TypeToConfirmAfter))</label> |
| 167 | <input id="transfer-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> | 167 | <input id="transfer-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 168 | </div> | 168 | </div> |
| 169 | - <button type="submit" class="act danger">(g::t(lang, K::TransferRepo))</button> | 169 | + <button type="submit" class="danger small">(g::t(lang, K::TransferRepo))</button> |
| 170 | </form> | 170 | </form> |
| 171 | ) | 171 | ) |
| 172 | </div> | 172 | </div> |
crates/forge-web/src/pages/repo_scrub.rsmodified+17 -7
| @@ -19,9 +19,11 @@ use topcoat::view::{View, component, view}; | |||
| 19 | 19 | ||
| 20 | use crate::i18n::Lang; | 20 | use crate::i18n::Lang; |
| 21 | use crate::i18n::code::{self as g}; | 21 | use crate::i18n::code::{self as g}; |
| 22 | +use crate::pages::passkeys::s; | ||
| 22 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; | 23 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 23 | use crate::pages::tree::{entry_rows, load_readme, read_dir, readme_card}; | 24 | use crate::pages::tree::{entry_rows, load_readme, read_dir, readme_card}; |
| 24 | use crate::state::AppState; | 25 | use crate::state::AppState; |
| 26 | +use crate::views::parts::{SubPart, head}; | ||
| 25 | use crate::views::{now_unix, shell}; | 27 | use crate::views::{now_unix, shell}; |
| 26 | 28 | ||
| 27 | /// Most parts kept in memory at once. The oldest entry goes first. | 29 | /// Most parts kept in memory at once. The oldest entry goes first. |
| @@ -202,15 +204,23 @@ async fn scrub_page(cx: &Cx) -> Result<impl View> { | |||
| 202 | let rows = parts.rows.clone(); | 204 | let rows = parts.rows.clone(); |
| 203 | let readme = parts.readme.clone(); | 205 | let readme = parts.readme.clone(); |
| 204 | let lang = ctx.lang; | 206 | let lang = ctx.lang; |
| 207 | + let short: String = oid.chars().take(7).collect(); | ||
| 208 | + let sub = vec![ | ||
| 209 | + SubPart::text(s(lang, "Files at this commit", "Bu commit'teki dosyalar")), | ||
| 210 | + SubPart::text(title.clone()), | ||
| 211 | + ]; | ||
| 205 | Ok(view! { | 212 | Ok(view! { |
| 206 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 213 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 207 | - <div data-scrub-tree="" data-scrub-when=(when.as_str())> | 214 | + head(title: short.as_str(), sub: sub) |
| 208 | - scrub_table(rows: rows, lang: lang) | 215 | + <div class="sheet"> |
| 209 | - </div> | 216 | + <div data-scrub-tree="" data-scrub-when=(when.as_str())> |
| 210 | - <div data-scrub-readme=""> | 217 | + scrub_table(rows: rows, lang: lang) |
| 211 | - if let Some(readme) = readme { | 218 | + </div> |
| 212 | - readme_card(name: readme.name, markdown: readme.markdown, body: readme.body) | 219 | + <div data-scrub-readme=""> |
| 213 | - } | 220 | + if let Some(readme) = readme { |
| 221 | + readme_card(name: readme.name, markdown: readme.markdown, body: readme.body) | ||
| 222 | + } | ||
| 223 | + </div> | ||
| 214 | </div> | 224 | </div> |
| 215 | ) | 225 | ) |
| 216 | }) | 226 | }) |
crates/forge-web/src/pages/repo_secrets.rsmodified+3 -3
| @@ -149,7 +149,7 @@ impl SecretsData { | |||
| 149 | } | 149 | } |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | -/// Header, sub-navigation and the one-line notice. | 152 | +/// Header, the rail and the one-line notice. |
| 153 | #[component] | 153 | #[component] |
| 154 | async fn frame_top( | 154 | async fn frame_top( |
| 155 | lang: Lang, | 155 | lang: Lang, |
| @@ -162,7 +162,7 @@ async fn frame_top( | |||
| 162 | let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error)); | 162 | let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error)); |
| 163 | let can_delete = head.can_delete; | 163 | let can_delete = head.can_delete; |
| 164 | Ok(view! { | 164 | Ok(view! { |
| 165 | - repo_head(head: head) | 165 | + repo_head(head: head, title: Some(g::t(lang, K::Secrets).to_owned())) |
| 166 | settings_frame(lang: lang, title: title, current: "secrets", can_delete: can_delete, | 166 | settings_frame(lang: lang, title: title, current: "secrets", can_delete: can_delete, |
| 167 | if let Some((text, is_error)) = notice { | 167 | if let Some((text, is_error)) = notice { |
| 168 | if is_error { | 168 | if is_error { |
| @@ -203,7 +203,7 @@ async fn secrets_body( | |||
| 203 | <section class="sec"> | 203 | <section class="sec"> |
| 204 | <h2>(g::t(lang, K::AddOrUpdate))</h2> | 204 | <h2>(g::t(lang, K::AddOrUpdate))</h2> |
| 205 | <div class="acts"> | 205 | <div class="acts"> |
| 206 | - reveal(label: g::t(lang, K::SaveSecret), id: Some("add-secret"), open: add_open, | 206 | + reveal(label: crate::pages::passkeys::s(lang, "Add secret", "Gizli anahtar ekle"), id: Some("add-secret"), open: add_open, |
| 207 | if let Some(message) = error { | 207 | if let Some(message) = error { |
| 208 | alert(message: message.as_str()) | 208 | alert(message: message.as_str()) |
| 209 | } | 209 | } |
crates/forge-web/src/pages/repo_security.rsmodified+36 -34
| @@ -121,41 +121,43 @@ async fn security_body( | |||
| 121 | ) -> Result<impl View> { | 121 | ) -> Result<impl View> { |
| 122 | let open_count = rows.iter().filter(|r| r.open).count(); | 122 | let open_count = rows.iter().filter(|r| r.open).count(); |
| 123 | Ok(view! { | 123 | Ok(view! { |
| 124 | - repo_head(head: head) | 124 | + repo_head(head: head, title: Some(i18n::t(lang, Key::Security).to_owned())) |
| 125 | - <section class="sec"> | 125 | + <div class="sheet"> |
| 126 | - <h2>(i18n::t(lang, Key::Security))</h2> | 126 | + <section class="sec"> |
| 127 | - if !enabled { | 127 | + <h2>(i18n::t(lang, Key::Security))</h2> |
| 128 | - <p class="state">(g::t(lang, K::SecurityOff))</p> | 128 | + if !enabled { |
| 129 | - } else { | 129 | + <p class="state">(g::t(lang, K::SecurityOff))</p> |
| 130 | - <p class="state">(g::dependencies_summary(lang, dependencies, open_count))</p> | 130 | + } else { |
| 131 | - <p class="hint">(g::t(lang, K::LockfilesRead))</p> | 131 | + <p class="state">(g::dependencies_summary(lang, dependencies, open_count))</p> |
| 132 | - } | 132 | + <p class="hint">(g::t(lang, K::LockfilesRead))</p> |
| 133 | - if rows.is_empty() { | 133 | + } |
| 134 | - <p class="state">(g::t(lang, K::NoAlerts))</p> | 134 | + if rows.is_empty() { |
| 135 | - } | 135 | + <p class="state">(g::t(lang, K::NoAlerts))</p> |
| 136 | - <div> | ||
| 137 | - for row in rows.iter() { | ||
| 138 | - <details class="row-open" data-kb-row=""> | ||
| 139 | - <summary class="line"> | ||
| 140 | - <span class="name">(row.advisory.as_str())</span> | ||
| 141 | - <span class="val"><code>(row.package.as_str())</code> " " <code>(row.version.as_str())</code> " · " (row.severity.as_str()) " · " <span class=(row.state_class)>(row.state_text)</span> " · " rel_time(lang: lang, stamp: row.created_at.as_str())</span> | ||
| 142 | - </summary> | ||
| 143 | - <div class="opened"> | ||
| 144 | - <p class="hint"><a href=(row.osv_href.as_str()) rel="noopener noreferrer">(crate::pages::passkeys::s(lang, "Details on osv.dev", "osv.dev'de ayrıntılar"))</a></p> | ||
| 145 | - <p class="hint">(row.summary.as_str())</p> | ||
| 146 | - <div class="acts"> | ||
| 147 | - if row.open { | ||
| 148 | - post_act(label: g::t(lang, K::Dismiss), action: row.dismiss_action.as_str(), csrf: csrf.as_str(), fields: row.fields.clone()) | ||
| 149 | - } | ||
| 150 | - if row.dismissed { | ||
| 151 | - post_act(label: g::t(lang, K::Reopen), action: row.reopen_action.as_str(), csrf: csrf.as_str(), fields: row.fields.clone()) | ||
| 152 | - } | ||
| 153 | - </div> | ||
| 154 | - </div> | ||
| 155 | - </details> | ||
| 156 | } | 136 | } |
| 157 | - </div> | 137 | + <div> |
| 158 | - </section> | 138 | + for row in rows.iter() { |
| 139 | + <details class="row-open" data-kb-row=""> | ||
| 140 | + <summary class="line"> | ||
| 141 | + <span class="name">(row.advisory.as_str())</span> | ||
| 142 | + <span class="val"><code>(row.package.as_str())</code> " " <code>(row.version.as_str())</code> " · " (row.severity.as_str()) " · " <span class=(row.state_class)>(row.state_text)</span> " · " rel_time(lang: lang, stamp: row.created_at.as_str())</span> | ||
| 143 | + </summary> | ||
| 144 | + <div class="opened"> | ||
| 145 | + <p class="hint"><a href=(row.osv_href.as_str()) rel="noopener noreferrer">(crate::pages::passkeys::s(lang, "Details on osv.dev", "osv.dev'de ayrıntılar"))</a></p> | ||
| 146 | + <p class="hint">(row.summary.as_str())</p> | ||
| 147 | + <div class="acts"> | ||
| 148 | + if row.open { | ||
| 149 | + post_act(label: g::t(lang, K::Dismiss), action: row.dismiss_action.as_str(), csrf: csrf.as_str(), fields: row.fields.clone()) | ||
| 150 | + } | ||
| 151 | + if row.dismissed { | ||
| 152 | + post_act(label: g::t(lang, K::Reopen), action: row.reopen_action.as_str(), csrf: csrf.as_str(), fields: row.fields.clone()) | ||
| 153 | + } | ||
| 154 | + </div> | ||
| 155 | + </div> | ||
| 156 | + </details> | ||
| 157 | + } | ||
| 158 | + </div> | ||
| 159 | + </section> | ||
| 160 | + </div> | ||
| 159 | }) | 161 | }) |
| 160 | } | 162 | } |
| 161 | 163 | ||
crates/forge-web/src/pages/repo_settings.rsmodified+47 -83
| @@ -40,7 +40,7 @@ use crate::pages::repo::repo_head; | |||
| 40 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | 40 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 41 | use crate::pages::repo_settings_live::settings_head; | 41 | use crate::pages::repo_settings_live::settings_head; |
| 42 | use crate::state::AppState; | 42 | use crate::state::AppState; |
| 43 | -use crate::views::parts::{confirm_act, post_act}; | 43 | +use crate::views::parts::{RailItem, confirm_act, post_act, rail}; |
| 44 | use crate::views::{alert, enc, shell}; | 44 | use crate::views::{alert, enc, shell}; |
| 45 | 45 | ||
| 46 | path_param!(owner); | 46 | path_param!(owner); |
| @@ -291,7 +291,7 @@ async fn danger_zone( | |||
| 291 | <input id="delete-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> | 291 | <input id="delete-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 292 | </div> | 292 | </div> |
| 293 | <div class="acts"> | 293 | <div class="acts"> |
| 294 | - <button type="submit" class="act danger">(g::t(lang, K::DeleteRepo))</button> | 294 | + <button type="submit" class="danger small">(g::t(lang, K::DeleteRepo))</button> |
| 295 | <button type="button" class="act quiet" data-close-details="">(g::t(lang, K::Cancel))</button> | 295 | <button type="button" class="act quiet" data-close-details="">(g::t(lang, K::Cancel))</button> |
| 296 | </div> | 296 | </div> |
| 297 | </form> | 297 | </form> |
| @@ -302,10 +302,11 @@ async fn danger_zone( | |||
| 302 | }) | 302 | }) |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | -/// The settings frame: the second-level links (`.sub`) above the page's own content (its children). | 305 | +/// The settings frame: the rail of settings pages beside the sheet holding the page's own content |
| 306 | -/// `current` names the section shown (`general`, `branches`, `webhooks`, ...) and gets `aria-current`. | 306 | +/// (its children). Every settings page shows the same rail. `current` names the page shown |
| 307 | -/// The General page's sections (`branches`, `discussions`, `danger`) are `?section=` links right after | 307 | +/// (`general`, `branches`, `webhooks`, ...) and marks its rail item. On the General page the sections |
| 308 | -/// General; the danger link is only for a viewer who may delete the repo (`can_delete`). | 308 | +/// (`branches`, `discussions`, `danger`) are tabs above the frame; the danger tab only for a viewer |
| 309 | +/// who may delete the repo (`can_delete`). | ||
| 309 | #[component] | 310 | #[component] |
| 310 | pub async fn settings_frame( | 311 | pub async fn settings_frame( |
| 311 | lang: Lang, | 312 | lang: Lang, |
| @@ -314,83 +315,40 @@ pub async fn settings_frame( | |||
| 314 | can_delete: bool, | 315 | can_delete: bool, |
| 315 | #[default] child: Child<'_>, | 316 | #[default] child: Child<'_>, |
| 316 | ) -> Result<impl View> { | 317 | ) -> Result<impl View> { |
| 317 | - let general = format!("/{title}/settings"); | 318 | + let general_on = matches!(current, "general" | "branches" | "discussions" | "danger"); |
| 318 | - let branches = format!("/{title}/settings?section=branches"); | ||
| 319 | - let discussions = format!("/{title}/settings?section=discussions"); | ||
| 320 | - let danger = format!("/{title}/settings?section=danger"); | ||
| 321 | - let branches_on = current == "branches"; | ||
| 322 | - let discussions_on = current == "discussions"; | ||
| 323 | - let danger_on = current == "danger"; | ||
| 324 | let discussions_label = crate::i18n::community::t(lang, crate::i18n::community::K::Discussions); | 319 | let discussions_label = crate::i18n::community::t(lang, crate::i18n::community::K::Discussions); |
| 325 | - let collaborators = format!("/{title}/settings/collaborators"); | 320 | + let item = |name: &str, href: String, on: bool| RailItem { |
| 326 | - let rename = format!("/{title}/settings/rename"); | 321 | + name: name.to_owned(), |
| 327 | - let hooks = format!("/{title}/settings/hooks"); | 322 | + val: String::new(), |
| 328 | - let mirrors = format!("/{title}/settings/mirrors"); | 323 | + href, |
| 329 | - let secrets = format!("/{title}/settings/secrets"); | 324 | + current: on, |
| 330 | - let general_on = current == "general"; | 325 | + }; |
| 331 | - let collaborators_on = current == "collaborators"; | 326 | + let items = vec![ |
| 332 | - let rename_on = current == "rename"; | 327 | + item(g::t(lang, K::General), format!("/{title}/settings"), general_on), |
| 333 | - let hooks_on = current == "webhooks"; | 328 | + item(g::t(lang, K::Collaborators), format!("/{title}/settings/collaborators"), current == "collaborators"), |
| 334 | - let mirrors_on = current == "mirrors"; | 329 | + item(g::t(lang, K::RenameTransferNav), format!("/{title}/settings/rename"), current == "rename"), |
| 335 | - let secrets_on = current == "secrets"; | 330 | + item(g::t(lang, K::Webhooks), format!("/{title}/settings/hooks"), current == "webhooks"), |
| 336 | - let wiki = format!("/{title}/settings/wiki"); | 331 | + item(g::t(lang, K::Mirrors), format!("/{title}/settings/mirrors"), current == "mirrors"), |
| 337 | - let wiki_on = current == "wiki"; | 332 | + item(g::t(lang, K::Secrets), format!("/{title}/settings/secrets"), current == "secrets"), |
| 333 | + item(crate::i18n::code::t(lang, crate::i18n::code::K::TabWiki), format!("/{title}/settings/wiki"), current == "wiki"), | ||
| 334 | + ]; | ||
| 338 | Ok(view! { | 335 | Ok(view! { |
| 339 | - <nav class="sub" aria-label=(g::t(lang, K::SettingsNavLabel))> | 336 | + if general_on { |
| 340 | - if general_on { | 337 | + <nav class="tabs" aria-label=(g::t(lang, K::SettingsNavLabel))> |
| 341 | - <a href=(general) aria-current="page">(g::t(lang, K::General))</a> | 338 | + <a href=(format!("/{title}/settings")) aria-current=((current == "general").then_some("page"))>(g::t(lang, K::General))</a> |
| 342 | - } else { | 339 | + <a href=(format!("/{title}/settings?section=branches")) aria-current=((current == "branches").then_some("page"))>(g::t(lang, K::BranchProtection))</a> |
| 343 | - <a href=(general)>(g::t(lang, K::General))</a> | 340 | + <a href=(format!("/{title}/settings?section=discussions")) aria-current=((current == "discussions").then_some("page"))>(discussions_label)</a> |
| 344 | - } | 341 | + if can_delete { |
| 345 | - if branches_on { | 342 | + <a href=(format!("/{title}/settings?section=danger")) aria-current=((current == "danger").then_some("page"))>(g::t(lang, K::DangerZone))</a> |
| 346 | - <a href=(branches.as_str()) aria-current="page">(g::t(lang, K::BranchProtection))</a> | ||
| 347 | - } else { | ||
| 348 | - <a href=(branches.as_str())>(g::t(lang, K::BranchProtection))</a> | ||
| 349 | - } | ||
| 350 | - if discussions_on { | ||
| 351 | - <a href=(discussions.as_str()) aria-current="page">(discussions_label)</a> | ||
| 352 | - } else { | ||
| 353 | - <a href=(discussions.as_str())>(discussions_label)</a> | ||
| 354 | - } | ||
| 355 | - if can_delete { | ||
| 356 | - if danger_on { | ||
| 357 | - <a href=(danger.as_str()) aria-current="page">(g::t(lang, K::DangerZone))</a> | ||
| 358 | - } else { | ||
| 359 | - <a href=(danger.as_str())>(g::t(lang, K::DangerZone))</a> | ||
| 360 | } | 343 | } |
| 361 | - } | 344 | + </nav> |
| 362 | - if collaborators_on { | 345 | + } |
| 363 | - <a href=(collaborators) aria-current="page">(g::t(lang, K::Collaborators))</a> | 346 | + <div class="work"> |
| 364 | - } else { | 347 | + rail(label: g::t(lang, K::SettingsNavLabel), items: items) |
| 365 | - <a href=(collaborators)>(g::t(lang, K::Collaborators))</a> | 348 | + <div class="sheet"> |
| 366 | - } | 349 | + (child) |
| 367 | - if rename_on { | 350 | + </div> |
| 368 | - <a href=(rename) aria-current="page">(g::t(lang, K::RenameTransferNav))</a> | 351 | + </div> |
| 369 | - } else { | ||
| 370 | - <a href=(rename)>(g::t(lang, K::RenameTransferNav))</a> | ||
| 371 | - } | ||
| 372 | - if hooks_on { | ||
| 373 | - <a href=(hooks) aria-current="page">(g::t(lang, K::Webhooks))</a> | ||
| 374 | - } else { | ||
| 375 | - <a href=(hooks)>(g::t(lang, K::Webhooks))</a> | ||
| 376 | - } | ||
| 377 | - if mirrors_on { | ||
| 378 | - <a href=(mirrors) aria-current="page">(g::t(lang, K::Mirrors))</a> | ||
| 379 | - } else { | ||
| 380 | - <a href=(mirrors)>(g::t(lang, K::Mirrors))</a> | ||
| 381 | - } | ||
| 382 | - if secrets_on { | ||
| 383 | - <a href=(secrets) aria-current="page">(g::t(lang, K::Secrets))</a> | ||
| 384 | - } else { | ||
| 385 | - <a href=(secrets)>(g::t(lang, K::Secrets))</a> | ||
| 386 | - } | ||
| 387 | - if wiki_on { | ||
| 388 | - <a href=(wiki) aria-current="page">(crate::i18n::code::t(lang, crate::i18n::code::K::TabWiki))</a> | ||
| 389 | - } else { | ||
| 390 | - <a href=(wiki)>(crate::i18n::code::t(lang, crate::i18n::code::K::TabWiki))</a> | ||
| 391 | - } | ||
| 392 | - </nav> | ||
| 393 | - (child) | ||
| 394 | }) | 352 | }) |
| 395 | } | 353 | } |
| 396 | 354 | ||
| @@ -811,8 +769,8 @@ struct SettingsView { | |||
| 811 | contexts: Vec<String>, | 769 | contexts: Vec<String>, |
| 812 | } | 770 | } |
| 813 | 771 | ||
| 814 | -/// The settings body: the repo header tabs with Settings active, the sub-navigation, then one section | 772 | +/// The settings body: the repo header with Settings active, then the rail and one section (`section`: |
| 815 | -/// (`section`: general, branches, discussions or danger) in one left aligned column. | 773 | +/// general, branches, discussions or danger) in the sheet. |
| 816 | #[component] | 774 | #[component] |
| 817 | async fn settings_body( | 775 | async fn settings_body( |
| 818 | lang: Lang, | 776 | lang: Lang, |
| @@ -871,10 +829,16 @@ async fn settings_body( | |||
| 871 | let (description, visibility) = (head.description.clone(), head.visibility); | 829 | let (description, visibility) = (head.description.clone(), head.visibility); |
| 872 | let discussions_on = head.discussions; | 830 | let discussions_on = head.discussions; |
| 873 | let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error)); | 831 | let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error)); |
| 832 | + let section_name = match section { | ||
| 833 | + "branches" => g::t(lang, K::BranchProtection), | ||
| 834 | + "discussions" => crate::i18n::community::t(lang, crate::i18n::community::K::Discussions), | ||
| 835 | + "danger" => g::t(lang, K::DangerZone), | ||
| 836 | + _ => g::t(lang, K::General), | ||
| 837 | + }; | ||
| 874 | // Only one section is rendered. The danger section is only chosen for a viewer who may delete | 838 | // Only one section is rendered. The danger section is only chosen for a viewer who may delete |
| 875 | // (see `pick_section`), and it is last so that its moves come after every clone. | 839 | // (see `pick_section`), and it is last so that its moves come after every clone. |
| 876 | Ok(view! { | 840 | Ok(view! { |
| 877 | - repo_head(head: head) | 841 | + repo_head(head: head, title: Some(section_name.to_owned())) |
| 878 | settings_frame(lang: lang, title: title.clone(), current: section, can_delete: can_delete, | 842 | settings_frame(lang: lang, title: title.clone(), current: section, can_delete: can_delete, |
| 879 | if let Some((text, is_error)) = notice { | 843 | if let Some((text, is_error)) = notice { |
| 880 | if is_error { | 844 | if is_error { |
crates/forge-web/src/pages/repo_side.rsmodified+51 -324
| @@ -11,25 +11,20 @@ use forge_core::Repo; | |||
| 11 | use forge_core::ci::{JobState, RunState}; | 11 | use forge_core::ci::{JobState, RunState}; |
| 12 | use forge_git::churn::{self, CommitChurn}; | 12 | use forge_git::churn::{self, CommitChurn}; |
| 13 | use forge_git::{browse, history}; | 13 | use forge_git::{browse, history}; |
| 14 | -use time::OffsetDateTime; | ||
| 15 | -use time::format_description::well_known::Rfc3339; | ||
| 16 | use topcoat::Result; | 14 | use topcoat::Result; |
| 17 | -use topcoat::view::{View, component, view}; | ||
| 18 | 15 | ||
| 19 | use crate::i18n::Lang; | 16 | use crate::i18n::Lang; |
| 20 | -use crate::i18n::releases_ci as rc; | 17 | +use crate::i18n::timeline as tl; |
| 21 | -use crate::i18n::timeline::{self as tl, K as TK}; | 18 | +use crate::pages::ci_runs::run_href; |
| 22 | -use crate::pages::ci_estimate::{self, Est, Step}; | ||
| 23 | -use crate::pages::ci_runs::{duration_templates, duration_text, run_href, state_text}; | ||
| 24 | use crate::pages::packages::PackageLink; | 19 | use crate::pages::packages::PackageLink; |
| 25 | use crate::pages::passkeys::s; | 20 | use crate::pages::passkeys::s; |
| 26 | use crate::pages::releases::LatestRelease; | 21 | use crate::pages::releases::LatestRelease; |
| 27 | use crate::pages::tree::LatestBar; | 22 | use crate::pages::tree::LatestBar; |
| 28 | use crate::repo_stats::{LangShare, languages, license_file, license_id}; | 23 | use crate::repo_stats::{LangShare, languages, license_file, license_id}; |
| 29 | use crate::state::AppState; | 24 | use crate::state::AppState; |
| 30 | -use crate::views::commit_line::commit_line; | 25 | +use crate::views::parts::SubPart; |
| 31 | -use crate::views::timeline::{StripBar, history_strip}; | 26 | +use crate::views::timeline::StripBar; |
| 32 | -use crate::views::{human_size, now_unix, rel_time, short_oid}; | 27 | +use crate::views::{human_size, short_oid}; |
| 33 | 28 | ||
| 34 | /// CI runs the home page shows: the newest. | 29 | /// CI runs the home page shows: the newest. |
| 35 | const RUNS_SHOWN: u32 = 1; | 30 | const RUNS_SHOWN: u32 = 1; |
| @@ -186,41 +181,13 @@ pub fn strip_bars(commits: &[CommitChurn], ci: &HashMap<String, RunState>) -> Ve | |||
| 186 | .collect() | 181 | .collect() |
| 187 | } | 182 | } |
| 188 | 183 | ||
| 189 | -/// One CI run as the column shows it: a link to the run, its dot, and one line of words. A run | 184 | +/// One CI run as the column shows it: a link to the run and its state, for the pips. |
| 190 | -/// still going has a clock that ticks. | ||
| 191 | pub struct RunRow { | 185 | pub struct RunRow { |
| 192 | pub href: String, | 186 | pub href: String, |
| 193 | - pub number: i64, | ||
| 194 | pub state: RunState, | 187 | pub state: RunState, |
| 195 | - pub dot: &'static str, | ||
| 196 | - /// Unix seconds the run started, for the ticking clock of a run still going. | ||
| 197 | - pub since: Option<String>, | ||
| 198 | - /// The text before the clock: the current job's name. | ||
| 199 | - pub pre: Option<String>, | ||
| 200 | - /// The right-hand text, or the elapsed time of a run still going. | ||
| 201 | - pub label: String, | ||
| 202 | - /// The expected total of a running run, from its past runs. When set, the bar is its fill. | ||
| 203 | - pub est: Option<Est>, | ||
| 204 | pub title: String, | 188 | pub title: String, |
| 205 | } | 189 | } |
| 206 | 190 | ||
| 207 | -/// The dot of a run: glowing while it goes, green passed, red failed, grey otherwise. | ||
| 208 | -fn run_dot(run: RunState) -> &'static str { | ||
| 209 | - match run { | ||
| 210 | - RunState::Success => "health-dot ok", | ||
| 211 | - RunState::Failure | RunState::Error => "health-dot bad", | ||
| 212 | - RunState::Running | RunState::Queued => "health-dot ember", | ||
| 213 | - RunState::Cancelled | RunState::WaitingApproval => "health-dot", | ||
| 214 | - } | ||
| 215 | -} | ||
| 216 | - | ||
| 217 | -/// Unix seconds of an RFC 3339 stamp. | ||
| 218 | -fn unix(stamp: &str) -> Option<i64> { | ||
| 219 | - OffsetDateTime::parse(stamp, &Rfc3339) | ||
| 220 | - .ok() | ||
| 221 | - .map(|at| at.unix_timestamp()) | ||
| 222 | -} | ||
| 223 | - | ||
| 224 | /// The newest runs of the repo, with their jobs. | 191 | /// The newest runs of the repo, with their jobs. |
| 225 | pub async fn run_rows(state: &AppState, lang: Lang, repo: &Repo) -> Result<Vec<RunRow>> { | 192 | pub async fn run_rows(state: &AppState, lang: Lang, repo: &Repo) -> Result<Vec<RunRow>> { |
| 226 | let title = format!("{}/{}", repo.owner_name, repo.name); | 193 | let title = format!("{}/{}", repo.owner_name, repo.name); |
| @@ -238,97 +205,14 @@ pub async fn run_rows(state: &AppState, lang: Lang, repo: &Repo) -> Result<Vec<R | |||
| 238 | ) | 205 | ) |
| 239 | }) | 206 | }) |
| 240 | .count(); | 207 | .count(); |
| 241 | - let started = jobs | ||
| 242 | - .iter() | ||
| 243 | - .filter_map(|job| job.started_at.as_deref()) | ||
| 244 | - .min(); | ||
| 245 | let branch = run | 208 | let branch = run |
| 246 | .git_ref | 209 | .git_ref |
| 247 | .strip_prefix("refs/heads/") | 210 | .strip_prefix("refs/heads/") |
| 248 | .or_else(|| run.git_ref.strip_prefix("refs/tags/")) | 211 | .or_else(|| run.git_ref.strip_prefix("refs/tags/")) |
| 249 | .unwrap_or(&run.git_ref); | 212 | .unwrap_or(&run.git_ref); |
| 250 | - let (since, pre, label, est) = if matches!(run.state, RunState::Running | RunState::Queued) | ||
| 251 | - { | ||
| 252 | - let current = jobs | ||
| 253 | - .iter() | ||
| 254 | - .find(|job| job.state == JobState::Running) | ||
| 255 | - .or_else(|| jobs.iter().find(|job| job.state == JobState::Queued)) | ||
| 256 | - .map(|job| job.name.as_str()) | ||
| 257 | - .unwrap_or(""); | ||
| 258 | - let current = if current.is_empty() && run.state == RunState::Queued { | ||
| 259 | - s(lang, "queued", "sırada") | ||
| 260 | - } else { | ||
| 261 | - current | ||
| 262 | - }; | ||
| 263 | - let since_stamp = started.unwrap_or(run.created_at.as_str()); | ||
| 264 | - let took = duration_text(lang, Some(since_stamp), None); | ||
| 265 | - let est = if run.state == RunState::Running { | ||
| 266 | - let samples = state | ||
| 267 | - .store | ||
| 268 | - .recent_job_samples(&repo.id, std::slice::from_ref(&run.git_ref)) | ||
| 269 | - .await?; | ||
| 270 | - let steps: Vec<Step> = jobs | ||
| 271 | - .iter() | ||
| 272 | - .map(|job| Step { | ||
| 273 | - name: job.name.clone(), | ||
| 274 | - needs: ci_estimate::needs_of(&job.spec_json), | ||
| 275 | - state: job.state, | ||
| 276 | - started: job.started_at.as_deref().and_then(unix), | ||
| 277 | - finished: job.finished_at.as_deref().and_then(unix), | ||
| 278 | - }) | ||
| 279 | - .collect(); | ||
| 280 | - let now = now_unix(); | ||
| 281 | - unix(since_stamp).and_then(|origin| { | ||
| 282 | - let end = ci_estimate::run_end(now, &steps, &samples, &run.git_ref)?; | ||
| 283 | - Some(ci_estimate::estimate(lang, origin, now, end)) | ||
| 284 | - }) | ||
| 285 | - } else { | ||
| 286 | - None | ||
| 287 | - }; | ||
| 288 | - let label = match est.as_ref() { | ||
| 289 | - Some(est) => format!("{took} \u{b7} {}", est.phrase), | ||
| 290 | - None => took, | ||
| 291 | - }; | ||
| 292 | - ( | ||
| 293 | - unix(since_stamp).map(|secs| secs.to_string()), | ||
| 294 | - (!current.is_empty()).then(|| format!("{current} \u{b7} ")), | ||
| 295 | - label, | ||
| 296 | - est, | ||
| 297 | - ) | ||
| 298 | - } else { | ||
| 299 | - let failed = jobs | ||
| 300 | - .iter() | ||
| 301 | - .find(|job| matches!(job.state, JobState::Failure | JobState::Error)) | ||
| 302 | - .map(|job| job.name.as_str()); | ||
| 303 | - let word = match run.state { | ||
| 304 | - RunState::Success => s(lang, "passed", "geçti").to_owned(), | ||
| 305 | - RunState::Failure | RunState::Error => match failed { | ||
| 306 | - Some(name) => format!("{name} {}", s(lang, "failed", "başarısız")), | ||
| 307 | - None => s(lang, "failed", "başarısız").to_owned(), | ||
| 308 | - }, | ||
| 309 | - RunState::Cancelled => s(lang, "cancelled", "iptal edildi").to_owned(), | ||
| 310 | - RunState::WaitingApproval | RunState::Running | RunState::Queued => { | ||
| 311 | - state_text(lang, run.state.as_str()) | ||
| 312 | - } | ||
| 313 | - }; | ||
| 314 | - // The same words as the running clock and the CI pages: "4m 12s". | ||
| 315 | - let took = duration_text(lang, started, run.finished_at.as_deref()); | ||
| 316 | - let label = if took.is_empty() || run.finished_at.is_none() { | ||
| 317 | - word | ||
| 318 | - } else { | ||
| 319 | - format!("{word} \u{b7} {took}") | ||
| 320 | - }; | ||
| 321 | - (None, None, label, None) | ||
| 322 | - }; | ||
| 323 | rows.push(RunRow { | 213 | rows.push(RunRow { |
| 324 | href: run_href(&title, run.number), | 214 | href: run_href(&title, run.number), |
| 325 | - number: run.number, | ||
| 326 | state: run.state, | 215 | state: run.state, |
| 327 | - dot: run_dot(run.state), | ||
| 328 | - since, | ||
| 329 | - pre, | ||
| 330 | - label, | ||
| 331 | - est, | ||
| 332 | title: format!( | 216 | title: format!( |
| 333 | "{}: {done}/{total} \u{b7} {branch} \u{b7} {}", | 217 | "{}: {done}/{total} \u{b7} {branch} \u{b7} {}", |
| 334 | s(lang, "Jobs passed", "Geçen işler"), | 218 | s(lang, "Jobs passed", "Geçen işler"), |
| @@ -356,209 +240,64 @@ pub async fn runs_fingerprint(state: &AppState, repo_id: &str) -> Result<String> | |||
| 356 | Ok(out.join("\n")) | 240 | Ok(out.join("\n")) |
| 357 | } | 241 | } |
| 358 | 242 | ||
| 359 | -/// One language's slice of the header's language bar: where it starts and how wide it is, in | 243 | +/// What the Code tab's sub line adds after the description: the commit on show, then the repo's |
| 360 | -/// percent of the bar, and its shade (0 the biggest). | 244 | +/// facts, its latest release, its packages and how many commits it has. |
| 361 | -pub struct LangSlice { | 245 | +pub fn code_sub( |
| 362 | - pub x: String, | ||
| 363 | - pub width: String, | ||
| 364 | - pub class: &'static str, | ||
| 365 | -} | ||
| 366 | - | ||
| 367 | -/// The bar's slices in order. Each shade is a class (the page's CSP allows no inline styles), and | ||
| 368 | -/// the SVG takes its geometry from attributes. | ||
| 369 | -fn lang_slices(langs: &[LangShare]) -> Vec<LangSlice> { | ||
| 370 | - const SHADES: [&str; 5] = ["lang-0", "lang-1", "lang-2", "lang-3", "lang-4"]; | ||
| 371 | - let mut at = 0u32; | ||
| 372 | - langs | ||
| 373 | - .iter() | ||
| 374 | - .enumerate() | ||
| 375 | - .map(|(i, share)| { | ||
| 376 | - let slice = LangSlice { | ||
| 377 | - x: format!("{at}%"), | ||
| 378 | - width: format!("{}%", share.percent), | ||
| 379 | - class: if share.others.is_empty() { | ||
| 380 | - SHADES[i.min(3)] | ||
| 381 | - } else { | ||
| 382 | - SHADES[4] | ||
| 383 | - }, | ||
| 384 | - }; | ||
| 385 | - at += share.percent; | ||
| 386 | - slice | ||
| 387 | - }) | ||
| 388 | - .collect() | ||
| 389 | -} | ||
| 390 | - | ||
| 391 | -/// The facts line under the repo header, in place of a side column: license, size and a bar of | ||
| 392 | -/// the languages on the left; the latest release and the packages as chips on the right. `facts` | ||
| 393 | -/// is None for a repo with no commit yet. | ||
| 394 | -#[component] | ||
| 395 | -pub async fn repo_strip( | ||
| 396 | lang: Lang, | 246 | lang: Lang, |
| 247 | + latest: Option<LatestBar>, | ||
| 397 | facts: Option<TreeFacts>, | 248 | facts: Option<TreeFacts>, |
| 398 | release: Option<LatestRelease>, | 249 | release: Option<LatestRelease>, |
| 399 | packages: Vec<PackageLink>, | 250 | packages: Vec<PackageLink>, |
| 400 | -) -> Result<impl View> { | 251 | + total: u64, |
| 401 | - let size = facts.as_ref().map(|f| human_size(lang, f.size)); | 252 | +) -> Vec<SubPart> { |
| 402 | - let license = facts.as_ref().and_then(|f| f.license.clone()); | 253 | + let mut parts = Vec::new(); |
| 403 | - let langs = facts.map(|f| f.languages).unwrap_or_default(); | ||
| 404 | - let slices = lang_slices(&langs); | ||
| 405 | - let bar_label = langs | ||
| 406 | - .iter() | ||
| 407 | - .map(|share| format!("{} {}%", lang_name(lang, share), share.percent)) | ||
| 408 | - .collect::<Vec<_>>() | ||
| 409 | - .join(", "); | ||
| 410 | - Ok(view! { | ||
| 411 | - <div class="repo-strip"> | ||
| 412 | - if let Some((file, id)) = license.as_ref() { | ||
| 413 | - <span class="strip-fact" title=(s(lang, "License", "Lisans"))> | ||
| 414 | - <svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v18M5 7h14M7 7l-3 7a3 3 0 0 0 6 0zM17 7l-3 7a3 3 0 0 0 6 0z"/></svg> | ||
| 415 | - if id.is_empty() { (file.as_str()) } else { (id.as_str()) } | ||
| 416 | - </span> | ||
| 417 | - } | ||
| 418 | - if let Some(size) = size.as_ref() { | ||
| 419 | - <span class="strip-fact" title=(s(lang, "Size", "Boyut"))>(size.as_str())</span> | ||
| 420 | - } | ||
| 421 | - if !langs.is_empty() { | ||
| 422 | - <div class="strip-langs"> | ||
| 423 | - <svg class="lang-bar" viewBox="0 0 100 6" preserveAspectRatio="none" role="img" aria-label=(bar_label.as_str())> | ||
| 424 | - for slice in slices.iter() { | ||
| 425 | - <rect class=(slice.class) x=(slice.x.as_str()) y="0" width=(slice.width.as_str()) height="100%"></rect> | ||
| 426 | - } | ||
| 427 | - </svg> | ||
| 428 | - <ul class="lang-legend"> | ||
| 429 | - for (share, slice) in langs.iter().zip(slices.iter()) { | ||
| 430 | - <li title=(lang_meta(lang, share))><span class=(format!("lang-dot {}", slice.class)) aria-hidden="true"></span>(lang_name(lang, share))" "<span class="muted">(format!("{}%", share.percent))</span></li> | ||
| 431 | - } | ||
| 432 | - </ul> | ||
| 433 | - </div> | ||
| 434 | - } | ||
| 435 | - <div class="strip-chips"> | ||
| 436 | - if let Some(release) = release.as_ref() { | ||
| 437 | - <a class="strip-chip" href=(release.href.as_str()) title=(format!("{}{}", release.title, release_counts(lang, release)))> | ||
| 438 | - <span class="sr-only">(rc::t(lang, rc::K::LatestReleaseHeading))" "</span> | ||
| 439 | - <svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8z"/><circle cx="7.5" cy="7.5" r="1.5"/></svg> | ||
| 440 | - (release.tag.as_str()) | ||
| 441 | - <span class="muted">rel_time(lang: lang, stamp: release.when.iso.as_str())</span> | ||
| 442 | - </a> | ||
| 443 | - } | ||
| 444 | - for link in packages.iter() { | ||
| 445 | - <a class="strip-chip" href=(link.href.as_str()) title=(link.latest.as_str())> | ||
| 446 | - <svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 8 12 3 3 8v8l9 5 9-5zM3 8l9 5 9-5M12 13v8"/></svg> | ||
| 447 | - (link.name.as_str()) | ||
| 448 | - </a> | ||
| 449 | - } | ||
| 450 | - </div> | ||
| 451 | - </div> | ||
| 452 | - }) | ||
| 453 | -} | ||
| 454 | - | ||
| 455 | -/// The README pane's header line: the license, the size and the top language, as text beside the | ||
| 456 | -/// file name. The full language split is the title. Nothing when the tree has no facts. | ||
| 457 | -#[component] | ||
| 458 | -pub async fn readme_meta(lang: Lang, facts: Option<TreeFacts>) -> Result<impl View> { | ||
| 459 | let facts = facts.unwrap_or_default(); | 254 | let facts = facts.unwrap_or_default(); |
| 460 | - let mut parts: Vec<String> = Vec::new(); | 255 | + if let Some(share) = facts.languages.first() { |
| 256 | + parts.push(SubPart::text(lang_name(lang, share))); | ||
| 257 | + } | ||
| 461 | if let Some((file, id)) = facts.license.as_ref() { | 258 | if let Some((file, id)) = facts.license.as_ref() { |
| 462 | - parts.push(if id.is_empty() { | 259 | + parts.push(SubPart::text(if id.is_empty() { file } else { id }.as_str())); |
| 463 | - file.clone() | ||
| 464 | - } else { | ||
| 465 | - id.clone() | ||
| 466 | - }); | ||
| 467 | } | 260 | } |
| 468 | if facts.size > 0 { | 261 | if facts.size > 0 { |
| 469 | - parts.push(human_size(lang, facts.size)); | 262 | + parts.push(SubPart::text(human_size(lang, facts.size))); |
| 470 | } | 263 | } |
| 471 | - if let Some(share) = facts.languages.first() { | 264 | + if let Some(bar) = latest { |
| 472 | - parts.push(format!("{} {}%", lang_name(lang, share), share.percent)); | 265 | + let mut sha = SubPart::link(bar.short.as_str(), bar.last.href.as_str()); |
| 266 | + sha.class = "mono"; | ||
| 267 | + parts.push(sha); | ||
| 268 | + parts.push(SubPart::link(bar.last.summary.as_str(), bar.last.href.as_str())); | ||
| 269 | + parts.push(SubPart::text(bar.author.as_str())); | ||
| 270 | + parts.push(SubPart::text(bar.last.age.as_str())); | ||
| 473 | } | 271 | } |
| 474 | - let all = facts | 272 | + if total > 0 { |
| 475 | - .languages | 273 | + parts.push(SubPart::text(tl::commit_count(lang, total))); |
| 476 | - .iter() | ||
| 477 | - .map(|share| format!("{} {}%", lang_name(lang, share), share.percent)) | ||
| 478 | - .collect::<Vec<_>>() | ||
| 479 | - .join(", "); | ||
| 480 | - let text = parts.join(" \u{b7} "); | ||
| 481 | - let show = !parts.is_empty(); | ||
| 482 | - Ok(view! { | ||
| 483 | - if show { | ||
| 484 | - <span class="readme-meta" title=(all.as_str())>(text.as_str())</span> | ||
| 485 | - } | ||
| 486 | - }) | ||
| 487 | -} | ||
| 488 | - | ||
| 489 | -/// The dot's state word is accent only while the run goes; every other state is plain text. | ||
| 490 | -fn dock_state_class(run: RunState) -> &'static str { | ||
| 491 | - match run { | ||
| 492 | - RunState::Running | RunState::Queued => "dock-state is-live", | ||
| 493 | - _ => "dock-state", | ||
| 494 | } | 274 | } |
| 275 | + if let Some(release) = release { | ||
| 276 | + parts.push(SubPart::link( | ||
| 277 | + format!("{}{}", release.tag, release_counts(lang, &release)), | ||
| 278 | + release.href.as_str(), | ||
| 279 | + )); | ||
| 280 | + } | ||
| 281 | + for link in packages { | ||
| 282 | + parts.push(SubPart::link(link.name.as_str(), link.href.as_str())); | ||
| 283 | + } | ||
| 284 | + parts | ||
| 495 | } | 285 | } |
| 496 | 286 | ||
| 497 | -/// The repo's bottom dock, shown under the panes on the repo home and the tree pages: one info row | 287 | +/// The newest runs for a head, oldest first, each a pip that opens its run. |
| 498 | -/// (the newest CI run's dot, number and state, the commit's sha, author and subject with a | 288 | +pub fn run_pips(runs: &[RunRow]) -> Vec<(String, String, &'static str)> { |
| 499 | -/// full-message expander, the commit count and All runs), then the history strip. `latest` is the | 289 | + runs.iter() |
| 500 | -/// commit the page shows. The clock attributes on the root let the page's ticker count a running run. | 290 | + .take(8) |
| 501 | -#[component] | 291 | + .rev() |
| 502 | -pub async fn repo_dock( | 292 | + .map(|run| { |
| 503 | - lang: Lang, | 293 | + let class = match run.state { |
| 504 | - runs: Vec<RunRow>, | 294 | + RunState::Failure | RunState::Error => "bad", |
| 505 | - total: u64, | 295 | + RunState::Running | RunState::Queued => "live", |
| 506 | - ci_href: String, | 296 | + _ => "", |
| 507 | - owner: String, | 297 | + }; |
| 508 | - repo: String, | 298 | + (run.href.clone(), run.title.clone(), class) |
| 509 | - bars: Vec<StripBar>, | 299 | + }) |
| 510 | - latest: Option<LatestBar>, | 300 | + .collect() |
| 511 | -) -> Result<impl View> { | ||
| 512 | - // The clock: the server's time and the duration words the page's ticker rewrites with. | ||
| 513 | - let now = now_unix(); | ||
| 514 | - let (fm, fs) = duration_templates(lang); | ||
| 515 | - let commits = tl::commit_count(lang, total); | ||
| 516 | - let all_runs = tl::t(lang, TK::AllRuns); | ||
| 517 | - let aria = tl::t(lang, TK::Timeline); | ||
| 518 | - let expand = s(lang, "Full commit message", "Commit mesajının tamamı"); | ||
| 519 | - Ok(view! { | ||
| 520 | - <section class="repo-dock canvas-dock" aria-label=(aria) data-now=(now.to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())> | ||
| 521 | - <div class="dock-info"> | ||
| 522 | - if let Some(run) = runs.first() { | ||
| 523 | - <a class="dock-run" href=(run.href.as_str()) title=(run.title.as_str())> | ||
| 524 | - <span class=(run.dot)></span> | ||
| 525 | - <span class="side-run-name">(format!("CI #{}", run.number))</span> | ||
| 526 | - </a> | ||
| 527 | - <span class=(dock_state_class(run.state))>(state_text(lang, run.state.as_str()))</span> | ||
| 528 | - if let Some(since) = run.since.as_deref() { | ||
| 529 | - if let Some(est) = run.est.as_ref() { | ||
| 530 | - <span class="dock-clock muted" data-since=(since) data-pre=(run.pre.as_deref()) data-expected=(est.expected.as_str()) data-left=(est.left.as_str()) data-over=(est.over.as_str()) data-lm=(est.minutes.as_str())>(run.label.as_str())</span> | ||
| 531 | - } else { | ||
| 532 | - <span class="dock-clock muted" data-since=(since) data-pre=(run.pre.as_deref())>(run.label.as_str())</span> | ||
| 533 | - } | ||
| 534 | - } | ||
| 535 | - } | ||
| 536 | - if let Some(bar) = latest { | ||
| 537 | - <span class="sha dock-sha">(bar.short.as_str())</span> | ||
| 538 | - if let (Some(src), Some(href)) = (bar.avatar, bar.author_href) { | ||
| 539 | - <a class="dock-author" href=(href) title=(bar.author.as_str())> | ||
| 540 | - <img class="avatar avatar-sm dock-avatar" src=(src) alt=(bar.author.as_str()) width="20" height="20"> | ||
| 541 | - </a> | ||
| 542 | - } else { | ||
| 543 | - <span class="avatar avatar-sm avatar-blank dock-avatar" aria-hidden="true" title=(bar.author.as_str())>(bar.author.chars().next().map(|c| c.to_uppercase().collect::<String>()).unwrap_or_default())</span> | ||
| 544 | - } | ||
| 545 | - <a class="dock-subject" href=(bar.last.href.as_str()) title=(bar.last.absolute.as_str())>commit_line(subject: bar.last.summary.clone())</a> | ||
| 546 | - <details class="dock-expand"> | ||
| 547 | - <summary aria-label=(expand) title=(expand)><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></summary> | ||
| 548 | - <div class="dock-message"> | ||
| 549 | - <p class="dock-message-by muted small">(bar.author.as_str())</p> | ||
| 550 | - <pre class="dock-message-text">(bar.message.as_str())</pre> | ||
| 551 | - </div> | ||
| 552 | - </details> | ||
| 553 | - } | ||
| 554 | - <span class="dock-count muted small">(commits.as_str())</span> | ||
| 555 | - <a class="small dock-all" href=(ci_href.as_str())>(all_runs)</a> | ||
| 556 | - </div> | ||
| 557 | - <div class="dock-history"> | ||
| 558 | - history_strip(lang: lang, owner: owner, repo: repo, bars: bars) | ||
| 559 | - </div> | ||
| 560 | - </section> | ||
| 561 | - }) | ||
| 562 | } | 301 | } |
| 563 | 302 | ||
| 564 | /// " · 2 assets · 41 downloads" after the release's age; empty without assets. | 303 | /// " · 2 assets · 41 downloads" after the release's age; empty without assets. |
| @@ -591,15 +330,3 @@ fn lang_name(lang: Lang, share: &LangShare) -> String { | |||
| 591 | } | 330 | } |
| 592 | } | 331 | } |
| 593 | 332 | ||
| 594 | -/// "412 files · 2.9 MB", or the folded languages on the remainder row. | ||
| 595 | -fn lang_meta(lang: Lang, share: &LangShare) -> String { | ||
| 596 | - if !share.others.is_empty() { | ||
| 597 | - return share.others.join(", "); | ||
| 598 | - } | ||
| 599 | - let files = match lang { | ||
| 600 | - Lang::Tr => format!("{} dosya", share.files), | ||
| 601 | - Lang::En if share.files == 1 => "1 file".to_owned(), | ||
| 602 | - Lang::En => format!("{} files", share.files), | ||
| 603 | - }; | ||
| 604 | - format!("{files} \u{b7} {}", human_size(lang, share.bytes)) | ||
| 605 | -} | ||
crates/forge-web/src/pages/repo_transfer.rsmodified+28 -26
| @@ -74,32 +74,34 @@ async fn transfer_body( | |||
| 74 | settings: Option<String>, | 74 | settings: Option<String>, |
| 75 | ) -> Result<impl View> { | 75 | ) -> Result<impl View> { |
| 76 | Ok(view! { | 76 | Ok(view! { |
| 77 | - repo_head(head: head) | 77 | + repo_head(head: head, title: Some(g::t(lang, K::TransferTitle).to_owned())) |
| 78 | - <section class="sec"> | 78 | + <div class="sheet"> |
| 79 | - <h2>(g::t(lang, K::TransferTitle))</h2> | 79 | + <section class="sec"> |
| 80 | - if let Some(summary) = summary.as_ref() { | 80 | + <h2>(g::t(lang, K::TransferTitle))</h2> |
| 81 | - <p class="state">(summary.before.as_str()) rel_time(lang: lang, stamp: summary.expires_at.as_str()) (summary.after)</p> | 81 | + if let Some(summary) = summary.as_ref() { |
| 82 | - <div class="acts"> | 82 | + <p class="state">(summary.before.as_str()) rel_time(lang: lang, stamp: summary.expires_at.as_str()) (summary.after)</p> |
| 83 | - if let Some(action) = accept { | 83 | + <div class="acts"> |
| 84 | - post_act(label: g::t(lang, K::AcceptTransfer), action: action.as_str(), csrf: csrf.as_str()) | 84 | + if let Some(action) = accept { |
| 85 | - } | 85 | + post_act(label: g::t(lang, K::AcceptTransfer), action: action.as_str(), csrf: csrf.as_str()) |
| 86 | - if let Some(action) = decline { | 86 | + } |
| 87 | - confirm_act(lang: lang, label: g::t(lang, K::DeclineTransfer), action: action.as_str(), csrf: csrf.as_str()) | 87 | + if let Some(action) = decline { |
| 88 | - } | 88 | + confirm_act(lang: lang, label: g::t(lang, K::DeclineTransfer), action: action.as_str(), csrf: csrf.as_str()) |
| 89 | - if let Some(action) = cancel { | 89 | + } |
| 90 | - confirm_act(lang: lang, label: g::t(lang, K::CancelTransfer), action: action.as_str(), csrf: csrf.as_str()) | 90 | + if let Some(action) = cancel { |
| 91 | - } | 91 | + confirm_act(lang: lang, label: g::t(lang, K::CancelTransfer), action: action.as_str(), csrf: csrf.as_str()) |
| 92 | - </div> | 92 | + } |
| 93 | - } | 93 | + </div> |
| 94 | - if summary.is_none() { | 94 | + } |
| 95 | - <p class="state">(g::t(lang, K::NoPendingTransfer))</p> | 95 | + if summary.is_none() { |
| 96 | - } | 96 | + <p class="state">(g::t(lang, K::NoPendingTransfer))</p> |
| 97 | - if let Some(href) = settings { | 97 | + } |
| 98 | - <div class="acts"> | 98 | + if let Some(href) = settings { |
| 99 | - <a class="act quiet" href=(href.as_str())>(g::t(lang, K::StartTransferLink))</a> | 99 | + <div class="acts"> |
| 100 | - </div> | 100 | + <a class="act" href=(href.as_str())>(g::t(lang, K::StartTransferLink))</a> |
| 101 | - } | 101 | + </div> |
| 102 | - </section> | 102 | + } |
| 103 | + </section> | ||
| 104 | + </div> | ||
| 103 | }) | 105 | }) |
| 104 | } | 106 | } |
| 105 | 107 | ||
crates/forge-web/src/pages/repo_webhooks.rsmodified+41 -35
| @@ -31,7 +31,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | |||
| 31 | use crate::pages::repo_settings::settings_frame; | 31 | use crate::pages::repo_settings::settings_frame; |
| 32 | use crate::pages::repo_settings_live::settings_head; | 32 | use crate::pages::repo_settings_live::settings_head; |
| 33 | use crate::state::AppState; | 33 | use crate::state::AppState; |
| 34 | -use crate::views::parts::{confirm_act, post_act, reveal}; | 34 | +use crate::views::parts::{confirm_act, post_act}; |
| 35 | use crate::views::{alert, enc, now_unix, relative_time, shell}; | 35 | use crate::views::{alert, enc, now_unix, relative_time, shell}; |
| 36 | use crate::webhooks::client::{WebhookPolicy, validate_url}; | 36 | use crate::webhooks::client::{WebhookPolicy, validate_url}; |
| 37 | use crate::webhooks::emit::emit_ping; | 37 | use crate::webhooks::emit::emit_ping; |
| @@ -486,19 +486,26 @@ impl Frame { | |||
| 486 | } | 486 | } |
| 487 | } | 487 | } |
| 488 | 488 | ||
| 489 | -/// Header, sub-navigation, the one-line notice, and the archived note. | 489 | +/// Header, the rail, the one-line notice, and the archived note. `heading` is the page's title (the |
| 490 | +/// list's name, or the hook's URL); `action` is the head's main action as (href, label), if any. | ||
| 490 | #[component] | 491 | #[component] |
| 491 | async fn frame_top( | 492 | async fn frame_top( |
| 492 | head: RepoHead, | 493 | head: RepoHead, |
| 493 | title: String, | 494 | title: String, |
| 495 | + heading: String, | ||
| 494 | notice: Option<(&'static str, bool)>, | 496 | notice: Option<(&'static str, bool)>, |
| 495 | archived: bool, | 497 | archived: bool, |
| 496 | lang: Lang, | 498 | lang: Lang, |
| 499 | + #[default] action: Option<(String, &'static str)>, | ||
| 497 | #[default] child: Child<'_>, | 500 | #[default] child: Child<'_>, |
| 498 | ) -> Result<impl View> { | 501 | ) -> Result<impl View> { |
| 499 | let can_delete = head.can_delete; | 502 | let can_delete = head.can_delete; |
| 500 | Ok(view! { | 503 | Ok(view! { |
| 501 | - repo_head(head: head) | 504 | + repo_head(head: head, title: Some(heading), |
| 505 | + if let Some((href, label)) = action { | ||
| 506 | + <a class="button primary" href=(href.as_str())>(label)</a> | ||
| 507 | + } | ||
| 508 | + ) | ||
| 502 | settings_frame(lang: lang, title: title, current: "webhooks", can_delete: can_delete, | 509 | settings_frame(lang: lang, title: title, current: "webhooks", can_delete: can_delete, |
| 503 | if let Some((text, is_error)) = notice { | 510 | if let Some((text, is_error)) = notice { |
| 504 | if is_error { | 511 | if is_error { |
| @@ -529,7 +536,7 @@ async fn hook_form( | |||
| 529 | lang: Lang, | 536 | lang: Lang, |
| 530 | ) -> Result<impl View> { | 537 | ) -> Result<impl View> { |
| 531 | Ok(view! { | 538 | Ok(view! { |
| 532 | - <form method="post" action=(action.as_str()) class="fields"> | 539 | + <form method="post" action=(action.as_str())> |
| 533 | if let Some(message) = error { | 540 | if let Some(message) = error { |
| 534 | alert(message: message.as_str()) | 541 | alert(message: message.as_str()) |
| 535 | } | 542 | } |
| @@ -550,20 +557,27 @@ async fn hook_form( | |||
| 550 | <section class="sec"> | 557 | <section class="sec"> |
| 551 | <h2>(crate::pages::passkeys::s(lang, "Delivery", "Teslimat"))</h2> | 558 | <h2>(crate::pages::passkeys::s(lang, "Delivery", "Teslimat"))</h2> |
| 552 | <div class="field" role="group" aria-labelledby="hook-events-title"> | 559 | <div class="field" role="group" aria-labelledby="hook-events-title"> |
| 553 | - <p class="field-title" id="hook-events-title">(g::t(lang, K::Events))</p> | 560 | + <span class="field-label" id="hook-events-title">(g::t(lang, K::Events))</span> |
| 554 | - for event in events.iter() { | 561 | + <div class="checks"> |
| 562 | + for event in events.iter() { | ||
| 563 | + <label class="switch"> | ||
| 564 | + <input type="checkbox" name=(event.name.as_str()) value="on" checked=(event.checked)> | ||
| 565 | + <span>(event.label)</span> | ||
| 566 | + </label> | ||
| 567 | + } | ||
| 568 | + </div> | ||
| 569 | + </div> | ||
| 570 | + <div class="field"> | ||
| 571 | + <span class="field-label">(crate::pages::passkeys::s(lang, "State", "Durum"))</span> | ||
| 572 | + <div class="checks"> | ||
| 555 | <label class="switch"> | 573 | <label class="switch"> |
| 556 | - <input type="checkbox" name=(event.name.as_str()) value="on" checked=(event.checked)> | 574 | + <input type="checkbox" name="active" value="on" checked=(active)> |
| 557 | - <span>(event.label)</span> | 575 | + <span>(g::t(lang, K::ActiveField))</span> |
| 558 | </label> | 576 | </label> |
| 559 | - } | 577 | + </div> |
| 560 | </div> | 578 | </div> |
| 561 | - <label class="switch"> | 579 | + <button type="submit" class="primary">(submit)</button> |
| 562 | - <input type="checkbox" name="active" value="on" checked=(active)> | ||
| 563 | - <span>(g::t(lang, K::ActiveField))</span> | ||
| 564 | - </label> | ||
| 565 | </section> | 580 | </section> |
| 566 | - <button type="submit" class="primary">(submit)</button> | ||
| 567 | </form> | 581 | </form> |
| 568 | }) | 582 | }) |
| 569 | } | 583 | } |
| @@ -574,32 +588,20 @@ async fn hooks_list_body( | |||
| 574 | title: String, | 588 | title: String, |
| 575 | notice: Option<(&'static str, bool)>, | 589 | notice: Option<(&'static str, bool)>, |
| 576 | archived: bool, | 590 | archived: bool, |
| 577 | - csrf: String, | ||
| 578 | rows: Vec<HookRow>, | 591 | rows: Vec<HookRow>, |
| 579 | lang: Lang, | 592 | lang: Lang, |
| 580 | ) -> Result<impl View> { | 593 | ) -> Result<impl View> { |
| 581 | let new_action = format!("{}/new", hooks_href(&title)); | 594 | let new_action = format!("{}/new", hooks_href(&title)); |
| 582 | - let blank = HookDraft::blank(); | 595 | + let add = (!archived).then(|| (new_action, g::t(lang, K::AddWebhook))); |
| 583 | - let events = event_boxes(lang, &blank.events); | ||
| 584 | let empty = rows.is_empty(); | 596 | let empty = rows.is_empty(); |
| 585 | Ok(view! { | 597 | Ok(view! { |
| 586 | - frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, | 598 | + frame_top(head: head, title: title.clone(), heading: g::t(lang, K::Webhooks).to_owned(), notice: notice, archived: archived, lang: lang, action: add, |
| 587 | <section class="sec"> | 599 | <section class="sec"> |
| 588 | - <h2>(g::t(lang, K::Webhooks))</h2> | ||
| 589 | if empty { | 600 | if empty { |
| 590 | <p class="state">(g::t(lang, K::NoWebhooks))</p> | 601 | <p class="state">(g::t(lang, K::NoWebhooks))</p> |
| 591 | } else { | 602 | } else { |
| 592 | <p class="hint">(g::t(lang, K::WebhooksIntro))</p> | 603 | <p class="hint">(g::t(lang, K::WebhooksIntro))</p> |
| 593 | } | 604 | } |
| 594 | - if !archived { | ||
| 595 | - <div class="acts"> | ||
| 596 | - reveal(label: g::t(lang, K::AddWebhook), id: Some("add-webhook"), | ||
| 597 | - hook_form(action: new_action, csrf: csrf, url: String::new(), events: events, | ||
| 598 | - active: blank.active, secret_hint: g::t(lang, K::SecretHintNew).to_owned(), | ||
| 599 | - error: None, submit: g::t(lang, K::CreateWebhook), lang: lang) | ||
| 600 | - ) | ||
| 601 | - </div> | ||
| 602 | - } | ||
| 603 | for row in rows.iter() { | 605 | for row in rows.iter() { |
| 604 | <a class="line" href=(row.href.as_str()) data-kb-row=""> | 606 | <a class="line" href=(row.href.as_str()) data-kb-row=""> |
| 605 | <span class="name"><span class=(row.dot_class) role="img" aria-label=(row.dot_text) title=(row.dot_text)></span> (row.url.as_str())</span> | 607 | <span class="name"><span class=(row.dot_class) role="img" aria-label=(row.dot_text) title=(row.dot_text)></span> (row.url.as_str())</span> |
| @@ -686,8 +688,14 @@ async fn hook_body( | |||
| 686 | let test_action = format!("{edit_action}/test"); | 688 | let test_action = format!("{edit_action}/test"); |
| 687 | let delete_action = format!("{edit_action}/delete"); | 689 | let delete_action = format!("{edit_action}/delete"); |
| 688 | let events = event_boxes(lang, &draft.events); | 690 | let events = event_boxes(lang, &draft.events); |
| 691 | + // The hook's name is its URL; a hook with no URL yet shows the list's name. | ||
| 692 | + let heading = if draft.url.is_empty() { | ||
| 693 | + g::t(lang, K::Webhooks).to_owned() | ||
| 694 | + } else { | ||
| 695 | + draft.url.clone() | ||
| 696 | + }; | ||
| 689 | Ok(view! { | 697 | Ok(view! { |
| 690 | - frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, | 698 | + frame_top(head: head, title: title.clone(), heading: heading, notice: notice, archived: archived, lang: lang, |
| 691 | if archived { | 699 | if archived { |
| 692 | <section class="sec"> | 700 | <section class="sec"> |
| 693 | <h2>(crate::pages::passkeys::s(lang, "Endpoint", "Uç nokta"))</h2> | 701 | <h2>(crate::pages::passkeys::s(lang, "Endpoint", "Uç nokta"))</h2> |
| @@ -732,7 +740,7 @@ async fn hooks_list_page(cx: &Cx) -> Result<impl View> { | |||
| 732 | let owner = path_param::<Owner>(cx); | 740 | let owner = path_param::<Owner>(cx); |
| 733 | let name = path_param::<Repo>(cx); | 741 | let name = path_param::<Repo>(cx); |
| 734 | let ctx = load_repo(cx, owner, name).await?; | 742 | let ctx = load_repo(cx, owner, name).await?; |
| 735 | - let (_, session) = require_user(cx).await?; | 743 | + require_user(cx).await?; |
| 736 | if !ctx.can_admin() { | 744 | if !ctx.can_admin() { |
| 737 | return Err(forbidden().into()); | 745 | return Err(forbidden().into()); |
| 738 | } | 746 | } |
| @@ -759,11 +767,10 @@ async fn hooks_list_page(cx: &Cx) -> Result<impl View> { | |||
| 759 | rows.push(hook_row(lang, tz, &frame.title, hook, last, &last_stamp)); | 767 | rows.push(hook_row(lang, tz, &frame.title, hook, last, &last_stamp)); |
| 760 | } | 768 | } |
| 761 | let notice = notice_from_query(cx, lang); | 769 | let notice = notice_from_query(cx, lang); |
| 762 | - let csrf = session.csrf_token.clone(); | ||
| 763 | Ok(view! { | 770 | Ok(view! { |
| 764 | shell(title: frame.page_title.as_str(), viewer: ctx.viewer.as_ref(), | 771 | shell(title: frame.page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 765 | hooks_list_body(head: frame.head, title: frame.title, notice: notice, | 772 | hooks_list_body(head: frame.head, title: frame.title, notice: notice, |
| 766 | - archived: frame.archived, csrf: csrf, rows: rows, lang: lang)) | 773 | + archived: frame.archived, rows: rows, lang: lang)) |
| 767 | }) | 774 | }) |
| 768 | } | 775 | } |
| 769 | 776 | ||
| @@ -803,9 +810,8 @@ async fn hook_new_body( | |||
| 803 | let events = event_boxes(lang, &draft.events); | 810 | let events = event_boxes(lang, &draft.events); |
| 804 | let back = hooks_href(&title); | 811 | let back = hooks_href(&title); |
| 805 | Ok(view! { | 812 | Ok(view! { |
| 806 | - frame_top(head: head, title: title.clone(), notice: None, archived: archived, lang: lang, | 813 | + frame_top(head: head, title: title.clone(), heading: g::t(lang, K::AddWebhook).to_owned(), notice: None, archived: archived, lang: lang, |
| 807 | <section class="sec"> | 814 | <section class="sec"> |
| 808 | - <h2>(g::t(lang, K::AddWebhook))</h2> | ||
| 809 | <p class="hint">(g::t(lang, K::AddWebhookIntro))</p> | 815 | <p class="hint">(g::t(lang, K::AddWebhookIntro))</p> |
| 810 | <div class="acts"> | 816 | <div class="acts"> |
| 811 | <a class="act quiet" href=(back.as_str())>(g::t(lang, K::BackToWebhooks))</a> | 817 | <a class="act quiet" href=(back.as_str())>(g::t(lang, K::BackToWebhooks))</a> |
| @@ -1722,7 +1728,7 @@ mod tests { | |||
| 1722 | assert!(body.contains("Add webhook"), "{body}"); | 1728 | assert!(body.contains("Add webhook"), "{body}"); |
| 1723 | assert!(body.contains("none yet"), "{body}"); | 1729 | assert!(body.contains("none yet"), "{body}"); |
| 1724 | assert!( | 1730 | assert!( |
| 1725 | - body.contains("<nav class=\"sub\" aria-label=\"Settings\">"), | 1731 | + body.contains("<nav class=\"rail\" aria-label=\"Settings\">"), |
| 1726 | "{body}" | 1732 | "{body}" |
| 1727 | ); | 1733 | ); |
| 1728 | let (status, _, body) = send( | 1734 | let (status, _, body) = send( |
crates/forge-web/src/pages/review_requests.rsmodified+26 -28
| @@ -13,7 +13,6 @@ use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; | |||
| 13 | use topcoat::router::request::uri; | 13 | use topcoat::router::request::uri; |
| 14 | use topcoat::router::response::Response; | 14 | use topcoat::router::response::Response; |
| 15 | use topcoat::router::{Body, StatusCode, page, path_param, route}; | 15 | use topcoat::router::{Body, StatusCode, page, path_param, route}; |
| 16 | -use crate::views::parts::reveal; | ||
| 17 | use topcoat::view::{View, component, view}; | 16 | use topcoat::view::{View, component, view}; |
| 18 | 17 | ||
| 19 | use crate::auth::{current_user, require_user}; | 18 | use crate::auth::{current_user, require_user}; |
| @@ -22,9 +21,11 @@ use crate::i18n::{self, Lang}; | |||
| 22 | use crate::live::{Topic, stream_wakes}; | 21 | use crate::live::{Topic, stream_wakes}; |
| 23 | use crate::notify; | 22 | use crate::notify; |
| 24 | use crate::pages::issue_parts::{ItemKind, check_write, may_change, parse_number}; | 23 | use crate::pages::issue_parts::{ItemKind, check_write, may_change, parse_number}; |
| 24 | +use crate::pages::passkeys::s; | ||
| 25 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; | 25 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| 27 | -use crate::views::{rel_time, repo_href, shell}; | 27 | +use crate::views::parts::{SubPart, head, post_act, reveal}; |
| 28 | +use crate::views::{alert, rel_time, repo_href, shell}; | ||
| 28 | 29 | ||
| 29 | path_param!(owner); | 30 | path_param!(owner); |
| 30 | path_param!(repo); | 31 | path_param!(repo); |
| @@ -210,28 +211,22 @@ pub(crate) async fn reviewers_box(lang: Lang, reviewers: ReviewersView) -> Resul | |||
| 210 | } = reviewers; | 211 | } = reviewers; |
| 211 | let message = error.map(|code| error_text(lang, code)); | 212 | let message = error.map(|code| error_text(lang, code)); |
| 212 | Ok(view! { | 213 | Ok(view! { |
| 213 | - <section class="sec reviewers-box" id="reviewers"> | 214 | + <section class="sec meta" id="reviewers"> |
| 214 | <h2>(ga::t(lang, AK::Reviewers))</h2> | 215 | <h2>(ga::t(lang, AK::Reviewers))</h2> |
| 215 | if let Some(message) = message { | 216 | if let Some(message) = message { |
| 216 | - <p class="alert" role="alert">(message)</p> | 217 | + alert(message: message) |
| 217 | } | 218 | } |
| 218 | if names.is_empty() { | 219 | if names.is_empty() { |
| 219 | - <p class="state">(ga::t(lang, AK::NoReviewers))</p> | 220 | + <p class="hint">(ga::t(lang, AK::NoReviewers))</p> |
| 221 | + } | ||
| 222 | + for name in names.iter() { | ||
| 223 | + <div class="line"> | ||
| 224 | + <span class="name"><a href=(format!("/{name}"))>(name.as_str())</a></span> | ||
| 225 | + if write { | ||
| 226 | + post_act(label: ga::t(lang, AK::WithdrawRequest), action: action.as_str(), csrf: csrf.as_str(), fields: vec![("action".to_owned(), "withdraw".to_owned()), ("username".to_owned(), name.to_owned())]) | ||
| 227 | + } | ||
| 228 | + </div> | ||
| 220 | } | 229 | } |
| 221 | - <div class="plain-rows"> | ||
| 222 | - for name in names.iter() { | ||
| 223 | - <div class="line"> | ||
| 224 | - <a class="name" href=(format!("/{name}"))>(name.as_str())</a> | ||
| 225 | - if write { | ||
| 226 | - <form method="post" action=(action.as_str()) class="act-form"> | ||
| 227 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 228 | - <input type="hidden" name="username" value=(name.as_str())> | ||
| 229 | - <button type="submit" name="action" value="withdraw" class="act quiet">(ga::t(lang, AK::WithdrawRequest))</button> | ||
| 230 | - </form> | ||
| 231 | - } | ||
| 232 | - </div> | ||
| 233 | - } | ||
| 234 | - </div> | ||
| 235 | if write { | 230 | if write { |
| 236 | <div class="acts"> | 231 | <div class="acts"> |
| 237 | reveal(label: ga::t(lang, AK::RequestReview), id: Some("request-review"), | 232 | reveal(label: ga::t(lang, AK::RequestReview), id: Some("request-review"), |
| @@ -291,16 +286,19 @@ async fn review_requests(cx: &Cx) -> Result<impl View> { | |||
| 291 | } | 286 | } |
| 292 | let heading = ga::t(lang, AK::ReviewRequests); | 287 | let heading = ga::t(lang, AK::ReviewRequests); |
| 293 | let empty = rows.is_empty(); | 288 | let empty = rows.is_empty(); |
| 289 | + let sub = vec![SubPart::text(s( | ||
| 290 | + lang, | ||
| 291 | + "Pull requests waiting for your review", | ||
| 292 | + "İncelemeni bekleyen değişiklik istekleri", | ||
| 293 | + ))]; | ||
| 294 | Ok(view! { | 294 | Ok(view! { |
| 295 | shell(title: heading, viewer: Some(&viewer), | 295 | shell(title: heading, viewer: Some(&viewer), |
| 296 | - <section data-live="/review-requests/events"> | 296 | + head(title: heading, sub: sub, live: Some("/review-requests/events")) |
| 297 | - <h1 class="sr-only">(heading)</h1> | 297 | + <div class="sheet"> |
| 298 | - </section> | 298 | + <div class="sec"> |
| 299 | - if empty { | 299 | + if empty { |
| 300 | - <p class="state">(ga::t(lang, AK::NoReviewRequests))</p> | 300 | + <p class="state">(ga::t(lang, AK::NoReviewRequests))</p> |
| 301 | - } | 301 | + } |
| 302 | - if !empty { | ||
| 303 | - <div class="plain-rows"> | ||
| 304 | for row in rows.iter() { | 302 | for row in rows.iter() { |
| 305 | <a class="line" href=(row.1.as_str()) data-kb-row=""> | 303 | <a class="line" href=(row.1.as_str()) data-kb-row=""> |
| 306 | <span class="name">(row.2.as_str())</span> | 304 | <span class="name">(row.2.as_str())</span> |
| @@ -310,7 +308,7 @@ async fn review_requests(cx: &Cx) -> Result<impl View> { | |||
| 310 | </a> | 308 | </a> |
| 311 | } | 309 | } |
| 312 | </div> | 310 | </div> |
| 313 | - } | 311 | + </div> |
| 314 | ) | 312 | ) |
| 315 | }) | 313 | }) |
| 316 | } | 314 | } |
crates/forge-web/src/pages/settings_appearance.rsmodified+64 -48
| @@ -24,7 +24,9 @@ use crate::custom_colour; | |||
| 24 | use crate::i18n::accents::{accent_name, base_name}; | 24 | use crate::i18n::accents::{accent_name, base_name}; |
| 25 | use crate::i18n::misc::{self as g, K}; | 25 | use crate::i18n::misc::{self as g, K}; |
| 26 | use crate::i18n::{self, Lang}; | 26 | use crate::i18n::{self, Lang}; |
| 27 | +use crate::pages::passkeys::s; | ||
| 27 | use crate::state::AppState; | 28 | use crate::state::AppState; |
| 29 | +use crate::views::parts::{SubPart, head}; | ||
| 28 | use crate::views::shell; | 30 | use crate::views::shell; |
| 29 | 31 | ||
| 30 | /// Language codes offered on the page. `auto` follows the browser. Other codes must be | 32 | /// Language codes offered on the page. `auto` follows the browser. Other codes must be |
| @@ -316,9 +318,10 @@ async fn colour_row(row: ColourRow) -> Result<impl View> { | |||
| 316 | "accent-swatch hue-swatch" | 318 | "accent-swatch hue-swatch" |
| 317 | }; | 319 | }; |
| 318 | Ok(view! { | 320 | Ok(view! { |
| 319 | - <div class="colour-line"> | ||
| 320 | <fieldset class="colour-picker" data-colour-row="true" data-kind=(kind) data-lightness=(lightness.as_str())> | 321 | <fieldset class="colour-picker" data-colour-row="true" data-kind=(kind) data-lightness=(lightness.as_str())> |
| 321 | - <legend>(legend)</legend> | 322 | + <legend class="sr-only">(legend)</legend> |
| 323 | + <div class="field"> | ||
| 324 | + <span class="field-label" aria-hidden="true">(legend)</span> | ||
| 322 | <div class="colour-choices"> | 325 | <div class="colour-choices"> |
| 323 | for choice in choices.into_iter() { | 326 | for choice in choices.into_iter() { |
| 324 | <label class="colour-choice"> | 327 | <label class="colour-choice"> |
| @@ -336,15 +339,13 @@ async fn colour_row(row: ColourRow) -> Result<impl View> { | |||
| 336 | <span class="accent-swatch" data-accent-light-swatch=(choice.value) aria-hidden="true"></span> | 339 | <span class="accent-swatch" data-accent-light-swatch=(choice.value) aria-hidden="true"></span> |
| 337 | } | 340 | } |
| 338 | } | 341 | } |
| 339 | - <span>(choice.label)</span> | 342 | + <span class="sr-only">(choice.label)</span> |
| 340 | </label> | 343 | </label> |
| 341 | } | 344 | } |
| 342 | - </div> | ||
| 343 | - <div class="hue-row"> | ||
| 344 | <label class="colour-choice"> | 345 | <label class="colour-choice"> |
| 345 | <input type="radio" name=(field) value=(value.as_str()) checked=(stripe.custom) data-hue-custom="true" data-autosubmit="true"> | 346 | <input type="radio" name=(field) value=(value.as_str()) checked=(stripe.custom) data-hue-custom="true" data-autosubmit="true"> |
| 346 | <span class=(custom_swatch) aria-hidden="true"></span> | 347 | <span class=(custom_swatch) aria-hidden="true"></span> |
| 347 | - <span>(custom_label)</span> | 348 | + <span class="sr-only">(custom_label)</span> |
| 348 | </label> | 349 | </label> |
| 349 | <div class="tune"> | 350 | <div class="tune"> |
| 350 | <input type="range" class="hue-stripe" min="0" max="359" value=(hue_value.as_str()) aria-label=(hue_label) data-hue-stripe="true" data-autosubmit="true"> | 351 | <input type="range" class="hue-stripe" min="0" max="359" value=(hue_value.as_str()) aria-label=(hue_label) data-hue-stripe="true" data-autosubmit="true"> |
| @@ -355,8 +356,8 @@ async fn colour_row(row: ColourRow) -> Result<impl View> { | |||
| 355 | <small class="hex-note" data-hex-note="true" data-message=(note)></small> | 356 | <small class="hex-note" data-hex-note="true" data-message=(note)></small> |
| 356 | </div> | 357 | </div> |
| 357 | </div> | 358 | </div> |
| 359 | + </div> | ||
| 358 | </fieldset> | 360 | </fieldset> |
| 359 | - </div> | ||
| 360 | }) | 361 | }) |
| 361 | } | 362 | } |
| 362 | 363 | ||
| @@ -429,42 +430,45 @@ async fn appearance_body(page: AppearancePage) -> Result<impl View> { | |||
| 429 | sound_on, | 430 | sound_on, |
| 430 | } = page; | 431 | } = page; |
| 431 | Ok(view! { | 432 | Ok(view! { |
| 433 | + <div class="sheet fit"> | ||
| 432 | <form id="appearance-form" method="post" action="/settings/appearance" class="appearance" data-appearance="true"> | 434 | <form id="appearance-form" method="post" action="/settings/appearance" class="appearance" data-appearance="true"> |
| 433 | - <h1 class="sr-only">(g::t(lang, K::Appearance))</h1> | ||
| 434 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 435 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 435 | <section class="sec"> | 436 | <section class="sec"> |
| 436 | - <h2>(crate::pages::passkeys::s(lang, "Theme and language", "Tema ve dil"))</h2> | 437 | + <h2>(s(lang, "Theme and language", "Tema ve dil"))</h2> |
| 437 | - <div class="field-pair"> | 438 | + <div class="field"> |
| 438 | - <div class="field"> | 439 | + <span class="field-label" id="theme-label">(g::t(lang, K::ThemeLabel))</span> |
| 439 | - <label for="theme">(g::t(lang, K::ThemeLabel))</label> | 440 | + <div class="choice" role="radiogroup" aria-labelledby="theme-label"> |
| 440 | - <select id="theme" name="theme" data-autosubmit="true"> | 441 | + for choice in theme.into_iter() { |
| 441 | - for choice in theme.into_iter() { | 442 | + <label> |
| 442 | - <option value=(choice.value) selected=(choice.selected)>(choice.label)</option> | 443 | + <input type="radio" name="theme" value=(choice.value) checked=(choice.selected) data-autosubmit="true"> |
| 443 | - } | 444 | + <span>(choice.label)</span> |
| 444 | - </select> | 445 | + </label> |
| 445 | - <p class="hint">(g::t(lang, K::MatchSystemHelp))</p> | 446 | + } |
| 446 | - </div> | ||
| 447 | - <div class="field"> | ||
| 448 | - <label for="language">(g::t(lang, K::LanguageLabel))</label> | ||
| 449 | - <select id="language" name="language" data-autosubmit="true"> | ||
| 450 | - for choice in language.into_iter() { | ||
| 451 | - <option value=(choice.value) selected=(choice.selected)>(choice.label)</option> | ||
| 452 | - } | ||
| 453 | - </select> | ||
| 454 | </div> | 447 | </div> |
| 455 | </div> | 448 | </div> |
| 449 | + <div class="field"> | ||
| 450 | + <label for="language">(g::t(lang, K::LanguageLabel))</label> | ||
| 451 | + <select id="language" name="language" data-autosubmit="true"> | ||
| 452 | + for choice in language.into_iter() { | ||
| 453 | + <option value=(choice.value) selected=(choice.selected)>(choice.label)</option> | ||
| 454 | + } | ||
| 455 | + </select> | ||
| 456 | + </div> | ||
| 456 | </section> | 457 | </section> |
| 457 | <section class="sec"> | 458 | <section class="sec"> |
| 458 | <h2>(colours)</h2> | 459 | <h2>(colours)</h2> |
| 459 | <fieldset class="colour-group" data-colour-group="true" data-tab=(tab)> | 460 | <fieldset class="colour-group" data-colour-group="true" data-tab=(tab)> |
| 460 | <legend class="sr-only">(colours)</legend> | 461 | <legend class="sr-only">(colours)</legend> |
| 461 | - <div class="tabs" role="group"> | 462 | + <div class="field"> |
| 462 | - for choice in tabs.into_iter() { | 463 | + <span class="field-label" id="colour-tab-label">(s(lang, "For", "Tema"))</span> |
| 463 | - <label> | 464 | + <div class="choice" role="radiogroup" aria-labelledby="colour-tab-label"> |
| 464 | - <input type="radio" name="colour_tab" value=(choice.value) checked=(choice.selected) data-colour-tab=(choice.value)> | 465 | + for choice in tabs.into_iter() { |
| 465 | - <span>(choice.label)</span> | 466 | + <label> |
| 466 | - </label> | 467 | + <input type="radio" name="colour_tab" value=(choice.value) checked=(choice.selected) data-colour-tab=(choice.value)> |
| 467 | - } | 468 | + <span>(choice.label)</span> |
| 469 | + </label> | ||
| 470 | + } | ||
| 471 | + </div> | ||
| 468 | </div> | 472 | </div> |
| 469 | colour_panel(group: light) | 473 | colour_panel(group: light) |
| 470 | colour_panel(group: dark) | 474 | colour_panel(group: dark) |
| @@ -473,23 +477,27 @@ async fn appearance_body(page: AppearancePage) -> Result<impl View> { | |||
| 473 | <section class="sec"> | 477 | <section class="sec"> |
| 474 | <h2>(g::t(lang, K::SoundLabel))</h2> | 478 | <h2>(g::t(lang, K::SoundLabel))</h2> |
| 475 | <input type="hidden" name="sound_shown" value="1"> | 479 | <input type="hidden" name="sound_shown" value="1"> |
| 476 | - <label class="switch"> | 480 | + <div class="field"> |
| 477 | - <input type="checkbox" name="sound" value="on" checked=(sound_on) data-autosubmit="true"> | 481 | + <span class="field-label" id="alerts-label">(s(lang, "Run alerts", "Çalışma uyarıları"))</span> |
| 478 | - <span>(g::t(lang, K::SoundSwitch))</span> | 482 | + <div class="sound-row"> |
| 479 | - </label> | 483 | + <div class="choice" role="radiogroup" aria-labelledby="alerts-label"> |
| 480 | - <p class="hint">(g::t(lang, K::SoundOwnRuns)) " · " (g::t(lang, K::SoundFootOwn))</p> | 484 | + <label> |
| 481 | - <div class="line"> | 485 | + <input type="radio" name="sound" value="on" checked=(sound_on) data-autosubmit="true"> |
| 482 | - <span class="name">(g::t(lang, K::SoundPassed))</span> | 486 | + <span>(s(lang, "On", "Açık"))</span> |
| 483 | - <span class="val">(g::t(lang, K::SoundPassedNote))</span> | 487 | + </label> |
| 484 | - <button type="button" class="act" data-sound-play="passed">(g::t(lang, K::SoundPlay))</button> | 488 | + <label> |
| 485 | - </div> | 489 | + <input type="radio" name="sound" value="off" checked=(!sound_on) data-autosubmit="true"> |
| 486 | - <div class="line"> | 490 | + <span>(s(lang, "Off", "Kapalı"))</span> |
| 487 | - <span class="name">(g::t(lang, K::SoundFailed))</span> | 491 | + </label> |
| 488 | - <span class="val">(g::t(lang, K::SoundFailedNote))</span> | 492 | + </div> |
| 489 | - <button type="button" class="act" data-sound-play="failed">(g::t(lang, K::SoundPlay))</button> | 493 | + <span class="hint">(g::t(lang, K::SoundOwnRuns))</span> |
| 494 | + <button type="button" class="act play" data-sound-play="passed" title=(g::t(lang, K::SoundPassedNote))>(g::t(lang, K::SoundPassed))</button> | ||
| 495 | + <button type="button" class="act play" data-sound-play="failed" title=(g::t(lang, K::SoundFailedNote))>(g::t(lang, K::SoundFailed))</button> | ||
| 496 | + </div> | ||
| 490 | </div> | 497 | </div> |
| 491 | </section> | 498 | </section> |
| 492 | </form> | 499 | </form> |
| 500 | + </div> | ||
| 493 | }) | 501 | }) |
| 494 | } | 502 | } |
| 495 | 503 | ||
| @@ -597,8 +605,16 @@ async fn appearance_page(cx: &Cx) -> Result<impl View> { | |||
| 597 | .user_prefs(&viewer.0.id) | 605 | .user_prefs(&viewer.0.id) |
| 598 | .await?; | 606 | .await?; |
| 599 | let page = page_for(&viewer, lang, &prefs); | 607 | let page = page_for(&viewer, lang, &prefs); |
| 608 | + let sub = vec![SubPart::text(s( | ||
| 609 | + lang, | ||
| 610 | + "Saved to your account, follows you on every device", | ||
| 611 | + "Hesabına kaydedilir, her cihazda seninle gelir", | ||
| 612 | + ))]; | ||
| 600 | Ok(view! { | 613 | Ok(view! { |
| 601 | - shell(title: g::t(lang, K::Appearance), viewer: Some(&viewer), appearance_body(page: page)) | 614 | + shell(title: g::t(lang, K::Appearance), viewer: Some(&viewer), |
| 615 | + head(title: g::t(lang, K::Appearance), sub: sub) | ||
| 616 | + appearance_body(page: page) | ||
| 617 | + ) | ||
| 602 | }) | 618 | }) |
| 603 | } | 619 | } |
| 604 | 620 | ||
crates/forge-web/src/pages/settings_export.rsmodified+8 -9
| @@ -26,6 +26,7 @@ use crate::i18n::migrate::{self as g, K}; | |||
| 26 | use crate::i18n::{self, Lang}; | 26 | use crate::i18n::{self, Lang}; |
| 27 | use crate::pages::ci_runs::{changed_event, events_response}; | 27 | use crate::pages::ci_runs::{changed_event, events_response}; |
| 28 | use crate::state::AppState; | 28 | use crate::state::AppState; |
| 29 | +use crate::views::parts::{SubPart, head}; | ||
| 29 | use crate::views::{alert, csrf_field, human_size, rel_time, shell}; | 30 | use crate::views::{alert, csrf_field, human_size, rel_time, shell}; |
| 30 | 31 | ||
| 31 | path_param!(export_id); | 32 | path_param!(export_id); |
| @@ -62,19 +63,17 @@ async fn export_view(lang: Lang, csrf: &str, exports: Vec<DataExport>) -> Result | |||
| 62 | let empty = exports.is_empty(); | 63 | let empty = exports.is_empty(); |
| 63 | let ttl_note = g::export_ttl_note(lang, exporter::EXPORT_TTL_DAYS); | 64 | let ttl_note = g::export_ttl_note(lang, exporter::EXPORT_TTL_DAYS); |
| 64 | Ok(view! { | 65 | Ok(view! { |
| 65 | - <h1 class="sr-only">(g::t(lang, K::ExportTitle))</h1> | 66 | + head(title: g::t(lang, K::ExportTitle), sub: vec![SubPart::text(g::t(lang, K::ExportIntro))], |
| 66 | - <div class="export-page" data-live=(live.as_deref()) data-live-state=(if building { "building" } else { "idle" })> | 67 | + <form method="post" action="/settings/export"> |
| 68 | + csrf_field(token: csrf) | ||
| 69 | + <button type="submit" class="primary" disabled=(building)>(g::t(lang, K::ExportRequest))</button> | ||
| 70 | + </form> | ||
| 71 | + ) | ||
| 72 | + <div class="sheet fit export-page" data-live=(live.as_deref()) data-live-state=(if building { "building" } else { "idle" })> | ||
| 67 | <section class="sec"> | 73 | <section class="sec"> |
| 68 | <h2>(crate::pages::passkeys::s(lang, "Archive", "Arşiv"))</h2> | 74 | <h2>(crate::pages::passkeys::s(lang, "Archive", "Arşiv"))</h2> |
| 69 | - <p class="hint">(g::t(lang, K::ExportIntro))</p> | ||
| 70 | <p class="hint">(g::t(lang, K::ExportContents))</p> | 75 | <p class="hint">(g::t(lang, K::ExportContents))</p> |
| 71 | <p class="hint">(g::t(lang, K::ExportEmailNote)) " " (ttl_note.as_str())</p> | 76 | <p class="hint">(g::t(lang, K::ExportEmailNote)) " " (ttl_note.as_str())</p> |
| 72 | - <div class="acts"> | ||
| 73 | - <form method="post" action="/settings/export" class="act-form"> | ||
| 74 | - csrf_field(token: csrf) | ||
| 75 | - <button type="submit" class="act" disabled=(building)>(g::t(lang, K::ExportRequest))</button> | ||
| 76 | - </form> | ||
| 77 | - </div> | ||
| 78 | </section> | 77 | </section> |
| 79 | <section class="sec"> | 78 | <section class="sec"> |
| 80 | <h2>(crate::pages::passkeys::s(lang, "Your archives", "Arşivleriniz"))</h2> | 79 | <h2>(crate::pages::passkeys::s(lang, "Your archives", "Arşivleriniz"))</h2> |
crates/forge-web/src/pages/settings_gpg.rsmodified+54 -47
| @@ -8,7 +8,7 @@ use topcoat::Result; | |||
| 8 | use topcoat::context::{Cx, app_context}; | 8 | use topcoat::context::{Cx, app_context}; |
| 9 | use topcoat::router::content::Form; | 9 | use topcoat::router::content::Form; |
| 10 | use topcoat::router::error::{SeeOther, not_found, see_other}; | 10 | use topcoat::router::error::{SeeOther, not_found, see_other}; |
| 11 | -use topcoat::router::{page, route}; | 11 | +use topcoat::router::{page, query_params, route}; |
| 12 | use topcoat::view::{View, component, view}; | 12 | use topcoat::view::{View, component, view}; |
| 13 | 13 | ||
| 14 | use crate::audit::{self, Actor, Target}; | 14 | use crate::audit::{self, Actor, Target}; |
| @@ -16,8 +16,9 @@ use crate::auth::{require_csrf, require_user}; | |||
| 16 | use crate::i18n::{self, Key, Lang, t}; | 16 | use crate::i18n::{self, Key, Lang, t}; |
| 17 | use crate::signatures; | 17 | use crate::signatures; |
| 18 | use crate::state::AppState; | 18 | use crate::state::AppState; |
| 19 | -use crate::pages::settings_keys::{KeysDraft, keys_page_view}; | 19 | +use crate::pages::passkeys::s; |
| 20 | -use crate::views::parts::{confirm_act, reveal}; | 20 | +use crate::pages::settings_keys::{AddQuery, KeyKind, KeysDraft, keys_page_view}; |
| 21 | +use crate::views::parts::confirm_act; | ||
| 21 | use crate::views::{added_status, alert, user_facing_message}; | 22 | use crate::views::{added_status, alert, user_facing_message}; |
| 22 | 23 | ||
| 23 | #[derive(Deserialize)] | 24 | #[derive(Deserialize)] |
| @@ -44,58 +45,64 @@ pub(crate) async fn gpg_section( | |||
| 44 | armored: &str, | 45 | armored: &str, |
| 45 | error: Option<String>, | 46 | error: Option<String>, |
| 46 | available: bool, | 47 | available: bool, |
| 48 | + add: bool, | ||
| 47 | ) -> Result<impl View> { | 49 | ) -> Result<impl View> { |
| 48 | let empty = keys.is_empty(); | 50 | let empty = keys.is_empty(); |
| 49 | - let open = error.is_some(); | ||
| 50 | Ok(view! { | 51 | Ok(view! { |
| 51 | - <section class="sec" id="gpg"> | 52 | + if !available { |
| 52 | - <h2>(t(lang, Key::GpgKeys))</h2> | 53 | + <p class="state">(t(lang, Key::GpgUnavailable))</p> |
| 53 | - if !available { | 54 | + } |
| 54 | - <p class="hint">(t(lang, Key::GpgUnavailable))</p> | 55 | + if add { |
| 55 | - } | 56 | + <div class="sheet-add" id="add-gpg-key"> |
| 56 | - if empty { | 57 | + if let Some(message) = error { |
| 57 | - <p class="state">(t(lang, Key::NoGpgKeys))</p> | 58 | + alert(message: message.as_str()) |
| 58 | - } | ||
| 59 | - <div> | ||
| 60 | - for key in keys.into_iter() { | ||
| 61 | - <details class="row-open"> | ||
| 62 | - <summary class="line"> | ||
| 63 | - <span class="name">(key.emails.join(", "))</span> | ||
| 64 | - <span class="val">added_status(lang: lang, added: Some(key.created_at.as_str()), used: None)</span> | ||
| 65 | - </summary> | ||
| 66 | - <div class="opened"> | ||
| 67 | - <code class="hint">(key.fingerprint.clone())</code> | ||
| 68 | - <div class="acts"> | ||
| 69 | - confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/gpg/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) | ||
| 70 | - </div> | ||
| 71 | - </div> | ||
| 72 | - </details> | ||
| 73 | } | 59 | } |
| 74 | - </div> | 60 | + <form method="post" action="/settings/gpg" class="fields"> |
| 75 | - <div class="acts"> | 61 | + <input type="hidden" name="csrf" value=(csrf)> |
| 76 | - reveal(label: t(lang, Key::AddKeyButton), id: Some("add-gpg-key"), open: open, | 62 | + <div class="field"> |
| 77 | - if let Some(message) = error { | 63 | + <label for="gpg-key">(t(lang, Key::ArmoredPublicKeyLabel))</label> |
| 78 | - alert(message: message.as_str()) | 64 | + <textarea id="gpg-key" name="armored" rows="8" spellcheck="false" required=(true)>(armored)</textarea> |
| 79 | - } | 65 | + <p class="hint">(t(lang, Key::ArmoredHint))</p> |
| 80 | - <form method="post" action="/settings/gpg" class="fields"> | 66 | + </div> |
| 81 | - <input type="hidden" name="csrf" value=(csrf)> | 67 | + <div class="acts asks"> |
| 82 | - <div class="field"> | ||
| 83 | - <label for="gpg-key">(t(lang, Key::ArmoredPublicKeyLabel))</label> | ||
| 84 | - <textarea id="gpg-key" name="armored" rows="8" spellcheck="false" required=(true)>(armored)</textarea> | ||
| 85 | - <p class="hint">(t(lang, Key::ArmoredHint))</p> | ||
| 86 | - </div> | ||
| 87 | <button type="submit" class="primary">(t(lang, Key::AddKeyButton))</button> | 68 | <button type="submit" class="primary">(t(lang, Key::AddKeyButton))</button> |
| 88 | - </form> | 69 | + <a class="act" href="/settings/gpg">(s(lang, "Keep it", "Vazgeç"))</a> |
| 89 | - ) | 70 | + </div> |
| 71 | + </form> | ||
| 90 | </div> | 72 | </div> |
| 91 | - </section> | 73 | + } |
| 74 | + if empty { | ||
| 75 | + <p class="state">(t(lang, Key::NoGpgKeys))</p> | ||
| 76 | + } | ||
| 77 | + for key in keys.into_iter() { | ||
| 78 | + <details class="row-open"> | ||
| 79 | + <summary class="line"> | ||
| 80 | + <span class="name">(key.emails.join(", "))</span> | ||
| 81 | + <span class="val">added_status(lang: lang, added: Some(key.created_at.as_str()), used: None)</span> | ||
| 82 | + </summary> | ||
| 83 | + <div class="opened"> | ||
| 84 | + <code class="hint">(key.fingerprint.clone())</code> | ||
| 85 | + <div class="acts"> | ||
| 86 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/gpg/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) | ||
| 87 | + </div> | ||
| 88 | + </div> | ||
| 89 | + </details> | ||
| 90 | + } | ||
| 92 | }) | 91 | }) |
| 93 | } | 92 | } |
| 94 | 93 | ||
| 95 | -#[route(GET "/settings/gpg")] | 94 | +#[page("/settings/gpg")] |
| 96 | -async fn gpg_page(cx: &Cx) -> Result<SeeOther> { | 95 | +async fn gpg_page(cx: &Cx) -> Result<impl View> { |
| 97 | - require_user(cx).await?; | 96 | + let viewer = require_user(cx).await?; |
| 98 | - Ok(see_other("/settings/keys#gpg")) | 97 | + let lang = i18n::lang(cx, Some(&viewer.0)); |
| 98 | + let state = app_context::<AppState>(cx); | ||
| 99 | + let draft = KeysDraft { | ||
| 100 | + add: query_params::<AddQuery>(cx)?.add.is_some(), | ||
| 101 | + ..KeysDraft::default() | ||
| 102 | + }; | ||
| 103 | + Ok(view! { | ||
| 104 | + keys_page_view(lang: lang, state: state, viewer: &viewer, kind: KeyKind::Gpg, draft: draft) | ||
| 105 | + }) | ||
| 99 | } | 106 | } |
| 100 | 107 | ||
| 101 | #[page(POST "/settings/gpg")] | 108 | #[page(POST "/settings/gpg")] |
| @@ -143,7 +150,7 @@ async fn gpg_add(cx: &Cx, Form(form): Form<AddKeyForm>) -> Result<impl View> { | |||
| 143 | ..KeysDraft::default() | 150 | ..KeysDraft::default() |
| 144 | }; | 151 | }; |
| 145 | Ok(view! { | 152 | Ok(view! { |
| 146 | - keys_page_view(lang: lang, state: state, viewer: &viewer, draft: draft) | 153 | + keys_page_view(lang: lang, state: state, viewer: &viewer, kind: KeyKind::Gpg, draft: draft) |
| 147 | }) | 154 | }) |
| 148 | } | 155 | } |
| 149 | 156 | ||
crates/forge-web/src/pages/settings_gpg_tests.rsmodified+3 -11
| @@ -157,17 +157,9 @@ async fn gpg_refusals_and_the_listing_share_one_site() { | |||
| 157 | "the key survives refused deletes" | 157 | "the key survives refused deletes" |
| 158 | ); | 158 | ); |
| 159 | 159 | ||
| 160 | - // The GPG page now redirects to the keys page, which lists the key. | 160 | + // The listing is the GPG kind of the keys page. The notice shows only when GPG is missing on this |
| 161 | - let redirect = call(&site, "GET", "/settings/gpg", Some(&cookie), None).await; | 161 | + // server. |
| 162 | - assert_eq!(redirect.status, 303, "gpg page redirects"); | 162 | + let reply = call(&site, "GET", "/settings/gpg", Some(&cookie), None).await; |
| 163 | - assert_eq!( | ||
| 164 | - redirect.location.as_deref(), | ||
| 165 | - Some("/settings/keys#gpg"), | ||
| 166 | - "gpg page redirects to the keys page" | ||
| 167 | - ); | ||
| 168 | - | ||
| 169 | - // The listing is read from the keys page. The notice shows only when GPG is missing on this server. | ||
| 170 | - let reply = call(&site, "GET", "/settings/keys", Some(&cookie), None).await; | ||
| 171 | assert_eq!(reply.status, 200, "listing page"); | 163 | assert_eq!(reply.status, 200, "listing page"); |
| 172 | assert!( | 164 | assert!( |
| 173 | reply.body.contains(FINGERPRINT), | 165 | reply.body.contains(FINGERPRINT), |
crates/forge-web/src/pages/settings_keys.rsmodified+148 -51
| @@ -1,5 +1,5 @@ | |||
| 1 | -//! Page: keys (`/settings/keys`): SSH keys, GPG keys and access tokens on one page. Only ed25519 | 1 | +//! Page: keys (`/settings/keys`, `/settings/gpg`, `/settings/tokens`): SSH keys, GPG keys and access |
| 2 | -//! and ECDSA SSH keys are accepted. | 2 | +//! tokens, one kind at a time, with the kinds in the rail. Only ed25519 and ECDSA SSH keys are accepted. |
| 3 | 3 | ||
| 4 | use base64::prelude::{BASE64_STANDARD, BASE64_STANDARD_NO_PAD, Engine as _}; | 4 | use base64::prelude::{BASE64_STANDARD, BASE64_STANDARD_NO_PAD, Engine as _}; |
| 5 | use forge_core::{AuditAction, Session, SshKey, User}; | 5 | use forge_core::{AuditAction, Session, SshKey, User}; |
| @@ -9,7 +9,7 @@ use topcoat::Result; | |||
| 9 | use topcoat::context::{Cx, app_context}; | 9 | use topcoat::context::{Cx, app_context}; |
| 10 | use topcoat::router::content::Form; | 10 | use topcoat::router::content::Form; |
| 11 | use topcoat::router::error::{SeeOther, see_other}; | 11 | use topcoat::router::error::{SeeOther, see_other}; |
| 12 | -use topcoat::router::{page, route}; | 12 | +use topcoat::router::{page, query_params, route}; |
| 13 | use topcoat::view::{View, component, view}; | 13 | use topcoat::view::{View, component, view}; |
| 14 | 14 | ||
| 15 | use crate::audit::{self, Actor, Target}; | 15 | use crate::audit::{self, Actor, Target}; |
| @@ -18,7 +18,8 @@ use crate::i18n::{self, Key, Lang, t, unsupported_key_type}; | |||
| 18 | use crate::state::AppState; | 18 | use crate::state::AppState; |
| 19 | use crate::pages::settings_gpg::gpg_section; | 19 | use crate::pages::settings_gpg::gpg_section; |
| 20 | use crate::pages::settings_tokens::tokens_section; | 20 | use crate::pages::settings_tokens::tokens_section; |
| 21 | -use crate::views::parts::{confirm_act, reveal}; | 21 | +use crate::pages::passkeys::s; |
| 22 | +use crate::views::parts::{RailItem, SubPart, confirm_act, head, rail}; | ||
| 22 | use crate::views::{added_status, alert, shell, user_facing_message}; | 23 | use crate::views::{added_status, alert, shell, user_facing_message}; |
| 23 | 24 | ||
| 24 | /// Algorithms accepted for web-registered keys. `ssh-rsa` is rejected with its own message. | 25 | /// Algorithms accepted for web-registered keys. `ssh-rsa` is rejected with its own message. |
| @@ -148,14 +149,64 @@ pub(crate) struct KeysDraft { | |||
| 148 | pub gpg_error: Option<String>, | 149 | pub gpg_error: Option<String>, |
| 149 | pub token: Option<String>, | 150 | pub token: Option<String>, |
| 150 | pub token_error: Option<String>, | 151 | pub token_error: Option<String>, |
| 152 | + /// The add form is open, by `?add` or because it came back with an error. | ||
| 153 | + pub add: bool, | ||
| 151 | } | 154 | } |
| 152 | 155 | ||
| 153 | -/// The keys page for the viewer, with what a form sent back. | 156 | +/// Which kind of key the page shows. |
| 157 | +#[derive(Clone, Copy, PartialEq, Eq)] | ||
| 158 | +pub(crate) enum KeyKind { | ||
| 159 | + Ssh, | ||
| 160 | + Gpg, | ||
| 161 | + Tokens, | ||
| 162 | +} | ||
| 163 | + | ||
| 164 | +impl KeyKind { | ||
| 165 | + fn href(self) -> &'static str { | ||
| 166 | + match self { | ||
| 167 | + KeyKind::Ssh => "/settings/keys", | ||
| 168 | + KeyKind::Gpg => "/settings/gpg", | ||
| 169 | + KeyKind::Tokens => "/settings/tokens", | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + fn title(self, lang: Lang) -> &'static str { | ||
| 174 | + match self { | ||
| 175 | + KeyKind::Ssh => t(lang, Key::SshKeys), | ||
| 176 | + KeyKind::Gpg => t(lang, Key::GpgKeys), | ||
| 177 | + KeyKind::Tokens => t(lang, Key::AccessTokens), | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + fn add_label(self, lang: Lang) -> &'static str { | ||
| 182 | + match self { | ||
| 183 | + KeyKind::Ssh => s(lang, "Add SSH key", "SSH anahtarı ekle"), | ||
| 184 | + KeyKind::Gpg => s(lang, "Add GPG key", "GPG anahtarı ekle"), | ||
| 185 | + KeyKind::Tokens => t(lang, Key::NewToken), | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + fn about(self, lang: Lang) -> &'static str { | ||
| 190 | + match self { | ||
| 191 | + KeyKind::Ssh => s(lang, "Push and pull over SSH", "SSH ile gönder ve çek"), | ||
| 192 | + KeyKind::Gpg => s(lang, "Verify the commits you sign", "İmzaladığın commit'leri doğrula"), | ||
| 193 | + KeyKind::Tokens => s(lang, "Sign in from the command line and from scripts", "Komut satırından ve betiklerden giriş yap"), | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | +} | ||
| 197 | + | ||
| 198 | +#[query_params(error = bad_request)] | ||
| 199 | +pub(crate) struct AddQuery { | ||
| 200 | + pub add: Option<String>, | ||
| 201 | +} | ||
| 202 | + | ||
| 203 | +/// The keys page for the viewer, one kind at a time, with what a form sent back. | ||
| 154 | #[component] | 204 | #[component] |
| 155 | pub(crate) async fn keys_page_view( | 205 | pub(crate) async fn keys_page_view( |
| 156 | lang: Lang, | 206 | lang: Lang, |
| 157 | state: &AppState, | 207 | state: &AppState, |
| 158 | viewer: &(User, Session), | 208 | viewer: &(User, Session), |
| 209 | + kind: KeyKind, | ||
| 159 | draft: KeysDraft, | 210 | draft: KeysDraft, |
| 160 | ) -> Result<impl View> { | 211 | ) -> Result<impl View> { |
| 161 | let keys = state.store.list_ssh_keys(&viewer.0.id).await?; | 212 | let keys = state.store.list_ssh_keys(&viewer.0.id).await?; |
| @@ -163,15 +214,58 @@ pub(crate) async fn keys_page_view( | |||
| 163 | let tokens = state.store.list_tokens(&viewer.0.id).await?; | 214 | let tokens = state.store.list_tokens(&viewer.0.id).await?; |
| 164 | let available = crate::signatures::gpg_available(state).await; | 215 | let available = crate::signatures::gpg_available(state).await; |
| 165 | let csrf = viewer.1.csrf_token.as_str(); | 216 | let csrf = viewer.1.csrf_token.as_str(); |
| 217 | + let count = |k: KeyKind| match k { | ||
| 218 | + KeyKind::Ssh => keys.len(), | ||
| 219 | + KeyKind::Gpg => gpg_keys.len(), | ||
| 220 | + KeyKind::Tokens => tokens.len(), | ||
| 221 | + }; | ||
| 222 | + let items: Vec<RailItem> = [KeyKind::Ssh, KeyKind::Gpg, KeyKind::Tokens] | ||
| 223 | + .into_iter() | ||
| 224 | + .map(|k| RailItem { | ||
| 225 | + name: k.title(lang).to_owned(), | ||
| 226 | + val: count(k).to_string(), | ||
| 227 | + href: k.href().to_owned(), | ||
| 228 | + current: k == kind, | ||
| 229 | + }) | ||
| 230 | + .collect(); | ||
| 231 | + let sub = vec![ | ||
| 232 | + SubPart::text(kind.about(lang)), | ||
| 233 | + SubPart::text(key_count(lang, count(kind))), | ||
| 234 | + ]; | ||
| 235 | + let add_href = format!("{}?add", kind.href()); | ||
| 236 | + let add_open = draft.add | ||
| 237 | + || draft.ssh_error.is_some() | ||
| 238 | + || draft.gpg_error.is_some() | ||
| 239 | + || draft.token_error.is_some(); | ||
| 166 | Ok(view! { | 240 | Ok(view! { |
| 167 | - shell(title: pk_title(lang), viewer: Some(viewer), | 241 | + shell(title: kind.title(lang), viewer: Some(viewer), |
| 168 | - ssh_section(lang: lang, csrf: csrf, keys: keys, public_key: draft.public_key.as_str(), error: draft.ssh_error) | 242 | + head(title: kind.title(lang), sub: sub, |
| 169 | - gpg_section(lang: lang, csrf: csrf, keys: gpg_keys, armored: draft.armored.as_str(), error: draft.gpg_error, available: available) | 243 | + <a class="button primary" href=(add_href)>(kind.add_label(lang))</a> |
| 170 | - tokens_section(lang: lang, csrf: csrf, tokens: tokens, created: draft.token, error: draft.token_error) | 244 | + ) |
| 245 | + <div class="work"> | ||
| 246 | + rail(label: pk_title(lang), items: items) | ||
| 247 | + <div class="sheet fit"> | ||
| 248 | + if kind == KeyKind::Ssh { | ||
| 249 | + ssh_section(lang: lang, csrf: csrf, keys: keys, public_key: draft.public_key.as_str(), error: draft.ssh_error, add: add_open) | ||
| 250 | + } else if kind == KeyKind::Gpg { | ||
| 251 | + gpg_section(lang: lang, csrf: csrf, keys: gpg_keys, armored: draft.armored.as_str(), error: draft.gpg_error, available: available, add: add_open) | ||
| 252 | + } else { | ||
| 253 | + tokens_section(lang: lang, csrf: csrf, tokens: tokens, created: draft.token, error: draft.token_error, add: add_open) | ||
| 254 | + } | ||
| 255 | + </div> | ||
| 256 | + </div> | ||
| 171 | ) | 257 | ) |
| 172 | }) | 258 | }) |
| 173 | } | 259 | } |
| 174 | 260 | ||
| 261 | +fn key_count(lang: Lang, n: usize) -> String { | ||
| 262 | + match lang { | ||
| 263 | + Lang::Tr => format!("{n} anahtar"), | ||
| 264 | + Lang::En if n == 1 => "1 key".to_owned(), | ||
| 265 | + Lang::En => format!("{n} keys"), | ||
| 266 | + } | ||
| 267 | +} | ||
| 268 | + | ||
| 175 | fn pk_title(lang: Lang) -> &'static str { | 269 | fn pk_title(lang: Lang) -> &'static str { |
| 176 | crate::pages::passkeys::s(lang, "Keys", "Anahtarlar") | 270 | crate::pages::passkeys::s(lang, "Keys", "Anahtarlar") |
| 177 | } | 271 | } |
| @@ -183,52 +277,51 @@ async fn ssh_section( | |||
| 183 | keys: Vec<SshKey>, | 277 | keys: Vec<SshKey>, |
| 184 | public_key: &str, | 278 | public_key: &str, |
| 185 | error: Option<String>, | 279 | error: Option<String>, |
| 280 | + add: bool, | ||
| 186 | ) -> Result<impl View> { | 281 | ) -> Result<impl View> { |
| 187 | let empty = keys.is_empty(); | 282 | let empty = keys.is_empty(); |
| 188 | - let open = error.is_some(); | ||
| 189 | Ok(view! { | 283 | Ok(view! { |
| 190 | - <section class="sec" id="ssh"> | 284 | + if add { |
| 191 | - <h2>(t(lang, Key::SshKeys))</h2> | 285 | + <div class="sheet-add" id="add-key"> |
| 192 | - if empty { | 286 | + if let Some(message) = error { |
| 193 | - <p class="state">(t(lang, Key::NoSshKeys))</p> | 287 | + alert(message: message.as_str()) |
| 194 | - } | ||
| 195 | - <div> | ||
| 196 | - for key in keys.into_iter() { | ||
| 197 | - <details class="row-open"> | ||
| 198 | - <summary class="line"> | ||
| 199 | - <span class="name">(key.title.clone())</span> | ||
| 200 | - <span class="val">(key.algorithm.clone()) " · " added_status(lang: lang, added: Some(key.created_at.as_str()), used: key.last_used_at.as_deref())</span> | ||
| 201 | - </summary> | ||
| 202 | - <div class="opened"> | ||
| 203 | - <code class="hint">(key.fingerprint.clone())</code> | ||
| 204 | - <div class="acts"> | ||
| 205 | - confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/keys/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) | ||
| 206 | - </div> | ||
| 207 | - </div> | ||
| 208 | - </details> | ||
| 209 | } | 288 | } |
| 210 | - </div> | 289 | + <form data-hard="true" method="post" action="/settings/keys" class="fields"> |
| 211 | - <div class="acts"> | 290 | + <input type="hidden" name="csrf" value=(csrf)> |
| 212 | - reveal(label: t(lang, Key::AddKeyButton), id: Some("add-key"), open: open, | 291 | + <div class="field"> |
| 213 | - if let Some(message) = error { | 292 | + <label for="ssh-title">(t(lang, Key::TitleOptional))</label> |
| 214 | - alert(message: message.as_str()) | 293 | + <input id="ssh-title" type="text" name="title" maxlength="100" autocomplete="off"> |
| 215 | - } | 294 | + </div> |
| 216 | - <form data-hard="true" method="post" action="/settings/keys" class="fields"> | 295 | + <div class="field"> |
| 217 | - <input type="hidden" name="csrf" value=(csrf)> | 296 | + <label for="ssh-key">(t(lang, Key::PublicKeyLabel))</label> |
| 218 | - <div class="field"> | 297 | + <textarea id="ssh-key" name="public_key" rows="4" spellcheck="false" required=(true)>(public_key)</textarea> |
| 219 | - <label for="ssh-title">(t(lang, Key::TitleOptional))</label> | 298 | + <p class="hint">(t(lang, Key::PublicKeyHint))</p> |
| 220 | - <input id="ssh-title" type="text" name="title" maxlength="100" autocomplete="off"> | 299 | + </div> |
| 221 | - </div> | 300 | + <div class="acts asks"> |
| 222 | - <div class="field"> | ||
| 223 | - <label for="ssh-key">(t(lang, Key::PublicKeyLabel))</label> | ||
| 224 | - <textarea id="ssh-key" name="public_key" rows="4" spellcheck="false" required=(true)>(public_key)</textarea> | ||
| 225 | - <p class="hint">(t(lang, Key::PublicKeyHint))</p> | ||
| 226 | - </div> | ||
| 227 | <button type="submit" class="primary">(t(lang, Key::AddKeyButton))</button> | 301 | <button type="submit" class="primary">(t(lang, Key::AddKeyButton))</button> |
| 228 | - </form> | 302 | + <a class="act" href="/settings/keys">(s(lang, "Keep it", "Vazgeç"))</a> |
| 229 | - ) | 303 | + </div> |
| 304 | + </form> | ||
| 230 | </div> | 305 | </div> |
| 231 | - </section> | 306 | + } |
| 307 | + if empty { | ||
| 308 | + <p class="state">(t(lang, Key::NoSshKeys))</p> | ||
| 309 | + } | ||
| 310 | + for key in keys.into_iter() { | ||
| 311 | + <details class="row-open"> | ||
| 312 | + <summary class="line"> | ||
| 313 | + <span class="name">(key.title.clone())</span> | ||
| 314 | + <span class="val mono">(key.fingerprint.chars().take(15).collect::<String>())</span> | ||
| 315 | + <span class="val">added_status(lang: lang, added: Some(key.created_at.as_str()), used: key.last_used_at.as_deref())</span> | ||
| 316 | + </summary> | ||
| 317 | + <div class="opened"> | ||
| 318 | + <code class="hint">(key.algorithm.clone()) " " (key.fingerprint.clone())</code> | ||
| 319 | + <div class="acts"> | ||
| 320 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/keys/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) | ||
| 321 | + </div> | ||
| 322 | + </div> | ||
| 323 | + </details> | ||
| 324 | + } | ||
| 232 | }) | 325 | }) |
| 233 | } | 326 | } |
| 234 | 327 | ||
| @@ -237,8 +330,12 @@ async fn keys_page(cx: &Cx) -> Result<impl View> { | |||
| 237 | let viewer = require_user(cx).await?; | 330 | let viewer = require_user(cx).await?; |
| 238 | let lang = i18n::lang(cx, Some(&viewer.0)); | 331 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 239 | let state = app_context::<AppState>(cx); | 332 | let state = app_context::<AppState>(cx); |
| 333 | + let draft = KeysDraft { | ||
| 334 | + add: query_params::<AddQuery>(cx)?.add.is_some(), | ||
| 335 | + ..KeysDraft::default() | ||
| 336 | + }; | ||
| 240 | Ok(view! { | 337 | Ok(view! { |
| 241 | - keys_page_view(lang: lang, state: state, viewer: &viewer, draft: KeysDraft::default()) | 338 | + keys_page_view(lang: lang, state: state, viewer: &viewer, kind: KeyKind::Ssh, draft: draft) |
| 242 | }) | 339 | }) |
| 243 | } | 340 | } |
| 244 | 341 | ||
| @@ -297,7 +394,7 @@ async fn keys_add(cx: &Cx, Form(form): Form<AddKeyForm>) -> Result<impl View> { | |||
| 297 | ..KeysDraft::default() | 394 | ..KeysDraft::default() |
| 298 | }; | 395 | }; |
| 299 | Ok(view! { | 396 | Ok(view! { |
| 300 | - keys_page_view(lang: lang, state: state, viewer: &viewer, draft: draft) | 397 | + keys_page_view(lang: lang, state: state, viewer: &viewer, kind: KeyKind::Ssh, draft: draft) |
| 301 | }) | 398 | }) |
| 302 | } | 399 | } |
| 303 | 400 | ||
crates/forge-web/src/pages/settings_notifications.rsmodified+72 -69
| @@ -17,8 +17,9 @@ use topcoat::view::{View, component, view}; | |||
| 17 | use crate::auth::{require_csrf, require_user}; | 17 | use crate::auth::{require_csrf, require_user}; |
| 18 | use crate::i18n::push as push_text; | 18 | use crate::i18n::push as push_text; |
| 19 | use crate::i18n::{self, Key, Lang, t}; | 19 | use crate::i18n::{self, Key, Lang, t}; |
| 20 | +use crate::pages::passkeys::s; | ||
| 20 | use crate::state::AppState; | 21 | use crate::state::AppState; |
| 21 | -use crate::views::parts::confirm_act; | 22 | +use crate::views::parts::{SubPart, confirm_act, head}; |
| 22 | use crate::views::{csrf_field, rel_time, shell}; | 23 | use crate::views::{csrf_field, rel_time, shell}; |
| 23 | 24 | ||
| 24 | #[query_params(error = bad_request)] | 25 | #[query_params(error = bad_request)] |
| @@ -70,80 +71,82 @@ async fn notifications_body(page: NotificationsPage) -> Result<impl View> { | |||
| 70 | // locked and the notes below say why. | 71 | // locked and the notes below say why. |
| 71 | let blocked = unverified_note.is_some() || server_note.is_some(); | 72 | let blocked = unverified_note.is_some() || server_note.is_some(); |
| 72 | Ok(view! { | 73 | Ok(view! { |
| 73 | - <h1 class="sr-only">(t(lang, Key::Notifications))</h1> | 74 | + head(title: t(lang, Key::Notifications), sub: vec![SubPart::text(s(lang, "Email, and push to your devices", "E-posta ve cihazlarına bildirim"))]) |
| 74 | if let Some(message) = notice { | 75 | if let Some(message) = notice { |
| 75 | <p class="state" role="status">(message.as_str())</p> | 76 | <p class="state" role="status">(message.as_str())</p> |
| 76 | } | 77 | } |
| 77 | - <section class="sec" id="email"> | 78 | + <div class="sheet"> |
| 78 | - <h2>(crate::pages::passkeys::s(lang, "Email", "E-posta"))</h2> | 79 | + <section class="sec" id="email"> |
| 79 | - <form id="notify-form" method="post" action="/settings/notifications" class="notify-form"> | 80 | + <h2>(s(lang, "Email", "E-posta"))</h2> |
| 80 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 81 | + <form id="notify-form" method="post" action="/settings/notifications" class="notify-form"> |
| 81 | - </form> | 82 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 82 | - <label class="switch"> | 83 | + </form> |
| 83 | - <input type="checkbox" form="notify-form" name="email_notifications" value="1" checked=(on) disabled=(blocked) data-autosubmit="true"> | 84 | + <label class="switch"> |
| 84 | - <span>(t(lang, Key::EmailNotifyLabel))</span> | 85 | + <input type="checkbox" form="notify-form" name="email_notifications" value="1" checked=(on) disabled=(blocked) data-autosubmit="true"> |
| 85 | - </label> | 86 | + <span>(t(lang, Key::EmailNotifyLabel))</span> |
| 86 | - <p class="hint">(t(lang, Key::EmailNotifyHelp))</p> | 87 | + </label> |
| 87 | - if let Some(message) = server_note { | 88 | + <p class="hint">(t(lang, Key::EmailNotifyHelp))</p> |
| 88 | - <p class="hint warn" role="note">(message)</p> | 89 | + if let Some(message) = server_note { |
| 89 | - } | 90 | + <p class="hint warn" role="note">(message)</p> |
| 90 | - if let Some(message) = unverified_note { | 91 | + } |
| 91 | - <p class="hint" role="note">(message)</p> | 92 | + if let Some(message) = unverified_note { |
| 92 | - } | 93 | + <p class="hint" role="note">(message)</p> |
| 93 | - <noscript> | 94 | + } |
| 95 | + <noscript> | ||
| 96 | + <div class="acts"> | ||
| 97 | + <button type="submit" form="notify-form" class="primary" disabled=(blocked)>(t(lang, Key::Save))</button> | ||
| 98 | + </div> | ||
| 99 | + </noscript> | ||
| 100 | + </section> | ||
| 101 | + <section class="sec" id="device" data-push="true" data-live="/settings/notifications/push/events"> | ||
| 102 | + <h2>(push_text::t(lang, push_text::K::DeviceHeading))</h2> | ||
| 103 | + <p class="state" data-push-state="on" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOn))</p> | ||
| 104 | + <p class="state" data-push-state="off" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOff))</p> | ||
| 105 | + <p class="hint">(push_text::t(lang, push_text::K::DeviceHelp))</p> | ||
| 106 | + <p class="hint" role="note" data-push-state="unsupported" hidden=(true)>(push_text::t(lang, push_text::K::DeviceUnsupported))</p> | ||
| 107 | + <p class="hint" role="note" data-push-state="https" hidden=(true)>(push_text::t(lang, push_text::K::DeviceNeedsHttps))</p> | ||
| 108 | + <p class="hint" role="note" data-push-state="ios" hidden=(true)>(push_text::t(lang, push_text::K::DeviceIosHint))</p> | ||
| 109 | + <p class="hint" role="note" data-push-state="denied" hidden=(true)>(push_text::t(lang, push_text::K::DeviceDenied))</p> | ||
| 110 | + <p class="hint warn" role="alert" data-push-state="error" hidden=(true)>(push_text::t(lang, push_text::K::DeviceError))</p> | ||
| 94 | <div class="acts"> | 111 | <div class="acts"> |
| 95 | - <button type="submit" form="notify-form" class="primary" disabled=(blocked)>(t(lang, Key::Save))</button> | 112 | + <button type="button" class="act" data-push-action="enable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOn))</button> |
| 113 | + <button type="button" class="act quiet" data-push-action="disable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOff))</button> | ||
| 114 | + <form method="post" action="/settings/notifications/push/test"> | ||
| 115 | + csrf_field(token: csrf.as_str()) | ||
| 116 | + <button type="submit" class="act" data-push-test="true" disabled=(!can_test)>(push_text::t(lang, push_text::K::SendTest))</button> | ||
| 117 | + </form> | ||
| 96 | </div> | 118 | </div> |
| 97 | - </noscript> | 119 | + if !can_test { |
| 98 | - </section> | 120 | + <p class="hint">(push_text::t(lang, push_text::K::TestNoDevices))</p> |
| 99 | - <section class="sec" id="device" data-push="true" data-live="/settings/notifications/push/events"> | 121 | + } |
| 100 | - <h2>(push_text::t(lang, push_text::K::DeviceHeading))</h2> | 122 | + </section> |
| 101 | - <p class="state" data-push-state="on" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOn))</p> | 123 | + <section class="sec" id="devices"> |
| 102 | - <p class="state" data-push-state="off" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOff))</p> | 124 | + <h2>(push_text::t(lang, push_text::K::DevicesHeading))</h2> |
| 103 | - <p class="hint">(push_text::t(lang, push_text::K::DeviceHelp))</p> | 125 | + if devices.is_empty() { |
| 104 | - <p class="hint" role="note" data-push-state="unsupported" hidden=(true)>(push_text::t(lang, push_text::K::DeviceUnsupported))</p> | 126 | + <p class="state">(push_text::t(lang, push_text::K::DevicesEmpty))</p> |
| 105 | - <p class="hint" role="note" data-push-state="https" hidden=(true)>(push_text::t(lang, push_text::K::DeviceNeedsHttps))</p> | 127 | + } |
| 106 | - <p class="hint" role="note" data-push-state="ios" hidden=(true)>(push_text::t(lang, push_text::K::DeviceIosHint))</p> | 128 | + for device in devices.into_iter() { |
| 107 | - <p class="hint" role="note" data-push-state="denied" hidden=(true)>(push_text::t(lang, push_text::K::DeviceDenied))</p> | 129 | + <details class="row-open"> |
| 108 | - <p class="hint warn" role="alert" data-push-state="error" hidden=(true)>(push_text::t(lang, push_text::K::DeviceError))</p> | 130 | + <summary class="line"> |
| 109 | - <div class="acts"> | 131 | + <span class="name">(device.agent_label.as_str())</span> |
| 110 | - <button type="button" class="act" data-push-action="enable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOn))</button> | 132 | + <span class="val">(push_text::added_label(lang)) " " rel_time(lang: lang, stamp: device.created_at.as_str())</span> |
| 111 | - <button type="button" class="act quiet" data-push-action="disable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOff))</button> | 133 | + </summary> |
| 112 | - <form method="post" action="/settings/notifications/push/test" class="act-form"> | 134 | + <div class="opened"> |
| 113 | - csrf_field(token: csrf.as_str()) | 135 | + <p class="hint"> |
| 114 | - <button type="submit" class="act" data-push-test="true" disabled=(!can_test)>(push_text::t(lang, push_text::K::SendTest))</button> | 136 | + if let Some(stamp) = device.last_success_at.as_deref() { |
| 115 | - </form> | 137 | + (push_text::last_delivered_label(lang)) " " rel_time(lang: lang, stamp: stamp) |
| 116 | - </div> | 138 | + } else { |
| 117 | - if !can_test { | 139 | + (push_text::t(lang, push_text::K::NeverDelivered)) |
| 118 | - <p class="hint">(push_text::t(lang, push_text::K::TestNoDevices))</p> | 140 | + } |
| 119 | - } | 141 | + </p> |
| 120 | - </section> | 142 | + <div class="acts"> |
| 121 | - <section class="sec" id="devices"> | 143 | + confirm_act(lang: lang, label: push_text::t(lang, push_text::K::RemoveDevice), action: "/settings/notifications/push/remove", csrf: csrf.as_str(), fields: vec![("id".to_owned(), device.id.clone())]) |
| 122 | - <h2>(push_text::t(lang, push_text::K::DevicesHeading))</h2> | 144 | + </div> |
| 123 | - if devices.is_empty() { | ||
| 124 | - <p class="state">(push_text::t(lang, push_text::K::DevicesEmpty))</p> | ||
| 125 | - } | ||
| 126 | - for device in devices.into_iter() { | ||
| 127 | - <details class="row-open"> | ||
| 128 | - <summary class="line"> | ||
| 129 | - <span class="name">(device.agent_label.as_str())</span> | ||
| 130 | - <span class="val">(push_text::added_label(lang)) " " rel_time(lang: lang, stamp: device.created_at.as_str())</span> | ||
| 131 | - </summary> | ||
| 132 | - <div class="opened"> | ||
| 133 | - <p class="hint"> | ||
| 134 | - if let Some(stamp) = device.last_success_at.as_deref() { | ||
| 135 | - (push_text::last_delivered_label(lang)) " " rel_time(lang: lang, stamp: stamp) | ||
| 136 | - } else { | ||
| 137 | - (push_text::t(lang, push_text::K::NeverDelivered)) | ||
| 138 | - } | ||
| 139 | - </p> | ||
| 140 | - <div class="acts"> | ||
| 141 | - confirm_act(lang: lang, label: push_text::t(lang, push_text::K::RemoveDevice), action: "/settings/notifications/push/remove", csrf: csrf.as_str(), fields: vec![("id".to_owned(), device.id.clone())]) | ||
| 142 | </div> | 145 | </div> |
| 143 | - </div> | 146 | + </details> |
| 144 | - </details> | 147 | + } |
| 145 | - } | 148 | + </section> |
| 146 | - </section> | 149 | + </div> |
| 147 | }) | 150 | }) |
| 148 | } | 151 | } |
| 149 | 152 | ||
crates/forge-web/src/pages/settings_profile.rsmodified+5 -2
| @@ -23,8 +23,9 @@ use crate::audit::{self, Actor, Target}; | |||
| 23 | use crate::auth::{require_csrf, require_user}; | 23 | use crate::auth::{require_csrf, require_user}; |
| 24 | use crate::i18n::{self, Key, Lang, about_too_long, display_name_too_long, t}; | 24 | use crate::i18n::{self, Key, Lang, about_too_long, display_name_too_long, t}; |
| 25 | use crate::live::Topic; | 25 | use crate::live::Topic; |
| 26 | +use crate::pages::passkeys::s; | ||
| 26 | use crate::state::AppState; | 27 | use crate::state::AppState; |
| 27 | -use crate::views::parts::{confirm_act, reveal}; | 28 | +use crate::views::parts::{SubPart, confirm_act, head, reveal}; |
| 28 | use crate::views::{alert, avatar_url, shell, user_facing_message}; | 29 | use crate::views::{alert, avatar_url, shell, user_facing_message}; |
| 29 | 30 | ||
| 30 | /// Longest "about" text, in characters. | 31 | /// Longest "about" text, in characters. |
| @@ -140,10 +141,11 @@ async fn profile_body(page: ProfilePage) -> Result<impl View> { | |||
| 140 | } = page; | 141 | } = page; |
| 141 | let avatar_open = errors.avatar.is_some(); | 142 | let avatar_open = errors.avatar.is_some(); |
| 142 | Ok(view! { | 143 | Ok(view! { |
| 143 | - <h1 class="sr-only">(t(lang, Key::Profile))</h1> | 144 | + head(title: t(lang, Key::Profile), sub: vec![SubPart::text(s(lang, "What others see on your profile", "Başkalarının profilinde gördükleri"))]) |
| 144 | if let Some(message) = notice { | 145 | if let Some(message) = notice { |
| 145 | <p class="state" role="status">(message)</p> | 146 | <p class="state" role="status">(message)</p> |
| 146 | } | 147 | } |
| 148 | + <div class="sheet fit"> | ||
| 147 | <section class="sec"> | 149 | <section class="sec"> |
| 148 | <h2>(t(lang, Key::Avatar))</h2> | 150 | <h2>(t(lang, Key::Avatar))</h2> |
| 149 | <img class="avatar" src=(avatar_src.as_str()) alt=(t(lang, Key::AvatarAlt)) width="48" height="48"> | 151 | <img class="avatar" src=(avatar_src.as_str()) alt=(t(lang, Key::AvatarAlt)) width="48" height="48"> |
| @@ -216,6 +218,7 @@ async fn profile_body(page: ProfilePage) -> Result<impl View> { | |||
| 216 | </div> | 218 | </div> |
| 217 | </section> | 219 | </section> |
| 218 | </form> | 220 | </form> |
| 221 | + </div> | ||
| 219 | }) | 222 | }) |
| 220 | } | 223 | } |
| 221 | 224 | ||
crates/forge-web/src/pages/settings_security.rsmodified+90 -3
| @@ -28,7 +28,7 @@ use crate::i18n::{self, Key, Lang, password_too_long, password_too_short, t}; | |||
| 28 | use crate::pages::passkeys::{PasskeyPanel, build_panel, passkeys_panel, s}; | 28 | use crate::pages::passkeys::{PasskeyPanel, build_panel, passkeys_panel, s}; |
| 29 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| 30 | use crate::throttle::{self, LOGIN_USER_LIMIT, TWO_FACTOR_USER_LIMIT}; | 30 | use crate::throttle::{self, LOGIN_USER_LIMIT, TWO_FACTOR_USER_LIMIT}; |
| 31 | -use crate::views::parts::{post_act, reveal}; | 31 | +use crate::views::parts::{RailItem, SubPart, head, post_act, rail, reveal}; |
| 32 | use crate::views::{added_status, alert, rel_time, shell, user_facing_message}; | 32 | use crate::views::{added_status, alert, rel_time, shell, user_facing_message}; |
| 33 | 33 | ||
| 34 | /// Shortest and longest new passwords, in characters. | 34 | /// Shortest and longest new passwords, in characters. |
| @@ -44,6 +44,8 @@ const MAX_DEVICE_NAME_CHARS: usize = 40; | |||
| 44 | #[query_params(error = bad_request)] | 44 | #[query_params(error = bad_request)] |
| 45 | struct SecurityQuery { | 45 | struct SecurityQuery { |
| 46 | saved: Option<String>, | 46 | saved: Option<String>, |
| 47 | + /// The topic to show: password, email, two-factor, passkeys, sessions or danger. | ||
| 48 | + part: Option<String>, | ||
| 47 | } | 49 | } |
| 48 | 50 | ||
| 49 | #[derive(Deserialize)] | 51 | #[derive(Deserialize)] |
| @@ -130,6 +132,8 @@ struct Shown { | |||
| 130 | codes: Option<Vec<String>>, | 132 | codes: Option<Vec<String>>, |
| 131 | /// Set when a check was refused by the throttle. The response then answers 429. | 133 | /// Set when a check was refused by the throttle. The response then answers 429. |
| 132 | throttled: Option<Duration>, | 134 | throttled: Option<Duration>, |
| 135 | + /// The topic asked for in the address. | ||
| 136 | + part: Option<String>, | ||
| 133 | } | 137 | } |
| 134 | 138 | ||
| 135 | /// Which two-factor panel an error belongs to. That panel stays open with its message. | 139 | /// Which two-factor panel an error belongs to. That panel stays open with its message. |
| @@ -184,6 +188,8 @@ struct SecurityPage { | |||
| 184 | owned_repos: Vec<String>, | 188 | owned_repos: Vec<String>, |
| 185 | /// Web sessions open on the account, the count the Sessions topic shows. | 189 | /// Web sessions open on the account, the count the Sessions topic shows. |
| 186 | session_count: usize, | 190 | session_count: usize, |
| 191 | + /// The topic asked for in the address, when no error or notice picks one. | ||
| 192 | + part: Option<String>, | ||
| 187 | } | 193 | } |
| 188 | 194 | ||
| 189 | #[component] | 195 | #[component] |
| @@ -208,8 +214,10 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { | |||
| 208 | passkeys, | 214 | passkeys, |
| 209 | owned_repos, | 215 | owned_repos, |
| 210 | session_count, | 216 | session_count, |
| 217 | + part, | ||
| 211 | } = page; | 218 | } = page; |
| 212 | let two_factor_on = two_factor.is_some(); | 219 | let two_factor_on = two_factor.is_some(); |
| 220 | + let passkey_count = passkeys.items.len(); | ||
| 213 | let pending_set = pending.is_some(); | 221 | let pending_set = pending.is_some(); |
| 214 | let password_open = password_error.is_some(); | 222 | let password_open = password_error.is_some(); |
| 215 | let email_open = email_error.is_some(); | 223 | let email_open = email_error.is_some(); |
| @@ -227,11 +235,73 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { | |||
| 227 | let delete_open = delete_error.is_some(); | 235 | let delete_open = delete_error.is_some(); |
| 228 | let delete_blocked = !owned_repos.is_empty(); | 236 | let delete_blocked = !owned_repos.is_empty(); |
| 229 | let sessions_line = format!("{session_count} {}", s(lang, "active", "etkin")); | 237 | let sessions_line = format!("{session_count} {}", s(lang, "active", "etkin")); |
| 238 | + let two_factor_val = if two_factor_on { | ||
| 239 | + t(lang, Key::PillOn) | ||
| 240 | + } else { | ||
| 241 | + t(lang, Key::PillOff) | ||
| 242 | + }; | ||
| 243 | + // One topic shows at a time: the one with an error or fresh codes, else the one asked for. | ||
| 244 | + const TOPICS: [&str; 6] = ["password", "email", "two-factor", "passkeys", "sessions", "danger"]; | ||
| 245 | + let active: &'static str = if password_open { | ||
| 246 | + "password" | ||
| 247 | + } else if email_open { | ||
| 248 | + "email" | ||
| 249 | + } else if regenerate_open || disable_open || setup_error.is_some() || codes.is_some() || (pending_set && part.is_none()) { | ||
| 250 | + "two-factor" | ||
| 251 | + } else if delete_open { | ||
| 252 | + "danger" | ||
| 253 | + } else { | ||
| 254 | + part.as_deref() | ||
| 255 | + .and_then(|asked| TOPICS.into_iter().find(|topic| *topic == asked)) | ||
| 256 | + .unwrap_or("password") | ||
| 257 | + }; | ||
| 258 | + // The kinds of security, one per topic. Each shows its topic in the sheet. | ||
| 259 | + let items: Vec<RailItem> = vec![ | ||
| 260 | + RailItem { | ||
| 261 | + name: t(lang, Key::Password).to_owned(), | ||
| 262 | + val: String::new(), | ||
| 263 | + href: "?part=password".to_owned(), | ||
| 264 | + current: active == "password", | ||
| 265 | + }, | ||
| 266 | + RailItem { | ||
| 267 | + name: t(lang, Key::Email).to_owned(), | ||
| 268 | + val: String::new(), | ||
| 269 | + href: "?part=email".to_owned(), | ||
| 270 | + current: active == "email", | ||
| 271 | + }, | ||
| 272 | + RailItem { | ||
| 273 | + name: t(lang, Key::TwoFactorAuth).to_owned(), | ||
| 274 | + val: two_factor_val.to_owned(), | ||
| 275 | + href: "?part=two-factor".to_owned(), | ||
| 276 | + current: active == "two-factor", | ||
| 277 | + }, | ||
| 278 | + RailItem { | ||
| 279 | + name: s(lang, "Passkeys", "Geçiş anahtarları").to_owned(), | ||
| 280 | + val: passkey_count.to_string(), | ||
| 281 | + href: "?part=passkeys".to_owned(), | ||
| 282 | + current: active == "passkeys", | ||
| 283 | + }, | ||
| 284 | + RailItem { | ||
| 285 | + name: t(lang, Key::Sessions).to_owned(), | ||
| 286 | + val: session_count.to_string(), | ||
| 287 | + href: "?part=sessions".to_owned(), | ||
| 288 | + current: active == "sessions", | ||
| 289 | + }, | ||
| 290 | + RailItem { | ||
| 291 | + name: t(lang, Key::DangerZone).to_owned(), | ||
| 292 | + val: String::new(), | ||
| 293 | + href: "?part=danger".to_owned(), | ||
| 294 | + current: active == "danger", | ||
| 295 | + }, | ||
| 296 | + ]; | ||
| 230 | Ok(view! { | 297 | Ok(view! { |
| 231 | - <h1 class="sr-only">(t(lang, Key::Security))</h1> | 298 | + head(title: t(lang, Key::Security), sub: vec![SubPart::text(s(lang, "Sign-in, email, two-factor, passkeys and sessions", "Giriş, e-posta, iki adımlı doğrulama, geçiş anahtarları ve oturumlar"))]) |
| 232 | if let Some(message) = notice { | 299 | if let Some(message) = notice { |
| 233 | <p class="state" role="status">(message)</p> | 300 | <p class="state" role="status">(message)</p> |
| 234 | } | 301 | } |
| 302 | + <div class="work"> | ||
| 303 | + rail(label: t(lang, Key::Security), items: items) | ||
| 304 | + <div class="sheet" data-topic=(active)> | ||
| 235 | <section class="sec" id="password"> | 305 | <section class="sec" id="password"> |
| 236 | <h2>(t(lang, Key::Password))</h2> | 306 | <h2>(t(lang, Key::Password))</h2> |
| 237 | if let Some(stamp) = password_changed { | 307 | if let Some(stamp) = password_changed { |
| @@ -436,6 +506,8 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { | |||
| 436 | </div> | 506 | </div> |
| 437 | } | 507 | } |
| 438 | </section> | 508 | </section> |
| 509 | + </div> | ||
| 510 | + </div> | ||
| 439 | }) | 511 | }) |
| 440 | } | 512 | } |
| 441 | 513 | ||
| @@ -554,6 +626,7 @@ async fn build_page( | |||
| 554 | password_changed, | 626 | password_changed, |
| 555 | two_factor, | 627 | two_factor, |
| 556 | session_count: state.store.list_sessions(&viewer.0.id).await?.len(), | 628 | session_count: state.store.list_sessions(&viewer.0.id).await?.len(), |
| 629 | + part: shown.part, | ||
| 557 | }) | 630 | }) |
| 558 | } | 631 | } |
| 559 | 632 | ||
| @@ -652,9 +725,23 @@ fn check_new_password(lang: Lang, new: &str, confirm: &str) -> Option<String> { | |||
| 652 | async fn security_page(cx: &Cx) -> Result<impl View> { | 725 | async fn security_page(cx: &Cx) -> Result<impl View> { |
| 653 | let viewer = require_user(cx).await?; | 726 | let viewer = require_user(cx).await?; |
| 654 | let lang = i18n::lang(cx, Some(&viewer.0)); | 727 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 655 | - let saved = query_params::<SecurityQuery>(cx)?.saved.clone(); | 728 | + let query = query_params::<SecurityQuery>(cx)?; |
| 729 | + let saved = query.saved.clone(); | ||
| 730 | + // A notice belongs to a topic: the page opens on it. | ||
| 731 | + let part = query.part.clone().or_else(|| { | ||
| 732 | + saved.as_deref().map(|saved| { | ||
| 733 | + match saved { | ||
| 734 | + "password" => "password", | ||
| 735 | + "2fa-off" => "two-factor", | ||
| 736 | + s if s.starts_with("passkey") => "passkeys", | ||
| 737 | + _ => "email", | ||
| 738 | + } | ||
| 739 | + .to_owned() | ||
| 740 | + }) | ||
| 741 | + }); | ||
| 656 | let shown = Shown { | 742 | let shown = Shown { |
| 657 | notice: notice_for(lang, saved.as_deref()), | 743 | notice: notice_for(lang, saved.as_deref()), |
| 744 | + part, | ||
| 658 | ..Shown::default() | 745 | ..Shown::default() |
| 659 | }; | 746 | }; |
| 660 | respond(cx, viewer, shown).await | 747 | respond(cx, viewer, shown).await |
crates/forge-web/src/pages/settings_sessions.rsmodified+24 -15
| @@ -15,9 +15,9 @@ use crate::auth::{logout, require_csrf, require_user}; | |||
| 15 | use crate::i18n::{self, Key, Lang, t}; | 15 | use crate::i18n::{self, Key, Lang, t}; |
| 16 | use crate::pages::passkeys::s; | 16 | use crate::pages::passkeys::s; |
| 17 | use crate::state::AppState; | 17 | use crate::state::AppState; |
| 18 | -use crate::views::parts::confirm_act; | 18 | +use crate::views::parts::{SubPart, confirm_act, head}; |
| 19 | use crate::views::{rel_time, shell}; | 19 | use crate::views::{rel_time, shell}; |
| 20 | -use crate::web_push::agent_label; | 20 | +use crate::web_push::agent_label_in; |
| 21 | 21 | ||
| 22 | #[derive(Deserialize)] | 22 | #[derive(Deserialize)] |
| 23 | struct RevokeForm { | 23 | struct RevokeForm { |
| @@ -38,7 +38,7 @@ fn session_label(lang: Lang, session: &Session) -> String { | |||
| 38 | session | 38 | session |
| 39 | .user_agent | 39 | .user_agent |
| 40 | .as_deref() | 40 | .as_deref() |
| 41 | - .map_or_else(|| t(lang, Key::UnknownBrowser).to_owned(), agent_label) | 41 | + .map_or_else(|| t(lang, Key::UnknownBrowser).to_owned(), |agent| agent_label_in(lang, agent)) |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | #[component] | 44 | #[component] |
| @@ -50,13 +50,13 @@ async fn sessions_view( | |||
| 50 | ) -> Result<impl View> { | 50 | ) -> Result<impl View> { |
| 51 | let others = sessions.iter().filter(|s| s.id != current_id).count(); | 51 | let others = sessions.iter().filter(|s| s.id != current_id).count(); |
| 52 | Ok(view! { | 52 | Ok(view! { |
| 53 | - <h1 class="sr-only">(t(lang, Key::Sessions))</h1> | 53 | + head(title: t(lang, Key::Sessions), sub: vec![SubPart::text(s(lang, "Where you are signed in", "Oturum açık olduğun yerler"))]) |
| 54 | - if others > 0 { | 54 | + <div class="sheet fit"> |
| 55 | - <div class="acts"> | 55 | + if others > 0 { |
| 56 | - confirm_act(lang: lang, label: t(lang, Key::RevokeAllOthers), action: "/settings/sessions/revoke-others", csrf: csrf, note: Some(s(lang, "Every other browser is signed out at once. This one stays signed in.", "Diğer tüm tarayıcılarda oturum hemen kapanır. Bu tarayıcıda oturum açık kalır.").to_owned())) | 56 | + <div class="acts"> |
| 57 | - </div> | 57 | + confirm_act(lang: lang, label: t(lang, Key::RevokeAllOthers), action: "/settings/sessions/revoke-others", csrf: csrf, note: Some(s(lang, "Every other browser is signed out at once. This one stays signed in.", "Diğer tüm tarayıcılarda oturum hemen kapanır. Bu tarayıcıda oturum açık kalır.").to_owned())) |
| 58 | - } | 58 | + </div> |
| 59 | - <div> | 59 | + } |
| 60 | for session in sessions.into_iter() { | 60 | for session in sessions.into_iter() { |
| 61 | <details class="row-open"> | 61 | <details class="row-open"> |
| 62 | <summary class="line"> | 62 | <summary class="line"> |
| @@ -70,7 +70,9 @@ async fn sessions_view( | |||
| 70 | </summary> | 70 | </summary> |
| 71 | <div class="opened"> | 71 | <div class="opened"> |
| 72 | session_details(lang: lang, csrf: csrf, session: session.clone(), current: session.id == current_id) | 72 | session_details(lang: lang, csrf: csrf, session: session.clone(), current: session.id == current_id) |
| 73 | - <p class="back-act"><a class="act" href=(format!("/settings/sessions/{}", session.id))>(s(lang, "Open page", "Sayfayı aç"))</a></p> | 73 | + <div class="acts"> |
| 74 | + <a class="act" href=(format!("/settings/sessions/{}", session.id))>(s(lang, "Open page", "Sayfayı aç"))</a> | ||
| 75 | + </div> | ||
| 74 | </div> | 76 | </div> |
| 75 | </details> | 77 | </details> |
| 76 | } | 78 | } |
| @@ -128,11 +130,18 @@ async fn session_detail_view( | |||
| 128 | session: Session, | 130 | session: Session, |
| 129 | current: bool, | 131 | current: bool, |
| 130 | ) -> Result<impl View> { | 132 | ) -> Result<impl View> { |
| 133 | + let label = session_label(lang, &session); | ||
| 131 | Ok(view! { | 134 | Ok(view! { |
| 132 | - <h1 class="h1">(session_label(lang, &session))</h1> | 135 | + head(title: label.as_str()) |
| 133 | - <p class="hint">(i18n::dated_label(lang, Key::LastSeen)) " " rel_time(lang: lang, stamp: session.last_seen.as_str())</p> | 136 | + <div class="sheet fit"> |
| 134 | - session_details(lang: lang, csrf: csrf, session: session.clone(), current: current) | 137 | + <div class="sheet-tools"> |
| 135 | - <p class="back-act"><a class="act" href="/settings/sessions">(t(lang, Key::BackToSessions))</a></p> | 138 | + <a class="act" href="/settings/sessions">(t(lang, Key::BackToSessions))</a> |
| 139 | + </div> | ||
| 140 | + <section class="sec"> | ||
| 141 | + <p class="hint">(i18n::dated_label(lang, Key::LastSeen)) " " rel_time(lang: lang, stamp: session.last_seen.as_str())</p> | ||
| 142 | + session_details(lang: lang, csrf: csrf, session: session.clone(), current: current) | ||
| 143 | + </section> | ||
| 144 | + </div> | ||
| 136 | }) | 145 | }) |
| 137 | } | 146 | } |
| 138 | 147 | ||
crates/forge-web/src/pages/settings_tokens.rsmodified+74 -67
| @@ -13,7 +13,7 @@ use topcoat::context::{Cx, app_context}; | |||
| 13 | use topcoat::router::content::Form; | 13 | use topcoat::router::content::Form; |
| 14 | use topcoat::router::error::{SeeOther, see_other}; | 14 | use topcoat::router::error::{SeeOther, see_other}; |
| 15 | use topcoat::router::response::response_headers; | 15 | use topcoat::router::response::response_headers; |
| 16 | -use topcoat::router::{page, route}; | 16 | +use topcoat::router::{page, query_params, route}; |
| 17 | use topcoat::view::{View, component, view}; | 17 | use topcoat::view::{View, component, view}; |
| 18 | 18 | ||
| 19 | use crate::api::packages::PACKAGES_SCOPE; | 19 | use crate::api::packages::PACKAGES_SCOPE; |
| @@ -22,9 +22,10 @@ use crate::auth::{require_csrf, require_user}; | |||
| 22 | use crate::i18n::packages::{self as pk, K as PK}; | 22 | use crate::i18n::packages::{self as pk, K as PK}; |
| 23 | use crate::i18n::releases_ci::{self as rc, K as RC}; | 23 | use crate::i18n::releases_ci::{self as rc, K as RC}; |
| 24 | use crate::i18n::{self, Key, Lang, t, token_name_length}; | 24 | use crate::i18n::{self, Key, Lang, t, token_name_length}; |
| 25 | -use crate::pages::settings_keys::{KeysDraft, keys_page_view}; | 25 | +use crate::pages::passkeys::s; |
| 26 | +use crate::pages::settings_keys::{AddQuery, KeyKind, KeysDraft, keys_page_view}; | ||
| 26 | use crate::state::AppState; | 27 | use crate::state::AppState; |
| 27 | -use crate::views::parts::{confirm_act, reveal}; | 28 | +use crate::views::parts::confirm_act; |
| 28 | use crate::views::{alert, rel_time, rel_time_or_never}; | 29 | use crate::views::{alert, rel_time, rel_time_or_never}; |
| 29 | 30 | ||
| 30 | /// Scopes are fixed to `repo` for M1. | 31 | /// Scopes are fixed to `repo` for M1. |
| @@ -78,79 +79,85 @@ pub(crate) async fn tokens_section( | |||
| 78 | tokens: Vec<AccessToken>, | 79 | tokens: Vec<AccessToken>, |
| 79 | created: Option<String>, | 80 | created: Option<String>, |
| 80 | error: Option<String>, | 81 | error: Option<String>, |
| 82 | + add: bool, | ||
| 81 | ) -> Result<impl View> { | 83 | ) -> Result<impl View> { |
| 82 | let empty = tokens.is_empty(); | 84 | let empty = tokens.is_empty(); |
| 83 | - let open = error.is_some(); | ||
| 84 | Ok(view! { | 85 | Ok(view! { |
| 85 | - <section class="sec" id="tokens"> | 86 | + if let Some(token) = created { |
| 86 | - <h2>(t(lang, Key::AccessTokens))</h2> | 87 | + <div class="sheet-add" role="status" data-once=""> |
| 87 | - if let Some(token) = created { | 88 | + <p class="state">(t(lang, Key::YourNewToken))</p> |
| 88 | - <div class="opened" role="status" data-once=""> | 89 | + <p class="hint">(t(lang, Key::CopyNow))</p> |
| 89 | - <p class="state">(t(lang, Key::YourNewToken))</p> | 90 | + <div class="copy-box"> |
| 90 | - <p class="hint">(t(lang, Key::CopyNow))</p> | 91 | + <pre class="code"><code id="new-token">(token)</code></pre> |
| 91 | - <div class="copy-box"> | 92 | + <button type="button" class="small" data-copy="new-token" data-copied=(rc::t(lang, RC::CopyDone)) data-failed=(rc::t(lang, RC::CopyFailed))>(pk::t(lang, PK::CopyCommand))</button> |
| 92 | - <pre class="code"><code id="new-token">(token)</code></pre> | ||
| 93 | - <button type="button" data-copy="new-token" data-copied=(rc::t(lang, RC::CopyDone)) data-failed=(rc::t(lang, RC::CopyFailed))>(pk::t(lang, PK::CopyCommand))</button> | ||
| 94 | - </div> | ||
| 95 | - <p class="hint">(t(lang, Key::UseAsPassword))</p> | ||
| 96 | </div> | 93 | </div> |
| 97 | - } | 94 | + <p class="hint">(t(lang, Key::UseAsPassword))</p> |
| 98 | - if empty { | ||
| 99 | - <p class="state">(t(lang, Key::NoAccessTokens))</p> | ||
| 100 | - } | ||
| 101 | - <div> | ||
| 102 | - for token in tokens.into_iter() { | ||
| 103 | - <details class="row-open"> | ||
| 104 | - <summary class="line"> | ||
| 105 | - <span class="name">(token.name.clone())</span> | ||
| 106 | - <span class="val">(i18n::dated_label(lang, Key::LastUsed)) " " rel_time_or_never(lang: lang, stamp: token.last_used_at.as_deref()) ", " (i18n::dated_label(lang, Key::ExpiresLabel)) " " rel_time_or_never(lang: lang, stamp: token.expires_at.as_deref())</span> | ||
| 107 | - </summary> | ||
| 108 | - <div class="opened"> | ||
| 109 | - <p class="hint">(i18n::dated_label(lang, Key::Created)) " " rel_time(lang: lang, stamp: token.created_at.as_str())</p> | ||
| 110 | - <div class="acts"> | ||
| 111 | - confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/tokens/delete", csrf: csrf, fields: vec![("id".to_owned(), token.id.clone())], note: Some(delete_message(lang).to_owned())) | ||
| 112 | - </div> | ||
| 113 | - </div> | ||
| 114 | - </details> | ||
| 115 | - } | ||
| 116 | </div> | 95 | </div> |
| 117 | - <div class="acts"> | 96 | + } |
| 118 | - reveal(label: t(lang, Key::NewToken), id: Some("add-token"), open: open, | 97 | + if add { |
| 119 | - if let Some(message) = error { | 98 | + <div class="sheet-add" id="add-token"> |
| 120 | - alert(message: message.as_str()) | 99 | + if let Some(message) = error { |
| 121 | - } | 100 | + alert(message: message.as_str()) |
| 122 | - <form method="post" action="/settings/tokens" class="fields"> | 101 | + } |
| 123 | - <input type="hidden" name="csrf" value=(csrf)> | 102 | + <form method="post" action="/settings/tokens" class="fields"> |
| 124 | - <div class="field"> | 103 | + <input type="hidden" name="csrf" value=(csrf)> |
| 125 | - <label for="token-name">(t(lang, Key::Name))</label> | 104 | + <div class="field"> |
| 126 | - <input id="token-name" type="text" name="name" maxlength="64" required=(true) autocomplete="off"> | 105 | + <label for="token-name">(t(lang, Key::Name))</label> |
| 127 | - </div> | 106 | + <input id="token-name" type="text" name="name" maxlength="64" required=(true) autocomplete="off"> |
| 128 | - <div class="field"> | 107 | + </div> |
| 129 | - <label for="token-expires">(t(lang, Key::Expires))</label> | 108 | + <div class="field"> |
| 130 | - <select id="token-expires" name="expires"> | 109 | + <label for="token-expires">(t(lang, Key::Expires))</label> |
| 131 | - <option value="30">(t(lang, Key::ExpiresIn30))</option> | 110 | + <select id="token-expires" name="expires"> |
| 132 | - <option value="90" selected=(true)>(t(lang, Key::ExpiresIn90))</option> | 111 | + <option value="30">(t(lang, Key::ExpiresIn30))</option> |
| 133 | - <option value="365">(t(lang, Key::ExpiresIn365))</option> | 112 | + <option value="90" selected=(true)>(t(lang, Key::ExpiresIn90))</option> |
| 134 | - <option value="never">(t(lang, Key::ExpiresNever))</option> | 113 | + <option value="365">(t(lang, Key::ExpiresIn365))</option> |
| 135 | - </select> | 114 | + <option value="never">(t(lang, Key::ExpiresNever))</option> |
| 136 | - </div> | 115 | + </select> |
| 137 | - <label class="switch"> | 116 | + </div> |
| 138 | - <input type="checkbox" name="packages" value="on"> | 117 | + <label class="switch"> |
| 139 | - <span>(pk::t(lang, PK::ScopePackages))</span> | 118 | + <input type="checkbox" name="packages" value="on"> |
| 140 | - </label> | 119 | + <span>(pk::t(lang, PK::ScopePackages))</span> |
| 141 | - <p class="hint">(pk::t(lang, PK::ScopePackagesHelp)) " " (t(lang, Key::ScopeNote))</p> | 120 | + </label> |
| 121 | + <p class="hint">(pk::t(lang, PK::ScopePackagesHelp)) " " (t(lang, Key::ScopeNote))</p> | ||
| 122 | + <div class="acts asks"> | ||
| 142 | <button type="submit" class="primary">(t(lang, Key::CreateToken))</button> | 123 | <button type="submit" class="primary">(t(lang, Key::CreateToken))</button> |
| 143 | - </form> | 124 | + <a class="act" href="/settings/tokens">(s(lang, "Keep it", "Vazgeç"))</a> |
| 144 | - ) | 125 | + </div> |
| 126 | + </form> | ||
| 145 | </div> | 127 | </div> |
| 146 | - </section> | 128 | + } |
| 129 | + if empty { | ||
| 130 | + <p class="state">(t(lang, Key::NoAccessTokens))</p> | ||
| 131 | + } | ||
| 132 | + for token in tokens.into_iter() { | ||
| 133 | + <details class="row-open"> | ||
| 134 | + <summary class="line"> | ||
| 135 | + <span class="name">(token.name.clone())</span> | ||
| 136 | + <span class="val">(i18n::dated_label(lang, Key::LastUsed)) " " rel_time_or_never(lang: lang, stamp: token.last_used_at.as_deref()) ", " (i18n::dated_label(lang, Key::ExpiresLabel)) " " rel_time_or_never(lang: lang, stamp: token.expires_at.as_deref())</span> | ||
| 137 | + </summary> | ||
| 138 | + <div class="opened"> | ||
| 139 | + <p class="hint">(i18n::dated_label(lang, Key::Created)) " " rel_time(lang: lang, stamp: token.created_at.as_str())</p> | ||
| 140 | + <div class="acts"> | ||
| 141 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/tokens/delete", csrf: csrf, fields: vec![("id".to_owned(), token.id.clone())], note: Some(delete_message(lang).to_owned())) | ||
| 142 | + </div> | ||
| 143 | + </div> | ||
| 144 | + </details> | ||
| 145 | + } | ||
| 147 | }) | 146 | }) |
| 148 | } | 147 | } |
| 149 | 148 | ||
| 150 | -#[route(GET "/settings/tokens")] | 149 | +#[page("/settings/tokens")] |
| 151 | -async fn tokens_page(cx: &Cx) -> Result<SeeOther> { | 150 | +async fn tokens_page(cx: &Cx) -> Result<impl View> { |
| 152 | - require_user(cx).await?; | 151 | + let viewer = require_user(cx).await?; |
| 153 | - Ok(see_other("/settings/keys#tokens")) | 152 | + let lang = i18n::lang(cx, Some(&viewer.0)); |
| 153 | + let state = app_context::<AppState>(cx); | ||
| 154 | + let draft = KeysDraft { | ||
| 155 | + add: query_params::<AddQuery>(cx)?.add.is_some(), | ||
| 156 | + ..KeysDraft::default() | ||
| 157 | + }; | ||
| 158 | + Ok(view! { | ||
| 159 | + keys_page_view(lang: lang, state: state, viewer: &viewer, kind: KeyKind::Tokens, draft: draft) | ||
| 160 | + }) | ||
| 154 | } | 161 | } |
| 155 | 162 | ||
| 156 | #[page(POST "/settings/tokens")] | 163 | #[page(POST "/settings/tokens")] |
| @@ -214,7 +221,7 @@ async fn tokens_create(cx: &Cx, Form(form): Form<CreateTokenForm>) -> Result<imp | |||
| 214 | ..KeysDraft::default() | 221 | ..KeysDraft::default() |
| 215 | }; | 222 | }; |
| 216 | Ok(view! { | 223 | Ok(view! { |
| 217 | - keys_page_view(lang: lang, state: state, viewer: &viewer, draft: draft) | 224 | + keys_page_view(lang: lang, state: state, viewer: &viewer, kind: KeyKind::Tokens, draft: draft) |
| 218 | }) | 225 | }) |
| 219 | } | 226 | } |
| 220 | 227 | ||
crates/forge-web/src/pages/setup.rsmodified+4 -4
| @@ -14,6 +14,7 @@ use crate::audit::{self, Actor, Target}; | |||
| 14 | use crate::auth::{check_pre_csrf, clear_pre_csrf, hash_password_async, login, pre_csrf_token}; | 14 | use crate::auth::{check_pre_csrf, clear_pre_csrf, hash_password_async, login, pre_csrf_token}; |
| 15 | use crate::i18n::{self, Key, Lang, password_too_long, password_too_short, t}; | 15 | use crate::i18n::{self, Key, Lang, password_too_long, password_too_short, t}; |
| 16 | use crate::state::AppState; | 16 | use crate::state::AppState; |
| 17 | +use crate::views::parts::{SubPart, head}; | ||
| 17 | use crate::views::{alert, shell, user_facing_message}; | 18 | use crate::views::{alert, shell, user_facing_message}; |
| 18 | 19 | ||
| 19 | const MIN_PASSWORD_CHARS: usize = 12; | 20 | const MIN_PASSWORD_CHARS: usize = 12; |
| @@ -42,9 +43,8 @@ async fn setup_form( | |||
| 42 | error: Option<String>, | 43 | error: Option<String>, |
| 43 | ) -> Result<impl View> { | 44 | ) -> Result<impl View> { |
| 44 | Ok(view! { | 45 | Ok(view! { |
| 45 | - <section> | 46 | + head(title: t(lang, Key::WelcomeToForge), sub: vec![SubPart::text(t(lang, Key::SetupSub))]) |
| 46 | - <h1>(t(lang, Key::WelcomeToForge))</h1> | 47 | + <div class="sheet fit"> |
| 47 | - <p class="hint">(t(lang, Key::SetupSub))</p> | ||
| 48 | <form data-hard="true" method="post" action="/setup" class="fields"> | 48 | <form data-hard="true" method="post" action="/setup" class="fields"> |
| 49 | if let Some(message) = error { | 49 | if let Some(message) = error { |
| 50 | alert(message: message.as_str()) | 50 | alert(message: message.as_str()) |
| @@ -69,7 +69,7 @@ async fn setup_form( | |||
| 69 | </div> | 69 | </div> |
| 70 | <button type="submit" class="primary">(t(lang, Key::CreateAdmin))</button> | 70 | <button type="submit" class="primary">(t(lang, Key::CreateAdmin))</button> |
| 71 | </form> | 71 | </form> |
| 72 | - </section> | 72 | + </div> |
| 73 | }) | 73 | }) |
| 74 | } | 74 | } |
| 75 | 75 | ||
crates/forge-web/src/pages/snippets.rsmodified+65 -67
| @@ -27,7 +27,7 @@ use crate::pages::snippets_live::{bump_snippet, item_live_url, list_live_url}; | |||
| 27 | use crate::render::highlight::highlight_lines; | 27 | use crate::render::highlight::highlight_lines; |
| 28 | use crate::render::markdown::render_markdown; | 28 | use crate::render::markdown::render_markdown; |
| 29 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| 30 | -use crate::views::parts::confirm_act; | 30 | +use crate::views::parts::{SubPart, confirm_act, head}; |
| 31 | use crate::views::{alert, empty_state, rel_time, shell, user_facing_message}; | 31 | use crate::views::{alert, empty_state, rel_time, shell, user_facing_message}; |
| 32 | 32 | ||
| 33 | path_param!(id); | 33 | path_param!(id); |
| @@ -296,13 +296,12 @@ async fn snippet_list_body( | |||
| 296 | live: Option<String>, | 296 | live: Option<String>, |
| 297 | ) -> Result<impl View> { | 297 | ) -> Result<impl View> { |
| 298 | Ok(view! { | 298 | Ok(view! { |
| 299 | - <div data-live=(live.as_deref())> | 299 | + head(title: g::t(lang, K::Snippets), |
| 300 | - <h1 class="sr-only">(g::t(lang, K::Snippets))</h1> | ||
| 301 | if signed_in { | 300 | if signed_in { |
| 302 | - <div class="acts"> | 301 | + <a class="button primary" href="/snippets/new">(g::t(lang, K::NewSnippet))</a> |
| 303 | - <a class="act" href="/snippets/new">(g::t(lang, K::NewSnippet))</a> | ||
| 304 | - </div> | ||
| 305 | } | 302 | } |
| 303 | + ) | ||
| 304 | + <div class="sheet" data-live=(live.as_deref())> | ||
| 306 | if rows.is_empty() { | 305 | if rows.is_empty() { |
| 307 | empty_state(title: g::t(lang, K::NoSnippets)) | 306 | empty_state(title: g::t(lang, K::NoSnippets)) |
| 308 | } else { | 307 | } else { |
| @@ -392,7 +391,6 @@ async fn snippet_form( | |||
| 392 | lang: Lang, | 391 | lang: Lang, |
| 393 | csrf: &str, | 392 | csrf: &str, |
| 394 | action: &str, | 393 | action: &str, |
| 395 | - heading: &str, | ||
| 396 | title: &str, | 394 | title: &str, |
| 397 | description: &str, | 395 | description: &str, |
| 398 | visibility: &str, | 396 | visibility: &str, |
| @@ -415,7 +413,6 @@ async fn snippet_form( | |||
| 415 | if let Some(message) = error { | 413 | if let Some(message) = error { |
| 416 | alert(message: message.as_str()) | 414 | alert(message: message.as_str()) |
| 417 | } | 415 | } |
| 418 | - <h1 class="sr-only">(heading)</h1> | ||
| 419 | <form method="post" action=(action) class="fields snippet-form"> | 416 | <form method="post" action=(action) class="fields snippet-form"> |
| 420 | <input type="hidden" name="csrf" value=(csrf)> | 417 | <input type="hidden" name="csrf" value=(csrf)> |
| 421 | <div class="field"> | 418 | <div class="field"> |
| @@ -429,19 +426,21 @@ async fn snippet_form( | |||
| 429 | placeholder=(g::t(lang, K::DescriptionOptional))> | 426 | placeholder=(g::t(lang, K::DescriptionOptional))> |
| 430 | </div> | 427 | </div> |
| 431 | <div class="field" role="radiogroup" aria-labelledby="snippet-visibility"> | 428 | <div class="field" role="radiogroup" aria-labelledby="snippet-visibility"> |
| 432 | - <p class="state" id="snippet-visibility">(g::t(lang, K::Visibility))</p> | 429 | + <label id="snippet-visibility">(g::t(lang, K::Visibility))</label> |
| 433 | - <label class="switch" title=(g::t(lang, K::PublicOption))> | 430 | + <div class="choice"> |
| 434 | - <input type="radio" name="visibility" value="public" checked=(public)> | 431 | + <label title=(g::t(lang, K::PublicOption))> |
| 435 | - <span>(g::t(lang, K::VisibilityPublic))</span> | 432 | + <input type="radio" name="visibility" value="public" checked=(public)> |
| 436 | - </label> | 433 | + <span>(g::t(lang, K::VisibilityPublic))</span> |
| 437 | - <label class="switch" title=(g::t(lang, K::UnlistedOption))> | 434 | + </label> |
| 438 | - <input type="radio" name="visibility" value="unlisted" checked=(unlisted)> | 435 | + <label title=(g::t(lang, K::UnlistedOption))> |
| 439 | - <span>(g::t(lang, K::VisibilityUnlisted))</span> | 436 | + <input type="radio" name="visibility" value="unlisted" checked=(unlisted)> |
| 440 | - </label> | 437 | + <span>(g::t(lang, K::VisibilityUnlisted))</span> |
| 441 | - <label class="switch" title=(g::t(lang, K::PrivateOption))> | 438 | + </label> |
| 442 | - <input type="radio" name="visibility" value="private" checked=(private)> | 439 | + <label title=(g::t(lang, K::PrivateOption))> |
| 443 | - <span>(g::t(lang, K::VisibilityPrivate))</span> | 440 | + <input type="radio" name="visibility" value="private" checked=(private)> |
| 444 | - </label> | 441 | + <span>(g::t(lang, K::VisibilityPrivate))</span> |
| 442 | + </label> | ||
| 443 | + </div> | ||
| 445 | </div> | 444 | </div> |
| 446 | <button type="submit" class="primary">(g::t(lang, K::SaveSnippet))</button> | 445 | <button type="submit" class="primary">(g::t(lang, K::SaveSnippet))</button> |
| 447 | snippet_files(lang: lang, slots: slots, active: active, removable: removable, can_add: can_add, | 446 | snippet_files(lang: lang, slots: slots, active: active, removable: removable, can_add: can_add, |
| @@ -468,40 +467,39 @@ async fn snippet_body( | |||
| 468 | let history_href = format!("/snippets/{snippet_id}/revisions"); | 467 | let history_href = format!("/snippets/{snippet_id}/revisions"); |
| 469 | let delete_action = format!("/snippets/{snippet_id}/delete"); | 468 | let delete_action = format!("/snippets/{snippet_id}/delete"); |
| 470 | Ok(view! { | 469 | Ok(view! { |
| 471 | - <div data-live=(live.as_deref())> | 470 | + head(title: title, sub: vec![SubPart::text(owner), SubPart::text(visibility)], |
| 472 | - <h1 class="h1">(title)</h1> | 471 | + <a class="button" href=(history_href)>(g::t(lang, K::Revisions))</a> |
| 473 | - <p class="hint">(owner) " · " (visibility) " · " (g::updated_before(lang)) rel_time(lang: lang, stamp: updated_at) (g::updated_after(lang))</p> | 472 | + if let Some(token) = owner_csrf { |
| 474 | - </div> | 473 | + <a class="button" href=(edit_href)>(g::t(lang, K::Edit))</a> |
| 475 | - if !description.is_empty() { | ||
| 476 | - <p class="state">(description)</p> | ||
| 477 | - } | ||
| 478 | - <nav class="sub" aria-label=(g::t(lang, K::SnippetNav))> | ||
| 479 | - <a href=(history_href)>(g::t(lang, K::Revisions))</a> | ||
| 480 | - </nav> | ||
| 481 | - if let Some(token) = owner_csrf { | ||
| 482 | - <div class="acts"> | ||
| 483 | - <a class="act" href=(edit_href)>(g::t(lang, K::Edit))</a> | ||
| 484 | confirm_act(lang: lang, label: g::t(lang, K::Delete), action: delete_action.as_str(), csrf: token.as_str()) | 474 | confirm_act(lang: lang, label: g::t(lang, K::Delete), action: delete_action.as_str(), csrf: token.as_str()) |
| 485 | - </div> | 475 | + } |
| 486 | - } | 476 | + ) |
| 487 | - for file in files.into_iter() { | 477 | + <div class="sheet" data-live=(live.as_deref())> |
| 488 | - <section class="sec snippet-file"> | 478 | + <section class="sec"> |
| 489 | - <h2>(file.name.clone())</h2> | 479 | + if !description.is_empty() { |
| 490 | - <nav class="sub" aria-label=(g::t(lang, K::FileNav))> | 480 | + <p>(description)</p> |
| 491 | - <a href=(file.raw.clone())>(g::t(lang, K::Raw))</a> | 481 | + } |
| 492 | - </nav> | 482 | + <p class="hint">(g::updated_before(lang)) rel_time(lang: lang, stamp: updated_at) (g::updated_after(lang))</p> |
| 493 | - if file.markdown { | 483 | + if !is_owner { |
| 494 | - <div class="markdown-body">(Unescaped::new_unchecked(file.body.clone()))</div> | 484 | + <p class="hint">(g::t(lang, K::OnlyOwnerEdits))</p> |
| 495 | - } else if file.highlighted { | ||
| 496 | - <pre class="code snippet-code"><code>(Unescaped::new_unchecked(file.body.clone()))</code></pre> | ||
| 497 | - } else { | ||
| 498 | - <pre class="code snippet-code"><code>(file.body.clone())</code></pre> | ||
| 499 | } | 485 | } |
| 500 | </section> | 486 | </section> |
| 501 | - } | 487 | + for file in files.into_iter() { |
| 502 | - if !is_owner { | 488 | + <section class="sec snippet-file"> |
| 503 | - <p class="hint">(g::t(lang, K::OnlyOwnerEdits))</p> | 489 | + <div class="sheet-tools"> |
| 504 | - } | 490 | + <strong>(file.name.clone())</strong> |
| 491 | + <a class="act" href=(file.raw.clone())>(g::t(lang, K::Raw))</a> | ||
| 492 | + </div> | ||
| 493 | + if file.markdown { | ||
| 494 | + <div class="markdown-body">(Unescaped::new_unchecked(file.body.clone()))</div> | ||
| 495 | + } else if file.highlighted { | ||
| 496 | + <pre class="code snippet-code"><code>(Unescaped::new_unchecked(file.body.clone()))</code></pre> | ||
| 497 | + } else { | ||
| 498 | + <pre class="code snippet-code"><code>(file.body.clone())</code></pre> | ||
| 499 | + } | ||
| 500 | + </section> | ||
| 501 | + } | ||
| 502 | + </div> | ||
| 505 | }) | 503 | }) |
| 506 | } | 504 | } |
| 507 | 505 | ||
| @@ -516,24 +514,21 @@ async fn revisions_body( | |||
| 516 | let back = format!("/snippets/{snippet_id}"); | 514 | let back = format!("/snippets/{snippet_id}"); |
| 517 | let heading = g::revisions_of(lang, title); | 515 | let heading = g::revisions_of(lang, title); |
| 518 | Ok(view! { | 516 | Ok(view! { |
| 519 | - <div data-live=(live.as_deref())> | 517 | + head(title: heading.as_str(), |
| 520 | - <h1 class="h1">(heading.as_str())</h1> | 518 | + <a class="button" href=(back)>(g::t(lang, K::BackToSnippet))</a> |
| 521 | - <nav class="sub"> | 519 | + ) |
| 522 | - <a href=(back)>(g::t(lang, K::BackToSnippet))</a> | 520 | + <div class="sheet" data-live=(live.as_deref())> |
| 523 | - </nav> | 521 | + if revisions.is_empty() { |
| 524 | - </div> | 522 | + <p class="state">(g::t(lang, K::NoRevisions))</p> |
| 525 | - if revisions.is_empty() { | 523 | + } else { |
| 526 | - <p class="state">(g::t(lang, K::NoRevisions))</p> | ||
| 527 | - } else { | ||
| 528 | - <div> | ||
| 529 | for rev in revisions.into_iter() { | 524 | for rev in revisions.into_iter() { |
| 530 | <div class="line" data-kb-row=""> | 525 | <div class="line" data-kb-row=""> |
| 531 | <span class="name">(g::t(lang, K::RevisionLabel))(rev.number)</span> | 526 | <span class="name">(g::t(lang, K::RevisionLabel))(rev.number)</span> |
| 532 | <span class="val">(rev.author) " · " rel_time(lang: lang, stamp: rev.at.as_str()) " · " (rev.file_names)</span> | 527 | <span class="val">(rev.author) " · " rel_time(lang: lang, stamp: rev.at.as_str()) " · " (rev.file_names)</span> |
| 533 | </div> | 528 | </div> |
| 534 | } | 529 | } |
| 535 | - </div> | 530 | + } |
| 536 | - } | 531 | + </div> |
| 537 | }) | 532 | }) |
| 538 | } | 533 | } |
| 539 | 534 | ||
| @@ -554,9 +549,12 @@ async fn snippet_form_page( | |||
| 554 | let visibility = draft.visibility.clone(); | 549 | let visibility = draft.visibility.clone(); |
| 555 | Ok(view! { | 550 | Ok(view! { |
| 556 | shell(title: heading, viewer: Some(viewer), | 551 | shell(title: heading, viewer: Some(viewer), |
| 557 | - snippet_form(lang: lang, csrf: csrf.as_str(), action: action, heading: heading, | 552 | + head(title: heading) |
| 558 | - title: title.as_str(), description: description.as_str(), | 553 | + <div class="sheet"> |
| 559 | - visibility: visibility.as_str(), slots: slots, active: active, error: error) | 554 | + snippet_form(lang: lang, csrf: csrf.as_str(), action: action, |
| 555 | + title: title.as_str(), description: description.as_str(), | ||
| 556 | + visibility: visibility.as_str(), slots: slots, active: active, error: error) | ||
| 557 | + </div> | ||
| 560 | ) | 558 | ) |
| 561 | }) | 559 | }) |
| 562 | } | 560 | } |
crates/forge-web/src/pages/tree.rsmodified+89 -111
| @@ -22,18 +22,18 @@ use crate::pages::code_live::{follows_branch, live_url}; | |||
| 22 | use crate::pages::finder::file_finder; | 22 | use crate::pages::finder::file_finder; |
| 23 | use crate::pages::passkeys::s; | 23 | use crate::pages::passkeys::s; |
| 24 | use crate::pages::refs::{load_refs, ref_links}; | 24 | use crate::pages::refs::{load_refs, ref_links}; |
| 25 | -use crate::pages::repo::{https_clone_url, readme_head, repo_head, ssh_clone_url}; | 25 | +use crate::pages::repo::repo_head; |
| 26 | use crate::pages::repo_ctx::load_repo; | 26 | use crate::pages::repo_ctx::load_repo; |
| 27 | use crate::pages::repo_side::{ | 27 | use crate::pages::repo_side::{ |
| 28 | - commit_strip, repo_dock, run_rows, run_states, strip_bars, tree_facts, | 28 | + code_sub, commit_strip, run_pips, run_rows, tree_facts, |
| 29 | }; | 29 | }; |
| 30 | use crate::raw::raw_url; | 30 | use crate::raw::raw_url; |
| 31 | use crate::render::emoji::emojify; | 31 | use crate::render::emoji::emojify; |
| 32 | use crate::render::markdown::{LinkContext, render_markdown}; | 32 | use crate::render::markdown::{LinkContext, render_markdown}; |
| 33 | use crate::state::AppState; | 33 | use crate::state::AppState; |
| 34 | use crate::views::{ | 34 | use crate::views::{ |
| 35 | - Crumb, avatar_url, display_name, empty_state, iso_time, now_unix, ref_selector, relative_time, | 35 | + display_name, empty_state, iso_time, now_unix, ref_selector, relative_time, repo_href, shell, |
| 36 | - repo_href, shell, short_oid, user_href, | 36 | + short_oid, |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | /// Files at the root of a directory that count as its README, in priority order. | 39 | /// Files at the root of a directory that count as its README, in priority order. |
| @@ -125,12 +125,6 @@ pub struct LatestBar { | |||
| 125 | pub last: LastCommit, | 125 | pub last: LastCommit, |
| 126 | pub short: String, | 126 | pub short: String, |
| 127 | pub author: String, | 127 | pub author: String, |
| 128 | - /// Profile link, only when the author maps to a forge user. | ||
| 129 | - pub author_href: Option<String>, | ||
| 130 | - /// Avatar of that user. None for plain-text authors. | ||
| 131 | - pub avatar: Option<String>, | ||
| 132 | - /// The full commit message, body included, emoji rendered. | ||
| 133 | - pub message: String, | ||
| 134 | } | 128 | } |
| 135 | 129 | ||
| 136 | /// Latest commit bar for `dir` at `commit` (`""` is the root). Errors and timeouts leave the bar | 130 | /// Latest commit bar for `dir` at `commit` (`""` is the root). Errors and timeouts leave the bar |
| @@ -163,21 +157,14 @@ pub async fn latest_bar( | |||
| 163 | }; | 157 | }; |
| 164 | 158 | ||
| 165 | let user = author_account(state, repo, &info.author_email).await; | 159 | let user = author_account(state, repo, &info.author_email).await; |
| 166 | - let (author, author_href, avatar) = match user { | 160 | + let author = match user { |
| 167 | - Some(user) => ( | 161 | + Some(user) => display_name(lang, &user.username), |
| 168 | - display_name(lang, &user.username), | 162 | + None => info.author_name.clone(), |
| 169 | - Some(user_href(&user.username)), | ||
| 170 | - Some(avatar_url(&user.username, user.avatar_hash.as_deref())), | ||
| 171 | - ), | ||
| 172 | - None => (info.author_name.clone(), None, None), | ||
| 173 | }; | 163 | }; |
| 174 | Some(LatestBar { | 164 | Some(LatestBar { |
| 175 | last: last_commit_view(lang, repo, &info, now_unix(), tz), | 165 | last: last_commit_view(lang, repo, &info, now_unix(), tz), |
| 176 | short: short_oid(&info.oid).to_owned(), | 166 | short: short_oid(&info.oid).to_owned(), |
| 177 | author, | 167 | author, |
| 178 | - author_href, | ||
| 179 | - avatar, | ||
| 180 | - message: emojify(&info.message).into_owned(), | ||
| 181 | }) | 168 | }) |
| 182 | } | 169 | } |
| 183 | 170 | ||
| @@ -289,28 +276,6 @@ fn blob_href(repo: &RepoRow, ref_name: &str, rel: &str) -> Option<String> { | |||
| 289 | )) | 276 | )) |
| 290 | } | 277 | } |
| 291 | 278 | ||
| 292 | -/// Breadcrumb for `path` under `kind` ("tree" or "blob"). Every segment links. | ||
| 293 | -pub fn path_crumbs(repo: &RepoRow, ref_name: &str, kind: &str, path: &str) -> Vec<Crumb> { | ||
| 294 | - let mut out = vec![Crumb { | ||
| 295 | - label: repo.name.clone(), | ||
| 296 | - href: Some(repo_href(&repo.owner_name, &repo.name, "", "")), | ||
| 297 | - }]; | ||
| 298 | - let mut prefix = String::new(); | ||
| 299 | - for seg in path.split('/').filter(|s| !s.is_empty()) { | ||
| 300 | - prefix = child_path(&prefix, seg); | ||
| 301 | - out.push(Crumb { | ||
| 302 | - label: seg.to_owned(), | ||
| 303 | - href: Some(repo_href( | ||
| 304 | - &repo.owner_name, | ||
| 305 | - &repo.name, | ||
| 306 | - kind, | ||
| 307 | - &format!("{ref_name}/{prefix}"), | ||
| 308 | - )), | ||
| 309 | - }); | ||
| 310 | - } | ||
| 311 | - out | ||
| 312 | -} | ||
| 313 | - | ||
| 314 | /// Link context for markdown in the directory `dir`: relative links resolve against `dir`. | 279 | /// Link context for markdown in the directory `dir`: relative links resolve against `dir`. |
| 315 | pub fn link_context(state: &AppState, repo: &RepoRow, ref_name: &str, dir: &str) -> LinkContext { | 280 | pub fn link_context(state: &AppState, repo: &RepoRow, ref_name: &str, dir: &str) -> LinkContext { |
| 316 | let at = |section: &str| { | 281 | let at = |section: &str| { |
| @@ -382,32 +347,80 @@ pub async fn load_readme( | |||
| 382 | } | 347 | } |
| 383 | } | 348 | } |
| 384 | 349 | ||
| 385 | -/// One row of a listing: a stretched link to the entry (the whole row is the target), its icon, | 350 | +/// A folder's rows in the rail: its name, then its age. `current` marks the file the sheet shows. |
| 386 | -/// its name and its age right after the name. Submodules have no page, so their row shows the short sha. | 351 | +/// Submodules have no page, so their row shows the short sha. A long folder scrolls here alone. |
| 387 | #[component] | 352 | #[component] |
| 388 | -pub async fn tree_table(rows: Vec<EntryRow>, lang: Lang) -> Result<impl View> { | 353 | +pub async fn tree_table( |
| 354 | + rows: Vec<EntryRow>, | ||
| 355 | + lang: Lang, | ||
| 356 | + #[default] current: Option<String>, | ||
| 357 | +) -> Result<impl View> { | ||
| 389 | Ok(view! { | 358 | Ok(view! { |
| 390 | - <div class="tree-list"> | 359 | + <div class="rail-list tree-list"> |
| 391 | for row in rows.into_iter() { | 360 | for row in rows.into_iter() { |
| 392 | - <div class="line tree-entry" data-kb-row=""> | 361 | + if let Some(href) = row.href { |
| 393 | - <span class="tree-kind"> | 362 | + <a class="rail-item tree-entry" href=(href) data-kb-row="" aria-current=((current.as_deref() == Some(row.name.as_str())).then_some("page"))> |
| 394 | - if row.kind == "dir" { | 363 | + <span class="sr-only">(g::kind_label(lang, row.kind))</span> |
| 395 | - <svg class="kind-icon is-dir" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg> | 364 | + <span class="nm dir">(row.name)if row.kind == "dir" { "/" }</span> |
| 396 | - } else { | 365 | + if let Some(last) = row.last { |
| 397 | - <svg class="kind-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/></svg> | 366 | + <time class="val" data-rel="true" datetime=(last.iso) title=(last.absolute)>(last.age)</time> |
| 398 | } | 367 | } |
| 368 | + </a> | ||
| 369 | + } else { | ||
| 370 | + <div class="rail-item tree-entry" data-kb-row=""> | ||
| 399 | <span class="sr-only">(g::kind_label(lang, row.kind))</span> | 371 | <span class="sr-only">(g::kind_label(lang, row.kind))</span> |
| 400 | - </span> | 372 | + <span class="nm dir">(row.name)</span> |
| 401 | - if let Some(href) = row.href { | 373 | + <span class="val">(row.short)</span> |
| 402 | - <a class="tree-entry-name" href=(href)>(row.name)</a> | 374 | + </div> |
| 403 | - } else { | 375 | + } |
| 404 | - <span class="tree-entry-name">(row.name)</span> | 376 | + } |
| 405 | - <span class="tree-entry-sha mono">(row.short)</span> | 377 | + </div> |
| 406 | - } | 378 | + }) |
| 407 | - if let Some(last) = row.last { | 379 | +} |
| 408 | - <time class="tree-entry-age" data-rel="true" datetime=(last.iso) title=(last.absolute)>(last.age)</time> | 380 | + |
| 409 | - } | 381 | +/// The sheet beside a folder: its README, with Source, History and Raw as tools, or `none`. |
| 410 | - </div> | 382 | +#[component] |
| 383 | +pub async fn readme_sheet( | ||
| 384 | + lang: Lang, | ||
| 385 | + owner: String, | ||
| 386 | + repo: String, | ||
| 387 | + ref_name: String, | ||
| 388 | + dir: String, | ||
| 389 | + readme: Option<Readme>, | ||
| 390 | + none: &str, | ||
| 391 | +) -> Result<impl View> { | ||
| 392 | + let search = repo_href(&owner, &repo, "search", ""); | ||
| 393 | + let readme_name = readme.as_ref().map(|readme| readme.name.clone()); | ||
| 394 | + let links = readme.as_ref().map(|readme| { | ||
| 395 | + let path = if dir.is_empty() { | ||
| 396 | + readme.name.clone() | ||
| 397 | + } else { | ||
| 398 | + format!("{dir}/{}", readme.name) | ||
| 399 | + }; | ||
| 400 | + let target = format!("{ref_name}/{path}"); | ||
| 401 | + ( | ||
| 402 | + repo_href(&owner, &repo, "blob", &target), | ||
| 403 | + repo_href(&owner, &repo, "commits", &target), | ||
| 404 | + repo_href(&owner, &repo, "raw", &target), | ||
| 405 | + ) | ||
| 406 | + }); | ||
| 407 | + // The tools row names what is shown: the README, or the folder (the repo name at the root). | ||
| 408 | + let shown = readme_name.unwrap_or_else(|| if dir.is_empty() { repo.clone() } else { dir.clone() }); | ||
| 409 | + Ok(view! { | ||
| 410 | + <div class="sheet"> | ||
| 411 | + <div class="sheet-tools"> | ||
| 412 | + <strong>(shown)</strong> | ||
| 413 | + if let Some((source, history, raw)) = links { | ||
| 414 | + <a class="act" href=(source)>(s(lang, "Source", "Kaynak"))</a> | ||
| 415 | + <a class="act" href=(history)>(s(lang, "History", "Geçmiş"))</a> | ||
| 416 | + <a class="act" href=(raw)>(s(lang, "Raw", "Ham"))</a> | ||
| 417 | + } | ||
| 418 | + <a class="act" href=(search)>(g::t(lang, K::SearchCodePlaceholder))</a> | ||
| 419 | + </div> | ||
| 420 | + if let Some(readme) = readme { | ||
| 421 | + readme_card(name: readme.name, markdown: readme.markdown, body: readme.body) | ||
| 422 | + } else { | ||
| 423 | + empty_state(title: none) | ||
| 411 | } | 424 | } |
| 412 | </div> | 425 | </div> |
| 413 | }) | 426 | }) |
| @@ -457,18 +470,16 @@ async fn tree_page(cx: &Cx) -> Result<impl View> { | |||
| 457 | .map(|e| e.name) | 470 | .map(|e| e.name) |
| 458 | .collect() | 471 | .collect() |
| 459 | }; | 472 | }; |
| 460 | - let (last, bar, strip, ci_states, runs) = tokio::join!( | 473 | + let (last, bar, strip, runs) = tokio::join!( |
| 461 | last_commits(state, &ctx.path, &commit, &dir, &names), | 474 | last_commits(state, &ctx.path, &commit, &dir, &names), |
| 462 | latest_bar(state, repo, &ctx.path, &commit, "", lang, ctx.viewer_tz()), | 475 | latest_bar(state, repo, &ctx.path, &commit, "", lang, ctx.viewer_tz()), |
| 463 | commit_strip(state, repo, &ctx.path, &commit), | 476 | commit_strip(state, repo, &ctx.path, &commit), |
| 464 | - run_states(state, &repo.id), | ||
| 465 | run_rows(state, lang, repo), | 477 | run_rows(state, lang, repo), |
| 466 | ); | 478 | ); |
| 467 | - let ci_states = ci_states?; | ||
| 468 | let runs = runs?; | 479 | let runs = runs?; |
| 469 | let facts = tree_facts(state, repo, &ctx.path, &commit, &root_names).await?; | 480 | let facts = tree_facts(state, repo, &ctx.path, &commit, &root_names).await?; |
| 470 | - let bars = strip_bars(&strip.commits, &ci_states); | 481 | + let pips = run_pips(&runs); |
| 471 | - let total = strip.total; | 482 | + let sub = code_sub(lang, bar, Some(facts), None, Vec::new(), strip.total); |
| 472 | let refs: Vec<RefInfo> = load_refs(ctx.path.clone()).await?; | 483 | let refs: Vec<RefInfo> = load_refs(ctx.path.clone()).await?; |
| 473 | let readme = load_readme(state, repo, &ctx.path, &ref_name, &commit, &dir, &entries).await?; | 484 | let readme = load_readme(state, repo, &ctx.path, &ref_name, &commit, &dir, &entries).await?; |
| 474 | let rows = entry_rows( | 485 | let rows = entry_rows( |
| @@ -484,7 +495,6 @@ async fn tree_page(cx: &Cx) -> Result<impl View> { | |||
| 484 | let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo); | 495 | let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo); |
| 485 | let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", ""); | 496 | let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", ""); |
| 486 | let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", ""); | 497 | let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", ""); |
| 487 | - let ci_href = repo_href(&repo.owner_name, &repo.name, "ci", ""); | ||
| 488 | let live = follows_branch(&refs, &ref_name) | 498 | let live = follows_branch(&refs, &ref_name) |
| 489 | .then(|| live_url(&repo.owner_name, &repo.name, &refs, &ref_name)); | 499 | .then(|| live_url(&repo.owner_name, &repo.name, &refs, &ref_name)); |
| 490 | 500 | ||
| @@ -494,61 +504,29 @@ async fn tree_page(cx: &Cx) -> Result<impl View> { | |||
| 494 | let dock_owner = finder_owner.clone(); | 504 | let dock_owner = finder_owner.clone(); |
| 495 | let dock_repo = finder_repo.clone(); | 505 | let dock_repo = finder_repo.clone(); |
| 496 | let finder_ref = ref_name.clone(); | 506 | let finder_ref = ref_name.clone(); |
| 497 | - let https = https_clone_url(&state.config, &repo.owner_name, &repo.name); | 507 | + let readme_file = readme.as_ref().map(|readme| readme.name.clone()); |
| 498 | - let ssh = ssh_clone_url(&state.config, &repo.owner_name, &repo.name); | ||
| 499 | - let downloads = ( | ||
| 500 | - repo_href( | ||
| 501 | - &repo.owner_name, | ||
| 502 | - &repo.name, | ||
| 503 | - "archive", | ||
| 504 | - &format!("{ref_name}.zip"), | ||
| 505 | - ), | ||
| 506 | - repo_href( | ||
| 507 | - &repo.owner_name, | ||
| 508 | - &repo.name, | ||
| 509 | - "archive", | ||
| 510 | - &format!("{ref_name}.tar.gz"), | ||
| 511 | - ), | ||
| 512 | - ); | ||
| 513 | - let readme_label = readme | ||
| 514 | - .as_ref() | ||
| 515 | - .map(|readme| readme.name.clone()) | ||
| 516 | - .unwrap_or_else(|| "README".to_owned()); | ||
| 517 | let mut header = ctx.head(state, "code").await?; | 508 | let mut header = ctx.head(state, "code").await?; |
| 518 | // The header and the browse bar share the branch's stream: the client follows the first | 509 | // The header and the browse bar share the branch's stream: the client follows the first |
| 519 | // [data-live] on the page, which is the header. | 510 | // [data-live] on the page, which is the header. |
| 520 | if let Some(url) = &live { | 511 | if let Some(url) = &live { |
| 521 | header.live = url.clone(); | 512 | header.live = url.clone(); |
| 522 | } | 513 | } |
| 523 | - // The same two panes as the repo home, over the same dock, so the page fits the window. | ||
| 524 | Ok(view! { | 514 | Ok(view! { |
| 525 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 515 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 526 | - repo_head(head: header) | 516 | + repo_head(head: header, sub: sub, pips: pips) |
| 527 | - <div class="repo-grid repo-home canvas-repo tree-browse"> | 517 | + <div class="work"> |
| 528 | - <div class="repo-main canvas-files"> | 518 | + <nav class="rail" aria-label=(s(lang, "Files", "Dosyalar"))> |
| 529 | - <div class="browse-bar" data-live=(live.as_deref()) data-live-code=(live.is_some().then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> | 519 | + <div class="rail-head browse-bar" data-live=(live.as_deref()) data-live-code=(live.is_some().then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> |
| 520 | + <h2>(s(lang, "Files", "Dosyalar"))</h2> | ||
| 530 | ref_selector(lang: lang, label: mi::t(lang, MK::RefLabel), current: ref_name.clone(), branches: branches, tags: tags, | 521 | ref_selector(lang: lang, label: mi::t(lang, MK::RefLabel), current: ref_name.clone(), branches: branches, tags: tags, |
| 531 | branches_href: branches_href, tags_href: tags_href) | 522 | branches_href: branches_href, tags_href: tags_href) |
| 532 | file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) | 523 | file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) |
| 533 | </div> | 524 | </div> |
| 534 | - tree_table(rows: rows, lang: lang) | 525 | + tree_table(rows: rows, lang: lang, current: readme_file) |
| 535 | - </div> | 526 | + </nav> |
| 536 | - <div class="repo-split" role="separator" aria-orientation="vertical" | 527 | + readme_sheet(lang: lang, owner: dock_owner, repo: dock_repo, ref_name: ref_name.clone(), dir: dir.clone(), readme: readme, |
| 537 | - aria-label=(s(lang, "Resize file tree", "Dosya ağacını boyutlandır")) tabindex="0" | 528 | + none: s(lang, "No README in this folder", "Bu klasörde README yok")) |
| 538 | - data-repo-split=""></div> | ||
| 539 | - <div class="repo-readme canvas-readme"> | ||
| 540 | - readme_head(label: readme_label, facts: Some(facts), https: https, ssh: ssh, downloads: Some(downloads), lang: lang) | ||
| 541 | - <div class="canvas-body"> | ||
| 542 | - if let Some(readme) = readme { | ||
| 543 | - readme_card(name: readme.name, markdown: readme.markdown, body: readme.body) | ||
| 544 | - } else { | ||
| 545 | - empty_state(title: s(lang, "No README in this folder", "Bu klasörde README yok")) | ||
| 546 | - } | ||
| 547 | - </div> | ||
| 548 | - </div> | ||
| 549 | </div> | 529 | </div> |
| 550 | - repo_dock(lang: lang, runs: runs, total: total, ci_href: ci_href, | ||
| 551 | - owner: dock_owner, repo: dock_repo, bars: bars, latest: bar) | ||
| 552 | ) | 530 | ) |
| 553 | }) | 531 | }) |
| 554 | } | 532 | } |
crates/forge-web/src/pages/user_prefs.rsmodified+5 -61
| @@ -1,5 +1,4 @@ | |||
| 1 | -//! Route: `POST /-/prefs`, a signed-in user's account preferences: the tree width of a repo home, | 1 | +//! Route: `POST /-/prefs`, a signed-in user's account preferences: the diff view. The values live in the `user_prefs` table |
| 2 | -//! the profile corner's position and the diff view. The values live in the `user_prefs` table | ||
| 3 | //! (store/user_prefs.rs). Only the keys below are accepted; each has its own check. An empty value | 2 | //! (store/user_prefs.rs). Only the keys below are accepted; each has its own check. An empty value |
| 4 | //! deletes the key. Signed-out callers get what `require_csrf` gives. | 3 | //! deletes the key. Signed-out callers get what `require_csrf` gives. |
| 5 | 4 | ||
| @@ -15,16 +14,9 @@ use topcoat::router::{Body, route}; | |||
| 15 | use crate::auth::require_csrf; | 14 | use crate::auth::require_csrf; |
| 16 | use crate::state::AppState; | 15 | use crate::state::AppState; |
| 17 | 16 | ||
| 18 | -/// Key of the repo home's file tree width, in CSS pixels. | ||
| 19 | -pub const TREE_WIDTH: &str = "tree_width"; | ||
| 20 | -/// Key of the profile corner's position: `x,y` as fractions of the free space, each 0 to 1. | ||
| 21 | -pub const CORNER_POS: &str = "corner_pos"; | ||
| 22 | /// Key of the diff view: `split` or `unified`. | 17 | /// Key of the diff view: `split` or `unified`. |
| 23 | pub const DIFF_VIEW: &str = "diff_view"; | 18 | pub const DIFF_VIEW: &str = "diff_view"; |
| 24 | 19 | ||
| 25 | -const MIN_TREE_WIDTH: u32 = 120; | ||
| 26 | -const MAX_TREE_WIDTH: u32 = 4000; | ||
| 27 | - | ||
| 28 | #[derive(Deserialize)] | 20 | #[derive(Deserialize)] |
| 29 | struct PrefForm { | 21 | struct PrefForm { |
| 30 | #[serde(default)] | 22 | #[serde(default)] |
| @@ -39,37 +31,6 @@ struct PrefForm { | |||
| 39 | /// the value to store (normalised), and `Err` is the reason a 400 gives. | 31 | /// the value to store (normalised), and `Err` is the reason a 400 gives. |
| 40 | pub fn clean_pref(key: &str, value: &str) -> std::result::Result<Option<String>, &'static str> { | 32 | pub fn clean_pref(key: &str, value: &str) -> std::result::Result<Option<String>, &'static str> { |
| 41 | match key { | 33 | match key { |
| 42 | - TREE_WIDTH => { | ||
| 43 | - if value.is_empty() { | ||
| 44 | - return Ok(None); | ||
| 45 | - } | ||
| 46 | - let width = value | ||
| 47 | - .bytes() | ||
| 48 | - .all(|b| b.is_ascii_digit()) | ||
| 49 | - .then(|| value.parse::<u32>().ok()) | ||
| 50 | - .flatten() | ||
| 51 | - .filter(|w| (MIN_TREE_WIDTH..=MAX_TREE_WIDTH).contains(w)); | ||
| 52 | - width | ||
| 53 | - .map(|w| Some(w.to_string())) | ||
| 54 | - .ok_or("tree_width must be a whole number from 120 to 4000") | ||
| 55 | - } | ||
| 56 | - CORNER_POS => { | ||
| 57 | - if value.is_empty() { | ||
| 58 | - return Ok(None); | ||
| 59 | - } | ||
| 60 | - let fraction = |s: &str| { | ||
| 61 | - s.parse::<f64>() | ||
| 62 | - .ok() | ||
| 63 | - .filter(|v| v.is_finite() && (0.0..=1.0).contains(v)) | ||
| 64 | - }; | ||
| 65 | - match value.split_once(',') { | ||
| 66 | - Some((x, y)) => match (fraction(x), fraction(y)) { | ||
| 67 | - (Some(x), Some(y)) => Ok(Some(format!("{x},{y}"))), | ||
| 68 | - _ => Err("corner_pos must be two numbers from 0 to 1 written x,y"), | ||
| 69 | - }, | ||
| 70 | - None => Err("corner_pos must be two numbers from 0 to 1 written x,y"), | ||
| 71 | - } | ||
| 72 | - } | ||
| 73 | DIFF_VIEW => match value { | 34 | DIFF_VIEW => match value { |
| 74 | "" => Ok(None), | 35 | "" => Ok(None), |
| 75 | "split" | "unified" => Ok(Some(value.to_owned())), | 36 | "split" | "unified" => Ok(Some(value.to_owned())), |
| @@ -103,7 +64,7 @@ mod tests { | |||
| 103 | use crate::test_support::{app_router, create_session, test_state}; | 64 | use crate::test_support::{app_router, create_session, test_state}; |
| 104 | 65 | ||
| 105 | #[tokio::test] | 66 | #[tokio::test] |
| 106 | - async fn prefs_route_refuses_unknown_keys_and_stores_a_corner_position() { | 67 | + async fn prefs_route_refuses_unknown_keys_and_stores_the_diff_view() { |
| 107 | let dir = tempfile::tempdir().expect("tempdir"); | 68 | let dir = tempfile::tempdir().expect("tempdir"); |
| 108 | let state = test_state(dir.path()).await; | 69 | let state = test_state(dir.path()).await; |
| 109 | let user = state | 70 | let user = state |
| @@ -131,28 +92,11 @@ mod tests { | |||
| 131 | let _ = to_bytes(unknown.into_body(), usize::MAX).await.unwrap(); | 92 | let _ = to_bytes(unknown.into_body(), usize::MAX).await.unwrap(); |
| 132 | 93 | ||
| 133 | let stored = router | 94 | let stored = router |
| 134 | - .handle(post("csrf=prefs-csrf&key=corner_pos&value=0.5%2C0.25")) | 95 | + .handle(post("csrf=prefs-csrf&key=diff_view&value=split")) |
| 135 | .await; | 96 | .await; |
| 136 | - assert_eq!(stored.status().as_u16(), 204, "corner position saved"); | 97 | + assert_eq!(stored.status().as_u16(), 204, "diff view saved"); |
| 137 | let _ = to_bytes(stored.into_body(), usize::MAX).await.unwrap(); | 98 | let _ = to_bytes(stored.into_body(), usize::MAX).await.unwrap(); |
| 138 | let prefs = state.store.user_prefs(&user.id).await.unwrap(); | 99 | let prefs = state.store.user_prefs(&user.id).await.unwrap(); |
| 139 | - assert_eq!(prefs.get(CORNER_POS).map(String::as_str), Some("0.5,0.25")); | 100 | + assert_eq!(prefs.get(DIFF_VIEW).map(String::as_str), Some("split")); |
| 140 | - | ||
| 141 | - let page = router | ||
| 142 | - .handle( | ||
| 143 | - Request::builder() | ||
| 144 | - .method("GET") | ||
| 145 | - .uri("/tahinli") | ||
| 146 | - .header("cookie", cookie.as_str()) | ||
| 147 | - .body(Body::empty()) | ||
| 148 | - .unwrap(), | ||
| 149 | - ) | ||
| 150 | - .await; | ||
| 151 | - assert_eq!(page.status().as_u16(), 200); | ||
| 152 | - let bytes = to_bytes(page.into_body(), usize::MAX).await.unwrap(); | ||
| 153 | - assert!( | ||
| 154 | - String::from_utf8_lossy(&bytes).contains("data-corner-pos=\"0.5,0.25\""), | ||
| 155 | - "the page carries the stored corner" | ||
| 156 | - ); | ||
| 157 | } | 101 | } |
| 158 | } | 102 | } |
crates/forge-web/src/pages/wiki.rsmodified+151 -67
| @@ -17,7 +17,7 @@ use topcoat::context::{Cx, app_context}; | |||
| 17 | use topcoat::router::content::Form; | 17 | use topcoat::router::content::Form; |
| 18 | use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; | 18 | use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; |
| 19 | use topcoat::router::{page, path_param, route}; | 19 | use topcoat::router::{page, path_param, route}; |
| 20 | -use topcoat::view::{Unescaped, View, component, view}; | 20 | +use topcoat::view::{Child, Unescaped, View, component, view}; |
| 21 | 21 | ||
| 22 | use crate::audit::{self, Actor, Target}; | 22 | use crate::audit::{self, Actor, Target}; |
| 23 | use crate::auth::{require_csrf, require_user}; | 23 | use crate::auth::{require_csrf, require_user}; |
| @@ -30,6 +30,7 @@ use crate::pages::repo_settings::settings_frame; | |||
| 30 | use crate::pages::wiki_live::{bump_wiki, page_live_url, wiki_live_url}; | 30 | use crate::pages::wiki_live::{bump_wiki, page_live_url, wiki_live_url}; |
| 31 | use crate::render::markdown::render_markdown; | 31 | use crate::render::markdown::render_markdown; |
| 32 | use crate::state::AppState; | 32 | use crate::state::AppState; |
| 33 | +use crate::views::parts::{RailItem, rail}; | ||
| 33 | use crate::views::{alert, empty_state, rel_time, repo_href, shell}; | 34 | use crate::views::{alert, empty_state, rel_time, repo_href, shell}; |
| 34 | 35 | ||
| 35 | path_param!(owner); | 36 | path_param!(owner); |
| @@ -147,44 +148,87 @@ fn revision_rows(ctx: &RepoCtx, revs: &[PageRevision]) -> Vec<RevisionRow> { | |||
| 147 | .collect() | 148 | .collect() |
| 148 | } | 149 | } |
| 149 | 150 | ||
| 150 | -/// The header every wiki screen shares: the page name as its heading when the screen has links | 151 | +/// The links every wiki sheet offers: Home, All pages, the screen's own `extra` links, and New |
| 151 | -/// of its own (a page, its history, an edit), then the wiki's navigation as second-level text | 152 | +/// page for a writer. |
| 152 | -/// links (Home, All pages, any page-specific `extra` links) with "New page" as an action. | 153 | +fn wiki_links( |
| 154 | + lang: Lang, | ||
| 155 | + owner: &str, | ||
| 156 | + repo: &str, | ||
| 157 | + can_write: bool, | ||
| 158 | + extra: Vec<(String, String)>, | ||
| 159 | +) -> Vec<(String, String)> { | ||
| 160 | + let mut links = vec![ | ||
| 161 | + ( | ||
| 162 | + g::t(lang, K::Home).to_owned(), | ||
| 163 | + repo_href(owner, repo, "wiki", ""), | ||
| 164 | + ), | ||
| 165 | + ( | ||
| 166 | + g::t(lang, K::AllPages).to_owned(), | ||
| 167 | + repo_href(owner, repo, "wiki", "-/pages"), | ||
| 168 | + ), | ||
| 169 | + ]; | ||
| 170 | + links.extend(extra); | ||
| 171 | + if can_write { | ||
| 172 | + links.push(( | ||
| 173 | + g::t(lang, K::NewPage).to_owned(), | ||
| 174 | + repo_href(owner, repo, "wiki", "-/new"), | ||
| 175 | + )); | ||
| 176 | + } | ||
| 177 | + links | ||
| 178 | +} | ||
| 179 | + | ||
| 180 | +/// The page list beside a wiki page: every page, the one on screen marked. | ||
| 153 | #[component] | 181 | #[component] |
| 154 | -async fn wiki_head( | 182 | +async fn wiki_rail( |
| 155 | lang: Lang, | 183 | lang: Lang, |
| 156 | owner: String, | 184 | owner: String, |
| 157 | repo: String, | 185 | repo: String, |
| 158 | - can_write: bool, | 186 | + names: Vec<String>, |
| 159 | - title: String, | 187 | + current: String, |
| 160 | - extra: Vec<(String, String)>, | ||
| 161 | - live: Option<String>, | ||
| 162 | ) -> Result<impl View> { | 188 | ) -> Result<impl View> { |
| 163 | - let home = repo_href(&owner, &repo, "wiki", ""); | 189 | + let items: Vec<RailItem> = names |
| 164 | - let pages = repo_href(&owner, &repo, "wiki", "-/pages"); | 190 | + .into_iter() |
| 165 | - let new = repo_href(&owner, &repo, "wiki", "-/new"); | 191 | + .map(|name| RailItem { |
| 166 | - let heading_shown = !extra.is_empty(); | 192 | + href: repo_href(&owner, &repo, "wiki", &name), |
| 193 | + current: name == current, | ||
| 194 | + name: name.replace('-', " "), | ||
| 195 | + val: String::new(), | ||
| 196 | + }) | ||
| 197 | + .collect(); | ||
| 167 | Ok(view! { | 198 | Ok(view! { |
| 168 | - <div data-live=(live.as_deref())> | 199 | + rail(label: g::t(lang, K::PageNav), items: items) |
| 169 | - if heading_shown { | 200 | + }) |
| 170 | - <h1 class="h1">(title.as_str())</h1> | 201 | +} |
| 171 | - } else { | 202 | + |
| 172 | - <h1 class="sr-only">(title.as_str())</h1> | 203 | +/// A wiki screen's sheet: its tools row (name and links), then the screen. `live` is the stream |
| 173 | - } | 204 | +/// the screen follows. |
| 174 | - <nav class="sub" aria-label=(g::t(lang, K::PageNav))> | 205 | +#[component] |
| 175 | - <a href=(home)>(g::t(lang, K::Home))</a> | 206 | +async fn wiki_sheet( |
| 176 | - <a href=(pages)>(g::t(lang, K::AllPages))</a> | 207 | + #[default] title: Option<String>, |
| 177 | - for (label, href) in extra.into_iter() { | 208 | + links: Vec<(String, String)>, |
| 178 | - <a href=(href)>(label)</a> | 209 | + #[default] live: Option<String>, |
| 210 | + #[default] child: Child<'_>, | ||
| 211 | +) -> Result<impl View> { | ||
| 212 | + Ok(view! { | ||
| 213 | + <div class="sheet" data-live=(live.as_deref())> | ||
| 214 | + <div class="sheet-tools"> | ||
| 215 | + if let Some(title) = title { | ||
| 216 | + <strong>(title.as_str())</strong> | ||
| 179 | } | 217 | } |
| 180 | - if can_write { | 218 | + for (label, href) in links.into_iter() { |
| 181 | - <a class="act" href=(new)>(g::t(lang, K::NewPage))</a> | 219 | + <a class="act" href=(href)>(label)</a> |
| 182 | } | 220 | } |
| 183 | - </nav> | 221 | + </div> |
| 222 | + (child) | ||
| 184 | </div> | 223 | </div> |
| 185 | }) | 224 | }) |
| 186 | } | 225 | } |
| 187 | 226 | ||
| 227 | +/// The page names of the wiki, for the rail and the page list. | ||
| 228 | +async fn page_names(dir: PathBuf) -> Result<Vec<String>> { | ||
| 229 | + blocking(move || wiki::list_pages(&dir)).await | ||
| 230 | +} | ||
| 231 | + | ||
| 188 | /// The Edit / History links shown in the header of a rendered page. | 232 | /// The Edit / History links shown in the header of a rendered page. |
| 189 | fn page_links( | 233 | fn page_links( |
| 190 | lang: Lang, | 234 | lang: Lang, |
| @@ -251,13 +295,11 @@ async fn wiki_list_body( | |||
| 251 | if rows.is_empty() { | 295 | if rows.is_empty() { |
| 252 | empty_state(title: g::t(lang, K::NoPagesYet)) | 296 | empty_state(title: g::t(lang, K::NoPagesYet)) |
| 253 | } else { | 297 | } else { |
| 254 | - <div class="wiki-pages"> | 298 | + for (title, href) in rows.into_iter() { |
| 255 | - for (title, href) in rows.into_iter() { | 299 | + <a class="line" href=(href) data-kb-row=""> |
| 256 | - <a class="line" href=(href) data-kb-row=""> | 300 | + <span class="name">(title.as_str())</span> |
| 257 | - <span class="name">(title.as_str())</span> | 301 | + </a> |
| 258 | - </a> | 302 | + } |
| 259 | - } | ||
| 260 | - </div> | ||
| 261 | } | 303 | } |
| 262 | }) | 304 | }) |
| 263 | } | 305 | } |
| @@ -268,14 +310,12 @@ async fn wiki_history_body(lang: Lang, rows: Vec<RevisionRow>) -> Result<impl Vi | |||
| 268 | if rows.is_empty() { | 310 | if rows.is_empty() { |
| 269 | empty_state(title: g::t(lang, K::NoChangesYet)) | 311 | empty_state(title: g::t(lang, K::NoChangesYet)) |
| 270 | } else { | 312 | } else { |
| 271 | - <div class="wiki-history"> | 313 | + for row in rows.into_iter() { |
| 272 | - for row in rows.into_iter() { | 314 | + <a class="line" href=(row.href) data-kb-row=""> |
| 273 | - <a class="line" href=(row.href) data-kb-row=""> | 315 | + <span class="name">(row.subject.as_str())</span> |
| 274 | - <span class="name">(row.subject.as_str())</span> | 316 | + <span class="val"><code>(row.short.as_str())</code> " · " (row.author.as_str()) " · " rel_time(lang: lang, stamp: row.when.as_str())</span> |
| 275 | - <span class="val"><code>(row.short.as_str())</code> " · " (row.author.as_str()) " · " rel_time(lang: lang, stamp: row.when.as_str())</span> | 317 | + </a> |
| 276 | - </a> | 318 | + } |
| 277 | - } | ||
| 278 | - </div> | ||
| 279 | } | 319 | } |
| 280 | }) | 320 | }) |
| 281 | } | 321 | } |
| @@ -339,6 +379,7 @@ async fn wiki_home(cx: &Cx) -> Result<impl View> { | |||
| 339 | let state = app_context::<AppState>(cx); | 379 | let state = app_context::<AppState>(cx); |
| 340 | ensure_enabled(state, &ctx).await?; | 380 | ensure_enabled(state, &ctx).await?; |
| 341 | let dir = wiki_dir(state, &ctx)?; | 381 | let dir = wiki_dir(state, &ctx)?; |
| 382 | + let names = page_names(dir.clone()).await?; | ||
| 342 | let (_, home) = load_page(dir, "Home".to_owned()).await?; | 383 | let (_, home) = load_page(dir, "Home".to_owned()).await?; |
| 343 | let can_write = ctx.can_write(); | 384 | let can_write = ctx.can_write(); |
| 344 | let owner_name = ctx.repo.owner_name.clone(); | 385 | let owner_name = ctx.repo.owner_name.clone(); |
| @@ -351,25 +392,32 @@ async fn wiki_home(cx: &Cx) -> Result<impl View> { | |||
| 351 | ctx.repo.name, | 392 | ctx.repo.name, |
| 352 | g::t(lang, K::Wiki) | 393 | g::t(lang, K::Wiki) |
| 353 | ); | 394 | ); |
| 354 | - let (head_title, links) = if body_html.is_some() { | 395 | + let live = wiki_live_url(&owner_name, &repo_name); |
| 396 | + let (head_title, sheet_title, extra) = if body_html.is_some() { | ||
| 355 | ( | 397 | ( |
| 356 | - g::t(lang, K::Home).to_owned(), | 398 | + Some(g::t(lang, K::Home).to_owned()), |
| 399 | + None, | ||
| 357 | page_links(lang, &owner_name, &repo_name, "Home", can_write), | 400 | page_links(lang, &owner_name, &repo_name, "Home", can_write), |
| 358 | ) | 401 | ) |
| 359 | } else { | 402 | } else { |
| 360 | - (g::t(lang, K::Wiki).to_owned(), Vec::new()) | 403 | + (None, Some(g::t(lang, K::Wiki).to_owned()), Vec::new()) |
| 361 | }; | 404 | }; |
| 405 | + let links = wiki_links(lang, &owner_name, &repo_name, can_write, extra); | ||
| 362 | let header = ctx.head(state, "wiki").await?; | 406 | let header = ctx.head(state, "wiki").await?; |
| 363 | Ok(view! { cx => | 407 | Ok(view! { cx => |
| 364 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 408 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 365 | - repo_head(head: header) | 409 | + repo_head(head: header, title: head_title) |
| 366 | - 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))) | 410 | + <div class="work"> |
| 367 | - if let Some(html) = body_html.clone() { | 411 | + wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: "Home".to_owned()) |
| 368 | - wiki_view_body(html: html) | 412 | + wiki_sheet(title: sheet_title, links: links, live: Some(live), |
| 369 | - } | 413 | + if let Some(html) = body_html.clone() { |
| 370 | - if body_html.is_none() { | 414 | + wiki_view_body(html: html) |
| 371 | - wiki_empty_body(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: can_write) | 415 | + } |
| 372 | - } | 416 | + if body_html.is_none() { |
| 417 | + wiki_empty_body(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: can_write) | ||
| 418 | + } | ||
| 419 | + ) | ||
| 420 | + </div> | ||
| 373 | ) | 421 | ) |
| 374 | }) | 422 | }) |
| 375 | } | 423 | } |
| @@ -383,7 +431,7 @@ async fn wiki_pages(cx: &Cx) -> Result<impl View> { | |||
| 383 | ensure_enabled(state, &ctx).await?; | 431 | ensure_enabled(state, &ctx).await?; |
| 384 | let lang = i18n::lang(cx, ctx.viewer.as_ref().map(|(user, _)| user)); | 432 | let lang = i18n::lang(cx, ctx.viewer.as_ref().map(|(user, _)| user)); |
| 385 | let dir = wiki_dir(state, &ctx)?; | 433 | let dir = wiki_dir(state, &ctx)?; |
| 386 | - let names = blocking(move || wiki::list_pages(&dir)).await?; | 434 | + let names = page_names(dir).await?; |
| 387 | let can_write = ctx.can_write(); | 435 | let can_write = ctx.can_write(); |
| 388 | let owner_name = ctx.repo.owner_name.clone(); | 436 | let owner_name = ctx.repo.owner_name.clone(); |
| 389 | let repo_name = ctx.repo.name.clone(); | 437 | let repo_name = ctx.repo.name.clone(); |
| @@ -393,12 +441,14 @@ async fn wiki_pages(cx: &Cx) -> Result<impl View> { | |||
| 393 | ctx.repo.name, | 441 | ctx.repo.name, |
| 394 | g::t(lang, K::WikiPages) | 442 | g::t(lang, K::WikiPages) |
| 395 | ); | 443 | ); |
| 444 | + let links = wiki_links(lang, &owner_name, &repo_name, can_write, Vec::new()); | ||
| 396 | let header = ctx.head(state, "wiki").await?; | 445 | let header = ctx.head(state, "wiki").await?; |
| 397 | Ok(view! { cx => | 446 | Ok(view! { cx => |
| 398 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 447 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 399 | - repo_head(head: header) | 448 | + repo_head(head: header, title: Some(g::t(lang, K::AllPages).to_owned())) |
| 400 | - 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))) | 449 | + wiki_sheet(links: links, live: Some(wiki_live_url(&owner_name, &repo_name)), |
| 401 | - wiki_list_body(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names) | 450 | + wiki_list_body(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names) |
| 451 | + ) | ||
| 402 | ) | 452 | ) |
| 403 | }) | 453 | }) |
| 404 | } | 454 | } |
| @@ -415,6 +465,7 @@ async fn wiki_page_view(cx: &Cx) -> Result<impl View> { | |||
| 415 | return Err(not_found().into()); | 465 | return Err(not_found().into()); |
| 416 | } | 466 | } |
| 417 | let dir = wiki_dir(state, &ctx)?; | 467 | let dir = wiki_dir(state, &ctx)?; |
| 468 | + let names = page_names(dir.clone()).await?; | ||
| 418 | let (_, text) = load_page(dir, page_name.clone()).await?; | 469 | let (_, text) = load_page(dir, page_name.clone()).await?; |
| 419 | let Some(text) = text else { | 470 | let Some(text) = text else { |
| 420 | return Err(not_found().into()); | 471 | return Err(not_found().into()); |
| @@ -430,12 +481,23 @@ async fn wiki_page_view(cx: &Cx) -> Result<impl View> { | |||
| 430 | ctx.repo.owner_name, | 481 | ctx.repo.owner_name, |
| 431 | ctx.repo.name | 482 | ctx.repo.name |
| 432 | ); | 483 | ); |
| 484 | + let links = wiki_links( | ||
| 485 | + lang, | ||
| 486 | + &owner_name, | ||
| 487 | + &repo_name, | ||
| 488 | + can_write, | ||
| 489 | + page_links(lang, &owner_name, &repo_name, &page_name, can_write), | ||
| 490 | + ); | ||
| 433 | let header = ctx.head(state, "wiki").await?; | 491 | let header = ctx.head(state, "wiki").await?; |
| 434 | Ok(view! { cx => | 492 | Ok(view! { cx => |
| 435 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 493 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 436 | - repo_head(head: header) | 494 | + repo_head(head: header, title: Some(page_name.replace('-', " "))) |
| 437 | - 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))) | 495 | + <div class="work"> |
| 438 | - wiki_view_body(html: html) | 496 | + wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: page_name.clone()) |
| 497 | + wiki_sheet(links: links, live: Some(page_live_url(&owner_name, &repo_name, &page_name)), | ||
| 498 | + wiki_view_body(html: html) | ||
| 499 | + ) | ||
| 500 | + </div> | ||
| 439 | ) | 501 | ) |
| 440 | }) | 502 | }) |
| 441 | } | 503 | } |
| @@ -452,6 +514,7 @@ async fn wiki_page_history(cx: &Cx) -> Result<impl View> { | |||
| 452 | return Err(not_found().into()); | 514 | return Err(not_found().into()); |
| 453 | } | 515 | } |
| 454 | let dir = wiki_dir(state, &ctx)?; | 516 | let dir = wiki_dir(state, &ctx)?; |
| 517 | + let names = page_names(dir.clone()).await?; | ||
| 455 | let git = state.git.clone(); | 518 | let git = state.git.clone(); |
| 456 | let revs = wiki::page_history(&git, &dir, &page_name).await?; | 519 | let revs = wiki::page_history(&git, &dir, &page_name).await?; |
| 457 | let rows = revision_rows(&ctx, &revs); | 520 | let rows = revision_rows(&ctx, &revs); |
| @@ -464,12 +527,27 @@ async fn wiki_page_history(cx: &Cx) -> Result<impl View> { | |||
| 464 | ctx.repo.owner_name, | 527 | ctx.repo.owner_name, |
| 465 | ctx.repo.name | 528 | ctx.repo.name |
| 466 | ); | 529 | ); |
| 530 | + let can_write = ctx.can_write(); | ||
| 531 | + let links = wiki_links( | ||
| 532 | + lang, | ||
| 533 | + &owner_name, | ||
| 534 | + &repo_name, | ||
| 535 | + can_write, | ||
| 536 | + vec![( | ||
| 537 | + g::t(lang, K::BackToPage).to_owned(), | ||
| 538 | + repo_href(&owner_name, &repo_name, "wiki", &page_name), | ||
| 539 | + )], | ||
| 540 | + ); | ||
| 467 | let header = ctx.head(state, "wiki").await?; | 541 | let header = ctx.head(state, "wiki").await?; |
| 468 | Ok(view! { cx => | 542 | Ok(view! { cx => |
| 469 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 543 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 470 | - repo_head(head: header) | 544 | + repo_head(head: header, title: Some(format!("{} \u{b7} {}", page_name.replace('-', " "), g::t(lang, K::History)))) |
| 471 | - 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))) | 545 | + <div class="work"> |
| 472 | - wiki_history_body(lang: lang, rows: rows) | 546 | + wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: page_name.clone()) |
| 547 | + wiki_sheet(links: links, live: Some(page_live_url(&owner_name, &repo_name, &page_name)), | ||
| 548 | + wiki_history_body(lang: lang, rows: rows) | ||
| 549 | + ) | ||
| 550 | + </div> | ||
| 473 | ) | 551 | ) |
| 474 | }) | 552 | }) |
| 475 | } | 553 | } |
| @@ -487,6 +565,7 @@ async fn edit_screen( | |||
| 487 | let (user, session) = require_user(cx).await?; | 565 | let (user, session) = require_user(cx).await?; |
| 488 | let lang = i18n::lang(cx, Some(&user)); | 566 | let lang = i18n::lang(cx, Some(&user)); |
| 489 | let dir = wiki_dir(state, &ctx)?; | 567 | let dir = wiki_dir(state, &ctx)?; |
| 568 | + let names = page_names(dir.clone()).await?; | ||
| 490 | let head = blocking(move || wiki::head_commit(&dir)).await?; | 569 | let head = blocking(move || wiki::head_commit(&dir)).await?; |
| 491 | let action = if is_new { | 570 | let action = if is_new { |
| 492 | repo_href(&ctx.repo.owner_name, &ctx.repo.name, "wiki", "-/new") | 571 | repo_href(&ctx.repo.owner_name, &ctx.repo.name, "wiki", "-/new") |
| @@ -522,11 +601,16 @@ async fn edit_screen( | |||
| 522 | repo_href(&owner_name, &repo_name, "wiki", &name), | 601 | repo_href(&owner_name, &repo_name, "wiki", &name), |
| 523 | )] | 602 | )] |
| 524 | }; | 603 | }; |
| 604 | + let links = wiki_links(lang, &owner_name, &repo_name, !is_new, back_links); | ||
| 525 | Ok(view! { cx => | 605 | Ok(view! { cx => |
| 526 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 606 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 527 | - repo_head(head: header) | 607 | + repo_head(head: header, title: Some(head_title)) |
| 528 | - 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) | 608 | + <div class="work"> |
| 529 | - wiki_edit_body(lang: lang, action: action, csrf: csrf, base: base, name: name.clone(), is_new: is_new, content: content, error: error) | 609 | + wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: name.clone()) |
| 610 | + wiki_sheet(links: links, | ||
| 611 | + wiki_edit_body(lang: lang, action: action, csrf: csrf, base: base, name: name.clone(), is_new: is_new, content: content, error: error) | ||
| 612 | + ) | ||
| 613 | + </div> | ||
| 530 | ) | 614 | ) |
| 531 | }) | 615 | }) |
| 532 | } | 616 | } |
| @@ -726,7 +810,7 @@ async fn wiki_settings_page(cx: &Cx) -> Result<impl View> { | |||
| 726 | let csrf = session.csrf_token.clone(); | 810 | let csrf = session.csrf_token.clone(); |
| 727 | Ok(view! { cx => | 811 | Ok(view! { cx => |
| 728 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 812 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 729 | - repo_head(head: header) | 813 | + repo_head(head: header, title: Some(g::t(lang, K::Wiki).to_owned())) |
| 730 | settings_frame(lang: lang, title: format!("{}/{}", ctx.repo.owner_name, ctx.repo.name), current: "wiki", | 814 | settings_frame(lang: lang, title: format!("{}/{}", ctx.repo.owner_name, ctx.repo.name), current: "wiki", |
| 731 | can_delete: ctx.can_delete(), | 815 | can_delete: ctx.can_delete(), |
| 732 | wiki_settings_body(lang: lang, action: action, csrf: csrf, enabled: enabled) | 816 | wiki_settings_body(lang: lang, action: action, csrf: csrf, enabled: enabled) |
crates/forge-web/src/views/commit_line.rsmodified+0 -11
| @@ -5,19 +5,8 @@ | |||
| 5 | use topcoat::Result; | 5 | use topcoat::Result; |
| 6 | use topcoat::view::{View, component, view}; | 6 | use topcoat::view::{View, component, view}; |
| 7 | 7 | ||
| 8 | -use crate::render::commit_message::CommitMessage; | ||
| 9 | use crate::render::emoji::emojify; | 8 | use crate::render::emoji::emojify; |
| 10 | 9 | ||
| 11 | -/// The first clause of a subject, or the emojified subject when it does not parse. For text that | ||
| 12 | -/// is not rendered through `commit_line`, such as a heading. | ||
| 13 | -pub fn headline(subject: &str) -> String { | ||
| 14 | - let emojified = emojify(subject); | ||
| 15 | - match CommitMessage::parse(&emojified) { | ||
| 16 | - Some(message) => message.title(), | ||
| 17 | - None => emojified.into_owned(), | ||
| 18 | - } | ||
| 19 | -} | ||
| 20 | - | ||
| 21 | /// One subject on one line as it was written, header included, truncated by CSS. The full subject | 10 | /// One subject on one line as it was written, header included, truncated by CSS. The full subject |
| 22 | /// is the `title` attribute. | 11 | /// is the `title` attribute. |
| 23 | #[component] | 12 | #[component] |
crates/forge-web/src/views/commit_status.rsmodified+3 -3
| @@ -140,7 +140,7 @@ pub async fn checks_summary( | |||
| 140 | <strong>(text)</strong> | 140 | <strong>(text)</strong> |
| 141 | if has_items { | 141 | if has_items { |
| 142 | <details class="checks-details"> | 142 | <details class="checks-details"> |
| 143 | - <summary class="small muted">(g::t(lang, K::ShowChecks))</summary> | 143 | + <summary class="act">(g::t(lang, K::ShowChecks))</summary> |
| 144 | status_list(items: items, lang: lang) | 144 | status_list(items: items, lang: lang) |
| 145 | </details> | 145 | </details> |
| 146 | } | 146 | } |
| @@ -175,10 +175,10 @@ pub async fn status_list(items: Vec<StatusItem>, lang: Lang) -> Result<impl View | |||
| 175 | <span class=(item.icon_class.as_str())>(item.icon)</span> | 175 | <span class=(item.icon_class.as_str())>(item.icon)</span> |
| 176 | <code>(item.context.as_str())</code> | 176 | <code>(item.context.as_str())</code> |
| 177 | if item.has_description { | 177 | if item.has_description { |
| 178 | - <span class="muted small">(description_text(lang, item.description.as_str()))</span> | 178 | + <span class="hint">(description_text(lang, item.description.as_str()))</span> |
| 179 | } | 179 | } |
| 180 | if item.has_link { | 180 | if item.has_link { |
| 181 | - <a class="small" href=(item.link.as_str()) rel="nofollow noopener noreferrer">(g::t(lang, K::DetailsLink))</a> | 181 | + <a class="act" href=(item.link.as_str()) rel="nofollow noopener noreferrer">(g::t(lang, K::DetailsLink))</a> |
| 182 | } | 182 | } |
| 183 | </li> | 183 | </li> |
| 184 | } | 184 | } |
crates/forge-web/src/views/diff.rsmodified+38 -14
| @@ -85,6 +85,8 @@ pub struct DiffOpts { | |||
| 85 | pub query: Vec<(String, String)>, | 85 | pub query: Vec<(String, String)>, |
| 86 | /// `.patch` and `.diff` download links, when the page has them. | 86 | /// `.patch` and `.diff` download links, when the page has them. |
| 87 | pub downloads: Option<(String, String)>, | 87 | pub downloads: Option<(String, String)>, |
| 88 | + /// Shows this file alone, with no list of files: the review page picks one from its rail. | ||
| 89 | + pub only: Option<usize>, | ||
| 88 | } | 90 | } |
| 89 | 91 | ||
| 90 | impl DiffOpts { | 92 | impl DiffOpts { |
| @@ -146,6 +148,7 @@ impl DiffOpts { | |||
| 146 | path: request.path().to_owned(), | 148 | path: request.path().to_owned(), |
| 147 | query, | 149 | query, |
| 148 | downloads, | 150 | downloads, |
| 151 | + only: None, | ||
| 149 | }) | 152 | }) |
| 150 | } | 153 | } |
| 151 | 154 | ||
| @@ -526,8 +529,11 @@ pub async fn diff_section( | |||
| 526 | .files | 529 | .files |
| 527 | .iter() | 530 | .iter() |
| 528 | .enumerate() | 531 | .enumerate() |
| 529 | - .map(|(i, file)| FileView::new(i, file, oid, parent, owner, repo, lang, &mut comments)) | 532 | + .map(|(i, file)| (i, FileView::new(i, file, oid, parent, owner, repo, lang, &mut comments))) |
| 533 | + .filter(|(i, _)| opts.only.is_none_or(|only| only == *i)) | ||
| 534 | + .map(|(_, file)| file) | ||
| 530 | .collect(); | 535 | .collect(); |
| 536 | + let alone = opts.only.is_some(); | ||
| 531 | if split { | 537 | if split { |
| 532 | for file in &mut files { | 538 | for file in &mut files { |
| 533 | file.split_rows = split_rows(std::mem::take(&mut file.rows)); | 539 | file.split_rows = split_rows(std::mem::take(&mut file.rows)); |
| @@ -562,9 +568,15 @@ pub async fn diff_section( | |||
| 562 | 568 | ||
| 563 | Ok(view! { | 569 | Ok(view! { |
| 564 | <section class="diff-section"> | 570 | <section class="diff-section"> |
| 565 | - <h2>(files_label.as_str()) " " <span class="diff-stats"><span class="add">(add_label.as_str())</span> " " <span class="del">(del_label.as_str())</span></span></h2> | 571 | + if !alone || toolbar.is_some() { |
| 566 | - if let Some(bar) = toolbar { | 572 | + <div class="diff-head"> |
| 567 | - diff_toolbar(bar: bar, lang: lang) | 573 | + if !alone { |
| 574 | + <h2>(files_label.as_str()) " " <span class="diff-stats"><span class="add">(add_label.as_str())</span> " " <span class="del">(del_label.as_str())</span></span></h2> | ||
| 575 | + } | ||
| 576 | + if let Some(bar) = toolbar { | ||
| 577 | + diff_toolbar(bar: bar, lang: lang) | ||
| 578 | + } | ||
| 579 | + </div> | ||
| 568 | } | 580 | } |
| 569 | if truncated_files { | 581 | if truncated_files { |
| 570 | <p class="state">(truncated_note.as_str())</p> | 582 | <p class="state">(truncated_note.as_str())</p> |
| @@ -572,6 +584,7 @@ pub async fn diff_section( | |||
| 572 | if no_files { | 584 | if no_files { |
| 573 | <p class="state">(g::t(lang, K::NoFileChanges))</p> | 585 | <p class="state">(g::t(lang, K::NoFileChanges))</p> |
| 574 | } else { | 586 | } else { |
| 587 | + if !alone { | ||
| 575 | <ul class="diff-index"> | 588 | <ul class="diff-index"> |
| 576 | for item in nav.iter() { | 589 | for item in nav.iter() { |
| 577 | <li> | 590 | <li> |
| @@ -581,6 +594,7 @@ pub async fn diff_section( | |||
| 581 | </li> | 594 | </li> |
| 582 | } | 595 | } |
| 583 | </ul> | 596 | </ul> |
| 597 | + } | ||
| 584 | for file in files.into_iter() { | 598 | for file in files.into_iter() { |
| 585 | diff_file(file: file, lang: lang, split: split, anchored: anchored) | 599 | diff_file(file: file, lang: lang, split: split, anchored: anchored) |
| 586 | } | 600 | } |
| @@ -601,8 +615,8 @@ async fn diff_toolbar(bar: Toolbar, lang: Lang) -> Result<impl View> { | |||
| 601 | <a href=(bar.split_href.as_str()) aria-pressed=(split_on)>(b::t(lang, b::K::Split))</a> | 615 | <a href=(bar.split_href.as_str()) aria-pressed=(split_on)>(b::t(lang, b::K::Split))</a> |
| 602 | <a href=(bar.ws_href.as_str()) aria-pressed=(ws_on)>(b::t(lang, b::K::IgnoreWhitespace))</a> | 616 | <a href=(bar.ws_href.as_str()) aria-pressed=(ws_on)>(b::t(lang, b::K::IgnoreWhitespace))</a> |
| 603 | if let Some((patch, diff)) = bar.downloads { | 617 | if let Some((patch, diff)) = bar.downloads { |
| 604 | - <a class="act quiet" href=(patch.as_str()) title=(b::t(lang, b::K::PatchTitle))>(b::t(lang, b::K::PatchLink))</a> | 618 | + <a class="act" href=(patch.as_str()) title=(b::t(lang, b::K::PatchTitle))>(b::t(lang, b::K::PatchLink))</a> |
| 605 | - <a class="act quiet" href=(diff.as_str()) title=(b::t(lang, b::K::DiffTitle))>(b::t(lang, b::K::DiffLink))</a> | 619 | + <a class="act" href=(diff.as_str()) title=(b::t(lang, b::K::DiffTitle))>(b::t(lang, b::K::DiffLink))</a> |
| 606 | } | 620 | } |
| 607 | </nav> | 621 | </nav> |
| 608 | }) | 622 | }) |
| @@ -622,13 +636,11 @@ async fn diff_file(file: FileView, lang: Lang, split: bool, anchored: bool) -> R | |||
| 622 | }; | 636 | }; |
| 623 | Ok(view! { | 637 | Ok(view! { |
| 624 | <section class="diff-file" id=(file.anchor.as_str()) data-keep-anchor=(file.label.as_str())> | 638 | <section class="diff-file" id=(file.anchor.as_str()) data-keep-anchor=(file.label.as_str())> |
| 625 | - <header class="diff-file-header"> | 639 | + <div class="sheet-tools diff-file-header"> |
| 626 | - <code class="diff-path">(file.label.as_str())</code> | 640 | + <strong class="diff-path">(file.label.as_str())</strong> |
| 627 | - <span class="diff-file-meta"> | 641 | + <span class="hint">(file.status)</span> |
| 628 | - <span class="hint">(file.status)</span> | 642 | + <span class="diff-stats"><span class="add">(add_label.as_str())</span> " " <span class="del">(del_label.as_str())</span></span> |
| 629 | - <span class="diff-stats"><span class="add">(add_label.as_str())</span> " " <span class="del">(del_label.as_str())</span></span> | 643 | + </div> |
| 630 | - </span> | ||
| 631 | - </header> | ||
| 632 | if file.binary { | 644 | if file.binary { |
| 633 | <p class="state diff-collapsed">(g::t(lang, K::BinaryFileChanged))</p> | 645 | <p class="state diff-collapsed">(g::t(lang, K::BinaryFileChanged))</p> |
| 634 | } else { | 646 | } else { |
| @@ -642,6 +654,18 @@ async fn diff_file(file: FileView, lang: Lang, split: bool, anchored: bool) -> R | |||
| 642 | if has_rows { | 654 | if has_rows { |
| 643 | <div class="diff-file-body"> | 655 | <div class="diff-file-body"> |
| 644 | <table class=(table_class)> | 656 | <table class=(table_class)> |
| 657 | + // A fixed split table takes its column widths from here, not from its | ||
| 658 | + // first row, which is a hunk header spanning all of them. | ||
| 659 | + if split { | ||
| 660 | + <colgroup> | ||
| 661 | + if anchored { <col class="col-plus"> } | ||
| 662 | + <col class="col-ln"> | ||
| 663 | + <col class="col-code"> | ||
| 664 | + if anchored { <col class="col-plus"> } | ||
| 665 | + <col class="col-ln"> | ||
| 666 | + <col class="col-code"> | ||
| 667 | + </colgroup> | ||
| 668 | + } | ||
| 645 | for row in rows.into_iter() { | 669 | for row in rows.into_iter() { |
| 646 | diff_line(row: row, lang: lang) | 670 | diff_line(row: row, lang: lang) |
| 647 | } | 671 | } |
| @@ -817,7 +841,7 @@ async fn inline_comment_form(form: InlineForm, lang: Lang) -> Result<impl View> | |||
| 817 | if let Some(text) = suggest_line { | 841 | if let Some(text) = suggest_line { |
| 818 | <button type="button" class="act" data-suggest=(text.as_str())>(suggest_label)</button> | 842 | <button type="button" class="act" data-suggest=(text.as_str())>(suggest_label)</button> |
| 819 | } | 843 | } |
| 820 | - <a class="act quiet" href=(cancel_href.as_str())>(g::t(lang, K::CancelLink))</a> | 844 | + <a class="act" href=(cancel_href.as_str())>(g::t(lang, K::CancelLink))</a> |
| 821 | </div> | 845 | </div> |
| 822 | </form> | 846 | </form> |
| 823 | }) | 847 | }) |
crates/forge-web/src/views/mod.rsmodified+108 -174
| @@ -41,7 +41,6 @@ use crate::i18n::packages::{self as pk, K as PK}; | |||
| 41 | use crate::i18n::{self, Key, Lang, t}; | 41 | use crate::i18n::{self, Key, Lang, t}; |
| 42 | use crate::pages::assets::highlight_css_text; | 42 | use crate::pages::assets::highlight_css_text; |
| 43 | use crate::pages::passkeys::s; | 43 | use crate::pages::passkeys::s; |
| 44 | -use crate::pages::user_prefs::{CORNER_POS, TREE_WIDTH, clean_pref}; | ||
| 45 | use crate::state::AppState; | 44 | use crate::state::AppState; |
| 46 | 45 | ||
| 47 | /// Stylesheet URL. The version is a hash of the compiled CSS (build.rs), so a changed stylesheet | 46 | /// 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] = &[ | |||
| 115 | "import", | 114 | "import", |
| 116 | "review-requests", | 115 | "review-requests", |
| 117 | "setup", | 116 | "setup", |
| 117 | + "needs-you", | ||
| 118 | + "verify", | ||
| 119 | + "reset", | ||
| 118 | "org", | 120 | "org", |
| 119 | ]; | 121 | ]; |
| 120 | 122 | ||
| @@ -183,15 +185,22 @@ fn path_segments(path: &str, title: &str) -> Vec<(String, Option<String>)> { | |||
| 183 | // Titles read "owner/repo · Page": the path bar has the repo already. A page titled by | 185 | // Titles read "owner/repo · Page": the path bar has the repo already. A page titled by |
| 184 | // the repo alone is named by its route. | 186 | // the repo alone is named by its route. |
| 185 | [_, ..] => { | 187 | [_, ..] => { |
| 186 | - let page = title.rsplit(" · ").next().unwrap_or(title); | 188 | + // A title ending in the repo plus a word ("Install · owner/repo wiki") reads by |
| 187 | - let page = if page == format!("{owner}/{repo}") { | 189 | + // the part before it. |
| 188 | - parts[2..] | 190 | + let full = format!("{owner}/{repo}"); |
| 191 | + let mut tail = title.rsplit(" · "); | ||
| 192 | + let named = match tail.next() { | ||
| 193 | + Some(last) if last == full => None, | ||
| 194 | + Some(last) if last.starts_with(&format!("{full} ")) => tail.next(), | ||
| 195 | + last => last, | ||
| 196 | + }; | ||
| 197 | + let page = match named { | ||
| 198 | + Some(page) => page.to_owned(), | ||
| 199 | + None => parts[2..] | ||
| 189 | .iter() | 200 | .iter() |
| 190 | .map(|part| crumb_label(part)) | 201 | .map(|part| crumb_label(part)) |
| 191 | .collect::<Vec<_>>() | 202 | .collect::<Vec<_>>() |
| 192 | - .join("/") | 203 | + .join("/"), |
| 193 | - } else { | ||
| 194 | - page.to_owned() | ||
| 195 | }; | 204 | }; |
| 196 | segments.push((page, None)); | 205 | segments.push((page, None)); |
| 197 | } | 206 | } |
| @@ -336,29 +345,14 @@ struct ProfileCorner { | |||
| 336 | failing_href: String, | 345 | failing_href: String, |
| 337 | } | 346 | } |
| 338 | 347 | ||
| 339 | -/// The floating account panel fixed at the bottom left of the window (signed in only). It opens | 348 | +/// The profile at the start of the top bar (signed in only): the avatar, with a dot when something |
| 340 | -/// upward: the avatar, the viewer's full name, the chips, the notifications bell with its unread count and popover, then | 349 | +/// waits. Its menu holds the name, notifications with their popover, what waits on the viewer, the |
| 341 | -/// the profile, settings, admin and log out links and the theme choice. | 350 | +/// profile, settings and admin links, the theme choice and log out. |
| 342 | #[component] | 351 | #[component] |
| 343 | async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> { | 352 | async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> { |
| 344 | - let review_chip = (corner.reviews > 0).then(|| { | 353 | + let review_chip = (corner.reviews > 0).then(|| mi::review_requests_count(lang, corner.reviews)); |
| 345 | - ( | 354 | + let mention_chip = (corner.mentions > 0).then(|| mi::mentions_count(lang, corner.mentions)); |
| 346 | - corner.reviews.to_string(), | 355 | + let failing_chip = (corner.failing > 0).then(|| mi::failing_runs_count(lang, corner.failing)); |
| 347 | - mi::review_requests_count(lang, corner.reviews), | ||
| 348 | - ) | ||
| 349 | - }); | ||
| 350 | - let mention_chip = (corner.mentions > 0).then(|| { | ||
| 351 | - ( | ||
| 352 | - corner.mentions.to_string(), | ||
| 353 | - mi::mentions_count(lang, corner.mentions), | ||
| 354 | - ) | ||
| 355 | - }); | ||
| 356 | - let failing_chip = (corner.failing > 0).then(|| { | ||
| 357 | - ( | ||
| 358 | - corner.failing.to_string(), | ||
| 359 | - mi::failing_runs_count(lang, corner.failing), | ||
| 360 | - ) | ||
| 361 | - }); | ||
| 362 | let bell_label = mi::t(lang, MK::AllNotifications); | 356 | let bell_label = mi::t(lang, MK::AllNotifications); |
| 363 | let theme_label = mi::t(lang, MK::ThemeLabel); | 357 | let theme_label = mi::t(lang, MK::ThemeLabel); |
| 364 | let match_label = mi::t(lang, MK::MatchSystem); | 358 | let match_label = mi::t(lang, MK::MatchSystem); |
| @@ -399,24 +393,49 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> | |||
| 399 | let loading_label = mi::t(lang, MK::PeekLoading); | 393 | let loading_label = mi::t(lang, MK::PeekLoading); |
| 400 | let error_label = mi::t(lang, MK::PeekError); | 394 | let error_label = mi::t(lang, MK::PeekError); |
| 401 | Ok(view! { | 395 | Ok(view! { |
| 402 | - <div class="corner-wrap"> | ||
| 403 | <details class="corner" data-unread-stream=""> | 396 | <details class="corner" data-unread-stream=""> |
| 404 | <summary class="corner-btn" aria-label=(corner.username.as_str())> | 397 | <summary class="corner-btn" aria-label=(corner.username.as_str())> |
| 405 | - <span class="corner-avatar"><img class="avatar avatar-sm" src=(corner.avatar.as_str()) alt="" width="28" height="28"></span> | 398 | + <img class="avatar corner-avatar" src=(corner.avatar.as_str()) alt="" width="32" height="32"> |
| 406 | - <span class="corner-name" title=(corner.username.as_str())>(corner.name.as_str())</span> | 399 | + </summary> |
| 407 | - <span class="corner-chips" data-review=(review_template.as_str()) data-review-one=(review_one.as_str()) data-mention=(mention_template.as_str()) data-mention-one=(mention_one.as_str()) data-failing=(failing_template.as_str()) data-failing-one=(failing_one.as_str())> | 400 | + <div class="corner-menu"> |
| 408 | - if let Some((count, title)) = review_chip { | 401 | + <p class="corner-who" title=(corner.username.as_str())>(corner.name.as_str())</p> |
| 409 | - <a class="chip chip-review" href=(corner.review_href.as_str()) title=(title.as_str())><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg>(count.as_str())</a> | 402 | + <a class="corner-link corner-bell" href="/notifications" title=(bell_label) aria-expanded="false"> |
| 403 | + <span>(bell_title)</span> | ||
| 404 | + if corner.unread > 0 { | ||
| 405 | + <span class="bell-count">(corner.unread.to_string())</span> | ||
| 410 | } | 406 | } |
| 411 | - if let Some((count, title)) = mention_chip { | 407 | + </a> |
| 412 | - <a class="chip chip-mention" href=(corner.mention_href.as_str()) title=(title.as_str())><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>(count.as_str())</a> | 408 | + <div class="bell-pop" popover="auto" role="dialog" aria-label=(bell_title) data-loading=(loading_label) data-error=(error_label)> |
| 409 | + <div class="bell-box"> | ||
| 410 | + <div class="bell-head"> | ||
| 411 | + <span>(bell_title)</span> | ||
| 412 | + <form method="post" action="/notifications/mark_all_read" class="bell-clear"> | ||
| 413 | + <input type="hidden" name="csrf" value=(corner.csrf.as_str())> | ||
| 414 | + <button type="submit" class="link-button" title=(clear_title)>(clear_label)</button> | ||
| 415 | + </form> | ||
| 416 | + </div> | ||
| 417 | + <div class="bell-list"></div> | ||
| 418 | + <a class="button small bell-open" href="/notifications">(open_label)</a> | ||
| 419 | + </div> | ||
| 420 | + </div> | ||
| 421 | + <div class="corner-chips" data-review=(review_template.as_str()) data-review-one=(review_one.as_str()) data-mention=(mention_template.as_str()) data-mention-one=(mention_one.as_str()) data-failing=(failing_template.as_str()) data-failing-one=(failing_one.as_str())> | ||
| 422 | + if let Some(title) = review_chip { | ||
| 423 | + <a class="corner-link chip-review" href=(corner.review_href.as_str())>(title.as_str())</a> | ||
| 413 | } | 424 | } |
| 414 | - if let Some((count, title)) = failing_chip { | 425 | + if let Some(title) = mention_chip { |
| 415 | - <a class="chip chip-failing" href=(corner.failing_href.as_str()) title=(title.as_str())><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg>(count.as_str())</a> | 426 | + <a class="corner-link chip-mention" href=(corner.mention_href.as_str())>(title.as_str())</a> |
| 416 | } | 427 | } |
| 417 | - </span> | 428 | + if let Some(title) = failing_chip { |
| 418 | - </summary> | 429 | + <a class="corner-link chip-failing" href=(corner.failing_href.as_str())>(title.as_str())</a> |
| 419 | - <div class="corner-menu"> | 430 | + } |
| 431 | + </div> | ||
| 432 | + <div class="corner-sep"></div> | ||
| 433 | + <a class="corner-link" href=(profile_href.as_str())>(profile_label)</a> | ||
| 434 | + <a class="corner-link" href="/settings/profile">(settings_label)</a> | ||
| 435 | + if corner.is_admin { | ||
| 436 | + <a class="corner-link" href="/admin/users">(admin_label)</a> | ||
| 437 | + } | ||
| 438 | + <div class="corner-sep"></div> | ||
| 420 | <div class="corner-theme"><span>(theme_label)</span> | 439 | <div class="corner-theme"><span>(theme_label)</span> |
| 421 | <form method="post" action="/-/theme" class="corner-theme-set" data-no-tick="true"> | 440 | <form method="post" action="/-/theme" class="corner-theme-set" data-no-tick="true"> |
| 422 | <input type="hidden" name="csrf" value=(corner.csrf.as_str())> | 441 | <input type="hidden" name="csrf" value=(corner.csrf.as_str())> |
| @@ -432,43 +451,19 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> | |||
| 432 | </button> | 451 | </button> |
| 433 | </form> | 452 | </form> |
| 434 | </div> | 453 | </div> |
| 435 | - <a class="corner-link" href=(profile_href.as_str())>(profile_label)</a> | ||
| 436 | - <a class="corner-link" href="/settings/profile">(settings_label)</a> | ||
| 437 | - if corner.is_admin { | ||
| 438 | - <a class="corner-link" href="/admin/users">(admin_label)</a> | ||
| 439 | - } | ||
| 440 | <form data-hard="true" method="post" action="/logout"> | 454 | <form data-hard="true" method="post" action="/logout"> |
| 441 | <input type="hidden" name="csrf" value=(corner.csrf.as_str())> | 455 | <input type="hidden" name="csrf" value=(corner.csrf.as_str())> |
| 442 | <button type="submit" class="corner-link link-button">(logout_label)</button> | 456 | <button type="submit" class="corner-link link-button">(logout_label)</button> |
| 443 | </form> | 457 | </form> |
| 444 | </div> | 458 | </div> |
| 445 | </details> | 459 | </details> |
| 446 | - <a class="corner-bell" href="/notifications" title=(bell_label) aria-label=(bell_label) aria-expanded="false"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg> | ||
| 447 | - if corner.unread > 0 { | ||
| 448 | - <span class="bell-count">(corner.unread.to_string())</span> | ||
| 449 | - } | ||
| 450 | - </a> | ||
| 451 | - <div class="bell-pop" popover="auto" role="dialog" aria-label=(bell_title) data-loading=(loading_label) data-error=(error_label)> | ||
| 452 | - <div class="bell-box"> | ||
| 453 | - <div class="bell-head"> | ||
| 454 | - <span>(bell_title)</span> | ||
| 455 | - <form method="post" action="/notifications/mark_all_read" class="bell-clear"> | ||
| 456 | - <input type="hidden" name="csrf" value=(corner.csrf.as_str())> | ||
| 457 | - <button type="submit" class="link-button" title=(clear_title)>(clear_label)</button> | ||
| 458 | - </form> | ||
| 459 | - </div> | ||
| 460 | - <div class="bell-list"></div> | ||
| 461 | - <a class="button bell-open" href="/notifications">(open_label)</a> | ||
| 462 | - </div> | ||
| 463 | - </div> | ||
| 464 | - </div> | ||
| 465 | }) | 460 | }) |
| 466 | } | 461 | } |
| 467 | 462 | ||
| 468 | -/// Page shell: sticky top bar (logo, path bar and, signed in, the live strip), the section sidebar | 463 | +/// Page shell: the top bar (profile, wordmark, path bar, Explore and, signed in, the live strip), |
| 469 | -/// on section pages, `child` as the page content, and for signed-in viewers the floating profile | 464 | +/// the section tabs on section pages, and `child` as the page content. A page's `.head` is placed |
| 470 | -/// corner fixed at the bottom left. `viewer` drives the chrome: the live strip and the profile | 465 | +/// above those tabs by the stylesheet, so a page only writes its head and its sheets. `viewer` |
| 471 | -/// corner when signed in; search, theme, Explore and Log in otherwise. `extra_stylesheet` adds one | 466 | +/// drives the chrome: the live strip and the profile when signed in; search, theme and Log in otherwise. `extra_stylesheet` adds one |
| 472 | /// more stylesheet link to the head (such as a repo's generated label colors). | 467 | /// more stylesheet link to the head (such as a repo's generated label colors). |
| 473 | #[component] | 468 | #[component] |
| 474 | pub async fn shell( | 469 | pub async fn shell( |
| @@ -506,14 +501,6 @@ pub async fn shell( | |||
| 506 | _ => None, | 501 | _ => None, |
| 507 | }; | 502 | }; |
| 508 | let banner = crate::pages::banner::current(__cx, prefs.as_ref()); | 503 | let banner = crate::pages::banner::current(__cx, prefs.as_ref()); |
| 509 | - let tree_w = prefs | ||
| 510 | - .as_ref() | ||
| 511 | - .and_then(|p| p.get(TREE_WIDTH)) | ||
| 512 | - .and_then(|v| clean_pref(TREE_WIDTH, v).ok().flatten()); | ||
| 513 | - let corner_pos = prefs | ||
| 514 | - .as_ref() | ||
| 515 | - .and_then(|p| p.get(CORNER_POS)) | ||
| 516 | - .and_then(|v| clean_pref(CORNER_POS, v).ok().flatten()); | ||
| 517 | let sound_attr = crate::pages::settings_appearance::sound_attr(prefs.as_ref()); | 504 | let sound_attr = crate::pages::settings_appearance::sound_attr(prefs.as_ref()); |
| 518 | let banner_back = back.clone().unwrap_or_else(|| "/".to_owned()); | 505 | let banner_back = back.clone().unwrap_or_else(|| "/".to_owned()); |
| 519 | let dismiss_label = crate::i18n::accounts::t(lang, crate::i18n::accounts::A::Dismiss); | 506 | let dismiss_label = crate::i18n::accounts::t(lang, crate::i18n::accounts::A::Dismiss); |
| @@ -583,12 +570,20 @@ pub async fn shell( | |||
| 583 | theme_state, | 570 | theme_state, |
| 584 | mi::t(lang, theme_next), | 571 | mi::t(lang, theme_next), |
| 585 | ); | 572 | ); |
| 586 | - let anonymous = viewer.is_none(); | ||
| 587 | - let search_label = o::t(lang, OK::SearchPublicRepos); | ||
| 588 | let palette_label = br::t(lang, br::K::PaletteOpen).to_owned(); | 573 | let palette_label = br::t(lang, br::K::PaletteOpen).to_owned(); |
| 589 | let explore_label = t(lang, Key::Explore); | 574 | let explore_label = t(lang, Key::Explore); |
| 590 | // The path bar: one segment per part of the request path, the last one unlinked. | 575 | // The path bar: one segment per part of the request path, the last one unlinked. |
| 591 | - let segments = path_segments(uri(__cx).path(), title); | 576 | + let mut segments = path_segments(uri(__cx).path(), title); |
| 577 | + // A page with no place of its own in the path, such as settings, names its section and itself. | ||
| 578 | + if segments.is_empty() { | ||
| 579 | + if let Some(section) = §ion { | ||
| 580 | + let first = section.items.first().map(|item| item.href.clone()); | ||
| 581 | + if section.title != title { | ||
| 582 | + segments.push((section.title.clone(), first)); | ||
| 583 | + } | ||
| 584 | + } | ||
| 585 | + segments.push((title.to_owned(), None)); | ||
| 586 | + } | ||
| 592 | let path_attr = segments | 587 | let path_attr = segments |
| 593 | .iter() | 588 | .iter() |
| 594 | .map(|(label, _)| label.as_str()) | 589 | .map(|(label, _)| label.as_str()) |
| @@ -641,10 +636,6 @@ pub async fn shell( | |||
| 641 | || "/notifications".to_owned(), | 636 | || "/notifications".to_owned(), |
| 642 | |(owner, repo, number)| repo_href(owner, repo, "ci", &format!("runs/{number}")), | 637 | |(owner, repo, number)| repo_href(owner, repo, "ci", &format!("runs/{number}")), |
| 643 | ); | 638 | ); |
| 644 | - // The corner's drag saves its position with this token, the same one the page's forms send. | ||
| 645 | - let prefs_csrf = viewer | ||
| 646 | - .map(|(_, session)| session.csrf_token.clone()) | ||
| 647 | - .unwrap_or_default(); | ||
| 648 | let corner = viewer.map(|(user, session)| ProfileCorner { | 639 | let corner = viewer.map(|(user, session)| ProfileCorner { |
| 649 | username: user.username.clone(), | 640 | username: user.username.clone(), |
| 650 | name: user | 641 | name: user |
| @@ -674,7 +665,7 @@ pub async fn shell( | |||
| 674 | <meta charset="utf-8"> | 665 | <meta charset="utf-8"> |
| 675 | <meta name="viewport" content="width=device-width, initial-scale=1"> | 666 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 676 | <meta name="referrer" content="same-origin"> | 667 | <meta name="referrer" content="same-origin"> |
| 677 | - <meta name="theme-color" content="#5f7f67"> | 668 | + <meta name="theme-color" content="#b44d1a"> |
| 678 | <meta name="apple-mobile-web-app-capable" content="yes"> | 669 | <meta name="apple-mobile-web-app-capable" content="yes"> |
| 679 | <link rel="manifest" href="/manifest.webmanifest"> | 670 | <link rel="manifest" href="/manifest.webmanifest"> |
| 680 | <link rel="apple-touch-icon" href="/assets/icons/apple-touch-icon.png"> | 671 | <link rel="apple-touch-icon" href="/assets/icons/apple-touch-icon.png"> |
| @@ -690,22 +681,17 @@ pub async fn shell( | |||
| 690 | } | 681 | } |
| 691 | <script src=(NAV_SCRIPT_HREF) defer="defer"></script> | 682 | <script src=(NAV_SCRIPT_HREF) defer="defer"></script> |
| 692 | </head> | 683 | </head> |
| 693 | - <body data-link-restarting=(lk::t(lang, LinkKey::Restarting)) data-link-back=(lk::t(lang, LinkKey::BackSubmit)) data-done-saved=(lk::t(lang, LinkKey::Saved)) data-done-ok=(lk::t(lang, LinkKey::Done)) data-draft-restored=(lk::t(lang, LinkKey::DraftRestored)) data-draft-discard=(lk::t(lang, LinkKey::DraftDiscard)) data-select-filter=(lk::t(lang, LinkKey::SelectFilter)) data-select-none=(lk::t(lang, LinkKey::SelectNone)) data-signed-in=(signed_in.then(|| "true".to_owned())) data-tree-w=(tree_w) data-corner-pos=(corner_pos)> | 684 | + <body data-link-restarting=(lk::t(lang, LinkKey::Restarting)) data-link-back=(lk::t(lang, LinkKey::BackSubmit)) data-done-saved=(lk::t(lang, LinkKey::Saved)) data-done-ok=(lk::t(lang, LinkKey::Done)) data-draft-restored=(lk::t(lang, LinkKey::DraftRestored)) data-draft-discard=(lk::t(lang, LinkKey::DraftDiscard)) data-select-filter=(lk::t(lang, LinkKey::SelectFilter)) data-select-none=(lk::t(lang, LinkKey::SelectNone)) data-signed-in=(signed_in.then(|| "true".to_owned()))> |
| 694 | <header class="topbar"> | 685 | <header class="topbar"> |
| 695 | <div class="top-start"> | 686 | <div class="top-start"> |
| 696 | - <a class="wordmark" href="/"> | 687 | + if let Some(corner) = corner { |
| 697 | - <svg class="ico wordmark-mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 19c0-7 5-12 14-13-1 9-6 14-13 14"/><path d="M5 19l6-6"/></svg> | 688 | + <div class="corner-float"> |
| 698 | - "forge" | 689 | + profile_corner(lang: lang, corner: corner) |
| 699 | - </a> | 690 | + </div> |
| 700 | - <a class="top-explore" href="/explore" title=(explore_label) aria-label=(explore_label)> | 691 | + } |
| 701 | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5z"/></svg> | 692 | + <a class="wordmark" href="/">"forge"</a> |
| 702 | - <span>(explore_label)</span> | ||
| 703 | - </a> | ||
| 704 | </div> | 693 | </div> |
| 705 | <nav class="pathbar" aria-label=(mi::t(lang, MK::BreadcrumbNav))> | 694 | <nav class="pathbar" aria-label=(mi::t(lang, MK::BreadcrumbNav))> |
| 706 | - if signed_in { | ||
| 707 | - <svg class="ico pathbar-ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> | ||
| 708 | - } | ||
| 709 | <ol class="pathbar-segs"> | 695 | <ol class="pathbar-segs"> |
| 710 | for crumb in crumbs.iter() { | 696 | for crumb in crumbs.iter() { |
| 711 | if let Some(href) = &crumb.href { | 697 | if let Some(href) = &crumb.href { |
| @@ -733,6 +719,7 @@ pub async fn shell( | |||
| 733 | </button> | 719 | </button> |
| 734 | } | 720 | } |
| 735 | </nav> | 721 | </nav> |
| 722 | + <a class="top-explore" href="/explore">(explore_label)</a> | ||
| 736 | if signed_in { | 723 | if signed_in { |
| 737 | <div class="live-strip" data-activity="/-/activity" data-passed=(mi::t(lang, MK::Passed)) data-failed=(mi::t(lang, MK::Failed)) data-cancelled=(mi::t(lang, MK::Cancelled)) | 724 | <div class="live-strip" data-activity="/-/activity" data-passed=(mi::t(lang, MK::Passed)) data-failed=(mi::t(lang, MK::Failed)) data-cancelled=(mi::t(lang, MK::Cancelled)) |
| 738 | data-count-running=(running_tpl.as_str()) data-count-failed=(failed_tpl.as_str()) data-count-passed=(passed_tpl.as_str()) data-count-cancelled=(cancelled_tpl.as_str()) | 725 | data-count-running=(running_tpl.as_str()) data-count-failed=(failed_tpl.as_str()) data-count-passed=(passed_tpl.as_str()) data-count-cancelled=(cancelled_tpl.as_str()) |
| @@ -754,10 +741,6 @@ pub async fn shell( | |||
| 754 | } | 741 | } |
| 755 | </div> | 742 | </div> |
| 756 | } else { | 743 | } else { |
| 757 | - <form class="top-search" role="search" method="get" action="/explore"> | ||
| 758 | - <svg class="ico top-search-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> | ||
| 759 | - <input type="search" name="q" data-live-search="" autocomplete="off" placeholder=(search_label) aria-label=(search_label)> | ||
| 760 | - </form> | ||
| 761 | <form class="theme-form" method="post" action="/-/theme"> | 744 | <form class="theme-form" method="post" action="/-/theme"> |
| 762 | if let Some(csrf) = theme_csrf { | 745 | if let Some(csrf) = theme_csrf { |
| 763 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 746 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| @@ -795,33 +778,12 @@ pub async fn shell( | |||
| 795 | <div class="shell-body"> | 778 | <div class="shell-body"> |
| 796 | <main tabindex="-1" data-width=(width)> | 779 | <main tabindex="-1" data-width=(width)> |
| 797 | if let Some(section) = section { | 780 | if let Some(section) = section { |
| 798 | - section_tabs(label: section.title.as_str(), items: section.items, current: section.current, live: section.live) | 781 | + section_tabs(key: section.key, label: section.title.as_str(), items: section.items, current: section.current, live: section.live) |
| 799 | } | 782 | } |
| 800 | (child) | 783 | (child) |
| 801 | </main> | 784 | </main> |
| 802 | - <footer class="site-footer"> | ||
| 803 | - <span>"forge"</span> | ||
| 804 | - if anonymous { | ||
| 805 | - <form method="post" action="/-/theme" class="theme-picker"> | ||
| 806 | - <label> | ||
| 807 | - <span>(mi::t(lang, MK::ThemeLabel))</span> | ||
| 808 | - <select name="theme"> | ||
| 809 | - <option value="auto">(mi::t(lang, MK::MatchSystem))</option> | ||
| 810 | - <option value="light">(mi::t(lang, MK::Light))</option> | ||
| 811 | - <option value="dark">(mi::t(lang, MK::Dark))</option> | ||
| 812 | - </select> | ||
| 813 | - </label> | ||
| 814 | - <button type="submit" class="link-button">(mi::t(lang, MK::ApplyTheme))</button> | ||
| 815 | - </form> | ||
| 816 | - } | ||
| 817 | - </footer> | ||
| 818 | </div> | 785 | </div> |
| 819 | </div> | 786 | </div> |
| 820 | - if let Some(corner) = corner { | ||
| 821 | - <div class="corner-float" data-prefs-csrf=(prefs_csrf.as_str())> | ||
| 822 | - profile_corner(lang: lang, corner: corner) | ||
| 823 | - </div> | ||
| 824 | - } | ||
| 825 | </body> | 787 | </body> |
| 826 | </html> | 788 | </html> |
| 827 | } | 789 | } |
| @@ -841,6 +803,8 @@ pub struct NavItem { | |||
| 841 | /// A section's tabs: the admin area or the user's settings, one row of text links above the page. | 803 | /// A section's tabs: the admin area or the user's settings, one row of text links above the page. |
| 842 | #[derive(Clone)] | 804 | #[derive(Clone)] |
| 843 | pub struct Section { | 805 | pub struct Section { |
| 806 | + /// `admin` or `settings`: what the stylesheet keys on, the same in every language. | ||
| 807 | + pub key: &'static str, | ||
| 844 | pub title: String, | 808 | pub title: String, |
| 845 | pub items: Vec<NavItem>, | 809 | pub items: Vec<NavItem>, |
| 846 | pub current: &'static str, | 810 | pub current: &'static str, |
| @@ -1008,9 +972,9 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { | |||
| 1008 | let mut parts = path.trim_matches('/').split('/'); | 972 | let mut parts = path.trim_matches('/').split('/'); |
| 1009 | let first = parts.next()?; | 973 | let first = parts.next()?; |
| 1010 | let second = parts.next().unwrap_or(""); | 974 | let second = parts.next().unwrap_or(""); |
| 1011 | - let (title, items) = match first { | 975 | + let (key, title, items) = match first { |
| 1012 | - "admin" => (ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), | 976 | + "admin" => ("admin", ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), |
| 1013 | - "settings" => (o::t(lang, OK::Settings).to_owned(), settings_items(lang)), | 977 | + "settings" => ("settings", o::t(lang, OK::Settings).to_owned(), settings_items(lang)), |
| 1014 | _ => return None, | 978 | _ => return None, |
| 1015 | }; | 979 | }; |
| 1016 | let second = match second { | 980 | let second = match second { |
| @@ -1029,6 +993,7 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { | |||
| 1029 | "" | 993 | "" |
| 1030 | }; | 994 | }; |
| 1031 | Some(Section { | 995 | Some(Section { |
| 996 | + key, | ||
| 1032 | title, | 997 | title, |
| 1033 | items, | 998 | items, |
| 1034 | current, | 999 | current, |
| @@ -1039,6 +1004,7 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { | |||
| 1039 | /// One row of text tabs, with `aria-current="page"` on the current one. | 1004 | /// One row of text tabs, with `aria-current="page"` on the current one. |
| 1040 | #[component] | 1005 | #[component] |
| 1041 | async fn section_tabs( | 1006 | async fn section_tabs( |
| 1007 | + key: &'static str, | ||
| 1042 | label: &str, | 1008 | label: &str, |
| 1043 | items: Vec<NavItem>, | 1009 | items: Vec<NavItem>, |
| 1044 | current: &str, | 1010 | current: &str, |
| @@ -1053,7 +1019,7 @@ async fn section_tabs( | |||
| 1053 | }) | 1019 | }) |
| 1054 | .collect(); | 1020 | .collect(); |
| 1055 | Ok(view! { | 1021 | Ok(view! { |
| 1056 | - <nav class="tabs" aria-label=(label) data-live=(live)> | 1022 | + <nav class="tabs" aria-label=(label) data-section=(key) data-live=(live)> |
| 1057 | for (item, on) in links.into_iter() { | 1023 | for (item, on) in links.into_iter() { |
| 1058 | <a href=(item.href) aria-current=(on.then_some("page"))>(item.label)</a> | 1024 | <a href=(item.href) aria-current=(on.then_some("page"))>(item.label)</a> |
| 1059 | } | 1025 | } |
| @@ -1160,7 +1126,7 @@ pub async fn security_headers(cx: &Cx, body: Body, next: Next<'_>) -> Result<Res | |||
| 1160 | next.run(cx, body).await | 1126 | next.run(cx, body).await |
| 1161 | } | 1127 | } |
| 1162 | 1128 | ||
| 1163 | -// Repo browsing helpers: URLs, times and sizes, and the shared breadcrumb, tabs and ref selector. | 1129 | +// Repo browsing helpers: URLs, times and sizes, and the shared tabs and ref selector. |
| 1164 | 1130 | ||
| 1165 | /// Percent-encodes everything except unreserved characters and `/`. | 1131 | /// Percent-encodes everything except unreserved characters and `/`. |
| 1166 | pub fn enc(s: &str) -> String { | 1132 | pub fn enc(s: &str) -> String { |
| @@ -1361,31 +1327,6 @@ pub fn human_size(lang: Lang, bytes: u64) -> String { | |||
| 1361 | } | 1327 | } |
| 1362 | } | 1328 | } |
| 1363 | 1329 | ||
| 1364 | -/// One breadcrumb segment. `href` is None for the current location. | ||
| 1365 | -pub struct Crumb { | ||
| 1366 | - pub label: String, | ||
| 1367 | - pub href: Option<String>, | ||
| 1368 | -} | ||
| 1369 | - | ||
| 1370 | -#[component] | ||
| 1371 | -pub async fn breadcrumb(lang: Lang, crumbs: Vec<Crumb>) -> Result<impl View> { | ||
| 1372 | - Ok(view! { | ||
| 1373 | - <nav class="crumbs" aria-label=(mi::t(lang, MK::BreadcrumbNav))> | ||
| 1374 | - <ol> | ||
| 1375 | - for crumb in crumbs.into_iter() { | ||
| 1376 | - <li> | ||
| 1377 | - if let Some(href) = crumb.href { | ||
| 1378 | - <a href=(href)>(crumb.label)</a> | ||
| 1379 | - } else { | ||
| 1380 | - <span aria-current="page">(crumb.label)</span> | ||
| 1381 | - } | ||
| 1382 | - </li> | ||
| 1383 | - } | ||
| 1384 | - </ol> | ||
| 1385 | - </nav> | ||
| 1386 | - }) | ||
| 1387 | -} | ||
| 1388 | - | ||
| 1389 | fn tab_class(on: bool) -> &'static str { | 1330 | fn tab_class(on: bool) -> &'static str { |
| 1390 | if on { "tab active" } else { "tab" } | 1331 | if on { "tab active" } else { "tab" } |
| 1391 | } | 1332 | } |
| @@ -1451,7 +1392,6 @@ pub async fn repo_tabs( | |||
| 1451 | Ok(view! { | 1392 | Ok(view! { |
| 1452 | <nav class="repo-tabs" aria-label=(g::t(lang, K::RepositoryNav))> | 1393 | <nav class="repo-tabs" aria-label=(g::t(lang, K::RepositoryNav))> |
| 1453 | <a class=(tab_class(code_on)) href=(home)> | 1394 | <a class=(tab_class(code_on)) href=(home)> |
| 1454 | - <span class="tab-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m16 18 6-6-6-6M8 6l-6 6 6 6"/></svg></span> | ||
| 1455 | (t(lang, Key::Code)) | 1395 | (t(lang, Key::Code)) |
| 1456 | </a> | 1396 | </a> |
| 1457 | <details class="menu tab-more"> | 1397 | <details class="menu tab-more"> |
| @@ -1466,49 +1406,43 @@ pub async fn repo_tabs( | |||
| 1466 | </div> | 1406 | </div> |
| 1467 | </details> | 1407 | </details> |
| 1468 | <a class=(tab_class(issues_on)) href=(issues)> | 1408 | <a class=(tab_class(issues_on)) href=(issues)> |
| 1469 | - <span class="tab-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="1"/></svg></span> | ||
| 1470 | (g::t(lang, K::TabIssues)) | 1409 | (g::t(lang, K::TabIssues)) |
| 1471 | if let Some(count) = issues_count { | 1410 | if let Some(count) = issues_count { |
| 1472 | " " <span class="tab-count" data-arrive=(count.as_str())>(count.as_str())</span> | 1411 | " " <span class="tab-count" data-arrive=(count.as_str())>(count.as_str())</span> |
| 1473 | } | 1412 | } |
| 1474 | </a> | 1413 | </a> |
| 1475 | <a class=(tab_class(pulls_on)) href=(pulls)> | 1414 | <a class=(tab_class(pulls_on)) href=(pulls)> |
| 1476 | - <span class="tab-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="6" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="18" r="3"/><path d="M6 9v6M18 15V9a3 3 0 0 0-3-3h-3"/></svg></span> | ||
| 1477 | (g::t(lang, K::TabPulls)) | 1415 | (g::t(lang, K::TabPulls)) |
| 1478 | if let Some(count) = pulls_count { | 1416 | if let Some(count) = pulls_count { |
| 1479 | " " <span class="tab-count" data-arrive=(count.as_str())>(count.as_str())</span> | 1417 | " " <span class="tab-count" data-arrive=(count.as_str())>(count.as_str())</span> |
| 1480 | } | 1418 | } |
| 1481 | </a> | 1419 | </a> |
| 1482 | <a class=(tab_class(ci_on)) href=(ci)> | 1420 | <a class=(tab_class(ci_on)) href=(ci)> |
| 1483 | - <span class="tab-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M10 8.5v7l5.5-3.5z"/></svg></span> | ||
| 1484 | (g::t(lang, K::TabCi)) | 1421 | (g::t(lang, K::TabCi)) |
| 1485 | </a> | 1422 | </a> |
| 1486 | if discussions { | 1423 | if discussions { |
| 1487 | <a class=(tab_class(discussions_on)) href=(discussions_tab)> | 1424 | <a class=(tab_class(discussions_on)) href=(discussions_tab)> |
| 1488 | - <span class="tab-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg></span> | ||
| 1489 | (g::t(lang, K::TabDiscussions)) | 1425 | (g::t(lang, K::TabDiscussions)) |
| 1490 | </a> | 1426 | </a> |
| 1491 | } | 1427 | } |
| 1492 | if wiki { | 1428 | if wiki { |
| 1493 | <a class=(tab_class(wiki_on)) href=(wiki_tab)> | 1429 | <a class=(tab_class(wiki_on)) href=(wiki_tab)> |
| 1494 | - <span class="tab-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M2 4h6a4 4 0 0 1 4 4v12a3 3 0 0 0-3-3H2zM22 4h-6a4 4 0 0 0-4 4v12a3 3 0 0 1 3-3h7z"/></svg></span> | ||
| 1495 | (g::t(lang, K::TabWiki)) | 1430 | (g::t(lang, K::TabWiki)) |
| 1496 | </a> | 1431 | </a> |
| 1497 | } | 1432 | } |
| 1498 | if security { | 1433 | if security { |
| 1499 | <a class=(tab_class(security_on)) href=(security_tab)> | 1434 | <a class=(tab_class(security_on)) href=(security_tab)> |
| 1500 | - <span class="tab-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg></span> | ||
| 1501 | (t(lang, Key::Security)) | 1435 | (t(lang, Key::Security)) |
| 1502 | </a> | 1436 | </a> |
| 1503 | } | 1437 | } |
| 1504 | if can_admin { | 1438 | if can_admin { |
| 1505 | <a class=(tab_class(settings_on)) href=(settings)> | 1439 | <a class=(tab_class(settings_on)) href=(settings)> |
| 1506 | - <span class="tab-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1 7 17M17 7l2.1-2.1"/></svg></span> | ||
| 1507 | (g::t(lang, K::TabSettings)) | 1440 | (g::t(lang, K::TabSettings)) |
| 1508 | </a> | 1441 | </a> |
| 1509 | } | 1442 | } |
| 1510 | </nav> | 1443 | </nav> |
| 1511 | - }) | 1444 | + } |
| 1445 | + .boxed()) | ||
| 1512 | } | 1446 | } |
| 1513 | 1447 | ||
| 1514 | /// A branch or tag in the ref switcher. `href` points at its root tree; `updated` is the commit | 1448 | /// A branch or tag in the ref switcher. `href` points at its root tree; `updated` is the commit |
| @@ -1901,10 +1835,10 @@ mod shell_tests { | |||
| 1901 | 1835 | ||
| 1902 | // An anonymous page renders the default colours. | 1836 | // An anonymous page renders the default colours. |
| 1903 | let tag = html_tag(&html); | 1837 | let tag = html_tag(&html); |
| 1904 | - assert!(tag.contains("data-accent-light=\"sage\""), "{tag}"); | 1838 | + assert!(tag.contains("data-accent-light=\"ember\""), "{tag}"); |
| 1905 | - assert!(tag.contains("data-accent-dark=\"sage\""), "{tag}"); | 1839 | + assert!(tag.contains("data-accent-dark=\"ember\""), "{tag}"); |
| 1906 | - assert!(tag.contains("data-base-light=\"fern\""), "{tag}"); | 1840 | + assert!(tag.contains("data-base-light=\"anvil\""), "{tag}"); |
| 1907 | - assert!(tag.contains("data-base-dark=\"fern\""), "{tag}"); | 1841 | + assert!(tag.contains("data-base-dark=\"anvil\""), "{tag}"); |
| 1908 | } | 1842 | } |
| 1909 | 1843 | ||
| 1910 | /// The `<html …>` start tag of a page. | 1844 | /// The `<html …>` start tag of a page. |
| @@ -1976,10 +1910,10 @@ mod shell_tests { | |||
| 1976 | ["removed-palette", "removed-palette", "x", "x"], | 1910 | ["removed-palette", "removed-palette", "x", "x"], |
| 1977 | ) | 1911 | ) |
| 1978 | .await; | 1912 | .await; |
| 1979 | - assert!(removed.contains("data-accent-light=\"sage\""), "{removed}"); | 1913 | + assert!(removed.contains("data-accent-light=\"ember\""), "{removed}"); |
| 1980 | - assert!(removed.contains("data-accent-dark=\"sage\""), "{removed}"); | 1914 | + assert!(removed.contains("data-accent-dark=\"ember\""), "{removed}"); |
| 1981 | - assert!(removed.contains("data-base-light=\"fern\""), "{removed}"); | 1915 | + assert!(removed.contains("data-base-light=\"anvil\""), "{removed}"); |
| 1982 | - assert!(removed.contains("data-base-dark=\"fern\""), "{removed}"); | 1916 | + assert!(removed.contains("data-base-dark=\"anvil\""), "{removed}"); |
| 1983 | // A removed preset (`ochre`, `mist`) falls back too, and a hue passes through as itself. | 1917 | // A removed preset (`ochre`, `mist`) falls back too, and a hue passes through as itself. |
| 1984 | let retired = html_tag_for_colours( | 1918 | let retired = html_tag_for_colours( |
| 1985 | &router, | 1919 | &router, |
| @@ -1989,10 +1923,10 @@ mod shell_tests { | |||
| 1989 | ["ochre", "terracotta", "mist", "stone"], | 1923 | ["ochre", "terracotta", "mist", "stone"], |
| 1990 | ) | 1924 | ) |
| 1991 | .await; | 1925 | .await; |
| 1992 | - assert!(retired.contains("data-accent-light=\"sage\""), "{retired}"); | 1926 | + assert!(retired.contains("data-accent-light=\"ember\""), "{retired}"); |
| 1993 | - assert!(retired.contains("data-accent-dark=\"sage\""), "{retired}"); | 1927 | + assert!(retired.contains("data-accent-dark=\"ember\""), "{retired}"); |
| 1994 | - assert!(retired.contains("data-base-light=\"fern\""), "{retired}"); | 1928 | + assert!(retired.contains("data-base-light=\"anvil\""), "{retired}"); |
| 1995 | - assert!(retired.contains("data-base-dark=\"fern\""), "{retired}"); | 1929 | + assert!(retired.contains("data-base-dark=\"anvil\""), "{retired}"); |
| 1996 | let hued = html_tag_for_colours( | 1930 | let hued = html_tag_for_colours( |
| 1997 | &router, | 1931 | &router, |
| 1998 | &store, | 1932 | &store, |
crates/forge-web/src/views/parts.rsmodified+149 -6
| @@ -1,12 +1,19 @@ | |||
| 1 | -//! The parts every page acts through: the two ways an action opens in place. See the page language | 1 | +//! The parts every page acts through: the ways an action opens in place. See the page language in |
| 2 | -//! in `style/_min.scss`. An action sits right under what it acts on, as a text link. | 2 | +//! `docs/ui-language.md`. |
| 3 | 3 | ||
| 4 | use topcoat::Result; | 4 | use topcoat::Result; |
| 5 | -use topcoat::view::{Child, View, component, view}; | 5 | +use topcoat::view::{Child, View, ViewExt, component, view}; |
| 6 | 6 | ||
| 7 | use crate::i18n::Lang; | 7 | use crate::i18n::Lang; |
| 8 | use crate::pages::passkeys::s; | 8 | use crate::pages::passkeys::s; |
| 9 | 9 | ||
| 10 | +/// The width class of a strip segment holding `part` of `total`: `fr1` to `fr40`, since a page may | ||
| 11 | +/// not set inline styles. A segment with nothing in it still shows. | ||
| 12 | +pub fn seg_fr(part: u64, total: u64) -> String { | ||
| 13 | + let n = (part.saturating_mul(40) + total / 2).checked_div(total).unwrap_or(1); | ||
| 14 | + format!("fr{}", n.clamp(1, 40)) | ||
| 15 | +} | ||
| 16 | + | ||
| 10 | /// A text link that opens its form in place, on its own line under the links beside it. `open` | 17 | /// A text link that opens its form in place, on its own line under the links beside it. `open` |
| 11 | /// starts it open, as a form sent back with an error must. | 18 | /// starts it open, as a form sent back with an error must. |
| 12 | #[component] | 19 | #[component] |
| @@ -46,9 +53,9 @@ pub async fn confirm_act( | |||
| 46 | if let Some(note) = note { | 53 | if let Some(note) = note { |
| 47 | <p class="hint">(note)</p> | 54 | <p class="hint">(note)</p> |
| 48 | } | 55 | } |
| 49 | - <div class="acts"> | 56 | + <div class="acts asks"> |
| 50 | - <button type="submit" class="act danger">(label)</button> | 57 | + <button type="submit" class="danger small">(label)</button> |
| 51 | - <button type="button" class="act quiet" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> | 58 | + <button type="button" class="act" data-close-details="">(s(lang, "Keep it", "Vazgeç"))</button> |
| 52 | </div> | 59 | </div> |
| 53 | </form> | 60 | </form> |
| 54 | </details> | 61 | </details> |
| @@ -73,3 +80,139 @@ pub async fn post_act( | |||
| 73 | </form> | 80 | </form> |
| 74 | }) | 81 | }) |
| 75 | } | 82 | } |
| 83 | + | ||
| 84 | +/// One piece of a head's sub line. Pieces are joined with a middle dot. | ||
| 85 | +#[derive(Clone, Default)] | ||
| 86 | +pub struct SubPart { | ||
| 87 | + pub text: String, | ||
| 88 | + pub href: Option<String>, | ||
| 89 | + /// `""`, `"mono"` for a hash or a number, `"b"` for the one piece that matters most. | ||
| 90 | + pub class: &'static str, | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +impl SubPart { | ||
| 94 | + pub fn text(text: impl Into<String>) -> Self { | ||
| 95 | + Self { | ||
| 96 | + text: text.into(), | ||
| 97 | + ..Self::default() | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + pub fn link(text: impl Into<String>, href: impl Into<String>) -> Self { | ||
| 102 | + Self { | ||
| 103 | + text: text.into(), | ||
| 104 | + href: Some(href.into()), | ||
| 105 | + ..Self::default() | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + pub fn mono(text: impl Into<String>) -> Self { | ||
| 110 | + Self { | ||
| 111 | + text: text.into(), | ||
| 112 | + class: "mono", | ||
| 113 | + ..Self::default() | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + pub fn strong(text: impl Into<String>) -> Self { | ||
| 118 | + Self { | ||
| 119 | + text: text.into(), | ||
| 120 | + class: "b", | ||
| 121 | + ..Self::default() | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | +} | ||
| 125 | + | ||
| 126 | +/// The line under a head's title. `pips` are recent runs, oldest first, as (href, title, class). | ||
| 127 | +#[component] | ||
| 128 | +pub async fn head_sub( | ||
| 129 | + parts: Vec<SubPart>, | ||
| 130 | + #[default] pips: Vec<(String, String, &'static str)>, | ||
| 131 | +) -> Result<impl View> { | ||
| 132 | + let last = pips.len().saturating_sub(1); | ||
| 133 | + let show = !parts.is_empty() || !pips.is_empty(); | ||
| 134 | + let has_pips = !pips.is_empty(); | ||
| 135 | + Ok(view! { | ||
| 136 | + if show { | ||
| 137 | + <p class="head-sub"> | ||
| 138 | + for (n, part) in parts.into_iter().enumerate() { | ||
| 139 | + if n > 0 { | ||
| 140 | + <span class="sep" aria-hidden="true">"·"</span> | ||
| 141 | + } | ||
| 142 | + if let Some(href) = part.href { | ||
| 143 | + <a class=(part.class) href=(href)>(part.text)</a> | ||
| 144 | + } else { | ||
| 145 | + <span class=(part.class)>(part.text)</span> | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + if has_pips { | ||
| 149 | + <span class="pips"> | ||
| 150 | + for (n, (href, title, class)) in pips.into_iter().enumerate() { | ||
| 151 | + <a class=(if n == last { format!("pip cur {class}") } else { format!("pip {class}") }) href=(href) title=(title.clone()) aria-label=(title)></a> | ||
| 152 | + } | ||
| 153 | + </span> | ||
| 154 | + } | ||
| 155 | + </p> | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + .boxed()) | ||
| 159 | +} | ||
| 160 | + | ||
| 161 | +/// What a page is, and what you can do about it, together: the title with the page's actions right | ||
| 162 | +/// beside it (`child`), then the sub line. Every page starts with one. Section tabs follow it. | ||
| 163 | +#[component] | ||
| 164 | +pub async fn head( | ||
| 165 | + title: &str, | ||
| 166 | + #[default] sub: Vec<SubPart>, | ||
| 167 | + #[default] live: Option<&str>, | ||
| 168 | + #[default] child: Child<'_>, | ||
| 169 | +) -> Result<impl View> { | ||
| 170 | + Ok(view! { | ||
| 171 | + <section class="head" data-live=(live)> | ||
| 172 | + <div class="head-title"> | ||
| 173 | + <h1>(title)</h1> | ||
| 174 | + (child) | ||
| 175 | + </div> | ||
| 176 | + head_sub(parts: sub) | ||
| 177 | + </section> | ||
| 178 | + } | ||
| 179 | + .boxed()) | ||
| 180 | +} | ||
| 181 | + | ||
| 182 | +/// One row of a rail. | ||
| 183 | +#[derive(Clone, Default)] | ||
| 184 | +pub struct RailItem { | ||
| 185 | + pub name: String, | ||
| 186 | + pub val: String, | ||
| 187 | + pub href: String, | ||
| 188 | + pub current: bool, | ||
| 189 | +} | ||
| 190 | + | ||
| 191 | +/// The rail: one list beside the sheet, never two. It scrolls on its own. `label` names it for | ||
| 192 | +/// screen readers, `heading` is the optional small heading above it. `child` goes between the two, | ||
| 193 | +/// for a filter. | ||
| 194 | +#[component] | ||
| 195 | +pub async fn rail( | ||
| 196 | + label: &str, | ||
| 197 | + items: Vec<RailItem>, | ||
| 198 | + #[default] heading: Option<&str>, | ||
| 199 | + #[default] child: Child<'_>, | ||
| 200 | +) -> Result<impl View> { | ||
| 201 | + Ok(view! { | ||
| 202 | + <nav class="rail" aria-label=(label)> | ||
| 203 | + if let Some(heading) = heading { | ||
| 204 | + <h2>(heading)</h2> | ||
| 205 | + } | ||
| 206 | + (child) | ||
| 207 | + <div class="rail-list"> | ||
| 208 | + for item in items.into_iter() { | ||
| 209 | + <a class="rail-item" href=(item.href) aria-current=(item.current.then_some("page"))> | ||
| 210 | + <span class="nm">(item.name)</span> | ||
| 211 | + <span class="val">(item.val)</span> | ||
| 212 | + </a> | ||
| 213 | + } | ||
| 214 | + </div> | ||
| 215 | + </nav> | ||
| 216 | + } | ||
| 217 | + .boxed()) | ||
| 218 | +} | ||
crates/forge-web/src/views/repo_list.rsmodified+4 -4
| @@ -81,13 +81,13 @@ pub struct SortLink { | |||
| 81 | #[component] | 81 | #[component] |
| 82 | pub async fn sort_chips(links: Vec<SortLink>, lang: Lang) -> Result<impl View> { | 82 | pub async fn sort_chips(links: Vec<SortLink>, lang: Lang) -> Result<impl View> { |
| 83 | Ok(view! { | 83 | Ok(view! { |
| 84 | - <nav class="sub" aria-label=(g::t(lang, K::SortNav))> | 84 | + <nav class="sort" aria-label=(g::t(lang, K::SortNav))> |
| 85 | - <span>(g::t(lang, K::SortBy))</span> | 85 | + <span class="hint">(g::t(lang, K::SortBy))</span> |
| 86 | for link in links.into_iter() { | 86 | for link in links.into_iter() { |
| 87 | if link.current { | 87 | if link.current { |
| 88 | - <span class="current" aria-current="true">(link.label)</span> | 88 | + <span class="act current" aria-current="true">(link.label)</span> |
| 89 | } else { | 89 | } else { |
| 90 | - <a href=(link.href.as_str())>(link.label)</a> | 90 | + <a class="act" href=(link.href.as_str())>(link.label)</a> |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| 93 | </nav> | 93 | </nav> |
crates/forge-web/src/views/review_thread.rsmodified+70 -103
| @@ -1,7 +1,7 @@ | |||
| 1 | //! One review thread: a root comment and its replies, with the path and line, badges, an optional | 1 | //! One review thread: a root comment and its replies, with the path and line, badges, an optional |
| 2 | //! diff hunk, and the reply and resolve controls. The Files tab renders it under its diff line; | 2 | //! diff hunk, and the reply and resolve controls. The Files tab renders it under its diff line; |
| 3 | //! the Conversation tab (`return_to = "conversation"`) renders it in the timeline. Resolved | 3 | //! the Conversation tab (`return_to = "conversation"`) renders it in the timeline. Resolved |
| 4 | -//! threads collapse into a `<details>`. Markup uses the `review-*` classes. | 4 | +//! threads collapse into a `<details>`. The comments sit in one `.thread`, one block per comment. |
| 5 | 5 | ||
| 6 | use std::collections::HashMap; | 6 | use std::collections::HashMap; |
| 7 | use std::sync::Arc; | 7 | use std::sync::Arc; |
| @@ -15,7 +15,7 @@ use crate::i18n::Lang; | |||
| 15 | use crate::i18n::pulls_review::{self as g, K}; | 15 | use crate::i18n::pulls_review::{self as g, K}; |
| 16 | use crate::pages::issue_parts::When; | 16 | use crate::pages::issue_parts::When; |
| 17 | use crate::render::markdown::{LinkContext, render_markdown}; | 17 | use crate::render::markdown::{LinkContext, render_markdown}; |
| 18 | -use crate::views::parts::{confirm_act, post_act}; | 18 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 19 | use crate::views::{avatar_url, display_name, now_unix, user_href, user_link}; | 19 | use crate::views::{avatar_url, display_name, now_unix, user_href, user_link}; |
| 20 | 20 | ||
| 21 | /// What the Apply control of a suggestion shows. A root without a state shows the diff only. | 21 | /// What the Apply control of a suggestion shows. A root without a state shows the diff only. |
| @@ -125,15 +125,13 @@ fn body_parts( | |||
| 125 | 125 | ||
| 126 | /// The controls and content of a thread, shared by the open and the collapsed (resolved) forms. | 126 | /// The controls and content of a thread, shared by the open and the collapsed (resolved) forms. |
| 127 | struct ThreadParts { | 127 | struct ThreadParts { |
| 128 | - location: String, | ||
| 129 | - outdated: bool, | ||
| 130 | - pending: bool, | ||
| 131 | hunk: Option<String>, | 128 | hunk: Option<String>, |
| 132 | comments: Vec<CommentRow>, | 129 | comments: Vec<CommentRow>, |
| 133 | resolve_action: Option<String>, | 130 | resolve_action: Option<String>, |
| 134 | resolve_value: String, | 131 | resolve_value: String, |
| 135 | resolve_label: String, | 132 | resolve_label: String, |
| 136 | reply_action: Option<String>, | 133 | reply_action: Option<String>, |
| 134 | + reply_id: String, | ||
| 137 | csrf: String, | 135 | csrf: String, |
| 138 | return_to: String, | 136 | return_to: String, |
| 139 | lang: Lang, | 137 | lang: Lang, |
| @@ -194,6 +192,7 @@ pub async fn review_thread_in( | |||
| 194 | let Thread { root, replies } = thread; | 192 | let Thread { root, replies } = thread; |
| 195 | let suggest = ctx.suggest.get(&root.id).copied(); | 193 | let suggest = ctx.suggest.get(&root.id).copied(); |
| 196 | let anchor = format!("rc-{}", root.id); | 194 | let anchor = format!("rc-{}", root.id); |
| 195 | + let reply_id = format!("reply-{}", root.id); | ||
| 197 | let location = format!("{}:{}", root.path, root.line); | 196 | let location = format!("{}:{}", root.path, root.line); |
| 198 | let hunk = (show_hunk && !root.diff_hunk.is_empty()).then(|| root.diff_hunk.clone()); | 197 | let hunk = (show_hunk && !root.diff_hunk.is_empty()).then(|| root.diff_hunk.clone()); |
| 199 | let resolved = root.resolved; | 198 | let resolved = root.resolved; |
| @@ -218,48 +217,59 @@ pub async fn review_thread_in( | |||
| 218 | .collect(); | 217 | .collect(); |
| 219 | 218 | ||
| 220 | let parts = ThreadParts { | 219 | let parts = ThreadParts { |
| 221 | - location: location.clone(), | ||
| 222 | - outdated, | ||
| 223 | - pending, | ||
| 224 | hunk, | 220 | hunk, |
| 225 | comments, | 221 | comments, |
| 226 | resolve_action, | 222 | resolve_action, |
| 227 | resolve_value: resolve_value.to_owned(), | 223 | resolve_value: resolve_value.to_owned(), |
| 228 | resolve_label: resolve_label.to_owned(), | 224 | resolve_label: resolve_label.to_owned(), |
| 229 | reply_action, | 225 | reply_action, |
| 226 | + reply_id, | ||
| 230 | csrf: ctx.csrf.clone(), | 227 | csrf: ctx.csrf.clone(), |
| 231 | return_to, | 228 | return_to, |
| 232 | lang, | 229 | lang, |
| 233 | }; | 230 | }; |
| 234 | 231 | ||
| 235 | // One `<details>` for every thread: open unless resolved, so a resolved thread starts | 232 | // One `<details>` for every thread: open unless resolved, so a resolved thread starts |
| 236 | - // collapsed and can still be expanded. | 233 | + // collapsed and can still be expanded. Its summary row carries the location and the badges. |
| 237 | let summary = if resolved { | 234 | let summary = if resolved { |
| 238 | g::resolved_conversation(lang, &location) | 235 | g::resolved_conversation(lang, &location) |
| 239 | } else { | 236 | } else { |
| 240 | location | 237 | location |
| 241 | }; | 238 | }; |
| 239 | + let outdated_text = g::t(lang, K::Outdated); | ||
| 240 | + let pending_text = g::t(lang, K::Pending); | ||
| 242 | Ok(view! { | 241 | Ok(view! { |
| 243 | - <details class="review-thread" id=(anchor.as_str()) open=(!resolved)> | 242 | + <details class="row-open review-thread" id=(anchor.as_str()) open=(!resolved)> |
| 244 | - <summary class="review-thread-summary">(summary.as_str())</summary> | 243 | + <summary class="line"> |
| 245 | - thread_parts(parts: parts) | 244 | + <span class="name">(summary.as_str())</span> |
| 245 | + <span class="val"> | ||
| 246 | + if outdated { | ||
| 247 | + <span class="badge">(outdated_text)</span> | ||
| 248 | + } | ||
| 249 | + if pending { | ||
| 250 | + <span class="badge">(pending_text)</span> | ||
| 251 | + } | ||
| 252 | + </span> | ||
| 253 | + </summary> | ||
| 254 | + <div class="opened"> | ||
| 255 | + thread_parts(parts: parts) | ||
| 256 | + </div> | ||
| 246 | </details> | 257 | </details> |
| 247 | }) | 258 | }) |
| 248 | } | 259 | } |
| 249 | 260 | ||
| 261 | +/// The diff hunk, the comments, then the thread's tools and reply form. Split into siblings so | ||
| 262 | +/// each component's view stays small enough to type-check. | ||
| 250 | #[component] | 263 | #[component] |
| 251 | async fn thread_parts(parts: ThreadParts) -> Result<impl View> { | 264 | async fn thread_parts(parts: ThreadParts) -> Result<impl View> { |
| 252 | - // Split into three siblings so each component's view stays small enough to type-check. | ||
| 253 | let ThreadParts { | 265 | let ThreadParts { |
| 254 | - location, | ||
| 255 | - outdated, | ||
| 256 | - pending, | ||
| 257 | hunk, | 266 | hunk, |
| 258 | comments, | 267 | comments, |
| 259 | resolve_action, | 268 | resolve_action, |
| 260 | resolve_value, | 269 | resolve_value, |
| 261 | resolve_label, | 270 | resolve_label, |
| 262 | reply_action, | 271 | reply_action, |
| 272 | + reply_id, | ||
| 263 | csrf, | 273 | csrf, |
| 264 | return_to, | 274 | return_to, |
| 265 | lang, | 275 | lang, |
| @@ -269,31 +279,39 @@ async fn thread_parts(parts: ThreadParts) -> Result<impl View> { | |||
| 269 | resolve_value, | 279 | resolve_value, |
| 270 | resolve_label, | 280 | resolve_label, |
| 271 | reply_action, | 281 | reply_action, |
| 282 | + reply_id, | ||
| 272 | csrf: csrf.clone(), | 283 | csrf: csrf.clone(), |
| 273 | return_to: return_to.clone(), | 284 | return_to: return_to.clone(), |
| 274 | lang, | 285 | lang, |
| 275 | }; | 286 | }; |
| 276 | Ok(view! { | 287 | Ok(view! { |
| 277 | - thread_top(location: location, outdated: outdated, pending: pending, hunk: hunk, lang: lang) | 288 | + if let Some(text) = hunk { |
| 278 | - for comment in comments.into_iter() { | 289 | + <pre class="review-hunk"><code>(text.as_str())</code></pre> |
| 279 | - thread_comment(comment: comment, csrf: csrf.clone(), return_to: return_to.clone(), | ||
| 280 | - lang: lang) | ||
| 281 | } | 290 | } |
| 291 | + <div class="thread"> | ||
| 292 | + for comment in comments.into_iter() { | ||
| 293 | + thread_comment(comment: comment, csrf: csrf.clone(), return_to: return_to.clone(), | ||
| 294 | + lang: lang) | ||
| 295 | + } | ||
| 296 | + </div> | ||
| 282 | thread_footer(footer: footer) | 297 | thread_footer(footer: footer) |
| 283 | }) | 298 | }) |
| 284 | } | 299 | } |
| 285 | 300 | ||
| 286 | -/// Actions and the reply form at the foot of a thread. | 301 | +/// Tools and the reply form at the foot of a thread. |
| 287 | struct ThreadFooter { | 302 | struct ThreadFooter { |
| 288 | resolve_action: Option<String>, | 303 | resolve_action: Option<String>, |
| 289 | resolve_value: String, | 304 | resolve_value: String, |
| 290 | resolve_label: String, | 305 | resolve_label: String, |
| 291 | reply_action: Option<String>, | 306 | reply_action: Option<String>, |
| 307 | + reply_id: String, | ||
| 292 | csrf: String, | 308 | csrf: String, |
| 293 | return_to: String, | 309 | return_to: String, |
| 294 | lang: Lang, | 310 | lang: Lang, |
| 295 | } | 311 | } |
| 296 | 312 | ||
| 313 | +/// The resolve button, and Reply, which opens its form in place. Each is empty when the viewer | ||
| 314 | +/// may not use it. | ||
| 297 | #[component] | 315 | #[component] |
| 298 | async fn thread_footer(footer: ThreadFooter) -> Result<impl View> { | 316 | async fn thread_footer(footer: ThreadFooter) -> Result<impl View> { |
| 299 | let ThreadFooter { | 317 | let ThreadFooter { |
| @@ -301,84 +319,33 @@ async fn thread_footer(footer: ThreadFooter) -> Result<impl View> { | |||
| 301 | resolve_value, | 319 | resolve_value, |
| 302 | resolve_label, | 320 | resolve_label, |
| 303 | reply_action, | 321 | reply_action, |
| 322 | + reply_id, | ||
| 304 | csrf, | 323 | csrf, |
| 305 | return_to, | 324 | return_to, |
| 306 | lang, | 325 | lang, |
| 307 | } = footer; | 326 | } = footer; |
| 327 | + let reply_label = g::t(lang, K::ReplyLabel); | ||
| 328 | + let reply_button = g::t(lang, K::ReplyButton); | ||
| 308 | Ok(view! { | 329 | Ok(view! { |
| 309 | - thread_actions(resolve_action: resolve_action, resolve_value: resolve_value, | 330 | + if let Some(action) = resolve_action { |
| 310 | - resolve_label: resolve_label, csrf: csrf.clone(), return_to: return_to.clone()) | 331 | + <div class="acts"> |
| 311 | - if let Some(action) = reply_action { | ||
| 312 | - reply_form(action: action, csrf: csrf, return_to: return_to, lang: lang) | ||
| 313 | - } | ||
| 314 | - }) | ||
| 315 | -} | ||
| 316 | - | ||
| 317 | -/// The header (path, line, badges) and the optional diff hunk. | ||
| 318 | -#[component] | ||
| 319 | -async fn thread_top( | ||
| 320 | - location: String, | ||
| 321 | - outdated: bool, | ||
| 322 | - pending: bool, | ||
| 323 | - hunk: Option<String>, | ||
| 324 | - lang: Lang, | ||
| 325 | -) -> Result<impl View> { | ||
| 326 | - let outdated_text = g::t(lang, K::Outdated); | ||
| 327 | - let pending_text = g::t(lang, K::Pending); | ||
| 328 | - Ok(view! { | ||
| 329 | - <header class="review-thread-head"> | ||
| 330 | - <code>(location.as_str())</code> | ||
| 331 | - if outdated { | ||
| 332 | - <span class="review-badge review-badge-outdated">(outdated_text)</span> | ||
| 333 | - } | ||
| 334 | - if pending { | ||
| 335 | - <span class="review-badge review-badge-pending">(pending_text)</span> | ||
| 336 | - } | ||
| 337 | - </header> | ||
| 338 | - if let Some(text) = hunk { | ||
| 339 | - <pre class="review-hunk"><code>(text.as_str())</code></pre> | ||
| 340 | - } | ||
| 341 | - }) | ||
| 342 | -} | ||
| 343 | - | ||
| 344 | -/// The resolve or unresolve button. Empty when the viewer may not resolve. | ||
| 345 | -#[component] | ||
| 346 | -async fn thread_actions( | ||
| 347 | - resolve_action: Option<String>, | ||
| 348 | - resolve_value: String, | ||
| 349 | - resolve_label: String, | ||
| 350 | - csrf: String, | ||
| 351 | - return_to: String, | ||
| 352 | -) -> Result<impl View> { | ||
| 353 | - Ok(view! { | ||
| 354 | - <div class="acts review-thread-actions"> | ||
| 355 | - if let Some(action) = resolve_action { | ||
| 356 | post_act(label: resolve_label.as_str(), action: action.as_str(), csrf: csrf.as_str(), | 332 | post_act(label: resolve_label.as_str(), action: action.as_str(), csrf: csrf.as_str(), |
| 357 | fields: vec![("resolved".to_owned(), resolve_value.clone()), ("return".to_owned(), return_to.clone())]) | 333 | fields: vec![("resolved".to_owned(), resolve_value.clone()), ("return".to_owned(), return_to.clone())]) |
| 358 | - } | 334 | + </div> |
| 359 | - </div> | 335 | + } |
| 360 | - }) | 336 | + if let Some(action) = reply_action { |
| 361 | -} | 337 | + reveal(label: reply_button, |
| 362 | - | 338 | + <form method="post" action=(action.as_str()) class="fields"> |
| 363 | -#[component] | 339 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 364 | -async fn reply_form( | 340 | + <input type="hidden" name="return" value=(return_to.as_str())> |
| 365 | - action: String, | 341 | + <div class="field"> |
| 366 | - csrf: String, | 342 | + <label for=(reply_id.as_str())>(reply_label)</label> |
| 367 | - return_to: String, | 343 | + <textarea id=(reply_id.as_str()) name="body" rows="3"></textarea> |
| 368 | - lang: Lang, | 344 | + </div> |
| 369 | -) -> Result<impl View> { | 345 | + <button type="submit" class="primary">(reply_button)</button> |
| 370 | - let label = g::t(lang, K::ReplyLabel); | 346 | + </form> |
| 371 | - let button = g::t(lang, K::ReplyButton); | 347 | + ) |
| 372 | - Ok(view! { | 348 | + } |
| 373 | - <form method="post" action=(action.as_str()) class="review-reply fields"> | ||
| 374 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 375 | - <input type="hidden" name="return" value=(return_to.as_str())> | ||
| 376 | - <label class="field"> | ||
| 377 | - <span>(label)</span> | ||
| 378 | - <textarea name="body" rows="3"></textarea> | ||
| 379 | - </label> | ||
| 380 | - <button type="submit" class="primary">(button)</button> | ||
| 381 | - </form> | ||
| 382 | }) | 349 | }) |
| 383 | } | 350 | } |
| 384 | 351 | ||
| @@ -405,15 +372,15 @@ async fn thread_comment( | |||
| 405 | let delete = g::t(lang, K::DeleteButton); | 372 | let delete = g::t(lang, K::DeleteButton); |
| 406 | let has_acts = edit_href.is_some() || delete_href.is_some(); | 373 | let has_acts = edit_href.is_some() || delete_href.is_some(); |
| 407 | Ok(view! { | 374 | Ok(view! { |
| 408 | - <article class="review-comment"> | 375 | + <div> |
| 409 | - <header class="review-comment-head"> | 376 | + <p class="who"> |
| 410 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> | 377 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> |
| 411 | - <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> | 378 | + user_link(shown: author.as_str(), login: login.as_str()) |
| 412 | - <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> | 379 | + <span><time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time></span> |
| 413 | if let Some(href) = history_href { | 380 | if let Some(href) = history_href { |
| 414 | - <a class="issue-edited" href=(href.as_str())>(edited)</a> | 381 | + <a class="act" href=(href.as_str())>(edited)</a> |
| 415 | } | 382 | } |
| 416 | - </header> | 383 | + </p> |
| 417 | for part in parts.into_iter() { | 384 | for part in parts.into_iter() { |
| 418 | comment_part(part: part, csrf: csrf.clone(), return_to: return_to.clone(), | 385 | comment_part(part: part, csrf: csrf.clone(), return_to: return_to.clone(), |
| 419 | lang: lang) | 386 | lang: lang) |
| @@ -429,7 +396,7 @@ async fn thread_comment( | |||
| 429 | } | 396 | } |
| 430 | </div> | 397 | </div> |
| 431 | } | 398 | } |
| 432 | - </article> | 399 | + </div> |
| 433 | }) | 400 | }) |
| 434 | } | 401 | } |
| 435 | 402 | ||
| @@ -458,11 +425,11 @@ async fn comment_part( | |||
| 458 | let added_sign = "+"; | 425 | let added_sign = "+"; |
| 459 | Ok(view! { | 426 | Ok(view! { |
| 460 | if !suggestion { | 427 | if !suggestion { |
| 461 | - <div class="markdown-body review-comment-body">(Unescaped::new_unchecked(html))</div> | 428 | + <div class="markdown-body">(Unescaped::new_unchecked(html))</div> |
| 462 | } | 429 | } |
| 463 | if suggestion { | 430 | if suggestion { |
| 464 | <div class="review-suggestion"> | 431 | <div class="review-suggestion"> |
| 465 | - <div class="review-suggestion-caption">(caption)</div> | 432 | + <p class="hint">(caption)</p> |
| 466 | if !old.is_empty() { | 433 | if !old.is_empty() { |
| 467 | <div class="review-suggestion-line del"><span class="review-suggestion-sign">(removed_sign)</span><code>(old.as_str())</code></div> | 434 | <div class="review-suggestion-line del"><span class="review-suggestion-sign">(removed_sign)</span><code>(old.as_str())</code></div> |
| 468 | } | 435 | } |
| @@ -470,13 +437,13 @@ async fn comment_part( | |||
| 470 | <div class="review-suggestion-line add"><span class="review-suggestion-sign">(added_sign)</span><code>(line.as_str())</code></div> | 437 | <div class="review-suggestion-line add"><span class="review-suggestion-sign">(added_sign)</span><code>(line.as_str())</code></div> |
| 471 | } | 438 | } |
| 472 | if let Some(action) = apply_action { | 439 | if let Some(action) = apply_action { |
| 473 | - <div class="acts review-suggestion-apply"> | 440 | + <div class="acts"> |
| 474 | post_act(label: apply_label, action: action.as_str(), csrf: csrf.as_str(), | 441 | post_act(label: apply_label, action: action.as_str(), csrf: csrf.as_str(), |
| 475 | fields: vec![("block".to_owned(), block.clone()), ("return".to_owned(), return_to.clone())]) | 442 | fields: vec![("block".to_owned(), block.clone()), ("return".to_owned(), return_to.clone())]) |
| 476 | </div> | 443 | </div> |
| 477 | } | 444 | } |
| 478 | if outdated { | 445 | if outdated { |
| 479 | - <p class="review-suggestion-outdated">(outdated_text)</p> | 446 | + <p class="hint">(outdated_text)</p> |
| 480 | } | 447 | } |
| 481 | </div> | 448 | </div> |
| 482 | } | 449 | } |
crates/forge-web/src/views/timeline.rsmodified+1 -1
| @@ -84,7 +84,7 @@ pub async fn history_strip( | |||
| 84 | Ok(view! { | 84 | Ok(view! { |
| 85 | if show { | 85 | if show { |
| 86 | <div class="history-strip"> | 86 | <div class="history-strip"> |
| 87 | - <p class="history-label label">(heading.as_str())</p> | 87 | + <p class="hint history-label">(heading.as_str())</p> |
| 88 | <div class="history-bars" role="group" aria-label=(aria)> | 88 | <div class="history-bars" role="group" aria-label=(aria)> |
| 89 | for item in items.iter() { | 89 | for item in items.iter() { |
| 90 | <a class=(item.class.as_str()) href=(item.href.as_str()) aria-label=(item.label.as_str()) title=(item.label.as_str()) data-oid=(item.oid.as_str()) data-arrive=(item.oid.as_str())></a> | 90 | <a class=(item.class.as_str()) href=(item.href.as_str()) aria-label=(item.label.as_str()) title=(item.label.as_str()) data-oid=(item.oid.as_str()) data-arrive=(item.oid.as_str())></a> |
crates/forge-web/src/web_push/mod.rsmodified+14 -1
| @@ -160,6 +160,11 @@ pub fn safe_url(url: &str) -> String { | |||
| 160 | 160 | ||
| 161 | /// A short label for a device, from its User-Agent: "Chrome on Android", "Safari on iPhone". | 161 | /// A short label for a device, from its User-Agent: "Chrome on Android", "Safari on iPhone". |
| 162 | pub fn agent_label(user_agent: &str) -> String { | 162 | pub fn agent_label(user_agent: &str) -> String { |
| 163 | + agent_label_in(Lang::En, user_agent) | ||
| 164 | +} | ||
| 165 | + | ||
| 166 | +/// [`agent_label`] in the viewer's language: "Chrome on Linux", "Linux üzerinde Chrome". | ||
| 167 | +pub fn agent_label_in(lang: Lang, user_agent: &str) -> String { | ||
| 163 | let os = if user_agent.contains("iPhone") { | 168 | let os = if user_agent.contains("iPhone") { |
| 164 | "iPhone" | 169 | "iPhone" |
| 165 | } else if user_agent.contains("iPad") { | 170 | } else if user_agent.contains("iPad") { |
| @@ -174,6 +179,8 @@ pub fn agent_label(user_agent: &str) -> String { | |||
| 174 | "ChromeOS" | 179 | "ChromeOS" |
| 175 | } else if user_agent.contains("Linux") { | 180 | } else if user_agent.contains("Linux") { |
| 176 | "Linux" | 181 | "Linux" |
| 182 | + } else if lang == Lang::Tr { | ||
| 183 | + "bilinmeyen sistem" | ||
| 177 | } else { | 184 | } else { |
| 178 | "Unknown system" | 185 | "Unknown system" |
| 179 | }; | 186 | }; |
| @@ -187,10 +194,16 @@ pub fn agent_label(user_agent: &str) -> String { | |||
| 187 | "Chrome" | 194 | "Chrome" |
| 188 | } else if user_agent.contains("Safari/") { | 195 | } else if user_agent.contains("Safari/") { |
| 189 | "Safari" | 196 | "Safari" |
| 197 | + } else if lang == Lang::Tr { | ||
| 198 | + "Tarayıcı" | ||
| 190 | } else { | 199 | } else { |
| 191 | "Browser" | 200 | "Browser" |
| 192 | }; | 201 | }; |
| 193 | - format!("{browser} on {os}") | 202 | + match lang { |
| 203 | + Lang::Tr if os == "bilinmeyen sistem" => format!("{browser}, {os}"), | ||
| 204 | + Lang::Tr => format!("{os} üzerinde {browser}"), | ||
| 205 | + Lang::En => format!("{browser} on {os}"), | ||
| 206 | + } | ||
| 194 | } | 207 | } |
| 195 | 208 | ||
| 196 | /// The HTTP client for push requests: the webhook outbound policy (no internal addresses, no | 209 | /// The HTTP client for push requests: the webhook outbound policy (no internal addresses, no |
docs/ui-language.mdadded+133 -0
| @@ -0,0 +1,133 @@ | |||
| 1 | +# Forge page language | ||
| 2 | + | ||
| 3 | +Every page follows this, with no exceptions. The look lives in one place, `style/_one.scss`, the parts | ||
| 4 | +in `crates/forge-web/src/views/parts.rs`. A page writes structure and classes only: no page has its | ||
| 5 | +own button, field, menu, tab, tag or box. If something does not fit, change the part, never the page. | ||
| 6 | + | ||
| 7 | +`scripts/audit/measure.ts` reads the computed look of every control on every page and reports anything | ||
| 8 | +outside this language. | ||
| 9 | + | ||
| 10 | +## A page | ||
| 11 | + | ||
| 12 | +`main` holds these and nothing else, in this order: | ||
| 13 | + | ||
| 14 | +1. **Head**: `<section class="head">`, written with `head(title: .., sub: .., <actions>)` or, in a repo, | ||
| 15 | + `repo_head(head: header, title: .., sub: .., <actions>)`. One visible `h1`. What the page is and what | ||
| 16 | + you can do about it sit together: the actions come right after the title, never at the far end. | ||
| 17 | +2. **Tabs**: `<nav class="tabs">`, the sections of the area you are in. Settings and admin get theirs from | ||
| 18 | + the shell, and a page's head goes above them by itself. A repo's are inside `repo_head`. | ||
| 19 | +3. **Strip** (`.strip`): only CI steps and files under review. It shows the whole thing and is how you | ||
| 20 | + move through it. Never on repo or settings pages. | ||
| 21 | +4. **Work**: one `.sheet`, or `.work` when the page has a list to pick from: | ||
| 22 | + `<div class="work"> rail(..) <div class="sheet">..</div> </div>`. | ||
| 23 | + | ||
| 24 | +Also allowed in `main`: `.state` and `.alert` for a message about the whole page. | ||
| 25 | + | ||
| 26 | +No visible title is ever missing, and no `h1 class="sr-only"`. No page sets a width: the sheet takes the | ||
| 27 | +room. A page without a sub-list has no rail. | ||
| 28 | + | ||
| 29 | +## The rail | ||
| 30 | + | ||
| 31 | +`rail(label: .., items: vec![RailItem { name, val, href, current }])`. It holds **one** list, never two. A | ||
| 32 | +long list scrolls by itself, with a filter input above it. One folder at a time; the path bar goes up. | ||
| 33 | +Sections never go in the rail: they go in `.tabs`. | ||
| 34 | + | ||
| 35 | +## The sheet | ||
| 36 | + | ||
| 37 | +`<div class="sheet">`, white, radius 16, hairline ring. Add `fit` for a sheet that should hug its content. | ||
| 38 | + | ||
| 39 | +- `<div class="sheet-tools"><strong>Name</strong> <a class="act">Tool</a> ...</div>`: 48px row, the name | ||
| 40 | + of what is showing and its quiet tools right after it. | ||
| 41 | +- `<section class="sec"><h2>Topic</h2> ... </section>`: one topic. Hairline between topics. | ||
| 42 | +- A list: rows, with no heading if the tools row names it. | ||
| 43 | +- The sheet holds the content. Nothing nests a box in a box: no `.card`, `.rows-pane`, `.fit-pane`, | ||
| 44 | + `.row-line`, `.row-field`, `.page-head`, sidebars or second columns. | ||
| 45 | + | ||
| 46 | +## Rows | ||
| 47 | + | ||
| 48 | +`<a class="line" data-kb-row=""><span class="name">..</span><span class="val">..</span></a>` when the item | ||
| 49 | +has its own page. When it opens in place: | ||
| 50 | + | ||
| 51 | +```html | ||
| 52 | +<details class="row-open"> | ||
| 53 | + <summary class="line"><span class="name">laptop</span><span class="val">SHA256:9fK2c1Qx</span></summary> | ||
| 54 | + <div class="opened">..</div> | ||
| 55 | +</details> | ||
| 56 | +``` | ||
| 57 | + | ||
| 58 | +Details come right after the title on one line. Nothing is pushed to the far end of a row: | ||
| 59 | +no `margin-left:auto`, no `justify-content:space-between`, no second column at the right. | ||
| 60 | + | ||
| 61 | +## Actions | ||
| 62 | + | ||
| 63 | +- **Button**: `<button>` (soft), `<button class="primary">` (filled), `.small`. A head holds the page's | ||
| 64 | + main action as `.primary` and its others as soft. A form's submit is `.primary`, once, under its fields. | ||
| 65 | + `a.button` for a link that acts like one. | ||
| 66 | +- **Tool**: `.act`, a quiet word (14px, dim, radius 12). `.act.danger` for destructive. This is what goes in | ||
| 67 | + tools rows, in rows and in `.acts`. | ||
| 68 | +- `reveal(label, id, open)`: a tool that opens its form in place. `open` when a form came back with an error. | ||
| 69 | +- `confirm_act(lang, label, action, csrf, fields, note)`: every destructive action. It always asks first, in | ||
| 70 | + place, with a small filled danger button and "Keep it". There are no one-click deletes. | ||
| 71 | +- `post_act(label, action, csrf, fields)`: a tool that posts at once, for what loses nothing. | ||
| 72 | +- No optimistic UI. Show done only after the server said so. | ||
| 73 | + | ||
| 74 | +## Forms | ||
| 75 | + | ||
| 76 | +```html | ||
| 77 | +<form class="fields"> | ||
| 78 | + <div class="field"><label for="x">Name</label><input id="x"><p class="hint">One line.</p></div> | ||
| 79 | + <button type="submit" class="primary">Save</button> | ||
| 80 | +</form> | ||
| 81 | +``` | ||
| 82 | + | ||
| 83 | +The label sits beside its control in one column, the hint after the control. `.field-pair` for two short | ||
| 84 | +fields. A checkbox is `<label class="switch"><input type="checkbox"><span>..</span></label>`, the box right | ||
| 85 | +before its label. Few fixed options are `.choice`: | ||
| 86 | + | ||
| 87 | +```html | ||
| 88 | +<div class="choice"><label><input type="radio" name="theme" value="auto" checked><span>Auto</span></label> ..</div> | ||
| 89 | +``` | ||
| 90 | + | ||
| 91 | +Longer lists are a `<select>`. Fields are soft filled shapes with no line around them. Every control has a | ||
| 92 | +label. Errors are `alert` at the top of the form they belong to, which stays open with the user's text. | ||
| 93 | + | ||
| 94 | +## Lists and search | ||
| 95 | + | ||
| 96 | +Every search bar is live: `data-live-search` on a real GET form's input in `.plain-search`. It sits in the | ||
| 97 | +tools row or above the rail's list. Filters are the rail, or `.tabs` when there are only a few. Pagers | ||
| 98 | +appear only when another page exists. An empty list is `.state` with one line and its action as `.act`. | ||
| 99 | + | ||
| 100 | +## Menus | ||
| 101 | + | ||
| 102 | +Every dropdown, menu, popover and hover panel is the same panel: `.menu-list`, `.pop-panel` or | ||
| 103 | +`.row-menu-panel`, radius 20, shadow and ring, rows 34px high. Instant, no animation. No browser | ||
| 104 | +triangles. It never leaves the window, on a phone either. | ||
| 105 | + | ||
| 106 | +## Colour | ||
| 107 | + | ||
| 108 | +Tokens only: `--bg`, `--surface`, `--surface-2`, `--text`, `--muted`, `--border`, `--border-strong`, `--accent`, | ||
| 109 | +`--accent-soft`, `--bad`, `--danger-bg`, `--add-bg`, `--del-bg`. Accent marks the one live or selected | ||
| 110 | +thing. Running colour is the accent. Passed is neutral. Failed is `--bad`. Cancelled is grey, never red. | ||
| 111 | +Added is blue and deleted is rose. Graphs use the same set: neutral marks, accent for now. | ||
| 112 | + | ||
| 113 | +## Type | ||
| 114 | + | ||
| 115 | +Figtree for words, IBM Plex Mono for hashes, numbers beside names, paths and logs. No uppercase, no | ||
| 116 | +letter-spacing, no Archivo. `h1` 26/34 bold; `h2` 13 semibold dim; body 15/22; tools 14; hints 13. | ||
| 117 | + | ||
| 118 | +## Words | ||
| 119 | + | ||
| 120 | +Short, plain, sentence case, no em dashes. All text goes through i18n, or | ||
| 121 | +`crate::pages::passkeys::s(lang, "English", "Türkçe")`, in proper Turkish ("çevrim içi" is two words). A | ||
| 122 | +Turkish page shows no English, an English page no Turkish. | ||
| 123 | + | ||
| 124 | +## Rules that stayed | ||
| 125 | + | ||
| 126 | +- No page transitions, no decorative motion. Live arrivals only, off for reduced motion. | ||
| 127 | +- CSP is strict: no inline style attributes, no inline script. | ||
| 128 | +- List rows carry `data-kb-row`. Live pages keep `data-live`, `data-arrive` and every data attribute | ||
| 129 | + nav.js reads. | ||
| 130 | +- Signed-in preferences live in the database. | ||
| 131 | +- A setting must visibly change something, or it goes. | ||
| 132 | +- A phone (390px) is one column: no sideways scroll, tabs scroll inside their row. | ||
| 133 | +- Pages fit one screen where they can: use tabs and the rail, not stacked unrelated topics. | ||
scripts/audit/measure.tsmodified+113 -54
| @@ -1,7 +1,8 @@ | |||
| 1 | #!/usr/bin/env bun | 1 | #!/usr/bin/env bun |
| 2 | -// Measures pages against the page language in a real headless browser. For every path and window it | 2 | +// Measures pages against docs/ui-language.md in a real headless browser. For every path and window it |
| 3 | -// checks the left edge, sideways overflow, controls past the column and old layout classes, then | 3 | +// reads the computed look of every control and checks it against the one set of shapes, sizes and |
| 4 | -// opens each menu and disclosure on the page and checks the panel stays in the window. | 4 | +// fonts, checks the page's skeleton, then opens each menu and disclosure on the page and checks the |
| 5 | +// panel keeps the one look and stays in the window. | ||
| 5 | // | 6 | // |
| 6 | // Usage: bun scripts/audit/measure.ts BASE SESSION_COOKIE PATHS_FILE OUT_DIR [--shots] [--menus] | 7 | // Usage: bun scripts/audit/measure.ts BASE SESSION_COOKIE PATHS_FILE OUT_DIR [--shots] [--menus] |
| 7 | // PATHS_FILE has one path a line. Results go to OUT_DIR/measure.json; shots to OUT_DIR/shots. | 8 | // PATHS_FILE has one path a line. Results go to OUT_DIR/measure.json; shots to OUT_DIR/shots. |
| @@ -14,12 +15,11 @@ const shots = process.argv.includes("--shots"); | |||
| 14 | const menus = process.argv.includes("--menus"); | 15 | const menus = process.argv.includes("--menus"); |
| 15 | const FLOATING = "details.menu, details.pins-menu, details.ref-select, details.clone, details.corner, details.strip-runs, details.row-menu, details.commit-status, details.reaction-picker"; | 16 | const FLOATING = "details.menu, details.pins-menu, details.ref-select, details.clone, details.corner, details.strip-runs, details.row-menu, details.commit-status, details.reaction-picker"; |
| 16 | const paths = readFileSync(pathsFile, "utf8").split("\n").map((l) => l.trim()).filter(Boolean); | 17 | const paths = readFileSync(pathsFile, "utf8").split("\n").map((l) => l.trim()).filter(Boolean); |
| 17 | -const windows = [ | 18 | +// AUDIT_WINDOWS=1440x900,390x844 picks the windows, AUDIT_THEME=dark the theme, AUDIT_LANG=tr the language. |
| 18 | - [1920, 1080], | 19 | +const windows = (process.env.AUDIT_WINDOWS ?? "1920x1080,2560x1440,390x844").split(",").map((w) => w.split("x").map(Number)); |
| 19 | - [2560, 1440], | 20 | +const theme = process.env.AUDIT_THEME ?? "light"; |
| 20 | - [390, 844], | 21 | +// A port of its own, so several audits can run at once without reading each other's browser. |
| 21 | -]; | 22 | +const PORT = Number(process.env.AUDIT_CDP_PORT) || 9400 + Math.floor(Math.random() * 500); |
| 22 | -const PORT = 9333; | ||
| 23 | 23 | ||
| 24 | // A __Host- cookie cannot live on plain http, so a small proxy adds it. Streams never end and would | 24 | // A __Host- cookie cannot live on plain http, so a small proxy adds it. Streams never end and would |
| 25 | // starve the browser's connections, so they answer at once. | 25 | // starve the browser's connections, so they answer at once. |
| @@ -36,6 +36,7 @@ const proxy = Bun.serve({ | |||
| 36 | const headers = new Headers(req.headers); | 36 | const headers = new Headers(req.headers); |
| 37 | headers.delete("host"); | 37 | headers.delete("host"); |
| 38 | if (cookie !== "-") headers.set("cookie", cookie); | 38 | if (cookie !== "-") headers.set("cookie", cookie); |
| 39 | + if (process.env.AUDIT_LANG) headers.set("accept-language", process.env.AUDIT_LANG); | ||
| 39 | const r = await fetch(forge + url.pathname + url.search, { method: req.method, headers, body: req.body, redirect: "manual" }); | 40 | const r = await fetch(forge + url.pathname + url.search, { method: req.method, headers, body: req.body, redirect: "manual" }); |
| 40 | const back = new Headers(r.headers); | 41 | const back = new Headers(r.headers); |
| 41 | back.delete("content-encoding"); | 42 | back.delete("content-encoding"); |
| @@ -107,64 +108,106 @@ async function shot(name: string) { | |||
| 107 | if (r?.data) await Bun.write(`${out}/shots/${name}.png`, Buffer.from(r.data, "base64")); | 108 | if (r?.data) await Bun.write(`${out}/shots/${name}.png`, Buffer.from(r.data, "base64")); |
| 108 | } | 109 | } |
| 109 | 110 | ||
| 110 | -// Runs in the page. Everything it reports is a broken rule. | 111 | +// Runs in the page. Everything it reports is a broken rule of docs/ui-language.md. |
| 111 | -const CHECK = `(() => { | 112 | +const DESIGN = `(() => { |
| 112 | const bad = []; | 113 | const bad = []; |
| 113 | - const main = document.querySelector('main'); | 114 | + const ALLOWED_FONT = new Set(['11','12','12.5','13','13.5','14','15','17','22','24','26']); |
| 114 | - if (!main) return ['no main']; | 115 | + const ALLOWED_RADIUS = new Set(['0','2','3','5','6','10','11','12','14','15','16','18','19','20','30','50%','999','9999']); |
| 115 | - const w = innerWidth; | 116 | + const seen = (e) => { const r = e.getBoundingClientRect(); return r.width > 0 && r.height > 0 && getComputedStyle(e).visibility !== 'hidden'; }; |
| 116 | - if (document.documentElement.scrollWidth > w + 1) { | 117 | + const name = (e) => e.tagName.toLowerCase() + (e.classList.length ? '.' + [...e.classList].join('.') : '') + ' < ' + (e.parentElement.classList[0] || e.parentElement.tagName.toLowerCase()); |
| 117 | - const over = [...main.querySelectorAll('*')].find((e) => e.getBoundingClientRect().right > w + 1 && !e.closest('pre, .diff, .table-scroll, [data-scroll-x]')); | 118 | + const num = (v) => String(Math.round(parseFloat(v) * 10) / 10); |
| 118 | - bad.push('sideways overflow ' + document.documentElement.scrollWidth + ' at ' + (over ? over.tagName + '.' + over.className : '?')); | 119 | + const px = (e) => { const c = getComputedStyle(e), r = e.getBoundingClientRect(); return { h: Math.round(r.height), r: c.borderTopLeftRadius.endsWith('%') ? c.borderTopLeftRadius : num(c.borderTopLeftRadius), fs: num(c.fontSize), w: c.fontWeight, ff: c.fontFamily, bg: c.backgroundColor, b: parseFloat(c.borderTopWidth) + parseFloat(c.borderLeftWidth) + parseFloat(c.borderRightWidth) + parseFloat(c.borderBottomWidth) }; }; |
| 120 | + const none = (bg) => bg === 'rgba(0, 0, 0, 0)' || bg === 'transparent'; | ||
| 121 | + // Every kind of control has these shapes and no others: height, radius, font size. | ||
| 122 | + const CONTROLS = [[38,'19','15'],[32,'15','13'],[32,'15','14'],[32,'16','14'],[30,'12','14'],[34,'12','14'],[28,'14','14'],[36,'18','14']]; | ||
| 123 | + const root = document.querySelector('main'); | ||
| 124 | + if (!root) return ['no main']; | ||
| 125 | + // The page's skeleton. | ||
| 126 | + // A live wrapper with display: contents is not a part of the page: its children are. | ||
| 127 | + const flat = (e) => [...e.children].flatMap((c) => getComputedStyle(c).display === 'contents' ? flat(c) : [c]); | ||
| 128 | + const parts = flat(root); | ||
| 129 | + const heads = parts.filter((c) => c.matches('.head')); | ||
| 130 | + if (heads.length !== 1 && !root.querySelector(':scope > .auth')) bad.push('page: ' + heads.length + ' heads'); | ||
| 131 | + const h1 = [...document.querySelectorAll('h1')].filter((h) => seen(h) && !h.closest('.markdown-body') && !h.classList.contains('sr-only')); | ||
| 132 | + if (h1.length !== 1) bad.push('page: ' + h1.length + ' visible h1'); | ||
| 133 | + for (const c of parts) { | ||
| 134 | + if (!c.matches('.head, .tabs, .sheet, .work, .state, .alert, .strip, .jobs, .diff-section, .auth, script, style, template, dialog, [hidden], svg, .recent-pushes') ) bad.push('page: stray child of main: ' + name(c)); | ||
| 119 | } | 135 | } |
| 120 | - const cs = getComputedStyle(main); | 136 | + // Every control, found by what it is and not by its class. |
| 121 | - const left = main.getBoundingClientRect().left + parseFloat(cs.paddingLeft); | 137 | + const scope = [...document.querySelectorAll('.topbar *, main *')]; |
| 122 | - const right = main.getBoundingClientRect().right - parseFloat(cs.paddingRight); | 138 | + for (const e of scope) { |
| 123 | - const bar = document.querySelector('.pathbar'); | 139 | + if (!seen(e) || e.closest('.markdown-body, pre, .sr-only, svg')) continue; |
| 124 | - if (w >= 900 && bar && Math.abs(bar.getBoundingClientRect().left - left) > 1) bad.push('edge: path bar ' + bar.getBoundingClientRect().left + ' main ' + left); | 140 | + const c = getComputedStyle(e); |
| 125 | - for (const e of main.querySelectorAll('a, button, input, select, textarea, summary')) { | 141 | + const p = px(e); |
| 126 | - const r = e.getBoundingClientRect(); | 142 | + const label = name(e); |
| 127 | - if (!r.width || e.closest('pre, [popover], .menu-list, .pop-panel, .corner-menu, .tabs, .sub, .repo-tabs, .profile-tabs, .heat-grid, details:not([open]) > :not(summary)')) continue; | 143 | + const tag = e.tagName; |
| 128 | - const where = ' in ' + (e.parentElement.className || e.parentElement.tagName) + ' < ' + (e.parentElement.parentElement.className || e.parentElement.parentElement.tagName); | 144 | + const isText = tag === 'INPUT' && !['checkbox','radio','color','file','range','hidden'].includes(e.type); |
| 129 | - if (r.right > right + 1) bad.push('past the column: ' + e.tagName + ' "' + (e.textContent || e.name || '').trim().slice(0, 30) + '" right ' + Math.round(r.right) + ' > ' + Math.round(right) + where); | 145 | + const isBtn = tag === 'BUTTON' || (tag === 'INPUT' && ['submit','button'].includes(e.type)) || e.matches('summary.button, a.button, summary.act, a.act'); |
| 130 | - if (r.left < left - 1) bad.push('left of the edge: ' + e.tagName + '.' + e.className + ' "' + (e.textContent || '').trim().slice(0, 30) + '"' + where); | 146 | + if (isBtn && !e.closest('.heat-grid, .corner-theme-set, .choice, .swatches, .colour-grid') && !e.matches('.icon-btn, .rail-item, .line, .corner-link, .swatch')) { |
| 131 | - } | 147 | + if (!CONTROLS.some(([h, r, fs]) => p.h === h && p.r === r && p.fs === fs)) bad.push('control shape ' + p.h + '/' + p.r + '/' + p.fs + ': ' + label); |
| 132 | - const width = main.dataset.width; | ||
| 133 | - if (width !== 'wide') { | ||
| 134 | - for (const c of ['card', 'rows-pane', 'row-line', 'fit-pane', 'page-head', 'row-field', 'side-link', 'settings-layout']) { | ||
| 135 | - const n = main.querySelectorAll('.' + c).length; | ||
| 136 | - if (n) bad.push('old layout .' + c + ' x' + n); | ||
| 137 | } | 148 | } |
| 138 | - } | 149 | + if (isText || tag === 'SELECT') { |
| 139 | - if (width !== 'wide') { | 150 | + // One height a place: 32 in a tools row, 36 in the top bar, 38 everywhere else. |
| 140 | - for (const e of main.querySelectorAll('div, section, article, ul, ol, form, aside, nav')) { | 151 | + const want = e.closest('.sheet-tools') ? 32 : e.closest('.topbar, .pathbar, .top-search') ? 36 : 38; |
| 141 | - const c = getComputedStyle(e); | 152 | + if (p.h !== want) bad.push('field height ' + p.h + ' (want ' + want + '): ' + label); |
| 142 | - const r = e.getBoundingClientRect(); | 153 | + if (p.b) bad.push('field border: ' + label); |
| 143 | - if (r.height < 64 || r.width < 200 || e.closest('pre, table, .copy-box, .heatmap, [popover], .menu-list, .pop-panel, .corner-menu, .diff-file, .snippet-files, details > .status-list')) continue; | 154 | + if (none(p.bg) && !e.closest('.plain-search, .top-search')) bad.push('field without fill: ' + label); |
| 144 | - const filled = c.backgroundColor !== 'rgba(0, 0, 0, 0)'; | ||
| 145 | - const boxed = parseFloat(c.borderTopWidth) > 0 && parseFloat(c.borderLeftWidth) > 0 && parseFloat(c.borderRightWidth) > 0; | ||
| 146 | - if (filled || boxed) bad.push('box: ' + e.tagName + '.' + String(e.className).slice(0, 40)); | ||
| 147 | } | 155 | } |
| 148 | - for (const e of main.querySelectorAll('select')) { | 156 | + if (tag === 'TEXTAREA' && p.b) bad.push('field border: ' + label); |
| 149 | - if (!e.closest('.field') && e.getBoundingClientRect().width > 320) bad.push('stretched select ' + (e.name || '')); | 157 | + if (tag === 'TEXTAREA' && p.r !== '12') bad.push('textarea radius ' + p.r + ': ' + label); |
| 158 | + if (!/figtree/i.test(p.ff) && !/plex/i.test(p.ff) && !e.matches('input[type=checkbox], input[type=radio]')) bad.push('font ' + p.ff.split(',')[0] + ': ' + label); | ||
| 159 | + if (e.childNodes.length && [...e.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim())) { | ||
| 160 | + if (!ALLOWED_FONT.has(p.fs)) bad.push('font size ' + p.fs + ': ' + label); | ||
| 161 | + if (c.textTransform === 'uppercase') bad.push('uppercase: ' + label); | ||
| 162 | + if (c.fontStretch !== '100%') bad.push('font stretch ' + c.fontStretch + ': ' + label); | ||
| 150 | } | 163 | } |
| 151 | - for (const e of main.querySelectorAll('label:not(.colour-choice):has(> input[type=checkbox], > input[type=radio])')) { | 164 | + if (!none(p.bg) || p.b) { |
| 152 | - const i = e.querySelector('input').getBoundingClientRect(); | 165 | + if (!ALLOWED_RADIUS.has(p.r) && !p.r.endsWith('%')) bad.push('radius ' + p.r + ': ' + label); |
| 153 | - const t = e.querySelector('span, small'); | ||
| 154 | - if (t && t.getBoundingClientRect().top >= i.bottom - 1) bad.push('tick above its label: ' + t.textContent.trim().slice(0, 30)); | ||
| 155 | } | 166 | } |
| 167 | + const sides = [c.borderTopWidth, c.borderRightWidth, c.borderBottomWidth, c.borderLeftWidth].filter((v) => parseFloat(v) > 0).length; | ||
| 168 | + if (sides === 4 && !e.closest('table') && !e.matches('input[type=checkbox], input[type=radio]')) bad.push('box border: ' + label); | ||
| 169 | + if (parseFloat(c.borderLeftWidth) >= 2 && sides === 1) bad.push('side stripe: ' + label); | ||
| 170 | + if (c.boxShadow !== 'none' && /\\) -?\\d+px -?\\d+px [1-9]\\d*px/.test(c.boxShadow) && !e.matches('.corner-menu, .menu-list, .pop-panel, .ref-menu, .row-menu-panel, .tab-more-list, .strip-list, .bell-box, .palette-box, .decide, .decide-panel, .status-list, .ci-pop')) bad.push('shadow: ' + label); | ||
| 171 | + } | ||
| 172 | + // A form's submit and its Cancel are one row: neither sits alone as a child of the fields. | ||
| 173 | + for (const e of root.querySelectorAll('.fields > a.act, .fields > button.act')) { | ||
| 174 | + if (seen(e)) bad.push('act outside its acts row: ' + name(e)); | ||
| 175 | + } | ||
| 176 | + // Field widths by kind, in a labelled field: a word 280, a sentence or more 560. | ||
| 177 | + for (const e of root.querySelectorAll('.field > input[type=text], .field > input[type=email], .field > input[type=password], .field > input[type=url], .field > input:not([type]), .field > textarea')) { | ||
| 178 | + if (!seen(e) || e.closest('.sheet-tools, .decide-panel, .review-inline-form')) continue; | ||
| 179 | + const w = Math.round(e.getBoundingClientRect().width); | ||
| 180 | + const room = Math.round(e.parentElement.getBoundingClientRect().width); | ||
| 181 | + const want = e.tagName === 'TEXTAREA' || e.matches('[name=title], [name=summary], [name=description]') ? 560 : 280; | ||
| 182 | + if (w !== want && w < room - 4) bad.push('field width ' + w + ' (want ' + want + '): ' + name(e)); | ||
| 183 | + } | ||
| 184 | + if (document.documentElement.scrollWidth > innerWidth + 1) { | ||
| 185 | + const over = [...root.querySelectorAll('*')].find((e) => e.getBoundingClientRect().right > innerWidth + 1 && !e.closest('pre, table, .diff, .log')); | ||
| 186 | + bad.push('sideways overflow ' + document.documentElement.scrollWidth + ' at ' + (over ? name(over) : '?')); | ||
| 156 | } | 187 | } |
| 157 | // A pane that lost its height: its content is there and nothing of it can be seen. | 188 | // A pane that lost its height: its content is there and nothing of it can be seen. |
| 158 | - for (const e of main.querySelectorAll('div, section, ul, ol, pre, article')) { | 189 | + for (const e of root.querySelectorAll('div, section, ul, ol, pre, article')) { |
| 159 | const r = e.getBoundingClientRect(); | 190 | const r = e.getBoundingClientRect(); |
| 160 | if (r.height >= 4 || r.width < 40 || e.closest('.sr-only, [hidden]') || !e.innerText?.trim()) continue; | 191 | if (r.height >= 4 || r.width < 40 || e.closest('.sr-only, [hidden]') || !e.innerText?.trim()) continue; |
| 161 | if (e.children.length === 1 && e.firstElementChild.matches('.sr-only')) continue; | 192 | if (e.children.length === 1 && e.firstElementChild.matches('.sr-only')) continue; |
| 162 | - if (getComputedStyle(e).display !== 'none') bad.push('collapsed: ' + e.tagName + '.' + String(e.className).slice(0, 40) + ' height ' + Math.round(r.height)); | 193 | + if (getComputedStyle(e).display !== 'none') bad.push('collapsed: ' + name(e)); |
| 163 | } | 194 | } |
| 164 | - for (const b of main.querySelectorAll('.acts > button:not(.act, .primary), .sec button.danger:not(.act)')) bad.push('button where a text link belongs: ' + b.textContent.trim().slice(0, 30)); | ||
| 165 | return [...new Set(bad)]; | 195 | return [...new Set(bad)]; |
| 166 | })()`; | 196 | })()`; |
| 167 | 197 | ||
| 198 | +// The rules a floating panel must keep, run while it is open. | ||
| 199 | +const PANEL = `((root) => { | ||
| 200 | + const bad = []; | ||
| 201 | + const shaped = (e) => { const c = getComputedStyle(e); return c.position === 'absolute' || c.position === 'fixed'; }; | ||
| 202 | + const panel = [...root.querySelectorAll('*')].find((e) => shaped(e) && e.getBoundingClientRect().width > 80 && !e.closest('summary')); | ||
| 203 | + if (panel) { | ||
| 204 | + const c = getComputedStyle(panel); | ||
| 205 | + if (c.borderTopLeftRadius !== '20px') bad.push('panel radius ' + c.borderTopLeftRadius + ': ' + panel.className); | ||
| 206 | + if (c.boxShadow === 'none') bad.push('panel without shadow: ' + panel.className); | ||
| 207 | + } | ||
| 208 | + return bad; | ||
| 209 | +})`; | ||
| 210 | + | ||
| 168 | // Opens each closed disclosure and popover in turn, checks its panel, shuts it. | 211 | // Opens each closed disclosure and popover in turn, checks its panel, shuts it. |
| 169 | const OPEN = `(async () => { | 212 | const OPEN = `(async () => { |
| 170 | const bad = []; | 213 | const bad = []; |
| @@ -184,6 +227,8 @@ const OPEN = `(async () => { | |||
| 184 | if (!r.width || !r.height || k.closest('pre')) continue; | 227 | if (!r.width || !r.height || k.closest('pre')) continue; |
| 185 | if (r.right > innerWidth + 1 || r.left < -1) { bad.push('open panel leaves the window: ' + (summary.textContent || '').trim().slice(0, 30) + ' at ' + k.tagName + '.' + k.className + ' ' + Math.round(r.left) + '-' + Math.round(r.right)); break; } | 228 | if (r.right > innerWidth + 1 || r.left < -1) { bad.push('open panel leaves the window: ' + (summary.textContent || '').trim().slice(0, 30) + ' at ' + k.tagName + '.' + k.className + ' ' + Math.round(r.left) + '-' + Math.round(r.right)); break; } |
| 186 | } | 229 | } |
| 230 | + bad.push(...${PANEL}(root)); | ||
| 231 | + bad.push(...(${PANEL})(root)); | ||
| 187 | if (document.documentElement.scrollWidth > innerWidth + 1) bad.push('opening makes the page wide: ' + (summary.textContent || '').trim().slice(0, 30)); | 232 | if (document.documentElement.scrollWidth > innerWidth + 1) bad.push('opening makes the page wide: ' + (summary.textContent || '').trim().slice(0, 30)); |
| 188 | } | 233 | } |
| 189 | if (e.tagName === 'DETAILS') { e.open = false; } else { document.querySelector(':popover-open')?.hidePopover(); } | 234 | if (e.tagName === 'DETAILS') { e.open = false; } else { document.querySelector(':popover-open')?.hidePopover(); } |
| @@ -195,6 +240,7 @@ const OPEN = `(async () => { | |||
| 195 | await send("Page.enable"); | 240 | await send("Page.enable"); |
| 196 | await send("Runtime.enable"); | 241 | await send("Runtime.enable"); |
| 197 | await send("Network.enable"); | 242 | await send("Network.enable"); |
| 243 | +await send("Emulation.setEmulatedMedia", { features: [{ name: "prefers-color-scheme", value: theme }] }); | ||
| 198 | mkdirSync(`${out}/shots`, { recursive: true }); | 244 | mkdirSync(`${out}/shots`, { recursive: true }); |
| 199 | const report: Record<string, string[]> = {}; | 245 | const report: Record<string, string[]> = {}; |
| 200 | let openedTotal = 0; | 246 | let openedTotal = 0; |
| @@ -202,10 +248,12 @@ for (const path of paths) { | |||
| 202 | for (const [width, height] of windows) { | 248 | for (const [width, height] of windows) { |
| 203 | await send("Emulation.setDeviceMetricsOverride", { width, height, deviceScaleFactor: 1, mobile: false }); | 249 | await send("Emulation.setDeviceMetricsOverride", { width, height, deviceScaleFactor: 1, mobile: false }); |
| 204 | await go(base + path); | 250 | await go(base + path); |
| 205 | - const bad: string[] = (await js(CHECK)) ?? ["page did not answer"]; | 251 | + // An account's own theme wins over the system's: the audit asks for the one it measures. |
| 252 | + if (process.env.AUDIT_THEME) await js(`document.documentElement.setAttribute('data-theme', ${JSON.stringify(theme)})`); | ||
| 253 | + const bad: string[] = (await js(DESIGN)) ?? ["page did not answer"]; | ||
| 206 | const code = await js("document.title"); | 254 | const code = await js("document.title"); |
| 207 | if (/not found|error/i.test(code ?? "")) bad.push("title: " + code); | 255 | if (/not found|error/i.test(code ?? "")) bad.push("title: " + code); |
| 208 | - const name = path.replace(/[^a-z0-9]+/gi, "_") + "_" + width; | 256 | + const name = path.replace(/[^a-z0-9]+/gi, "_").slice(0, 120) + "_" + width + (theme === "dark" ? "_dark" : ""); |
| 209 | if (shots) await shot(name); | 257 | if (shots) await shot(name); |
| 210 | // --menus: one shot per floating panel, open, for review by eye. | 258 | // --menus: one shot per floating panel, open, for review by eye. |
| 211 | if (menus) { | 259 | if (menus) { |
| @@ -229,5 +277,16 @@ for (const path of paths) { | |||
| 229 | 277 | ||
| 230 | proc.kill(); | 278 | proc.kill(); |
| 231 | writeFileSync(`${out}/measure.json`, JSON.stringify(report, null, 1)); | 279 | writeFileSync(`${out}/measure.json`, JSON.stringify(report, null, 1)); |
| 280 | +// The same problems grouped, worst first, with one page for each. | ||
| 281 | +const groups = new Map<string, { n: number; at: string }>(); | ||
| 282 | +for (const [view, list] of Object.entries(report)) { | ||
| 283 | + for (const line of list) { | ||
| 284 | + const g = groups.get(line) ?? { n: 0, at: view }; | ||
| 285 | + g.n++; | ||
| 286 | + groups.set(line, g); | ||
| 287 | + } | ||
| 288 | +} | ||
| 289 | +const sorted = [...groups].sort((a, b) => b[1].n - a[1].n).map(([line, g]) => `${String(g.n).padStart(4)} ${line} (${g.at})`); | ||
| 290 | +writeFileSync(`${out}/measure.txt`, sorted.join("\n") + "\n"); | ||
| 232 | console.log(`${paths.length} paths, ${paths.length * windows.length} views, ${openedTotal} panels opened, ${Object.keys(report).length} views with problems`); | 291 | console.log(`${paths.length} paths, ${paths.length * windows.length} views, ${openedTotal} panels opened, ${Object.keys(report).length} views with problems`); |
| 233 | process.exit(0); | 292 | process.exit(0); |
scripts/audit/mock.pyadded+194 -0
| @@ -0,0 +1,194 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +"""Fills a seeded audit server with what seed.py cannot make without real runners: runners in every | ||
| 3 | +state, a history of finished, failed, running and cancelled CI runs with steps and logs, and an hour of | ||
| 4 | +host samples behind the runner graphs. | ||
| 5 | + | ||
| 6 | +Usage: scripts/audit/mock.py OUT_DIR db with the server stopped, as it holds the database | ||
| 7 | + scripts/audit/mock.py OUT_DIR samples with the server up | ||
| 8 | +""" | ||
| 9 | +import hashlib | ||
| 10 | +import json | ||
| 11 | +import math | ||
| 12 | +import os | ||
| 13 | +import random | ||
| 14 | +import secrets | ||
| 15 | +import sqlite3 | ||
| 16 | +import sys | ||
| 17 | +import time | ||
| 18 | +import urllib.request | ||
| 19 | + | ||
| 20 | +out, phase = sys.argv[1], sys.argv[2] | ||
| 21 | +seed = json.load(open(os.path.join(out, "seed.json"))) | ||
| 22 | +data = os.path.join(out, "data") | ||
| 23 | +SECRET = "mock-runner-secret" | ||
| 24 | +random.seed(7) | ||
| 25 | +now = time.time() | ||
| 26 | + | ||
| 27 | + | ||
| 28 | +def stamp(t): | ||
| 29 | + return time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(t)) + ".000000000Z" | ||
| 30 | + | ||
| 31 | + | ||
| 32 | +def uid(): | ||
| 33 | + alphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ" | ||
| 34 | + return "01MOCK" + "".join(random.choice(alphabet) for _ in range(20)) | ||
| 35 | + | ||
| 36 | + | ||
| 37 | +def fill_database(): | ||
| 38 | + db = sqlite3.connect(os.path.join(data, "forge.db"), timeout=30) | ||
| 39 | + db.row_factory = sqlite3.Row | ||
| 40 | + # Runners: two online, one busy, one offline, one disabled. The mock ones go first: they are older | ||
| 41 | + # than the seeded runner, which is the one to keep. | ||
| 42 | + db.execute("delete from ci_runners where id like '01MOCK%'") | ||
| 43 | + first = db.execute("select id from ci_runners order by created_at limit 1").fetchone()["id"] | ||
| 44 | + db.execute( | ||
| 45 | + "update ci_runners set name='build-01', labels='[\"linux\",\"x86_64\",\"large\"]', secret_hash=?, last_seen_at=?," | ||
| 46 | + " reported_concurrency=4, reported_version='0.9.2', reported_cpus=16, reported_memory_bytes=68719476736," | ||
| 47 | + " reported_build='949180b', reported_memory_free=41000000000, reported_memory_budget=60000000000 where id=?", | ||
| 48 | + (hashlib.sha256(SECRET.encode()).hexdigest(), stamp(now - 3), first), | ||
| 49 | + ) | ||
| 50 | + runners = [first] | ||
| 51 | + for name, labels, seen, disabled, cpus, memory in [ | ||
| 52 | + ("build-02", '["linux","x86_64"]', now - 8, 0, 8, 34359738368), | ||
| 53 | + ("arm-builder", '["linux","arm64"]', now - 40, 0, 4, 17179869184), | ||
| 54 | + ("old-mac", '["macos","arm64"]', now - 86400 * 3, 0, 8, 17179869184), | ||
| 55 | + ("retired-box", '["linux","x86_64"]', now - 86400 * 20, 1, 2, 8589934592), | ||
| 56 | + ]: | ||
| 57 | + rid = uid() | ||
| 58 | + runners.append(rid) | ||
| 59 | + db.execute( | ||
| 60 | + "insert into ci_runners (id,name,labels,secret_hash,created_at,last_seen_at,disabled,reported_concurrency," | ||
| 61 | + "reported_version,reported_cpus,reported_memory_bytes) values (?,?,?,?,?,?,?,?,?,?,?)", | ||
| 62 | + (rid, name, labels, secrets.token_hex(32), stamp(now - 86400 * 40), stamp(seen), disabled, 2, "0.9.2", cpus, memory), | ||
| 63 | + ) | ||
| 64 | + | ||
| 65 | + # Runs: the newest last, as the numbers go up. | ||
| 66 | + repo = db.execute( | ||
| 67 | + "select r.id from repos r join users u on u.id=r.owner_id where r.name=? and u.username=?", | ||
| 68 | + (seed["repo"], seed["admin"]), | ||
| 69 | + ).fetchone()["id"] | ||
| 70 | + actor = db.execute("select id from users where username=?", (seed["admin"],)).fetchone()["id"] | ||
| 71 | + head = seed["head_oid"] | ||
| 72 | + first_oid = seed["first_oid"] | ||
| 73 | + db.execute("delete from ci_job_steps where job_id like '01MOCK%'") | ||
| 74 | + db.execute("delete from ci_jobs where id like '01MOCK%'") | ||
| 75 | + db.execute("delete from ci_runs where id like '01MOCK%'") | ||
| 76 | + number = (db.execute("select max(number) n from ci_runs where repo_id=?", (repo,)).fetchone()["n"] or 0) + 1 | ||
| 77 | + JOBS = { | ||
| 78 | + "test": ["Checkout", "Unit tests", "E2E tests"], | ||
| 79 | + "lint": ["Checkout", "Clippy", "Format"], | ||
| 80 | + "package": ["Build", "Package"], | ||
| 81 | + } | ||
| 82 | + PLAN = [ | ||
| 83 | + "success", "success", "failure", "success", "cancelled", "success", "success", "failure", | ||
| 84 | + "success", "success", "success", "running", | ||
| 85 | + ] | ||
| 86 | + LOG = """{step} | ||
| 87 | + Compiling forge-core v0.9.2 | ||
| 88 | + Compiling forge-git v0.9.2 | ||
| 89 | + Compiling forge-web v0.9.2 | ||
| 90 | + Finished `dev` profile in 41.08s | ||
| 91 | + Running unittests src/lib.rs | ||
| 92 | + running 214 tests | ||
| 93 | + test store::ci::tests::a_requeued_job_starts_with_no_steps ... ok | ||
| 94 | + test store::ci::tests::steps_take_the_jobs_result ... ok | ||
| 95 | + test wiki_e2e::follows_a_push ... {result} | ||
| 96 | + """ | ||
| 97 | + logs = os.path.join(data, "ci", "logs") | ||
| 98 | + os.makedirs(logs, exist_ok=True) | ||
| 99 | + failed_run = None | ||
| 100 | + running_run = None | ||
| 101 | + for i, state in enumerate(PLAN): | ||
| 102 | + start = now - (len(PLAN) - i) * 3600 * 2 | ||
| 103 | + run_id = uid() | ||
| 104 | + took = random.randint(420, 1500) | ||
| 105 | + finished = None if state == "running" else stamp(start + took) | ||
| 106 | + db.execute( | ||
| 107 | + "insert into ci_runs (id,repo_id,number,trigger,git_ref,commit_oid,actor_id,state,created_at,finished_at)" | ||
| 108 | + " values (?,?,?,?,?,?,?,?,?,?)", | ||
| 109 | + (run_id, repo, number, "push", "refs/heads/main", head if i % 2 else first_oid, actor, state, stamp(start), finished), | ||
| 110 | + ) | ||
| 111 | + if state == "failure": | ||
| 112 | + failed_run = number | ||
| 113 | + if state == "running": | ||
| 114 | + running_run = number | ||
| 115 | + start = now - 420 | ||
| 116 | + for j, (name, steps) in enumerate(JOBS.items()): | ||
| 117 | + job_id = uid() | ||
| 118 | + job_state = state | ||
| 119 | + if state == "failure" and name != "test": | ||
| 120 | + job_state = "success" if name == "lint" else "skipped" | ||
| 121 | + if state == "running" and name == "package": | ||
| 122 | + job_state = "blocked" | ||
| 123 | + if state == "running" and name == "lint": | ||
| 124 | + job_state = "success" | ||
| 125 | + began = start + j * 20 | ||
| 126 | + length = took // len(JOBS) | ||
| 127 | + ended = None if job_state in ("running", "blocked") else stamp(began + length) | ||
| 128 | + lines = [] | ||
| 129 | + offset = 0 | ||
| 130 | + step_rows = [] | ||
| 131 | + for k, step in enumerate(steps): | ||
| 132 | + step_start = began + k * length // len(steps) | ||
| 133 | + bad = job_state == "failure" and k == len(steps) - 1 | ||
| 134 | + live = job_state == "running" and k == len(steps) - 1 | ||
| 135 | + text = "::group::" + step + "\n" + LOG.format(step="$ " + step.lower(), result="FAILED" if bad else "ok") | ||
| 136 | + if bad: | ||
| 137 | + text += "error: stream closed before the push event arrived\n --> crates/forge-e2e/tests/e2e/wiki_e2e.rs:212:9\n" | ||
| 138 | + text += "::endgroup::\n" | ||
| 139 | + step_rows.append((job_id, k, step, stamp(step_start), None if live or bad else stamp(step_start + length // len(steps)), offset)) | ||
| 140 | + offset += len(text.encode()) | ||
| 141 | + lines.append(text) | ||
| 142 | + body = "".join(lines) if job_state not in ("blocked", "skipped") else "" | ||
| 143 | + db.execute( | ||
| 144 | + "insert into ci_jobs (id,run_id,name,spec,state,runner_id,exit_code,queued_at,started_at,finished_at,heartbeat_at,log_bytes,step_scanned)" | ||
| 145 | + " values (?,?,?,?,?,?,?,?,?,?,?,?,?)", | ||
| 146 | + (job_id, run_id, name, '{"image":"docker.io/library/rust:1","run":"cargo test","needs":[],"secrets":[],"env":{},"artifacts":[],"runs_on":[],"cache":[],"timeout_minutes":60,"network":true}', | ||
| 147 | + job_state, runners[j % 2] if job_state != "blocked" else None, 1 if job_state == "failure" else 0, stamp(began - 5), stamp(began), ended, | ||
| 148 | + stamp(now) if job_state == "running" else None, len(body.encode()), len(body.encode())), | ||
| 149 | + ) | ||
| 150 | + if body: | ||
| 151 | + db.executemany("insert into ci_job_steps (job_id,seq,name,started_at,finished_at,log_offset) values (?,?,?,?,?,?)", step_rows) | ||
| 152 | + with open(os.path.join(logs, job_id + ".log"), "w") as f: | ||
| 153 | + f.write(body) | ||
| 154 | + number += 1 | ||
| 155 | + db.commit() | ||
| 156 | + | ||
| 157 | + seed["runner_id"] = first | ||
| 158 | + seed["failed_run"] = failed_run | ||
| 159 | + seed["running_run"] = running_run | ||
| 160 | + seed["runners"] = runners | ||
| 161 | + json.dump(seed, open(os.path.join(out, "seed.json"), "w")) | ||
| 162 | + print(f"[mock] done: failed #{failed_run}, running #{running_run}") | ||
| 163 | + | ||
| 164 | + | ||
| 165 | +def send_samples(): | ||
| 166 | + # An hour of samples behind the graphs: the server keeps them in memory, so they go in as a runner's would. | ||
| 167 | + samples = [] | ||
| 168 | + for m in range(0, 3600, 10): | ||
| 169 | + t = now - 3600 + m | ||
| 170 | + wave = (math.sin(m / 400) + 1) / 2 | ||
| 171 | + samples.append({ | ||
| 172 | + "at_ms": int(t * 1000), | ||
| 173 | + "cpu_percent": round(15 + 70 * wave + random.uniform(-5, 5), 1), | ||
| 174 | + "mem_used_bytes": int((18 + 22 * wave) * 2**30), | ||
| 175 | + "mem_total_bytes": 64 * 2**30, | ||
| 176 | + "net_rx_bytes_per_s": int((2 + 40 * wave) * 2**20), | ||
| 177 | + "net_tx_bytes_per_s": int((1 + 12 * wave) * 2**20), | ||
| 178 | + "running_jobs": int(wave * 4), | ||
| 179 | + }) | ||
| 180 | + request = urllib.request.Request( | ||
| 181 | + seed["base"] + "/api/v1/ci/runners/metrics", | ||
| 182 | + json.dumps({"samples": samples}).encode(), | ||
| 183 | + {"Content-Type": "application/json", "Authorization": "Bearer " + SECRET}, | ||
| 184 | + ) | ||
| 185 | + try: | ||
| 186 | + print("[mock] samples", urllib.request.urlopen(request).status) | ||
| 187 | + except OSError as e: | ||
| 188 | + print("[mock] samples failed:", e) | ||
| 189 | + | ||
| 190 | + | ||
| 191 | +if phase == "db": | ||
| 192 | + fill_database() | ||
| 193 | +else: | ||
| 194 | + send_samples() | ||
scripts/audit/paths.pyadded+21 -0
| @@ -0,0 +1,21 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +"""Prints one path a line for every GET page, filled from seed.json, for scripts/audit/measure.ts. | ||
| 3 | + | ||
| 4 | +Usage: scripts/audit/paths.py OUT_DIR SRC_DIR | ||
| 5 | +""" | ||
| 6 | +import json | ||
| 7 | +import os | ||
| 8 | +import re | ||
| 9 | +import sys | ||
| 10 | + | ||
| 11 | +out, SRC = sys.argv[1], sys.argv[2] | ||
| 12 | +seed = json.load(open(os.path.join(out, "seed.json"))) | ||
| 13 | +# The route table lives in shoot.py, which also starts a browser when run, so only that part is taken. | ||
| 14 | +text = open(os.path.join(os.path.dirname(__file__), "shoot.py"), encoding="utf-8").read() | ||
| 15 | +exec(text[text.index("def discover():"): text.index("def slugify(")]) | ||
| 16 | +seen = [] | ||
| 17 | +for pat in discover(): | ||
| 18 | + for url, _ in concrete(pat): | ||
| 19 | + if url not in seen: | ||
| 20 | + seen.append(url) | ||
| 21 | +print("\n".join(seen)) | ||
scripts/audit/run.shmodified+4 -0
| @@ -65,6 +65,8 @@ transport = "log" | |||
| 65 | enabled = true | 65 | enabled = true |
| 66 | EOF | 66 | EOF |
| 67 | 67 | ||
| 68 | +# With --keep-data the seed is there already, so the mock data goes in before the server takes the database. | ||
| 69 | +[[ $KEEP == 1 ]] && python3 "$ROOT/scripts/audit/mock.py" "$OUT" db | ||
| 68 | echo "[run] starting forge on 127.0.0.1:$PORT" | 70 | echo "[run] starting forge on 127.0.0.1:$PORT" |
| 69 | "$BIN" --config "$OUT/forge.toml" > "$OUT/forge.log" 2>&1 & | 71 | "$BIN" --config "$OUT/forge.toml" > "$OUT/forge.log" 2>&1 & |
| 70 | FORGE_PID=$! | 72 | FORGE_PID=$! |
| @@ -89,6 +91,8 @@ if [[ $KEEP == 0 ]]; then | |||
| 89 | python3 "$ROOT/scripts/audit/seed.py" "http://127.0.0.1:$PORT" "$OUT" 2>&1 | tee "$OUT/seed.log" | 91 | python3 "$ROOT/scripts/audit/seed.py" "http://127.0.0.1:$PORT" "$OUT" 2>&1 | tee "$OUT/seed.log" |
| 90 | fi | 92 | fi |
| 91 | 93 | ||
| 94 | +[[ $KEEP == 1 ]] && python3 "$ROOT/scripts/audit/mock.py" "$OUT" samples | ||
| 95 | + | ||
| 92 | # AUDIT_SERVE=1 stops here and keeps the seeded server up, for scripts/audit/measure.ts. | 96 | # AUDIT_SERVE=1 stops here and keeps the seeded server up, for scripts/audit/measure.ts. |
| 93 | if [[ -n "${AUDIT_SERVE:-}" ]]; then | 97 | if [[ -n "${AUDIT_SERVE:-}" ]]; then |
| 94 | echo "[run] serving on http://127.0.0.1:$PORT" | 98 | echo "[run] serving on http://127.0.0.1:$PORT" |
style/_admin_rows.scssmodified+7 -5
| @@ -212,11 +212,13 @@ | |||
| 212 | opacity: 1; | 212 | opacity: 1; |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | -.mx-table summary { | 215 | +.mx-table > summary.act { |
| 216 | - margin-top: 6px; | 216 | + margin-left: -10px; |
| 217 | - color: var(--text-2); | 217 | + list-style: none; |
| 218 | - font-size: 0.8125rem; | 218 | + |
| 219 | - cursor: pointer; | 219 | + &::-webkit-details-marker { |
| 220 | + display: none; | ||
| 221 | + } | ||
| 220 | } | 222 | } |
| 221 | 223 | ||
| 222 | .mx-table-scroll { | 224 | .mx-table-scroll { |
style/_alive_head.scssdeleted+0 -83
| @@ -1,83 +0,0 @@ | |||
| 1 | -// alive_head: see memory design/ALIVE.md. | ||
| 2 | -// Repo head: the code-pages menu after the Code tab and the actions menu at the right end. Both | ||
| 3 | -// panels float over the page. The tab bar clips its overflow (it scrolls on narrow windows), so the | ||
| 4 | -// tab menu takes no position of its own: its panel is placed at its static position, and its | ||
| 5 | -// containing block is an ancestor outside the bar, which the bar does not clip. The page head has | ||
| 6 | -// no overflow rule, so the actions panel is not clipped either. | ||
| 7 | - | ||
| 8 | -// Code pages menu (Commits, Branches, Tags, Releases). | ||
| 9 | -.tab-more { | ||
| 10 | - position: static; | ||
| 11 | - flex: none; | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -.repo-tabs .tab-more-toggle { | ||
| 15 | - display: inline-flex; | ||
| 16 | - align-items: center; | ||
| 17 | - margin-left: -16px; | ||
| 18 | - padding: 0 2px; | ||
| 19 | - border: 0; | ||
| 20 | - border-radius: 0; | ||
| 21 | - list-style: none; | ||
| 22 | - cursor: pointer; | ||
| 23 | - | ||
| 24 | - &::-webkit-details-marker { | ||
| 25 | - display: none; | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - svg { | ||
| 29 | - width: 14px; | ||
| 30 | - height: 14px; | ||
| 31 | - fill: none; | ||
| 32 | - stroke: currentColor; | ||
| 33 | - stroke-width: 2; | ||
| 34 | - stroke-linecap: round; | ||
| 35 | - stroke-linejoin: round; | ||
| 36 | - } | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | -.tab-more[open] > .tab-more-toggle { | ||
| 40 | - color: var(--text); | ||
| 41 | -} | ||
| 42 | - | ||
| 43 | -.tab-more-list { | ||
| 44 | - position: absolute; | ||
| 45 | - z-index: 10; | ||
| 46 | - display: flex; | ||
| 47 | - flex-direction: column; | ||
| 48 | - min-width: 180px; | ||
| 49 | - margin-top: 6px; | ||
| 50 | - padding: 6px 0; | ||
| 51 | - background: var(--surface); | ||
| 52 | - border: 1px solid var(--border); | ||
| 53 | - border-radius: var(--radius-lg); | ||
| 54 | -} | ||
| 55 | - | ||
| 56 | -.tab-more-link { | ||
| 57 | - display: block; | ||
| 58 | - padding: 8px 14px; | ||
| 59 | - color: var(--muted); | ||
| 60 | - white-space: nowrap; | ||
| 61 | - text-decoration: none; | ||
| 62 | - | ||
| 63 | - &:hover { | ||
| 64 | - color: var(--text); | ||
| 65 | - text-decoration: none; | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - &.is-current { | ||
| 69 | - color: var(--text); | ||
| 70 | - font-weight: 600; | ||
| 71 | - } | ||
| 72 | -} | ||
| 73 | - | ||
| 74 | -.head-more-list { | ||
| 75 | - right: 0; | ||
| 76 | - display: flex; | ||
| 77 | - flex-direction: column; | ||
| 78 | - align-items: flex-start; | ||
| 79 | - gap: 10px; | ||
| 80 | - min-width: 240px; | ||
| 81 | - padding: 12px 14px; | ||
| 82 | -} | ||
| 83 | - | ||
style/_alive_heat.scssdeleted+0 -47
| @@ -1,47 +0,0 @@ | |||
| 1 | -// alive_heat: see memory design/ALIVE.md. | ||
| 2 | -// Heat as age. nav.js sets data-heat on a row from its newest time[data-rel]: 3 under an hour, | ||
| 3 | -// 2 under a day, 1 under a week, no attribute when older. Tone only: the name moves from --text-2 | ||
| 4 | -// (the floor, which passes 4.5:1 in both themes) towards --text. No accent, and the only motion | ||
| 5 | -// is the colour fade on the name. The hover colour of a tree name is restored at the end. | ||
| 6 | - | ||
| 7 | -// The base state, for every row in these lists: the name is --text-2. | ||
| 8 | -[data-kb-row] .commit-summary, | ||
| 9 | -.repo-item .repo-name, | ||
| 10 | -.pin-card .repo-name { | ||
| 11 | - color: var(--text-2); | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -@media (prefers-reduced-motion: no-preference) { | ||
| 15 | - [data-kb-row] .commit-summary, | ||
| 16 | - .repo-item .repo-name, | ||
| 17 | - .pin-card .repo-name { | ||
| 18 | - transition: color 1s; | ||
| 19 | - } | ||
| 20 | -} | ||
| 21 | - | ||
| 22 | -// Level 1: slightly brighter than the base. | ||
| 23 | -[data-kb-row][data-heat="1"] .commit-summary, | ||
| 24 | -.repo-item[data-heat="1"] .repo-name, | ||
| 25 | -.pin-card[data-heat="1"] .repo-name { | ||
| 26 | - color: color-mix(in srgb, var(--text) 30%, var(--text-2)); | ||
| 27 | -} | ||
| 28 | - | ||
| 29 | -// Level 2: brighter. | ||
| 30 | -[data-kb-row][data-heat="2"] .commit-summary, | ||
| 31 | -.repo-item[data-heat="2"] .repo-name, | ||
| 32 | -.pin-card[data-heat="2"] .repo-name { | ||
| 33 | - color: color-mix(in srgb, var(--text) 65%, var(--text-2)); | ||
| 34 | -} | ||
| 35 | - | ||
| 36 | -// Level 3: the newest rows. The name is --text and bold, and the time is --text. | ||
| 37 | -[data-kb-row][data-heat="3"] .commit-summary, | ||
| 38 | -.repo-item[data-heat="3"] .repo-name, | ||
| 39 | -.pin-card[data-heat="3"] .repo-name { | ||
| 40 | - color: var(--text); | ||
| 41 | - font-weight: 600; | ||
| 42 | -} | ||
| 43 | - | ||
| 44 | -[data-heat="3"] time[data-rel] { | ||
| 45 | - color: var(--text); | ||
| 46 | -} | ||
| 47 | - | ||
style/_alive_issue.scssdeleted+0 -8
| @@ -1,8 +0,0 @@ | |||
| 1 | -// alive_issue: see memory design/ALIVE.md. | ||
| 2 | - | ||
| 3 | -// A sidebar part whose form is on the wire: dimmed, no spinner. The swap that follows replaces it. | ||
| 4 | -.issue-side-section.is-pending, | ||
| 5 | -.issue-check.is-pending { | ||
| 6 | - opacity: 0.6; | ||
| 7 | - cursor: progress; | ||
| 8 | -} | ||
style/_alive_lists.scssdeleted+0 -26
| @@ -1,26 +0,0 @@ | |||
| 1 | - | ||
| 2 | - | ||
| 3 | -// Commit page: one line under the title holds the hash, signature, author, time, parents, checks | ||
| 4 | -// and the Browse files link. It wraps on a narrow window and never becomes a card. | ||
| 5 | -.commit-facts { | ||
| 6 | - display: flex; | ||
| 7 | - flex-wrap: wrap; | ||
| 8 | - align-items: center; | ||
| 9 | - gap: 6px 14px; | ||
| 10 | - margin: 0 0 12px; | ||
| 11 | - font-size: 0.875rem; | ||
| 12 | - line-height: 1.5; | ||
| 13 | - | ||
| 14 | - > .commit-hash { | ||
| 15 | - height: auto; | ||
| 16 | - padding: 2px 8px; | ||
| 17 | - border-radius: var(--radius-full); | ||
| 18 | - font-family: var(--mono); | ||
| 19 | - font-size: 0.8125rem; | ||
| 20 | - } | ||
| 21 | - | ||
| 22 | - > .checks-summary { | ||
| 23 | - flex: 0 0 auto; | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | -} | ||
style/_alive_motion.scssdeleted+0 -92
| @@ -1,92 +0,0 @@ | |||
| 1 | -// alive_motion: see memory design/ALIVE.md. Motion only where something real happened: an arrival after | ||
| 2 | -// a live update, the running bar's breath, a finished bar settling, and the CI tab's live dot. The | ||
| 3 | -// classes come from nav.js (`arrived`, `hs-settle`, `tab-live`); everything moves only when the reader | ||
| 4 | -// has not asked for less motion. | ||
| 5 | - | ||
| 6 | -@media (prefers-reduced-motion: no-preference) { | ||
| 7 | - @keyframes arrive-in { | ||
| 8 | - from { opacity: 0; transform: translateY(-6px); } | ||
| 9 | - to { opacity: 1; transform: none; } | ||
| 10 | - } | ||
| 11 | - | ||
| 12 | - @keyframes arrive-grow { | ||
| 13 | - from { transform: scaleY(0); } | ||
| 14 | - to { transform: scaleY(1); } | ||
| 15 | - } | ||
| 16 | - | ||
| 17 | - @keyframes arrive-count { | ||
| 18 | - 0% { transform: scale(1); } | ||
| 19 | - 40% { transform: scale(1.3); } | ||
| 20 | - 100% { transform: scale(1); } | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | - @keyframes arrive-lift { | ||
| 24 | - 0% { filter: brightness(1.6); } | ||
| 25 | - 100% { filter: brightness(1); } | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - @keyframes hs-breathe { | ||
| 29 | - 0%, 100% { opacity: 1; } | ||
| 30 | - 50% { opacity: 0.35; } | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - // Only the start is given: the bar settles to its own final tone. | ||
| 34 | - @keyframes hs-settle { | ||
| 35 | - from { background-color: var(--accent); } | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - @keyframes tab-breathe { | ||
| 39 | - 0%, 100% { opacity: 1; } | ||
| 40 | - 50% { opacity: 0.35; } | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - // Rows slide in with a short fade; the commit bars grow from the strip's floor; a count and a | ||
| 44 | - // calendar cell mark the change. Later rules win the same-specificity ties. | ||
| 45 | - [data-arrive].arrived { | ||
| 46 | - animation: arrive-in 300ms ease-out both; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - .hs-bar.arrived { | ||
| 50 | - transform-origin: 50% 100%; | ||
| 51 | - animation: arrive-grow 300ms ease-out both; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - .tab-count.arrived { | ||
| 55 | - display: inline-block; | ||
| 56 | - animation: arrive-count 300ms ease-out; | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - .cell.arrived { | ||
| 60 | - animation: arrive-lift 300ms ease-out; | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - .history-bars > a.hs-live { | ||
| 64 | - animation: hs-breathe 2.4s ease-in-out infinite; | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - .history-bars > a.hs-settle { | ||
| 68 | - animation: hs-settle 1.2s ease-out; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - .repo-tabs a.tab-live::after { | ||
| 72 | - animation: tab-breathe 2.4s ease-in-out infinite; | ||
| 73 | - } | ||
| 74 | -} | ||
| 75 | - | ||
| 76 | -// The running bar is the accent in every state, with or without motion. | ||
| 77 | -.history-bars > a.hs-live { | ||
| 78 | - background: var(--accent); | ||
| 79 | - opacity: 1; | ||
| 80 | -} | ||
| 81 | - | ||
| 82 | -// The CI tab's dot while a run goes: static under reduced motion, breathing otherwise. | ||
| 83 | -.repo-tabs a.tab-live::after { | ||
| 84 | - content: ""; | ||
| 85 | - display: inline-block; | ||
| 86 | - width: 6px; | ||
| 87 | - height: 6px; | ||
| 88 | - margin-left: 6px; | ||
| 89 | - border-radius: 50%; | ||
| 90 | - background: var(--accent); | ||
| 91 | - vertical-align: middle; | ||
| 92 | -} | ||
style/_alive_scrub.scssdeleted+0 -61
| @@ -1,61 +0,0 @@ | |||
| 1 | -// alive_scrub: see memory design/ALIVE.md. The timeline scrub on the repo home (nav.js). | ||
| 2 | - | ||
| 3 | -// Touch drags across the strip move the preview instead of scrolling the page. | ||
| 4 | -.history-bars > a { | ||
| 5 | - touch-action: none; | ||
| 6 | -} | ||
| 7 | - | ||
| 8 | -.history-bars.is-scrubbing { | ||
| 9 | - cursor: ew-resize; | ||
| 10 | -} | ||
| 11 | - | ||
| 12 | -// The bar the preview shows, and the bar under the pointer while scrubbing: full tone, in the accent. | ||
| 13 | -.history-bars > a.is-scrubbed { | ||
| 14 | - background: var(--accent); | ||
| 15 | - opacity: 1; | ||
| 16 | -} | ||
| 17 | - | ||
| 18 | -// The preview's listing is not the latest commit: a quiet label says so. | ||
| 19 | -.scrub-marker { | ||
| 20 | - color: var(--muted); | ||
| 21 | - margin: 0 0 8px; | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | -// The dock note: the commit shown, its age, and the way back. | ||
| 25 | -.scrub-note { | ||
| 26 | - display: inline-flex; | ||
| 27 | - align-items: center; | ||
| 28 | - gap: 8px; | ||
| 29 | - color: var(--muted); | ||
| 30 | -} | ||
| 31 | - | ||
| 32 | -.scrub-sha { | ||
| 33 | - color: var(--text); | ||
| 34 | -} | ||
| 35 | - | ||
| 36 | -.scrub-back { | ||
| 37 | - background: none; | ||
| 38 | - border: 0; | ||
| 39 | - padding: 0; | ||
| 40 | - color: var(--text); | ||
| 41 | - font: inherit; | ||
| 42 | - text-decoration: underline; | ||
| 43 | - text-underline-offset: 3px; | ||
| 44 | - cursor: pointer; | ||
| 45 | -} | ||
| 46 | - | ||
| 47 | -.scrub-back:focus-visible { | ||
| 48 | - outline: 2px solid var(--focus); | ||
| 49 | - outline-offset: 2px; | ||
| 50 | -} | ||
| 51 | - | ||
| 52 | -// The label takes a row of the tree pane, on the rows' own inset. | ||
| 53 | -.repo-home .tree-list > .scrub-marker { | ||
| 54 | - flex: none; | ||
| 55 | - margin: 0; | ||
| 56 | - padding: 8px 14px; | ||
| 57 | -} | ||
| 58 | - | ||
| 59 | -.repo-home .tree-list .tree-entry { | ||
| 60 | - cursor: default; | ||
| 61 | -} | ||
style/_alive_settings.scssdeleted+0 -189
| @@ -1,189 +0,0 @@ | |||
| 1 | - | ||
| 2 | - | ||
| 3 | -// Branch protection: the rules are a list pane, the rule being edited fills the pane beside it. The | ||
| 4 | -// rows stay one `details` group, so the panes are drawn by the list and the open row's form is laid | ||
| 5 | -// over the right one: opening a row needs no script and closes the row that was open. | ||
| 6 | -@media (min-width: 900px) { | ||
| 7 | - | ||
| 8 | - .rule-list { | ||
| 9 | - position: relative; | ||
| 10 | - display: block; | ||
| 11 | - flex: 1 1 auto; | ||
| 12 | - min-height: 0; | ||
| 13 | - margin: 0; | ||
| 14 | - overflow: visible; | ||
| 15 | - border: 0; | ||
| 16 | - background: none; | ||
| 17 | - | ||
| 18 | - &::before, | ||
| 19 | - &::after { | ||
| 20 | - content: ""; | ||
| 21 | - position: absolute; | ||
| 22 | - top: 0; | ||
| 23 | - bottom: 0; | ||
| 24 | - box-sizing: border-box; | ||
| 25 | - background: var(--surface); | ||
| 26 | - border: 1px solid var(--border); | ||
| 27 | - border-radius: 10px; | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - &::before { | ||
| 31 | - left: 0; | ||
| 32 | - width: 300px; | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - &::after { | ||
| 36 | - left: 312px; | ||
| 37 | - right: 0; | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - > * + * { | ||
| 41 | - border-top: 0; | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - > .rule-row, | ||
| 45 | - > .rule-builtin { | ||
| 46 | - position: static; | ||
| 47 | - box-sizing: border-box; | ||
| 48 | - width: 300px; | ||
| 49 | - } | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - .rule-row > summary, | ||
| 53 | - .rule-new > summary, | ||
| 54 | - .rule-builtin { | ||
| 55 | - position: relative; | ||
| 56 | - z-index: 1; | ||
| 57 | - box-sizing: border-box; | ||
| 58 | - height: 36px; | ||
| 59 | - padding: 0 14px; | ||
| 60 | - box-shadow: inset 0 -1px var(--border); | ||
| 61 | - font-size: 13px; | ||
| 62 | - overflow: hidden; | ||
| 63 | - white-space: nowrap; | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - .rule-builtin { | ||
| 67 | - display: flex; | ||
| 68 | - align-items: center; | ||
| 69 | - gap: 12px; | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - .rule-row > summary:focus-visible { | ||
| 73 | - outline-offset: -2px; | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - .rule-row[open] > summary { | ||
| 77 | - background: var(--surface-2); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - .rule-row[open] > summary .rule-edit { | ||
| 81 | - visibility: hidden; | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - .rule-row[open] > summary .rule-chevron { | ||
| 85 | - transform: rotate(-45deg); | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - .rule-pills { | ||
| 89 | - display: flex; | ||
| 90 | - gap: 6px; | ||
| 91 | - min-width: 0; | ||
| 92 | - overflow: hidden; | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - .rule-pick { | ||
| 96 | - position: absolute; | ||
| 97 | - z-index: 1; | ||
| 98 | - top: 20px; | ||
| 99 | - left: 332px; | ||
| 100 | - margin: 0; | ||
| 101 | - } | ||
| 102 | - | ||
| 103 | - .rule-list:has(details[open]) .rule-pick { | ||
| 104 | - display: none; | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - .rule-row > .rule-form { | ||
| 108 | - position: absolute; | ||
| 109 | - z-index: 1; | ||
| 110 | - inset: 0 0 0 312px; | ||
| 111 | - display: grid; | ||
| 112 | - grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
| 113 | - align-content: start; | ||
| 114 | - gap: 20px 32px; | ||
| 115 | - box-sizing: border-box; | ||
| 116 | - padding: 20px; | ||
| 117 | - overflow: auto; | ||
| 118 | - border: 0; | ||
| 119 | - background: none; | ||
| 120 | - | ||
| 121 | - input[type="text"], | ||
| 122 | - input[name="pattern"] { | ||
| 123 | - max-width: none; | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - > :not(.rule-section, .rule-pair) { | ||
| 127 | - grid-column: 1 / -1; | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - > .rule-section:has(input[name="required_checks"]) { | ||
| 131 | - order: 1; | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - > .rule-pair { | ||
| 135 | - display: contents; | ||
| 136 | - | ||
| 137 | - > .rule-section { | ||
| 138 | - order: 2; | ||
| 139 | - } | ||
| 140 | - } | ||
| 141 | - | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | - .rule-section { | ||
| 145 | - > legend { | ||
| 146 | - margin-bottom: 8px; | ||
| 147 | - font-family: var(--mono); | ||
| 148 | - font-size: 11px; | ||
| 149 | - font-weight: 500; | ||
| 150 | - letter-spacing: 0.12em; | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | - > p.muted.small { | ||
| 154 | - max-width: none; | ||
| 155 | - } | ||
| 156 | - } | ||
| 157 | - | ||
| 158 | - .rule-form .switch-row:first-child { | ||
| 159 | - border-top: 0; | ||
| 160 | - } | ||
| 161 | -} | ||
| 162 | - | ||
| 163 | -// Branch protection rows: the open row differs from a closed one only in its background. Both keep | ||
| 164 | -// the Edit text and a right chevron, so nothing swaps when a row opens. | ||
| 165 | -.rule-row > summary .rule-chevron, | ||
| 166 | -.rule-row[open] > summary .rule-chevron { | ||
| 167 | - transform: rotate(-45deg); | ||
| 168 | -} | ||
| 169 | - | ||
| 170 | -.rule-row[open] > summary .rule-edit { | ||
| 171 | - visibility: visible; | ||
| 172 | -} | ||
| 173 | - | ||
| 174 | -// Appearance: the preset swatches fit in rows of seven or more; the seven accents sit on one row. | ||
| 175 | -.colour-choices { | ||
| 176 | - display: grid; | ||
| 177 | - grid-template-columns: repeat(auto-fill, minmax(3.5rem, 1fr)); | ||
| 178 | - gap: 12px 8px; | ||
| 179 | -} | ||
| 180 | - | ||
| 181 | -.colour-choices > .colour-choice { | ||
| 182 | - width: auto; | ||
| 183 | -} | ||
| 184 | - | ||
| 185 | -// The sound row spans the left column, so its label stays on one line beside the switch. | ||
| 186 | -@media (min-width: 1100px) { | ||
| 187 | - | ||
| 188 | -} | ||
| 189 | - | ||
style/_authoring.scssmodified+1 -1
| @@ -102,7 +102,7 @@ textarea.md-drop { | |||
| 102 | .review-pending { | 102 | .review-pending { |
| 103 | &::before { | 103 | &::before { |
| 104 | content: "\00b7"; | 104 | content: "\00b7"; |
| 105 | - margin-right: 0.4em; | 105 | + margin: 0 0.4em; |
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| 108 | 108 | ||
style/_browse.scssmodified+0 -9
| @@ -10,15 +10,6 @@ | |||
| 10 | margin: 0 0 12px; | 10 | margin: 0 0 12px; |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | -.seg { | ||
| 14 | - display: inline-flex; | ||
| 15 | - border: 1px solid var(--border-strong); | ||
| 16 | - border-radius: var(--radius-md); | ||
| 17 | - overflow: hidden; | ||
| 18 | - background: var(--surface); | ||
| 19 | - | ||
| 20 | -} | ||
| 21 | - | ||
| 22 | // Split view: two sides per row, code wraps instead of scrolling sideways. | 13 | // Split view: two sides per row, code wraps instead of scrolling sideways. |
| 23 | .diff-table.diff-split { | 14 | .diff-table.diff-split { |
| 24 | width: 100%; | 15 | width: 100%; |
style/_canvas.scssdeleted+0 -103
| @@ -1,103 +0,0 @@ | |||
| 1 | -// The shell of the approved canvases. Imported after every other sheet, so it wins by order. | ||
| 2 | -// Sizes are the canvases' own: a 54px path row with no box and no rule, a 36px tab row, 40px page | ||
| 3 | -// margins, the body's accent wash, and no footer once signed in. | ||
| 4 | - | ||
| 5 | -@media (min-width: 900px) { | ||
| 6 | - .topbar { | ||
| 7 | - height: 54px; | ||
| 8 | - padding: 0 40px; | ||
| 9 | - background: transparent; | ||
| 10 | - border-bottom: 0; | ||
| 11 | - } | ||
| 12 | - | ||
| 13 | - .pathbar, | ||
| 14 | - .pathbar:has(.pathbar-edit) { | ||
| 15 | - max-width: none; | ||
| 16 | - padding: 0; | ||
| 17 | - background: transparent; | ||
| 18 | - border: 0; | ||
| 19 | - box-shadow: none; | ||
| 20 | - border-radius: 0; | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | - .pathbar-ico { | ||
| 24 | - display: none; | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | - .pathbar-segs { | ||
| 28 | - font-family: var(--mono); | ||
| 29 | - font-size: 13px; | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - // The profile corner floats over the left of the page's foot. Panes stop above it, so it covers | ||
| 33 | - // nothing; only pages with a dock or a left column that leaves it room reach the window's foot. | ||
| 34 | - .shell-body > main { | ||
| 35 | - padding: 0 40px 72px; | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - .shell-body > main:has(.repo-home, .ci-run, .ci-job, .pull-page) { | ||
| 39 | - padding-bottom: 20px; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - // The accent wash shows through on signed-in pages: the shell itself paints nothing. | ||
| 43 | - .shell, | ||
| 44 | - .shell-body { | ||
| 45 | - background: transparent; | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - body[data-signed-in] .site-footer { | ||
| 49 | - display: none; | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - .corner-float { | ||
| 53 | - left: 40px; | ||
| 54 | - bottom: 20px; | ||
| 55 | - display: flex; | ||
| 56 | - align-items: center; | ||
| 57 | - box-sizing: border-box; | ||
| 58 | - height: 40px; | ||
| 59 | - padding: 0 8px 0 5px; | ||
| 60 | - background: var(--surface-2); | ||
| 61 | - border-radius: 9px; | ||
| 62 | - box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - .corner-float .corner-avatar .avatar { | ||
| 66 | - width: 28px; | ||
| 67 | - height: 28px; | ||
| 68 | - border-radius: 6px; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - // The tab row: 36px, one hairline, the active tab a 2px accent rule on it. | ||
| 72 | - .repo-tabs { | ||
| 73 | - min-height: 36px; | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - .repo-tabs { | ||
| 77 | - gap: 22px; | ||
| 78 | - | ||
| 79 | - .tab { | ||
| 80 | - padding: 0; | ||
| 81 | - height: 36px; | ||
| 82 | - line-height: 36px; | ||
| 83 | - font-size: 14px; | ||
| 84 | - color: var(--text-2); | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - .tab[aria-current="page"], | ||
| 88 | - .tab.active { | ||
| 89 | - color: var(--text); | ||
| 90 | - font-weight: 600; | ||
| 91 | - box-shadow: inset 0 -2px var(--accent); | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - .tab-count { | ||
| 95 | - height: 18px; | ||
| 96 | - padding: 0 4px; | ||
| 97 | - background: transparent; | ||
| 98 | - font-family: var(--mono); | ||
| 99 | - font-size: 11px; | ||
| 100 | - line-height: 18px; | ||
| 101 | - } | ||
| 102 | - } | ||
| 103 | -} | ||
style/_canvas_account.scssdeleted+0 -28
| @@ -1,28 +0,0 @@ | |||
| 1 | -// canvas_account: details of the account, explore, admin and snippet pages. | ||
| 2 | -// Imported last in main.scss, so these rules win over the page partials they correct. | ||
| 3 | - | ||
| 4 | -// Page heads: one 40px row, the right action centred in it at 32px, so at least 4px of the | ||
| 5 | -// row sits under the button before the rule. | ||
| 6 | -@media (min-width: 900px) { | ||
| 7 | - | ||
| 8 | -} | ||
| 9 | - | ||
| 10 | -// Heatmap: the last column's month label ends at the grid's edge and runs back over the | ||
| 11 | -// columns before it, so "Nov" does not clip at the card's right edge. | ||
| 12 | -.heat-months > span:last-child { | ||
| 13 | - justify-self: end; | ||
| 14 | -} | ||
| 15 | - | ||
| 16 | -// Explore: one pane with the shared 14px inset, nothing more. | ||
| 17 | -.explore { | ||
| 18 | - padding: 0; | ||
| 19 | -} | ||
| 20 | - | ||
| 21 | -.explore > ul, | ||
| 22 | -.explore > .repo-list { | ||
| 23 | - margin: 0; | ||
| 24 | -} | ||
| 25 | - | ||
| 26 | -.srv-form { | ||
| 27 | - margin-top: 12px; | ||
| 28 | -} | ||
style/_canvas_ci.scssdeleted+0 -110
| @@ -1,110 +0,0 @@ | |||
| 1 | -// The CI pages as the approved canvases (memory design/ALIVE.md): the runs list keeps its rows, drawn | ||
| 2 | -// as the canvas's rows, and the selected run's column stacks the head and the panes. | ||
| 3 | - | ||
| 4 | -// The runs list: a hairline under each row, 14 px sides, the open run on --surface-2. | ||
| 5 | -.ci-split > .ci-side .ci-row { | ||
| 6 | - padding: 10px 14px; | ||
| 7 | - box-shadow: inset 0 -1px var(--border); | ||
| 8 | - border-radius: 0; | ||
| 9 | -} | ||
| 10 | - | ||
| 11 | -.ci-split > .ci-side .ci-row[aria-current="true"] { | ||
| 12 | - background: var(--surface-2); | ||
| 13 | -} | ||
| 14 | - | ||
| 15 | -// The selected run's column: its head, its panes, and no scrolling of its own. | ||
| 16 | -.ci-split > .ci-detail { | ||
| 17 | - display: flex; | ||
| 18 | - flex-direction: column; | ||
| 19 | - gap: 12px; | ||
| 20 | - min-width: 0; | ||
| 21 | - min-height: 0; | ||
| 22 | - overflow: hidden; | ||
| 23 | - padding: 0; | ||
| 24 | - background: none; | ||
| 25 | - border: 0; | ||
| 26 | - box-shadow: none; | ||
| 27 | -} | ||
| 28 | - | ||
| 29 | -.ci-split > .ci-detail > .ci-tl-main { | ||
| 30 | - flex: 1 1 0; | ||
| 31 | - min-height: 0; | ||
| 32 | -} | ||
| 33 | - | ||
| 34 | -// The page reaches the window's foot, and the dock is the repo page's: 156px with the label in a | ||
| 35 | -// 254px column, so the floating profile corner covers no bars. | ||
| 36 | -.ci-run.fit-pane, | ||
| 37 | -.ci-job.fit-pane { | ||
| 38 | - height: calc(100dvh - var(--pane-top, 107px) - 20px); | ||
| 39 | -} | ||
| 40 | - | ||
| 41 | -.ci-dock { | ||
| 42 | - flex: none; | ||
| 43 | - height: 156px; | ||
| 44 | - box-sizing: border-box; | ||
| 45 | -} | ||
| 46 | - | ||
| 47 | -.ci-tl-tab { | ||
| 48 | - flex-direction: row; | ||
| 49 | -} | ||
| 50 | - | ||
| 51 | -// The dock's note sits under the `Last 48 commits` label, in the 254px label column, so no bar sits | ||
| 52 | -// under it. Below 900px the dock stacks and the note takes its own line. | ||
| 53 | -.ci-dock .ci-dock-note { | ||
| 54 | - top: 34px; | ||
| 55 | - left: 14px; | ||
| 56 | - right: auto; | ||
| 57 | - width: 226px; | ||
| 58 | - margin: 0; | ||
| 59 | - font-size: 12px; | ||
| 60 | - line-height: 1.3; | ||
| 61 | - color: var(--muted); | ||
| 62 | -} | ||
| 63 | - | ||
| 64 | -// The header's actions (Re-run, Re-run failed jobs, Cancel) and the log toolbar's buttons are one size: | ||
| 65 | -// 32px high, 13px text. Copy log and Full log take the same treatment. | ||
| 66 | -.ci-tl-actions button, | ||
| 67 | -.ci-tl-actions .button { | ||
| 68 | - height: 32px; | ||
| 69 | - font-size: 13px; | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | -.ci-tl-tools .ci-mini { | ||
| 73 | - display: inline-flex; | ||
| 74 | - align-items: center; | ||
| 75 | - justify-content: center; | ||
| 76 | - box-sizing: border-box; | ||
| 77 | - height: 32px; | ||
| 78 | - padding: 0 12px; | ||
| 79 | - font-size: 13px; | ||
| 80 | - line-height: 1; | ||
| 81 | - text-decoration: none; | ||
| 82 | -} | ||
| 83 | - | ||
| 84 | -.ci-tl-tools .ci-logsearch { | ||
| 85 | - height: 32px; | ||
| 86 | - box-sizing: border-box; | ||
| 87 | -} | ||
| 88 | - | ||
| 89 | -@media (max-width: 899px) { | ||
| 90 | - .ci-dock .ci-dock-note { | ||
| 91 | - position: static; | ||
| 92 | - width: auto; | ||
| 93 | - margin-bottom: 6px; | ||
| 94 | - } | ||
| 95 | -} | ||
| 96 | - | ||
| 97 | -.ci-tl-tools a.ci-mini { | ||
| 98 | - display: inline-flex; | ||
| 99 | - align-items: center; | ||
| 100 | - box-sizing: border-box; | ||
| 101 | - height: 32px; | ||
| 102 | - padding: 0 12px; | ||
| 103 | - border: 1px solid var(--border); | ||
| 104 | - border-radius: 7px; | ||
| 105 | - background: transparent; | ||
| 106 | - font-size: 13px; | ||
| 107 | - font-weight: 600; | ||
| 108 | - color: var(--text); | ||
| 109 | - text-decoration: none; | ||
| 110 | -} | ||
style/_canvas_commits.scssdeleted+0 -17
| @@ -1,17 +0,0 @@ | |||
| 1 | - | ||
| 2 | - | ||
| 3 | -@keyframes commits-beat { | ||
| 4 | - 50% { | ||
| 5 | - opacity: 0.4; | ||
| 6 | - } | ||
| 7 | -} | ||
| 8 | - | ||
| 9 | -@media (prefers-reduced-motion: reduce) { | ||
| 10 | - | ||
| 11 | -} | ||
| 12 | - | ||
| 13 | -// Below 900px the page stacks and the pane is as tall as its rows. | ||
| 14 | -@media (max-width: 899px) { | ||
| 15 | - | ||
| 16 | -} | ||
| 17 | - | ||
style/_canvas_detail.scssdeleted+0 -192
| @@ -1,192 +0,0 @@ | |||
| 1 | -// canvas_detail: the small fixes of the issue and pull conversation, and the label style. | ||
| 2 | -// Tokens only; motion is not used here. | ||
| 3 | - | ||
| 4 | -// Mono uppercase section label (the Add a comment heading). | ||
| 5 | -.label, | ||
| 6 | -.issue-comment > .label { | ||
| 7 | - @extend %mono-label; | ||
| 8 | - margin: 0 0 10px; | ||
| 9 | - color: var(--muted); | ||
| 10 | -} | ||
| 11 | - | ||
| 12 | -// Conversation: the outer pane is not a card. Each comment, the merge box and the compose box sit | ||
| 13 | -// directly on the page as 10px panes, with the same gap between them. | ||
| 14 | -@media (min-width: 900px) { | ||
| 15 | - .issue-layout > .issue-column.fit-pane { | ||
| 16 | - gap: 12px; | ||
| 17 | - padding: 0; | ||
| 18 | - border: 0; | ||
| 19 | - border-radius: 0; | ||
| 20 | - background: none; | ||
| 21 | - | ||
| 22 | - > .issue-timeline { | ||
| 23 | - gap: 12px; | ||
| 24 | - } | ||
| 25 | - } | ||
| 26 | -} | ||
| 27 | - | ||
| 28 | -.issue-item, | ||
| 29 | -.review-item, | ||
| 30 | -.merge-box, | ||
| 31 | -.issue-comment { | ||
| 32 | - border-radius: 10px; | ||
| 33 | -} | ||
| 34 | - | ||
| 35 | -.issue-comment { | ||
| 36 | - margin: 0; | ||
| 37 | - padding: 14px; | ||
| 38 | - border: 1px solid var(--border); | ||
| 39 | - background: var(--surface); | ||
| 40 | - box-shadow: none; | ||
| 41 | -} | ||
| 42 | - | ||
| 43 | -// Event rows sit under the comment avatars: the avatar starts 15px in (border plus 14px head pad). | ||
| 44 | -.issue-timeline > .issue-event { | ||
| 45 | - padding: 0 15px; | ||
| 46 | -} | ||
| 47 | - | ||
| 48 | -// Right sidebar: one pane, hairline-separated sections, scrolling inside itself. The notifications | ||
| 49 | -// section is a plain section, not a card nested in the pane. | ||
| 50 | -@media (min-width: 900px) { | ||
| 51 | - .issue-layout > .issue-sidebar.fit-pane { | ||
| 52 | - padding: 0 14px; | ||
| 53 | - overflow-y: auto; | ||
| 54 | - | ||
| 55 | - > .issue-side-section { | ||
| 56 | - margin: 0; | ||
| 57 | - padding: 14px 0; | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - } | ||
| 61 | -} | ||
| 62 | - | ||
| 63 | -// The list toolbar's selects match its 32px search field. | ||
| 64 | -.issue-search select { | ||
| 65 | - height: 32px; | ||
| 66 | - min-height: 0; | ||
| 67 | - padding-block: 0; | ||
| 68 | -} | ||
| 69 | - | ||
| 70 | -// The commit page: the facts sit on one line's top, and the disclosure has air above the file count. | ||
| 71 | -.commit-facts { | ||
| 72 | - align-items: flex-start; | ||
| 73 | -} | ||
| 74 | - | ||
| 75 | -// Labels: one line each, columns line up down the pane. Edit opens under its row and holds Delete, | ||
| 76 | -// so a pane of labels is not a pane of red buttons. | ||
| 77 | -.label-edit-body { | ||
| 78 | - display: flex; | ||
| 79 | - align-items: flex-end; | ||
| 80 | - gap: 12px; | ||
| 81 | - padding: 4px 0 14px; | ||
| 82 | - | ||
| 83 | -} | ||
| 84 | - | ||
| 85 | -.label-edit-form { | ||
| 86 | - display: flex; | ||
| 87 | - flex: 1 1 auto; | ||
| 88 | - align-items: flex-end; | ||
| 89 | - gap: 12px; | ||
| 90 | - min-width: 0; | ||
| 91 | - | ||
| 92 | - > label { | ||
| 93 | - display: flex; | ||
| 94 | - flex-direction: column; | ||
| 95 | - gap: 4px; | ||
| 96 | - margin: 0; | ||
| 97 | - font-size: 13px; | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - > label:has(> input[type="text"]) { | ||
| 101 | - flex: 1 1 0; | ||
| 102 | - min-width: 0; | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - > label:has(> input[type="color"]) { | ||
| 106 | - flex-direction: column; | ||
| 107 | - align-items: flex-start; | ||
| 108 | - gap: 4px; | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | - input[type="color"] { | ||
| 112 | - width: 36px; | ||
| 113 | - height: var(--control-h); | ||
| 114 | - } | ||
| 115 | - | ||
| 116 | - > button { | ||
| 117 | - align-self: flex-end; | ||
| 118 | - } | ||
| 119 | -} | ||
| 120 | - | ||
| 121 | -// New label: the colour's label sits at the left, like every other field. | ||
| 122 | -.stack > label:has(> input[type="color"]) { | ||
| 123 | - flex-direction: row; | ||
| 124 | - justify-content: flex-start; | ||
| 125 | - text-align: left; | ||
| 126 | -} | ||
| 127 | - | ||
| 128 | -// A chip whose colour is close to the page (white on light, black on dark) keeps a visible edge. | ||
| 129 | -.label-chip { | ||
| 130 | - box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--text) 14%, transparent); | ||
| 131 | -} | ||
| 132 | - | ||
| 133 | -// Server settings use the pane's width, in columns wide enough for a label and its two badges on | ||
| 134 | -// one line. | ||
| 135 | -.srv-page form.srv-form { | ||
| 136 | - max-width: none; | ||
| 137 | - padding-bottom: 20px; | ||
| 138 | -} | ||
| 139 | - | ||
| 140 | -// File pages: the path row has no rules of its own, the tab row's rule is the only one above it. | ||
| 141 | -.browse-bar { | ||
| 142 | - border-top: 0; | ||
| 143 | - border-bottom: 0; | ||
| 144 | -} | ||
| 145 | - | ||
| 146 | -// CI list: the log fills its pane to the bottom edge. | ||
| 147 | -.ci-tl-panel-log > .ci-log { | ||
| 148 | - flex: 1 1 auto; | ||
| 149 | - height: 100%; | ||
| 150 | - max-height: none; | ||
| 151 | - min-height: 0; | ||
| 152 | -} | ||
| 153 | - | ||
| 154 | -// Commit page: Show checks stays on the facts line and its list opens as a menu. | ||
| 155 | -.commit-facts > .checks-summary { | ||
| 156 | - position: relative; | ||
| 157 | - flex-wrap: nowrap; | ||
| 158 | - | ||
| 159 | - > .checks-details { | ||
| 160 | - flex-basis: auto; | ||
| 161 | - | ||
| 162 | - > .status-list { | ||
| 163 | - position: absolute; | ||
| 164 | - top: 100%; | ||
| 165 | - left: 0; | ||
| 166 | - z-index: 20; | ||
| 167 | - min-width: 320px; | ||
| 168 | - margin-top: 6px; | ||
| 169 | - padding: 8px 12px; | ||
| 170 | - background: var(--surface-2); | ||
| 171 | - border: 1px solid var(--border-strong); | ||
| 172 | - border-radius: var(--radius-md); | ||
| 173 | - } | ||
| 174 | - } | ||
| 175 | -} | ||
| 176 | - | ||
| 177 | -// A side pane matches the pane beside it. | ||
| 178 | -@media (min-width: 900px) { | ||
| 179 | - | ||
| 180 | -} | ||
| 181 | - | ||
| 182 | -// Blame: a commit takes two lines; going further back is a small mark on the first. | ||
| 183 | -.blame-table .blame-top > .blame-prior { | ||
| 184 | - flex: none; | ||
| 185 | - margin: 0 0 0 auto; | ||
| 186 | - text-decoration: none; | ||
| 187 | - color: var(--text-2); | ||
| 188 | - | ||
| 189 | - &:hover { | ||
| 190 | - color: var(--accent); | ||
| 191 | - } | ||
| 192 | -} | ||
style/_canvas_lists.scssdeleted+0 -282
| @@ -1,282 +0,0 @@ | |||
| 1 | -// canvas_lists: matches the approved canvases, see memory design/ALIVE.md. | ||
| 2 | -// Every list row is one line: 36px high, a hairline under it, 14px side padding, the metadata in | ||
| 3 | -// right aligned columns and no second line. Titles clip; nothing wraps. | ||
| 4 | - | ||
| 5 | -// Toolbar: one 44px row at the top of the pane. | ||
| 6 | -.issue-pane > .issue-toolbar { | ||
| 7 | - height: 44px; | ||
| 8 | - margin: 0; | ||
| 9 | - padding: 0 14px; | ||
| 10 | - flex-wrap: nowrap; | ||
| 11 | - gap: 10px; | ||
| 12 | - box-sizing: border-box; | ||
| 13 | - border-bottom: 1px solid var(--border); | ||
| 14 | -} | ||
| 15 | - | ||
| 16 | -.issue-pane > .issue-list { | ||
| 17 | - border: 0; | ||
| 18 | - border-radius: 0; | ||
| 19 | -} | ||
| 20 | - | ||
| 21 | -// Issue and pull rows: state dot, title, labels, then #n, author, age, milestone and tasks on the | ||
| 22 | -// right, then assignee avatars and the comment count at the far end. | ||
| 23 | -.issue-pane .issue-list > .issue-row { | ||
| 24 | - display: flex; | ||
| 25 | - align-items: center; | ||
| 26 | - gap: 12px; | ||
| 27 | - height: 36px; | ||
| 28 | - min-width: 0; | ||
| 29 | - padding: 0 14px; | ||
| 30 | - overflow: hidden; | ||
| 31 | - border-top: 0; | ||
| 32 | - border-bottom: 1px solid var(--border); | ||
| 33 | - background: var(--surface); | ||
| 34 | - | ||
| 35 | - &:hover { | ||
| 36 | - background: var(--surface-2); | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - > .issue-state { | ||
| 40 | - flex: none; | ||
| 41 | - width: 8px; | ||
| 42 | - height: 8px; | ||
| 43 | - margin: 0; | ||
| 44 | - border-width: 0; | ||
| 45 | - border-radius: 50%; | ||
| 46 | - background: var(--muted); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - > .issue-state-open { | ||
| 50 | - background: var(--ok); | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - > .issue-main { | ||
| 54 | - display: flex; | ||
| 55 | - flex: 1 1 auto; | ||
| 56 | - align-items: center; | ||
| 57 | - gap: 12px; | ||
| 58 | - min-width: 0; | ||
| 59 | - overflow: hidden; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - .issue-title-line { | ||
| 63 | - display: flex; | ||
| 64 | - flex: 0 1 auto; | ||
| 65 | - flex-wrap: nowrap; | ||
| 66 | - align-items: center; | ||
| 67 | - gap: 8px; | ||
| 68 | - min-width: 0; | ||
| 69 | - overflow: hidden; | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - .issue-title { | ||
| 73 | - min-width: 0; | ||
| 74 | - overflow: hidden; | ||
| 75 | - font-size: 14px; | ||
| 76 | - font-weight: 500; | ||
| 77 | - text-overflow: ellipsis; | ||
| 78 | - white-space: nowrap; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - .issue-title-line > :not(.issue-title) { | ||
| 82 | - flex: none; | ||
| 83 | - white-space: nowrap; | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - > .issue-main > .issue-meta { | ||
| 87 | - display: flex; | ||
| 88 | - flex: none; | ||
| 89 | - flex-wrap: nowrap; | ||
| 90 | - align-items: center; | ||
| 91 | - gap: 12px; | ||
| 92 | - margin: 0 0 0 auto; | ||
| 93 | - font-size: 13px; | ||
| 94 | - white-space: nowrap; | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - > .issue-aside { | ||
| 98 | - flex: none; | ||
| 99 | - gap: 8px; | ||
| 100 | - } | ||
| 101 | -} | ||
| 102 | - | ||
| 103 | -// Panes: the list sits in one pane with a 1px border, 10px radius and no shadow. | ||
| 104 | -.lang-list, | ||
| 105 | -.explore { | ||
| 106 | - box-shadow: none; | ||
| 107 | - border: 1px solid var(--border); | ||
| 108 | - border-radius: 10px; | ||
| 109 | - background: var(--surface); | ||
| 110 | - overflow: hidden; | ||
| 111 | -} | ||
| 112 | - | ||
| 113 | -// Repo rows (Explore and the profile tabs): mono name, visibility, the description clipped in | ||
| 114 | -// --text-2, then stars and the update age on the right. | ||
| 115 | -.repo-list > .repo-item { | ||
| 116 | - display: flex; | ||
| 117 | - flex-wrap: nowrap; | ||
| 118 | - align-items: center; | ||
| 119 | - gap: 16px; | ||
| 120 | - height: 52px; | ||
| 121 | - min-width: 0; | ||
| 122 | - padding: 0 16px; | ||
| 123 | - overflow: hidden; | ||
| 124 | - border-bottom: 1px solid var(--border); | ||
| 125 | - | ||
| 126 | - > .repo-name { | ||
| 127 | - flex: 0 1 auto; | ||
| 128 | - max-width: 40%; | ||
| 129 | - min-width: 0; | ||
| 130 | - overflow: hidden; | ||
| 131 | - font-family: var(--mono); | ||
| 132 | - font-size: 14px; | ||
| 133 | - font-weight: 500; | ||
| 134 | - text-overflow: ellipsis; | ||
| 135 | - white-space: nowrap; | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | - > .badge { | ||
| 139 | - flex: none; | ||
| 140 | - } | ||
| 141 | - | ||
| 142 | - > .repo-desc { | ||
| 143 | - flex: 1 1 auto; | ||
| 144 | - min-width: 0; | ||
| 145 | - overflow: hidden; | ||
| 146 | - color: var(--text-2); | ||
| 147 | - font-size: 13px; | ||
| 148 | - text-overflow: ellipsis; | ||
| 149 | - white-space: nowrap; | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - > .repo-stats { | ||
| 153 | - flex: none; | ||
| 154 | - margin-left: auto; | ||
| 155 | - white-space: nowrap; | ||
| 156 | - } | ||
| 157 | -} | ||
| 158 | - | ||
| 159 | -// Notification, Needs you and review request rows: reason as a small mono tag, the title, the | ||
| 160 | -// repo or detail, the age and the row's own actions. | ||
| 161 | -.review-request-list > li { | ||
| 162 | - display: flex; | ||
| 163 | - flex-wrap: nowrap; | ||
| 164 | - align-items: center; | ||
| 165 | - gap: 12px; | ||
| 166 | - height: 36px; | ||
| 167 | - min-width: 0; | ||
| 168 | - padding: 0 14px; | ||
| 169 | - overflow: hidden; | ||
| 170 | - border-bottom: 1px solid var(--border); | ||
| 171 | - | ||
| 172 | - > .badge { | ||
| 173 | - flex: none; | ||
| 174 | - font-family: var(--mono); | ||
| 175 | - font-size: 11px; | ||
| 176 | - } | ||
| 177 | - | ||
| 178 | - > .muted, | ||
| 179 | - > time { | ||
| 180 | - flex: none; | ||
| 181 | - white-space: nowrap; | ||
| 182 | - } | ||
| 183 | - | ||
| 184 | -} | ||
| 185 | - | ||
| 186 | -// Issue rows: the assignee sits in a fixed 24px slot at the right, so the columns line up whether | ||
| 187 | -// or not a row has an assignee. | ||
| 188 | -.issue-pane .issue-list > .issue-row > .issue-aside { | ||
| 189 | - display: flex; | ||
| 190 | - align-items: center; | ||
| 191 | - justify-content: flex-start; | ||
| 192 | - min-width: 30px; | ||
| 193 | - height: 24px; | ||
| 194 | - | ||
| 195 | - > .avatar { | ||
| 196 | - flex: none; | ||
| 197 | - width: 24px; | ||
| 198 | - height: 24px; | ||
| 199 | - } | ||
| 200 | -} | ||
| 201 | - | ||
| 202 | -// The #n is a right aligned column of fixed width, so the numbers line up down the list. | ||
| 203 | -.issue-pane .issue-list > .issue-row > .issue-main > .issue-meta > span:first-child { | ||
| 204 | - flex: none; | ||
| 205 | - width: 5ch; | ||
| 206 | - text-align: right; | ||
| 207 | - font-variant-numeric: tabular-nums; | ||
| 208 | -} | ||
| 209 | - | ||
| 210 | -// Toolbar controls share one 32px height, centred in the 44px toolbar. | ||
| 211 | -.issue-pane > .issue-toolbar { | ||
| 212 | - align-items: center; | ||
| 213 | - | ||
| 214 | - > input, | ||
| 215 | - > select, | ||
| 216 | - > button, | ||
| 217 | - > .button, | ||
| 218 | - > details > summary { | ||
| 219 | - height: 32px; | ||
| 220 | - box-sizing: border-box; | ||
| 221 | - } | ||
| 222 | - | ||
| 223 | - > details > summary { | ||
| 224 | - display: inline-flex; | ||
| 225 | - align-items: center; | ||
| 226 | - } | ||
| 227 | -} | ||
| 228 | - | ||
| 229 | -.lang-list > .empty-state { | ||
| 230 | - padding: 16px 14px; | ||
| 231 | -} | ||
| 232 | - | ||
| 233 | -// Labels: the colour is a 32px swatch with its label to the left and a border, like the inputs. | ||
| 234 | -label:has(> input[type="color"]) { | ||
| 235 | - display: flex; | ||
| 236 | - align-items: center; | ||
| 237 | - gap: 10px; | ||
| 238 | -} | ||
| 239 | - | ||
| 240 | -input[type="color"] { | ||
| 241 | - flex: none; | ||
| 242 | - width: 32px; | ||
| 243 | - height: 32px; | ||
| 244 | - box-sizing: border-box; | ||
| 245 | - padding: 3px; | ||
| 246 | - border: 1px solid var(--border-strong); | ||
| 247 | - border-radius: var(--radius-md); | ||
| 248 | - background: var(--surface); | ||
| 249 | - cursor: pointer; | ||
| 250 | - | ||
| 251 | - &::-webkit-color-swatch-wrapper { | ||
| 252 | - padding: 0; | ||
| 253 | - } | ||
| 254 | - | ||
| 255 | - &::-webkit-color-swatch { | ||
| 256 | - border: 0; | ||
| 257 | - border-radius: 3px; | ||
| 258 | - } | ||
| 259 | - | ||
| 260 | - &::-moz-color-swatch { | ||
| 261 | - border: 0; | ||
| 262 | - border-radius: 3px; | ||
| 263 | - } | ||
| 264 | -} | ||
| 265 | - | ||
| 266 | -// Pull Files: long diff lines scroll inside their file's body; the file header stays put. | ||
| 267 | -.pull-diff-scroll { | ||
| 268 | - min-width: 0; | ||
| 269 | - overflow-x: hidden; | ||
| 270 | - | ||
| 271 | - .diff-section, | ||
| 272 | - .diff-file { | ||
| 273 | - min-width: 0; | ||
| 274 | - max-width: 100%; | ||
| 275 | - } | ||
| 276 | - | ||
| 277 | - .diff-file-body { | ||
| 278 | - min-width: 0; | ||
| 279 | - max-width: 100%; | ||
| 280 | - overflow-x: auto; | ||
| 281 | - } | ||
| 282 | -} | ||
style/_canvas_pull.scssdeleted+0 -402
| @@ -1,402 +0,0 @@ | |||
| 1 | -// canvas_pull: the pull request head and its Files view, matched to the One Lit Thing canvas | ||
| 2 | -// (Pull.dc.html). Imported after _pull.scss and _review_flow.scss, so it wins by order. Sizes are | ||
| 3 | -// the canvas's own: a 24px title, 36px rows and panes, a 260px file column, and a diff pane that | ||
| 4 | -// scrolls inside itself. The page never scrolls: .pull-page takes the rest of the window. | ||
| 5 | - | ||
| 6 | -// Head: the title with the review buttons on one row, the state and branches on the next. | ||
| 7 | -.pull-head { | ||
| 8 | - display: flex; | ||
| 9 | - flex-direction: column; | ||
| 10 | - gap: 6px; | ||
| 11 | - flex: none; | ||
| 12 | - margin: 0; | ||
| 13 | -} | ||
| 14 | - | ||
| 15 | -.pull-line1 { | ||
| 16 | - display: flex; | ||
| 17 | - align-items: center; | ||
| 18 | - justify-content: space-between; | ||
| 19 | - gap: 12px; | ||
| 20 | - min-height: 32px; | ||
| 21 | - | ||
| 22 | - .issue-heading { | ||
| 23 | - min-width: 0; | ||
| 24 | - margin: 0; | ||
| 25 | - overflow: hidden; | ||
| 26 | - text-overflow: ellipsis; | ||
| 27 | - white-space: nowrap; | ||
| 28 | - font-family: var(--display); | ||
| 29 | - font-size: 24px; | ||
| 30 | - font-weight: 700; | ||
| 31 | - line-height: 1.2; | ||
| 32 | - letter-spacing: -0.005em; | ||
| 33 | - } | ||
| 34 | -} | ||
| 35 | - | ||
| 36 | -.pull-actions { | ||
| 37 | - display: flex; | ||
| 38 | - align-items: center; | ||
| 39 | - gap: 8px; | ||
| 40 | - flex: none; | ||
| 41 | - | ||
| 42 | - .btn { | ||
| 43 | - height: 32px; | ||
| 44 | - padding: 0 12px; | ||
| 45 | - border-radius: 7px; | ||
| 46 | - font-size: 13px; | ||
| 47 | - font-weight: 600; | ||
| 48 | - background: var(--surface-2); | ||
| 49 | - box-shadow: inset 0 0 0 1px var(--border); | ||
| 50 | - cursor: pointer; | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - .btn.main { | ||
| 54 | - background: var(--accent); | ||
| 55 | - color: var(--accent-ink); | ||
| 56 | - box-shadow: none; | ||
| 57 | - } | ||
| 58 | -} | ||
| 59 | - | ||
| 60 | -.pull-line2 { | ||
| 61 | - display: flex; | ||
| 62 | - align-items: center; | ||
| 63 | - gap: 8px; | ||
| 64 | - margin: 0; | ||
| 65 | - min-width: 0; | ||
| 66 | - font-size: 13px; | ||
| 67 | - white-space: nowrap; | ||
| 68 | - | ||
| 69 | - code { | ||
| 70 | - font-family: var(--mono); | ||
| 71 | - font-size: 12px; | ||
| 72 | - } | ||
| 73 | -} | ||
| 74 | - | ||
| 75 | -.pull-totals { | ||
| 76 | - margin-left: auto; | ||
| 77 | - font-family: var(--mono); | ||
| 78 | - font-size: 12px; | ||
| 79 | - color: var(--muted); | ||
| 80 | -} | ||
| 81 | - | ||
| 82 | -// The page: the two columns fill what the window leaves under the head. | ||
| 83 | -@media (min-width: 900px) { | ||
| 84 | - .fit-pane.pull-page { | ||
| 85 | - display: flex; | ||
| 86 | - flex-direction: column; | ||
| 87 | - height: max(420px, calc(100dvh - var(--pull-top, 262px))); | ||
| 88 | - padding: 0; | ||
| 89 | - overflow: hidden; | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - .pull-cols { | ||
| 93 | - flex: 1 1 auto; | ||
| 94 | - min-height: 0; | ||
| 95 | - display: grid; | ||
| 96 | - grid-template-columns: 260px minmax(0, 1fr); | ||
| 97 | - gap: 16px; | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - // The profile corner floats over the left of the page's foot: the panes stop above it. | ||
| 101 | - .pull-left { | ||
| 102 | - display: flex; | ||
| 103 | - flex-direction: column; | ||
| 104 | - gap: 12px; | ||
| 105 | - min-height: 0; | ||
| 106 | - margin-bottom: 64px; | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - // Panes: 36px heads with a hairline, 36px rows with a hairline, 10px corners, no shadow. | ||
| 110 | - .pull-left > .pane, | ||
| 111 | - .pull-diff { | ||
| 112 | - border-radius: 10px; | ||
| 113 | - background: var(--surface); | ||
| 114 | - box-shadow: inset 0 0 0 1px var(--border); | ||
| 115 | - } | ||
| 116 | - | ||
| 117 | - .pull-cap { | ||
| 118 | - display: flex; | ||
| 119 | - align-items: center; | ||
| 120 | - gap: 8px; | ||
| 121 | - flex: none; | ||
| 122 | - height: 36px; | ||
| 123 | - padding: 0 14px; | ||
| 124 | - box-shadow: inset 0 -1px var(--border); | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | - .pull-count { | ||
| 128 | - margin-left: auto; | ||
| 129 | - font-family: var(--mono); | ||
| 130 | - font-size: 12px; | ||
| 131 | - color: var(--muted); | ||
| 132 | - white-space: nowrap; | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - .pull-files { | ||
| 136 | - flex: 1 1 auto; | ||
| 137 | - min-height: 0; | ||
| 138 | - display: flex; | ||
| 139 | - flex-direction: column; | ||
| 140 | - overflow: hidden; | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - .pull-file-list { | ||
| 144 | - flex: 1 1 auto; | ||
| 145 | - min-height: 0; | ||
| 146 | - margin: 0; | ||
| 147 | - padding: 0; | ||
| 148 | - list-style: none; | ||
| 149 | - overflow: auto; | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - .pull-file { | ||
| 153 | - display: flex; | ||
| 154 | - align-items: center; | ||
| 155 | - gap: 8px; | ||
| 156 | - height: 36px; | ||
| 157 | - padding: 0 14px; | ||
| 158 | - box-shadow: inset 0 -1px var(--border); | ||
| 159 | - font-size: 13px; | ||
| 160 | - } | ||
| 161 | - | ||
| 162 | - .pull-file.current { | ||
| 163 | - background: var(--surface-2); | ||
| 164 | - } | ||
| 165 | - | ||
| 166 | - .pull-file-link { | ||
| 167 | - flex: 1 1 auto; | ||
| 168 | - min-width: 0; | ||
| 169 | - height: 100%; | ||
| 170 | - display: flex; | ||
| 171 | - align-items: center; | ||
| 172 | - gap: 8px; | ||
| 173 | - color: inherit; | ||
| 174 | - text-decoration: none; | ||
| 175 | - | ||
| 176 | - .clip { | ||
| 177 | - flex: 1 1 auto; | ||
| 178 | - min-width: 0; | ||
| 179 | - } | ||
| 180 | - } | ||
| 181 | - | ||
| 182 | - .pull-file-ico { | ||
| 183 | - flex: none; | ||
| 184 | - color: var(--muted); | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | - .pull-counts { | ||
| 188 | - flex: none; | ||
| 189 | - font-family: var(--mono); | ||
| 190 | - font-size: 12px; | ||
| 191 | - white-space: nowrap; | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | - .pull-file input[type="checkbox"] { | ||
| 195 | - flex: none; | ||
| 196 | - width: 14px; | ||
| 197 | - height: 14px; | ||
| 198 | - margin: 0; | ||
| 199 | - } | ||
| 200 | - | ||
| 201 | - .pull-file .viewed-note { | ||
| 202 | - flex: none; | ||
| 203 | - font-family: var(--mono); | ||
| 204 | - font-size: 11px; | ||
| 205 | - color: var(--muted); | ||
| 206 | - } | ||
| 207 | - | ||
| 208 | - .pull-checks { | ||
| 209 | - flex: 0 1 auto; | ||
| 210 | - max-height: 40%; | ||
| 211 | - min-height: 0; | ||
| 212 | - overflow: auto; | ||
| 213 | - } | ||
| 214 | - | ||
| 215 | - .pull-check { | ||
| 216 | - display: flex; | ||
| 217 | - align-items: center; | ||
| 218 | - gap: 10px; | ||
| 219 | - height: 36px; | ||
| 220 | - padding: 0 14px; | ||
| 221 | - box-shadow: inset 0 -1px var(--border); | ||
| 222 | - font-size: 13px; | ||
| 223 | - | ||
| 224 | - .clip { | ||
| 225 | - flex: 1 1 auto; | ||
| 226 | - min-width: 0; | ||
| 227 | - } | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - .pull-check .pull-time { | ||
| 231 | - flex: none; | ||
| 232 | - font-family: var(--mono); | ||
| 233 | - font-size: 12px; | ||
| 234 | - color: var(--muted); | ||
| 235 | - white-space: nowrap; | ||
| 236 | - } | ||
| 237 | - | ||
| 238 | - .pull-check > span:first-child { | ||
| 239 | - flex: none; | ||
| 240 | - width: 8px; | ||
| 241 | - height: 8px; | ||
| 242 | - border-radius: 50%; | ||
| 243 | - background: var(--muted); | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | - .pull-check > .ok { | ||
| 247 | - background: var(--ok); | ||
| 248 | - } | ||
| 249 | - | ||
| 250 | - .pull-check > .bad { | ||
| 251 | - background: var(--bad); | ||
| 252 | - } | ||
| 253 | - | ||
| 254 | - .pull-check > .live { | ||
| 255 | - background: var(--accent); | ||
| 256 | - animation: pull-beat 1.6s ease-in-out infinite; | ||
| 257 | - } | ||
| 258 | - | ||
| 259 | - // The diff pane: a 36px top row, then one scroller holding every file, then the compose line. | ||
| 260 | - .pull-diff { | ||
| 261 | - min-height: 0; | ||
| 262 | - display: flex; | ||
| 263 | - flex-direction: column; | ||
| 264 | - overflow: hidden; | ||
| 265 | - } | ||
| 266 | - | ||
| 267 | - .pull-diff-top { | ||
| 268 | - flex: none; | ||
| 269 | - display: flex; | ||
| 270 | - align-items: center; | ||
| 271 | - gap: 10px; | ||
| 272 | - height: 36px; | ||
| 273 | - padding: 0 14px; | ||
| 274 | - box-shadow: inset 0 -1px var(--border); | ||
| 275 | - } | ||
| 276 | - | ||
| 277 | - .pull-diff-scroll { | ||
| 278 | - flex: 1 1 auto; | ||
| 279 | - min-height: 0; | ||
| 280 | - overflow: auto; | ||
| 281 | - } | ||
| 282 | - | ||
| 283 | - // The section's own heading and file index repeat the head and the Files pane, so they are left out. | ||
| 284 | - .pull-diff-scroll > .diff-section > h2, | ||
| 285 | - .pull-diff-scroll > .diff-section > .diff-index { | ||
| 286 | - display: none; | ||
| 287 | - } | ||
| 288 | - | ||
| 289 | - .pull-diff-scroll .diff-section { | ||
| 290 | - margin: 0; | ||
| 291 | - } | ||
| 292 | - | ||
| 293 | - .pull-diff-scroll .diff-file { | ||
| 294 | - margin: 0; | ||
| 295 | - border-radius: 0; | ||
| 296 | - background: transparent; | ||
| 297 | - } | ||
| 298 | - | ||
| 299 | - // The file header sticks to the top of the pane, over the pane's own scroll, never over code. | ||
| 300 | - .pull-diff-scroll .diff-file-header { | ||
| 301 | - top: 0; | ||
| 302 | - border-radius: 0; | ||
| 303 | - } | ||
| 304 | - | ||
| 305 | - // Inline notes sit in an inset surface under their line. | ||
| 306 | - .pull-diff-scroll .review-thread { | ||
| 307 | - margin: 6px 12px 6px 96px; | ||
| 308 | - padding: 12px; | ||
| 309 | - border-radius: 8px; | ||
| 310 | - background: var(--surface-2); | ||
| 311 | - } | ||
| 312 | - | ||
| 313 | - // The compose line: one input and Comment, pinned at the pane's foot. Focus opens the rest. | ||
| 314 | - .pull-compose { | ||
| 315 | - flex: none; | ||
| 316 | - display: flex; | ||
| 317 | - flex-direction: column; | ||
| 318 | - gap: 8px; | ||
| 319 | - margin: 0; | ||
| 320 | - padding: 10px 14px; | ||
| 321 | - border-radius: 0; | ||
| 322 | - box-shadow: inset 0 1px var(--border); | ||
| 323 | - background: var(--surface); | ||
| 324 | - } | ||
| 325 | - | ||
| 326 | - .pull-more { | ||
| 327 | - display: none; | ||
| 328 | - align-items: center; | ||
| 329 | - gap: 12px; | ||
| 330 | - font-size: 13px; | ||
| 331 | - | ||
| 332 | - h2 { | ||
| 333 | - margin: 0; | ||
| 334 | - font-size: 13px; | ||
| 335 | - font-weight: 600; | ||
| 336 | - } | ||
| 337 | - | ||
| 338 | - p { | ||
| 339 | - margin: 0; | ||
| 340 | - } | ||
| 341 | - | ||
| 342 | - .review-inline { | ||
| 343 | - margin-left: auto; | ||
| 344 | - } | ||
| 345 | - } | ||
| 346 | - | ||
| 347 | - .pull-compose:focus-within .pull-more { | ||
| 348 | - display: flex; | ||
| 349 | - } | ||
| 350 | - | ||
| 351 | - .pull-compose-form { | ||
| 352 | - display: flex; | ||
| 353 | - align-items: center; | ||
| 354 | - gap: 8px; | ||
| 355 | - margin: 0; | ||
| 356 | - } | ||
| 357 | - | ||
| 358 | - .pull-compose .pull-input { | ||
| 359 | - flex: 1 1 auto; | ||
| 360 | - min-width: 0; | ||
| 361 | - height: 32px; | ||
| 362 | - padding: 0 12px; | ||
| 363 | - border: 0; | ||
| 364 | - border-radius: 7px; | ||
| 365 | - background: var(--bg); | ||
| 366 | - color: var(--text); | ||
| 367 | - box-shadow: inset 0 0 0 1px var(--border); | ||
| 368 | - font: inherit; | ||
| 369 | - font-size: 13px; | ||
| 370 | - outline: none; | ||
| 371 | - } | ||
| 372 | - | ||
| 373 | - .pull-compose .btn { | ||
| 374 | - flex: none; | ||
| 375 | - height: 36px; | ||
| 376 | - padding: 0 14px; | ||
| 377 | - border-radius: 7px; | ||
| 378 | - font-size: 13px; | ||
| 379 | - font-weight: 600; | ||
| 380 | - background: var(--surface-2); | ||
| 381 | - box-shadow: inset 0 0 0 1px var(--border); | ||
| 382 | - cursor: pointer; | ||
| 383 | - } | ||
| 384 | - | ||
| 385 | - .pull-compose .btn.primary { | ||
| 386 | - background: var(--accent); | ||
| 387 | - color: var(--accent-text); | ||
| 388 | - box-shadow: none; | ||
| 389 | - } | ||
| 390 | -} | ||
| 391 | - | ||
| 392 | -@keyframes pull-beat { | ||
| 393 | - 50% { | ||
| 394 | - opacity: 0.4; | ||
| 395 | - } | ||
| 396 | -} | ||
| 397 | - | ||
| 398 | -@media (min-width: 900px) and (prefers-reduced-motion: reduce) { | ||
| 399 | - .pull-check > .live { | ||
| 400 | - animation: none; | ||
| 401 | - } | ||
| 402 | -} | ||
style/_canvas_repo.scssdeleted+0 -608
| @@ -1,608 +0,0 @@ | |||
| 1 | -// canvas_repo: the repo home and the tree pages, matched to the approved layout study | ||
| 2 | -// (TimelineRepo.dc.html, see memory design/ALIVE.md). Two panes over one dock: the tree (340px) and | ||
| 3 | -// the README (the rest), then the dock (156px). Tokens only. Selectors carry .repo-home.canvas-repo so | ||
| 4 | -// they outrank the older repo home rules in _repo.scss, which are not repeated here. | ||
| 5 | - | ||
| 6 | -// Desktop: the panes fill the window above the dock. nav.js measures the top of .repo-home and the | ||
| 7 | -// footer (--pane-top, --pane-foot); the dock and its 12px gap come off the height. | ||
| 8 | -@media (min-width: 900px) { | ||
| 9 | - .repo-home.canvas-repo { | ||
| 10 | - --repo-home-h: max(360px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px) - 168px)); | ||
| 11 | - grid-template-columns: var(--tree-w, 340px) 12px minmax(0, 1fr); | ||
| 12 | - grid-template-rows: minmax(0, 1fr); | ||
| 13 | - gap: 0; | ||
| 14 | - height: var(--repo-home-h); | ||
| 15 | - margin-top: 12px; | ||
| 16 | - | ||
| 17 | - .repo-main, | ||
| 18 | - .repo-readme { | ||
| 19 | - height: auto; | ||
| 20 | - min-height: 0; | ||
| 21 | - } | ||
| 22 | - } | ||
| 23 | -} | ||
| 24 | - | ||
| 25 | -// The panes: surface, a 1px border, 10px radius, no shadow. Popovers drop out of the head, so the | ||
| 26 | -// panes do not clip; the scrolling parts are the tree rows and the README body. | ||
| 27 | -.repo-home.canvas-repo { | ||
| 28 | - .canvas-files, | ||
| 29 | - .canvas-readme { | ||
| 30 | - display: flex; | ||
| 31 | - flex-direction: column; | ||
| 32 | - min-width: 0; | ||
| 33 | - min-height: 0; | ||
| 34 | - overflow: visible; | ||
| 35 | - background: var(--surface); | ||
| 36 | - border: 1px solid var(--border); | ||
| 37 | - border-radius: 10px; | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - // Tree pane: the branch selector and the go-to-file tag share the head; the rows scroll below. | ||
| 41 | - .canvas-files { | ||
| 42 | - | ||
| 43 | - .ref-select { | ||
| 44 | - position: relative; | ||
| 45 | - flex: none; | ||
| 46 | - z-index: 6; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - // The branch keeps its exact spelling: a name is never upper-cased. | ||
| 50 | - .ref-select > summary { | ||
| 51 | - display: inline-flex; | ||
| 52 | - align-items: center; | ||
| 53 | - gap: 6px; | ||
| 54 | - height: 36px; | ||
| 55 | - padding: 0; | ||
| 56 | - background: none; | ||
| 57 | - border: 0; | ||
| 58 | - box-shadow: none; | ||
| 59 | - font-family: var(--mono); | ||
| 60 | - font-size: 13px; | ||
| 61 | - font-weight: 500; | ||
| 62 | - color: var(--text-2); | ||
| 63 | - cursor: pointer; | ||
| 64 | - list-style: none; | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - .ref-select > summary::-webkit-details-marker { | ||
| 68 | - display: none; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - .ref-select .ref-icon { | ||
| 72 | - display: none; | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - .ref-select .ref-name { | ||
| 76 | - padding: 0; | ||
| 77 | - background: none; | ||
| 78 | - border: 0; | ||
| 79 | - font: inherit; | ||
| 80 | - letter-spacing: inherit; | ||
| 81 | - text-transform: inherit; | ||
| 82 | - color: inherit; | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | - .ref-select .ref-caret svg { | ||
| 86 | - width: 10px; | ||
| 87 | - height: 10px; | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - .crumbs { | ||
| 91 | - flex: 1 1 auto; | ||
| 92 | - min-width: 0; | ||
| 93 | - overflow: hidden; | ||
| 94 | - font-family: var(--mono); | ||
| 95 | - font-size: 12px; | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - .crumbs ol { | ||
| 99 | - display: flex; | ||
| 100 | - margin: 0; | ||
| 101 | - padding: 0; | ||
| 102 | - list-style: none; | ||
| 103 | - overflow: hidden; | ||
| 104 | - white-space: nowrap; | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - // The go-to-file control sits at the right end, named, with its key beside the name. | ||
| 108 | - .finder-open { | ||
| 109 | - position: relative; | ||
| 110 | - align-self: center; | ||
| 111 | - display: inline-flex; | ||
| 112 | - align-items: center; | ||
| 113 | - flex: none; | ||
| 114 | - height: 20px; | ||
| 115 | - margin: 0 0 0 auto; | ||
| 116 | - padding: 0 7px; | ||
| 117 | - border: 0; | ||
| 118 | - border-radius: 5px; | ||
| 119 | - background: var(--surface-2); | ||
| 120 | - box-shadow: none; | ||
| 121 | - font-family: var(--mono); | ||
| 122 | - font-size: 11px; | ||
| 123 | - color: var(--text-2); | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - .finder-open .finder-label { | ||
| 127 | - margin-right: 6px; | ||
| 128 | - font-family: var(--font); | ||
| 129 | - font-size: 12px; | ||
| 130 | - } | ||
| 131 | - | ||
| 132 | - .finder-open kbd { | ||
| 133 | - padding: 0; | ||
| 134 | - border: 0; | ||
| 135 | - background: none; | ||
| 136 | - font: inherit; | ||
| 137 | - color: inherit; | ||
| 138 | - } | ||
| 139 | - | ||
| 140 | - // Rows: 30px, one line. The whole row is the target (the name link stretches over it). | ||
| 141 | - .table-wrap.tree-list { | ||
| 142 | - flex: 1 1 auto; | ||
| 143 | - min-height: 0; | ||
| 144 | - overflow-y: auto; | ||
| 145 | - padding: 4px 0; | ||
| 146 | - border: 0; | ||
| 147 | - border-radius: 0; | ||
| 148 | - background: none; | ||
| 149 | - box-shadow: none; | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - .tree-entry { | ||
| 153 | - position: relative; | ||
| 154 | - display: flex; | ||
| 155 | - align-items: center; | ||
| 156 | - gap: 10px; | ||
| 157 | - height: 30px; | ||
| 158 | - min-width: 0; | ||
| 159 | - padding: 0 14px; | ||
| 160 | - } | ||
| 161 | - | ||
| 162 | - .tree-entry:hover { | ||
| 163 | - background: var(--surface-2); | ||
| 164 | - } | ||
| 165 | - | ||
| 166 | - .tree-kind { | ||
| 167 | - display: inline-flex; | ||
| 168 | - flex: none; | ||
| 169 | - color: var(--muted); | ||
| 170 | - } | ||
| 171 | - | ||
| 172 | - .tree-kind .kind-icon { | ||
| 173 | - width: 14px; | ||
| 174 | - height: 14px; | ||
| 175 | - } | ||
| 176 | - | ||
| 177 | - .tree-entry-name { | ||
| 178 | - flex: 1 1 auto; | ||
| 179 | - min-width: 0; | ||
| 180 | - overflow: hidden; | ||
| 181 | - font-family: var(--mono); | ||
| 182 | - font-size: 13px; | ||
| 183 | - white-space: nowrap; | ||
| 184 | - text-overflow: ellipsis; | ||
| 185 | - color: var(--text); | ||
| 186 | - text-decoration: none; | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - a.tree-entry-name::after { | ||
| 190 | - content: ""; | ||
| 191 | - position: absolute; | ||
| 192 | - inset: 0; | ||
| 193 | - } | ||
| 194 | - | ||
| 195 | - .tree-entry-sha { | ||
| 196 | - flex: none; | ||
| 197 | - font-size: 12px; | ||
| 198 | - color: var(--muted); | ||
| 199 | - } | ||
| 200 | - | ||
| 201 | - .tree-entry-age { | ||
| 202 | - flex: none; | ||
| 203 | - margin-left: auto; | ||
| 204 | - font-size: 12px; | ||
| 205 | - text-align: right; | ||
| 206 | - white-space: nowrap; | ||
| 207 | - color: var(--muted); | ||
| 208 | - } | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - // README pane: the file name at the left, the facts and Clone at the right. | ||
| 212 | - .canvas-readme { | ||
| 213 | - | ||
| 214 | - .readme-meta { | ||
| 215 | - overflow: hidden; | ||
| 216 | - text-overflow: ellipsis; | ||
| 217 | - } | ||
| 218 | - | ||
| 219 | - // Clone is a plain button, not the filled one. The popover drops over the body. | ||
| 220 | - .clone { | ||
| 221 | - position: relative; | ||
| 222 | - z-index: 6; | ||
| 223 | - } | ||
| 224 | - | ||
| 225 | - .clone > summary.button { | ||
| 226 | - height: 28px; | ||
| 227 | - padding: 0 10px; | ||
| 228 | - border: 0; | ||
| 229 | - background: none; | ||
| 230 | - box-shadow: inset 0 0 0 1px var(--border); | ||
| 231 | - font-family: var(--font); | ||
| 232 | - font-size: 12px; | ||
| 233 | - font-weight: 500; | ||
| 234 | - color: var(--text); | ||
| 235 | - } | ||
| 236 | - | ||
| 237 | - // The body scrolls; padding 24px; prose left aligned, 760px, 14.5px over 1.6. | ||
| 238 | - .canvas-body { | ||
| 239 | - flex: 1 1 auto; | ||
| 240 | - min-height: 0; | ||
| 241 | - padding: 24px; | ||
| 242 | - overflow-y: auto; | ||
| 243 | - text-align: left; | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | - .canvas-body .repo-strip { | ||
| 247 | - margin: 0 0 16px; | ||
| 248 | - max-width: 760px; | ||
| 249 | - } | ||
| 250 | - | ||
| 251 | - .canvas-body .readme { | ||
| 252 | - max-width: 760px; | ||
| 253 | - margin: 0; | ||
| 254 | - padding: 0; | ||
| 255 | - background: none; | ||
| 256 | - border: 0; | ||
| 257 | - box-shadow: none; | ||
| 258 | - } | ||
| 259 | - | ||
| 260 | - .canvas-body .markdown-body { | ||
| 261 | - flex: none; | ||
| 262 | - max-width: 760px; | ||
| 263 | - overflow: visible; | ||
| 264 | - font-size: 14.5px; | ||
| 265 | - line-height: 1.6; | ||
| 266 | - color: var(--text-2); | ||
| 267 | - } | ||
| 268 | - | ||
| 269 | - .canvas-body .markdown-body > * { | ||
| 270 | - max-width: 760px; | ||
| 271 | - margin-left: 0; | ||
| 272 | - margin-right: 0; | ||
| 273 | - } | ||
| 274 | - | ||
| 275 | - .canvas-body .markdown-body h1, | ||
| 276 | - .canvas-body .markdown-body h2, | ||
| 277 | - .canvas-body .markdown-body h3 { | ||
| 278 | - color: var(--text); | ||
| 279 | - } | ||
| 280 | - | ||
| 281 | - .canvas-body .readme-text { | ||
| 282 | - font-family: var(--mono); | ||
| 283 | - font-size: 13px; | ||
| 284 | - white-space: pre-wrap; | ||
| 285 | - color: var(--text-2); | ||
| 286 | - } | ||
| 287 | - | ||
| 288 | - .canvas-body .empty-state { | ||
| 289 | - text-align: left; | ||
| 290 | - } | ||
| 291 | - } | ||
| 292 | -} | ||
| 293 | - | ||
| 294 | -// The dock: one pane under the panes, the full width. Its info row is 40px, its strip row 60px, with | ||
| 295 | -// 20px between; the padding is 20px 16px 0. It has no overflow clip, so the message expander can | ||
| 296 | -// open above it over the panes. | ||
| 297 | -.canvas-dock { | ||
| 298 | - position: relative; | ||
| 299 | - z-index: 2; | ||
| 300 | - box-sizing: border-box; | ||
| 301 | - display: grid; | ||
| 302 | - grid-template-rows: 40px 60px; | ||
| 303 | - row-gap: 20px; | ||
| 304 | - height: 156px; | ||
| 305 | - min-width: 0; | ||
| 306 | - margin-top: 12px; | ||
| 307 | - padding: 20px 16px 0; | ||
| 308 | - background: var(--surface); | ||
| 309 | - border: 1px solid var(--border); | ||
| 310 | - border-radius: 10px; | ||
| 311 | - font-size: 13px; | ||
| 312 | -} | ||
| 313 | - | ||
| 314 | -.canvas-dock .dock-info { | ||
| 315 | - display: flex; | ||
| 316 | - align-items: center; | ||
| 317 | - gap: 12px; | ||
| 318 | - height: 40px; | ||
| 319 | - min-width: 0; | ||
| 320 | - | ||
| 321 | - > * { | ||
| 322 | - flex: none; | ||
| 323 | - white-space: nowrap; | ||
| 324 | - } | ||
| 325 | - | ||
| 326 | - .dock-run { | ||
| 327 | - display: inline-flex; | ||
| 328 | - align-items: center; | ||
| 329 | - gap: 8px; | ||
| 330 | - font-weight: 600; | ||
| 331 | - color: var(--text); | ||
| 332 | - text-decoration: none; | ||
| 333 | - } | ||
| 334 | - | ||
| 335 | - // The state word is accent only while the run goes. | ||
| 336 | - .dock-state { | ||
| 337 | - color: var(--text-2); | ||
| 338 | - } | ||
| 339 | - | ||
| 340 | - .dock-state.is-live { | ||
| 341 | - color: var(--accent); | ||
| 342 | - } | ||
| 343 | - | ||
| 344 | - .sha { | ||
| 345 | - font-family: var(--mono); | ||
| 346 | - font-size: 12px; | ||
| 347 | - color: var(--text-2); | ||
| 348 | - } | ||
| 349 | - | ||
| 350 | - .dock-avatar { | ||
| 351 | - width: 20px; | ||
| 352 | - height: 20px; | ||
| 353 | - } | ||
| 354 | - | ||
| 355 | - // The subject takes the rest of the row and clips, one line. | ||
| 356 | - .dock-subject { | ||
| 357 | - flex: 1 1 auto; | ||
| 358 | - min-width: 0; | ||
| 359 | - overflow: hidden; | ||
| 360 | - white-space: nowrap; | ||
| 361 | - text-overflow: ellipsis; | ||
| 362 | - color: var(--text); | ||
| 363 | - text-decoration: none; | ||
| 364 | - } | ||
| 365 | - | ||
| 366 | - .dock-subject .commit-line { | ||
| 367 | - display: block; | ||
| 368 | - overflow: hidden; | ||
| 369 | - text-overflow: ellipsis; | ||
| 370 | - white-space: nowrap; | ||
| 371 | - } | ||
| 372 | - | ||
| 373 | - .dock-expand { | ||
| 374 | - position: relative; | ||
| 375 | - } | ||
| 376 | - | ||
| 377 | - .dock-expand > summary { | ||
| 378 | - display: inline-flex; | ||
| 379 | - align-items: center; | ||
| 380 | - justify-content: center; | ||
| 381 | - width: 24px; | ||
| 382 | - height: 24px; | ||
| 383 | - border-radius: 6px; | ||
| 384 | - color: var(--muted); | ||
| 385 | - cursor: pointer; | ||
| 386 | - list-style: none; | ||
| 387 | - } | ||
| 388 | - | ||
| 389 | - .dock-expand > summary::-webkit-details-marker { | ||
| 390 | - display: none; | ||
| 391 | - } | ||
| 392 | - | ||
| 393 | - .dock-expand > summary:hover, | ||
| 394 | - .dock-expand[open] > summary { | ||
| 395 | - background: var(--surface-2); | ||
| 396 | - color: var(--text); | ||
| 397 | - } | ||
| 398 | - | ||
| 399 | - // The full message opens above the dock: body included, scrolling inside its own box. | ||
| 400 | - .dock-message { | ||
| 401 | - position: absolute; | ||
| 402 | - bottom: calc(100% + 8px); | ||
| 403 | - left: 0; | ||
| 404 | - z-index: 10; | ||
| 405 | - width: min(640px, 80vw); | ||
| 406 | - max-height: 60vh; | ||
| 407 | - overflow-y: auto; | ||
| 408 | - box-sizing: border-box; | ||
| 409 | - padding: 14px 16px; | ||
| 410 | - background: var(--surface); | ||
| 411 | - border: 1px solid var(--border); | ||
| 412 | - border-radius: 10px; | ||
| 413 | - white-space: normal; | ||
| 414 | - } | ||
| 415 | - | ||
| 416 | - .dock-message-by { | ||
| 417 | - margin: 0; | ||
| 418 | - } | ||
| 419 | - | ||
| 420 | - .dock-message-text { | ||
| 421 | - margin: 8px 0 0; | ||
| 422 | - font-family: var(--mono); | ||
| 423 | - font-size: 12.5px; | ||
| 424 | - line-height: 1.5; | ||
| 425 | - white-space: pre-wrap; | ||
| 426 | - color: var(--text); | ||
| 427 | - } | ||
| 428 | - | ||
| 429 | - .dock-count { | ||
| 430 | - color: var(--muted); | ||
| 431 | - } | ||
| 432 | - | ||
| 433 | - .dock-all { | ||
| 434 | - font-weight: 600; | ||
| 435 | - color: var(--text); | ||
| 436 | - text-decoration: none; | ||
| 437 | - } | ||
| 438 | -} | ||
| 439 | - | ||
| 440 | -// The strip row: the label in a 254px column, then the bars of the last 48 commits, 60px tall. | ||
| 441 | -.canvas-dock .dock-history { | ||
| 442 | - display: grid; | ||
| 443 | - grid-template-columns: 254px minmax(0, 1fr); | ||
| 444 | - height: 60px; | ||
| 445 | - min-width: 0; | ||
| 446 | - order: 0; | ||
| 447 | -} | ||
| 448 | - | ||
| 449 | -.canvas-dock .history-strip { | ||
| 450 | - display: contents; | ||
| 451 | -} | ||
| 452 | - | ||
| 453 | -.canvas-dock .history-label { | ||
| 454 | - position: static; | ||
| 455 | - align-self: start; | ||
| 456 | - width: auto; | ||
| 457 | - height: auto; | ||
| 458 | - overflow: visible; | ||
| 459 | - clip-path: none; | ||
| 460 | - margin: 0; | ||
| 461 | - padding-top: 2px; | ||
| 462 | - font-family: var(--mono); | ||
| 463 | - font-size: 12px; | ||
| 464 | - font-weight: 500; | ||
| 465 | - color: var(--text-2); | ||
| 466 | -} | ||
| 467 | - | ||
| 468 | -.canvas-dock .history-bars { | ||
| 469 | - gap: 3px; | ||
| 470 | - height: 60px; | ||
| 471 | - min-width: 0; | ||
| 472 | - align-items: flex-end; | ||
| 473 | - | ||
| 474 | - > a { | ||
| 475 | - flex: 1 1 0; | ||
| 476 | - min-width: 2px; | ||
| 477 | - border-radius: 2px; | ||
| 478 | - background: var(--muted); | ||
| 479 | - opacity: 0.55; | ||
| 480 | - } | ||
| 481 | - | ||
| 482 | - > a.hs-bad { | ||
| 483 | - background: var(--bad); | ||
| 484 | - opacity: 1; | ||
| 485 | - } | ||
| 486 | - | ||
| 487 | - // Accent means a run is going. The newest commit is only brighter: a bar says nothing of a result | ||
| 488 | - // unless a run failed, and a repo with no CI has none. | ||
| 489 | - > a.hs-live { | ||
| 490 | - background: var(--accent); | ||
| 491 | - opacity: 1; | ||
| 492 | - } | ||
| 493 | - | ||
| 494 | - > a:last-child:not(.hs-bad, .hs-live) { | ||
| 495 | - opacity: 1; | ||
| 496 | - } | ||
| 497 | -} | ||
| 498 | - | ||
| 499 | -// Narrow windows: the panes stack and the page grows; the strip, which needs the width, is left out. | ||
| 500 | -@media (max-width: 899px) { | ||
| 501 | - .repo-home.canvas-repo { | ||
| 502 | - grid-template-columns: minmax(0, 1fr); | ||
| 503 | - grid-template-rows: auto; | ||
| 504 | - height: auto; | ||
| 505 | - margin-top: 12px; | ||
| 506 | - } | ||
| 507 | - | ||
| 508 | - .repo-home.canvas-repo .canvas-files .table-wrap.tree-list { | ||
| 509 | - overflow: visible; | ||
| 510 | - } | ||
| 511 | - | ||
| 512 | - .repo-home.canvas-repo .canvas-readme .canvas-body { | ||
| 513 | - overflow: visible; | ||
| 514 | - } | ||
| 515 | - | ||
| 516 | - .canvas-dock { | ||
| 517 | - height: auto; | ||
| 518 | - grid-template-rows: auto; | ||
| 519 | - } | ||
| 520 | - | ||
| 521 | - .canvas-dock .dock-info { | ||
| 522 | - flex-wrap: wrap; | ||
| 523 | - height: auto; | ||
| 524 | - row-gap: 8px; | ||
| 525 | - } | ||
| 526 | - | ||
| 527 | - .canvas-dock .dock-subject { | ||
| 528 | - flex: 1 1 100%; | ||
| 529 | - order: 1; | ||
| 530 | - } | ||
| 531 | -} | ||
| 532 | - | ||
| 533 | -@media (prefers-reduced-motion: reduce) { | ||
| 534 | - .canvas-dock .health-dot.ember { | ||
| 535 | - animation: none; | ||
| 536 | - } | ||
| 537 | -} | ||
| 538 | - | ||
| 539 | -// Fixes from the 1440px review (2026-11-01). Each rule is named by the screen it fixes. | ||
| 540 | - | ||
| 541 | -// Clone popover: the SSH hint wraps inside the 420px panel instead of running past its right edge. | ||
| 542 | -.repo-home.canvas-repo .canvas-readme .clone .pop-panel > .small { | ||
| 543 | - max-width: 100%; | ||
| 544 | - white-space: normal; | ||
| 545 | - overflow-wrap: anywhere; | ||
| 546 | -} | ||
| 547 | - | ||
| 548 | -// Dock: the full message opens from the expander's right edge, and never wider than the window. | ||
| 549 | -.canvas-dock .dock-info .dock-expand .dock-message { | ||
| 550 | - left: auto; | ||
| 551 | - right: 0; | ||
| 552 | - width: 640px; | ||
| 553 | - max-width: calc(100vw - 48px); | ||
| 554 | -} | ||
| 555 | - | ||
| 556 | -// Dock: the expander is a 20px square with a down chevron, the same as the tab-more toggle. | ||
| 557 | -.canvas-dock .dock-info .dock-expand > summary { | ||
| 558 | - width: 20px; | ||
| 559 | - height: 20px; | ||
| 560 | - border-radius: 5px; | ||
| 561 | -} | ||
| 562 | - | ||
| 563 | -.canvas-dock .dock-info .dock-expand > summary svg { | ||
| 564 | - width: 14px; | ||
| 565 | - height: 14px; | ||
| 566 | - fill: none; | ||
| 567 | - stroke: currentColor; | ||
| 568 | - stroke-width: 2; | ||
| 569 | - stroke-linecap: round; | ||
| 570 | - stroke-linejoin: round; | ||
| 571 | -} | ||
| 572 | - | ||
| 573 | -// Tree pane with no README: the message sits on the pane head's 14px inset, not the body's 24px. | ||
| 574 | -.repo-home.canvas-repo .canvas-readme .canvas-body:has(> .empty-state) { | ||
| 575 | - padding: 14px; | ||
| 576 | -} | ||
| 577 | - | ||
| 578 | -.repo-home.canvas-repo .canvas-readme .canvas-body > .empty-state { | ||
| 579 | - padding: 0; | ||
| 580 | -} | ||
| 581 | - | ||
| 582 | -// Blob page: the rendered Markdown starts 24px under the file bar. | ||
| 583 | -.file > .markdown-body { | ||
| 584 | - padding-top: 24px; | ||
| 585 | -} | ||
| 586 | - | ||
| 587 | -// Blame: the table is wider than the pane, so the pane scrolls both ways (the scrollbar shows at the | ||
| 588 | -// foot of the pane) and the file bar stays at the top. Long lines are never cut at the edge. | ||
| 589 | -.file.fit-pane:has(> .blame-table) { | ||
| 590 | - overflow: auto; | ||
| 591 | -} | ||
| 592 | - | ||
| 593 | -.file.fit-pane:has(> .blame-table) > .file-head { | ||
| 594 | - position: sticky; | ||
| 595 | - top: 0; | ||
| 596 | - z-index: 2; | ||
| 597 | -} | ||
| 598 | - | ||
| 599 | -.file > .file-view { | ||
| 600 | - overflow: auto; | ||
| 601 | -} | ||
| 602 | - | ||
| 603 | -// Finder: the input's text sits on the same 10px inset as the result rows (1px border included). | ||
| 604 | -dialog.finder .finder-input { | ||
| 605 | - padding-left: 9px; | ||
| 606 | - padding-right: 9px; | ||
| 607 | -} | ||
| 608 | - | ||
style/_fit.scssdeleted+0 -11
| @@ -1,11 +0,0 @@ | |||
| 1 | -// A pane that takes the window's remaining height, so the page itself does not scroll: what is too | ||
| 2 | -// long for the window scrolls inside it. nav.js measures the top and the footer (syncShellTop). Below | ||
| 3 | -// 900px pages stack, so a pane is as tall as its content. | ||
| 4 | -@media (min-width: 900px) { | ||
| 5 | - .fit-pane { | ||
| 6 | - box-sizing: border-box; | ||
| 7 | - height: max(360px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px))); | ||
| 8 | - overflow: auto; | ||
| 9 | - overscroll-behavior: contain; | ||
| 10 | - } | ||
| 11 | -} | ||
style/_fit_admin.scssdeleted+0 -38
| @@ -1,38 +0,0 @@ | |||
| 1 | -// One-screen layout of admin dashboards and forms. See _fit.scss. | ||
| 2 | -// | ||
| 3 | -// The selectors here are compound on purpose: _account_admin.scss and main.scss load after this | ||
| 4 | -// partial, so a single class rule there would win on equal specificity. | ||
| 5 | - | ||
| 6 | -// A fit pane's bottom margin would add to the page height, so it goes. | ||
| 7 | -.card.fit-pane { | ||
| 8 | - margin-bottom: 0; | ||
| 9 | -} | ||
| 10 | - | ||
| 11 | -// Instance health (/admin/health): the storage and services cards sit side by side, under the | ||
| 12 | -// summary. The alerts and the footnote span both columns. | ||
| 13 | -@media (min-width: 900px) { | ||
| 14 | - .health-page { | ||
| 15 | - display: grid; | ||
| 16 | - grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
| 17 | - column-gap: 16px; | ||
| 18 | - | ||
| 19 | - } | ||
| 20 | -} | ||
| 21 | - | ||
| 22 | -// User detail (/admin/users/{id}): the actions and the danger zone side by side, under the header. | ||
| 23 | -@media (min-width: 900px) { | ||
| 24 | - | ||
| 25 | -} | ||
| 26 | - | ||
| 27 | -// Mail settings (/admin/mail): the SMTP form runs three fields across, the actions span the row. | ||
| 28 | -@media (min-width: 900px) { | ||
| 29 | - form.stack[action="/admin/mail"] { | ||
| 30 | - display: grid; | ||
| 31 | - grid-template-columns: repeat(3, minmax(0, 1fr)); | ||
| 32 | - gap: 14px 24px; | ||
| 33 | - | ||
| 34 | - > .actions { | ||
| 35 | - grid-column: 1 / -1; | ||
| 36 | - } | ||
| 37 | - } | ||
| 38 | -} | ||
style/_fit_code.scssdeleted+0 -53
| @@ -1,53 +0,0 @@ | |||
| 1 | -// One-screen layout of code, commits and CI logs. See _fit.scss. | ||
| 2 | - | ||
| 3 | -// File view (blob): the file header stays put and the code, the image or the rendered Markdown is | ||
| 4 | -// the pane under it. The line anchors (#L12) scroll that box, since it is the nearest scroller. | ||
| 5 | -@media (min-width: 900px) { | ||
| 6 | - .file.fit-pane { | ||
| 7 | - display: flex; | ||
| 8 | - flex-direction: column; | ||
| 9 | - overflow: hidden; | ||
| 10 | - | ||
| 11 | - .file-head { | ||
| 12 | - flex: none; | ||
| 13 | - } | ||
| 14 | - | ||
| 15 | - .file-view, | ||
| 16 | - .file-image, | ||
| 17 | - .markdown-body { | ||
| 18 | - flex: 1 1 auto; | ||
| 19 | - min-height: 0; | ||
| 20 | - overflow: auto; | ||
| 21 | - } | ||
| 22 | - } | ||
| 23 | -} | ||
| 24 | - | ||
| 25 | -// Commit page: the title and the commit card stay above, and the diff fills the rest of the window. | ||
| 26 | -// The header is tall, so the pane may get less than the usual 360px minimum. | ||
| 27 | -@media (min-width: 900px) { | ||
| 28 | - .commit-diff.fit-pane { | ||
| 29 | - height: max(240px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px))); | ||
| 30 | - } | ||
| 31 | -} | ||
| 32 | - | ||
| 33 | -// Run page and runs list: the selected run (the right column of the split) is the pane. The runs | ||
| 34 | -// list beside it (.ci-side, main.scss) uses the same height. | ||
| 35 | -@media (min-width: 761px) { | ||
| 36 | - .ci-main { | ||
| 37 | - max-height: max(320px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px))); | ||
| 38 | - overflow: auto; | ||
| 39 | - } | ||
| 40 | -} | ||
| 41 | - | ||
| 42 | -// Profile overview: a little less air between the header, the tabs, the calendar and the pins, and | ||
| 43 | -// a smaller avatar, so the calendar and the pinned repos fit one window. | ||
| 44 | -@media (min-width: 900px) { | ||
| 45 | - .profile-page { | ||
| 46 | - gap: 16px; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - .profile-avatar { | ||
| 50 | - width: 144px; | ||
| 51 | - height: 144px; | ||
| 52 | - } | ||
| 53 | -} | ||
style/_fit_forms.scssdeleted+0 -64
| @@ -1,64 +0,0 @@ | |||
| 1 | - | ||
| 2 | - | ||
| 3 | -@media (min-width: 900px) { | ||
| 4 | - // A card that is a pane with a form in it: no bottom margin (the pane fills the window), and the | ||
| 5 | - // form takes the rest of the card under the heading. | ||
| 6 | - .fit-pane.card { | ||
| 7 | - margin-bottom: 0; | ||
| 8 | - | ||
| 9 | - &:has(> form) { | ||
| 10 | - display: flex; | ||
| 11 | - flex-direction: column; | ||
| 12 | - | ||
| 13 | - > form { | ||
| 14 | - flex: 1 1 auto; | ||
| 15 | - min-height: 0; | ||
| 16 | - } | ||
| 17 | - } | ||
| 18 | - } | ||
| 19 | - | ||
| 20 | - // The editor's label takes the rest of the form, and its textarea fills the label. | ||
| 21 | - .fit-pane > form > label:has(> textarea) { | ||
| 22 | - flex: 1 1 0; | ||
| 23 | - min-height: 0; | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - .fit-pane > form > label > textarea { | ||
| 27 | - flex: 1 1 0; | ||
| 28 | - min-height: 6rem; | ||
| 29 | - height: auto; | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - // The snippet form is the pane itself: its doc, its file card and the active file fill it. | ||
| 33 | - .snippet-form.fit-pane { | ||
| 34 | - // The pane clips its overflow, so the focus ring of the card edges gets a little room. | ||
| 35 | - padding: 4px; | ||
| 36 | - | ||
| 37 | - .snippet-files { | ||
| 38 | - flex: 1 1 auto; | ||
| 39 | - min-height: 0; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - // The active file is shown by a :has() rule in main.scss (specificity 1,3,0). This one is one | ||
| 43 | - // class higher, so the file can be a flex column that its contents fill. | ||
| 44 | - @for $i from 0 through 9 { | ||
| 45 | - .snippet-files:has(#snippet-tab-#{$i}:checked) .snippet-panel-#{$i} { | ||
| 46 | - display: flex; | ||
| 47 | - flex-direction: column; | ||
| 48 | - flex: 1 1 auto; | ||
| 49 | - min-height: 0; | ||
| 50 | - } | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - .snippet-content { | ||
| 54 | - flex: 1 1 0; | ||
| 55 | - min-height: 0; | ||
| 56 | - height: auto; | ||
| 57 | - } | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - // The form's two cards share a row on the widest windows; the header and the notes span both. | ||
| 61 | - @media (min-width: 1200px) { | ||
| 62 | - | ||
| 63 | - } | ||
| 64 | -} | ||
style/_fit_lists.scssdeleted+0 -4
| @@ -1,4 +0,0 @@ | |||
| 1 | -// One-screen layout of notifications, security log and audit log. See _fit.scss. | ||
| 2 | -@media (min-width: 900px) { | ||
| 3 | - | ||
| 4 | -} | ||
style/_fit_settings.scssdeleted+0 -10
| @@ -1,10 +0,0 @@ | |||
| 1 | - | ||
| 2 | - | ||
| 3 | -@media (min-width: 900px) { | ||
| 4 | - | ||
| 5 | -} | ||
| 6 | - | ||
| 7 | -// The new webhook form: the fields in the left column, the event list in the right one. | ||
| 8 | -@media (min-width: 900px) { | ||
| 9 | - | ||
| 10 | -} | ||
style/_fit_tables.scssdeleted+0 -5
| @@ -1,5 +0,0 @@ | |||
| 1 | - | ||
| 2 | - | ||
| 3 | -@media (max-width: 899px) { | ||
| 4 | - | ||
| 5 | -} | ||
style/_fit_threads.scssdeleted+0 -17
| @@ -1,17 +0,0 @@ | |||
| 1 | -// One-screen layout of issues, pull requests and discussions. See _fit.scss. | ||
| 2 | -// The conversation column and the side column carry .fit-pane in the markup: from 900px each scrolls | ||
| 3 | -// on its own and the page does not. The padding keeps a focus ring and the comment box's edge from | ||
| 4 | -// being cut by the scroller, and leaves room under the last item. | ||
| 5 | -@media (min-width: 900px) { | ||
| 6 | - .issue-column.fit-pane, | ||
| 7 | - .issue-sidebar.fit-pane { | ||
| 8 | - padding: 2px 8px 16px 2px; | ||
| 9 | - scrollbar-gutter: stable; | ||
| 10 | - } | ||
| 11 | - | ||
| 12 | - // A pull's files: the review bar and the diff scroll inside the pane. The header and tabs above it stay | ||
| 13 | - // in view, and the sticky file headers of the diff stick inside the pane. | ||
| 14 | - .fit-pane > .diff-section { | ||
| 15 | - padding: 2px 8px 16px 2px; | ||
| 16 | - } | ||
| 17 | -} | ||
style/_kb_rerun.scssmodified+6 -38
| @@ -1,21 +1,14 @@ | |||
| 1 | -// The Re-run control of a CI run row, which r reruns from the keyboard. It is a small quiet button in | 1 | +// The Re-run control of a CI run row, which r reruns from the keyboard. It is the shared quiet action |
| 2 | -// the row's top corner, shown on the hovered, focused or selected row. It sits over the row's corner, | 2 | +// right after the row's text, shown on the hovered, focused or selected row, and always on touch. |
| 3 | -// so the row keeps its height, and the title leaves room for it. | ||
| 4 | - | ||
| 5 | -.ci-run-list > li { | ||
| 6 | - position: relative; | ||
| 7 | -} | ||
| 8 | 3 | ||
| 9 | .ci-row-rerun-form { | 4 | .ci-row-rerun-form { |
| 10 | - position: absolute; | ||
| 11 | - top: 8px; | ||
| 12 | - right: 8px; | ||
| 13 | margin: 0; | 5 | margin: 0; |
| 14 | opacity: 0; | 6 | opacity: 0; |
| 15 | 7 | ||
| 16 | - li:hover &, | 8 | + .ci-run-item:hover &, |
| 17 | - li:focus-within &, | 9 | + .ci-run-item:focus-within &, |
| 18 | - li.kb-sel & { | 10 | + .ci-run-item.kb-sel &, |
| 11 | + .ci-run-item:has(> .ci-row[aria-current="true"]) & { | ||
| 19 | opacity: 1; | 12 | opacity: 1; |
| 20 | } | 13 | } |
| 21 | 14 | ||
| @@ -23,28 +16,3 @@ | |||
| 23 | opacity: 1; | 16 | opacity: 1; |
| 24 | } | 17 | } |
| 25 | } | 18 | } |
| 26 | - | ||
| 27 | -li:has(> .ci-row-rerun-form) .ci-row-title { | ||
| 28 | - padding-right: 64px; | ||
| 29 | -} | ||
| 30 | - | ||
| 31 | -.ci-row-rerun { | ||
| 32 | - height: 28px; | ||
| 33 | - padding: 0 10px; | ||
| 34 | - font-size: 13px; | ||
| 35 | - color: var(--text-2); | ||
| 36 | - background: var(--surface); | ||
| 37 | - border: 1px solid var(--border); | ||
| 38 | - border-radius: var(--radius-md); | ||
| 39 | - cursor: pointer; | ||
| 40 | - | ||
| 41 | - &:hover { | ||
| 42 | - color: var(--text); | ||
| 43 | - border-color: var(--border-strong); | ||
| 44 | - } | ||
| 45 | -} | ||
| 46 | - | ||
| 47 | -@media (prefers-reduced-motion: reduce) { | ||
| 48 | - .ci-row-rerun-form { | ||
| 49 | - } | ||
| 50 | -} | ||
style/_lang_admin.scssdeleted+0 -78
| @@ -1,78 +0,0 @@ | |||
| 1 | -// Settings and admin pages: the pages behind the site section sidebar (`.shell-site`, see views/mod.rs). | ||
| 2 | -// Main takes the window's full width. From 900px its one pane fills it, or a second pane sits beside | ||
| 3 | -// the first at a form's width, and anything that is not a pane (the head, a notice) spans the row. Forms stop at | ||
| 4 | -// 720px and stay left aligned. Repo, org and other pages are not affected. | ||
| 5 | - | ||
| 6 | -// The page's column: main itself, or the `data-live` wrapper that most admin pages put inside it. | ||
| 7 | -$page-column: ".shell-site > .shell-body > main, .shell-site > .shell-body > main > [data-live]:not(.srv-page):not(.health-page):not(.user-page):not(.teams-page)"; | ||
| 8 | - | ||
| 9 | -#{$page-column} { | ||
| 10 | - min-width: 0; | ||
| 11 | - max-width: none; | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -@media (min-width: 900px) { | ||
| 15 | - #{$page-column} { | ||
| 16 | - display: grid; | ||
| 17 | - grid-template-columns: minmax(0, 1fr); | ||
| 18 | - align-content: start; | ||
| 19 | - align-items: start; | ||
| 20 | - gap: 16px; | ||
| 21 | - | ||
| 22 | - > :not(.card) { | ||
| 23 | - grid-column: 1 / -1; | ||
| 24 | - } | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | -} | ||
| 28 | - | ||
| 29 | -// The head's action (Security's link to the log) sits at the right end of the one row. | ||
| 30 | -@media (min-width: 900px) { | ||
| 31 | - | ||
| 32 | -} | ||
| 33 | - | ||
| 34 | -// Panes side by side end at the same height. A card's bottom margin would shorten a stretched pane | ||
| 35 | -// by 16px, so the split's and the grids' cards drop it; the grid gap already spaces them. | ||
| 36 | -.health-page > .card { | ||
| 37 | - margin-bottom: 0; | ||
| 38 | -} | ||
| 39 | - | ||
| 40 | -// Server settings: every field's head is one 24px line, so the controls of a row sit on one line. A | ||
| 41 | -// label that does not fit is clipped with its full text in `title`; the badges keep their place. | ||
| 42 | -.srv-form .srv-field .srv-head { | ||
| 43 | - height: 24px; | ||
| 44 | - flex-wrap: nowrap; | ||
| 45 | - gap: 6px; | ||
| 46 | -} | ||
| 47 | - | ||
| 48 | -.srv-form .srv-field .srv-label { | ||
| 49 | - min-width: 0; | ||
| 50 | - margin-right: 0; | ||
| 51 | - overflow: hidden; | ||
| 52 | - text-overflow: ellipsis; | ||
| 53 | - white-space: nowrap; | ||
| 54 | -} | ||
| 55 | - | ||
| 56 | -.srv-form .srv-field .srv-head > .badge { | ||
| 57 | - flex: none; | ||
| 58 | - white-space: nowrap; | ||
| 59 | -} | ||
| 60 | - | ||
| 61 | -// Paths and other fixed values: one mono line, the same height as the inputs, scrolled sideways | ||
| 62 | -// rather than broken mid-word. | ||
| 63 | -.srv-form .srv-field .srv-fixed { | ||
| 64 | - display: block; | ||
| 65 | - box-sizing: border-box; | ||
| 66 | - height: var(--control-h); | ||
| 67 | - min-height: 0; | ||
| 68 | - padding: 0 12px; | ||
| 69 | - font-size: 13px; | ||
| 70 | - line-height: calc(var(--control-h) - 2px); | ||
| 71 | - white-space: nowrap; | ||
| 72 | - overflow-x: auto; | ||
| 73 | - overflow-y: hidden; | ||
| 74 | - overflow-wrap: normal; | ||
| 75 | - word-break: normal; | ||
| 76 | - scrollbar-width: thin; | ||
| 77 | -} | ||
| 78 | - | ||
style/_lang_browse.scssdeleted+0 -49
| @@ -1,49 +0,0 @@ | |||
| 1 | - | ||
| 2 | - | ||
| 3 | -@media (min-width: 900px) { | ||
| 4 | - | ||
| 5 | -} | ||
| 6 | - | ||
| 7 | -// Tree pages: the repo home's grid without the bottom dock (only the repo home shows the dock), so the | ||
| 8 | -// listing and the README fill the window. | ||
| 9 | -@media (min-width: 900px) { | ||
| 10 | - .tree-browse { | ||
| 11 | - --repo-home-h: max(360px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px))); | ||
| 12 | - } | ||
| 13 | -} | ||
| 14 | - | ||
| 15 | -// Code search: the search form and the results are one pane that fills the window. The results scroll | ||
| 16 | -// inside it, and take the full width. | ||
| 17 | -@media (min-width: 900px) { | ||
| 18 | - .search-page.fit-pane { | ||
| 19 | - display: flex; | ||
| 20 | - flex-direction: column; | ||
| 21 | - gap: 12px; | ||
| 22 | - overflow: hidden; | ||
| 23 | - | ||
| 24 | - > :not(.search-results) { | ||
| 25 | - flex: none; | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - > .search-results { | ||
| 29 | - flex: 1 1 auto; | ||
| 30 | - min-height: 0; | ||
| 31 | - overflow-y: auto; | ||
| 32 | - overscroll-behavior: contain; | ||
| 33 | - } | ||
| 34 | - } | ||
| 35 | -} | ||
| 36 | - | ||
| 37 | -.search-page .search-form, | ||
| 38 | -.search-page .search-results { | ||
| 39 | - width: 100%; | ||
| 40 | - max-width: none; | ||
| 41 | -} | ||
| 42 | - | ||
| 43 | -// Wiki: an empty list or page is left aligned in its pane, with the next step under the message. | ||
| 44 | -.wiki-page .empty-state { | ||
| 45 | - align-items: flex-start; | ||
| 46 | - padding: 0; | ||
| 47 | - text-align: left; | ||
| 48 | - | ||
| 49 | -} | ||
style/_lang_ci.scssdeleted+0 -132
| @@ -1,132 +0,0 @@ | |||
| 1 | -// The CI list and the job page in the page language (LANGUAGE.md): both fill the window under the head, | ||
| 2 | -// each pane scrolls inside itself, and nothing is a centred column. Imported last, so it wins over the | ||
| 3 | -// older split and job rules in main.scss and _fit_code.scss. | ||
| 4 | - | ||
| 5 | -// The timeline is drawn in 640 units: past this width its text would grow with the pane. | ||
| 6 | -.ci-gantt { | ||
| 7 | - max-width: 800px; | ||
| 8 | - overflow: visible; | ||
| 9 | -} | ||
| 10 | - | ||
| 11 | -// The runs list (480px, as the canvas) and the selected run fill the window down to the footer. | ||
| 12 | -@media (min-width: 900px) { | ||
| 13 | - .ci-split.fit-pane { | ||
| 14 | - grid-template-columns: clamp(340px, 25vw, 480px) minmax(0, 1fr); | ||
| 15 | - align-items: stretch; | ||
| 16 | - gap: 12px; | ||
| 17 | - padding: 0; | ||
| 18 | - overflow: hidden; | ||
| 19 | - } | ||
| 20 | - | ||
| 21 | - .ci-split > .ci-side, | ||
| 22 | - .ci-split > .ci-main { | ||
| 23 | - position: static; | ||
| 24 | - min-height: 0; | ||
| 25 | - max-height: none; | ||
| 26 | - margin: 0; | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - .ci-split > .ci-side { | ||
| 30 | - display: flex; | ||
| 31 | - flex-direction: column; | ||
| 32 | - overflow: hidden; | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - // One row of controls: the count, Run workflow and Status badge stay on one line. | ||
| 36 | - .ci-split > .ci-side .ci-side-head, | ||
| 37 | - .ci-split > .ci-side .ci-tools { | ||
| 38 | - flex-wrap: nowrap; | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - .ci-split > .ci-side .ci-run-list { | ||
| 42 | - flex: 1 1 auto; | ||
| 43 | - min-height: 0; | ||
| 44 | - overflow-y: auto; | ||
| 45 | - overscroll-behavior: contain; | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - .ci-split > .ci-main { | ||
| 49 | - overflow-y: auto; | ||
| 50 | - overscroll-behavior: contain; | ||
| 51 | - } | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | -// A run's page keeps the runs list at the left, in the same place, so a click only changes the right. | ||
| 55 | -.ci-split > .ci-run { | ||
| 56 | - display: flex; | ||
| 57 | - flex-direction: column; | ||
| 58 | - gap: 12px; | ||
| 59 | - min-width: 0; | ||
| 60 | - min-height: 0; | ||
| 61 | - | ||
| 62 | - > .ci-tl-main { | ||
| 63 | - flex: 1 1 0; | ||
| 64 | - min-height: 0; | ||
| 65 | - } | ||
| 66 | -} | ||
| 67 | - | ||
| 68 | -@media (min-width: 900px) { | ||
| 69 | - .ci-split.fit-pane:has(> .ci-run) { | ||
| 70 | - height: calc(100dvh - var(--pane-top, 107px) - 20px); | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - .ci-split > .ci-run { | ||
| 74 | - overflow: hidden; | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - .ci-all-runs { | ||
| 78 | - display: none; | ||
| 79 | - } | ||
| 80 | -} | ||
| 81 | - | ||
| 82 | -// Between phone and desktop the panes stack, as the rest of the site does. On a run's page the run | ||
| 83 | -// comes first and All runs leads back, or it would sit under a whole list. | ||
| 84 | -@media (max-width: 899px) { | ||
| 85 | - .ci-split { | ||
| 86 | - grid-template-columns: minmax(0, 1fr); | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - // The page scrolls here. A pane share of a fixed height left a run with a long title no room at all. | ||
| 90 | - .ci-split.fit-pane { | ||
| 91 | - height: auto; | ||
| 92 | - overflow: visible; | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - .ci-split > .ci-detail, | ||
| 96 | - .ci-split > .ci-run { | ||
| 97 | - height: auto; | ||
| 98 | - overflow: visible; | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - .ci-split > .ci-detail > .ci-tl-main, | ||
| 102 | - .ci-split > .ci-run > .ci-tl-main { | ||
| 103 | - flex: none; | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - .ci-split:has(> .ci-run) > .ci-side { | ||
| 107 | - display: none; | ||
| 108 | - } | ||
| 109 | -} | ||
| 110 | - | ||
| 111 | -// The detail's empty state reads from the left, inside its pane. | ||
| 112 | -.ci-split .empty-state { | ||
| 113 | - align-items: flex-start; | ||
| 114 | - padding: 16px 0; | ||
| 115 | - text-align: left; | ||
| 116 | - | ||
| 117 | -} | ||
| 118 | - | ||
| 119 | -// The job page: the head and the log fill the window, the log pane takes the rest. | ||
| 120 | -@media (min-width: 900px) { | ||
| 121 | - .ci-job.fit-pane { | ||
| 122 | - display: flex; | ||
| 123 | - flex-direction: column; | ||
| 124 | - gap: 12px; | ||
| 125 | - padding: 0; | ||
| 126 | - overflow: hidden; | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - .ci-job .ci-tl-no a { | ||
| 130 | - color: inherit; | ||
| 131 | - } | ||
| 132 | -} | ||
style/_lang_issues.scssdeleted+0 -266
| @@ -1,266 +0,0 @@ | |||
| 1 | -// Issues, pull requests and discussions in the page language (style/_language.scss, LANGUAGE.md). | ||
| 2 | -// Lists are one pane: a toolbar row, then hairline rows with the metadata at the right end. Issue, | ||
| 3 | -// pull and discussion pages are a conversation pane and a 300px sidebar pane, each scrolling inside | ||
| 4 | -// itself. Forms are 720px and left aligned. Markup: `.issue-pane` wraps a list page's body. | ||
| 5 | - | ||
| 6 | -// Lists: one pane that fills the window. The toolbar stays at the top, the rows scroll under it, | ||
| 7 | -// and the pager stays at the foot. | ||
| 8 | -@media (min-width: 900px) { | ||
| 9 | - .issue-pane.fit-pane { | ||
| 10 | - display: flex; | ||
| 11 | - flex-direction: column; | ||
| 12 | - margin: 0; | ||
| 13 | - padding: 0; | ||
| 14 | - overflow: hidden; | ||
| 15 | - border: 1px solid var(--border); | ||
| 16 | - border-radius: var(--radius-lg); | ||
| 17 | - background: var(--surface); | ||
| 18 | - | ||
| 19 | - > .issue-toolbar, | ||
| 20 | - > .pager { | ||
| 21 | - flex: none; | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | - > .issue-list, | ||
| 25 | - > .issue-timeline { | ||
| 26 | - flex: 1 1 auto; | ||
| 27 | - min-height: 0; | ||
| 28 | - overflow: auto; | ||
| 29 | - overscroll-behavior: contain; | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - > .issue-list { | ||
| 33 | - border: 0; | ||
| 34 | - border-radius: 0; | ||
| 35 | - background: none; | ||
| 36 | - } | ||
| 37 | - } | ||
| 38 | -} | ||
| 39 | - | ||
| 40 | -// Toolbar: tabs, search and filters, and the buttons on one row. | ||
| 41 | -.issue-pane > .issue-toolbar { | ||
| 42 | - display: flex; | ||
| 43 | - flex-wrap: wrap; | ||
| 44 | - align-items: center; | ||
| 45 | - gap: 8px 12px; | ||
| 46 | - margin: 0; | ||
| 47 | - padding: 10px 14px; | ||
| 48 | - border-bottom: 1px solid var(--border); | ||
| 49 | - | ||
| 50 | - > .issue-tabs { | ||
| 51 | - flex: none; | ||
| 52 | - gap: 2px; | ||
| 53 | - | ||
| 54 | - a { | ||
| 55 | - padding: 4px 10px; | ||
| 56 | - } | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - > .issue-search { | ||
| 60 | - flex: 1 1 16rem; | ||
| 61 | - min-width: 0; | ||
| 62 | - margin: 0; | ||
| 63 | - flex-wrap: nowrap; | ||
| 64 | - | ||
| 65 | - input[type="search"] { | ||
| 66 | - flex: 1 1 10rem; | ||
| 67 | - min-width: 8rem; | ||
| 68 | - max-width: none; | ||
| 69 | - height: 32px; | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - select, | ||
| 73 | - button { | ||
| 74 | - height: 32px; | ||
| 75 | - padding: 0 10px; | ||
| 76 | - font-size: 14px; | ||
| 77 | - } | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - > .issue-tools { | ||
| 81 | - display: flex; | ||
| 82 | - flex: none; | ||
| 83 | - align-items: center; | ||
| 84 | - gap: 8px; | ||
| 85 | - | ||
| 86 | - nav { | ||
| 87 | - display: flex; | ||
| 88 | - gap: 8px; | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - .button { | ||
| 92 | - height: 32px; | ||
| 93 | - padding: 0 12px; | ||
| 94 | - font-size: 13px; | ||
| 95 | - line-height: 30px; | ||
| 96 | - box-sizing: border-box; | ||
| 97 | - } | ||
| 98 | - } | ||
| 99 | -} | ||
| 100 | - | ||
| 101 | -// Rows: a hairline between them, the title and metadata on the left, the assignees and the | ||
| 102 | -// comment count right aligned at the far end of the row. | ||
| 103 | -.issue-pane .issue-list .issue-row { | ||
| 104 | - display: grid; | ||
| 105 | - grid-template-columns: 14px minmax(0, 1fr) minmax(7rem, auto); | ||
| 106 | - align-items: center; | ||
| 107 | - gap: 12px; | ||
| 108 | - padding: 10px 14px; | ||
| 109 | - border-top: 1px solid var(--border); | ||
| 110 | - | ||
| 111 | - > .issue-state { | ||
| 112 | - grid-column: 1; | ||
| 113 | - margin: 0; | ||
| 114 | - align-self: center; | ||
| 115 | - } | ||
| 116 | - | ||
| 117 | - > .issue-main { | ||
| 118 | - grid-column: 2; | ||
| 119 | - min-width: 0; | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - > .issue-aside { | ||
| 123 | - grid-column: 3; | ||
| 124 | - justify-content: flex-end; | ||
| 125 | - min-width: 0; | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - // A row without a state dot (discussions, the template chooser): two columns. | ||
| 129 | - &:not(:has(> .issue-state)) { | ||
| 130 | - grid-template-columns: minmax(0, 1fr) minmax(7rem, auto); | ||
| 131 | - | ||
| 132 | - > .issue-main { | ||
| 133 | - grid-column: 1; | ||
| 134 | - } | ||
| 135 | - | ||
| 136 | - > .issue-aside { | ||
| 137 | - grid-column: 2; | ||
| 138 | - } | ||
| 139 | - } | ||
| 140 | -} | ||
| 141 | - | ||
| 142 | -.issue-pane .issue-list .issue-row:first-child { | ||
| 143 | - border-top: 0; | ||
| 144 | -} | ||
| 145 | - | ||
| 146 | -.issue-pane .issue-row .issue-meta { | ||
| 147 | - margin-top: 2px; | ||
| 148 | -} | ||
| 149 | - | ||
| 150 | -.issue-pane .issue-row .issue-title-line { | ||
| 151 | - gap: 6px; | ||
| 152 | -} | ||
| 153 | - | ||
| 154 | -.issue-pane > .pager { | ||
| 155 | - margin: 0; | ||
| 156 | - padding: 8px 14px; | ||
| 157 | - border-top: 1px solid var(--border); | ||
| 158 | -} | ||
| 159 | - | ||
| 160 | -// Issue, pull request and discussion pages: the title in one line, then state and meta on one line. | ||
| 161 | -.issue-heading { | ||
| 162 | - overflow: hidden; | ||
| 163 | - margin: 0; | ||
| 164 | - font-size: 24px; | ||
| 165 | - line-height: 1.25; | ||
| 166 | - white-space: nowrap; | ||
| 167 | - text-overflow: ellipsis; | ||
| 168 | -} | ||
| 169 | - | ||
| 170 | -.issue-head { | ||
| 171 | - margin-bottom: 0; | ||
| 172 | -} | ||
| 173 | - | ||
| 174 | -.issue-byline { | ||
| 175 | - margin: 4px 0 0; | ||
| 176 | - font-size: 13px; | ||
| 177 | - line-height: 1.4; | ||
| 178 | -} | ||
| 179 | - | ||
| 180 | -@media (min-width: 900px) { | ||
| 181 | - // The conversation is the left pane, the sidebar a 300px right pane. Both scroll inside. | ||
| 182 | - .issue-layout { | ||
| 183 | - grid-template-columns: minmax(0, 1fr) 300px; | ||
| 184 | - gap: 16px; | ||
| 185 | - height: max(360px, calc(100dvh - var(--pane-top, 288px) - var(--pane-foot, 78px))); | ||
| 186 | - } | ||
| 187 | - | ||
| 188 | - .issue-layout > .issue-column.fit-pane, | ||
| 189 | - .issue-layout > .issue-sidebar.fit-pane { | ||
| 190 | - height: 100%; | ||
| 191 | - margin: 0; | ||
| 192 | - padding: 12px; | ||
| 193 | - border: 1px solid var(--border); | ||
| 194 | - border-radius: var(--radius-lg); | ||
| 195 | - background: var(--surface); | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - .issue-layout > .issue-column.fit-pane { | ||
| 199 | - gap: 12px; | ||
| 200 | - } | ||
| 201 | - | ||
| 202 | - // Sidebar: the sections stack with a hairline, so the labels and assignees fit one screen. | ||
| 203 | - .issue-layout > .issue-sidebar.fit-pane { | ||
| 204 | - gap: 0; | ||
| 205 | - | ||
| 206 | - > .issue-side-section:last-child { | ||
| 207 | - border-bottom: 0; | ||
| 208 | - } | ||
| 209 | - } | ||
| 210 | -} | ||
| 211 | - | ||
| 212 | -// Label checklist: compact chips in a wrapping row instead of one tall list. | ||
| 213 | -.issue-side-section form.stack:has(> .issue-check) { | ||
| 214 | - display: flex; | ||
| 215 | - flex-direction: row; | ||
| 216 | - flex-wrap: wrap; | ||
| 217 | - align-items: center; | ||
| 218 | - justify-content: flex-start; | ||
| 219 | - gap: 6px; | ||
| 220 | - | ||
| 221 | - > * { | ||
| 222 | - grid-column: auto; | ||
| 223 | - } | ||
| 224 | - | ||
| 225 | - > .issue-check { | ||
| 226 | - display: inline-flex; | ||
| 227 | - align-items: center; | ||
| 228 | - gap: 4px; | ||
| 229 | - height: 26px; | ||
| 230 | - margin: 0; | ||
| 231 | - padding: 0 8px 0 6px; | ||
| 232 | - border: 1px solid var(--border); | ||
| 233 | - border-radius: var(--radius-full); | ||
| 234 | - font-size: 12px; | ||
| 235 | - white-space: nowrap; | ||
| 236 | - | ||
| 237 | - .label-chip { | ||
| 238 | - padding: 0 4px; | ||
| 239 | - font-size: 12px; | ||
| 240 | - } | ||
| 241 | - } | ||
| 242 | - | ||
| 243 | - > div { | ||
| 244 | - flex: 1 0 100%; | ||
| 245 | - } | ||
| 246 | -} | ||
| 247 | - | ||
| 248 | -.issue-side-section .issue-chips { | ||
| 249 | - display: flex; | ||
| 250 | - flex-wrap: wrap; | ||
| 251 | - gap: 6px; | ||
| 252 | -} | ||
| 253 | - | ||
| 254 | -// Forms: 720px, left aligned. They do not stretch across a wide window. | ||
| 255 | -.issue-new, | ||
| 256 | -.issue-edit.card { | ||
| 257 | - max-width: 720px; | ||
| 258 | -} | ||
| 259 | - | ||
| 260 | -// Comment history: the versions scroll inside their pane. | ||
| 261 | -.issue-timeline.fit-pane { | ||
| 262 | - padding: 12px; | ||
| 263 | - border: 1px solid var(--border); | ||
| 264 | - border-radius: var(--radius-lg); | ||
| 265 | - background: var(--surface); | ||
| 266 | -} | ||
style/_lang_lists.scssdeleted+0 -42
| @@ -1,42 +0,0 @@ | |||
| 1 | -// Page language for the repo list and form pages: commits, branches, tags, releases, compare, labels, | ||
| 2 | -// milestones, merge queue and security. See _language.scss and LANGUAGE.md. Markup keeps its strings and | ||
| 3 | -// the classes tests read; this file gives the wrappers their one-screen shape. Headings are styled by | ||
| 4 | -// selector because tests read them as plain h2 elements. | ||
| 5 | - | ||
| 6 | -// A list pane: one surface pane that fills the window. Its toolbar row stays at the top, its rows | ||
| 7 | -// scroll inside `.list-scroll`, and the pager or a footnote sits at its foot. Below 900px it is as tall | ||
| 8 | -// as its content. | ||
| 9 | -@media (min-width: 900px) { | ||
| 10 | - .lang-list.fit-pane { | ||
| 11 | - display: flex; | ||
| 12 | - flex-direction: column; | ||
| 13 | - overflow: hidden; | ||
| 14 | - margin-bottom: 0; | ||
| 15 | - padding: 0; | ||
| 16 | - background: var(--surface); | ||
| 17 | - border-radius: var(--radius-lg); | ||
| 18 | - border: 1px solid var(--border); | ||
| 19 | - box-shadow: none; | ||
| 20 | - } | ||
| 21 | -} | ||
| 22 | - | ||
| 23 | -.lang-list { | ||
| 24 | - | ||
| 25 | - > .pager { | ||
| 26 | - flex: none; | ||
| 27 | - margin: 0; | ||
| 28 | - padding: 8px 16px; | ||
| 29 | - border-top: 1px solid var(--border); | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | -} | ||
| 33 | - | ||
| 34 | -// The release form was 960px wide; forms are 720px, left aligned. | ||
| 35 | -.release-form { | ||
| 36 | - max-width: 720px; | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | -@media (min-width: 900px) { | ||
| 40 | - | ||
| 41 | -} | ||
| 42 | - | ||
style/_lang_people.scssdeleted+0 -91
| @@ -1,91 +0,0 @@ | |||
| 1 | - | ||
| 2 | - | ||
| 3 | -// The import pages' tab strip and cards run to the width of the page, not 960px. | ||
| 4 | -.import-job, | ||
| 5 | -.export-page { | ||
| 6 | - max-width: none; | ||
| 7 | -} | ||
| 8 | - | ||
| 9 | -// The head's side note (Explore's intro): a small line at the right, out of the h1's row flow. | ||
| 10 | -@media (min-width: 900px) { | ||
| 11 | - | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -// Needs you: sections are columns on a wide window. One section takes the whole width. | ||
| 15 | -@media (min-width: 900px) { | ||
| 16 | - | ||
| 17 | -} | ||
| 18 | - | ||
| 19 | -// Review requests: wide rows with the metadata at the right, not stacked under the title. | ||
| 20 | -@media (min-width: 900px) { | ||
| 21 | - .review-request-list li { | ||
| 22 | - display: grid; | ||
| 23 | - grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) minmax(0, 12rem) 9rem; | ||
| 24 | - align-items: center; | ||
| 25 | - gap: 0 16px; | ||
| 26 | - padding: 10px 0; | ||
| 27 | - border-bottom: 1px solid var(--border); | ||
| 28 | - | ||
| 29 | - &:last-child { | ||
| 30 | - border-bottom: 0; | ||
| 31 | - } | ||
| 32 | - } | ||
| 33 | -} | ||
| 34 | - | ||
| 35 | -// Profile: a left pane (avatar, name, bio, local time, buttons) about 300px wide, and a right pane | ||
| 36 | -// with the tabs and the content, which takes the rest of the width. Below 900px the page stacks. | ||
| 37 | -@media (min-width: 900px) { | ||
| 38 | - .profile-page { | ||
| 39 | - position: relative; | ||
| 40 | - min-height: 340px; | ||
| 41 | - padding-left: 324px; | ||
| 42 | - | ||
| 43 | - > * { | ||
| 44 | - min-width: 0; | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - > * + * { | ||
| 48 | - margin-top: 16px; | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - > :nth-child(2) { | ||
| 52 | - margin-top: 0; | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - > .profile-head { | ||
| 56 | - position: absolute; | ||
| 57 | - top: 0; | ||
| 58 | - left: 0; | ||
| 59 | - box-sizing: border-box; | ||
| 60 | - width: 300px; | ||
| 61 | - flex-direction: column; | ||
| 62 | - align-items: flex-start; | ||
| 63 | - flex-wrap: nowrap; | ||
| 64 | - gap: 12px; | ||
| 65 | - padding: 20px; | ||
| 66 | - background: var(--surface); | ||
| 67 | - border: 1px solid var(--border); | ||
| 68 | - border-radius: var(--radius-lg); | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - .profile-head .profile-about { | ||
| 72 | - padding: 0; | ||
| 73 | - background: none; | ||
| 74 | - border: 0; | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - .profile-head .profile-avatar { | ||
| 78 | - width: 160px; | ||
| 79 | - height: 160px; | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - } | ||
| 83 | -} | ||
| 84 | - | ||
| 85 | -// The profile's tab row sits where every other page's head row sits. | ||
| 86 | -@media (min-width: 900px) { | ||
| 87 | - .profile-page > nav { | ||
| 88 | - margin-top: -8px; | ||
| 89 | - } | ||
| 90 | -} | ||
| 91 | - | ||
style/_language.scssdeleted+0 -5
| @@ -1,5 +0,0 @@ | |||
| 1 | -// The page language shared by every page (see the head rules): one head row of one height with one | ||
| 2 | -// rule under it, so nothing jumps between pages. Imported after the page partials. | ||
| 3 | -@media (min-width: 900px) { | ||
| 4 | - | ||
| 5 | -} | ||
style/_look.scssmodified+6 -6
| @@ -27,13 +27,13 @@ h1 { | |||
| 27 | // muted captions that head a card's table or list. Only static UI text takes this; prose and user | 27 | // muted captions that head a card's table or list. Only static UI text takes this; prose and user |
| 28 | // content (commit messages, names, descriptions) keep their case. | 28 | // content (commit messages, names, descriptions) keep their case. |
| 29 | %mono-label { | 29 | %mono-label { |
| 30 | - font-family: var(--mono); | ||
| 31 | - font-weight: 500; | ||
| 32 | - font-size: 11px; | ||
| 33 | - line-height: 1.4; | ||
| 34 | - letter-spacing: 0.12em; | ||
| 35 | - text-transform: uppercase; | ||
| 36 | color: var(--muted); | 30 | color: var(--muted); |
| 31 | + font-family: var(--font); | ||
| 32 | + font-size: 13px; | ||
| 33 | + font-weight: 600; | ||
| 34 | + letter-spacing: 0; | ||
| 35 | + line-height: 1.4; | ||
| 36 | + text-transform: none; | ||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | th, | 39 | th, |
style/_min.scssmodified+2 -3
| @@ -507,8 +507,8 @@ div.line { | |||
| 507 | } | 507 | } |
| 508 | 508 | ||
| 509 | // A tick or a radio always sits right before its own text, wherever the label is. | 509 | // A tick or a radio always sits right before its own text, wherever the label is. |
| 510 | -main label:not(.colour-choice):has(> input[type="checkbox"]), | 510 | +main label:not(.colour-choice, .choice > label):has(> input[type="checkbox"]), |
| 511 | -main label:not(.colour-choice):has(> input[type="radio"]) { | 511 | +main label:not(.colour-choice, .choice > label):has(> input[type="radio"]) { |
| 512 | display: flex; | 512 | display: flex; |
| 513 | flex-direction: row; | 513 | flex-direction: row; |
| 514 | align-items: flex-start; | 514 | align-items: flex-start; |
| @@ -533,7 +533,6 @@ main label:not(.colour-choice):has(> input[type="radio"]) { | |||
| 533 | // Nothing here is a box: topics sit straight on the page. | 533 | // Nothing here is a box: topics sit straight on the page. |
| 534 | main[data-width="read"] .explore, | 534 | main[data-width="read"] .explore, |
| 535 | main[data-width="read"] .heat, | 535 | main[data-width="read"] .heat, |
| 536 | -main[data-width="read"] .sec.issue-comment, | ||
| 537 | main .lang-list, | 536 | main .lang-list, |
| 538 | main .snippet-files { | 537 | main .snippet-files { |
| 539 | border: 0; | 538 | border: 0; |
style/_min_menus.scssmodified+41 -0
| @@ -74,6 +74,7 @@ | |||
| 74 | .watch-menu > .menu-list, | 74 | .watch-menu > .menu-list, |
| 75 | .head-more-list, | 75 | .head-more-list, |
| 76 | .pins-menu > .pop-panel, | 76 | .pins-menu > .pop-panel, |
| 77 | +.pins-menu > .menu-list, | ||
| 77 | .clone > .menu-list, | 78 | .clone > .menu-list, |
| 78 | .clone > .pop-panel { | 79 | .clone > .pop-panel { |
| 79 | right: auto !important; | 80 | right: auto !important; |
| @@ -83,6 +84,7 @@ | |||
| 83 | 84 | ||
| 84 | @media (max-width: 899px) { | 85 | @media (max-width: 899px) { |
| 85 | .pins-menu > .pop-panel, | 86 | .pins-menu > .pop-panel, |
| 87 | + .pins-menu > .menu-list, | ||
| 86 | .clone > .menu-list, | 88 | .clone > .menu-list, |
| 87 | .clone > .pop-panel, | 89 | .clone > .pop-panel, |
| 88 | .repo-readme .clone > .menu-list, | 90 | .repo-readme .clone > .menu-list, |
| @@ -163,3 +165,42 @@ | |||
| 163 | white-space: normal; | 165 | white-space: normal; |
| 164 | } | 166 | } |
| 165 | } | 167 | } |
| 168 | + | ||
| 169 | +// The pins menu opens from its own words, as a panel with the menu's padding, over the page. | ||
| 170 | +details.pins-menu { | ||
| 171 | + position: relative; | ||
| 172 | + display: inline-block; | ||
| 173 | + align-self: flex-start; | ||
| 174 | + | ||
| 175 | + > .menu-list { | ||
| 176 | + z-index: 40; | ||
| 177 | + width: 320px; | ||
| 178 | + padding: 14px 16px; | ||
| 179 | + gap: 10px; | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + > .menu-list > .hint { | ||
| 183 | + margin: 0; | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + > .menu-list > button[type="submit"] { | ||
| 187 | + align-self: flex-start; | ||
| 188 | + } | ||
| 189 | +} | ||
| 190 | + | ||
| 191 | +// Inside the menu each repo is a menu row: one column, 34px, no hairlines. | ||
| 192 | +details.pins-menu > .menu-list > .pin-options { | ||
| 193 | + display: flex; | ||
| 194 | + flex-direction: column; | ||
| 195 | + gap: 0; | ||
| 196 | + | ||
| 197 | + li { | ||
| 198 | + border-bottom: 0; | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + label { | ||
| 202 | + min-height: 34px; | ||
| 203 | + align-items: center; | ||
| 204 | + padding: 0; | ||
| 205 | + } | ||
| 206 | +} | ||
style/_one.scssadded+2932 -0
Diff too large; view file
| @@ -0,0 +1,2932 @@ | |||
| 1 | +// The one look. Imported last. Every control, list, panel and page part gets its look here and | ||
| 2 | +// nowhere else, so moving between pages changes the content and nothing else. The rules are in | ||
| 3 | +// docs/ui-language.md. | ||
| 4 | + | ||
| 5 | +:root { | ||
| 6 | + --radius-sm: 12px; | ||
| 7 | + --radius-md: 12px; | ||
| 8 | + --radius-lg: 20px; | ||
| 9 | + --radius-sheet: 16px; | ||
| 10 | + --control-h: 38px; | ||
| 11 | + --control-sm: 32px; | ||
| 12 | + --display: var(--font); | ||
| 13 | + --topbar-h: 56px; | ||
| 14 | + --gutter: 24px; | ||
| 15 | + --add-bg: #e6effb; | ||
| 16 | + --add-text: #1d3f6e; | ||
| 17 | + --add-mark: #2d68b4; | ||
| 18 | + --del-bg: #fbe8ea; | ||
| 19 | + --del-text: #8a1f2d; | ||
| 20 | + --del-mark: #b3202f; | ||
| 21 | + --bad: #b3202f; | ||
| 22 | + --danger: #b3202f; | ||
| 23 | + --caution: #b3202f; | ||
| 24 | + --danger-bg: #fbe8ea; | ||
| 25 | + --alert-bg: #fbe8ea; | ||
| 26 | + --alert-text: #8a1f2d; | ||
| 27 | + --pop-shadow: 0 12px 36px rgba(20, 18, 15, 0.14); | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +@mixin one-dark { | ||
| 31 | + --add-bg: #17304e; | ||
| 32 | + --add-text: #b9d6f7; | ||
| 33 | + --add-mark: #7fb3ef; | ||
| 34 | + --del-bg: #3b1d20; | ||
style/_one_admin.scssadded+217 -0
Diff too large; view file
style/_one_ci.scssadded+250 -0
Diff too large; view file
style/_one_code.scssadded+198 -0
Diff too large; view file
style/_one_people.scssadded+307 -0
Diff too large; view file
style/_one_review.scssadded+147 -0
Diff too large; view file
style/_one_shell.scssadded+259 -0
Diff too large; view file
style/_one_threads.scssadded+304 -0
Diff too large; view file
style/_pull.scssmodified+1 -1
Diff too large; view file
style/_system.scssdeleted+0 -614
Diff too large; view file
style/main.scssmodified+9 -149
Diff too large; view file