Forward-compatible ci.toml, admin/settings sidebars, sidebar side pref, unified radii
Browse files at this commitd000946b4c31377e692796bb3d61155f0520a9d8Parent: b6b26bb- feat
- forward-compatible ci.toml, admin/settings sidebars, sidebar side pref, unified radii
32 changed files +1243 -185
- .forge/ci.toml +0 -4
- Cargo.lock +11 -0
- crates/forge-ci/Cargo.toml +1 -0
- crates/forge-ci/src/config.rs +52 -14
- crates/forge-core/migrations/0043_sidebar_side.sql +5 -0
- crates/forge-core/src/authz.rs +1 -0
- crates/forge-core/src/model.rs +4 -0
- crates/forge-core/src/store/account_tokens.rs +2 -1
- crates/forge-core/src/store/migrate.rs +1 -0
- crates/forge-core/src/store/mod.rs +5 -2
- crates/forge-core/src/store/orgs.rs +2 -2
- crates/forge-core/src/store/ui_prefs.rs +83 -5
- crates/forge-core/src/store/user_delete.rs +1 -0
- crates/forge-web/assets/nav.js +2 -2
- crates/forge-web/src/api/releases.rs +9 -1
- crates/forge-web/src/ci/schedule.rs +121 -5
- crates/forge-web/src/i18n/admin.rs +4 -0
- crates/forge-web/src/i18n/misc.rs +17 -0
- crates/forge-web/src/i18n/mod.rs +4 -12
- crates/forge-web/src/pages/admin_runners.rs +0 -9
- crates/forge-web/src/pages/admin_users.rs +0 -1
- crates/forge-web/src/pages/settings_appearance.rs +67 -2
- crates/forge-web/src/views/mod.rs +258 -14
- crates/forge-web/tests/section_nav_e2e.rs +321 -0
- crates/forge-web/tests/ui_prefs_e2e.rs +74 -0
- docs/ci.md +4 -1
- style/_dashboard.scss +1 -1
- style/_heatmap.scss +1 -1
- style/_pull.scss +11 -11
- style/_repo.scss +11 -11
- style/_shell.scss +28 -6
- style/main.scss +142 -80
.forge/ci.tomlmodified+0 -4
| @@ -7,7 +7,6 @@ | |||
| 7 | push = ["main"] | 7 | push = ["main"] |
| 8 | pull_request = true | 8 | pull_request = true |
| 9 | manual = true | 9 | manual = true |
| 10 | -tags = ["v*"] | ||
| 11 | 10 | ||
| 12 | [jobs.test] | 11 | [jobs.test] |
| 13 | image = "docker.io/library/rust:1" | 12 | image = "docker.io/library/rust:1" |
| @@ -35,6 +34,3 @@ mkdir -p dist && cp target/dist/forge dist/forge | |||
| 35 | artifacts = ["dist/forge", "forge-*-linux", "SHA256SUMS"] | 34 | artifacts = ["dist/forge", "forge-*-linux", "SHA256SUMS"] |
| 36 | cache = ["target"] | 35 | cache = ["target"] |
| 37 | timeout_minutes = 120 | 36 | timeout_minutes = 120 |
| 38 | - | ||
| 39 | -[release] | ||
| 40 | -assets = ["build:forge-*-linux", "build:SHA256SUMS"] | ||
Cargo.lockmodified+11 -0
| @@ -1852,6 +1852,7 @@ dependencies = [ | |||
| 1852 | "base64 0.23.1", | 1852 | "base64 0.23.1", |
| 1853 | "globset", | 1853 | "globset", |
| 1854 | "serde", | 1854 | "serde", |
| 1855 | + "serde_ignored", | ||
| 1855 | "serde_json", | 1856 | "serde_json", |
| 1856 | "thiserror 2.0.21", | 1857 | "thiserror 2.0.21", |
| 1857 | "toml", | 1858 | "toml", |
| @@ -6206,6 +6207,16 @@ dependencies = [ | |||
| 6206 | "syn 3.0.9", | 6207 | "syn 3.0.9", |
| 6207 | ] | 6208 | ] |
| 6208 | 6209 | ||
| 6210 | +[[package]] | ||
| 6211 | +name = "serde_ignored" | ||
| 6212 | +version = "0.1.14" | ||
| 6213 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 6214 | +checksum = "115dffd5f3853e06e746965a20dcbae6ee747ae30b543d91b0e089668bb07798" | ||
| 6215 | +dependencies = [ | ||
| 6216 | + "serde", | ||
| 6217 | + "serde_core", | ||
| 6218 | +] | ||
| 6219 | + | ||
| 6209 | [[package]] | 6220 | [[package]] |
| 6210 | name = "serde_json" | 6221 | name = "serde_json" |
| 6211 | version = "1.0.154" | 6222 | version = "1.0.154" |
crates/forge-ci/Cargo.tomlmodified+1 -0
| @@ -10,6 +10,7 @@ publish = false | |||
| 10 | base64 = { workspace = true } | 10 | base64 = { workspace = true } |
| 11 | globset = { workspace = true } | 11 | globset = { workspace = true } |
| 12 | serde = { workspace = true } | 12 | serde = { workspace = true } |
| 13 | +serde_ignored = "0.1.14" | ||
| 13 | serde_json = { workspace = true } | 14 | serde_json = { workspace = true } |
| 14 | thiserror = { workspace = true } | 15 | thiserror = { workspace = true } |
| 15 | toml = { workspace = true } | 16 | toml = { workspace = true } |
crates/forge-ci/src/config.rsmodified+52 -14
| @@ -40,7 +40,6 @@ pub const MAX_RELEASE_TITLE_CHARS: usize = 200; | |||
| 40 | 40 | ||
| 41 | /// A parsed and validated workflow. | 41 | /// A parsed and validated workflow. |
| 42 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | 42 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| 43 | -#[serde(deny_unknown_fields)] | ||
| 44 | pub struct CiConfig { | 43 | pub struct CiConfig { |
| 45 | /// Optional display name, e.g. `"build"`. The CI badge uses it as its label. | 44 | /// Optional display name, e.g. `"build"`. The CI badge uses it as its label. |
| 46 | #[serde(default)] | 45 | #[serde(default)] |
| @@ -54,11 +53,16 @@ pub struct CiConfig { | |||
| 54 | /// The `[release]` table. Optional; when set, a tag run that fully succeeds publishes a release. | 53 | /// The `[release]` table. Optional; when set, a tag run that fully succeeds publishes a release. |
| 55 | #[serde(default)] | 54 | #[serde(default)] |
| 56 | pub release: Option<ReleaseSpec>, | 55 | pub release: Option<ReleaseSpec>, |
| 56 | + /// Keys this forge does not know, as dotted paths, e.g. `release` or `jobs.build.foo`. They are | ||
| 57 | + /// ignored, not rejected, so a newer `ci.toml` still runs on an older forge. Filled by | ||
| 58 | + /// [`parse_config`]; never read from the file. | ||
| 59 | + #[serde(skip)] | ||
| 60 | + pub warnings: Vec<String>, | ||
| 57 | } | 61 | } |
| 58 | 62 | ||
| 59 | /// The `[release]` table. Requires `on.tags`. See docs/ci.md, Releases. | 63 | /// The `[release]` table. Requires `on.tags`. See docs/ci.md, Releases. |
| 60 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | 64 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| 61 | -#[serde(deny_unknown_fields, default)] | 65 | +#[serde(default)] |
| 62 | pub struct ReleaseSpec { | 66 | pub struct ReleaseSpec { |
| 63 | /// `"<job>:<glob>"` entries. The glob matches the job's flattened artifact names. | 67 | /// `"<job>:<glob>"` entries. The glob matches the job's flattened artifact names. |
| 64 | pub assets: Vec<String>, | 68 | pub assets: Vec<String>, |
| @@ -132,7 +136,7 @@ pub enum ReleaseNotes { | |||
| 132 | 136 | ||
| 133 | /// The `[on]` table. | 137 | /// The `[on]` table. |
| 134 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | 138 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| 135 | -#[serde(deny_unknown_fields, default)] | 139 | +#[serde(default)] |
| 136 | pub struct Triggers { | 140 | pub struct Triggers { |
| 137 | /// Branch globs, e.g. `"main"`, `"release/*"`. | 141 | /// Branch globs, e.g. `"main"`, `"release/*"`. |
| 138 | pub push: Vec<String>, | 142 | pub push: Vec<String>, |
| @@ -156,7 +160,6 @@ impl Default for Triggers { | |||
| 156 | 160 | ||
| 157 | /// One `[jobs.<name>]` table. | 161 | /// One `[jobs.<name>]` table. |
| 158 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | 162 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| 159 | -#[serde(deny_unknown_fields)] | ||
| 160 | pub struct JobSpec { | 163 | pub struct JobSpec { |
| 161 | pub image: String, | 164 | pub image: String, |
| 162 | pub run: String, | 165 | pub run: String, |
| @@ -207,8 +210,18 @@ pub fn parse_config(text: &str) -> Result<CiConfig, ConfigError> { | |||
| 207 | max: MAX_CONFIG_BYTES, | 210 | max: MAX_CONFIG_BYTES, |
| 208 | }); | 211 | }); |
| 209 | } | 212 | } |
| 210 | - let config: CiConfig = toml::from_str(text).map_err(|e| ConfigError::Toml(e.to_string()))?; | 213 | + let de = toml::Deserializer::parse(text).map_err(|e| ConfigError::Toml(e.to_string()))?; |
| 214 | + let mut warnings = Vec::new(); | ||
| 215 | + let mut config: CiConfig = serde_ignored::deserialize(de, |path| { | ||
| 216 | + // serde_ignored marks `Option` wrappers with `?`; they are not part of the key path. | ||
| 217 | + let path = path.to_string().replace("?.", ""); | ||
| 218 | + warnings.push(format!( | ||
| 219 | + "unknown key `{path}` ignored \u{2014} this forge may be older than your ci.toml" | ||
| 220 | + )); | ||
| 221 | + }) | ||
| 222 | + .map_err(|e| ConfigError::Toml(e.to_string()))?; | ||
| 211 | config.validate()?; | 223 | config.validate()?; |
| 224 | + config.warnings = warnings; | ||
| 212 | Ok(config) | 225 | Ok(config) |
| 213 | } | 226 | } |
| 214 | 227 | ||
| @@ -694,16 +707,41 @@ artifacts = ["target/release/forge"] | |||
| 694 | } | 707 | } |
| 695 | 708 | ||
| 696 | #[test] | 709 | #[test] |
| 697 | - fn unknown_keys_are_rejected() { | 710 | + fn unknown_keys_are_ignored_with_a_warning() { |
| 711 | + let cfg = parse_config(&format!("[on]\nschedule = true\n{}", job_toml(""))).unwrap(); | ||
| 712 | + assert_eq!(cfg.warnings.len(), 1); | ||
| 713 | + assert!(cfg.warnings[0].starts_with("unknown key `on.schedule` ignored")); | ||
| 714 | + assert!(cfg.on.manual, "known keys still apply"); | ||
| 715 | + | ||
| 716 | + let cfg = parse_config(&job_toml("bogus = 1")).unwrap(); | ||
| 717 | + assert_eq!(cfg.warnings.len(), 1); | ||
| 718 | + assert!(cfg.warnings[0].contains("`jobs.build.bogus`"), "{:?}", cfg.warnings); | ||
| 719 | + assert_eq!(cfg.jobs.len(), 1); | ||
| 720 | + | ||
| 721 | + let cfg = parse_config(&format!("{}\n[other]\nx = 1\n", job_toml(""))).unwrap(); | ||
| 722 | + assert_eq!(cfg.warnings.len(), 1); | ||
| 723 | + assert!(cfg.warnings[0].contains("`other`"), "{:?}", cfg.warnings); | ||
| 724 | + } | ||
| 725 | + | ||
| 726 | + #[test] | ||
| 727 | + fn known_file_has_no_warnings() { | ||
| 728 | + assert!(parse_config(EXAMPLE).unwrap().warnings.is_empty()); | ||
| 729 | + } | ||
| 730 | + | ||
| 731 | + #[test] | ||
| 732 | + fn known_keys_are_still_validated() { | ||
| 698 | assert!(matches!( | 733 | assert!(matches!( |
| 699 | - err_of(&format!("[on]\nschedule = true\n{}", job_toml(""))), | 734 | + err_of(&format!("[on]\npush = 3\n{}", job_toml(""))), |
| 700 | ConfigError::Toml(_) | 735 | ConfigError::Toml(_) |
| 701 | )); | 736 | )); |
| 702 | assert!(matches!( | 737 | assert!(matches!( |
| 703 | - err_of(&job_toml("bogus = 1")), | 738 | + err_of(&job_toml("timeout_minutes = \"soon\"\nbogus = 1")), |
| 704 | ConfigError::Toml(_) | 739 | ConfigError::Toml(_) |
| 705 | )); | 740 | )); |
| 706 | - assert!(matches!(err_of("[other]\nx = 1\n"), ConfigError::Toml(_))); | 741 | + assert!(matches!( |
| 742 | + err_of(&job_toml("timeout_minutes = 0")), | ||
| 743 | + ConfigError::InvalidTimeout { .. } | ||
| 744 | + )); | ||
| 707 | } | 745 | } |
| 708 | 746 | ||
| 709 | #[test] | 747 | #[test] |
| @@ -1153,11 +1191,11 @@ artifacts = ["target/release/forge"] | |||
| 1153 | } | 1191 | } |
| 1154 | 1192 | ||
| 1155 | #[test] | 1193 | #[test] |
| 1156 | - fn release_unknown_keys_are_rejected() { | 1194 | + fn release_unknown_keys_are_ignored_with_a_warning() { |
| 1157 | - assert!(matches!( | 1195 | + let cfg = parse_config(&release_toml("bogus = 1")).unwrap(); |
| 1158 | - err_of(&release_toml("bogus = 1")), | 1196 | + assert_eq!(cfg.warnings.len(), 1); |
| 1159 | - ConfigError::Toml(_) | 1197 | + assert!(cfg.warnings[0].contains("`release.bogus`"), "{:?}", cfg.warnings); |
| 1160 | - )); | 1198 | + assert!(cfg.release.is_some()); |
| 1161 | } | 1199 | } |
| 1162 | 1200 | ||
| 1163 | #[test] | 1201 | #[test] |
crates/forge-core/migrations/0043_sidebar_side.sqladded+5 -0
| @@ -0,0 +1,5 @@ | |||
| 1 | +-- Which side the main shell sidebar sits on: 'left' or 'right'. The store checks the value (see | ||
| 2 | +-- store/ui_prefs.rs), and the web layer renders it on <html> as data-sidebar. Applied by | ||
| 3 | +-- store/migrate.rs. | ||
| 4 | + | ||
| 5 | +ALTER TABLE users ADD COLUMN sidebar_side TEXT NOT NULL DEFAULT 'left'; | ||
crates/forge-core/src/authz.rsmodified+1 -0
| @@ -132,6 +132,7 @@ mod tests { | |||
| 132 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), | 132 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), |
| 133 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), | 133 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 134 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), | 134 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 135 | + sidebar_side: crate::store::ui_prefs::DEFAULT_SIDEBAR.into(), | ||
| 135 | kind: AccountKind::User, | 136 | kind: AccountKind::User, |
| 136 | email_notifications: true, | 137 | email_notifications: true, |
| 137 | } | 138 | } |
crates/forge-core/src/model.rsmodified+4 -0
| @@ -56,6 +56,8 @@ pub struct User { | |||
| 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. "fern" 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". | ||
| 60 | + pub sidebar_side: String, | ||
| 59 | /// `User` for a person, `Org` for an organization. | 61 | /// `User` for a person, `Org` for an organization. |
| 60 | pub kind: AccountKind, | 62 | pub kind: AccountKind, |
| 61 | /// Whether notifications are also sent by email (needs a verified email and instance mail). | 63 | /// Whether notifications are also sent by email (needs a verified email and instance mail). |
| @@ -140,6 +142,7 @@ impl std::fmt::Debug for User { | |||
| 140 | .field("accent_dark", &self.accent_dark) | 142 | .field("accent_dark", &self.accent_dark) |
| 141 | .field("base_light", &self.base_light) | 143 | .field("base_light", &self.base_light) |
| 142 | .field("base_dark", &self.base_dark) | 144 | .field("base_dark", &self.base_dark) |
| 145 | + .field("sidebar_side", &self.sidebar_side) | ||
| 143 | .field("kind", &self.kind) | 146 | .field("kind", &self.kind) |
| 144 | .finish() | 147 | .finish() |
| 145 | } | 148 | } |
| @@ -232,6 +235,7 @@ mod tests { | |||
| 232 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), | 235 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), |
| 233 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), | 236 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 234 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), | 237 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 238 | + sidebar_side: crate::store::ui_prefs::DEFAULT_SIDEBAR.into(), | ||
| 235 | kind: AccountKind::User, | 239 | kind: AccountKind::User, |
| 236 | email_notifications: true, | 240 | email_notifications: true, |
| 237 | }; | 241 | }; |
crates/forge-core/src/store/account_tokens.rsmodified+2 -1
| @@ -100,7 +100,7 @@ impl Store { | |||
| 100 | &conn, | 100 | &conn, |
| 101 | "SELECT id, username, email, password_hash, is_admin, created_at, about, timezone, \ | 101 | "SELECT id, username, email, password_hash, is_admin, created_at, about, timezone, \ |
| 102 | (SELECT hash FROM avatars WHERE avatars.user_id = users.id) AS avatar_hash, \ | 102 | (SELECT hash FROM avatars WHERE avatars.user_id = users.id) AS avatar_hash, \ |
| 103 | - theme, language, kind, email_notifications, display_name, accent, accent_dark, base_light, base_dark FROM users WHERE LOWER(email) = LOWER(?1) \ | 103 | + theme, language, kind, email_notifications, display_name, accent, accent_dark, base_light, base_dark, sidebar_side FROM users WHERE LOWER(email) = LOWER(?1) \ |
| 104 | AND email_verified_at IS NOT NULL AND kind = 'user' LIMIT 1", | 104 | AND email_verified_at IS NOT NULL AND kind = 'user' LIMIT 1", |
| 105 | (email.to_owned(),), | 105 | (email.to_owned(),), |
| 106 | map_user, | 106 | map_user, |
| @@ -307,6 +307,7 @@ impl Store { | |||
| 307 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), | 307 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), |
| 308 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), | 308 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 309 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), | 309 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 310 | + sidebar_side: crate::store::ui_prefs::DEFAULT_SIDEBAR.into(), | ||
| 310 | kind: AccountKind::User, | 311 | kind: AccountKind::User, |
| 311 | email_notifications: true, | 312 | email_notifications: true, |
| 312 | }; | 313 | }; |
crates/forge-core/src/store/migrate.rsmodified+1 -0
| @@ -61,6 +61,7 @@ pub const MIGRATIONS: &[(u32, &str)] = &[ | |||
| 61 | (40, include_str!("../../migrations/0040_mail_queue.sql")), | 61 | (40, include_str!("../../migrations/0040_mail_queue.sql")), |
| 62 | (41, include_str!("../../migrations/0041_accent.sql")), | 62 | (41, include_str!("../../migrations/0041_accent.sql")), |
| 63 | (42, include_str!("../../migrations/0042_colours.sql")), | 63 | (42, include_str!("../../migrations/0042_colours.sql")), |
| 64 | + (43, include_str!("../../migrations/0043_sidebar_side.sql")), | ||
| 64 | ]; | 65 | ]; |
| 65 | 66 | ||
| 66 | /// The highest migration version this binary knows about. | 67 | /// The highest migration version this binary knows about. |
crates/forge-core/src/store/mod.rsmodified+5 -2
| @@ -110,7 +110,7 @@ struct Inner { | |||
| 110 | 110 | ||
| 111 | const USER_COLS: &str = "id, username, email, password_hash, is_admin, created_at, about, timezone, \ | 111 | const USER_COLS: &str = "id, username, email, password_hash, is_admin, created_at, about, timezone, \ |
| 112 | (SELECT hash FROM avatars WHERE avatars.user_id = users.id) AS avatar_hash, \ | 112 | (SELECT hash FROM avatars WHERE avatars.user_id = users.id) AS avatar_hash, \ |
| 113 | - theme, language, kind, email_notifications, display_name, accent, accent_dark, base_light, base_dark"; | 113 | + theme, language, kind, email_notifications, display_name, accent, accent_dark, base_light, base_dark, sidebar_side"; |
| 114 | const SESSION_COLS: &str = "id, user_id, csrf_token, created_at, expires_at, last_seen, user_agent"; | 114 | const SESSION_COLS: &str = "id, user_id, csrf_token, created_at, expires_at, last_seen, user_agent"; |
| 115 | const SSH_KEY_COLS: &str = | 115 | const SSH_KEY_COLS: &str = |
| 116 | "id, user_id, title, algorithm, key_blob, fingerprint, created_at, last_used_at"; | 116 | "id, user_id, title, algorithm, key_blob, fingerprint, created_at, last_used_at"; |
| @@ -204,6 +204,7 @@ impl Store { | |||
| 204 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), | 204 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), |
| 205 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), | 205 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 206 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), | 206 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 207 | + sidebar_side: crate::store::ui_prefs::DEFAULT_SIDEBAR.into(), | ||
| 207 | kind: AccountKind::User, | 208 | kind: AccountKind::User, |
| 208 | email_notifications: true, | 209 | email_notifications: true, |
| 209 | }; | 210 | }; |
| @@ -251,6 +252,7 @@ impl Store { | |||
| 251 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), | 252 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), |
| 252 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), | 253 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 253 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), | 254 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 255 | + sidebar_side: crate::store::ui_prefs::DEFAULT_SIDEBAR.into(), | ||
| 254 | kind: AccountKind::User, | 256 | kind: AccountKind::User, |
| 255 | email_notifications: true, | 257 | email_notifications: true, |
| 256 | }; | 258 | }; |
| @@ -1048,6 +1050,7 @@ fn map_user(row: &Row) -> Result<User> { | |||
| 1048 | accent_dark: col_text(row, 15)?, | 1050 | accent_dark: col_text(row, 15)?, |
| 1049 | base_light: col_text(row, 16)?, | 1051 | base_light: col_text(row, 16)?, |
| 1050 | base_dark: col_text(row, 17)?, | 1052 | base_dark: col_text(row, 17)?, |
| 1053 | + sidebar_side: col_text(row, 18)?, | ||
| 1051 | }) | 1054 | }) |
| 1052 | } | 1055 | } |
| 1053 | 1056 | ||
| @@ -2178,7 +2181,7 @@ impl Store { | |||
| 2178 | WHERE collaborators.repo_id = ?1 ORDER BY users.username_folded" | 2181 | WHERE collaborators.repo_id = ?1 ORDER BY users.username_folded" |
| 2179 | ), | 2182 | ), |
| 2180 | (repo_id.to_string(),), | 2183 | (repo_id.to_string(),), |
| 2181 | - |row| Ok((map_user(row)?, parse_role(&col_text(row, 18)?)?)), | 2184 | + |row| Ok((map_user(row)?, parse_role(&col_text(row, 19)?)?)), |
| 2182 | ) | 2185 | ) |
| 2183 | .await | 2186 | .await |
| 2184 | } | 2187 | } |
crates/forge-core/src/store/orgs.rsmodified+2 -2
| @@ -277,7 +277,7 @@ impl Store { | |||
| 277 | ORDER BY (org_role = 'owner') DESC, username_folded" | 277 | ORDER BY (org_role = 'owner') DESC, username_folded" |
| 278 | ), | 278 | ), |
| 279 | (org_id.to_string(),), | 279 | (org_id.to_string(),), |
| 280 | - |row| Ok((map_user(row)?, OrgMemberRole::parse(&col_text(row, 18)?)?)), | 280 | + |row| Ok((map_user(row)?, OrgMemberRole::parse(&col_text(row, 19)?)?)), |
| 281 | ) | 281 | ) |
| 282 | .await | 282 | .await |
| 283 | } | 283 | } |
| @@ -397,7 +397,7 @@ impl Store { | |||
| 397 | (SELECT org_id FROM org_members WHERE user_id = ?1) ORDER BY username_folded" | 397 | (SELECT org_id FROM org_members WHERE user_id = ?1) ORDER BY username_folded" |
| 398 | ), | 398 | ), |
| 399 | (user_id.to_string(),), | 399 | (user_id.to_string(),), |
| 400 | - |row| Ok((map_user(row)?, OrgMemberRole::parse(&col_text(row, 18)?)?)), | 400 | + |row| Ok((map_user(row)?, OrgMemberRole::parse(&col_text(row, 19)?)?)), |
| 401 | ) | 401 | ) |
| 402 | .await | 402 | .await |
| 403 | } | 403 | } |
crates/forge-core/src/store/ui_prefs.rsmodified+83 -5
| @@ -1,8 +1,8 @@ | |||
| 1 | -//! Per-user UI preferences: the colour theme, the language and the colour choices. The colours | 1 | +//! Per-user UI preferences: the colour theme, the language, the colour choices and the side of the |
| 2 | -//! are an accent and a base (neutral background, surface and text) for each of the light and the | 2 | +//! shell sidebar. The colours are an accent and a base (neutral background, surface and text) for |
| 3 | -//! dark theme. All are stored as text in `users` (migrations 0030, 0041 and 0042). The web layer | 3 | +//! each of the light and the dark theme. All are stored as text in `users` (migrations 0030, 0041, |
| 4 | -//! decides which values it offers; the store only checks that a value is well formed, so a new | 4 | +//! 0042 and 0043). The web layer decides which values it offers; the store only checks that a |
| 5 | -//! language, accent or base needs no store change. | 5 | +//! value is well formed, so a new language, accent or base needs no store change. |
| 6 | 6 | ||
| 7 | use super::{Store, db_err}; | 7 | use super::{Store, db_err}; |
| 8 | use crate::error::{Error, Result}; | 8 | use crate::error::{Error, Result}; |
| @@ -21,6 +21,12 @@ pub const DEFAULT_ACCENT: &str = "sage"; | |||
| 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 = "fern"; |
| 23 | 23 | ||
| 24 | +/// The sidebar sides, in the order the settings page lists them. | ||
| 25 | +pub const SIDEBAR_SIDES: &[&str] = &["left", "right"]; | ||
| 26 | + | ||
| 27 | +/// The side a new user's sidebar sits on. It is the side the shell has always used. | ||
| 28 | +pub const DEFAULT_SIDEBAR: &str = "left"; | ||
| 29 | + | ||
| 24 | /// Longest accepted language code, in bytes. | 30 | /// Longest accepted language code, in bytes. |
| 25 | const MAX_LANGUAGE_LEN: usize = 16; | 31 | const MAX_LANGUAGE_LEN: usize = 16; |
| 26 | 32 | ||
| @@ -52,6 +58,11 @@ pub fn valid_accent(id: &str) -> bool { | |||
| 52 | .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-') | 58 | .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-') |
| 53 | } | 59 | } |
| 54 | 60 | ||
| 61 | +/// True for `left` or `right`, the two sides the sidebar can sit on. | ||
| 62 | +pub fn valid_sidebar(side: &str) -> bool { | ||
| 63 | + SIDEBAR_SIDES.contains(&side) | ||
| 64 | +} | ||
| 65 | + | ||
| 55 | impl Store { | 66 | impl Store { |
| 56 | /// Sets the user's theme and language. Anything malformed is rejected and nothing is written. | 67 | /// Sets the user's theme and language. Anything malformed is rejected and nothing is written. |
| 57 | pub async fn set_ui_prefs(&self, user_id: &str, theme: &str, language: &str) -> Result<()> { | 68 | pub async fn set_ui_prefs(&self, user_id: &str, theme: &str, language: &str) -> Result<()> { |
| @@ -136,6 +147,26 @@ impl Store { | |||
| 136 | Ok(()) | 147 | Ok(()) |
| 137 | } | 148 | } |
| 138 | 149 | ||
| 150 | + /// Sets the side the shell sidebar sits on. Anything but `left` or `right` is rejected and | ||
| 151 | + /// nothing is written. | ||
| 152 | + pub async fn set_sidebar_side(&self, user_id: &str, side: &str) -> Result<()> { | ||
| 153 | + if !valid_sidebar(side) { | ||
| 154 | + return Err(Error::Invalid(format!("sidebar {side:?}"))); | ||
| 155 | + } | ||
| 156 | + let conn = self.inner.conn.lock().await; | ||
| 157 | + let n = conn | ||
| 158 | + .execute( | ||
| 159 | + "UPDATE users SET sidebar_side = ?2 WHERE id = ?1", | ||
| 160 | + (user_id.to_string(), side.to_string()), | ||
| 161 | + ) | ||
| 162 | + .await | ||
| 163 | + .map_err(db_err)?; | ||
| 164 | + if n == 0 { | ||
| 165 | + return Err(Error::NotFound); | ||
| 166 | + } | ||
| 167 | + Ok(()) | ||
| 168 | + } | ||
| 169 | + | ||
| 139 | /// Turns the email copy of notifications on or off for one user (migration 0035). | 170 | /// Turns the email copy of notifications on or off for one user (migration 0035). |
| 140 | pub async fn set_email_notifications(&self, user_id: &str, on: bool) -> Result<()> { | 171 | pub async fn set_email_notifications(&self, user_id: &str, on: bool) -> Result<()> { |
| 141 | let conn = self.inner.conn.lock().await; | 172 | let conn = self.inner.conn.lock().await; |
| @@ -310,4 +341,51 @@ mod tests { | |||
| 310 | ("dark", "tr") | 341 | ("dark", "tr") |
| 311 | ); | 342 | ); |
| 312 | } | 343 | } |
| 344 | + | ||
| 345 | + #[tokio::test] | ||
| 346 | + async fn sidebar_side_persists_and_bad_values_change_nothing() { | ||
| 347 | + let dir = tempfile::tempdir().unwrap(); | ||
| 348 | + let store = Store::open(&dir.path().join("forge.db")).await.unwrap(); | ||
| 349 | + let user = store | ||
| 350 | + .create_user("tahinli", None, "hash", false) | ||
| 351 | + .await | ||
| 352 | + .unwrap(); | ||
| 353 | + assert_eq!(user.sidebar_side, DEFAULT_SIDEBAR); | ||
| 354 | + | ||
| 355 | + store.set_sidebar_side(&user.id, "right").await.unwrap(); | ||
| 356 | + assert_eq!( | ||
| 357 | + store | ||
| 358 | + .user_by_id(&user.id) | ||
| 359 | + .await | ||
| 360 | + .unwrap() | ||
| 361 | + .unwrap() | ||
| 362 | + .sidebar_side, | ||
| 363 | + "right" | ||
| 364 | + ); | ||
| 365 | + | ||
| 366 | + for bad in ["", "Right", "top", "../x", "left "] { | ||
| 367 | + assert!( | ||
| 368 | + store.set_sidebar_side(&user.id, bad).await.is_err(), | ||
| 369 | + "{bad}" | ||
| 370 | + ); | ||
| 371 | + } | ||
| 372 | + assert_eq!( | ||
| 373 | + store | ||
| 374 | + .user_by_id(&user.id) | ||
| 375 | + .await | ||
| 376 | + .unwrap() | ||
| 377 | + .unwrap() | ||
| 378 | + .sidebar_side, | ||
| 379 | + "right" | ||
| 380 | + ); | ||
| 381 | + } | ||
| 382 | + | ||
| 383 | + #[test] | ||
| 384 | + fn sidebar_sides() { | ||
| 385 | + assert!(valid_sidebar("left")); | ||
| 386 | + assert!(valid_sidebar("right")); | ||
| 387 | + for bad in ["", "center", "Left", "right-2"] { | ||
| 388 | + assert!(!valid_sidebar(bad), "{bad}"); | ||
| 389 | + } | ||
| 390 | + } | ||
| 313 | } | 391 | } |
crates/forge-core/src/store/user_delete.rsmodified+1 -0
| @@ -170,6 +170,7 @@ impl Store { | |||
| 170 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), | 170 | accent_dark: crate::store::ui_prefs::DEFAULT_ACCENT.into(), |
| 171 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), | 171 | base_light: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 172 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), | 172 | base_dark: crate::store::ui_prefs::DEFAULT_BASE.into(), |
| 173 | + sidebar_side: crate::store::ui_prefs::DEFAULT_SIDEBAR.into(), | ||
| 173 | kind: AccountKind::User, | 174 | kind: AccountKind::User, |
| 174 | email_notifications: true, | 175 | email_notifications: true, |
| 175 | }; | 176 | }; |
crates/forge-web/assets/nav.jsmodified+2 -2
| @@ -130,7 +130,7 @@ | |||
| 130 | 130 | ||
| 131 | function adopt(doc, keepFields, dd) { | 131 | function adopt(doc, keepFields, dd) { |
| 132 | document.title = doc.title; | 132 | document.title = doc.title; |
| 133 | - ['lang', 'data-theme', 'data-accent-light', 'data-accent-dark', 'data-base-light', 'data-base-dark', 'data-ui'].forEach(function (name) { | 133 | + ['lang', 'data-theme', 'data-accent-light', 'data-accent-dark', 'data-base-light', 'data-base-dark', 'data-sidebar', 'data-ui'].forEach(function (name) { |
| 134 | if (doc.documentElement.hasAttribute(name)) { root.setAttribute(name, doc.documentElement.getAttribute(name)); } | 134 | if (doc.documentElement.hasAttribute(name)) { root.setAttribute(name, doc.documentElement.getAttribute(name)); } |
| 135 | else { root.removeAttribute(name); } | 135 | else { root.removeAttribute(name); } |
| 136 | }); | 136 | }); |
| @@ -424,7 +424,7 @@ | |||
| 424 | 424 | ||
| 425 | // Appearance page: a colour or theme choice shows on <html> at once, before the form's request returns. | 425 | // Appearance page: a colour or theme choice shows on <html> at once, before the form's request returns. |
| 426 | // The attributes match what the shell renders: theme `auto` has no data-theme, `dark` is dark, else light. | 426 | // The attributes match what the shell renders: theme `auto` has no data-theme, `dark` is dark, else light. |
| 427 | - var PREVIEW_ATTR = { accent_light: 'data-accent-light', accent_dark: 'data-accent-dark', base_light: 'data-base-light', base_dark: 'data-base-dark' }; | 427 | + var PREVIEW_ATTR = { accent_light: 'data-accent-light', accent_dark: 'data-accent-dark', base_light: 'data-base-light', base_dark: 'data-base-dark', sidebar_side: 'data-sidebar' }; |
| 428 | 428 | ||
| 429 | document.addEventListener('change', function (e) { | 429 | document.addEventListener('change', function (e) { |
| 430 | var el = e.target; | 430 | var el = e.target; |
crates/forge-web/src/api/releases.rsmodified+9 -1
| @@ -415,9 +415,17 @@ mod tests { | |||
| 415 | let out = std::process::Command::new("git") | 415 | let out = std::process::Command::new("git") |
| 416 | .current_dir(dir) | 416 | .current_dir(dir) |
| 417 | .args(args) | 417 | .args(args) |
| 418 | + .env("GIT_AUTHOR_NAME", "test") | ||
| 419 | + .env("GIT_AUTHOR_EMAIL", "test@example.com") | ||
| 420 | + .env("GIT_COMMITTER_NAME", "test") | ||
| 421 | + .env("GIT_COMMITTER_EMAIL", "test@example.com") | ||
| 418 | .output() | 422 | .output() |
| 419 | .expect("git runs"); | 423 | .expect("git runs"); |
| 420 | - assert!(out.status.success(), "git {args:?} failed"); | 424 | + assert!( |
| 425 | + out.status.success(), | ||
| 426 | + "git {args:?} failed: {}", | ||
| 427 | + String::from_utf8_lossy(&out.stderr) | ||
| 428 | + ); | ||
| 421 | String::from_utf8_lossy(&out.stdout).trim().to_owned() | 429 | String::from_utf8_lossy(&out.stdout).trim().to_owned() |
| 422 | } | 430 | } |
| 423 | 431 | ||
crates/forge-web/src/ci/schedule.rsmodified+121 -5
| @@ -10,8 +10,10 @@ use forge_core::ci::{CiRun, NewJob}; | |||
| 10 | use forge_core::store::commit_status::StatusState; | 10 | use forge_core::store::commit_status::StatusState; |
| 11 | use forge_core::{PullRequest, Repo}; | 11 | use forge_core::{PullRequest, Repo}; |
| 12 | use forge_git::browse::{read_blob, resolve_commit}; | 12 | use forge_git::browse::{read_blob, resolve_commit}; |
| 13 | +use tokio::io::AsyncWriteExt; | ||
| 13 | 14 | ||
| 14 | -use super::{publish, sync_run_statuses}; | 15 | +use super::api::fit_to_cap; |
| 16 | +use super::{log_path, publish, sync_run_statuses}; | ||
| 15 | use crate::internal::is_zero_oid; | 17 | use crate::internal::is_zero_oid; |
| 16 | use crate::state::AppState; | 18 | use crate::state::AppState; |
| 17 | 19 | ||
| @@ -19,6 +21,9 @@ use crate::state::AppState; | |||
| 19 | pub const CONFIG_PATH: &str = ".forge/ci.toml"; | 21 | pub const CONFIG_PATH: &str = ".forge/ci.toml"; |
| 20 | /// Largest workflow file read, in bytes. | 22 | /// Largest workflow file read, in bytes. |
| 21 | const MAX_CONFIG_BYTES: usize = 64 * 1024; | 23 | const MAX_CONFIG_BYTES: usize = 64 * 1024; |
| 24 | +/// Most config warnings written to each job log. The rest are only in the tracing output. | ||
| 25 | +const MAX_WARNING_LINES: usize = 20; | ||
| 26 | +const MIB: u64 = 1024 * 1024; | ||
| 22 | 27 | ||
| 23 | /// A job ready to store: name, `JobSpec` as JSON, and its needs. | 28 | /// A job ready to store: name, `JobSpec` as JSON, and its needs. |
| 24 | type PlannedJob = (String, String, Vec<String>); | 29 | type PlannedJob = (String, String, Vec<String>); |
| @@ -36,10 +41,12 @@ enum Plan { | |||
| 36 | Missing, | 41 | Missing, |
| 37 | /// The file is valid but this event does not trigger it. | 42 | /// The file is valid but this event does not trigger it. |
| 38 | NotTriggered, | 43 | NotTriggered, |
| 39 | - /// Create a run with these jobs, or an Error run when `config_error` is set. | 44 | + /// Create a run with these jobs, or an Error run when `config_error` is set. `warnings` are the |
| 45 | + /// config's ignored keys, written to the start of every job log. | ||
| 40 | Run { | 46 | Run { |
| 41 | jobs: Vec<PlannedJob>, | 47 | jobs: Vec<PlannedJob>, |
| 42 | config_error: Option<String>, | 48 | config_error: Option<String>, |
| 49 | + warnings: Vec<String>, | ||
| 43 | }, | 50 | }, |
| 44 | } | 51 | } |
| 45 | 52 | ||
| @@ -76,7 +83,12 @@ pub async fn on_ref_update( | |||
| 76 | }; | 83 | }; |
| 77 | let result = async { | 84 | let result = async { |
| 78 | let loaded = load(state, &repo.id, new_oid).await; | 85 | let loaded = load(state, &repo.id, new_oid).await; |
| 79 | - if let Plan::Run { jobs, config_error } = plan_for(loaded, &event)? { | 86 | + if let Plan::Run { |
| 87 | + jobs, | ||
| 88 | + config_error, | ||
| 89 | + warnings, | ||
| 90 | + } = plan_for(loaded, &event)? | ||
| 91 | + { | ||
| 80 | create( | 92 | create( |
| 81 | state, | 93 | state, |
| 82 | Request { | 94 | Request { |
| @@ -90,6 +102,7 @@ pub async fn on_ref_update( | |||
| 90 | }, | 102 | }, |
| 91 | jobs, | 103 | jobs, |
| 92 | config_error.as_deref(), | 104 | config_error.as_deref(), |
| 105 | + &warnings, | ||
| 93 | ) | 106 | ) |
| 94 | .await?; | 107 | .await?; |
| 95 | } | 108 | } |
| @@ -120,7 +133,12 @@ async fn pull_run( | |||
| 120 | actor_id: &str, | 133 | actor_id: &str, |
| 121 | ) -> forge_core::Result<()> { | 134 | ) -> forge_core::Result<()> { |
| 122 | let loaded = load(state, &repo.id, &pull.head_oid).await; | 135 | let loaded = load(state, &repo.id, &pull.head_oid).await; |
| 123 | - let Plan::Run { jobs, config_error } = plan_for(loaded, &Event::PullRequest)? else { | 136 | + let Plan::Run { |
| 137 | + jobs, | ||
| 138 | + config_error, | ||
| 139 | + warnings, | ||
| 140 | + } = plan_for(loaded, &Event::PullRequest)? | ||
| 141 | + else { | ||
| 124 | return Ok(()); | 142 | return Ok(()); |
| 125 | }; | 143 | }; |
| 126 | let needs_approval = needs_approval(state, repo, pull).await?; | 144 | let needs_approval = needs_approval(state, repo, pull).await?; |
| @@ -138,6 +156,7 @@ async fn pull_run( | |||
| 138 | }, | 156 | }, |
| 139 | jobs, | 157 | jobs, |
| 140 | config_error.as_deref(), | 158 | config_error.as_deref(), |
| 159 | + &warnings, | ||
| 141 | ) | 160 | ) |
| 142 | .await?; | 161 | .await?; |
| 143 | Ok(()) | 162 | Ok(()) |
| @@ -167,7 +186,11 @@ pub async fn manual_run( | |||
| 167 | }; | 186 | }; |
| 168 | let loaded = load(state, &repo.id, &commit).await; | 187 | let loaded = load(state, &repo.id, &commit).await; |
| 169 | match plan_for(loaded, &Event::Manual)? { | 188 | match plan_for(loaded, &Event::Manual)? { |
| 170 | - Plan::Run { jobs, config_error } => { | 189 | + Plan::Run { |
| 190 | + jobs, | ||
| 191 | + config_error, | ||
| 192 | + warnings, | ||
| 193 | + } => { | ||
| 171 | create( | 194 | create( |
| 172 | state, | 195 | state, |
| 173 | Request { | 196 | Request { |
| @@ -181,6 +204,7 @@ pub async fn manual_run( | |||
| 181 | }, | 204 | }, |
| 182 | jobs, | 205 | jobs, |
| 183 | config_error.as_deref(), | 206 | config_error.as_deref(), |
| 207 | + &warnings, | ||
| 184 | ) | 208 | ) |
| 185 | .await | 209 | .await |
| 186 | } | 210 | } |
| @@ -200,6 +224,7 @@ async fn create( | |||
| 200 | req: Request<'_>, | 224 | req: Request<'_>, |
| 201 | jobs: Vec<PlannedJob>, | 225 | jobs: Vec<PlannedJob>, |
| 202 | config_error: Option<&str>, | 226 | config_error: Option<&str>, |
| 227 | + warnings: &[String], | ||
| 203 | ) -> forge_core::Result<CiRun> { | 228 | ) -> forge_core::Result<CiRun> { |
| 204 | let new_jobs: Vec<NewJob<'_>> = jobs | 229 | let new_jobs: Vec<NewJob<'_>> = jobs |
| 205 | .iter() | 230 | .iter() |
| @@ -224,6 +249,7 @@ async fn create( | |||
| 224 | ) | 249 | ) |
| 225 | .await?; | 250 | .await?; |
| 226 | state.ci_live.bump_repo(&run.repo_id); | 251 | state.ci_live.bump_repo(&run.repo_id); |
| 252 | + note_warnings(state, &run, warnings).await?; | ||
| 227 | if let Some(message) = config_error { | 253 | if let Some(message) = config_error { |
| 228 | let url = format!( | 254 | let url = format!( |
| 229 | "{}/{}/{}/ci/runs/{}", | 255 | "{}/{}/{}/ci/runs/{}", |
| @@ -249,6 +275,65 @@ async fn create( | |||
| 249 | Ok(run) | 275 | Ok(run) |
| 250 | } | 276 | } |
| 251 | 277 | ||
| 278 | +/// Writes the config warnings as `[forge] warning: ...` lines at the start of every job's log, and | ||
| 279 | +/// logs them. Runs before the runners are woken, so the lines come first. A failed write is logged | ||
| 280 | +/// and does not fail the run. | ||
| 281 | +async fn note_warnings( | ||
| 282 | + state: &AppState, | ||
| 283 | + run: &CiRun, | ||
| 284 | + warnings: &[String], | ||
| 285 | +) -> forge_core::Result<()> { | ||
| 286 | + if warnings.is_empty() { | ||
| 287 | + return Ok(()); | ||
| 288 | + } | ||
| 289 | + let mut text = String::new(); | ||
| 290 | + for warning in warnings { | ||
| 291 | + tracing::warn!(run_id = %run.id, repo_id = %run.repo_id, "ci: {warning}"); | ||
| 292 | + } | ||
| 293 | + for warning in warnings.iter().take(MAX_WARNING_LINES) { | ||
| 294 | + text.push_str(&format!("[forge] warning: {warning}\n")); | ||
| 295 | + } | ||
| 296 | + let cap = state.config.ci.max_log_mb.saturating_mul(MIB); | ||
| 297 | + for job in state.store.jobs_for_run(&run.id).await? { | ||
| 298 | + let path = log_path(&state.config.data_dir, &job.id); | ||
| 299 | + let current = match tokio::fs::metadata(&path).await { | ||
| 300 | + Ok(meta) => meta.len(), | ||
| 301 | + Err(e) if e.kind() == std::io::ErrorKind::NotFound => 0, | ||
| 302 | + Err(e) => { | ||
| 303 | + tracing::error!(error = %e, job_id = %job.id, "ci: reading the job log failed"); | ||
| 304 | + continue; | ||
| 305 | + } | ||
| 306 | + }; | ||
| 307 | + let bytes = fit_to_cap(current, cap, text.as_bytes()); | ||
| 308 | + if bytes.is_empty() { | ||
| 309 | + continue; | ||
| 310 | + } | ||
| 311 | + let written: std::io::Result<()> = async { | ||
| 312 | + if let Some(parent) = path.parent() { | ||
| 313 | + tokio::fs::create_dir_all(parent).await?; | ||
| 314 | + } | ||
| 315 | + let mut file = tokio::fs::OpenOptions::new() | ||
| 316 | + .create(true) | ||
| 317 | + .append(true) | ||
| 318 | + .open(&path) | ||
| 319 | + .await?; | ||
| 320 | + file.write_all(&bytes).await?; | ||
| 321 | + file.flush().await | ||
| 322 | + } | ||
| 323 | + .await; | ||
| 324 | + if let Err(e) = written { | ||
| 325 | + tracing::error!(error = %e, job_id = %job.id, "ci: writing the job log failed"); | ||
| 326 | + continue; | ||
| 327 | + } | ||
| 328 | + if let Err(e) = state.store.add_log_bytes(&job.id, bytes.len() as i64).await { | ||
| 329 | + tracing::error!(error = %e, job_id = %job.id, "ci: counting the job log bytes failed"); | ||
| 330 | + continue; | ||
| 331 | + } | ||
| 332 | + state.ci_live.bump_job(&job.id); | ||
| 333 | + } | ||
| 334 | + Ok(()) | ||
| 335 | +} | ||
| 336 | + | ||
| 252 | /// Decides what a request does, given the loaded config and the event. | 337 | /// Decides what a request does, given the loaded config and the event. |
| 253 | fn plan_for(loaded: Loaded, event: &Event<'_>) -> forge_core::Result<Plan> { | 338 | fn plan_for(loaded: Loaded, event: &Event<'_>) -> forge_core::Result<Plan> { |
| 254 | match loaded { | 339 | match loaded { |
| @@ -256,6 +341,7 @@ fn plan_for(loaded: Loaded, event: &Event<'_>) -> forge_core::Result<Plan> { | |||
| 256 | Loaded::Invalid(message) => Ok(Plan::Run { | 341 | Loaded::Invalid(message) => Ok(Plan::Run { |
| 257 | jobs: Vec::new(), | 342 | jobs: Vec::new(), |
| 258 | config_error: Some(message), | 343 | config_error: Some(message), |
| 344 | + warnings: Vec::new(), | ||
| 259 | }), | 345 | }), |
| 260 | Loaded::Valid(cfg) => { | 346 | Loaded::Valid(cfg) => { |
| 261 | if !cfg.triggered_by(event) { | 347 | if !cfg.triggered_by(event) { |
| @@ -264,6 +350,7 @@ fn plan_for(loaded: Loaded, event: &Event<'_>) -> forge_core::Result<Plan> { | |||
| 264 | Ok(Plan::Run { | 350 | Ok(Plan::Run { |
| 265 | jobs: plan_jobs(&cfg)?, | 351 | jobs: plan_jobs(&cfg)?, |
| 266 | config_error: None, | 352 | config_error: None, |
| 353 | + warnings: cfg.warnings.clone(), | ||
| 267 | }) | 354 | }) |
| 268 | } | 355 | } |
| 269 | } | 356 | } |
| @@ -612,6 +699,35 @@ run = "make" | |||
| 612 | assert_eq!(test.state, StatusState::Pending); | 699 | assert_eq!(test.state, StatusState::Pending); |
| 613 | } | 700 | } |
| 614 | 701 | ||
| 702 | + #[tokio::test] | ||
| 703 | + async fn unknown_config_keys_still_run_and_warn_in_each_job_log() { | ||
| 704 | + let fx = fixture().await; | ||
| 705 | + let text = format!("{CONFIG_ONE_JOB}\n[future]\nx = 1\n"); | ||
| 706 | + push(&fx, &[(CONFIG_PATH, text.as_str())], "refs/heads/main").await; | ||
| 707 | + | ||
| 708 | + let run = fx | ||
| 709 | + .state | ||
| 710 | + .store | ||
| 711 | + .run_by_number(&fx.repo.id, 1) | ||
| 712 | + .await | ||
| 713 | + .expect("query") | ||
| 714 | + .expect("run exists"); | ||
| 715 | + assert!(run.config_error.is_none(), "unknown keys are not an error"); | ||
| 716 | + let jobs = fx.state.store.jobs_for_run(&run.id).await.expect("jobs"); | ||
| 717 | + assert_eq!(state_of(&jobs, "build"), Some(JobState::Queued)); | ||
| 718 | + | ||
| 719 | + for job in &jobs { | ||
| 720 | + let log = std::fs::read_to_string(log_path(&fx.state.config.data_dir, &job.id)) | ||
| 721 | + .expect("job log"); | ||
| 722 | + assert!( | ||
| 723 | + log.starts_with( | ||
| 724 | + "[forge] warning: unknown key `future` ignored \u{2014} this forge may be older than your ci.toml\n" | ||
| 725 | + ), | ||
| 726 | + "log was {log:?}" | ||
| 727 | + ); | ||
| 728 | + } | ||
| 729 | + } | ||
| 730 | + | ||
| 615 | #[tokio::test] | 731 | #[tokio::test] |
| 616 | async fn no_file_means_no_run() { | 732 | async fn no_file_means_no_run() { |
| 617 | let fx = fixture().await; | 733 | let fx = fixture().await; |
crates/forge-web/src/i18n/admin.rsmodified+4 -0
| @@ -11,6 +11,7 @@ pub enum K { | |||
| 11 | ActionLabel, | 11 | ActionLabel, |
| 12 | ActorUsername, | 12 | ActorUsername, |
| 13 | AddARunner, | 13 | AddARunner, |
| 14 | + AdminArea, | ||
| 14 | Administrator, | 15 | Administrator, |
| 15 | AllActions, | 16 | AllActions, |
| 16 | Anonymous, | 17 | Anonymous, |
| @@ -168,6 +169,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 168 | (ActorUsername, Tr) => "Yapan kullanıcı adı", | 169 | (ActorUsername, Tr) => "Yapan kullanıcı adı", |
| 169 | (AddARunner, En) => "Add a runner", | 170 | (AddARunner, En) => "Add a runner", |
| 170 | (AddARunner, Tr) => "Çalıştırıcı ekle", | 171 | (AddARunner, Tr) => "Çalıştırıcı ekle", |
| 172 | + (AdminArea, En) => "Admin", | ||
| 173 | + (AdminArea, Tr) => "Yönetim", | ||
| 171 | (Administrator, En) => "Administrator", | 174 | (Administrator, En) => "Administrator", |
| 172 | (Administrator, Tr) => "Yönetici", | 175 | (Administrator, Tr) => "Yönetici", |
| 173 | (AllActions, En) => "All actions", | 176 | (AllActions, En) => "All actions", |
| @@ -722,6 +725,7 @@ mod tests { | |||
| 722 | K::ActionLabel, | 725 | K::ActionLabel, |
| 723 | K::ActorUsername, | 726 | K::ActorUsername, |
| 724 | K::AddARunner, | 727 | K::AddARunner, |
| 728 | + K::AdminArea, | ||
| 725 | K::Administrator, | 729 | K::Administrator, |
| 726 | K::AllActions, | 730 | K::AllActions, |
| 727 | K::Anonymous, | 731 | K::Anonymous, |
crates/forge-web/src/i18n/misc.rsmodified+17 -0
| @@ -31,6 +31,11 @@ pub enum K { | |||
| 31 | DarkColours, | 31 | DarkColours, |
| 32 | BackgroundLabel, | 32 | BackgroundLabel, |
| 33 | ChooseBase, | 33 | ChooseBase, |
| 34 | + // Appearance: which side the shell sidebar sits on. | ||
| 35 | + SidebarLabel, | ||
| 36 | + SidebarLeft, | ||
| 37 | + SidebarRight, | ||
| 38 | + ChooseSidebar, | ||
| 34 | // Notifications: row kinds. | 39 | // Notifications: row kinds. |
| 35 | KindOpenIssue, | 40 | KindOpenIssue, |
| 36 | KindClosedIssue, | 41 | KindClosedIssue, |
| @@ -173,6 +178,10 @@ const ALL: &[K] = &[ | |||
| 173 | K::DarkColours, | 178 | K::DarkColours, |
| 174 | K::BackgroundLabel, | 179 | K::BackgroundLabel, |
| 175 | K::ChooseBase, | 180 | K::ChooseBase, |
| 181 | + K::SidebarLabel, | ||
| 182 | + K::SidebarLeft, | ||
| 183 | + K::SidebarRight, | ||
| 184 | + K::ChooseSidebar, | ||
| 176 | K::KindOpenIssue, | 185 | K::KindOpenIssue, |
| 177 | K::KindClosedIssue, | 186 | K::KindClosedIssue, |
| 178 | K::KindOpenPull, | 187 | K::KindOpenPull, |
| @@ -327,6 +336,14 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 327 | (BackgroundLabel, Tr) => "Arka plan", | 336 | (BackgroundLabel, Tr) => "Arka plan", |
| 328 | (ChooseBase, En) => "Choose a background from the list.", | 337 | (ChooseBase, En) => "Choose a background from the list.", |
| 329 | (ChooseBase, Tr) => "Listeden bir arka plan seçin.", | 338 | (ChooseBase, Tr) => "Listeden bir arka plan seçin.", |
| 339 | + (SidebarLabel, En) => "Sidebar position", | ||
| 340 | + (SidebarLabel, Tr) => "Kenar çubuğu konumu", | ||
| 341 | + (SidebarLeft, En) => "Left", | ||
| 342 | + (SidebarLeft, Tr) => "Sol", | ||
| 343 | + (SidebarRight, En) => "Right", | ||
| 344 | + (SidebarRight, Tr) => "Sağ", | ||
| 345 | + (ChooseSidebar, En) => "Choose a sidebar position from the list.", | ||
| 346 | + (ChooseSidebar, Tr) => "Listeden bir kenar çubuğu konumu seçin.", | ||
| 330 | (KindOpenIssue, En) => "Open issue", | 347 | (KindOpenIssue, En) => "Open issue", |
| 331 | (KindOpenIssue, Tr) => "Açık sorun", | 348 | (KindOpenIssue, Tr) => "Açık sorun", |
| 332 | (KindClosedIssue, En) => "Closed issue", | 349 | (KindClosedIssue, En) => "Closed issue", |
crates/forge-web/src/i18n/mod.rsmodified+4 -12
| @@ -124,9 +124,7 @@ pub enum Key { | |||
| 124 | AccessTokens, | 124 | AccessTokens, |
| 125 | Sessions, | 125 | Sessions, |
| 126 | Security, | 126 | Security, |
| 127 | - AdminUsers, | 127 | + BackToSite, |
| 128 | - AdminAuditLog, | ||
| 129 | - AdminRunners, | ||
| 130 | LogOut, | 128 | LogOut, |
| 131 | LogIn, | 129 | LogIn, |
| 132 | SiteMenu, | 130 | SiteMenu, |
| @@ -355,9 +353,7 @@ pub const ALL: &[Key] = &[ | |||
| 355 | Key::AccessTokens, | 353 | Key::AccessTokens, |
| 356 | Key::Sessions, | 354 | Key::Sessions, |
| 357 | Key::Security, | 355 | Key::Security, |
| 358 | - Key::AdminUsers, | 356 | + Key::BackToSite, |
| 359 | - Key::AdminAuditLog, | ||
| 360 | - Key::AdminRunners, | ||
| 361 | Key::LogOut, | 357 | Key::LogOut, |
| 362 | Key::LogIn, | 358 | Key::LogIn, |
| 363 | Key::SiteMenu, | 359 | Key::SiteMenu, |
| @@ -574,12 +570,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 574 | (Sessions, Tr) => "Oturumlar", | 570 | (Sessions, Tr) => "Oturumlar", |
| 575 | (Security, En) => "Security", | 571 | (Security, En) => "Security", |
| 576 | (Security, Tr) => "Güvenlik", | 572 | (Security, Tr) => "Güvenlik", |
| 577 | - (AdminUsers, En) => "Admin: users", | 573 | + (BackToSite, En) => "Back to forge", |
| 578 | - (AdminUsers, Tr) => "Yönetici: kullanıcılar", | 574 | + (BackToSite, Tr) => "Forge'a dön", |
| 579 | - (AdminAuditLog, En) => "Admin: audit log", | ||
| 580 | - (AdminAuditLog, Tr) => "Yönetici: denetim günlüğü", | ||
| 581 | - (AdminRunners, En) => "Admin: runners", | ||
| 582 | - (AdminRunners, Tr) => "Yönetici: çalıştırıcılar", | ||
| 583 | (LogOut, En) => "Log out", | 575 | (LogOut, En) => "Log out", |
| 584 | (LogOut, Tr) => "Çıkış yap", | 576 | (LogOut, Tr) => "Çıkış yap", |
| 585 | (SiteMenu, En) => "Menu", | 577 | (SiteMenu, En) => "Menu", |
crates/forge-web/src/pages/admin_runners.rsmodified+0 -9
| @@ -100,13 +100,6 @@ fn register_command(base_url: &str, token: &str) -> String { | |||
| 100 | ) | 100 | ) |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | -#[component] | ||
| 104 | -async fn runners_nav(lang: Lang) -> Result<impl View> { | ||
| 105 | - Ok(view! { | ||
| 106 | - <p><a href="/admin/users">(g::t(lang, K::Users))</a> " · " <a href="/admin/audit">(g::t(lang, K::AuditLog))</a> " · " <a href="/admin/backups">(g::t(lang, K::Backups))</a> " · " <a href="/admin/replication">(g::t(lang, K::Replication))</a> " · " <a href="/admin/mail">(g::t(lang, K::Mail))</a> " · " <a href="/admin/runners" aria-current="page">(g::t(lang, K::Runners))</a></p> | ||
| 107 | - }) | ||
| 108 | -} | ||
| 109 | - | ||
| 110 | #[component] | 103 | #[component] |
| 111 | async fn runners_view( | 104 | async fn runners_view( |
| 112 | lang: Lang, | 105 | lang: Lang, |
| @@ -118,7 +111,6 @@ async fn runners_view( | |||
| 118 | Ok(view! { | 111 | Ok(view! { |
| 119 | <section class="page-head"> | 112 | <section class="page-head"> |
| 120 | <h1>(g::t(lang, K::CiRunners))</h1> | 113 | <h1>(g::t(lang, K::CiRunners))</h1> |
| 121 | - runners_nav(lang: lang) | ||
| 122 | </section> | 114 | </section> |
| 123 | if let Some((text, is_error)) = notice { | 115 | if let Some((text, is_error)) = notice { |
| 124 | if is_error { | 116 | if is_error { |
| @@ -191,7 +183,6 @@ async fn token_view( | |||
| 191 | Ok(view! { | 183 | Ok(view! { |
| 192 | <section class="page-head"> | 184 | <section class="page-head"> |
| 193 | <h1>(g::t(lang, K::RegistrationToken))</h1> | 185 | <h1>(g::t(lang, K::RegistrationToken))</h1> |
| 194 | - runners_nav(lang: lang) | ||
| 195 | </section> | 186 | </section> |
| 196 | <section class="card notice" role="status"> | 187 | <section class="card notice" role="status"> |
| 197 | <p><strong>(g::t(lang, K::CopyTokenNow))</strong></p> | 188 | <p><strong>(g::t(lang, K::CopyTokenNow))</strong></p> |
crates/forge-web/src/pages/admin_users.rsmodified+0 -1
| @@ -60,7 +60,6 @@ async fn users_view( | |||
| 60 | Ok(view! { | 60 | Ok(view! { |
| 61 | <section class="page-head"> | 61 | <section class="page-head"> |
| 62 | <h1>(g::t(lang, K::Users))</h1> | 62 | <h1>(g::t(lang, K::Users))</h1> |
| 63 | - <p><a href="/admin/audit">(g::t(lang, K::AuditLog))</a> " · " <a href="/admin/backups">(g::t(lang, K::Backups))</a> " · " <a href="/admin/replication">(g::t(lang, K::Replication))</a> " · " <a href="/admin/mail">(g::t(lang, K::Mail))</a> " · " <a href="/admin/runners">(g::t(lang, K::Runners))</a> " · " <a href="/admin/invites">(g::t(lang, K::Invites))</a></p> | ||
| 64 | </section> | 63 | </section> |
| 65 | <section class="card"> | 64 | <section class="card"> |
| 66 | <div class="table-wrap"> | 65 | <div class="table-wrap"> |
crates/forge-web/src/pages/settings_appearance.rsmodified+67 -2
| @@ -1,10 +1,11 @@ | |||
| 1 | //! Page: appearance (`/settings/appearance`). The colour theme, the language, and for each of the | 1 | //! Page: appearance (`/settings/appearance`). The colour theme, the language, and for each of the |
| 2 | -//! light and dark themes a background and an accent colour, all stored per user. Every change | 2 | +//! light and dark themes a background and an accent colour, and the side of the shell sidebar, |
| 3 | +//! all stored per user. Every change | ||
| 3 | //! saves at once, so the form has no Save button. Anonymous visitors set the theme from the footer | 4 | //! saves at once, so the form has no Save button. Anonymous visitors set the theme from the footer |
| 4 | //! instead (see `pages/theme_cookie.rs`). Every POST checks the CSRF token first. | 5 | //! instead (see `pages/theme_cookie.rs`). Every POST checks the CSRF token first. |
| 5 | 6 | ||
| 6 | use forge_core::AuditAction; | 7 | use forge_core::AuditAction; |
| 7 | -use forge_core::store::ui_prefs::THEMES; | 8 | +use forge_core::store::ui_prefs::{SIDEBAR_SIDES, THEMES}; |
| 8 | use forge_core::{Error as CoreError, Session, Store, User}; | 9 | use forge_core::{Error as CoreError, Session, Store, User}; |
| 9 | use serde::{Deserialize, Deserializer}; | 10 | use serde::{Deserialize, Deserializer}; |
| 10 | use topcoat::Result; | 11 | use topcoat::Result; |
| @@ -30,6 +31,9 @@ pub const LANGUAGE_CODES: &[&str] = &["auto", "en", "tr"]; | |||
| 30 | /// Theme codes, in display order. | 31 | /// Theme codes, in display order. |
| 31 | const THEME_CODES: &[&str] = &["auto", "light", "dark"]; | 32 | const THEME_CODES: &[&str] = &["auto", "light", "dark"]; |
| 32 | 33 | ||
| 34 | +/// Sidebar sides, in display order. Must match `store::ui_prefs::SIDEBAR_SIDES`. | ||
| 35 | +const SIDEBAR_CODES: &[&str] = &["left", "right"]; | ||
| 36 | + | ||
| 33 | /// Reads a field that is present as a string, even an empty one. The plain `Option<String>` | 37 | /// Reads a field that is present as a string, even an empty one. The plain `Option<String>` |
| 34 | /// reading would turn an empty value into `None`, which is the same as a missing field. | 38 | /// reading would turn an empty value into `None`, which is the same as a missing field. |
| 35 | fn present_string<'de, D: Deserializer<'de>>( | 39 | fn present_string<'de, D: Deserializer<'de>>( |
| @@ -57,6 +61,8 @@ struct AppearanceForm { | |||
| 57 | base_light: Option<String>, | 61 | base_light: Option<String>, |
| 58 | #[serde(default, deserialize_with = "present_string")] | 62 | #[serde(default, deserialize_with = "present_string")] |
| 59 | base_dark: Option<String>, | 63 | base_dark: Option<String>, |
| 64 | + #[serde(default, deserialize_with = "present_string")] | ||
| 65 | + sidebar_side: Option<String>, | ||
| 60 | } | 66 | } |
| 61 | 67 | ||
| 62 | struct Choice { | 68 | struct Choice { |
| @@ -83,6 +89,15 @@ struct AppearancePage { | |||
| 83 | language: Vec<Choice>, | 89 | language: Vec<Choice>, |
| 84 | light: ColourGroup, | 90 | light: ColourGroup, |
| 85 | dark: ColourGroup, | 91 | dark: ColourGroup, |
| 92 | + sidebar: Vec<Choice>, | ||
| 93 | +} | ||
| 94 | + | ||
| 95 | +/// The label of a sidebar side. | ||
| 96 | +fn sidebar_label(lang: Lang, code: &str) -> &'static str { | ||
| 97 | + match code { | ||
| 98 | + "right" => g::t(lang, K::SidebarRight), | ||
| 99 | + _ => g::t(lang, K::SidebarLeft), | ||
| 100 | + } | ||
| 86 | } | 101 | } |
| 87 | 102 | ||
| 88 | /// The label of a language code. The two native names stay as they are in every language. | 103 | /// The label of a language code. The two native names stay as they are in every language. |
| @@ -204,6 +219,7 @@ async fn appearance_body(page: AppearancePage) -> Result<impl View> { | |||
| 204 | language, | 219 | language, |
| 205 | light, | 220 | light, |
| 206 | dark, | 221 | dark, |
| 222 | + sidebar, | ||
| 207 | } = page; | 223 | } = page; |
| 208 | Ok(view! { | 224 | Ok(view! { |
| 209 | <div class="settings-layout"> | 225 | <div class="settings-layout"> |
| @@ -230,6 +246,17 @@ async fn appearance_body(page: AppearancePage) -> Result<impl View> { | |||
| 230 | } | 246 | } |
| 231 | </select> | 247 | </select> |
| 232 | </label> | 248 | </label> |
| 249 | + <fieldset class="side-picker"> | ||
| 250 | + <legend>(g::t(lang, K::SidebarLabel))</legend> | ||
| 251 | + <div class="segmented" role="group"> | ||
| 252 | + for choice in sidebar.into_iter() { | ||
| 253 | + <label class="segment"> | ||
| 254 | + <input type="radio" name="sidebar_side" value=(choice.value) checked=(choice.selected) data-autosubmit="true"> | ||
| 255 | + <span>(choice.label)</span> | ||
| 256 | + </label> | ||
| 257 | + } | ||
| 258 | + </div> | ||
| 259 | + </fieldset> | ||
| 233 | </div> | 260 | </div> |
| 234 | <div class="appearance-columns"> | 261 | <div class="appearance-columns"> |
| 235 | colour_group_fields(group: light) | 262 | colour_group_fields(group: light) |
| @@ -271,6 +298,22 @@ fn base_choice(lang: Lang, posted: Option<&str>, stored: &str) -> forge_core::Re | |||
| 271 | } | 298 | } |
| 272 | } | 299 | } |
| 273 | 300 | ||
| 301 | +/// The sidebar side a save stores. An absent field keeps the stored side. A present one must be | ||
| 302 | +/// `left` or `right`, so an empty or unknown value is rejected. | ||
| 303 | +fn sidebar_choice(lang: Lang, posted: Option<&str>, stored: &str) -> forge_core::Result<String> { | ||
| 304 | + match posted { | ||
| 305 | + None => Ok(stored.to_owned()), | ||
| 306 | + Some(side) if SIDEBAR_SIDES.contains(&side) => Ok(side.to_owned()), | ||
| 307 | + Some(_) => Err(CoreError::Invalid(g::t(lang, K::ChooseSidebar).into())), | ||
| 308 | + } | ||
| 309 | +} | ||
| 310 | + | ||
| 311 | +/// The side a viewer's stored value stands for. Anything but `right` is `left`, the default, which | ||
| 312 | +/// is also what the shell renders on `<html>` (see `views/mod.rs`). | ||
| 313 | +pub fn sidebar_stored(stored: &str) -> &'static str { | ||
| 314 | + if stored == "right" { "right" } else { "left" } | ||
| 315 | +} | ||
| 316 | + | ||
| 274 | /// Builds the page for a viewer. Each choice shows the stored value, or the default when the | 317 | /// Builds the page for a viewer. Each choice shows the stored value, or the default when the |
| 275 | /// stored id is no longer offered, which is what the page renders on `<html>` too. | 318 | /// stored id is no longer offered, which is what the page renders on `<html>` too. |
| 276 | fn page_for(viewer: &(User, Session), lang: Lang) -> AppearancePage { | 319 | fn page_for(viewer: &(User, Session), lang: Lang) -> AppearancePage { |
| @@ -294,6 +337,9 @@ fn page_for(viewer: &(User, Session), lang: Lang) -> AppearancePage { | |||
| 294 | accent::resolve_base(&user.base_dark).id, | 337 | accent::resolve_base(&user.base_dark).id, |
| 295 | accent::resolve(&user.accent_dark).id, | 338 | accent::resolve(&user.accent_dark).id, |
| 296 | ), | 339 | ), |
| 340 | + sidebar: choices(SIDEBAR_CODES, sidebar_stored(&user.sidebar_side), |code| { | ||
| 341 | + sidebar_label(lang, code) | ||
| 342 | + }), | ||
| 297 | } | 343 | } |
| 298 | } | 344 | } |
| 299 | 345 | ||
| @@ -319,9 +365,11 @@ async fn appearance_save(cx: &Cx, Form(form): Form<AppearanceForm>) -> Result<Se | |||
| 319 | let accent_dark = accent_choice(lang, form.accent_dark.as_deref(), &user.accent_dark)?; | 365 | let accent_dark = accent_choice(lang, form.accent_dark.as_deref(), &user.accent_dark)?; |
| 320 | let base_light = base_choice(lang, form.base_light.as_deref(), &user.base_light)?; | 366 | let base_light = base_choice(lang, form.base_light.as_deref(), &user.base_light)?; |
| 321 | let base_dark = base_choice(lang, form.base_dark.as_deref(), &user.base_dark)?; | 367 | let base_dark = base_choice(lang, form.base_dark.as_deref(), &user.base_dark)?; |
| 368 | + let sidebar_side = sidebar_choice(lang, form.sidebar_side.as_deref(), &user.sidebar_side)?; | ||
| 322 | store | 369 | store |
| 323 | .set_ui_prefs(&user.id, &form.theme, &form.language) | 370 | .set_ui_prefs(&user.id, &form.theme, &form.language) |
| 324 | .await?; | 371 | .await?; |
| 372 | + store.set_sidebar_side(&user.id, &sidebar_side).await?; | ||
| 325 | store | 373 | store |
| 326 | .set_colours( | 374 | .set_colours( |
| 327 | &user.id, | 375 | &user.id, |
| @@ -348,6 +396,7 @@ async fn appearance_save(cx: &Cx, Form(form): Form<AppearanceForm>) -> Result<Se | |||
| 348 | "accent_dark": accent_dark, | 396 | "accent_dark": accent_dark, |
| 349 | "base_light": base_light, | 397 | "base_light": base_light, |
| 350 | "base_dark": base_dark, | 398 | "base_dark": base_dark, |
| 399 | + "sidebar_side": sidebar_side, | ||
| 351 | }), | 400 | }), |
| 352 | ) | 401 | ) |
| 353 | .await; | 402 | .await; |
| @@ -441,4 +490,20 @@ mod tests { | |||
| 441 | ); | 490 | ); |
| 442 | assert_eq!(language_label(Lang::Tr, "tr"), "T\u{fc}rk\u{e7}e"); | 491 | assert_eq!(language_label(Lang::Tr, "tr"), "T\u{fc}rk\u{e7}e"); |
| 443 | } | 492 | } |
| 493 | + | ||
| 494 | + #[test] | ||
| 495 | + fn only_left_or_right_passes_for_the_sidebar() { | ||
| 496 | + assert_eq!( | ||
| 497 | + sidebar_choice(Lang::En, Some("right"), "left").unwrap(), | ||
| 498 | + "right" | ||
| 499 | + ); | ||
| 500 | + assert_eq!(sidebar_choice(Lang::Tr, None, "right").unwrap(), "right"); | ||
| 501 | + assert!(sidebar_choice(Lang::En, Some("top"), "left").is_err()); | ||
| 502 | + assert!(sidebar_choice(Lang::En, Some(""), "left").is_err()); | ||
| 503 | + assert!(sidebar_choice(Lang::En, Some("Right"), "left").is_err()); | ||
| 504 | + assert_eq!(sidebar_stored("right"), "right"); | ||
| 505 | + assert_eq!(sidebar_stored("left"), "left"); | ||
| 506 | + assert_eq!(sidebar_stored("bogus"), "left"); | ||
| 507 | + assert_eq!(sidebar_label(Lang::Tr, "right"), "Sa\u{11f}"); | ||
| 508 | + } | ||
| 444 | } | 509 | } |
crates/forge-web/src/views/mod.rsmodified+258 -14
| @@ -22,6 +22,7 @@ use topcoat::router::response::{Response, response_headers}; | |||
| 22 | use topcoat::router::{Body, Next, layer}; | 22 | use topcoat::router::{Body, Next, layer}; |
| 23 | use topcoat::view::{Child, View, component, view}; | 23 | use topcoat::view::{Child, View, component, view}; |
| 24 | 24 | ||
| 25 | +use crate::i18n::admin::{self as ad, K as AK}; | ||
| 25 | use crate::i18n::code::{self as g, K}; | 26 | use crate::i18n::code::{self as g, K}; |
| 26 | use crate::i18n::community::{self as cm, K as CK}; | 27 | use crate::i18n::community::{self as cm, K as CK}; |
| 27 | use crate::i18n::misc::{self as mi, K as MK}; | 28 | use crate::i18n::misc::{self as mi, K as MK}; |
| @@ -160,6 +161,13 @@ pub async fn shell( | |||
| 160 | let theme_csrf = viewer.map(|(_, session)| session.csrf_token.clone()); | 161 | let theme_csrf = viewer.map(|(_, session)| session.csrf_token.clone()); |
| 161 | let back = uri(__cx).path_and_query().map(|p| p.as_str().to_owned()); | 162 | let back = uri(__cx).path_and_query().map(|p| p.as_str().to_owned()); |
| 162 | let lang = i18n::lang(__cx, viewer.map(|(user, _)| user)); | 163 | let lang = i18n::lang(__cx, viewer.map(|(user, _)| user)); |
| 164 | + // The admin area and the user settings swap the global links for their own list. Signed-in only. | ||
| 165 | + let section = if signed_in { | ||
| 166 | + section_for(lang, uri(__cx).path()) | ||
| 167 | + } else { | ||
| 168 | + None | ||
| 169 | + }; | ||
| 170 | + let section_menu = section.clone(); | ||
| 163 | let theme_attr = crate::theme::data_theme(__cx, viewer.map(|(user, _)| user)); | 171 | let theme_attr = crate::theme::data_theme(__cx, viewer.map(|(user, _)| user)); |
| 164 | // Always set, defaults included, so a page never keeps the colours of the one before it. | 172 | // Always set, defaults included, so a page never keeps the colours of the one before it. |
| 165 | // Each of the four choices is resolved on its own, so an id that is no longer offered falls | 173 | // Each of the four choices is resolved on its own, so an id that is no longer offered falls |
| @@ -183,6 +191,11 @@ pub async fn shell( | |||
| 183 | let accent_dark_id = crate::accent::resolve(stored_accent_dark).id; | 191 | let accent_dark_id = crate::accent::resolve(stored_accent_dark).id; |
| 184 | let base_light_id = crate::accent::resolve_base(stored_base_light).id; | 192 | let base_light_id = crate::accent::resolve_base(stored_base_light).id; |
| 185 | let base_dark_id = crate::accent::resolve_base(stored_base_dark).id; | 193 | let base_dark_id = crate::accent::resolve_base(stored_base_dark).id; |
| 194 | + // The side of the shell sidebar: `right` only when stored so, `left` otherwise. | ||
| 195 | + let sidebar_side = match viewer { | ||
| 196 | + Some((user, _)) if user.sidebar_side == "right" => "right", | ||
| 197 | + _ => "left", | ||
| 198 | + }; | ||
| 186 | // The stored preference, "auto" included, drives the button: its icon, its label and the | 199 | // The stored preference, "auto" included, drives the button: its icon, its label and the |
| 187 | // value it posts (the next preference in the cycle auto, light, dark). | 200 | // value it posts (the next preference in the cycle auto, light, dark). |
| 188 | let theme_pref = crate::theme::preference(__cx, viewer.map(|(user, _)| user)); | 201 | let theme_pref = crate::theme::preference(__cx, viewer.map(|(user, _)| user)); |
| @@ -212,7 +225,7 @@ pub async fn shell( | |||
| 212 | let unread_aside = unread_badge.clone(); | 225 | let unread_aside = unread_badge.clone(); |
| 213 | Ok(view! { | 226 | Ok(view! { |
| 214 | <!DOCTYPE html> | 227 | <!DOCTYPE html> |
| 215 | - <html lang=(lang.code()) data-theme=(theme_attr) data-accent-light=(accent_light_id) data-accent-dark=(accent_dark_id) data-base-light=(base_light_id) data-base-dark=(base_dark_id)> | 228 | + <html lang=(lang.code()) data-theme=(theme_attr) data-accent-light=(accent_light_id) data-accent-dark=(accent_dark_id) data-base-light=(base_light_id) data-base-dark=(base_dark_id) data-sidebar=(sidebar_side)> |
| 216 | <head> | 229 | <head> |
| 217 | <meta charset="utf-8"> | 230 | <meta charset="utf-8"> |
| 218 | <meta name="viewport" content="width=device-width, initial-scale=1"> | 231 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| @@ -234,7 +247,11 @@ pub async fn shell( | |||
| 234 | <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg> | 247 | <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg> |
| 235 | </summary> | 248 | </summary> |
| 236 | <div class="nav-panel"> | 249 | <div class="nav-panel"> |
| 237 | - side_nav(lang: lang, current: current, unread: unread_menu, repos: side_repos_menu) | 250 | + if let Some(section) = section_menu { |
| 251 | + section_nav(title: section.title, back: section.back, items: section.items, current: section.current) | ||
| 252 | + } else { | ||
| 253 | + side_nav(lang: lang, current: current, unread: unread_menu, repos: side_repos_menu) | ||
| 254 | + } | ||
| 238 | </div> | 255 | </div> |
| 239 | </details> | 256 | </details> |
| 240 | } | 257 | } |
| @@ -285,17 +302,9 @@ pub async fn shell( | |||
| 285 | </summary> | 302 | </summary> |
| 286 | <ul class="menu-list"> | 303 | <ul class="menu-list"> |
| 287 | <li><a href=(user_href(username.as_str()))>(mi::t(lang, MK::YourProfile))</a></li> | 304 | <li><a href=(user_href(username.as_str()))>(mi::t(lang, MK::YourProfile))</a></li> |
| 288 | - <li><a href="/settings/keys">(t(lang, Key::SshKeys))</a></li> | 305 | + <li><a href="/settings/profile">(o::t(lang, OK::Settings))</a></li> |
| 289 | - <li><a href="/settings/gpg">(t(lang, Key::GpgKeys))</a></li> | ||
| 290 | - <li><a href="/settings/tokens">(t(lang, Key::AccessTokens))</a></li> | ||
| 291 | - <li><a href="/settings/sessions">(t(lang, Key::Sessions))</a></li> | ||
| 292 | - <li><a href="/settings/security">(t(lang, Key::Security))</a></li> | ||
| 293 | - <li><a href="/settings/notifications">(t(lang, Key::MenuNotificationEmails))</a></li> | ||
| 294 | - <li><a href="/settings/appearance">(mi::t(lang, MK::Appearance))</a></li> | ||
| 295 | if is_admin { | 306 | if is_admin { |
| 296 | - <li><a href="/admin/users">(t(lang, Key::AdminUsers))</a></li> | 307 | + <li><a href="/admin/users">(ad::t(lang, AK::AdminArea))</a></li> |
| 297 | - <li><a href="/admin/audit">(t(lang, Key::AdminAuditLog))</a></li> | ||
| 298 | - <li><a href="/admin/runners">(t(lang, Key::AdminRunners))</a></li> | ||
| 299 | } | 308 | } |
| 300 | <li> | 309 | <li> |
| 301 | <form data-hard="true" method="post" action="/logout"> | 310 | <form data-hard="true" method="post" action="/logout"> |
| @@ -313,7 +322,11 @@ pub async fn shell( | |||
| 313 | <div class="shell"> | 322 | <div class="shell"> |
| 314 | if signed_in { | 323 | if signed_in { |
| 315 | <aside class="shell-sidebar"> | 324 | <aside class="shell-sidebar"> |
| 316 | - side_nav(lang: lang, current: current, unread: unread_aside, repos: side_repos) | 325 | + if let Some(section) = section { |
| 326 | + section_nav(title: section.title, back: section.back, items: section.items, current: section.current) | ||
| 327 | + } else { | ||
| 328 | + side_nav(lang: lang, current: current, unread: unread_aside, repos: side_repos) | ||
| 329 | + } | ||
| 317 | </aside> | 330 | </aside> |
| 318 | } | 331 | } |
| 319 | <main tabindex="-1"> | 332 | <main tabindex="-1"> |
| @@ -402,6 +415,237 @@ async fn side_nav( | |||
| 402 | }) | 415 | }) |
| 403 | } | 416 | } |
| 404 | 417 | ||
| 418 | +/// One link of a section sidebar. `key` is the second path segment it answers to (`users` for | ||
| 419 | +/// `/admin/users`), so the current link follows from the URL alone. | ||
| 420 | +#[derive(Clone)] | ||
| 421 | +pub struct NavItem { | ||
| 422 | + pub key: &'static str, | ||
| 423 | + pub href: &'static str, | ||
| 424 | + pub label: &'static str, | ||
| 425 | + pub icon: &'static str, | ||
| 426 | +} | ||
| 427 | + | ||
| 428 | +/// A section sidebar: the admin area or user settings, shown in place of the global links. | ||
| 429 | +#[derive(Clone)] | ||
| 430 | +pub struct Section { | ||
| 431 | + pub title: &'static str, | ||
| 432 | + pub back: &'static str, | ||
| 433 | + pub items: Vec<NavItem>, | ||
| 434 | + pub current: &'static str, | ||
| 435 | +} | ||
| 436 | + | ||
| 437 | +fn admin_items(lang: Lang) -> Vec<NavItem> { | ||
| 438 | + let item = |key, href, label, icon| NavItem { | ||
| 439 | + key, | ||
| 440 | + href, | ||
| 441 | + label, | ||
| 442 | + icon, | ||
| 443 | + }; | ||
| 444 | + vec![ | ||
| 445 | + item("users", "/admin/users", ad::t(lang, AK::Users), "users"), | ||
| 446 | + item( | ||
| 447 | + "invites", | ||
| 448 | + "/admin/invites", | ||
| 449 | + ad::t(lang, AK::Invites), | ||
| 450 | + "invites", | ||
| 451 | + ), | ||
| 452 | + item("audit", "/admin/audit", ad::t(lang, AK::AuditLog), "audit"), | ||
| 453 | + item( | ||
| 454 | + "runners", | ||
| 455 | + "/admin/runners", | ||
| 456 | + ad::t(lang, AK::Runners), | ||
| 457 | + "runners", | ||
| 458 | + ), | ||
| 459 | + item("mail", "/admin/mail", ad::t(lang, AK::Mail), "mail"), | ||
| 460 | + item( | ||
| 461 | + "backups", | ||
| 462 | + "/admin/backups", | ||
| 463 | + ad::t(lang, AK::Backups), | ||
| 464 | + "backups", | ||
| 465 | + ), | ||
| 466 | + item( | ||
| 467 | + "replication", | ||
| 468 | + "/admin/replication", | ||
| 469 | + ad::t(lang, AK::Replication), | ||
| 470 | + "replication", | ||
| 471 | + ), | ||
| 472 | + ] | ||
| 473 | +} | ||
| 474 | + | ||
| 475 | +fn settings_items(lang: Lang) -> Vec<NavItem> { | ||
| 476 | + let item = |key, href, label, icon| NavItem { | ||
| 477 | + key, | ||
| 478 | + href, | ||
| 479 | + label, | ||
| 480 | + icon, | ||
| 481 | + }; | ||
| 482 | + vec![ | ||
| 483 | + item( | ||
| 484 | + "profile", | ||
| 485 | + "/settings/profile", | ||
| 486 | + t(lang, Key::Profile), | ||
| 487 | + "profile", | ||
| 488 | + ), | ||
| 489 | + item("keys", "/settings/keys", t(lang, Key::SshKeys), "keys"), | ||
| 490 | + item("gpg", "/settings/gpg", t(lang, Key::GpgKeys), "gpg"), | ||
| 491 | + item( | ||
| 492 | + "tokens", | ||
| 493 | + "/settings/tokens", | ||
| 494 | + t(lang, Key::AccessTokens), | ||
| 495 | + "tokens", | ||
| 496 | + ), | ||
| 497 | + item( | ||
| 498 | + "sessions", | ||
| 499 | + "/settings/sessions", | ||
| 500 | + t(lang, Key::Sessions), | ||
| 501 | + "sessions", | ||
| 502 | + ), | ||
| 503 | + item( | ||
| 504 | + "security", | ||
| 505 | + "/settings/security", | ||
| 506 | + t(lang, Key::Security), | ||
| 507 | + "security", | ||
| 508 | + ), | ||
| 509 | + item( | ||
| 510 | + "notifications", | ||
| 511 | + "/settings/notifications", | ||
| 512 | + t(lang, Key::MenuNotificationEmails), | ||
| 513 | + "notifications", | ||
| 514 | + ), | ||
| 515 | + item( | ||
| 516 | + "appearance", | ||
| 517 | + "/settings/appearance", | ||
| 518 | + mi::t(lang, MK::Appearance), | ||
| 519 | + "appearance", | ||
| 520 | + ), | ||
| 521 | + item( | ||
| 522 | + "pins", | ||
| 523 | + "/settings/pins", | ||
| 524 | + o::t(lang, OK::CustomizePins), | ||
| 525 | + "pins", | ||
| 526 | + ), | ||
| 527 | + ] | ||
| 528 | +} | ||
| 529 | + | ||
| 530 | +/// The section sidebar for a path under `/admin` or `/settings`, or `None` elsewhere. Picked from | ||
| 531 | +/// the path alone, so every page under those prefixes gets it. `/settings/security/log` is | ||
| 532 | +/// Security's page, so it highlights Security. | ||
| 533 | +pub fn section_for(lang: Lang, path: &str) -> Option<Section> { | ||
| 534 | + let mut parts = path.trim_matches('/').split('/'); | ||
| 535 | + let first = parts.next()?; | ||
| 536 | + let second = parts.next().unwrap_or(""); | ||
| 537 | + let (title, items) = match first { | ||
| 538 | + "admin" => (ad::t(lang, AK::AdminArea), admin_items(lang)), | ||
| 539 | + "settings" => (o::t(lang, OK::Settings), settings_items(lang)), | ||
| 540 | + _ => return None, | ||
| 541 | + }; | ||
| 542 | + let current = items | ||
| 543 | + .iter() | ||
| 544 | + .find(|item| item.key == second) | ||
| 545 | + .map_or("", |item| item.key); | ||
| 546 | + Some(Section { | ||
| 547 | + title, | ||
| 548 | + back: t(lang, Key::BackToSite), | ||
| 549 | + items, | ||
| 550 | + current, | ||
| 551 | + }) | ||
| 552 | +} | ||
| 553 | + | ||
| 554 | +/// The section sidebar: a link back to the global navigation, then the section's own links with | ||
| 555 | +/// `aria-current="page"` on the current one. | ||
| 556 | +#[component] | ||
| 557 | +async fn section_nav( | ||
| 558 | + title: &str, | ||
| 559 | + back: &str, | ||
| 560 | + items: Vec<NavItem>, | ||
| 561 | + current: &str, | ||
| 562 | +) -> Result<impl View> { | ||
| 563 | + let links: Vec<(NavItem, bool)> = items | ||
| 564 | + .into_iter() | ||
| 565 | + .map(|item| { | ||
| 566 | + let on = item.key == current; | ||
| 567 | + (item, on) | ||
| 568 | + }) | ||
| 569 | + .collect(); | ||
| 570 | + Ok(view! { | ||
| 571 | + <nav class="side-links" aria-label=(back)> | ||
| 572 | + <a class="side-link" href="/"> | ||
| 573 | + nav_icon(name: "back") | ||
| 574 | + (back) | ||
| 575 | + </a> | ||
| 576 | + </nav> | ||
| 577 | + <div class="side-group"> | ||
| 578 | + <h2 class="side-h">(title)</h2> | ||
| 579 | + <nav class="side-links" aria-label=(title)> | ||
| 580 | + for (item, on) in links.into_iter() { | ||
| 581 | + <a class=(side_class(on)) href=(item.href) aria-current=(on.then_some("page"))> | ||
| 582 | + nav_icon(name: item.icon) | ||
| 583 | + (item.label) | ||
| 584 | + </a> | ||
| 585 | + } | ||
| 586 | + </nav> | ||
| 587 | + </div> | ||
| 588 | + }) | ||
| 589 | +} | ||
| 590 | + | ||
| 591 | +/// The inline icon of a section link, by name. Unknown names draw nothing. | ||
| 592 | +#[component] | ||
| 593 | +async fn nav_icon(name: &str) -> Result<impl View> { | ||
| 594 | + Ok(view! { | ||
| 595 | + if name == "back" { | ||
| 596 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M19 12H5M11 6l-6 6 6 6"/></svg> | ||
| 597 | + } | ||
| 598 | + if name == "users" { | ||
| 599 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="9" cy="8" r="4"/><path d="M2 21c0-4 3-6 7-6s7 2 7 6"/><path d="M16 4a4 4 0 0 1 0 8M22 21c0-3-2-5-4-5.5"/></svg> | ||
| 600 | + } | ||
| 601 | + if name == "invites" { | ||
| 602 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg> | ||
| 603 | + } | ||
| 604 | + if name == "audit" { | ||
| 605 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4h6v3H9z"/><path d="M7 5H5v16h14V5h-2"/><path d="M9 12h6M9 16h6"/></svg> | ||
| 606 | + } | ||
| 607 | + if name == "runners" { | ||
| 608 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="6" rx="1.5"/><rect x="3" y="14" width="18" height="6" rx="1.5"/><path d="M7 7h.01M7 17h.01"/></svg> | ||
| 609 | + } | ||
| 610 | + if name == "mail" { | ||
| 611 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M22 2 11 13"/><path d="M22 2 15 22l-4-9-9-4z"/></svg> | ||
| 612 | + } | ||
| 613 | + if name == "backups" { | ||
| 614 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><ellipse cx="12" cy="5" rx="8" ry="3"/><path d="M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5"/><path d="M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6"/></svg> | ||
| 615 | + } | ||
| 616 | + if name == "replication" { | ||
| 617 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 11a8 8 0 0 0-14.5-4.5L3 9"/><path d="M3 4v5h5"/><path d="M4 13a8 8 0 0 0 14.5 4.5L21 15"/><path d="M21 20v-5h-5"/></svg> | ||
| 618 | + } | ||
| 619 | + if name == "profile" { | ||
| 620 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg> | ||
| 621 | + } | ||
| 622 | + if name == "keys" { | ||
| 623 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="8" cy="15" r="4"/><path d="M11 12l9-9M17 6l3 3M14 9l2 2"/></svg> | ||
| 624 | + } | ||
| 625 | + if name == "gpg" { | ||
| 626 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="9" r="6"/><path d="m9 14-2 7 5-3 5 3-2-7"/></svg> | ||
| 627 | + } | ||
| 628 | + if name == "tokens" { | ||
| 629 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9h16M4 15h16M10 3l-2 18M16 3l-2 18"/></svg> | ||
| 630 | + } | ||
| 631 | + if name == "sessions" { | ||
| 632 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg> | ||
| 633 | + } | ||
| 634 | + if name == "security" { | ||
| 635 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6z"/></svg> | ||
| 636 | + } | ||
| 637 | + if name == "notifications" { | ||
| 638 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 7 3 9H3c0-2 3-2 3-9"/><path d="M10.3 21a1.9 1.9 0 0 0 3.4 0"/></svg> | ||
| 639 | + } | ||
| 640 | + if name == "appearance" { | ||
| 641 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg> | ||
| 642 | + } | ||
| 643 | + if name == "pins" { | ||
| 644 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17v5"/><path d="M9 3h6l-1 6 3 3v2H7v-2l3-3z"/></svg> | ||
| 645 | + } | ||
| 646 | + }) | ||
| 647 | +} | ||
| 648 | + | ||
| 405 | /// Name to show for a user. The reserved ghost account, which owns the content of deleted | 649 | /// Name to show for a user. The reserved ghost account, which owns the content of deleted |
| 406 | /// users, is shown as "Deleted user" ("Silinmiş kullanıcı"). Avatar and link lookups keep the real | 650 | /// users, is shown as "Deleted user" ("Silinmiş kullanıcı"). Avatar and link lookups keep the real |
| 407 | /// login name. | 651 | /// login name. |
| @@ -910,7 +1154,7 @@ mod tests { | |||
| 910 | async fn admin_links_are_shown_to_admins() { | 1154 | async fn admin_links_are_shown_to_admins() { |
| 911 | let html = menu_html(true).await; | 1155 | let html = menu_html(true).await; |
| 912 | assert!(html.contains("href=\"/admin/users\"")); | 1156 | assert!(html.contains("href=\"/admin/users\"")); |
| 913 | - assert!(html.contains("href=\"/admin/audit\"")); | 1157 | + assert!(!html.contains("Admin:"), "one Admin entry, no per-page items"); |
| 914 | } | 1158 | } |
| 915 | } | 1159 | } |
| 916 | 1160 | ||
crates/forge-web/tests/section_nav_e2e.rsadded+321 -0
| @@ -0,0 +1,321 @@ | |||
| 1 | +//! Black-box tests for the admin and settings section sidebars: every page under `/admin` and | ||
| 2 | +//! `/settings` swaps the global links for the section's own list, marks the current entry with | ||
| 3 | +//! `aria-current="page"`, and has no " · "-joined link row. | ||
| 4 | + | ||
| 5 | +#![allow(dead_code)] | ||
| 6 | + | ||
| 7 | +mod common; | ||
| 8 | +use common::{BIN, Server, describe, launch, pick_ports, write_config}; | ||
| 9 | +use std::path::Path; | ||
| 10 | +use std::process::Command; | ||
| 11 | +use std::time::Duration; | ||
| 12 | + | ||
| 13 | +use reqwest::header::{COOKIE, HeaderMap, HeaderName, SET_COOKIE}; | ||
| 14 | + | ||
| 15 | +const PW: &str = "tahinli-password-123"; | ||
| 16 | + | ||
| 17 | +struct Resp { | ||
| 18 | + status: u16, | ||
| 19 | + headers: HeaderMap, | ||
| 20 | + body: String, | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +impl Resp { | ||
| 24 | + fn header(&self, name: HeaderName) -> Option<String> { | ||
| 25 | + self.headers | ||
| 26 | + .get(name) | ||
| 27 | + .and_then(|v| v.to_str().ok()) | ||
| 28 | + .map(str::to_owned) | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + fn set_cookies(&self) -> Vec<String> { | ||
| 32 | + self.headers | ||
| 33 | + .get_all(SET_COOKIE) | ||
| 34 | + .iter() | ||
| 35 | + .filter_map(|v| v.to_str().ok().map(str::to_owned)) | ||
| 36 | + .collect() | ||
| 37 | + } | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +struct Http { | ||
| 41 | + client: reqwest::Client, | ||
| 42 | + base: String, | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +impl Http { | ||
| 46 | + fn new(port: u16) -> Self { | ||
| 47 | + let client = reqwest::Client::builder() | ||
| 48 | + .redirect(reqwest::redirect::Policy::none()) | ||
| 49 | + .timeout(Duration::from_secs(60)) | ||
| 50 | + .build() | ||
| 51 | + .expect("http client"); | ||
| 52 | + Self { | ||
| 53 | + client, | ||
| 54 | + base: format!("http://127.0.0.1:{port}"), | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + async fn get(&self, path: &str, cookie: Option<&str>) -> Resp { | ||
| 59 | + self.send(self.client.get(format!("{}{path}", self.base)), cookie) | ||
| 60 | + .await | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + async fn post_form(&self, path: &str, form: &[(&str, &str)], cookie: Option<&str>) -> Resp { | ||
| 64 | + self.send( | ||
| 65 | + self.client.post(format!("{}{path}", self.base)).form(form), | ||
| 66 | + cookie, | ||
| 67 | + ) | ||
| 68 | + .await | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + async fn send(&self, req: reqwest::RequestBuilder, cookie: Option<&str>) -> Resp { | ||
| 72 | + let req = match cookie { | ||
| 73 | + Some(cookie) => req.header(COOKIE, cookie), | ||
| 74 | + None => req, | ||
| 75 | + }; | ||
| 76 | + let res = req.send().await.expect("http request"); | ||
| 77 | + let status = res.status().as_u16(); | ||
| 78 | + let headers = res.headers().clone(); | ||
| 79 | + let body = res.text().await.expect("read body"); | ||
| 80 | + Resp { | ||
| 81 | + status, | ||
| 82 | + headers, | ||
| 83 | + body, | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +/// `name=value` for the cookie whose name ends with `suffix`, ignoring cleared cookies. | ||
| 89 | +fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> { | ||
| 90 | + resp.set_cookies().iter().find_map(|set| { | ||
| 91 | + let pair = set.split(';').next()?; | ||
| 92 | + let (name, value) = pair.split_once('=')?; | ||
| 93 | + (name.ends_with(suffix) && !value.is_empty()).then(|| format!("{name}={value}")) | ||
| 94 | + }) | ||
| 95 | +} | ||
| 96 | + | ||
| 97 | +/// The value of the first `<input name="...">` on a page. | ||
| 98 | +fn input_value(body: &str, name: &str) -> String { | ||
| 99 | + let doc = scraper::Html::parse_document(body); | ||
| 100 | + let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector"); | ||
| 101 | + doc.select(&selector) | ||
| 102 | + .next() | ||
| 103 | + .and_then(|el| el.value().attr("value")) | ||
| 104 | + .unwrap_or_else(|| panic!("no input named {name} on page")) | ||
| 105 | + .to_owned() | ||
| 106 | +} | ||
| 107 | + | ||
| 108 | +/// The `data-theme` attribute of `<html>`, if the page sets one. | ||
| 109 | +fn html_theme(body: &str) -> Option<String> { | ||
| 110 | + let doc = scraper::Html::parse_document(body); | ||
| 111 | + doc.root_element().attr("data-theme").map(str::to_owned) | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +/// The value of attribute `name` on `<html>`, if the page sets it. | ||
| 115 | +fn html_attr(body: &str, name: &str) -> Option<String> { | ||
| 116 | + let doc = scraper::Html::parse_document(body); | ||
| 117 | + doc.root_element().attr(name).map(str::to_owned) | ||
| 118 | +} | ||
| 119 | + | ||
| 120 | +/// The four colour attributes of `<html>`, in the order light accent, dark accent, light base, | ||
| 121 | +/// dark base. | ||
| 122 | +fn html_colours(body: &str) -> [Option<String>; 4] { | ||
| 123 | + [ | ||
| 124 | + html_attr(body, "data-accent-light"), | ||
| 125 | + html_attr(body, "data-accent-dark"), | ||
| 126 | + html_attr(body, "data-base-light"), | ||
| 127 | + html_attr(body, "data-base-dark"), | ||
| 128 | + ] | ||
| 129 | +} | ||
| 130 | + | ||
| 131 | +/// The checked radio of each colour group, in the same order as `html_colours`. | ||
| 132 | +fn checked_colours(body: &str) -> [Option<String>; 4] { | ||
| 133 | + [ | ||
| 134 | + checked_radio(body, "accent_light"), | ||
| 135 | + checked_radio(body, "accent_dark"), | ||
| 136 | + checked_radio(body, "base_light"), | ||
| 137 | + checked_radio(body, "base_dark"), | ||
| 138 | + ] | ||
| 139 | +} | ||
| 140 | + | ||
| 141 | +/// The value of the checked radio button in the group `name` on a page. | ||
| 142 | +fn checked_radio(body: &str, name: &str) -> Option<String> { | ||
| 143 | + let doc = scraper::Html::parse_document(body); | ||
| 144 | + let selector = | ||
| 145 | + scraper::Selector::parse(&format!("input[type=\"radio\"][name=\"{name}\"][checked]")) | ||
| 146 | + .expect("selector"); | ||
| 147 | + doc.select(&selector) | ||
| 148 | + .next() | ||
| 149 | + .and_then(|el| el.value().attr("value")) | ||
| 150 | + .map(str::to_owned) | ||
| 151 | +} | ||
| 152 | + | ||
| 153 | +/// The option value that is selected in the `<select name="...">` on a page. | ||
| 154 | +fn selected_option(body: &str, select: &str) -> Option<String> { | ||
| 155 | + let doc = scraper::Html::parse_document(body); | ||
| 156 | + let selector = scraper::Selector::parse(&format!("select[name=\"{select}\"] option[selected]")) | ||
| 157 | + .expect("selector"); | ||
| 158 | + doc.select(&selector) | ||
| 159 | + .next() | ||
| 160 | + .and_then(|el| el.value().attr("value")) | ||
| 161 | + .map(str::to_owned) | ||
| 162 | +} | ||
| 163 | + | ||
| 164 | +/// The top-bar theme button: the value it posts and its accessible label. | ||
| 165 | +fn theme_button(body: &str) -> (String, String) { | ||
| 166 | + let doc = scraper::Html::parse_document(body); | ||
| 167 | + let form = scraper::Selector::parse("form.theme-form").expect("selector"); | ||
| 168 | + let form = doc | ||
| 169 | + .select(&form) | ||
| 170 | + .next() | ||
| 171 | + .unwrap_or_else(|| panic!("no theme button on page")); | ||
| 172 | + let value = scraper::Selector::parse("input[name=\"theme\"]").expect("selector"); | ||
| 173 | + let value = form | ||
| 174 | + .select(&value) | ||
| 175 | + .next() | ||
| 176 | + .and_then(|el| el.value().attr("value")) | ||
| 177 | + .expect("theme value") | ||
| 178 | + .to_owned(); | ||
| 179 | + let button = scraper::Selector::parse("button").expect("selector"); | ||
| 180 | + let label = form | ||
| 181 | + .select(&button) | ||
| 182 | + .next() | ||
| 183 | + .and_then(|el| el.value().attr("aria-label")) | ||
| 184 | + .expect("aria-label") | ||
| 185 | + .to_owned(); | ||
| 186 | + (value, label) | ||
| 187 | +} | ||
| 188 | + | ||
| 189 | +/// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded. | ||
| 190 | +fn admin(config: &Path, args: &[&str]) { | ||
| 191 | + let out = Command::new(BIN) | ||
| 192 | + .arg("--config") | ||
| 193 | + .arg(config) | ||
| 194 | + .arg("admin") | ||
| 195 | + .args(args) | ||
| 196 | + .env("FORGE_PASSWORD", PW) | ||
| 197 | + .output() | ||
| 198 | + .expect("run admin command"); | ||
| 199 | + assert!( | ||
| 200 | + out.status.success(), | ||
| 201 | + "admin {args:?} failed:\n{}", | ||
| 202 | + describe(&out) | ||
| 203 | + ); | ||
| 204 | +} | ||
| 205 | + | ||
| 206 | +async fn login(http: &Http, username: &str) -> String { | ||
| 207 | + let page = http.get("/login", None).await; | ||
| 208 | + assert_eq!(page.status, 200, "GET /login"); | ||
| 209 | + let precsrf_cookie = cookie_named(&page, "forge_precsrf").expect("precsrf cookie"); | ||
| 210 | + let precsrf = input_value(&page.body, "precsrf"); | ||
| 211 | + let res = http | ||
| 212 | + .post_form( | ||
| 213 | + "/login", | ||
| 214 | + &[ | ||
| 215 | + ("username", username), | ||
| 216 | + ("password", PW), | ||
| 217 | + ("next", "/"), | ||
| 218 | + ("precsrf", &precsrf), | ||
| 219 | + ], | ||
| 220 | + Some(&precsrf_cookie), | ||
| 221 | + ) | ||
| 222 | + .await; | ||
| 223 | + assert_eq!(res.status, 303, "login as {username}: {}", res.body); | ||
| 224 | + cookie_named(&res, "forge_session").expect("session cookie after login") | ||
| 225 | +} | ||
| 226 | + | ||
| 227 | +/// A running server with user `tahinli`. The temp dir lives as long as the test. | ||
| 228 | +struct Env { | ||
| 229 | + _root: tempfile::TempDir, | ||
| 230 | + _server: Server, | ||
| 231 | + http: Http, | ||
| 232 | +} | ||
| 233 | + | ||
| 234 | +async fn start() -> Env { | ||
| 235 | + let root = tempfile::tempdir().expect("temp dir"); | ||
| 236 | + let dir = root.path().to_path_buf(); | ||
| 237 | + let ports = pick_ports(); | ||
| 238 | + let config = write_config(&dir, ports); | ||
| 239 | + admin(&config, &["create-user", "tahinli", "--admin"]); | ||
| 240 | + let (server, ports) = launch(&dir, ports).await; | ||
| 241 | + let http = Http::new(ports.http); | ||
| 242 | + Env { | ||
| 243 | + _root: root, | ||
| 244 | + _server: server, | ||
| 245 | + http, | ||
| 246 | + } | ||
| 247 | +} | ||
| 248 | + | ||
| 249 | +/// The sidebar links as (href, aria-current) pairs. | ||
| 250 | +fn sidebar(body: &str) -> Vec<(String, Option<String>)> { | ||
| 251 | + let doc = scraper::Html::parse_document(body); | ||
| 252 | + let sel = scraper::Selector::parse("aside.shell-sidebar a.side-link").expect("selector"); | ||
| 253 | + doc.select(&sel) | ||
| 254 | + .map(|a| { | ||
| 255 | + ( | ||
| 256 | + a.value().attr("href").unwrap_or("").to_owned(), | ||
| 257 | + a.value().attr("aria-current").map(str::to_owned), | ||
| 258 | + ) | ||
| 259 | + }) | ||
| 260 | + .collect() | ||
| 261 | +} | ||
| 262 | + | ||
| 263 | +fn assert_section(body: &str, current: &str, hrefs: &[&str]) { | ||
| 264 | + let links = sidebar(body); | ||
| 265 | + assert_eq!(links[0].0, "/", "first entry is the way back"); | ||
| 266 | + for href in hrefs { | ||
| 267 | + assert!(links.iter().any(|(h, _)| h == href), "missing {href}"); | ||
| 268 | + } | ||
| 269 | + let marked: Vec<_> = links | ||
| 270 | + .iter() | ||
| 271 | + .filter(|(_, c)| c.as_deref() == Some("page")) | ||
| 272 | + .collect(); | ||
| 273 | + assert_eq!(marked.len(), 1, "exactly one current entry: {links:?}"); | ||
| 274 | + assert_eq!(marked[0].0, current); | ||
| 275 | + assert!(!body.contains("</a> · <a"), "no dot-separated link row"); | ||
| 276 | +} | ||
| 277 | + | ||
| 278 | +#[tokio::test] | ||
| 279 | +async fn admin_pages_get_the_admin_sidebar() { | ||
| 280 | + let env = start().await; | ||
| 281 | + let session = login(&env.http, "tahinli").await; | ||
| 282 | + let want = [ | ||
| 283 | + "/admin/users", | ||
| 284 | + "/admin/invites", | ||
| 285 | + "/admin/audit", | ||
| 286 | + "/admin/runners", | ||
| 287 | + "/admin/mail", | ||
| 288 | + "/admin/backups", | ||
| 289 | + "/admin/replication", | ||
| 290 | + ]; | ||
| 291 | + for path in want { | ||
| 292 | + let page = env.http.get(path, Some(&session)).await; | ||
| 293 | + assert_eq!(page.status, 200, "GET {path}"); | ||
| 294 | + assert_section(&page.body, path, &want); | ||
| 295 | + assert!( | ||
| 296 | + !sidebar(&page.body).iter().any(|(h, _)| h == "/explore"), | ||
| 297 | + "global links are swapped out" | ||
| 298 | + ); | ||
| 299 | + } | ||
| 300 | +} | ||
| 301 | + | ||
| 302 | +#[tokio::test] | ||
| 303 | +async fn settings_pages_get_the_settings_sidebar() { | ||
| 304 | + let env = start().await; | ||
| 305 | + let session = login(&env.http, "tahinli").await; | ||
| 306 | + let want = [ | ||
| 307 | + "/settings/profile", | ||
| 308 | + "/settings/keys", | ||
| 309 | + "/settings/gpg", | ||
| 310 | + "/settings/tokens", | ||
| 311 | + "/settings/sessions", | ||
| 312 | + "/settings/security", | ||
| 313 | + "/settings/notifications", | ||
| 314 | + "/settings/appearance", | ||
| 315 | + ]; | ||
| 316 | + for path in want { | ||
| 317 | + let page = env.http.get(path, Some(&session)).await; | ||
| 318 | + assert_eq!(page.status, 200, "GET {path}"); | ||
| 319 | + assert_section(&page.body, path, &want); | ||
| 320 | + } | ||
| 321 | +} | ||
crates/forge-web/tests/ui_prefs_e2e.rsmodified+74 -0
| @@ -781,3 +781,77 @@ async fn theme_button_cycles_for_anonymous_visitors_through_the_cookie() { | |||
| 781 | ) | 781 | ) |
| 782 | ); | 782 | ); |
| 783 | } | 783 | } |
| 784 | + | ||
| 785 | +#[tokio::test] | ||
| 786 | +async fn appearance_sidebar_side_saves_and_renders_on_html() { | ||
| 787 | + let env = start().await; | ||
| 788 | + let session = login(&env.http, "tahinli").await; | ||
| 789 | + | ||
| 790 | + let page = env.http.get("/settings/appearance", Some(&session)).await; | ||
| 791 | + assert_eq!( | ||
| 792 | + html_attr(&page.body, "data-sidebar").as_deref(), | ||
| 793 | + Some("left") | ||
| 794 | + ); | ||
| 795 | + assert_eq!( | ||
| 796 | + checked_radio(&page.body, "sidebar_side").as_deref(), | ||
| 797 | + Some("left") | ||
| 798 | + ); | ||
| 799 | + let csrf = input_value(&page.body, "csrf"); | ||
| 800 | + | ||
| 801 | + let saved = env | ||
| 802 | + .http | ||
| 803 | + .post_form( | ||
| 804 | + "/settings/appearance", | ||
| 805 | + &[ | ||
| 806 | + ("csrf", &csrf), | ||
| 807 | + ("theme", "light"), | ||
| 808 | + ("language", "en"), | ||
| 809 | + ("sidebar_side", "right"), | ||
| 810 | + ], | ||
| 811 | + Some(&session), | ||
| 812 | + ) | ||
| 813 | + .await; | ||
| 814 | + assert_eq!(saved.status, 303, "save: {}", saved.body); | ||
| 815 | + | ||
| 816 | + let page = env.http.get("/settings/appearance", Some(&session)).await; | ||
| 817 | + assert_eq!( | ||
| 818 | + html_attr(&page.body, "data-sidebar").as_deref(), | ||
| 819 | + Some("right") | ||
| 820 | + ); | ||
| 821 | + assert_eq!( | ||
| 822 | + checked_radio(&page.body, "sidebar_side").as_deref(), | ||
| 823 | + Some("right") | ||
| 824 | + ); | ||
| 825 | + | ||
| 826 | + // A save without the field keeps the side; a malformed side changes nothing. | ||
| 827 | + let saved = env | ||
| 828 | + .http | ||
| 829 | + .post_form( | ||
| 830 | + "/settings/appearance", | ||
| 831 | + &[("csrf", &csrf), ("theme", "light"), ("language", "en")], | ||
| 832 | + Some(&session), | ||
| 833 | + ) | ||
| 834 | + .await; | ||
| 835 | + assert_eq!(saved.status, 303, "save: {}", saved.body); | ||
| 836 | + for bad in ["", "top", "Right"] { | ||
| 837 | + let res = env | ||
| 838 | + .http | ||
| 839 | + .post_form( | ||
| 840 | + "/settings/appearance", | ||
| 841 | + &[ | ||
| 842 | + ("csrf", &csrf), | ||
| 843 | + ("theme", "light"), | ||
| 844 | + ("language", "en"), | ||
| 845 | + ("sidebar_side", bad), | ||
| 846 | + ], | ||
| 847 | + Some(&session), | ||
| 848 | + ) | ||
| 849 | + .await; | ||
| 850 | + assert_ne!(res.status, 303, "bad sidebar {bad:?} must not save"); | ||
| 851 | + } | ||
| 852 | + let page = env.http.get("/settings/appearance", Some(&session)).await; | ||
| 853 | + assert_eq!( | ||
| 854 | + html_attr(&page.body, "data-sidebar").as_deref(), | ||
| 855 | + Some("right") | ||
| 856 | + ); | ||
| 857 | +} | ||
docs/ci.mdmodified+4 -1
| @@ -14,7 +14,10 @@ supported as an option (`executor = "podman"`). | |||
| 14 | 14 | ||
| 15 | ## Format reference | 15 | ## Format reference |
| 16 | 16 | ||
| 17 | -The file is limited to 64 KiB. Unknown keys are an error at every level (`deny_unknown_fields`). | 17 | +The file is limited to 64 KiB. Parsing is forward-compatible: an unknown key at any level (top level, `[on]`, |
| 18 | +`[jobs.<name>]`, `[release]`) is ignored, not rejected, so a `ci.toml` that uses a newer feature still runs on an | ||
| 19 | +older forge. The run's jobs get a `[forge] warning: unknown key ...` line at the start of their logs. Known keys | ||
| 20 | +keep full validation: their types, globs, limits and other checks still make the file an error. | ||
| 18 | A file with a parse error still creates a run, in state `error`, with the message shown on the run | 21 | A file with a parse error still creates a run, in state `error`, with the message shown on the run |
| 19 | page and a `ci/config` status set to `error`. | 22 | page and a `ci/config` status set to `error`. |
| 20 | 23 | ||
style/_dashboard.scssmodified+1 -1
| @@ -165,7 +165,7 @@ | |||
| 165 | height: 28px; | 165 | height: 28px; |
| 166 | padding: 0 12px; | 166 | padding: 0 12px; |
| 167 | border: 1px solid var(--border); | 167 | border: 1px solid var(--border); |
| 168 | - border-radius: 999px; | 168 | + border-radius: var(--radius-full); |
| 169 | color: var(--text-2); | 169 | color: var(--text-2); |
| 170 | text-decoration: none; | 170 | text-decoration: none; |
| 171 | } | 171 | } |
style/_heatmap.scssmodified+1 -1
| @@ -17,7 +17,7 @@ $gap: 3px; | |||
| 17 | padding: 24px; | 17 | padding: 24px; |
| 18 | background: var(--surface); | 18 | background: var(--surface); |
| 19 | border: 1px solid var(--border); | 19 | border: 1px solid var(--border); |
| 20 | - border-radius: var(--radius); | 20 | + border-radius: var(--radius-lg); |
| 21 | min-width: 0; | 21 | min-width: 0; |
| 22 | 22 | ||
| 23 | h2 { | 23 | h2 { |
style/_pull.scssmodified+11 -11
| @@ -94,7 +94,7 @@ | |||
| 94 | 94 | ||
| 95 | code { | 95 | code { |
| 96 | padding: 1px 6px; | 96 | padding: 1px 6px; |
| 97 | - border-radius: 6px; | 97 | + border-radius: var(--radius-sm); |
| 98 | background: var(--surface-2); | 98 | background: var(--surface-2); |
| 99 | color: var(--text); | 99 | color: var(--text); |
| 100 | font-family: var(--mono); | 100 | font-family: var(--mono); |
| @@ -111,7 +111,7 @@ | |||
| 111 | height: 26px; | 111 | height: 26px; |
| 112 | padding: 0 11px; | 112 | padding: 0 11px; |
| 113 | border: 1px solid currentColor; | 113 | border: 1px solid currentColor; |
| 114 | - border-radius: 999px; | 114 | + border-radius: var(--radius-full); |
| 115 | background: var(--surface-2); | 115 | background: var(--surface-2); |
| 116 | font-size: 13.5px; | 116 | font-size: 13.5px; |
| 117 | font-weight: 600; | 117 | font-weight: 600; |
| @@ -148,7 +148,7 @@ | |||
| 148 | 148 | ||
| 149 | .issue-list { | 149 | .issue-list { |
| 150 | border-color: var(--border); | 150 | border-color: var(--border); |
| 151 | - border-radius: var(--radius); | 151 | + border-radius: var(--radius-lg); |
| 152 | background: var(--surface); | 152 | background: var(--surface); |
| 153 | box-shadow: none; | 153 | box-shadow: none; |
| 154 | } | 154 | } |
| @@ -257,7 +257,7 @@ | |||
| 257 | color: var(--text); | 257 | color: var(--text); |
| 258 | background: var(--surface); | 258 | background: var(--surface); |
| 259 | border: 1px solid var(--border-strong); | 259 | border: 1px solid var(--border-strong); |
| 260 | - border-radius: var(--radius); | 260 | + border-radius: var(--radius-md); |
| 261 | white-space: nowrap; | 261 | white-space: nowrap; |
| 262 | } | 262 | } |
| 263 | 263 | ||
| @@ -295,7 +295,7 @@ | |||
| 295 | .issue-item, | 295 | .issue-item, |
| 296 | .review-item { | 296 | .review-item { |
| 297 | border: 1px solid var(--border); | 297 | border: 1px solid var(--border); |
| 298 | - border-radius: var(--radius); | 298 | + border-radius: var(--radius-lg); |
| 299 | background: var(--surface); | 299 | background: var(--surface); |
| 300 | overflow: hidden; | 300 | overflow: hidden; |
| 301 | } | 301 | } |
| @@ -319,7 +319,7 @@ | |||
| 319 | padding: 18px 20px; | 319 | padding: 18px 20px; |
| 320 | border: 1px solid var(--border); | 320 | border: 1px solid var(--border); |
| 321 | border-left: 3px solid var(--border-strong); | 321 | border-left: 3px solid var(--border-strong); |
| 322 | - border-radius: var(--radius); | 322 | + border-radius: var(--radius-lg); |
| 323 | background: var(--surface); | 323 | background: var(--surface); |
| 324 | 324 | ||
| 325 | &.merge-ok { | 325 | &.merge-ok { |
| @@ -378,9 +378,9 @@ | |||
| 378 | 378 | ||
| 379 | .merge-box button[type="submit"] { | 379 | .merge-box button[type="submit"] { |
| 380 | width: 100%; | 380 | width: 100%; |
| 381 | - height: 38px; | 381 | + height: var(--control-h); |
| 382 | border: 1px solid var(--accent); | 382 | border: 1px solid var(--accent); |
| 383 | - border-radius: var(--radius); | 383 | + border-radius: var(--radius-md); |
| 384 | background: var(--accent); | 384 | background: var(--accent); |
| 385 | color: var(--accent-text); | 385 | color: var(--accent-text); |
| 386 | font-weight: 600; | 386 | font-weight: 600; |
| @@ -441,7 +441,7 @@ | |||
| 441 | max-width: 100%; | 441 | max-width: 100%; |
| 442 | margin: 0 0 24px; | 442 | margin: 0 0 24px; |
| 443 | border-color: var(--border); | 443 | border-color: var(--border); |
| 444 | - border-radius: var(--radius); | 444 | + border-radius: var(--radius-lg); |
| 445 | background: var(--surface); | 445 | background: var(--surface); |
| 446 | overflow: visible; | 446 | overflow: visible; |
| 447 | } | 447 | } |
| @@ -456,7 +456,7 @@ | |||
| 456 | flex-wrap: wrap; | 456 | flex-wrap: wrap; |
| 457 | gap: 6px 16px; | 457 | gap: 6px 16px; |
| 458 | padding: 10px 14px; | 458 | padding: 10px 14px; |
| 459 | - border-radius: var(--radius) var(--radius) 0 0; | 459 | + border-radius: var(--radius-lg) var(--radius-lg) 0 0; |
| 460 | background: var(--surface-2); | 460 | background: var(--surface-2); |
| 461 | font-size: 13.5px; | 461 | font-size: 13.5px; |
| 462 | } | 462 | } |
| @@ -478,7 +478,7 @@ | |||
| 478 | 478 | ||
| 479 | .diff-file-body { | 479 | .diff-file-body { |
| 480 | border: 0; | 480 | border: 0; |
| 481 | - border-radius: 0 0 var(--radius) var(--radius); | 481 | + border-radius: 0 0 var(--radius-lg) var(--radius-lg); |
| 482 | background: var(--surface); | 482 | background: var(--surface); |
| 483 | overflow-x: auto; | 483 | overflow-x: auto; |
| 484 | overflow-y: hidden; | 484 | overflow-y: hidden; |
style/_repo.scssmodified+11 -11
| @@ -25,7 +25,7 @@ | |||
| 25 | color: var(--muted); | 25 | color: var(--muted); |
| 26 | background: transparent; | 26 | background: transparent; |
| 27 | border: 1px solid var(--border-strong); | 27 | border: 1px solid var(--border-strong); |
| 28 | - border-radius: 999px; | 28 | + border-radius: var(--radius-full); |
| 29 | } | 29 | } |
| 30 | } | 30 | } |
| 31 | 31 | ||
| @@ -70,7 +70,7 @@ | |||
| 70 | color: var(--text); | 70 | color: var(--text); |
| 71 | background: var(--surface); | 71 | background: var(--surface); |
| 72 | border: 1px solid var(--border-strong); | 72 | border: 1px solid var(--border-strong); |
| 73 | - border-radius: var(--radius); | 73 | + border-radius: var(--radius-md); |
| 74 | cursor: pointer; | 74 | cursor: pointer; |
| 75 | 75 | ||
| 76 | &:hover { | 76 | &:hover { |
| @@ -112,7 +112,7 @@ | |||
| 112 | margin: 0 0 16px; | 112 | margin: 0 0 16px; |
| 113 | 113 | ||
| 114 | input { | 114 | input { |
| 115 | - height: 34px; | 115 | + height: var(--control-h); |
| 116 | max-width: 360px; | 116 | max-width: 360px; |
| 117 | font-size: 14px; | 117 | font-size: 14px; |
| 118 | } | 118 | } |
| @@ -133,7 +133,7 @@ | |||
| 133 | color: var(--text); | 133 | color: var(--text); |
| 134 | background: var(--surface); | 134 | background: var(--surface); |
| 135 | border: 1px solid var(--border-strong); | 135 | border: 1px solid var(--border-strong); |
| 136 | - border-radius: 999px; | 136 | + border-radius: var(--radius-full); |
| 137 | } | 137 | } |
| 138 | } | 138 | } |
| 139 | 139 | ||
| @@ -152,7 +152,7 @@ | |||
| 152 | display: inline-flex; | 152 | display: inline-flex; |
| 153 | align-items: center; | 153 | align-items: center; |
| 154 | gap: 8px; | 154 | gap: 8px; |
| 155 | - height: 32px; | 155 | + height: var(--control-h); |
| 156 | list-style: none; | 156 | list-style: none; |
| 157 | cursor: pointer; | 157 | cursor: pointer; |
| 158 | 158 | ||
| @@ -187,7 +187,7 @@ | |||
| 187 | padding: 18px; | 187 | padding: 18px; |
| 188 | background: var(--surface); | 188 | background: var(--surface); |
| 189 | border: 1px solid var(--border); | 189 | border: 1px solid var(--border); |
| 190 | - border-radius: var(--radius); | 190 | + border-radius: var(--radius-lg); |
| 191 | box-shadow: var(--shadow); | 191 | box-shadow: var(--shadow); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| @@ -204,14 +204,14 @@ | |||
| 204 | 204 | ||
| 205 | input { | 205 | input { |
| 206 | width: 100%; | 206 | width: 100%; |
| 207 | - height: 38px; | 207 | + height: var(--control-h); |
| 208 | padding: 0 12px; | 208 | padding: 0 12px; |
| 209 | font-family: var(--mono); | 209 | font-family: var(--mono); |
| 210 | font-size: 13px; | 210 | font-size: 13px; |
| 211 | color: var(--text); | 211 | color: var(--text); |
| 212 | background: var(--surface-2); | 212 | background: var(--surface-2); |
| 213 | border: 1px solid var(--border); | 213 | border: 1px solid var(--border); |
| 214 | - border-radius: var(--radius); | 214 | + border-radius: var(--radius-md); |
| 215 | 215 | ||
| 216 | &:focus-visible { | 216 | &:focus-visible { |
| 217 | outline: 2px solid var(--focus); | 217 | outline: 2px solid var(--focus); |
| @@ -494,7 +494,7 @@ | |||
| 494 | color: var(--accent-ink); | 494 | color: var(--accent-ink); |
| 495 | background: var(--surface-2); | 495 | background: var(--surface-2); |
| 496 | border: 1px solid var(--border); | 496 | border: 1px solid var(--border); |
| 497 | - border-radius: 999px; | 497 | + border-radius: var(--radius-full); |
| 498 | 498 | ||
| 499 | &:hover { | 499 | &:hover { |
| 500 | border-color: var(--accent); | 500 | border-color: var(--accent); |
| @@ -595,7 +595,7 @@ | |||
| 595 | min-width: 0; | 595 | min-width: 0; |
| 596 | background: var(--surface); | 596 | background: var(--surface); |
| 597 | border: 1px solid var(--border); | 597 | border: 1px solid var(--border); |
| 598 | - border-radius: 12px; | 598 | + border-radius: var(--radius-lg); |
| 599 | box-shadow: var(--shadow); | 599 | box-shadow: var(--shadow); |
| 600 | } | 600 | } |
| 601 | 601 | ||
| @@ -662,7 +662,7 @@ | |||
| 662 | font-weight: 500; | 662 | font-weight: 500; |
| 663 | font-size: 0.875rem; | 663 | font-size: 0.875rem; |
| 664 | color: var(--text-2); | 664 | color: var(--text-2); |
| 665 | - border-radius: 12px; | 665 | + border-radius: var(--radius-lg); |
| 666 | 666 | ||
| 667 | &::-webkit-details-marker { | 667 | &::-webkit-details-marker { |
| 668 | display: none; | 668 | display: none; |
style/_shell.scssmodified+28 -6
| @@ -88,7 +88,7 @@ | |||
| 88 | margin: 0; | 88 | margin: 0; |
| 89 | padding: 0 12px 0 36px; | 89 | padding: 0 12px 0 36px; |
| 90 | border: 1px solid var(--border); | 90 | border: 1px solid var(--border); |
| 91 | - border-radius: var(--radius); | 91 | + border-radius: var(--radius-md); |
| 92 | background: var(--surface); | 92 | background: var(--surface); |
| 93 | color: var(--text); | 93 | color: var(--text); |
| 94 | font: inherit; | 94 | font: inherit; |
| @@ -127,7 +127,7 @@ | |||
| 127 | margin: 0; | 127 | margin: 0; |
| 128 | padding: 0; | 128 | padding: 0; |
| 129 | border: 1px solid var(--border); | 129 | border: 1px solid var(--border); |
| 130 | - border-radius: var(--radius); | 130 | + border-radius: var(--radius-md); |
| 131 | background: var(--surface); | 131 | background: var(--surface); |
| 132 | color: var(--text-2); | 132 | color: var(--text-2); |
| 133 | font: inherit; | 133 | font: inherit; |
| @@ -232,7 +232,7 @@ | |||
| 232 | overflow-y: auto; | 232 | overflow-y: auto; |
| 233 | background: var(--surface); | 233 | background: var(--surface); |
| 234 | border: 1px solid var(--border); | 234 | border: 1px solid var(--border); |
| 235 | - border-radius: var(--radius); | 235 | + border-radius: var(--radius-lg); |
| 236 | box-shadow: var(--shadow); | 236 | box-shadow: var(--shadow); |
| 237 | } | 237 | } |
| 238 | 238 | ||
| @@ -260,7 +260,7 @@ | |||
| 260 | gap: 10px; | 260 | gap: 10px; |
| 261 | min-height: 36px; | 261 | min-height: 36px; |
| 262 | padding: 0 12px; | 262 | padding: 0 12px; |
| 263 | - border-radius: var(--radius); | 263 | + border-radius: var(--radius-md); |
| 264 | color: var(--text-2); | 264 | color: var(--text-2); |
| 265 | font-size: 14.5px; | 265 | font-size: 14.5px; |
| 266 | font-weight: 500; | 266 | font-weight: 500; |
| @@ -324,7 +324,7 @@ | |||
| 324 | min-height: 32px; | 324 | min-height: 32px; |
| 325 | padding: 0 12px; | 325 | padding: 0 12px; |
| 326 | overflow: hidden; | 326 | overflow: hidden; |
| 327 | - border-radius: var(--radius); | 327 | + border-radius: var(--radius-md); |
| 328 | font-family: var(--mono); | 328 | font-family: var(--mono); |
| 329 | font-size: 13.5px; | 329 | font-size: 13.5px; |
| 330 | color: var(--text-2); | 330 | color: var(--text-2); |
| @@ -455,7 +455,7 @@ | |||
| 455 | gap: 8px; | 455 | gap: 8px; |
| 456 | min-height: 36px; | 456 | min-height: 36px; |
| 457 | padding: 0 12px; | 457 | padding: 0 12px; |
| 458 | - border-radius: var(--radius); | 458 | + border-radius: var(--radius-md); |
| 459 | box-shadow: none; | 459 | box-shadow: none; |
| 460 | color: var(--text-2); | 460 | color: var(--text-2); |
| 461 | font-size: 14.5px; | 461 | font-size: 14.5px; |
| @@ -484,6 +484,28 @@ | |||
| 484 | } | 484 | } |
| 485 | } | 485 | } |
| 486 | 486 | ||
| 487 | +// Sidebar on the right (the user's preference, set on <html> as data-sidebar). The sidebar takes the | ||
| 488 | +// second column and its border moves to its inner edge. A repo's tabs follow it. Below 900px the | ||
| 489 | +// sidebar is hidden either way, so the phone layout and the nav toggle are unchanged. | ||
| 490 | +@media (min-width: 900px) { | ||
| 491 | + html[data-sidebar="right"] .shell:has(> .shell-sidebar) { | ||
| 492 | + grid-template-columns: minmax(0, 1fr) var(--sidebar-w); | ||
| 493 | + } | ||
| 494 | + | ||
| 495 | + html[data-sidebar="right"] .shell > .shell-sidebar { | ||
| 496 | + order: 2; | ||
| 497 | + border-right: 0; | ||
| 498 | + border-left: 1px solid var(--border); | ||
| 499 | + } | ||
| 500 | + | ||
| 501 | + html[data-sidebar="right"] .shell:has(> .shell-sidebar) .repo-tabs { | ||
| 502 | + left: auto; | ||
| 503 | + right: 0; | ||
| 504 | + border-right: 0; | ||
| 505 | + border-left: 1px solid var(--border); | ||
| 506 | + } | ||
| 507 | +} | ||
| 508 | + | ||
| 487 | // Soft navigation: a thin progress line along the top while a page is being fetched in place | 509 | // Soft navigation: a thin progress line along the top while a page is being fetched in place |
| 488 | // (nav.js sets aria-busy on <html>). Decorative; the page stays usable underneath. | 510 | // (nav.js sets aria-busy on <html>). Decorative; the page stays usable underneath. |
| 489 | html[aria-busy="true"] body::before { | 511 | html[aria-busy="true"] body::before { |
style/main.scssmodified+142 -80
| @@ -86,7 +86,13 @@ | |||
| 86 | --important: #6A4BB0; | 86 | --important: #6A4BB0; |
| 87 | --warning: #9A6200; | 87 | --warning: #9A6200; |
| 88 | --shadow: 0 10px 28px rgba(30, 36, 32, .10); | 88 | --shadow: 0 10px 28px rgba(30, 36, 32, .10); |
| 89 | - --radius: 10px; | 89 | + // Radius scale: sm chips/badges, md every control (buttons, inputs, selects, textareas), |
| 90 | + // lg cards and panels, full pills. Nested shapes never exceed their container. | ||
| 91 | + --radius-sm: 6px; | ||
| 92 | + --radius-md: 8px; | ||
| 93 | + --radius-lg: 12px; | ||
| 94 | + --radius-full: 999px; | ||
| 95 | + --control-h: 36px; | ||
| 90 | --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif; | 96 | --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif; |
| 91 | --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; | 97 | --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; |
| 92 | --topbar-h: 52px; | 98 | --topbar-h: 52px; |
| @@ -180,7 +186,7 @@ a { | |||
| 180 | :focus-visible { | 186 | :focus-visible { |
| 181 | outline: 2px solid var(--focus); | 187 | outline: 2px solid var(--focus); |
| 182 | outline-offset: 2px; | 188 | outline-offset: 2px; |
| 183 | - border-radius: 6px; | 189 | + border-radius: var(--radius-sm); |
| 184 | } | 190 | } |
| 185 | 191 | ||
| 186 | // <main tabindex="-1"> only takes focus from nav.js after a soft navigation, so screen readers | 192 | // <main tabindex="-1"> only takes focus from nav.js after a soft navigation, so screen readers |
| @@ -242,7 +248,7 @@ pre { | |||
| 242 | list-style: none; | 248 | list-style: none; |
| 243 | padding: 6px 10px; | 249 | padding: 6px 10px; |
| 244 | border: 1px solid var(--border); | 250 | border: 1px solid var(--border); |
| 245 | - border-radius: var(--radius); | 251 | + border-radius: var(--radius-md); |
| 246 | 252 | ||
| 247 | &::-webkit-details-marker { | 253 | &::-webkit-details-marker { |
| 248 | display: none; | 254 | display: none; |
| @@ -264,7 +270,7 @@ pre { | |||
| 264 | list-style: none; | 270 | list-style: none; |
| 265 | background: var(--surface); | 271 | background: var(--surface); |
| 266 | border: 1px solid var(--border); | 272 | border: 1px solid var(--border); |
| 267 | - border-radius: var(--radius); | 273 | + border-radius: var(--radius-lg); |
| 268 | box-shadow: var(--shadow); | 274 | box-shadow: var(--shadow); |
| 269 | z-index: 10; | 275 | z-index: 10; |
| 270 | 276 | ||
| @@ -328,7 +334,7 @@ main { | |||
| 328 | .card { | 334 | .card { |
| 329 | background: var(--surface); | 335 | background: var(--surface); |
| 330 | border: 1px solid var(--border); | 336 | border: 1px solid var(--border); |
| 331 | - border-radius: var(--radius); | 337 | + border-radius: var(--radius-lg); |
| 332 | padding: 20px; | 338 | padding: 20px; |
| 333 | margin-bottom: 16px; | 339 | margin-bottom: 16px; |
| 334 | 340 | ||
| @@ -352,13 +358,14 @@ button { | |||
| 352 | align-self: flex-start; // keep natural width inside flex columns (.stack, cards) | 358 | align-self: flex-start; // keep natural width inside flex columns (.stack, cards) |
| 353 | align-items: center; | 359 | align-items: center; |
| 354 | gap: 8px; | 360 | gap: 8px; |
| 355 | - height: 34px; | 361 | + height: var(--control-h); |
| 362 | + box-sizing: border-box; | ||
| 356 | padding: 0 14px; | 363 | padding: 0 14px; |
| 357 | font: inherit; | 364 | font: inherit; |
| 358 | font-size: 0.875rem; | 365 | font-size: 0.875rem; |
| 359 | font-weight: 500; | 366 | font-weight: 500; |
| 360 | white-space: nowrap; | 367 | white-space: nowrap; |
| 361 | - border-radius: var(--radius); | 368 | + border-radius: var(--radius-md); |
| 362 | border: 1px solid var(--border-strong); | 369 | border: 1px solid var(--border-strong); |
| 363 | background: var(--surface); | 370 | background: var(--surface); |
| 364 | color: var(--text); | 371 | color: var(--text); |
| @@ -455,10 +462,13 @@ textarea { | |||
| 455 | color: var(--text); | 462 | color: var(--text); |
| 456 | background: var(--surface); | 463 | background: var(--surface); |
| 457 | border: 1px solid var(--border-strong); | 464 | border: 1px solid var(--border-strong); |
| 458 | - border-radius: var(--radius); | 465 | + border-radius: var(--radius-md); |
| 459 | - padding: 8px 12px; | 466 | + height: var(--control-h); |
| 467 | + box-sizing: border-box; | ||
| 468 | + padding: 0 12px; | ||
| 460 | width: 100%; | 469 | width: 100%; |
| 461 | max-width: 100%; | 470 | max-width: 100%; |
| 471 | + line-height: 1.25rem; | ||
| 462 | 472 | ||
| 463 | &::placeholder { | 473 | &::placeholder { |
| 464 | color: var(--muted); | 474 | color: var(--muted); |
| @@ -488,6 +498,22 @@ input[type="checkbox"] { | |||
| 488 | 498 | ||
| 489 | // Native dropdown lists take their colours from the option rule where the browser honours it; | 499 | // Native dropdown lists take their colours from the option rule where the browser honours it; |
| 490 | // color-scheme (set on :root above) covers the rest. | 500 | // color-scheme (set on :root above) covers the rest. |
| 501 | +// One box for every select: same height, padding and font wherever it sits. | ||
| 502 | +select { | ||
| 503 | + box-sizing: border-box; | ||
| 504 | + height: var(--control-h); | ||
| 505 | + min-height: var(--control-h); | ||
| 506 | + padding: 0 12px; | ||
| 507 | + font-size: 1rem; | ||
| 508 | + line-height: 1.25rem; | ||
| 509 | +} | ||
| 510 | + | ||
| 511 | +select[multiple], | ||
| 512 | +select[size]:not([size="1"]) { | ||
| 513 | + height: auto; | ||
| 514 | + padding: 6px 12px; | ||
| 515 | +} | ||
| 516 | + | ||
| 491 | select option, | 517 | select option, |
| 492 | select optgroup { | 518 | select optgroup { |
| 493 | background: var(--surface); | 519 | background: var(--surface); |
| @@ -515,7 +541,7 @@ select optgroup { | |||
| 515 | select:not([multiple]):not([size])::picker(select) { | 541 | select:not([multiple]):not([size])::picker(select) { |
| 516 | background: var(--surface); | 542 | background: var(--surface); |
| 517 | border: 1px solid var(--border); | 543 | border: 1px solid var(--border); |
| 518 | - border-radius: var(--radius); | 544 | + border-radius: var(--radius-md); |
| 519 | box-shadow: var(--shadow); | 545 | box-shadow: var(--shadow); |
| 520 | padding: 4px; | 546 | padding: 4px; |
| 521 | margin-top: 4px; | 547 | margin-top: 4px; |
| @@ -526,7 +552,7 @@ select optgroup { | |||
| 526 | 552 | ||
| 527 | select:not([multiple]):not([size]) option { | 553 | select:not([multiple]):not([size]) option { |
| 528 | padding: 7px 10px; | 554 | padding: 7px 10px; |
| 529 | - border-radius: 6px; | 555 | + border-radius: var(--radius-sm); |
| 530 | color: var(--text); | 556 | color: var(--text); |
| 531 | background: transparent; | 557 | background: transparent; |
| 532 | font: inherit; | 558 | font: inherit; |
| @@ -558,6 +584,7 @@ input[type="file"] { | |||
| 558 | width: auto; | 584 | width: auto; |
| 559 | max-width: 100%; | 585 | max-width: 100%; |
| 560 | padding: 0; | 586 | padding: 0; |
| 587 | + height: auto; | ||
| 561 | border: 0; | 588 | border: 0; |
| 562 | border-radius: 0; | 589 | border-radius: 0; |
| 563 | background: transparent; | 590 | background: transparent; |
| @@ -571,11 +598,11 @@ input[type="file"]::-webkit-file-upload-button { | |||
| 571 | font: inherit; | 598 | font: inherit; |
| 572 | font-size: 0.875rem; | 599 | font-size: 0.875rem; |
| 573 | font-weight: 500; | 600 | font-weight: 500; |
| 574 | - height: 34px; | 601 | + height: calc(var(--control-h) - 4px); |
| 575 | padding: 0 14px; | 602 | padding: 0 14px; |
| 576 | margin-right: 10px; | 603 | margin-right: 10px; |
| 577 | border: 1px solid var(--border-strong); | 604 | border: 1px solid var(--border-strong); |
| 578 | - border-radius: var(--radius); | 605 | + border-radius: var(--radius-md); |
| 579 | background: var(--surface-2); | 606 | background: var(--surface-2); |
| 580 | color: var(--text); | 607 | color: var(--text); |
| 581 | cursor: pointer; | 608 | cursor: pointer; |
| @@ -586,6 +613,9 @@ input[type="file"]::-webkit-file-upload-button { | |||
| 586 | } | 613 | } |
| 587 | 614 | ||
| 588 | textarea { | 615 | textarea { |
| 616 | + height: auto; | ||
| 617 | + min-height: calc(var(--control-h) * 2); | ||
| 618 | + padding: 8px 12px; | ||
| 589 | font-family: var(--mono); | 619 | font-family: var(--mono); |
| 590 | font-size: 0.875rem; | 620 | font-size: 0.875rem; |
| 591 | resize: vertical; | 621 | resize: vertical; |
| @@ -593,7 +623,7 @@ textarea { | |||
| 593 | 623 | ||
| 594 | fieldset { | 624 | fieldset { |
| 595 | border: 1px solid var(--border); | 625 | border: 1px solid var(--border); |
| 596 | - border-radius: var(--radius); | 626 | + border-radius: var(--radius-lg); |
| 597 | padding: 12px 14px; | 627 | padding: 12px 14px; |
| 598 | margin: 0; | 628 | margin: 0; |
| 599 | display: flex; | 629 | display: flex; |
| @@ -615,7 +645,7 @@ fieldset { | |||
| 615 | color: var(--alert-text); | 645 | color: var(--alert-text); |
| 616 | border: 1px solid var(--bad); | 646 | border: 1px solid var(--bad); |
| 617 | padding: 10px 14px; | 647 | padding: 10px 14px; |
| 618 | - border-radius: var(--radius); | 648 | + border-radius: var(--radius-lg); |
| 619 | margin: 0 0 12px; | 649 | margin: 0 0 12px; |
| 620 | } | 650 | } |
| 621 | 651 | ||
| @@ -624,7 +654,7 @@ fieldset { | |||
| 624 | pre.code { | 654 | pre.code { |
| 625 | background: var(--code-bg); | 655 | background: var(--code-bg); |
| 626 | border: 1px solid var(--border); | 656 | border: 1px solid var(--border); |
| 627 | - border-radius: var(--radius); | 657 | + border-radius: var(--radius-lg); |
| 628 | padding: 12px; | 658 | padding: 12px; |
| 629 | margin: 6px 0 14px; | 659 | margin: 6px 0 14px; |
| 630 | overflow-x: auto; | 660 | overflow-x: auto; |
| @@ -653,7 +683,7 @@ code { | |||
| 653 | white-space: nowrap; | 683 | white-space: nowrap; |
| 654 | border: 1px solid transparent; | 684 | border: 1px solid transparent; |
| 655 | padding: 0 9px; | 685 | padding: 0 9px; |
| 656 | - border-radius: 999px; | 686 | + border-radius: var(--radius-full); |
| 657 | margin-left: 6px; | 687 | margin-left: 6px; |
| 658 | vertical-align: middle; | 688 | vertical-align: middle; |
| 659 | 689 | ||
| @@ -903,7 +933,7 @@ code { | |||
| 903 | gap: 6px; | 933 | gap: 6px; |
| 904 | padding: 5px 10px; | 934 | padding: 5px 10px; |
| 905 | border: 1px solid var(--border); | 935 | border: 1px solid var(--border); |
| 906 | - border-radius: var(--radius); | 936 | + border-radius: var(--radius-md); |
| 907 | background: var(--surface); | 937 | background: var(--surface); |
| 908 | 938 | ||
| 909 | &::-webkit-details-marker { | 939 | &::-webkit-details-marker { |
| @@ -932,7 +962,7 @@ code { | |||
| 932 | padding: 8px 0; | 962 | padding: 8px 0; |
| 933 | background: var(--surface); | 963 | background: var(--surface); |
| 934 | border: 1px solid var(--border); | 964 | border: 1px solid var(--border); |
| 935 | - border-radius: var(--radius); | 965 | + border-radius: var(--radius-lg); |
| 936 | box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); | 966 | box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); |
| 937 | } | 967 | } |
| 938 | 968 | ||
| @@ -1107,7 +1137,7 @@ code { | |||
| 1107 | .commit-oid { | 1137 | .commit-oid { |
| 1108 | padding: 2px 8px; | 1138 | padding: 2px 8px; |
| 1109 | border: 1px solid var(--border); | 1139 | border: 1px solid var(--border); |
| 1110 | - border-radius: 999px; | 1140 | + border-radius: var(--radius-full); |
| 1111 | background: var(--code-bg); | 1141 | background: var(--code-bg); |
| 1112 | color: var(--text); | 1142 | color: var(--text); |
| 1113 | font-size: 0.8125rem; | 1143 | font-size: 0.8125rem; |
| @@ -1264,7 +1294,7 @@ code { | |||
| 1264 | overflow-x: auto; | 1294 | overflow-x: auto; |
| 1265 | background: var(--code-bg); | 1295 | background: var(--code-bg); |
| 1266 | border: 1px solid var(--border); | 1296 | border: 1px solid var(--border); |
| 1267 | - border-radius: var(--radius); | 1297 | + border-radius: var(--radius-lg); |
| 1268 | line-height: 1.45; | 1298 | line-height: 1.45; |
| 1269 | 1299 | ||
| 1270 | code { | 1300 | code { |
| @@ -1297,7 +1327,7 @@ code { | |||
| 1297 | 1327 | ||
| 1298 | details { | 1328 | details { |
| 1299 | border: 1px solid var(--border); | 1329 | border: 1px solid var(--border); |
| 1300 | - border-radius: var(--radius); | 1330 | + border-radius: var(--radius-lg); |
| 1301 | padding: 8px 12px; | 1331 | padding: 8px 12px; |
| 1302 | 1332 | ||
| 1303 | summary { | 1333 | summary { |
| @@ -1311,7 +1341,7 @@ code { | |||
| 1311 | margin: 0 0 1em; | 1341 | margin: 0 0 1em; |
| 1312 | color: var(--text); | 1342 | color: var(--text); |
| 1313 | border-left: 0.25em solid var(--alert-accent, var(--border)); | 1343 | border-left: 0.25em solid var(--alert-accent, var(--border)); |
| 1314 | - border-radius: 0 var(--radius) var(--radius) 0; | 1344 | + border-radius: 0 var(--radius-lg) var(--radius-lg) 0; |
| 1315 | background: var(--surface); | 1345 | background: var(--surface); |
| 1316 | 1346 | ||
| 1317 | > :last-child { | 1347 | > :last-child { |
| @@ -1365,7 +1395,7 @@ code { | |||
| 1365 | background: var(--surface); | 1395 | background: var(--surface); |
| 1366 | border: 1px solid var(--border); | 1396 | border: 1px solid var(--border); |
| 1367 | border-bottom: 0; | 1397 | border-bottom: 0; |
| 1368 | - border-radius: var(--radius) var(--radius) 0 0; | 1398 | + border-radius: var(--radius-lg) var(--radius-lg) 0 0; |
| 1369 | } | 1399 | } |
| 1370 | 1400 | ||
| 1371 | .file-actions { | 1401 | .file-actions { |
| @@ -1383,7 +1413,7 @@ code { | |||
| 1383 | -webkit-overflow-scrolling: touch; | 1413 | -webkit-overflow-scrolling: touch; |
| 1384 | background: var(--code-bg); | 1414 | background: var(--code-bg); |
| 1385 | border: 1px solid var(--border); | 1415 | border: 1px solid var(--border); |
| 1386 | - border-radius: 0 0 var(--radius) var(--radius); | 1416 | + border-radius: 0 0 var(--radius-lg) var(--radius-lg); |
| 1387 | } | 1417 | } |
| 1388 | 1418 | ||
| 1389 | .file-table, | 1419 | .file-table, |
| @@ -1444,7 +1474,7 @@ code { | |||
| 1444 | padding: 16px; | 1474 | padding: 16px; |
| 1445 | background: var(--code-bg); | 1475 | background: var(--code-bg); |
| 1446 | border: 1px solid var(--border); | 1476 | border: 1px solid var(--border); |
| 1447 | - border-radius: 0 0 var(--radius) var(--radius); | 1477 | + border-radius: 0 0 var(--radius-lg) var(--radius-lg); |
| 1448 | overflow: auto; | 1478 | overflow: auto; |
| 1449 | 1479 | ||
| 1450 | img { | 1480 | img { |
| @@ -1457,7 +1487,7 @@ code { | |||
| 1457 | margin: 12px 0; | 1487 | margin: 12px 0; |
| 1458 | padding: 10px 12px; | 1488 | padding: 10px 12px; |
| 1459 | border: 1px solid var(--border); | 1489 | border: 1px solid var(--border); |
| 1460 | - border-radius: var(--radius); | 1490 | + border-radius: var(--radius-lg); |
| 1461 | background: var(--surface); | 1491 | background: var(--surface); |
| 1462 | color: var(--muted); | 1492 | color: var(--muted); |
| 1463 | overflow-wrap: anywhere; | 1493 | overflow-wrap: anywhere; |
| @@ -1475,7 +1505,7 @@ code { | |||
| 1475 | min-width: 0; | 1505 | min-width: 0; |
| 1476 | margin: 0 0 16px; | 1506 | margin: 0 0 16px; |
| 1477 | border: 1px solid var(--border); | 1507 | border: 1px solid var(--border); |
| 1478 | - border-radius: var(--radius); | 1508 | + border-radius: var(--radius-lg); |
| 1479 | background: var(--surface); | 1509 | background: var(--surface); |
| 1480 | overflow: hidden; | 1510 | overflow: hidden; |
| 1481 | } | 1511 | } |
| @@ -1638,7 +1668,7 @@ code { | |||
| 1638 | padding: 16px 20px; | 1668 | padding: 16px 20px; |
| 1639 | background: var(--surface); | 1669 | background: var(--surface); |
| 1640 | border: 1px solid var(--border); | 1670 | border: 1px solid var(--border); |
| 1641 | - border-radius: var(--radius); | 1671 | + border-radius: var(--radius-lg); |
| 1642 | overflow-wrap: anywhere; | 1672 | overflow-wrap: anywhere; |
| 1643 | } | 1673 | } |
| 1644 | 1674 | ||
| @@ -1729,7 +1759,7 @@ code { | |||
| 1729 | padding: 14px 16px; | 1759 | padding: 14px 16px; |
| 1730 | background: var(--surface); | 1760 | background: var(--surface); |
| 1731 | border: 1px solid var(--border); | 1761 | border: 1px solid var(--border); |
| 1732 | - border-radius: var(--radius); | 1762 | + border-radius: var(--radius-lg); |
| 1733 | overflow-wrap: anywhere; | 1763 | overflow-wrap: anywhere; |
| 1734 | 1764 | ||
| 1735 | p { | 1765 | p { |
| @@ -1820,7 +1850,7 @@ code { | |||
| 1820 | } | 1850 | } |
| 1821 | 1851 | ||
| 1822 | .settings-layout select { | 1852 | .settings-layout select { |
| 1823 | - max-width: 24rem; | 1853 | + max-width: none; |
| 1824 | } | 1854 | } |
| 1825 | 1855 | ||
| 1826 | // Colour pickers (appearance settings). Each choice is a native radio, so the keyboard and screen | 1856 | // Colour pickers (appearance settings). Each choice is a native radio, so the keyboard and screen |
| @@ -1834,14 +1864,38 @@ code { | |||
| 1834 | } | 1864 | } |
| 1835 | 1865 | ||
| 1836 | .appearance-top { | 1866 | .appearance-top { |
| 1837 | - display: flex; | 1867 | + display: grid; |
| 1838 | - flex-wrap: wrap; | 1868 | + grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); |
| 1869 | + align-items: start; | ||
| 1839 | gap: 16px 24px; | 1870 | gap: 16px 24px; |
| 1840 | 1871 | ||
| 1841 | - label { | 1872 | + > label, |
| 1873 | + > fieldset { | ||
| 1842 | display: grid; | 1874 | display: grid; |
| 1843 | gap: 4px; | 1875 | gap: 4px; |
| 1844 | min-width: 0; | 1876 | min-width: 0; |
| 1877 | + // Helper text sits in a row of its own below, so it never moves the control. | ||
| 1878 | + align-content: start; | ||
| 1879 | + } | ||
| 1880 | +} | ||
| 1881 | + | ||
| 1882 | +// The sidebar side (appearance settings): a segmented toggle, styled like the snippet switch. | ||
| 1883 | +.side-picker { | ||
| 1884 | + border: 0; | ||
| 1885 | + padding: 0; | ||
| 1886 | + margin: 0; | ||
| 1887 | + justify-items: start; | ||
| 1888 | + | ||
| 1889 | + legend { | ||
| 1890 | + padding: 0; | ||
| 1891 | + margin-bottom: 4px; | ||
| 1892 | + font-weight: 500; | ||
| 1893 | + font-size: 0.875rem; | ||
| 1894 | + color: var(--text-2); | ||
| 1895 | + } | ||
| 1896 | + | ||
| 1897 | + .segmented { | ||
| 1898 | + min-height: 2.5rem; | ||
| 1845 | } | 1899 | } |
| 1846 | } | 1900 | } |
| 1847 | 1901 | ||
| @@ -1993,7 +2047,7 @@ code { | |||
| 1993 | .label-chip { | 2047 | .label-chip { |
| 1994 | display: inline-block; | 2048 | display: inline-block; |
| 1995 | padding: 2px 10px; | 2049 | padding: 2px 10px; |
| 1996 | - border-radius: 999px; | 2050 | + border-radius: var(--radius-full); |
| 1997 | font-size: 0.8125rem; | 2051 | font-size: 0.8125rem; |
| 1998 | font-weight: 600; | 2052 | font-weight: 600; |
| 1999 | text-decoration: none; | 2053 | text-decoration: none; |
| @@ -2092,7 +2146,7 @@ code { | |||
| 2092 | .mail-filters .subnav-link { | 2146 | .mail-filters .subnav-link { |
| 2093 | padding: 4px 10px; | 2147 | padding: 4px 10px; |
| 2094 | border: 1px solid var(--border); | 2148 | border: 1px solid var(--border); |
| 2095 | - border-radius: 999px; | 2149 | + border-radius: var(--radius-full); |
| 2096 | } | 2150 | } |
| 2097 | 2151 | ||
| 2098 | .mail-filters .subnav-link.current { | 2152 | .mail-filters .subnav-link.current { |
| @@ -2112,7 +2166,7 @@ code { | |||
| 2112 | display: inline-block; | 2166 | display: inline-block; |
| 2113 | min-width: 1.6em; | 2167 | min-width: 1.6em; |
| 2114 | padding: 0 0.4em; | 2168 | padding: 0 0.4em; |
| 2115 | - border-radius: 999px; | 2169 | + border-radius: var(--radius-full); |
| 2116 | background: var(--code-bg); | 2170 | background: var(--code-bg); |
| 2117 | color: var(--muted); | 2171 | color: var(--muted); |
| 2118 | font-size: 0.85em; | 2172 | font-size: 0.85em; |
| @@ -2134,7 +2188,7 @@ code { | |||
| 2134 | 2188 | ||
| 2135 | a { | 2189 | a { |
| 2136 | padding: 0.35rem 0.75rem; | 2190 | padding: 0.35rem 0.75rem; |
| 2137 | - border-radius: var(--radius); | 2191 | + border-radius: var(--radius-md); |
| 2138 | color: var(--muted); | 2192 | color: var(--muted); |
| 2139 | text-decoration: none; | 2193 | text-decoration: none; |
| 2140 | 2194 | ||
| @@ -2173,7 +2227,7 @@ code { | |||
| 2173 | margin: 0; | 2227 | margin: 0; |
| 2174 | padding: 0; | 2228 | padding: 0; |
| 2175 | border: 1px solid var(--border); | 2229 | border: 1px solid var(--border); |
| 2176 | - border-radius: var(--radius); | 2230 | + border-radius: var(--radius-lg); |
| 2177 | overflow: hidden; | 2231 | overflow: hidden; |
| 2178 | } | 2232 | } |
| 2179 | 2233 | ||
| @@ -2237,7 +2291,7 @@ code { | |||
| 2237 | gap: 0.35rem; | 2291 | gap: 0.35rem; |
| 2238 | padding: 0.75rem 1rem; | 2292 | padding: 0.75rem 1rem; |
| 2239 | border: 1px solid var(--border); | 2293 | border: 1px solid var(--border); |
| 2240 | - border-radius: var(--radius); | 2294 | + border-radius: var(--radius-lg); |
| 2241 | background: var(--surface); | 2295 | background: var(--surface); |
| 2242 | 2296 | ||
| 2243 | .pinned-title { | 2297 | .pinned-title { |
| @@ -2285,7 +2339,7 @@ code { | |||
| 2285 | .label-chip { | 2339 | .label-chip { |
| 2286 | display: inline-block; | 2340 | display: inline-block; |
| 2287 | padding: 0 0.6rem; | 2341 | padding: 0 0.6rem; |
| 2288 | - border-radius: 999px; | 2342 | + border-radius: var(--radius-full); |
| 2289 | font-size: 0.8rem; | 2343 | font-size: 0.8rem; |
| 2290 | font-weight: 600; | 2344 | font-weight: 600; |
| 2291 | line-height: 1.6; | 2345 | line-height: 1.6; |
| @@ -2329,7 +2383,7 @@ code { | |||
| 2329 | .issue-badge { | 2383 | .issue-badge { |
| 2330 | display: inline-block; | 2384 | display: inline-block; |
| 2331 | padding: 2px 10px; | 2385 | padding: 2px 10px; |
| 2332 | - border-radius: 999px; | 2386 | + border-radius: var(--radius-full); |
| 2333 | font-size: 0.85rem; | 2387 | font-size: 0.85rem; |
| 2334 | font-weight: 600; | 2388 | font-weight: 600; |
| 2335 | 2389 | ||
| @@ -2379,7 +2433,7 @@ code { | |||
| 2379 | .issue-item { | 2433 | .issue-item { |
| 2380 | min-width: 0; | 2434 | min-width: 0; |
| 2381 | border: 1px solid var(--border); | 2435 | border: 1px solid var(--border); |
| 2382 | - border-radius: var(--radius); | 2436 | + border-radius: var(--radius-lg); |
| 2383 | background: var(--surface); | 2437 | background: var(--surface); |
| 2384 | overflow: hidden; | 2438 | overflow: hidden; |
| 2385 | } | 2439 | } |
| @@ -2430,7 +2484,7 @@ code { | |||
| 2430 | gap: 0.3rem; | 2484 | gap: 0.3rem; |
| 2431 | padding: 0.15rem 0.5rem; | 2485 | padding: 0.15rem 0.5rem; |
| 2432 | border: 1px solid var(--border); | 2486 | border: 1px solid var(--border); |
| 2433 | - border-radius: 999px; | 2487 | + border-radius: var(--radius-full); |
| 2434 | background: var(--surface); | 2488 | background: var(--surface); |
| 2435 | color: var(--text); | 2489 | color: var(--text); |
| 2436 | font: inherit; | 2490 | font: inherit; |
| @@ -2464,7 +2518,7 @@ span.reaction { | |||
| 2464 | list-style: none; | 2518 | list-style: none; |
| 2465 | padding: 0.15rem 0.5rem; | 2519 | padding: 0.15rem 0.5rem; |
| 2466 | border: 1px dashed var(--border); | 2520 | border: 1px dashed var(--border); |
| 2467 | - border-radius: 999px; | 2521 | + border-radius: var(--radius-full); |
| 2468 | color: var(--muted); | 2522 | color: var(--muted); |
| 2469 | font-size: 0.85rem; | 2523 | font-size: 0.85rem; |
| 2470 | cursor: pointer; | 2524 | cursor: pointer; |
| @@ -2623,7 +2677,7 @@ span.reaction { | |||
| 2623 | gap: 0.75rem; | 2677 | gap: 0.75rem; |
| 2624 | padding: 1rem 1.25rem; | 2678 | padding: 1rem 1.25rem; |
| 2625 | border: 1px solid var(--border); | 2679 | border: 1px solid var(--border); |
| 2626 | - border-radius: var(--radius); | 2680 | + border-radius: var(--radius-lg); |
| 2627 | background: var(--surface); | 2681 | background: var(--surface); |
| 2628 | 2682 | ||
| 2629 | &.merge-ok { | 2683 | &.merge-ok { |
| @@ -2736,7 +2790,7 @@ span.reaction { | |||
| 2736 | 2790 | ||
| 2737 | .review-thread { | 2791 | .review-thread { |
| 2738 | border: 1px solid var(--border); | 2792 | border: 1px solid var(--border); |
| 2739 | - border-radius: var(--radius); | 2793 | + border-radius: var(--radius-lg); |
| 2740 | background: var(--surface); | 2794 | background: var(--surface); |
| 2741 | overflow: hidden; | 2795 | overflow: hidden; |
| 2742 | 2796 | ||
| @@ -2824,7 +2878,7 @@ span.reaction { | |||
| 2824 | .review-badge { | 2878 | .review-badge { |
| 2825 | display: inline-block; | 2879 | display: inline-block; |
| 2826 | padding: 0 8px; | 2880 | padding: 0 8px; |
| 2827 | - border-radius: 999px; | 2881 | + border-radius: var(--radius-full); |
| 2828 | font-size: 0.75rem; | 2882 | font-size: 0.75rem; |
| 2829 | font-weight: 600; | 2883 | font-weight: 600; |
| 2830 | line-height: 20px; | 2884 | line-height: 20px; |
| @@ -2874,7 +2928,7 @@ span.reaction { | |||
| 2874 | .review-inline-form { | 2928 | .review-inline-form { |
| 2875 | padding: 10px 12px; | 2929 | padding: 10px 12px; |
| 2876 | border: 1px solid var(--accent); | 2930 | border: 1px solid var(--accent); |
| 2877 | - border-radius: var(--radius); | 2931 | + border-radius: var(--radius-lg); |
| 2878 | background: var(--surface); | 2932 | background: var(--surface); |
| 2879 | white-space: normal; | 2933 | white-space: normal; |
| 2880 | } | 2934 | } |
| @@ -2908,7 +2962,7 @@ span.reaction { | |||
| 2908 | gap: 8px; | 2962 | gap: 8px; |
| 2909 | padding: 12px 16px; | 2963 | padding: 12px 16px; |
| 2910 | border: 1px solid var(--border); | 2964 | border: 1px solid var(--border); |
| 2911 | - border-radius: var(--radius); | 2965 | + border-radius: var(--radius-lg); |
| 2912 | background: var(--surface); | 2966 | background: var(--surface); |
| 2913 | } | 2967 | } |
| 2914 | 2968 | ||
| @@ -2942,7 +2996,7 @@ span.reaction { | |||
| 2942 | background: var(--surface); | 2996 | background: var(--surface); |
| 2943 | border: 1px solid var(--border); | 2997 | border: 1px solid var(--border); |
| 2944 | border-left: 3px solid var(--accent); | 2998 | border-left: 3px solid var(--accent); |
| 2945 | - border-radius: var(--radius); | 2999 | + border-radius: var(--radius-lg); |
| 2946 | margin: 0; | 3000 | margin: 0; |
| 2947 | padding: 10px 12px; | 3001 | padding: 10px 12px; |
| 2948 | } | 3002 | } |
| @@ -3040,7 +3094,7 @@ span.reaction { | |||
| 3040 | font-size: 0.75rem; | 3094 | font-size: 0.75rem; |
| 3041 | font-weight: 600; | 3095 | font-weight: 600; |
| 3042 | padding: 2px 8px; | 3096 | padding: 2px 8px; |
| 3043 | - border-radius: 999px; | 3097 | + border-radius: var(--radius-full); |
| 3044 | background: var(--private-bg); | 3098 | background: var(--private-bg); |
| 3045 | color: var(--private-text); | 3099 | color: var(--private-text); |
| 3046 | 3100 | ||
| @@ -3063,7 +3117,7 @@ span.reaction { | |||
| 3063 | 3117 | ||
| 3064 | .delivery { | 3118 | .delivery { |
| 3065 | border: 1px solid var(--border); | 3119 | border: 1px solid var(--border); |
| 3066 | - border-radius: var(--radius); | 3120 | + border-radius: var(--radius-lg); |
| 3067 | margin: 0 0 8px; | 3121 | margin: 0 0 8px; |
| 3068 | padding: 8px 12px; | 3122 | padding: 8px 12px; |
| 3069 | 3123 | ||
| @@ -3082,7 +3136,7 @@ span.reaction { | |||
| 3082 | 3136 | ||
| 3083 | .code-block { | 3137 | .code-block { |
| 3084 | background: var(--code-bg); | 3138 | background: var(--code-bg); |
| 3085 | - border-radius: var(--radius); | 3139 | + border-radius: var(--radius-lg); |
| 3086 | font-family: var(--mono); | 3140 | font-family: var(--mono); |
| 3087 | font-size: 0.8125rem; | 3141 | font-size: 0.8125rem; |
| 3088 | margin: 0; | 3142 | margin: 0; |
| @@ -3147,7 +3201,7 @@ span.reaction { | |||
| 3147 | padding: 8px 12px; | 3201 | padding: 8px 12px; |
| 3148 | background: var(--surface); | 3202 | background: var(--surface); |
| 3149 | border: 1px solid var(--border); | 3203 | border: 1px solid var(--border); |
| 3150 | - border-radius: var(--radius); | 3204 | + border-radius: var(--radius-lg); |
| 3151 | box-shadow: 0 4px 16px rgb(0 0 0 / 12%); | 3205 | box-shadow: 0 4px 16px rgb(0 0 0 / 12%); |
| 3152 | } | 3206 | } |
| 3153 | } | 3207 | } |
| @@ -3214,7 +3268,7 @@ span.reaction { | |||
| 3214 | display: inline-block; | 3268 | display: inline-block; |
| 3215 | min-width: 1.4rem; | 3269 | min-width: 1.4rem; |
| 3216 | padding: 0 0.4rem; | 3270 | padding: 0 0.4rem; |
| 3217 | - border-radius: 999px; | 3271 | + border-radius: var(--radius-full); |
| 3218 | background: var(--accent); | 3272 | background: var(--accent); |
| 3219 | color: var(--accent-text); | 3273 | color: var(--accent-text); |
| 3220 | font-size: 0.75rem; | 3274 | font-size: 0.75rem; |
| @@ -3491,7 +3545,7 @@ span.reaction { | |||
| 3491 | font-size: 0.75rem; | 3545 | font-size: 0.75rem; |
| 3492 | font-weight: 600; | 3546 | font-weight: 600; |
| 3493 | padding: 2px 8px; | 3547 | padding: 2px 8px; |
| 3494 | - border-radius: 999px; | 3548 | + border-radius: var(--radius-full); |
| 3495 | vertical-align: middle; | 3549 | vertical-align: middle; |
| 3496 | white-space: nowrap; | 3550 | white-space: nowrap; |
| 3497 | } | 3551 | } |
| @@ -3579,7 +3633,7 @@ span.reaction { | |||
| 3579 | font-size: 0.75rem; | 3633 | font-size: 0.75rem; |
| 3580 | font-weight: 600; | 3634 | font-weight: 600; |
| 3581 | padding: 2px 8px; | 3635 | padding: 2px 8px; |
| 3582 | - border-radius: 999px; | 3636 | + border-radius: var(--radius-full); |
| 3583 | background: var(--private-bg); | 3637 | background: var(--private-bg); |
| 3584 | color: var(--private-text); | 3638 | color: var(--private-text); |
| 3585 | 3639 | ||
| @@ -3699,7 +3753,7 @@ span.reaction { | |||
| 3699 | 3753 | ||
| 3700 | .ci-count { | 3754 | .ci-count { |
| 3701 | padding: 1px 8px; | 3755 | padding: 1px 8px; |
| 3702 | - border-radius: 999px; | 3756 | + border-radius: var(--radius-full); |
| 3703 | background: var(--surface-2); | 3757 | background: var(--surface-2); |
| 3704 | color: var(--muted); | 3758 | color: var(--muted); |
| 3705 | font-size: 0.8125rem; | 3759 | font-size: 0.8125rem; |
| @@ -3753,7 +3807,7 @@ span.reaction { | |||
| 3753 | gap: 6px; | 3807 | gap: 6px; |
| 3754 | min-width: 0; | 3808 | min-width: 0; |
| 3755 | padding: 9px 10px; | 3809 | padding: 9px 10px; |
| 3756 | - border-radius: 8px; | 3810 | + border-radius: var(--radius-md); |
| 3757 | color: inherit; | 3811 | color: inherit; |
| 3758 | text-decoration: none; | 3812 | text-decoration: none; |
| 3759 | 3813 | ||
| @@ -4133,7 +4187,7 @@ span.reaction { | |||
| 4133 | overflow-x: auto; | 4187 | overflow-x: auto; |
| 4134 | color: var(--text-2); | 4188 | color: var(--text-2); |
| 4135 | background: var(--code-bg); | 4189 | background: var(--code-bg); |
| 4136 | - border-radius: 8px; | 4190 | + border-radius: var(--radius-md); |
| 4137 | } | 4191 | } |
| 4138 | 4192 | ||
| 4139 | // Phone width: the list stacks over the run. The timeline keeps its own scroll box. | 4193 | // Phone width: the list stacks over the run. The timeline keeps its own scroll box. |
| @@ -4226,7 +4280,8 @@ span.reaction { | |||
| 4226 | border: 0; | 4280 | border: 0; |
| 4227 | } | 4281 | } |
| 4228 | 4282 | ||
| 4229 | -.snippet-segmented { | 4283 | +.snippet-segmented, |
| 4284 | +.segmented { | ||
| 4230 | display: inline-flex; | 4285 | display: inline-flex; |
| 4231 | align-items: center; | 4286 | align-items: center; |
| 4232 | gap: 2px; | 4287 | gap: 2px; |
| @@ -4235,11 +4290,12 @@ span.reaction { | |||
| 4235 | max-width: 100%; | 4290 | max-width: 100%; |
| 4236 | padding: 2px; | 4291 | padding: 2px; |
| 4237 | border: 1px solid var(--border); | 4292 | border: 1px solid var(--border); |
| 4238 | - border-radius: 999px; | 4293 | + border-radius: var(--radius-full); |
| 4239 | background: var(--surface-2); | 4294 | background: var(--surface-2); |
| 4240 | } | 4295 | } |
| 4241 | 4296 | ||
| 4242 | -.snippet-segmented .segment { | 4297 | +.snippet-segmented .segment, |
| 4298 | +.segmented .segment { | ||
| 4243 | position: relative; | 4299 | position: relative; |
| 4244 | display: inline-flex; | 4300 | display: inline-flex; |
| 4245 | margin: 0; | 4301 | margin: 0; |
| @@ -4260,7 +4316,7 @@ span.reaction { | |||
| 4260 | align-items: center; | 4316 | align-items: center; |
| 4261 | height: 26px; | 4317 | height: 26px; |
| 4262 | padding: 0 12px; | 4318 | padding: 0 12px; |
| 4263 | - border-radius: 999px; | 4319 | + border-radius: var(--radius-full); |
| 4264 | font-size: 0.8125rem; | 4320 | font-size: 0.8125rem; |
| 4265 | font-weight: 500; | 4321 | font-weight: 500; |
| 4266 | line-height: 1; | 4322 | line-height: 1; |
| @@ -4316,7 +4372,7 @@ span.reaction { | |||
| 4316 | padding: 20px 22px 16px; | 4372 | padding: 20px 22px 16px; |
| 4317 | background: var(--surface); | 4373 | background: var(--surface); |
| 4318 | border: 1px solid var(--border); | 4374 | border: 1px solid var(--border); |
| 4319 | - border-radius: 12px; | 4375 | + border-radius: var(--radius-lg); |
| 4320 | box-shadow: var(--shadow); | 4376 | box-shadow: var(--shadow); |
| 4321 | 4377 | ||
| 4322 | &:focus-within { | 4378 | &:focus-within { |
| @@ -4379,7 +4435,7 @@ span.reaction { | |||
| 4379 | overflow: hidden; | 4435 | overflow: hidden; |
| 4380 | background: var(--surface); | 4436 | background: var(--surface); |
| 4381 | border: 1px solid var(--border); | 4437 | border: 1px solid var(--border); |
| 4382 | - border-radius: 12px; | 4438 | + border-radius: var(--radius-lg); |
| 4383 | box-shadow: var(--shadow); | 4439 | box-shadow: var(--shadow); |
| 4384 | 4440 | ||
| 4385 | // Only the filename and the contents light the card; tab radios and buttons do not. | 4441 | // Only the filename and the contents light the card; tab radios and buttons do not. |
| @@ -4404,6 +4460,7 @@ span.reaction { | |||
| 4404 | .snippet-tabs { | 4460 | .snippet-tabs { |
| 4405 | display: flex; | 4461 | display: flex; |
| 4406 | align-items: flex-end; | 4462 | align-items: flex-end; |
| 4463 | + padding-top: 6px; | ||
| 4407 | flex: 1 1 auto; | 4464 | flex: 1 1 auto; |
| 4408 | min-width: 0; | 4465 | min-width: 0; |
| 4409 | max-width: 100%; | 4466 | max-width: 100%; |
| @@ -4436,15 +4493,19 @@ span.reaction { | |||
| 4436 | .snippet-form .snippet-tab { | 4493 | .snippet-form .snippet-tab { |
| 4437 | flex: none; | 4494 | flex: none; |
| 4438 | display: inline-flex; | 4495 | display: inline-flex; |
| 4496 | + flex-direction: row; // the global label is a column; keep the text centred in the tab | ||
| 4497 | + justify-content: flex-start; | ||
| 4439 | align-items: center; | 4498 | align-items: center; |
| 4499 | + gap: 0; | ||
| 4440 | box-sizing: border-box; | 4500 | box-sizing: border-box; |
| 4441 | max-width: 200px; | 4501 | max-width: 200px; |
| 4442 | - height: 36px; | 4502 | + height: 30px; |
| 4443 | margin: 0 1px; | 4503 | margin: 0 1px; |
| 4444 | - padding: 0 14px; | 4504 | + padding: 0 12px; |
| 4505 | + line-height: 1; | ||
| 4445 | border: 1px solid transparent; | 4506 | border: 1px solid transparent; |
| 4446 | border-bottom: 0; | 4507 | border-bottom: 0; |
| 4447 | - border-radius: 8px 8px 0 0; | 4508 | + border-radius: var(--radius-md) var(--radius-md) 0 0; |
| 4448 | color: var(--muted); | 4509 | color: var(--muted); |
| 4449 | font-family: var(--mono); | 4510 | font-family: var(--mono); |
| 4450 | font-size: 0.8125rem; | 4511 | font-size: 0.8125rem; |
| @@ -4477,13 +4538,13 @@ span.reaction { | |||
| 4477 | display: inline-flex; | 4538 | display: inline-flex; |
| 4478 | align-items: center; | 4539 | align-items: center; |
| 4479 | justify-content: center; | 4540 | justify-content: center; |
| 4480 | - align-self: center; | 4541 | + align-self: flex-end; |
| 4481 | width: 30px; | 4542 | width: 30px; |
| 4482 | height: 30px; | 4543 | height: 30px; |
| 4483 | - margin: 0 0 3px 4px; | 4544 | + margin: 0 0 0 4px; |
| 4484 | padding: 0; | 4545 | padding: 0; |
| 4485 | border: 0; | 4546 | border: 0; |
| 4486 | - border-radius: 8px; | 4547 | + border-radius: var(--radius-md); |
| 4487 | background: transparent; | 4548 | background: transparent; |
| 4488 | color: var(--muted); | 4549 | color: var(--muted); |
| 4489 | 4550 | ||
| @@ -4554,7 +4615,7 @@ span.reaction { | |||
| 4554 | padding: 0; | 4615 | padding: 0; |
| 4555 | justify-content: center; | 4616 | justify-content: center; |
| 4556 | border: 0; | 4617 | border: 0; |
| 4557 | - border-radius: 8px; | 4618 | + border-radius: var(--radius-md); |
| 4558 | background: transparent; | 4619 | background: transparent; |
| 4559 | color: var(--muted); | 4620 | color: var(--muted); |
| 4560 | 4621 | ||
| @@ -4622,7 +4683,8 @@ span.reaction { | |||
| 4622 | width: 100%; | 4683 | width: 100%; |
| 4623 | } | 4684 | } |
| 4624 | 4685 | ||
| 4625 | - .snippet-segmented .segment { | 4686 | + .snippet-segmented .segment, |
| 4687 | + .segmented .segment { | ||
| 4626 | > span { | 4688 | > span { |
| 4627 | width: 26px; | 4689 | width: 26px; |
| 4628 | padding: 0; | 4690 | padding: 0; |
| @@ -4717,7 +4779,7 @@ span.reaction { | |||
| 4717 | overflow-wrap: anywhere; | 4779 | overflow-wrap: anywhere; |
| 4718 | background: var(--code-bg); | 4780 | background: var(--code-bg); |
| 4719 | border: 1px solid var(--border); | 4781 | border: 1px solid var(--border); |
| 4720 | - border-radius: var(--radius); | 4782 | + border-radius: var(--radius-lg); |
| 4721 | color: var(--text); | 4783 | color: var(--text); |
| 4722 | 4784 | ||
| 4723 | code { | 4785 | code { |
| @@ -4832,7 +4894,7 @@ span.reaction { | |||
| 4832 | height: 32px; | 4894 | height: 32px; |
| 4833 | padding: 0 14px; | 4895 | padding: 0 14px; |
| 4834 | border: 1px solid var(--border-strong); | 4896 | border: 1px solid var(--border-strong); |
| 4835 | - border-radius: 999px; | 4897 | + border-radius: var(--radius-full); |
| 4836 | background: var(--surface); | 4898 | background: var(--surface); |
| 4837 | box-shadow: var(--shadow); | 4899 | box-shadow: var(--shadow); |
| 4838 | color: var(--text); | 4900 | color: var(--text); |
| @@ -5007,7 +5069,7 @@ span.reaction { | |||
| 5007 | display: inline-block; | 5069 | display: inline-block; |
| 5008 | padding: 0 8px; | 5070 | padding: 0 8px; |
| 5009 | border: 1px solid transparent; | 5071 | border: 1px solid transparent; |
| 5010 | - border-radius: 999px; | 5072 | + border-radius: var(--radius-full); |
| 5011 | font-size: 0.75rem; | 5073 | font-size: 0.75rem; |
| 5012 | font-weight: 600; | 5074 | font-weight: 600; |
| 5013 | line-height: 1.6; | 5075 | line-height: 1.6; |
| @@ -5042,7 +5104,7 @@ span.reaction { | |||
| 5042 | display: inline-block; | 5104 | display: inline-block; |
| 5043 | padding: 6px 12px; | 5105 | padding: 6px 12px; |
| 5044 | border: 1px solid var(--border-strong); | 5106 | border: 1px solid var(--border-strong); |
| 5045 | - border-radius: var(--radius); | 5107 | + border-radius: var(--radius-md); |
| 5046 | background: var(--surface); | 5108 | background: var(--surface); |
| 5047 | color: var(--text-2); | 5109 | color: var(--text-2); |
| 5048 | font-size: 0.875rem; | 5110 | font-size: 0.875rem; |
| @@ -5117,7 +5179,7 @@ span.reaction { | |||
| 5117 | > .security-device { | 5179 | > .security-device { |
| 5118 | padding: 12px 14px; | 5180 | padding: 12px 14px; |
| 5119 | border: 1px solid var(--border); | 5181 | border: 1px solid var(--border); |
| 5120 | - border-radius: var(--radius); | 5182 | + border-radius: var(--radius-lg); |
| 5121 | background: var(--surface-2); | 5183 | background: var(--surface-2); |
| 5122 | } | 5184 | } |
| 5123 | } | 5185 | } |