Tabbed pages keep one head height, so switching Settings or Admin tabs no longer moves the tabs or the sheet
Browse files at this commitf708a8c20df948ce8a9cfb4654b0816c66e1e49dParent: 41ee476All checks have passed
Show checks
ci/buildSucceededDetails
- style
- tabbed pages keep one head height, so switching Settings or Admin tabs no longer moves the tabs or the sheet
- rows that only held facts and actions are one flat line with their actions beside the facts and a confirm that opens in place (tokens, SSH and GPG keys, push devices, secrets, packages, mail, merge queue, branches, tags, advisories, sessions)
- Security shows password and email directly and lists sessions with Revoke on each line, and the security log sits in the Security rail
- every control has one focus ring inside its own edge
- colours offer five presets and a Custom chip with its word, on the same columns in both rows
- Run alerts previews stand on the switch's middle line
- the CI log keeps line numbers on one line, the run and job pages fit the window with the log scrolling inside, and the job head reads Run #N with a plain state
- passed is one green everywhere in CI, taken from the accent's lightness and strength, and the Log and Timeline switch marks its current tab like any other
- the admin organization page lists its members with links and puts Open profile in the head
- a one-field form sends from beside its field
- the snippet form's files are one row on the fields' edge
- the profile menu's name opens your profile in place of a Your profile row
- every pager, numbered or not, is the same row on the sheet's inset ✨ feat: the path bar names every place above a page as a link (repo sections, #N items, a job's run, Keys above GPG keys and tokens, Users above an account, Snippets above a snippet), so no page needs the browser's Back button
- the audit log has numbered pages, folds repeats into one line with ×N, and reads as words in English and Turkish, with every action, target kind, detail and role named in both ♻️ refactor: the Spark and Gold accents and the Spark background are gone, and accounts that chose them fall back to the default
- old session addresses redirect to Security 🐛 fix: branch rows keep the commit subject on the row's line
- edit history titles read "of the issue description"
34 changed files +1908 -815
- crates/forge-core/src/store/audit.rs +70 -35
- crates/forge-e2e/tests/e2e/orgs_ui_e2e.rs +2 -2
- crates/forge-e2e/tests/e2e/section_nav_e2e.rs +1 -2
- crates/forge-e2e/tests/e2e/ui_prefs_e2e.rs +10 -10
- crates/forge-e2e/tests/e2e/wiki_e2e.rs +1 -1
- crates/forge-web-base/src/accent.rs +16 -8
- crates/forge-web-base/src/accent_palette.rs +0 -88
- crates/forge-web-base/src/i18n/audit_names.rs +536 -0
- crates/forge-web-base/src/i18n/issues.rs +4 -4
- crates/forge-web-base/src/i18n/mod.rs +3 -2
- crates/forge-web/src/pages/admin_mail.rs +13 -18
- crates/forge-web/src/pages/admin_user_detail.rs +43 -19
- crates/forge-web/src/pages/audit_log.rs +244 -103
- crates/forge-web/src/pages/branches.rs +23 -28
- crates/forge-web/src/pages/ci_job.rs +6 -7
- crates/forge-web/src/pages/merge_queue.rs +22 -26
- crates/forge-web/src/pages/packages_oci.rs +9 -16
- crates/forge-web/src/pages/palette.rs +9 -5
- crates/forge-web/src/pages/refs.rs +7 -12
- crates/forge-web/src/pages/repo.rs +2 -4
- crates/forge-web/src/pages/repo_secrets.rs +7 -13
- crates/forge-web/src/pages/repo_security.rs +11 -18
- crates/forge-web/src/pages/settings_appearance.rs +6 -7
- crates/forge-web/src/pages/settings_gpg.rs +7 -14
- crates/forge-web/src/pages/settings_keys.rs +20 -18
- crates/forge-web/src/pages/settings_notifications.rs +11 -18
- crates/forge-web/src/pages/settings_security.rs +192 -107
- crates/forge-web/src/pages/settings_sessions.rs +38 -163
- crates/forge-web/src/pages/settings_tokens.rs +5 -12
- crates/forge-web/src/views/mod.rs +231 -40
- docs/ui-language.md +34 -8
- style/_one.scss +183 -7
- style/_one_ci.scss +96 -0
- style/_one_people.scss +46 -0
crates/forge-core/src/store/audit.rsmodified+70 -35
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | use turso::{Row, Value}; | 3 | use turso::{Row, Value}; |
| 4 | 4 | ||
| 5 | -use super::{Store, col_opt_text, col_text, db_err, fetch_all}; | 5 | +use super::{Store, col_int, col_opt_text, col_text, db_err, fetch_all, fetch_opt}; |
| 6 | use crate::audit::{AuditAction, AuditCursor, AuditEntry, AuditFilter}; | 6 | use crate::audit::{AuditAction, AuditCursor, AuditEntry, AuditFilter}; |
| 7 | use crate::error::{Error, Result}; | 7 | use crate::error::{Error, Result}; |
| 8 | 8 | ||
| @@ -28,6 +28,46 @@ fn map_audit(row: &Row) -> Result<AuditEntry> { | |||
| 28 | }) | 28 | }) |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | +/// The WHERE clause and its parameters for `filter` and an optional cursor, shared by the | ||
| 32 | +/// listings and the count so they select the same entries. | ||
| 33 | +fn audit_where(filter: &AuditFilter, before: Option<&AuditCursor>) -> (String, Vec<Value>) { | ||
| 34 | + let mut clauses: Vec<&str> = Vec::new(); | ||
| 35 | + let mut params: Vec<Value> = Vec::new(); | ||
| 36 | + if let Some(actor) = &filter.actor_id { | ||
| 37 | + clauses.push("actor_id = ?"); | ||
| 38 | + params.push(Value::Text(actor.clone())); | ||
| 39 | + } | ||
| 40 | + if let Some(action) = filter.action { | ||
| 41 | + clauses.push("action = ?"); | ||
| 42 | + params.push(Value::Text(action.as_str().to_string())); | ||
| 43 | + } | ||
| 44 | + if let Some(kind) = &filter.target_kind { | ||
| 45 | + clauses.push("target_kind = ?"); | ||
| 46 | + params.push(Value::Text(kind.clone())); | ||
| 47 | + } | ||
| 48 | + if let Some(id) = &filter.target_id { | ||
| 49 | + clauses.push("target_id = ?"); | ||
| 50 | + params.push(Value::Text(id.clone())); | ||
| 51 | + } | ||
| 52 | + if let Some(user) = &filter.involving_user { | ||
| 53 | + clauses.push("(actor_id = ? OR (target_kind = 'user' AND target_id = ?))"); | ||
| 54 | + params.push(Value::Text(user.clone())); | ||
| 55 | + params.push(Value::Text(user.clone())); | ||
| 56 | + } | ||
| 57 | + if let Some(cursor) = before { | ||
| 58 | + clauses.push("(at < ? OR (at = ? AND id < ?))"); | ||
| 59 | + params.push(Value::Text(cursor.at.clone())); | ||
| 60 | + params.push(Value::Text(cursor.at.clone())); | ||
| 61 | + params.push(Value::Text(cursor.id.clone())); | ||
| 62 | + } | ||
| 63 | + let where_sql = if clauses.is_empty() { | ||
| 64 | + String::new() | ||
| 65 | + } else { | ||
| 66 | + format!("WHERE {}", clauses.join(" AND ")) | ||
| 67 | + }; | ||
| 68 | + (where_sql, params) | ||
| 69 | +} | ||
| 70 | + | ||
| 31 | impl Store { | 71 | impl Store { |
| 32 | /// Appends one entry. Nothing else in the store writes to `audit_log`. | 72 | /// Appends one entry. Nothing else in the store writes to `audit_log`. |
| 33 | pub async fn record_audit(&self, entry: &AuditEntry) -> Result<()> { | 73 | pub async fn record_audit(&self, entry: &AuditEntry) -> Result<()> { |
| @@ -66,40 +106,7 @@ impl Store { | |||
| 66 | before: Option<&AuditCursor>, | 106 | before: Option<&AuditCursor>, |
| 67 | limit: u32, | 107 | limit: u32, |
| 68 | ) -> Result<Vec<AuditEntry>> { | 108 | ) -> Result<Vec<AuditEntry>> { |
| 69 | - let mut clauses: Vec<&str> = Vec::new(); | 109 | + let (where_sql, mut params) = audit_where(filter, before); |
| 70 | - let mut params: Vec<Value> = Vec::new(); | ||
| 71 | - if let Some(actor) = &filter.actor_id { | ||
| 72 | - clauses.push("actor_id = ?"); | ||
| 73 | - params.push(Value::Text(actor.clone())); | ||
| 74 | - } | ||
| 75 | - if let Some(action) = filter.action { | ||
| 76 | - clauses.push("action = ?"); | ||
| 77 | - params.push(Value::Text(action.as_str().to_string())); | ||
| 78 | - } | ||
| 79 | - if let Some(kind) = &filter.target_kind { | ||
| 80 | - clauses.push("target_kind = ?"); | ||
| 81 | - params.push(Value::Text(kind.clone())); | ||
| 82 | - } | ||
| 83 | - if let Some(id) = &filter.target_id { | ||
| 84 | - clauses.push("target_id = ?"); | ||
| 85 | - params.push(Value::Text(id.clone())); | ||
| 86 | - } | ||
| 87 | - if let Some(user) = &filter.involving_user { | ||
| 88 | - clauses.push("(actor_id = ? OR (target_kind = 'user' AND target_id = ?))"); | ||
| 89 | - params.push(Value::Text(user.clone())); | ||
| 90 | - params.push(Value::Text(user.clone())); | ||
| 91 | - } | ||
| 92 | - if let Some(cursor) = before { | ||
| 93 | - clauses.push("(at < ? OR (at = ? AND id < ?))"); | ||
| 94 | - params.push(Value::Text(cursor.at.clone())); | ||
| 95 | - params.push(Value::Text(cursor.at.clone())); | ||
| 96 | - params.push(Value::Text(cursor.id.clone())); | ||
| 97 | - } | ||
| 98 | - let where_sql = if clauses.is_empty() { | ||
| 99 | - String::new() | ||
| 100 | - } else { | ||
| 101 | - format!("WHERE {}", clauses.join(" AND ")) | ||
| 102 | - }; | ||
| 103 | let sql = format!( | 110 | let sql = format!( |
| 104 | "SELECT {AUDIT_COLS} FROM audit_log {where_sql} ORDER BY at DESC, id DESC LIMIT ?" | 111 | "SELECT {AUDIT_COLS} FROM audit_log {where_sql} ORDER BY at DESC, id DESC LIMIT ?" |
| 105 | ); | 112 | ); |
| @@ -108,6 +115,34 @@ impl Store { | |||
| 108 | fetch_all(&conn, &sql, params, map_audit).await | 115 | fetch_all(&conn, &sql, params, map_audit).await |
| 109 | } | 116 | } |
| 110 | 117 | ||
| 118 | + /// Entries matching `filter` in the same order as [`Store::list_audit`], skipping `offset` | ||
| 119 | + /// entries first. For numbered pages. `limit` is clamped to 1..=200. | ||
| 120 | + pub async fn list_audit_page( | ||
| 121 | + &self, | ||
| 122 | + filter: &AuditFilter, | ||
| 123 | + offset: u32, | ||
| 124 | + limit: u32, | ||
| 125 | + ) -> Result<Vec<AuditEntry>> { | ||
| 126 | + let (where_sql, mut params) = audit_where(filter, None); | ||
| 127 | + let sql = format!( | ||
| 128 | + "SELECT {AUDIT_COLS} FROM audit_log {where_sql} ORDER BY at DESC, id DESC \ | ||
| 129 | + LIMIT ? OFFSET ?" | ||
| 130 | + ); | ||
| 131 | + params.push(Value::Integer(i64::from(limit.clamp(1, MAX_AUDIT_PAGE)))); | ||
| 132 | + params.push(Value::Integer(i64::from(offset))); | ||
| 133 | + let conn = self.read_conn().await; | ||
| 134 | + fetch_all(&conn, &sql, params, map_audit).await | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + /// How many entries match `filter`, for the page count. | ||
| 138 | + pub async fn count_audit(&self, filter: &AuditFilter) -> Result<u64> { | ||
| 139 | + let (where_sql, params) = audit_where(filter, None); | ||
| 140 | + let sql = format!("SELECT COUNT(*) FROM audit_log {where_sql}"); | ||
| 141 | + let conn = self.read_conn().await; | ||
| 142 | + let count = fetch_opt(&conn, &sql, params, |row| col_int(row, 0)).await?; | ||
| 143 | + Ok(count.unwrap_or(0).max(0) as u64) | ||
| 144 | + } | ||
| 145 | + | ||
| 111 | /// Retention: deletes entries stamped before `cutoff` (an RFC 3339 UTC stamp). Returns the | 146 | /// Retention: deletes entries stamped before `cutoff` (an RFC 3339 UTC stamp). Returns the |
| 112 | /// number of entries removed. This is the only delete on the audit log. | 147 | /// number of entries removed. This is the only delete on the audit log. |
| 113 | pub async fn purge_audit_before(&self, cutoff: &str) -> Result<u64> { | 148 | pub async fn purge_audit_before(&self, cutoff: &str) -> Result<u64> { |
crates/forge-e2e/tests/e2e/orgs_ui_e2e.rsmodified+2 -2
| @@ -469,14 +469,14 @@ async fn org_settings_delete_and_audit_end_to_end() { | |||
| 469 | .await; | 469 | .await; |
| 470 | assert_eq!(audit.status, 200, "audit page"); | 470 | assert_eq!(audit.status, 200, "audit page"); |
| 471 | assert!( | 471 | assert!( |
| 472 | - audit.body.contains("<code>org_settings_updated</code>"), | 472 | + audit.body.contains("title=\"org_settings_updated\""), |
| 473 | "settings change is audited" | 473 | "settings change is audited" |
| 474 | ); | 474 | ); |
| 475 | let audit = http | 475 | let audit = http |
| 476 | .get("/admin/audit?action=org_deleted", Some(&root_session)) | 476 | .get("/admin/audit?action=org_deleted", Some(&root_session)) |
| 477 | .await; | 477 | .await; |
| 478 | assert!( | 478 | assert!( |
| 479 | - audit.body.contains("<code>org_deleted</code>"), | 479 | + audit.body.contains("title=\"org_deleted\""), |
| 480 | "org deletion is audited" | 480 | "org deletion is audited" |
| 481 | ); | 481 | ); |
| 482 | } | 482 | } |
crates/forge-e2e/tests/e2e/section_nav_e2e.rsmodified+1 -2
| @@ -201,12 +201,11 @@ async fn settings_pages_get_the_settings_tabs() { | |||
| 201 | "/settings/keys", | 201 | "/settings/keys", |
| 202 | "/settings/export", | 202 | "/settings/export", |
| 203 | ]; | 203 | ]; |
| 204 | - // A page folded into another tab marks that tab: sessions under security, GPG keys and | 204 | + // A page folded into another tab marks that tab: GPG keys and |
| 205 | // tokens under keys. | 205 | // tokens under keys. |
| 206 | let pages = [ | 206 | let pages = [ |
| 207 | ("/settings/profile", "/settings/profile"), | 207 | ("/settings/profile", "/settings/profile"), |
| 208 | ("/settings/keys", "/settings/keys"), | 208 | ("/settings/keys", "/settings/keys"), |
| 209 | - ("/settings/sessions", "/settings/security"), | ||
| 210 | ("/settings/security", "/settings/security"), | 209 | ("/settings/security", "/settings/security"), |
| 211 | ("/settings/notifications", "/settings/notifications"), | 210 | ("/settings/notifications", "/settings/notifications"), |
| 212 | ("/settings/appearance", "/settings/appearance"), | 211 | ("/settings/appearance", "/settings/appearance"), |
crates/forge-e2e/tests/e2e/ui_prefs_e2e.rsmodified+10 -10
| @@ -267,14 +267,14 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() { | |||
| 267 | ("csrf", &csrf), | 267 | ("csrf", &csrf), |
| 268 | ("theme", "light"), | 268 | ("theme", "light"), |
| 269 | ("language", "en"), | 269 | ("language", "en"), |
| 270 | - ("base_dark", "spark"), | 270 | + ("base_dark", "graphite"), |
| 271 | ], | 271 | ], |
| 272 | Some(&session), | 272 | Some(&session), |
| 273 | ) | 273 | ) |
| 274 | .await; | 274 | .await; |
| 275 | assert_eq!(saved.status, 303, "save: {}", saved.body); | 275 | assert_eq!(saved.status, 303, "save: {}", saved.body); |
| 276 | let page = env.http.get("/settings/appearance", Some(&session)).await; | 276 | let page = env.http.get("/settings/appearance", Some(&session)).await; |
| 277 | - let chosen = ["ocean", "plum", "ink", "spark"].map(str::to_owned); | 277 | + let chosen = ["ocean", "plum", "ink", "graphite"].map(str::to_owned); |
| 278 | assert_eq!(checked_colours(&page.body), chosen.clone().map(Some)); | 278 | assert_eq!(checked_colours(&page.body), chosen.clone().map(Some)); |
| 279 | assert_eq!(html_colours(&page.body), chosen.map(Some)); | 279 | assert_eq!(html_colours(&page.body), chosen.map(Some)); |
| 280 | 280 | ||
| @@ -300,7 +300,7 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() { | |||
| 300 | assert_ne!(res.status, 303, "bad {field} {bad:?} must not save"); | 300 | assert_ne!(res.status, 303, "bad {field} {bad:?} must not save"); |
| 301 | } | 301 | } |
| 302 | let page = env.http.get("/settings/appearance", Some(&session)).await; | 302 | let page = env.http.get("/settings/appearance", Some(&session)).await; |
| 303 | - let chosen = ["ocean", "plum", "ink", "spark"].map(str::to_owned); | 303 | + let chosen = ["ocean", "plum", "ink", "graphite"].map(str::to_owned); |
| 304 | assert_eq!(checked_colours(&page.body), chosen.clone().map(Some)); | 304 | assert_eq!(checked_colours(&page.body), chosen.clone().map(Some)); |
| 305 | assert_eq!(html_colours(&page.body), chosen.map(Some)); | 305 | assert_eq!(html_colours(&page.body), chosen.map(Some)); |
| 306 | 306 | ||
| @@ -314,8 +314,8 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() { | |||
| 314 | ("theme", "light"), | 314 | ("theme", "light"), |
| 315 | ("language", "tr"), | 315 | ("language", "tr"), |
| 316 | ("accent_light", "hue-200"), | 316 | ("accent_light", "hue-200"), |
| 317 | - ("accent_dark", "gold"), | 317 | + ("accent_dark", "rose"), |
| 318 | - ("base_light", "spark"), | 318 | + ("base_light", "graphite"), |
| 319 | ("base_dark", "dusk"), | 319 | ("base_dark", "dusk"), |
| 320 | ], | 320 | ], |
| 321 | Some(&session), | 321 | Some(&session), |
| @@ -324,9 +324,9 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() { | |||
| 324 | assert_eq!(saved.status, 303, "save: {}", saved.body); | 324 | assert_eq!(saved.status, 303, "save: {}", saved.body); |
| 325 | let page = env.http.get("/settings/appearance", Some(&session)).await; | 325 | let page = env.http.get("/settings/appearance", Some(&session)).await; |
| 326 | // The Custom radio carries the hue at the default vividness; the stored id stays `hue-200`. | 326 | // The Custom radio carries the hue at the default vividness; the stored id stays `hue-200`. |
| 327 | - let checked = ["hue-200-v50", "gold", "spark", "dusk"].map(str::to_owned); | 327 | + let checked = ["hue-200-v50", "rose", "graphite", "dusk"].map(str::to_owned); |
| 328 | assert_eq!(checked_colours(&page.body), checked.map(Some)); | 328 | assert_eq!(checked_colours(&page.body), checked.map(Some)); |
| 329 | - let chosen = ["hue-200", "gold", "spark", "dusk"].map(str::to_owned); | 329 | + let chosen = ["hue-200", "rose", "graphite", "dusk"].map(str::to_owned); |
| 330 | assert_eq!(html_colours(&page.body), chosen.map(Some)); | 330 | assert_eq!(html_colours(&page.body), chosen.map(Some)); |
| 331 | 331 | ||
| 332 | // The newest accents and backgrounds save and show the same way. | 332 | // The newest accents and backgrounds save and show the same way. |
| @@ -369,16 +369,16 @@ async fn a_save_without_colour_fields_keeps_the_stored_colours() { | |||
| 369 | ("theme", "light"), | 369 | ("theme", "light"), |
| 370 | ("language", "en"), | 370 | ("language", "en"), |
| 371 | ("accent_light", "rose"), | 371 | ("accent_light", "rose"), |
| 372 | - ("accent_dark", "gold"), | 372 | + ("accent_dark", "ocean"), |
| 373 | ("base_light", "fern"), | 373 | ("base_light", "fern"), |
| 374 | - ("base_dark", "spark"), | 374 | + ("base_dark", "dusk"), |
| 375 | ], | 375 | ], |
| 376 | Some(&session), | 376 | Some(&session), |
| 377 | ) | 377 | ) |
| 378 | .await; | 378 | .await; |
| 379 | assert_eq!(saved.status, 303, "save: {}", saved.body); | 379 | assert_eq!(saved.status, 303, "save: {}", saved.body); |
| 380 | let before = env.http.get("/settings/appearance", Some(&session)).await; | 380 | let before = env.http.get("/settings/appearance", Some(&session)).await; |
| 381 | - let stored = ["rose", "gold", "fern", "spark"].map(str::to_owned); | 381 | + let stored = ["rose", "ocean", "fern", "dusk"].map(str::to_owned); |
| 382 | assert_eq!(html_colours(&before.body), stored.clone().map(Some)); | 382 | assert_eq!(html_colours(&before.body), stored.clone().map(Some)); |
| 383 | 383 | ||
| 384 | let saved = env | 384 | let saved = env |
crates/forge-e2e/tests/e2e/wiki_e2e.rsmodified+1 -1
| @@ -242,7 +242,7 @@ async fn wiki_end_to_end() { | |||
| 242 | .await; | 242 | .await; |
| 243 | assert_eq!(audit.status, 200, "audit page"); | 243 | assert_eq!(audit.status, 200, "audit page"); |
| 244 | assert!( | 244 | assert!( |
| 245 | - audit.body.contains("<code>wiki_pushed</code>"), | 245 | + audit.body.contains("title=\"wiki_pushed\""), |
| 246 | "the wiki push is audited: {}", | 246 | "the wiki push is audited: {}", |
| 247 | audit.body | 247 | audit.body |
| 248 | ); | 248 | ); |
crates/forge-web-base/src/accent.rsmodified+16 -8
| @@ -310,16 +310,24 @@ mod tests { | |||
| 310 | fn the_presets_are_offered_in_picker_order_and_removed_ids_are_not() { | 310 | fn the_presets_are_offered_in_picker_order_and_removed_ids_are_not() { |
| 311 | assert_eq!( | 311 | assert_eq!( |
| 312 | ids().collect::<Vec<_>>(), | 312 | ids().collect::<Vec<_>>(), |
| 313 | - ["ember", "sage", "spark", "ocean", "plum", "rose", "gold"] | 313 | + ["ember", "sage", "ocean", "plum", "rose"] |
| 314 | ); | 314 | ); |
| 315 | assert_eq!( | 315 | assert_eq!( |
| 316 | base_ids().collect::<Vec<_>>(), | 316 | base_ids().collect::<Vec<_>>(), |
| 317 | - ["anvil", "fern", "spark", "graphite", "dusk", "ink"] | 317 | + ["anvil", "fern", "graphite", "dusk", "ink"] |
| 318 | ); | 318 | ); |
| 319 | - for id in ["ochre", "teal", "Sage", "sage ", "terracotta"] { | 319 | + for id in [ |
| 320 | + "ochre", | ||
| 321 | + "teal", | ||
| 322 | + "Sage", | ||
| 323 | + "sage ", | ||
| 324 | + "terracotta", | ||
| 325 | + "spark", | ||
| 326 | + "gold", | ||
| 327 | + ] { | ||
| 320 | assert!(!is_offered(id), "{id}"); | 328 | assert!(!is_offered(id), "{id}"); |
| 321 | } | 329 | } |
| 322 | - for id in ["stone", "mist", "Fern", "dune", "slate-blue"] { | 330 | + for id in ["stone", "mist", "Fern", "dune", "slate-blue", "spark"] { |
| 323 | assert!(!is_offered_base(id), "{id}"); | 331 | assert!(!is_offered_base(id), "{id}"); |
| 324 | } | 332 | } |
| 325 | } | 333 | } |
| @@ -372,11 +380,11 @@ mod tests { | |||
| 372 | fn preset_hues_come_from_the_colour() { | 380 | fn preset_hues_come_from_the_colour() { |
| 373 | assert_eq!(preset_accent_hue("sage"), Some(149)); | 381 | assert_eq!(preset_accent_hue("sage"), Some(149)); |
| 374 | assert_eq!(preset_accent_hue("ocean"), Some(240)); | 382 | assert_eq!(preset_accent_hue("ocean"), Some(240)); |
| 375 | - assert_eq!(preset_accent_hue("spark"), Some(42)); | 383 | + assert_eq!(preset_accent_hue("plum"), Some(300)); |
| 376 | assert_eq!(preset_accent_hue("fern"), None); | 384 | assert_eq!(preset_accent_hue("fern"), None); |
| 377 | assert_eq!(preset_accent_hue("hue-5"), None); | 385 | assert_eq!(preset_accent_hue("hue-5"), None); |
| 378 | assert!(preset_base_hue("fern").is_some()); | 386 | assert!(preset_base_hue("fern").is_some()); |
| 379 | - assert!(preset_base_hue("spark").is_some()); | 387 | + assert!(preset_base_hue("dusk").is_some()); |
| 380 | assert_eq!(preset_base_hue("sage"), None); | 388 | assert_eq!(preset_base_hue("sage"), None); |
| 381 | } | 389 | } |
| 382 | 390 | ||
| @@ -406,8 +414,8 @@ mod tests { | |||
| 406 | Some("/theme/custom.css?al=hue-215&ad=plum&bl=fern&bd=hue-7") | 414 | Some("/theme/custom.css?al=hue-215&ad=plum&bl=fern&bd=hue-7") |
| 407 | ); | 415 | ); |
| 408 | assert_eq!( | 416 | assert_eq!( |
| 409 | - custom_css_href("sage", "sage", "spark", "hue-0").as_deref(), | 417 | + custom_css_href("sage", "sage", "ink", "hue-0").as_deref(), |
| 410 | - Some("/theme/custom.css?al=sage&ad=sage&bl=spark&bd=hue-0") | 418 | + Some("/theme/custom.css?al=sage&ad=sage&bl=ink&bd=hue-0") |
| 411 | ); | 419 | ); |
| 412 | } | 420 | } |
| 413 | 421 | ||
crates/forge-web-base/src/accent_palette.rsmodified+0 -88
| @@ -141,34 +141,6 @@ pub const PALETTES: &[Palette] = &[ | |||
| 141 | hunk_text: "#B3C385", | 141 | hunk_text: "#B3C385", |
| 142 | }, | 142 | }, |
| 143 | }, | 143 | }, |
| 144 | - // Flare orange: a bright, clean orange on plain neutral greys. | ||
| 145 | - Palette { | ||
| 146 | - id: "spark", | ||
| 147 | - light: Tokens { | ||
| 148 | - accent: "#E8590C", | ||
| 149 | - accent_ink: "#A83A07", | ||
| 150 | - accent_soft: "#FDE9DB", | ||
| 151 | - accent_text: "#18181B", | ||
| 152 | - focus: "#A83A07", | ||
| 153 | - public_bg: "#FDE9DB", | ||
| 154 | - public_text: "#A83A07", | ||
| 155 | - note: "#A83A07", | ||
| 156 | - hunk_bg: "#FEF4EC", | ||
| 157 | - hunk_text: "#9C3606", | ||
| 158 | - }, | ||
| 159 | - dark: Tokens { | ||
| 160 | - accent: "#FF7A1A", | ||
| 161 | - accent_ink: "#FF9A4D", | ||
| 162 | - accent_soft: "#3B2214", | ||
| 163 | - accent_text: "#18181B", | ||
| 164 | - focus: "#FF7A1A", | ||
| 165 | - public_bg: "#3B2214", | ||
| 166 | - public_text: "#FF9A4D", | ||
| 167 | - note: "#FF9A4D", | ||
| 168 | - hunk_bg: "#2A1A10", | ||
| 169 | - hunk_text: "#FF7A1A", | ||
| 170 | - }, | ||
| 171 | - }, | ||
| 172 | // Blue, clear and cool. | 144 | // Blue, clear and cool. |
| 173 | Palette { | 145 | Palette { |
| 174 | id: "ocean", | 146 | id: "ocean", |
| @@ -253,34 +225,6 @@ pub const PALETTES: &[Palette] = &[ | |||
| 253 | hunk_text: "#E79DAD", | 225 | hunk_text: "#E79DAD", |
| 254 | }, | 226 | }, |
| 255 | }, | 227 | }, |
| 256 | - // Bright yellow, leaning to lemon, so it takes dark text. | ||
| 257 | - Palette { | ||
| 258 | - id: "gold", | ||
| 259 | - light: Tokens { | ||
| 260 | - accent: "#D4A017", | ||
| 261 | - accent_ink: "#7D5A00", | ||
| 262 | - accent_soft: "#F8F0D6", | ||
| 263 | - accent_text: "#1F1700", | ||
| 264 | - focus: "#7D5A00", | ||
| 265 | - public_bg: "#F8F0D6", | ||
| 266 | - public_text: "#7D5A00", | ||
| 267 | - note: "#7D5A00", | ||
| 268 | - hunk_bg: "#FCF8EA", | ||
| 269 | - hunk_text: "#7D5A00", | ||
| 270 | - }, | ||
| 271 | - dark: Tokens { | ||
| 272 | - accent: "#E8BC4A", | ||
| 273 | - accent_ink: "#F5D27A", | ||
| 274 | - accent_soft: "#3A2E0E", | ||
| 275 | - accent_text: "#1F1700", | ||
| 276 | - focus: "#E8BC4A", | ||
| 277 | - public_bg: "#3A2E0E", | ||
| 278 | - public_text: "#F5D27A", | ||
| 279 | - note: "#F5D27A", | ||
| 280 | - hunk_bg: "#2A220D", | ||
| 281 | - hunk_text: "#E8BC4A", | ||
| 282 | - }, | ||
| 283 | - }, | ||
| 284 | ]; | 228 | ]; |
| 285 | 229 | ||
| 286 | /// The neutral colour tokens one base sets in one theme. The values are CSS colours; | 230 | /// The neutral colour tokens one base sets in one theme. The values are CSS colours; |
| @@ -438,38 +382,6 @@ pub const BASES: &[Base] = &[ | |||
| 438 | ln_text: "#8A959A", | 382 | ln_text: "#8A959A", |
| 439 | }, | 383 | }, |
| 440 | }, | 384 | }, |
| 441 | - // Spark: plain neutral greys, barely warm. | ||
| 442 | - Base { | ||
| 443 | - id: "spark", | ||
| 444 | - light: BaseTokens { | ||
| 445 | - bg: "#FAFAFA", | ||
| 446 | - surface: "#FFFFFF", | ||
| 447 | - surface_2: "#F0F0F0", | ||
| 448 | - text: "#18181B", | ||
| 449 | - text_2: "#3F3F46", | ||
| 450 | - muted: "#6C6C75", | ||
| 451 | - border: "#E4E4E7", | ||
| 452 | - border_strong: "#D4D4D8", | ||
| 453 | - code_bg: "#F0F0F0", | ||
| 454 | - private_bg: "#F0F0F0", | ||
| 455 | - private_text: "#3F3F46", | ||
| 456 | - ln_text: "#666670", | ||
| 457 | - }, | ||
| 458 | - dark: BaseTokens { | ||
| 459 | - bg: "#18181A", | ||
| 460 | - surface: "#212124", | ||
| 461 | - surface_2: "#2A2A2E", | ||
| 462 | - text: "#F4F4F5", | ||
| 463 | - text_2: "#D4D4D8", | ||
| 464 | - muted: "#A1A1AA", | ||
| 465 | - border: "#3A3A40", | ||
| 466 | - border_strong: "#4A4A50", | ||
| 467 | - code_bg: "#111113", | ||
| 468 | - private_bg: "#2A2A2E", | ||
| 469 | - private_text: "#D4D4D8", | ||
| 470 | - ln_text: "#A1A1AA", | ||
| 471 | - }, | ||
| 472 | - }, | ||
| 473 | // Graphite: a cool neutral grey, flatter than the warmer neutrals. | 385 | // Graphite: a cool neutral grey, flatter than the warmer neutrals. |
| 474 | Base { | 386 | Base { |
| 475 | id: "graphite", | 387 | id: "graphite", |
crates/forge-web-base/src/i18n/audit_names.rsadded+536 -0
| @@ -0,0 +1,536 @@ | |||
| 1 | +//! Display names for audit log entries: the action ids, the target kinds and the detail keys that | ||
| 2 | +//! the audit log stores. An id with no name here shows its raw text, and the test below rules that | ||
| 3 | +//! out for every action id. | ||
| 4 | + | ||
| 5 | +use super::Lang; | ||
| 6 | + | ||
| 7 | +/// The display name of an audit action id, or `None` for an id this table does not know. | ||
| 8 | +pub fn action_name(lang: Lang, action: &str) -> Option<&'static str> { | ||
| 9 | + match (action, lang) { | ||
| 10 | + ("login_success", Lang::En) => Some("Signed in"), | ||
| 11 | + ("login_success", Lang::Tr) => Some("Giriş yapıldı"), | ||
| 12 | + ("login_failed", Lang::En) => Some("Sign-in failed"), | ||
| 13 | + ("login_failed", Lang::Tr) => Some("Giriş başarısız"), | ||
| 14 | + ("login_2fa_failed", Lang::En) => Some("Two-factor sign-in failed"), | ||
| 15 | + ("login_2fa_failed", Lang::Tr) => Some("İki adımlı doğrulama başarısız"), | ||
| 16 | + ("logout", Lang::En) => Some("Signed out"), | ||
| 17 | + ("logout", Lang::Tr) => Some("Çıkış yapıldı"), | ||
| 18 | + ("password_changed", Lang::En) => Some("Password changed"), | ||
| 19 | + ("password_changed", Lang::Tr) => Some("Parola değiştirildi"), | ||
| 20 | + ("email_changed", Lang::En) => Some("Email changed"), | ||
| 21 | + ("email_changed", Lang::Tr) => Some("E-posta değiştirildi"), | ||
| 22 | + ("password_reset_by_admin", Lang::En) => Some("Password reset by admin"), | ||
| 23 | + ("password_reset_by_admin", Lang::Tr) => Some("Parola yönetici tarafından sıfırlandı"), | ||
| 24 | + ("totp_enabled", Lang::En) => Some("Two-factor authentication turned on"), | ||
| 25 | + ("totp_enabled", Lang::Tr) => Some("İki adımlı doğrulama açıldı"), | ||
| 26 | + ("totp_disabled", Lang::En) => Some("Two-factor authentication turned off"), | ||
| 27 | + ("totp_disabled", Lang::Tr) => Some("İki adımlı doğrulama kapatıldı"), | ||
| 28 | + ("recovery_codes_regenerated", Lang::En) => Some("Recovery codes regenerated"), | ||
| 29 | + ("recovery_codes_regenerated", Lang::Tr) => Some("Kurtarma kodları yenilendi"), | ||
| 30 | + ("ssh_key_added", Lang::En) => Some("SSH key added"), | ||
| 31 | + ("ssh_key_added", Lang::Tr) => Some("SSH anahtarı eklendi"), | ||
| 32 | + ("ssh_key_removed", Lang::En) => Some("SSH key removed"), | ||
| 33 | + ("ssh_key_removed", Lang::Tr) => Some("SSH anahtarı kaldırıldı"), | ||
| 34 | + ("gpg_key_added", Lang::En) => Some("GPG key added"), | ||
| 35 | + ("gpg_key_added", Lang::Tr) => Some("GPG anahtarı eklendi"), | ||
| 36 | + ("gpg_key_deleted", Lang::En) => Some("GPG key deleted"), | ||
| 37 | + ("gpg_key_deleted", Lang::Tr) => Some("GPG anahtarı silindi"), | ||
| 38 | + ("token_created", Lang::En) => Some("Access token created"), | ||
| 39 | + ("token_created", Lang::Tr) => Some("Erişim belirteci oluşturuldu"), | ||
| 40 | + ("token_revoked", Lang::En) => Some("Access token revoked"), | ||
| 41 | + ("token_revoked", Lang::Tr) => Some("Erişim belirteci iptal edildi"), | ||
| 42 | + ("session_revoked", Lang::En) => Some("Session revoked"), | ||
| 43 | + ("session_revoked", Lang::Tr) => Some("Oturum sonlandırıldı"), | ||
| 44 | + ("user_created", Lang::En) => Some("User created"), | ||
| 45 | + ("user_created", Lang::Tr) => Some("Kullanıcı oluşturuldu"), | ||
| 46 | + ("username_changed", Lang::En) => Some("Username changed"), | ||
| 47 | + ("username_changed", Lang::Tr) => Some("Kullanıcı adı değiştirildi"), | ||
| 48 | + ("user_deleted", Lang::En) => Some("User deleted"), | ||
| 49 | + ("user_deleted", Lang::Tr) => Some("Kullanıcı silindi"), | ||
| 50 | + ("repo_created", Lang::En) => Some("Repository created"), | ||
| 51 | + ("repo_created", Lang::Tr) => Some("Depo oluşturuldu"), | ||
| 52 | + ("repo_deleted", Lang::En) => Some("Repository deleted"), | ||
| 53 | + ("repo_deleted", Lang::Tr) => Some("Depo silindi"), | ||
| 54 | + ("repo_renamed", Lang::En) => Some("Repository renamed"), | ||
| 55 | + ("repo_renamed", Lang::Tr) => Some("Depo yeniden adlandırıldı"), | ||
| 56 | + ("repo_transferred", Lang::En) => Some("Repository transferred"), | ||
| 57 | + ("repo_transferred", Lang::Tr) => Some("Depo devredildi"), | ||
| 58 | + ("repo_transfer_initiated", Lang::En) => Some("Repository transfer started"), | ||
| 59 | + ("repo_transfer_initiated", Lang::Tr) => Some("Depo devri başlatıldı"), | ||
| 60 | + ("repo_transfer_accepted", Lang::En) => Some("Repository transfer accepted"), | ||
| 61 | + ("repo_transfer_accepted", Lang::Tr) => Some("Depo devri kabul edildi"), | ||
| 62 | + ("repo_transfer_declined", Lang::En) => Some("Repository transfer declined"), | ||
| 63 | + ("repo_transfer_declined", Lang::Tr) => Some("Depo devri reddedildi"), | ||
| 64 | + ("repo_transfer_cancelled", Lang::En) => Some("Repository transfer cancelled"), | ||
| 65 | + ("repo_transfer_cancelled", Lang::Tr) => Some("Depo devri iptal edildi"), | ||
| 66 | + ("repo_visibility_changed", Lang::En) => Some("Repository visibility changed"), | ||
| 67 | + ("repo_visibility_changed", Lang::Tr) => Some("Depo görünürlüğü değiştirildi"), | ||
| 68 | + ("collaborator_added", Lang::En) => Some("Collaborator added"), | ||
| 69 | + ("collaborator_added", Lang::Tr) => Some("Ortak eklendi"), | ||
| 70 | + ("collaborator_removed", Lang::En) => Some("Collaborator removed"), | ||
| 71 | + ("collaborator_removed", Lang::Tr) => Some("Ortak kaldırıldı"), | ||
| 72 | + ("collaborator_role_changed", Lang::En) => Some("Collaborator role changed"), | ||
| 73 | + ("collaborator_role_changed", Lang::Tr) => Some("Ortak rolü değiştirildi"), | ||
| 74 | + ("branch_rule_created", Lang::En) => Some("Branch rule created"), | ||
| 75 | + ("branch_rule_created", Lang::Tr) => Some("Dal kuralı oluşturuldu"), | ||
| 76 | + ("branch_rule_updated", Lang::En) => Some("Branch rule updated"), | ||
| 77 | + ("branch_rule_updated", Lang::Tr) => Some("Dal kuralı güncellendi"), | ||
| 78 | + ("branch_rule_deleted", Lang::En) => Some("Branch rule deleted"), | ||
| 79 | + ("branch_rule_deleted", Lang::Tr) => Some("Dal kuralı silindi"), | ||
| 80 | + ("repo_archived", Lang::En) => Some("Repository archived"), | ||
| 81 | + ("repo_archived", Lang::Tr) => Some("Depo arşivlendi"), | ||
| 82 | + ("repo_unarchived", Lang::En) => Some("Repository unarchived"), | ||
| 83 | + ("repo_unarchived", Lang::Tr) => Some("Depo arşivden çıkarıldı"), | ||
| 84 | + ("webhook_created", Lang::En) => Some("Webhook created"), | ||
| 85 | + ("webhook_created", Lang::Tr) => Some("Web kancası oluşturuldu"), | ||
| 86 | + ("webhook_updated", Lang::En) => Some("Webhook updated"), | ||
| 87 | + ("webhook_updated", Lang::Tr) => Some("Web kancası güncellendi"), | ||
| 88 | + ("webhook_deleted", Lang::En) => Some("Webhook deleted"), | ||
| 89 | + ("webhook_deleted", Lang::Tr) => Some("Web kancası silindi"), | ||
| 90 | + ("mirror_created", Lang::En) => Some("Mirror created"), | ||
| 91 | + ("mirror_created", Lang::Tr) => Some("Yansı oluşturuldu"), | ||
| 92 | + ("mirror_updated", Lang::En) => Some("Mirror updated"), | ||
| 93 | + ("mirror_updated", Lang::Tr) => Some("Yansı güncellendi"), | ||
| 94 | + ("mirror_deleted", Lang::En) => Some("Mirror deleted"), | ||
| 95 | + ("mirror_deleted", Lang::Tr) => Some("Yansı silindi"), | ||
| 96 | + ("mirror_sync_failed", Lang::En) => Some("Mirror sync failed"), | ||
| 97 | + ("mirror_sync_failed", Lang::Tr) => Some("Yansı eşitleme başarısız"), | ||
| 98 | + ("backup_started", Lang::En) => Some("Backup started"), | ||
| 99 | + ("backup_started", Lang::Tr) => Some("Yedekleme başlatıldı"), | ||
| 100 | + ("fsck_started", Lang::En) => Some("Integrity check started"), | ||
| 101 | + ("fsck_started", Lang::Tr) => Some("Bütünlük denetimi başlatıldı"), | ||
| 102 | + ("replication_reconcile_started", Lang::En) => Some("Replication reconcile started"), | ||
| 103 | + ("replication_reconcile_started", Lang::Tr) => Some("Çoğaltma uzlaştırması başlatıldı"), | ||
| 104 | + ("ci_secret_set", Lang::En) => Some("CI secret set"), | ||
| 105 | + ("ci_secret_set", Lang::Tr) => Some("CI gizli değeri ayarlandı"), | ||
| 106 | + ("ci_secret_deleted", Lang::En) => Some("CI secret deleted"), | ||
| 107 | + ("ci_secret_deleted", Lang::Tr) => Some("CI gizli değeri silindi"), | ||
| 108 | + ("ci_runner_registered", Lang::En) => Some("CI runner registered"), | ||
| 109 | + ("ci_runner_registered", Lang::Tr) => Some("CI çalıştırıcısı kaydedildi"), | ||
| 110 | + ("ci_runner_deleted", Lang::En) => Some("CI runner deleted"), | ||
| 111 | + ("ci_runner_deleted", Lang::Tr) => Some("CI çalıştırıcısı silindi"), | ||
| 112 | + ("ci_runner_restart_requested", Lang::En) => Some("CI runner restart requested"), | ||
| 113 | + ("ci_runner_restart_requested", Lang::Tr) => { | ||
| 114 | + Some("CI çalıştırıcısının yeniden başlatılması istendi") | ||
| 115 | + } | ||
| 116 | + ("ci_runner_config_changed", Lang::En) => Some("CI runner settings changed"), | ||
| 117 | + ("ci_runner_config_changed", Lang::Tr) => Some("CI çalıştırıcısı ayarları değiştirildi"), | ||
| 118 | + ("ci_registration_token_created", Lang::En) => Some("CI registration token created"), | ||
| 119 | + ("ci_registration_token_created", Lang::Tr) => Some("CI kayıt belirteci oluşturuldu"), | ||
| 120 | + ("advisory_alert_dismissed", Lang::En) => Some("Advisory alert dismissed"), | ||
| 121 | + ("advisory_alert_dismissed", Lang::Tr) => Some("Güvenlik uyarısı kapatıldı"), | ||
| 122 | + ("advisory_alert_reopened", Lang::En) => Some("Advisory alert reopened"), | ||
| 123 | + ("advisory_alert_reopened", Lang::Tr) => Some("Güvenlik uyarısı yeniden açıldı"), | ||
| 124 | + ("ui_prefs_changed", Lang::En) => Some("Display preferences changed"), | ||
| 125 | + ("ui_prefs_changed", Lang::Tr) => Some("Görünüm tercihleri değiştirildi"), | ||
| 126 | + ("discussions_enabled", Lang::En) => Some("Discussions turned on"), | ||
| 127 | + ("discussions_enabled", Lang::Tr) => Some("Tartışmalar açıldı"), | ||
| 128 | + ("discussions_disabled", Lang::En) => Some("Discussions turned off"), | ||
| 129 | + ("discussions_disabled", Lang::Tr) => Some("Tartışmalar kapatıldı"), | ||
| 130 | + ("discussion_created", Lang::En) => Some("Discussion created"), | ||
| 131 | + ("discussion_created", Lang::Tr) => Some("Tartışma oluşturuldu"), | ||
| 132 | + ("discussion_edited", Lang::En) => Some("Discussion edited"), | ||
| 133 | + ("discussion_edited", Lang::Tr) => Some("Tartışma düzenlendi"), | ||
| 134 | + ("discussion_deleted", Lang::En) => Some("Discussion deleted"), | ||
| 135 | + ("discussion_deleted", Lang::Tr) => Some("Tartışma silindi"), | ||
| 136 | + ("discussion_locked", Lang::En) => Some("Discussion locked"), | ||
| 137 | + ("discussion_locked", Lang::Tr) => Some("Tartışma kilitlendi"), | ||
| 138 | + ("discussion_unlocked", Lang::En) => Some("Discussion unlocked"), | ||
| 139 | + ("discussion_unlocked", Lang::Tr) => Some("Tartışmanın kilidi açıldı"), | ||
| 140 | + ("discussion_answered", Lang::En) => Some("Discussion answered"), | ||
| 141 | + ("discussion_answered", Lang::Tr) => Some("Tartışma yanıtlandı"), | ||
| 142 | + ("discussion_comment_created", Lang::En) => Some("Discussion comment posted"), | ||
| 143 | + ("discussion_comment_created", Lang::Tr) => Some("Tartışmaya yorum eklendi"), | ||
| 144 | + ("discussion_comment_edited", Lang::En) => Some("Discussion comment edited"), | ||
| 145 | + ("discussion_comment_edited", Lang::Tr) => Some("Tartışma yorumu düzenlendi"), | ||
| 146 | + ("discussion_comment_deleted", Lang::En) => Some("Discussion comment deleted"), | ||
| 147 | + ("discussion_comment_deleted", Lang::Tr) => Some("Tartışma yorumu silindi"), | ||
| 148 | + ("mail_settings_updated", Lang::En) => Some("Mail settings updated"), | ||
| 149 | + ("mail_settings_updated", Lang::Tr) => Some("E-posta ayarları güncellendi"), | ||
| 150 | + ("mail_test_queued", Lang::En) => Some("Test email queued"), | ||
| 151 | + ("mail_test_queued", Lang::Tr) => Some("Deneme e-postası kuyruğa alındı"), | ||
| 152 | + ("server_settings_updated", Lang::En) => Some("Server settings updated"), | ||
| 153 | + ("server_settings_updated", Lang::Tr) => Some("Sunucu ayarları güncellendi"), | ||
| 154 | + ("server_restarted", Lang::En) => Some("Server restarted"), | ||
| 155 | + ("server_restarted", Lang::Tr) => Some("Sunucu yeniden başlatıldı"), | ||
| 156 | + ("snippet_created", Lang::En) => Some("Snippet created"), | ||
| 157 | + ("snippet_created", Lang::Tr) => Some("Parçacık oluşturuldu"), | ||
| 158 | + ("snippet_updated", Lang::En) => Some("Snippet updated"), | ||
| 159 | + ("snippet_updated", Lang::Tr) => Some("Parçacık güncellendi"), | ||
| 160 | + ("snippet_deleted", Lang::En) => Some("Snippet deleted"), | ||
| 161 | + ("snippet_deleted", Lang::Tr) => Some("Parçacık silindi"), | ||
| 162 | + ("wiki_page_saved", Lang::En) => Some("Wiki page saved"), | ||
| 163 | + ("wiki_page_saved", Lang::Tr) => Some("Wiki sayfası kaydedildi"), | ||
| 164 | + ("wiki_enabled", Lang::En) => Some("Wiki turned on"), | ||
| 165 | + ("wiki_enabled", Lang::Tr) => Some("Wiki açıldı"), | ||
| 166 | + ("wiki_disabled", Lang::En) => Some("Wiki turned off"), | ||
| 167 | + ("wiki_disabled", Lang::Tr) => Some("Wiki kapatıldı"), | ||
| 168 | + ("wiki_pushed", Lang::En) => Some("Wiki pushed"), | ||
| 169 | + ("wiki_pushed", Lang::Tr) => Some("Wiki gönderildi"), | ||
| 170 | + ("org_created", Lang::En) => Some("Organization created"), | ||
| 171 | + ("org_created", Lang::Tr) => Some("Kuruluş oluşturuldu"), | ||
| 172 | + ("org_deleted", Lang::En) => Some("Organization deleted"), | ||
| 173 | + ("org_deleted", Lang::Tr) => Some("Kuruluş silindi"), | ||
| 174 | + ("org_settings_updated", Lang::En) => Some("Organization settings updated"), | ||
| 175 | + ("org_settings_updated", Lang::Tr) => Some("Kuruluş ayarları güncellendi"), | ||
| 176 | + ("org_member_added", Lang::En) => Some("Organization member added"), | ||
| 177 | + ("org_member_added", Lang::Tr) => Some("Kuruluşa üye eklendi"), | ||
| 178 | + ("org_member_removed", Lang::En) => Some("Organization member removed"), | ||
| 179 | + ("org_member_removed", Lang::Tr) => Some("Kuruluş üyesi çıkarıldı"), | ||
| 180 | + ("org_member_role_changed", Lang::En) => Some("Organization member role changed"), | ||
| 181 | + ("org_member_role_changed", Lang::Tr) => Some("Kuruluş üyesinin rolü değiştirildi"), | ||
| 182 | + ("team_created", Lang::En) => Some("Team created"), | ||
| 183 | + ("team_created", Lang::Tr) => Some("Takım oluşturuldu"), | ||
| 184 | + ("team_updated", Lang::En) => Some("Team updated"), | ||
| 185 | + ("team_updated", Lang::Tr) => Some("Takım güncellendi"), | ||
| 186 | + ("team_deleted", Lang::En) => Some("Team deleted"), | ||
| 187 | + ("team_deleted", Lang::Tr) => Some("Takım silindi"), | ||
| 188 | + ("team_member_added", Lang::En) => Some("Team member added"), | ||
| 189 | + ("team_member_added", Lang::Tr) => Some("Takıma üye eklendi"), | ||
| 190 | + ("team_member_removed", Lang::En) => Some("Team member removed"), | ||
| 191 | + ("team_member_removed", Lang::Tr) => Some("Takım üyesi çıkarıldı"), | ||
| 192 | + ("team_repo_added", Lang::En) => Some("Repository added to team"), | ||
| 193 | + ("team_repo_added", Lang::Tr) => Some("Takıma depo eklendi"), | ||
| 194 | + ("team_repo_removed", Lang::En) => Some("Repository removed from team"), | ||
| 195 | + ("team_repo_removed", Lang::Tr) => Some("Takımdan depo çıkarıldı"), | ||
| 196 | + ("password_reset_completed", Lang::En) => Some("Password reset completed"), | ||
| 197 | + ("password_reset_completed", Lang::Tr) => Some("Parola sıfırlama tamamlandı"), | ||
| 198 | + ("email_verified", Lang::En) => Some("Email verified"), | ||
| 199 | + ("email_verified", Lang::Tr) => Some("E-posta doğrulandı"), | ||
| 200 | + ("invite_sent", Lang::En) => Some("Invite sent"), | ||
| 201 | + ("invite_sent", Lang::Tr) => Some("Davet gönderildi"), | ||
| 202 | + ("invite_accepted", Lang::En) => Some("Invite accepted"), | ||
| 203 | + ("invite_accepted", Lang::Tr) => Some("Davet kabul edildi"), | ||
| 204 | + ("user_suspended", Lang::En) => Some("User suspended"), | ||
| 205 | + ("user_suspended", Lang::Tr) => Some("Kullanıcı askıya alındı"), | ||
| 206 | + ("user_unsuspended", Lang::En) => Some("User unsuspended"), | ||
| 207 | + ("user_unsuspended", Lang::Tr) => Some("Kullanıcının askısı kaldırıldı"), | ||
| 208 | + ("admin_granted", Lang::En) => Some("Admin access granted"), | ||
| 209 | + ("admin_granted", Lang::Tr) => Some("Yönetici yetkisi verildi"), | ||
| 210 | + ("admin_revoked", Lang::En) => Some("Admin access revoked"), | ||
| 211 | + ("admin_revoked", Lang::Tr) => Some("Yönetici yetkisi alındı"), | ||
| 212 | + ("totp_disabled_by_admin", Lang::En) => { | ||
| 213 | + Some("Two-factor authentication turned off by admin") | ||
| 214 | + } | ||
| 215 | + ("totp_disabled_by_admin", Lang::Tr) => { | ||
| 216 | + Some("İki adımlı doğrulama yönetici tarafından kapatıldı") | ||
| 217 | + } | ||
| 218 | + ("passkey_added", Lang::En) => Some("Passkey added"), | ||
| 219 | + ("passkey_added", Lang::Tr) => Some("Geçiş anahtarı eklendi"), | ||
| 220 | + ("passkey_renamed", Lang::En) => Some("Passkey renamed"), | ||
| 221 | + ("passkey_renamed", Lang::Tr) => Some("Geçiş anahtarı yeniden adlandırıldı"), | ||
| 222 | + ("passkey_deleted", Lang::En) => Some("Passkey deleted"), | ||
| 223 | + ("passkey_deleted", Lang::Tr) => Some("Geçiş anahtarı silindi"), | ||
| 224 | + ("passkeys_removed_by_admin", Lang::En) => Some("Passkeys removed by admin"), | ||
| 225 | + ("passkeys_removed_by_admin", Lang::Tr) => { | ||
| 226 | + Some("Geçiş anahtarları yönetici tarafından kaldırıldı") | ||
| 227 | + } | ||
| 228 | + ("passkey_login", Lang::En) => Some("Signed in with passkey"), | ||
| 229 | + ("passkey_login", Lang::Tr) => Some("Geçiş anahtarıyla giriş yapıldı"), | ||
| 230 | + _ => None, | ||
| 231 | + } | ||
| 232 | +} | ||
| 233 | + | ||
| 234 | +/// The display name of a target kind (what an audit entry was done to), or `None` if unknown. | ||
| 235 | +pub fn target_kind_name(lang: Lang, kind: &str) -> Option<&'static str> { | ||
| 236 | + match (kind, lang) { | ||
| 237 | + ("backup", Lang::En) => Some("backup"), | ||
| 238 | + ("backup", Lang::Tr) => Some("yedek"), | ||
| 239 | + ("branch_rule", Lang::En) => Some("branch rule"), | ||
| 240 | + ("branch_rule", Lang::Tr) => Some("dal kuralı"), | ||
| 241 | + ("ci_runner", Lang::En) => Some("CI runner"), | ||
| 242 | + ("ci_runner", Lang::Tr) => Some("CI çalıştırıcısı"), | ||
| 243 | + ("ci_runner_token", Lang::En) => Some("CI runner token"), | ||
| 244 | + ("ci_runner_token", Lang::Tr) => Some("CI çalıştırıcı belirteci"), | ||
| 245 | + ("comment", Lang::En) => Some("comment"), | ||
| 246 | + ("comment", Lang::Tr) => Some("yorum"), | ||
| 247 | + ("discussion", Lang::En) => Some("discussion"), | ||
| 248 | + ("discussion", Lang::Tr) => Some("tartışma"), | ||
| 249 | + ("fsck", Lang::En) => Some("integrity check"), | ||
| 250 | + ("fsck", Lang::Tr) => Some("bütünlük denetimi"), | ||
| 251 | + ("gpg_key", Lang::En) => Some("GPG key"), | ||
| 252 | + ("gpg_key", Lang::Tr) => Some("GPG anahtarı"), | ||
| 253 | + ("invite", Lang::En) => Some("invite"), | ||
| 254 | + ("invite", Lang::Tr) => Some("davet"), | ||
| 255 | + ("issue", Lang::En) => Some("issue"), | ||
| 256 | + ("issue", Lang::Tr) => Some("sorun"), | ||
| 257 | + ("mail", Lang::En) => Some("mail"), | ||
| 258 | + ("mail", Lang::Tr) => Some("e-posta"), | ||
| 259 | + ("mirror", Lang::En) => Some("mirror"), | ||
| 260 | + ("mirror", Lang::Tr) => Some("yansı"), | ||
| 261 | + ("org", Lang::En) => Some("organization"), | ||
| 262 | + ("org", Lang::Tr) => Some("kuruluş"), | ||
| 263 | + ("replication", Lang::En) => Some("replication"), | ||
| 264 | + ("replication", Lang::Tr) => Some("çoğaltma"), | ||
| 265 | + ("repo", Lang::En) => Some("repository"), | ||
| 266 | + ("repo", Lang::Tr) => Some("depo"), | ||
| 267 | + ("server", Lang::En) => Some("server"), | ||
| 268 | + ("server", Lang::Tr) => Some("sunucu"), | ||
| 269 | + ("session", Lang::En) => Some("session"), | ||
| 270 | + ("session", Lang::Tr) => Some("oturum"), | ||
| 271 | + ("snippet", Lang::En) => Some("snippet"), | ||
| 272 | + ("snippet", Lang::Tr) => Some("parçacık"), | ||
| 273 | + ("ssh_key", Lang::En) => Some("SSH key"), | ||
| 274 | + ("ssh_key", Lang::Tr) => Some("SSH anahtarı"), | ||
| 275 | + ("team", Lang::En) => Some("team"), | ||
| 276 | + ("team", Lang::Tr) => Some("takım"), | ||
| 277 | + ("token", Lang::En) => Some("access token"), | ||
| 278 | + ("token", Lang::Tr) => Some("erişim belirteci"), | ||
| 279 | + ("user", Lang::En) => Some("user"), | ||
| 280 | + ("user", Lang::Tr) => Some("kullanıcı"), | ||
| 281 | + _ => None, | ||
| 282 | + } | ||
| 283 | +} | ||
| 284 | + | ||
| 285 | +/// The display name of a key stored in an audit entry's details, or `None` if unknown. | ||
| 286 | +pub fn detail_key_name(lang: Lang, key: &str) -> Option<&'static str> { | ||
| 287 | + match (key, lang) { | ||
| 288 | + ("user", Lang::En) => Some("user"), | ||
| 289 | + ("user", Lang::Tr) => Some("kullanıcı"), | ||
| 290 | + ("trigger", Lang::En) => Some("trigger"), | ||
| 291 | + ("trigger", Lang::Tr) => Some("tetikleyici"), | ||
| 292 | + ("to", Lang::En) => Some("to"), | ||
| 293 | + ("to", Lang::Tr) => Some("hedef"), | ||
| 294 | + ("name", Lang::En) => Some("name"), | ||
| 295 | + ("name", Lang::Tr) => Some("ad"), | ||
| 296 | + ("from", Lang::En) => Some("from"), | ||
| 297 | + ("from", Lang::Tr) => Some("kaynak"), | ||
| 298 | + ("role", Lang::En) => Some("role"), | ||
| 299 | + ("role", Lang::Tr) => Some("rol"), | ||
| 300 | + ("mirror_id", Lang::En) => Some("mirror"), | ||
| 301 | + ("mirror_id", Lang::Tr) => Some("yansı"), | ||
| 302 | + ("direction", Lang::En) => Some("direction"), | ||
| 303 | + ("direction", Lang::Tr) => Some("yön"), | ||
| 304 | + ("url", Lang::En) => Some("URL"), | ||
| 305 | + ("url", Lang::Tr) => Some("URL"), | ||
| 306 | + ("reason", Lang::En) => Some("reason"), | ||
| 307 | + ("reason", Lang::Tr) => Some("neden"), | ||
| 308 | + ("hook_id", Lang::En) => Some("webhook"), | ||
| 309 | + ("hook_id", Lang::Tr) => Some("web kancası"), | ||
| 310 | + ("admin", Lang::En) => Some("admin"), | ||
| 311 | + ("admin", Lang::Tr) => Some("yönetici"), | ||
| 312 | + ("theme", Lang::En) => Some("theme"), | ||
| 313 | + ("theme", Lang::Tr) => Some("tema"), | ||
| 314 | + ("set", Lang::En) => Some("set"), | ||
| 315 | + ("set", Lang::Tr) => Some("ayarlanan"), | ||
| 316 | + ("cleared", Lang::En) => Some("cleared"), | ||
| 317 | + ("cleared", Lang::Tr) => Some("temizlenen"), | ||
| 318 | + ("reset", Lang::En) => Some("reset"), | ||
| 319 | + ("reset", Lang::Tr) => Some("sıfırlanan"), | ||
| 320 | + ("runner_id", Lang::En) => Some("runner"), | ||
| 321 | + ("runner_id", Lang::Tr) => Some("çalıştırıcı"), | ||
| 322 | + ("repo_id", Lang::En) => Some("repository"), | ||
| 323 | + ("repo_id", Lang::Tr) => Some("depo"), | ||
| 324 | + ("reassigned_to", Lang::En) => Some("reassigned to"), | ||
| 325 | + ("reassigned_to", Lang::Tr) => Some("devredilen"), | ||
| 326 | + ("language", Lang::En) => Some("language"), | ||
| 327 | + ("language", Lang::Tr) => Some("dil"), | ||
| 328 | + ("full", Lang::En) => Some("full"), | ||
| 329 | + ("full", Lang::Tr) => Some("tam"), | ||
| 330 | + ("field", Lang::En) => Some("field"), | ||
| 331 | + ("field", Lang::Tr) => Some("alan"), | ||
| 332 | + ("avatar", Lang::En) => Some("avatar"), | ||
| 333 | + ("avatar", Lang::Tr) => Some("profil resmi"), | ||
| 334 | + ("updates", Lang::En) => Some("updates"), | ||
| 335 | + ("updates", Lang::Tr) => Some("güncellemeler"), | ||
| 336 | + ("ttl_hours", Lang::En) => Some("valid for hours"), | ||
| 337 | + ("ttl_hours", Lang::Tr) => Some("geçerlilik (saat)"), | ||
| 338 | + ("setup", Lang::En) => Some("setup"), | ||
| 339 | + ("setup", Lang::Tr) => Some("kurulum"), | ||
| 340 | + ("self_service", Lang::En) => Some("self-service"), | ||
| 341 | + ("self_service", Lang::Tr) => Some("kendi kendine"), | ||
| 342 | + ("self", Lang::En) => Some("self"), | ||
| 343 | + ("self", Lang::Tr) => Some("kendisi"), | ||
| 344 | + ("second_factor", Lang::En) => Some("second factor"), | ||
| 345 | + ("second_factor", Lang::Tr) => Some("ikinci adım"), | ||
| 346 | + ("register", Lang::En) => Some("register"), | ||
| 347 | + ("register", Lang::Tr) => Some("kayıt"), | ||
| 348 | + ("port", Lang::En) => Some("port"), | ||
| 349 | + ("port", Lang::Tr) => Some("bağlantı noktası"), | ||
| 350 | + ("page", Lang::En) => Some("page"), | ||
| 351 | + ("page", Lang::Tr) => Some("sayfa"), | ||
| 352 | + ("others", Lang::En) => Some("others"), | ||
| 353 | + ("others", Lang::Tr) => Some("diğerleri"), | ||
| 354 | + ("org", Lang::En) => Some("organization"), | ||
| 355 | + ("org", Lang::Tr) => Some("kuruluş"), | ||
| 356 | + ("mode", Lang::En) => Some("mode"), | ||
| 357 | + ("mode", Lang::Tr) => Some("mod"), | ||
| 358 | + ("members_can_create_repos", Lang::En) => Some("members can create repositories"), | ||
| 359 | + ("members_can_create_repos", Lang::Tr) => Some("üyeler depo oluşturabilir"), | ||
| 360 | + ("invite", Lang::En) => Some("invite"), | ||
| 361 | + ("invite", Lang::Tr) => Some("davet"), | ||
| 362 | + ("import", Lang::En) => Some("import"), | ||
| 363 | + ("import", Lang::Tr) => Some("içe aktarma"), | ||
| 364 | + ("host", Lang::En) => Some("host"), | ||
| 365 | + ("host", Lang::Tr) => Some("sunucu adresi"), | ||
| 366 | + ("fork_of", Lang::En) => Some("fork of"), | ||
| 367 | + ("fork_of", Lang::Tr) => Some("çatal kaynağı"), | ||
| 368 | + ("enabled", Lang::En) => Some("enabled"), | ||
| 369 | + ("enabled", Lang::Tr) => Some("açık"), | ||
| 370 | + ("ecosystem", Lang::En) => Some("ecosystem"), | ||
| 371 | + ("ecosystem", Lang::Tr) => Some("ekosistem"), | ||
| 372 | + ("default_repo_role", Lang::En) => Some("default repository role"), | ||
| 373 | + ("default_repo_role", Lang::Tr) => Some("varsayılan depo rolü"), | ||
| 374 | + ("commit", Lang::En) => Some("commit"), | ||
| 375 | + ("commit", Lang::Tr) => Some("commit"), | ||
| 376 | + ("boot_id", Lang::En) => Some("boot ID"), | ||
| 377 | + ("boot_id", Lang::Tr) => Some("açılış kimliği"), | ||
| 378 | + ("all_repos", Lang::En) => Some("all repositories"), | ||
| 379 | + ("all_repos", Lang::Tr) => Some("tüm depolar"), | ||
| 380 | + ("advisory", Lang::En) => Some("advisory"), | ||
| 381 | + ("advisory", Lang::Tr) => Some("güvenlik uyarısı"), | ||
| 382 | + ("version", Lang::En) => Some("version"), | ||
| 383 | + ("version", Lang::Tr) => Some("sürüm"), | ||
| 384 | + ("security", Lang::En) => Some("security"), | ||
| 385 | + ("security", Lang::Tr) => Some("güvenlik"), | ||
| 386 | + ("secret_changed", Lang::En) => Some("secret changed"), | ||
| 387 | + ("secret_changed", Lang::Tr) => Some("gizli değer değişti"), | ||
| 388 | + ("secret_cleared", Lang::En) => Some("secret cleared"), | ||
| 389 | + ("secret_cleared", Lang::Tr) => Some("gizli değer temizlendi"), | ||
| 390 | + ("password_changed", Lang::En) => Some("password changed"), | ||
| 391 | + ("password_changed", Lang::Tr) => Some("parola değiştirildi"), | ||
| 392 | + ("package", Lang::En) => Some("package"), | ||
| 393 | + ("package", Lang::Tr) => Some("paket"), | ||
| 394 | + ("user_ids", Lang::En) => Some("users"), | ||
| 395 | + ("user_ids", Lang::Tr) => Some("kullanıcılar"), | ||
| 396 | + ("base_light", Lang::En) => Some("light base"), | ||
| 397 | + ("base_light", Lang::Tr) => Some("açık taban"), | ||
| 398 | + ("base_dark", Lang::En) => Some("dark base"), | ||
| 399 | + ("base_dark", Lang::Tr) => Some("koyu taban"), | ||
| 400 | + ("accent_light", Lang::En) => Some("light accent"), | ||
| 401 | + ("accent_light", Lang::Tr) => Some("açık vurgu"), | ||
| 402 | + ("accent_dark", Lang::En) => Some("dark accent"), | ||
| 403 | + ("accent_dark", Lang::Tr) => Some("koyu vurgu"), | ||
| 404 | + ("passkey", Lang::En) => Some("passkey"), | ||
| 405 | + ("passkey", Lang::Tr) => Some("geçiş anahtarı"), | ||
| 406 | + ("ok", Lang::En) => Some("ok"), | ||
| 407 | + ("ok", Lang::Tr) => Some("tamam"), | ||
| 408 | + ("next", Lang::En) => Some("next"), | ||
| 409 | + ("next", Lang::Tr) => Some("sonraki"), | ||
| 410 | + _ => None, | ||
| 411 | + } | ||
| 412 | +} | ||
| 413 | + | ||
| 414 | +#[cfg(test)] | ||
| 415 | +mod tests { | ||
| 416 | + use super::*; | ||
| 417 | + | ||
| 418 | + const ACTION_IDS: &[&str] = &[ | ||
| 419 | + "login_success", | ||
| 420 | + "login_failed", | ||
| 421 | + "login_2fa_failed", | ||
| 422 | + "logout", | ||
| 423 | + "password_changed", | ||
| 424 | + "email_changed", | ||
| 425 | + "password_reset_by_admin", | ||
| 426 | + "totp_enabled", | ||
| 427 | + "totp_disabled", | ||
| 428 | + "recovery_codes_regenerated", | ||
| 429 | + "ssh_key_added", | ||
| 430 | + "ssh_key_removed", | ||
| 431 | + "gpg_key_added", | ||
| 432 | + "gpg_key_deleted", | ||
| 433 | + "token_created", | ||
| 434 | + "token_revoked", | ||
| 435 | + "session_revoked", | ||
| 436 | + "user_created", | ||
| 437 | + "username_changed", | ||
| 438 | + "user_deleted", | ||
| 439 | + "repo_created", | ||
| 440 | + "repo_deleted", | ||
| 441 | + "repo_renamed", | ||
| 442 | + "repo_transferred", | ||
| 443 | + "repo_transfer_initiated", | ||
| 444 | + "repo_transfer_accepted", | ||
| 445 | + "repo_transfer_declined", | ||
| 446 | + "repo_transfer_cancelled", | ||
| 447 | + "repo_visibility_changed", | ||
| 448 | + "collaborator_added", | ||
| 449 | + "collaborator_removed", | ||
| 450 | + "collaborator_role_changed", | ||
| 451 | + "branch_rule_created", | ||
| 452 | + "branch_rule_updated", | ||
| 453 | + "branch_rule_deleted", | ||
| 454 | + "repo_archived", | ||
| 455 | + "repo_unarchived", | ||
| 456 | + "webhook_created", | ||
| 457 | + "webhook_updated", | ||
| 458 | + "webhook_deleted", | ||
| 459 | + "mirror_created", | ||
| 460 | + "mirror_updated", | ||
| 461 | + "mirror_deleted", | ||
| 462 | + "mirror_sync_failed", | ||
| 463 | + "backup_started", | ||
| 464 | + "fsck_started", | ||
| 465 | + "replication_reconcile_started", | ||
| 466 | + "ci_secret_set", | ||
| 467 | + "ci_secret_deleted", | ||
| 468 | + "ci_runner_registered", | ||
| 469 | + "ci_runner_deleted", | ||
| 470 | + "ci_runner_restart_requested", | ||
| 471 | + "ci_runner_config_changed", | ||
| 472 | + "ci_registration_token_created", | ||
| 473 | + "advisory_alert_dismissed", | ||
| 474 | + "advisory_alert_reopened", | ||
| 475 | + "ui_prefs_changed", | ||
| 476 | + "discussions_enabled", | ||
| 477 | + "discussions_disabled", | ||
| 478 | + "discussion_created", | ||
| 479 | + "discussion_edited", | ||
| 480 | + "discussion_deleted", | ||
| 481 | + "discussion_locked", | ||
| 482 | + "discussion_unlocked", | ||
| 483 | + "discussion_answered", | ||
| 484 | + "discussion_comment_created", | ||
| 485 | + "discussion_comment_edited", | ||
| 486 | + "discussion_comment_deleted", | ||
| 487 | + "mail_settings_updated", | ||
| 488 | + "mail_test_queued", | ||
| 489 | + "server_settings_updated", | ||
| 490 | + "server_restarted", | ||
| 491 | + "snippet_created", | ||
| 492 | + "snippet_updated", | ||
| 493 | + "snippet_deleted", | ||
| 494 | + "wiki_page_saved", | ||
| 495 | + "wiki_enabled", | ||
| 496 | + "wiki_disabled", | ||
| 497 | + "wiki_pushed", | ||
| 498 | + "org_created", | ||
| 499 | + "org_deleted", | ||
| 500 | + "org_settings_updated", | ||
| 501 | + "org_member_added", | ||
| 502 | + "org_member_removed", | ||
| 503 | + "org_member_role_changed", | ||
| 504 | + "team_created", | ||
| 505 | + "team_updated", | ||
| 506 | + "team_deleted", | ||
| 507 | + "team_member_added", | ||
| 508 | + "team_member_removed", | ||
| 509 | + "team_repo_added", | ||
| 510 | + "team_repo_removed", | ||
| 511 | + "password_reset_completed", | ||
| 512 | + "email_verified", | ||
| 513 | + "invite_sent", | ||
| 514 | + "invite_accepted", | ||
| 515 | + "user_suspended", | ||
| 516 | + "user_unsuspended", | ||
| 517 | + "admin_granted", | ||
| 518 | + "admin_revoked", | ||
| 519 | + "totp_disabled_by_admin", | ||
| 520 | + "passkey_added", | ||
| 521 | + "passkey_renamed", | ||
| 522 | + "passkey_deleted", | ||
| 523 | + "passkeys_removed_by_admin", | ||
| 524 | + "passkey_login", | ||
| 525 | + ]; | ||
| 526 | + | ||
| 527 | + #[test] | ||
| 528 | + fn every_action_has_both_names() { | ||
| 529 | + for id in ACTION_IDS { | ||
| 530 | + assert!( | ||
| 531 | + action_name(Lang::En, id).is_some() && action_name(Lang::Tr, id).is_some(), | ||
| 532 | + "{id}" | ||
| 533 | + ); | ||
| 534 | + } | ||
| 535 | + } | ||
| 536 | +} | ||
crates/forge-web-base/src/i18n/issues.rsmodified+4 -4
| @@ -675,18 +675,18 @@ pub fn history_what(lang: Lang, pull: bool, target_kind: &str) -> &'static str { | |||
| 675 | } | 675 | } |
| 676 | } | 676 | } |
| 677 | 677 | ||
| 678 | -/// The history page title: `Edit history of a {what} · {suffix}`. | 678 | +/// The history page title: `Edit history of the {what} · {suffix}`. |
| 679 | pub fn history_title(lang: Lang, what: &str, suffix: &str) -> String { | 679 | pub fn history_title(lang: Lang, what: &str, suffix: &str) -> String { |
| 680 | match lang { | 680 | match lang { |
| 681 | - Lang::En => format!("Edit history of a {what} \u{b7} {suffix}"), | 681 | + Lang::En => format!("Edit history of the {what} \u{b7} {suffix}"), |
| 682 | Lang::Tr => format!("Düzenleme geçmişi: {what} \u{b7} {suffix}"), | 682 | Lang::Tr => format!("Düzenleme geçmişi: {what} \u{b7} {suffix}"), |
| 683 | } | 683 | } |
| 684 | } | 684 | } |
| 685 | 685 | ||
| 686 | -/// The history page heading: `Edit history of {what}`. | 686 | +/// The history page heading: `Edit history of the {what}`. |
| 687 | pub fn history_heading(lang: Lang, what: &str) -> String { | 687 | pub fn history_heading(lang: Lang, what: &str) -> String { |
| 688 | match lang { | 688 | match lang { |
| 689 | - Lang::En => format!("Edit history of {what}"), | 689 | + Lang::En => format!("Edit history of the {what}"), |
| 690 | Lang::Tr => format!("Düzenleme geçmişi: {what}"), | 690 | Lang::Tr => format!("Düzenleme geçmişi: {what}"), |
| 691 | } | 691 | } |
| 692 | } | 692 | } |
crates/forge-web-base/src/i18n/mod.rsmodified+3 -2
| @@ -21,6 +21,7 @@ pub mod accents; | |||
| 21 | pub mod accounts; | 21 | pub mod accounts; |
| 22 | pub mod admin; | 22 | pub mod admin; |
| 23 | pub mod alerts; | 23 | pub mod alerts; |
| 24 | +pub mod audit_names; | ||
| 24 | pub mod authoring; | 25 | pub mod authoring; |
| 25 | pub mod browse; | 26 | pub mod browse; |
| 26 | pub mod code; | 27 | pub mod code; |
| @@ -906,8 +907,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 906 | (Added, Tr) => "eklendi", | 907 | (Added, Tr) => "eklendi", |
| 907 | (LastUsed, En) => "last used", | 908 | (LastUsed, En) => "last used", |
| 908 | (LastUsed, Tr) => "son kullanım", | 909 | (LastUsed, Tr) => "son kullanım", |
| 909 | - (Created, En) => "Created", | 910 | + (Created, En) => "created", |
| 910 | - (Created, Tr) => "Oluşturuldu", | 911 | + (Created, Tr) => "oluşturma", |
| 911 | (SignedIn, En) => "Signed in", | 912 | (SignedIn, En) => "Signed in", |
| 912 | (SignedIn, Tr) => "Giriş", | 913 | (SignedIn, Tr) => "Giriş", |
| 913 | (LastSeen, En) => "last seen", | 914 | (LastSeen, En) => "last seen", |
crates/forge-web/src/pages/admin_mail.rsmodified+13 -18
| @@ -309,28 +309,23 @@ async fn mail_view( | |||
| 309 | } else { | 309 | } else { |
| 310 | <div> | 310 | <div> |
| 311 | for row in queue.rows.into_iter() { | 311 | for row in queue.rows.into_iter() { |
| 312 | - <details class="row-open"> | 312 | + <div class="line"> |
| 313 | - <summary class="line"> | 313 | + <span class="name">(row.subject.as_str())</span> |
| 314 | - <span class="name">(row.subject.as_str())</span> | 314 | + <span class="val">(row.to.as_str()) " · " (row.kind) " · " <span class=(row.state_class)>(row.state)</span> |
| 315 | - <span class="val">(row.to.as_str()) " · " (row.kind) " · " <span class=(row.state_class)>(row.state)</span></span> | 315 | + " · " (g::t(lang, K::TableQueued)) " " rel_time(lang: lang, stamp: row.created.as_str()) |
| 316 | - </summary> | 316 | + " · " (g::t(lang, K::TableTries)) " " (row.attempts) |
| 317 | - <div class="opened"> | ||
| 318 | - <p class="hint">(g::t(lang, K::TableQueued)) " " rel_time(lang: lang, stamp: row.created.as_str())</p> | ||
| 319 | - <p class="hint">(g::t(lang, K::TableTries)) " " (row.attempts)</p> | ||
| 320 | if let Some(sent) = row.sent.as_deref() { | 317 | if let Some(sent) = row.sent.as_deref() { |
| 321 | - <p class="hint">(g::t(lang, K::MailSentAt)) " " rel_time(lang: lang, stamp: sent)</p> | 318 | + " · " (g::t(lang, K::MailSentAt)) " " rel_time(lang: lang, stamp: sent) |
| 322 | } | 319 | } |
| 323 | if !row.error.is_empty() { | 320 | if !row.error.is_empty() { |
| 324 | - <p class="hint">(g::t(lang, K::TableLastError)) " " (row.error.as_str())</p> | 321 | + " · " (g::t(lang, K::TableLastError)) ": " (row.error.as_str()) |
| 325 | } | 322 | } |
| 326 | - if row.failed { | 323 | + </span> |
| 327 | - <div class="acts"> | 324 | + if row.failed { |
| 328 | - post_act(label: g::t(lang, K::MailRetryNow), action: "/admin/mail/queue/retry", csrf: csrf.as_str(), fields: vec![("id".to_owned(), row.id.clone()), ("state".to_owned(), filter_param.clone())]) | 325 | + post_act(label: g::t(lang, K::MailRetryNow), action: "/admin/mail/queue/retry", csrf: csrf.as_str(), fields: vec![("id".to_owned(), row.id.clone()), ("state".to_owned(), filter_param.clone())]) |
| 329 | - confirm_act(lang: lang, label: g::t(lang, K::MailDiscard), action: "/admin/mail/queue/discard", csrf: csrf.as_str(), fields: vec![("id".to_owned(), row.id.clone()), ("state".to_owned(), filter_param.clone())], note: Some(crate::pages::passkeys::s(lang, "The message will not be sent.", "İleti gönderilmez.").to_owned())) | 326 | + confirm_act(lang: lang, label: g::t(lang, K::MailDiscard), action: "/admin/mail/queue/discard", csrf: csrf.as_str(), fields: vec![("id".to_owned(), row.id.clone()), ("state".to_owned(), filter_param.clone())], note: Some(crate::pages::passkeys::s(lang, "The message will not be sent.", "İleti gönderilmez.").to_owned())) |
| 330 | - </div> | 327 | + } |
| 331 | - } | 328 | + </div> |
| 332 | - </div> | ||
| 333 | - </details> | ||
| 334 | } | 329 | } |
| 335 | </div> | 330 | </div> |
| 336 | } | 331 | } |
crates/forge-web/src/pages/admin_user_detail.rsmodified+43 -19
| @@ -4,6 +4,7 @@ | |||
| 4 | //! like the rest of the admin area. | 4 | //! like the rest of the admin area. |
| 5 | 5 | ||
| 6 | use forge_core::names::normalize_name; | 6 | use forge_core::names::normalize_name; |
| 7 | +use forge_core::store::orgs::OrgMemberRole; | ||
| 7 | use forge_core::store::suspension::{AccountFacts, Suspension}; | 8 | use forge_core::store::suspension::{AccountFacts, Suspension}; |
| 8 | use forge_core::store::user_delete::GHOST_USERNAME; | 9 | use forge_core::store::user_delete::GHOST_USERNAME; |
| 9 | use forge_core::{AuditAction, Store, User}; | 10 | use forge_core::{AuditAction, Store, User}; |
| @@ -26,7 +27,7 @@ use crate::live::{Topic, stream_changes}; | |||
| 26 | use crate::pages::admin_users::admin_only; | 27 | use crate::pages::admin_users::admin_only; |
| 27 | use crate::pages::passkeys::s; | 28 | use crate::pages::passkeys::s; |
| 28 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| 29 | -use crate::views::parts::{confirm_act, head, post_act, reveal}; | 30 | +use crate::views::parts::{SubPart, confirm_act, head, post_act, reveal}; |
| 30 | use crate::views::{alert, enc, rel_time, rel_time_or_never, shell, user_facing_message}; | 31 | use crate::views::{alert, enc, rel_time, rel_time_or_never, shell, user_facing_message}; |
| 31 | 32 | ||
| 32 | #[query_params(error = bad_request)] | 33 | #[query_params(error = bad_request)] |
| @@ -198,12 +199,10 @@ async fn detail_body( | |||
| 198 | passkey_count | 199 | passkey_count |
| 199 | ); | 200 | ); |
| 200 | Ok(view! { | 201 | Ok(view! { |
| 201 | - head(title: target.username.as_str()) | 202 | + head(title: target.username.as_str(), |
| 203 | + <a class="button" href=(profile.as_str())>(profile_label)</a> | ||
| 204 | + ) | ||
| 202 | <div class="sheet" data-live=(live.as_str())> | 205 | <div class="sheet" data-live=(live.as_str())> |
| 203 | - <div class="sheet-tools"> | ||
| 204 | - <a class="act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> | ||
| 205 | - <a class="act" href=(profile.as_str())>(profile_label)</a> | ||
| 206 | - </div> | ||
| 207 | <p class="hint"> | 206 | <p class="hint"> |
| 208 | if !email.is_empty() { | 207 | if !email.is_empty() { |
| 209 | (email.as_str()) " · " | 208 | (email.as_str()) " · " |
| @@ -289,7 +288,7 @@ async fn detail_body( | |||
| 289 | </section> | 288 | </section> |
| 290 | if !own { | 289 | if !own { |
| 291 | <section class="sec"> | 290 | <section class="sec"> |
| 292 | - <h2>(i18n::t(lang, Key::Delete))</h2> | 291 | + <h2>(i18n::t(lang, Key::DangerZone))</h2> |
| 293 | <p class="hint">(at(lang, A::DeleteHelp))</p> | 292 | <p class="hint">(at(lang, A::DeleteHelp))</p> |
| 294 | <div class="acts"> | 293 | <div class="acts"> |
| 295 | <a class="act danger" href=(delete_href.as_str())>(i18n::t(lang, Key::Delete))</a> | 294 | <a class="act danger" href=(delete_href.as_str())>(i18n::t(lang, Key::Delete))</a> |
| @@ -300,25 +299,50 @@ async fn detail_body( | |||
| 300 | }) | 299 | }) |
| 301 | } | 300 | } |
| 302 | 301 | ||
| 303 | -/// An organization's page: its name, its member count, its profile, and its delete. An | 302 | +/// An organization's page: its name, its members with a link to each account, its profile, and its |
| 304 | -/// organization is not a person, so the delete goes through the same POST as a user's. | 303 | +/// delete. An organization is not a person, so the delete goes through the same POST as a user's. |
| 305 | #[component] | 304 | #[component] |
| 306 | -async fn org_body(lang: Lang, csrf: &str, org: User, members: usize) -> Result<impl View> { | 305 | +async fn org_body( |
| 306 | + lang: Lang, | ||
| 307 | + csrf: &str, | ||
| 308 | + org: User, | ||
| 309 | + members: Vec<(User, OrgMemberRole)>, | ||
| 310 | +) -> Result<impl View> { | ||
| 307 | let base = format!("/admin/users/{}", enc(&org.id)); | 311 | let base = format!("/admin/users/{}", enc(&org.id)); |
| 308 | let delete_action = format!("{base}/delete"); | 312 | let delete_action = format!("{base}/delete"); |
| 309 | let profile = format!("/{}", enc(&org.username)); | 313 | let profile = format!("/{}", enc(&org.username)); |
| 310 | - let members = members.to_string(); | 314 | + let count = format!("{} {}", og::t(lang, OG::Members), members.len()); |
| 311 | let profile_label = s(lang, "Open profile", "Profili aç"); | 315 | let profile_label = s(lang, "Open profile", "Profili aç"); |
| 316 | + let organization = s(lang, "Organization", "Kuruluş"); | ||
| 317 | + let owner = s(lang, "Owner", "Sahip"); | ||
| 318 | + let member = s(lang, "Member", "Üye"); | ||
| 319 | + let rows: Vec<(String, String, &str)> = members | ||
| 320 | + .into_iter() | ||
| 321 | + .map(|(user, role)| { | ||
| 322 | + let href = format!("/admin/users/{}", enc(&user.id)); | ||
| 323 | + let role = match role { | ||
| 324 | + OrgMemberRole::Owner => owner, | ||
| 325 | + OrgMemberRole::Member => member, | ||
| 326 | + }; | ||
| 327 | + (href, user.username, role) | ||
| 328 | + }) | ||
| 329 | + .collect(); | ||
| 312 | Ok(view! { | 330 | Ok(view! { |
| 313 | - head(title: org.username.as_str()) | 331 | + head(title: org.username.as_str(), sub: vec![ |
| 332 | + SubPart::text(organization), | ||
| 333 | + SubPart::text(count.as_str()), | ||
| 334 | + ], | ||
| 335 | + <a class="button" href=(profile.as_str())>(profile_label)</a> | ||
| 336 | + ) | ||
| 314 | <div class="sheet"> | 337 | <div class="sheet"> |
| 315 | - <div class="sheet-tools"> | ||
| 316 | - <a class="act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> | ||
| 317 | - <a class="act" href=(profile.as_str())>(profile_label)</a> | ||
| 318 | - </div> | ||
| 319 | - <p class="hint">(og::t(lang, OG::Members)) " " (members.as_str())</p> | ||
| 320 | <section class="sec"> | 338 | <section class="sec"> |
| 321 | - <h2>(i18n::t(lang, Key::Delete))</h2> | 339 | + <h2>(og::t(lang, OG::Members))</h2> |
| 340 | + for (href, name, role) in rows.iter() { | ||
| 341 | + <a class="line" href=(href.as_str())><span class="name">(name.as_str())</span><span class="val">(*role)</span></a> | ||
| 342 | + } | ||
| 343 | + </section> | ||
| 344 | + <section class="sec"> | ||
| 345 | + <h2>(i18n::t(lang, Key::DangerZone))</h2> | ||
| 322 | <div class="acts"> | 346 | <div class="acts"> |
| 323 | confirm_act(lang: lang, label: g::t(lang, K::DeleteOrgTitle), action: delete_action.as_str(), csrf: csrf) | 347 | confirm_act(lang: lang, label: g::t(lang, K::DeleteOrgTitle), action: delete_action.as_str(), csrf: csrf) |
| 324 | </div> | 348 | </div> |
| @@ -377,7 +401,7 @@ async fn detail_page(cx: &Cx) -> Result<impl View> { | |||
| 377 | let id = path_param_segment(cx, "user_id").to_owned(); | 401 | let id = path_param_segment(cx, "user_id").to_owned(); |
| 378 | let org = match store.user_by_id(&id).await? { | 402 | let org = match store.user_by_id(&id).await? { |
| 379 | Some(user) if user.is_org() => { | 403 | Some(user) if user.is_org() => { |
| 380 | - let members = store.org_members(&user.id).await?.len(); | 404 | + let members = store.org_members(&user.id).await?; |
| 381 | Some((user, members)) | 405 | Some((user, members)) |
| 382 | } | 406 | } |
| 383 | _ => None, | 407 | _ => None, |
crates/forge-web/src/pages/audit_log.rsmodified+244 -103
| @@ -1,9 +1,10 @@ | |||
| 1 | //! Pages: the admin audit log (`/admin/audit`, instance admins only, 404 otherwise) and a user's | 1 | //! Pages: the admin audit log (`/admin/audit`, instance admins only, 404 otherwise) and a user's |
| 2 | //! own security log (`/settings/security/log`: entries the viewer acted in, or that targeted | 2 | //! own security log (`/settings/security/log`: entries the viewer acted in, or that targeted |
| 3 | -//! them). Both list newest first, a page of rows at a time, continued with a cursor: 8 rows on the | 3 | +//! them). Both list newest first, a page of rows at a time, with numbered pages: 8 rows on the |
| 4 | //! admin page (its filter bar takes the room) and 10 in the own log, sized to fit the window. | 4 | //! admin page (its filter bar takes the room) and 10 in the own log, sized to fit the window. |
| 5 | +//! Repeats in a row (same action, actor and target) fold into one row with a count. | ||
| 5 | 6 | ||
| 6 | -use forge_core::{AuditAction, AuditCursor, AuditEntry, AuditFilter, Store}; | 7 | +use forge_core::{AuditAction, AuditEntry, AuditFilter, Store}; |
| 7 | use topcoat::Result; | 8 | use topcoat::Result; |
| 8 | use topcoat::context::{Cx, app_context}; | 9 | use topcoat::context::{Cx, app_context}; |
| 9 | use topcoat::router::response::Response; | 10 | use topcoat::router::response::Response; |
| @@ -12,12 +13,15 @@ use topcoat::view::{View, component, view}; | |||
| 12 | 13 | ||
| 13 | use crate::auth::require_user; | 14 | use crate::auth::require_user; |
| 14 | use crate::i18n::admin::{self as g, K}; | 15 | use crate::i18n::admin::{self as g, K}; |
| 15 | -use crate::i18n::{self, Lang}; | 16 | +use crate::i18n::{self, Lang, audit_names}; |
| 16 | use crate::live::{Topic, stream_changes}; | 17 | use crate::live::{Topic, stream_changes}; |
| 17 | use crate::pages::admin_users::admin_only; | 18 | use crate::pages::admin_users::admin_only; |
| 18 | use crate::pages::issues_list::list_href; | 19 | use crate::pages::issues_list::list_href; |
| 20 | +use crate::pages::passkeys::s; | ||
| 21 | +use crate::pages::settings_security::{security_rail_for, security_sub}; | ||
| 19 | use crate::state::AppState; | 22 | use crate::state::AppState; |
| 20 | -use crate::views::parts::{SubPart, head}; | 23 | +use crate::views::parts::{RailItem, SubPart, head, rail}; |
| 24 | +use crate::views::repo_list::{PageLink, pager, pager_links}; | ||
| 21 | use crate::views::{rel_time, shell}; | 25 | use crate::views::{rel_time, shell}; |
| 22 | 26 | ||
| 23 | /// Entries per page of the admin audit log, under its filter bar. | 27 | /// Entries per page of the admin audit log, under its filter bar. |
| @@ -26,21 +30,113 @@ const ADMIN_PAGE_SIZE: usize = 8; | |||
| 26 | /// Entries per page of the own security log. | 30 | /// Entries per page of the own security log. |
| 27 | const OWN_PAGE_SIZE: usize = 10; | 31 | const OWN_PAGE_SIZE: usize = 10; |
| 28 | 32 | ||
| 33 | +/// Details shorter than this show in the row; longer ones move to the line's hover title. | ||
| 34 | +const DETAILS_INLINE_CHARS: usize = 80; | ||
| 35 | + | ||
| 29 | #[query_params(error = bad_request)] | 36 | #[query_params(error = bad_request)] |
| 30 | pub(crate) struct AuditQuery { | 37 | pub(crate) struct AuditQuery { |
| 31 | action: Option<String>, | 38 | action: Option<String>, |
| 32 | actor: Option<String>, | 39 | actor: Option<String>, |
| 40 | + /// Old cursor links. Still accepted so old bookmarks load, and ignored. | ||
| 41 | + #[allow(dead_code)] | ||
| 33 | before: Option<String>, | 42 | before: Option<String>, |
| 43 | + /// The 1-based page number. Anything unreadable is page 1. | ||
| 44 | + page: Option<String>, | ||
| 34 | } | 45 | } |
| 35 | 46 | ||
| 36 | -/// One table row, already formatted for display. | 47 | +/// One table row, already formatted for display. A row can stand for several entries in a row. |
| 37 | struct RowView { | 48 | struct RowView { |
| 38 | when: String, | 49 | when: String, |
| 39 | actor: String, | 50 | actor: String, |
| 51 | + /// The action as words: "Ui prefs changed". | ||
| 52 | + name: String, | ||
| 53 | + /// The raw action, for the hover title. | ||
| 40 | action: String, | 54 | action: String, |
| 55 | + /// "kind: name", or the name alone, or empty when the entry has no target name. | ||
| 41 | target: String, | 56 | target: String, |
| 42 | ip: String, | 57 | ip: String, |
| 43 | - details: String, | 58 | + /// The details when short enough to show in the row. Empty when they are long. |
| 59 | + details_inline: String, | ||
| 60 | + /// The details when too long for the row, for the line's hover title. Empty otherwise. | ||
| 61 | + details_title: String, | ||
| 62 | + /// How many entries this row stands for. | ||
| 63 | + count: usize, | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +/// "ci_secret_set" as "CI secret set": words, with the short names in capitals. | ||
| 67 | +fn action_words(action: &str) -> String { | ||
| 68 | + let words: Vec<String> = action | ||
| 69 | + .split('_') | ||
| 70 | + .enumerate() | ||
| 71 | + .map(|(i, word)| match word { | ||
| 72 | + "ci" | "ui" | "ip" | "ssh" | "gpg" | "oci" | "totp" | "2fa" | "api" | "pat" => { | ||
| 73 | + word.to_uppercase() | ||
| 74 | + } | ||
| 75 | + _ if i == 0 => { | ||
| 76 | + let mut chars = word.chars(); | ||
| 77 | + match chars.next() { | ||
| 78 | + Some(first) => first.to_uppercase().chain(chars).collect(), | ||
| 79 | + None => String::new(), | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + _ => word.to_owned(), | ||
| 83 | + }) | ||
| 84 | + .collect(); | ||
| 85 | + words.join(" ") | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +/// A stored role ("write") in the viewer's language. | ||
| 89 | +fn role_word(lang: Lang, role: &str) -> Option<&'static str> { | ||
| 90 | + Some(match role { | ||
| 91 | + "read" => s(lang, "read", "okuma"), | ||
| 92 | + "write" => s(lang, "write", "yazma"), | ||
| 93 | + "admin" => s(lang, "admin", "yönetici"), | ||
| 94 | + "maintain" => s(lang, "maintain", "bakım"), | ||
| 95 | + "triage" => s(lang, "triage", "ön değerlendirme"), | ||
| 96 | + "owner" => s(lang, "owner", "sahip"), | ||
| 97 | + "member" => s(lang, "member", "üye"), | ||
| 98 | + _ => return None, | ||
| 99 | + }) | ||
| 100 | +} | ||
| 101 | + | ||
| 102 | +/// An action's name in the viewer's language; an action with no name yet reads as its words. | ||
| 103 | +fn action_label(lang: Lang, action: &str) -> String { | ||
| 104 | + audit_names::action_name(lang, action) | ||
| 105 | + .map(str::to_owned) | ||
| 106 | + .unwrap_or_else(|| action_words(action)) | ||
| 107 | +} | ||
| 108 | + | ||
| 109 | +/// A flat JSON object as "key value · key value" in the viewer's language, so a row reads as | ||
| 110 | +/// text. Anything else (nested values, arrays, broken JSON) stays as it was stored. | ||
| 111 | +fn details_words(lang: Lang, data: &str) -> String { | ||
| 112 | + let Ok(serde_json::Value::Object(map)) = serde_json::from_str::<serde_json::Value>(data) else { | ||
| 113 | + return data.to_owned(); | ||
| 114 | + }; | ||
| 115 | + let mut parts = Vec::with_capacity(map.len()); | ||
| 116 | + for (key, value) in map { | ||
| 117 | + let value = match value { | ||
| 118 | + serde_json::Value::String(text) => text, | ||
| 119 | + serde_json::Value::Bool(yes) => s( | ||
| 120 | + lang, | ||
| 121 | + if yes { "yes" } else { "no" }, | ||
| 122 | + if yes { "evet" } else { "hayır" }, | ||
| 123 | + ) | ||
| 124 | + .to_owned(), | ||
| 125 | + serde_json::Value::Number(_) | serde_json::Value::Null => value.to_string(), | ||
| 126 | + _ => return data.to_owned(), | ||
| 127 | + }; | ||
| 128 | + // A role is a word of the app's own, so it reads in the viewer's language too. | ||
| 129 | + let value = if key == "role" { | ||
| 130 | + role_word(lang, &value).map(str::to_owned).unwrap_or(value) | ||
| 131 | + } else { | ||
| 132 | + value | ||
| 133 | + }; | ||
| 134 | + let key = audit_names::detail_key_name(lang, &key) | ||
| 135 | + .map(str::to_owned) | ||
| 136 | + .unwrap_or_else(|| key.replace('_', " ")); | ||
| 137 | + parts.push(format!("{key} {value}")); | ||
| 138 | + } | ||
| 139 | + parts.join(" · ") | ||
| 44 | } | 140 | } |
| 45 | 141 | ||
| 46 | fn row_view(entry: &AuditEntry, lang: Lang) -> RowView { | 142 | fn row_view(entry: &AuditEntry, lang: Lang) -> RowView { |
| @@ -53,46 +149,100 @@ fn row_view(entry: &AuditEntry, lang: Lang) -> RowView { | |||
| 53 | } else { | 149 | } else { |
| 54 | entry.target_name.as_str() | 150 | entry.target_name.as_str() |
| 55 | }; | 151 | }; |
| 56 | - let target = if entry.target_kind.is_empty() { | 152 | + let target = match (entry.target_kind.is_empty(), name.is_empty()) { |
| 57 | - name.to_owned() | 153 | + (_, true) => String::new(), |
| 154 | + (true, false) => name.to_owned(), | ||
| 155 | + (false, false) => { | ||
| 156 | + let kind = audit_names::target_kind_name(lang, &entry.target_kind) | ||
| 157 | + .map(str::to_owned) | ||
| 158 | + .unwrap_or_else(|| entry.target_kind.replace('_', " ")); | ||
| 159 | + format!("{kind}: {name}") | ||
| 160 | + } | ||
| 161 | + }; | ||
| 162 | + let details = if entry.data == "{}" { | ||
| 163 | + String::new() | ||
| 164 | + } else { | ||
| 165 | + details_words(lang, &entry.data) | ||
| 166 | + }; | ||
| 167 | + let (details_inline, details_title) = if details.chars().count() < DETAILS_INLINE_CHARS { | ||
| 168 | + (details.clone(), String::new()) | ||
| 58 | } else { | 169 | } else { |
| 59 | - format!("{}: {name}", entry.target_kind) | 170 | + (String::new(), details.clone()) |
| 60 | }; | 171 | }; |
| 61 | RowView { | 172 | RowView { |
| 62 | when: entry.at.clone(), | 173 | when: entry.at.clone(), |
| 63 | actor, | 174 | actor, |
| 175 | + name: action_label(lang, entry.action.as_str()), | ||
| 64 | action: entry.action.as_str().to_owned(), | 176 | action: entry.action.as_str().to_owned(), |
| 65 | target, | 177 | target, |
| 66 | ip: entry.ip.clone(), | 178 | ip: entry.ip.clone(), |
| 67 | - details: if entry.data == "{}" { | 179 | + details_inline, |
| 68 | - String::new() | 180 | + details_title, |
| 69 | - } else { | 181 | + count: 1, |
| 70 | - entry.data.clone() | ||
| 71 | - }, | ||
| 72 | } | 182 | } |
| 73 | } | 183 | } |
| 74 | 184 | ||
| 75 | -/// One page of `size` entries, and the cursor for the page after it when there may be one. | 185 | +/// Rows for `entries` (newest first), with consecutive entries of the same action, actor and |
| 186 | +/// target folded into one row. The row keeps the newest entry's time, IP and details. | ||
| 187 | +fn fold_rows(entries: &[AuditEntry], lang: Lang) -> Vec<RowView> { | ||
| 188 | + let mut rows: Vec<(&AuditEntry, RowView)> = Vec::new(); | ||
| 189 | + for entry in entries { | ||
| 190 | + if let Some((last, row)) = rows.last_mut() { | ||
| 191 | + let same = last.action == entry.action | ||
| 192 | + && last.actor_id == entry.actor_id | ||
| 193 | + && last.actor_name == entry.actor_name | ||
| 194 | + && last.target_kind == entry.target_kind | ||
| 195 | + && last.target_id == entry.target_id | ||
| 196 | + && last.target_name == entry.target_name; | ||
| 197 | + if same { | ||
| 198 | + row.count += 1; | ||
| 199 | + continue; | ||
| 200 | + } | ||
| 201 | + } | ||
| 202 | + rows.push((entry, row_view(entry, lang))); | ||
| 203 | + } | ||
| 204 | + rows.into_iter().map(|(_, row)| row).collect() | ||
| 205 | +} | ||
| 206 | + | ||
| 207 | +/// The page the query asks for, 1-based. Anything unreadable is page 1. | ||
| 208 | +fn requested_page(query: &AuditQuery) -> u64 { | ||
| 209 | + query | ||
| 210 | + .page | ||
| 211 | + .as_deref() | ||
| 212 | + .and_then(|p| p.parse::<u64>().ok()) | ||
| 213 | + .unwrap_or(1) | ||
| 214 | + .max(1) | ||
| 215 | +} | ||
| 216 | + | ||
| 217 | +/// One page of `size` entries, and the page that was asked for, clamped to the pages there are, | ||
| 218 | +/// with the page count. | ||
| 76 | async fn fetch_page( | 219 | async fn fetch_page( |
| 77 | store: &Store, | 220 | store: &Store, |
| 78 | filter: &AuditFilter, | 221 | filter: &AuditFilter, |
| 79 | - before: Option<&str>, | 222 | + page: u64, |
| 80 | size: usize, | 223 | size: usize, |
| 81 | -) -> forge_core::Result<(Vec<AuditEntry>, Option<String>)> { | 224 | +) -> forge_core::Result<(Vec<AuditEntry>, u64, u64)> { |
| 82 | - let cursor = before.and_then(AuditCursor::decode); | 225 | + let total = store.count_audit(filter).await?; |
| 83 | - let mut entries = store | 226 | + let pages = total.div_ceil(size as u64).max(1); |
| 84 | - .list_audit(filter, cursor.as_ref(), (size + 1) as u32) | 227 | + let page = page.clamp(1, pages); |
| 85 | - .await?; | 228 | + let offset = ((page - 1) * size as u64) as u32; |
| 86 | - let more = entries.len() > size; | 229 | + let entries = store.list_audit_page(filter, offset, size as u32).await?; |
| 87 | - entries.truncate(size); | 230 | + Ok((entries, page, pages)) |
| 88 | - let next = if more { | 231 | +} |
| 89 | - entries | 232 | + |
| 90 | - .last() | 233 | +/// The numbered pager's entries and links for `page` of `pages`, under `href`'s params. |
| 91 | - .map(|entry| AuditCursor::after(entry).encode()) | 234 | +fn nav_for( |
| 92 | - } else { | 235 | + page: u64, |
| 93 | - None | 236 | + pages: u64, |
| 94 | - }; | 237 | + base: &str, |
| 95 | - Ok((entries, next)) | 238 | + params: &[(&str, &str)], |
| 239 | +) -> (Vec<PageLink>, Option<String>, Option<String>) { | ||
| 240 | + pager_links(page, pages, |n| { | ||
| 241 | + let number = n.to_string(); | ||
| 242 | + let mut all: Vec<(&str, &str)> = params.to_vec(); | ||
| 243 | + all.push(("page", number.as_str())); | ||
| 244 | + list_href(base, &all) | ||
| 245 | + }) | ||
| 96 | } | 246 | } |
| 97 | 247 | ||
| 98 | #[component] | 248 | #[component] |
| @@ -102,39 +252,28 @@ async fn audit_table(lang: Lang, rows: Vec<RowView>, show_actor: bool) -> Result | |||
| 102 | <p class="state">(g::t(lang, K::NoEntries))</p> | 252 | <p class="state">(g::t(lang, K::NoEntries))</p> |
| 103 | } else { | 253 | } else { |
| 104 | for row in rows.into_iter() { | 254 | for row in rows.into_iter() { |
| 105 | - if row.ip.is_empty() && row.details.is_empty() { | 255 | + let count = row.count.to_string(); |
| 106 | - <div class="line" data-kb-row=""> | 256 | + <div class="line" data-kb-row="" title=(row.details_title.as_str())> |
| 107 | - <span class="name"><code>(row.action.as_str())</code></span> | 257 | + <span class="name" title=(row.action.as_str())>(row.name.as_str())</span> |
| 108 | - <span class="val"> | 258 | + if row.count > 1 { |
| 109 | - rel_time(lang: lang, stamp: row.when.as_str()) | 259 | + <span class="count">"×" (count.as_str())</span> |
| 110 | - if show_actor { | 260 | + } |
| 111 | - " · " (row.actor.as_str()) | 261 | + <span class="val"> |
| 112 | - } | 262 | + rel_time(lang: lang, stamp: row.when.as_str()) |
| 263 | + if show_actor { | ||
| 264 | + " · " (row.actor.as_str()) | ||
| 265 | + } | ||
| 266 | + if !row.target.is_empty() { | ||
| 113 | " · " (row.target.as_str()) | 267 | " · " (row.target.as_str()) |
| 114 | - </span> | 268 | + } |
| 115 | - </div> | 269 | + if !row.ip.is_empty() { |
| 116 | - } else { | 270 | + " · IP " (row.ip.as_str()) |
| 117 | - <details class="row-open" data-kb-row=""> | 271 | + } |
| 118 | - <summary class="line"> | 272 | + if !row.details_inline.is_empty() { |
| 119 | - <span class="name"><code>(row.action.as_str())</code></span> | 273 | + " · " (row.details_inline.as_str()) |
| 120 | - <span class="val"> | 274 | + } |
| 121 | - rel_time(lang: lang, stamp: row.when.as_str()) | 275 | + </span> |
| 122 | - if show_actor { | 276 | + </div> |
| 123 | - " · " (row.actor.as_str()) | ||
| 124 | - } | ||
| 125 | - " · " (row.target.as_str()) | ||
| 126 | - </span> | ||
| 127 | - </summary> | ||
| 128 | - <div class="opened"> | ||
| 129 | - if !row.ip.is_empty() { | ||
| 130 | - <p class="hint">"IP " (row.ip.as_str())</p> | ||
| 131 | - } | ||
| 132 | - if !row.details.is_empty() { | ||
| 133 | - <p class="hint"><code>(row.details.as_str())</code></p> | ||
| 134 | - } | ||
| 135 | - </div> | ||
| 136 | - </details> | ||
| 137 | - } | ||
| 138 | } | 277 | } |
| 139 | } | 278 | } |
| 140 | }) | 279 | }) |
| @@ -148,8 +287,11 @@ async fn admin_audit_view( | |||
| 148 | actor: String, | 287 | actor: String, |
| 149 | notice: Option<String>, | 288 | notice: Option<String>, |
| 150 | rows: Vec<RowView>, | 289 | rows: Vec<RowView>, |
| 151 | - older_href: Option<String>, | 290 | + page: u64, |
| 291 | + pages: u64, | ||
| 292 | + nav: (Vec<PageLink>, Option<String>, Option<String>), | ||
| 152 | ) -> Result<impl View> { | 293 | ) -> Result<impl View> { |
| 294 | + let (links, prev, next) = nav; | ||
| 153 | let sub = vec![SubPart::text(g::t(lang, K::AuditIntro))]; | 295 | let sub = vec![SubPart::text(g::t(lang, K::AuditIntro))]; |
| 154 | Ok(view! { | 296 | Ok(view! { |
| 155 | head(title: g::t(lang, K::AuditLog), sub: sub) | 297 | head(title: g::t(lang, K::AuditLog), sub: sub) |
| @@ -166,7 +308,7 @@ async fn admin_audit_view( | |||
| 166 | <select name="action" data-autosubmit="true"> | 308 | <select name="action" data-autosubmit="true"> |
| 167 | <option value="" selected=(action.is_empty())>(g::t(lang, K::AllActions))</option> | 309 | <option value="" selected=(action.is_empty())>(g::t(lang, K::AllActions))</option> |
| 168 | for known in AuditAction::ALL.iter().copied() { | 310 | for known in AuditAction::ALL.iter().copied() { |
| 169 | - <option value=(known.as_str()) selected=(known.as_str() == action.as_str())>(known.as_str())</option> | 311 | + <option value=(known.as_str()) selected=(known.as_str() == action.as_str())>(action_label(lang, known.as_str()))</option> |
| 170 | } | 312 | } |
| 171 | </select> | 313 | </select> |
| 172 | </label> | 314 | </label> |
| @@ -176,11 +318,7 @@ async fn admin_audit_view( | |||
| 176 | <p class="state" role="status">(message.as_str())</p> | 318 | <p class="state" role="status">(message.as_str())</p> |
| 177 | } | 319 | } |
| 178 | audit_table(lang: lang, rows: rows, show_actor: true) | 320 | audit_table(lang: lang, rows: rows, show_actor: true) |
| 179 | - if let Some(href) = older_href { | 321 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 180 | - <div class="acts"> | ||
| 181 | - <a class="act" href=(href.as_str())>(g::t(lang, K::Older))</a> | ||
| 182 | - </div> | ||
| 183 | - } | ||
| 184 | </div> | 322 | </div> |
| 185 | }) | 323 | }) |
| 186 | } | 324 | } |
| @@ -188,19 +326,26 @@ async fn admin_audit_view( | |||
| 188 | #[component] | 326 | #[component] |
| 189 | async fn own_log_view( | 327 | async fn own_log_view( |
| 190 | lang: Lang, | 328 | lang: Lang, |
| 329 | + items: Vec<RailItem>, | ||
| 191 | rows: Vec<RowView>, | 330 | rows: Vec<RowView>, |
| 192 | - older_href: Option<String>, | 331 | + page: u64, |
| 332 | + pages: u64, | ||
| 333 | + nav: (Vec<PageLink>, Option<String>, Option<String>), | ||
| 193 | ) -> Result<impl View> { | 334 | ) -> Result<impl View> { |
| 194 | - let sub = vec![SubPart::text(g::t(lang, K::OwnLogIntro))]; | 335 | + let (links, prev, next) = nav; |
| 336 | + let sub = vec![SubPart::text(security_sub(lang))]; | ||
| 195 | Ok(view! { | 337 | Ok(view! { |
| 196 | - head(title: g::t(lang, K::SecurityLogTitle), sub: sub) | 338 | + head(title: i18n::t(lang, i18n::Key::Security), sub: sub) |
| 197 | - <div class="sheet"> | 339 | + <div class="work"> |
| 198 | - audit_table(lang: lang, rows: rows, show_actor: false) | 340 | + rail(label: i18n::t(lang, i18n::Key::Security), items: items) |
| 199 | - if let Some(href) = older_href { | 341 | + <div class="sheet"> |
| 200 | - <div class="acts"> | 342 | + <section class="sec"> |
| 201 | - <a class="act" href=(href.as_str())>(g::t(lang, K::Older))</a> | 343 | + <h2>(g::t(lang, K::SecurityLogTitle))</h2> |
| 202 | - </div> | 344 | + <p class="hint">(g::t(lang, K::OwnLogIntro))</p> |
| 203 | - } | 345 | + audit_table(lang: lang, rows: rows, show_actor: false) |
| 346 | + </section> | ||
| 347 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | ||
| 348 | + </div> | ||
| 204 | </div> | 349 | </div> |
| 205 | }) | 350 | }) |
| 206 | } | 351 | } |
| @@ -229,30 +374,26 @@ async fn admin_audit_page(cx: &Cx) -> Result<impl View> { | |||
| 229 | } | 374 | } |
| 230 | } | 375 | } |
| 231 | // An unknown action or actor matches nothing, so the notice explains the empty table. | 376 | // An unknown action or actor matches nothing, so the notice explains the empty table. |
| 232 | - let (entries, next) = if notice.is_some() { | 377 | + let (entries, page, pages) = if notice.is_some() { |
| 233 | - (Vec::new(), None) | 378 | + (Vec::new(), 1, 1) |
| 234 | } else { | 379 | } else { |
| 235 | - fetch_page(store, &filter, query.before.as_deref(), ADMIN_PAGE_SIZE).await? | 380 | + fetch_page(store, &filter, requested_page(&query), ADMIN_PAGE_SIZE).await? |
| 236 | }; | 381 | }; |
| 237 | 382 | ||
| 238 | - let rows: Vec<RowView> = entries.iter().map(|entry| row_view(entry, lang)).collect(); | 383 | + let rows = fold_rows(&entries, lang); |
| 239 | - let older_href = next.map(|cursor| { | 384 | + let nav = nav_for( |
| 240 | - list_href( | 385 | + page, |
| 241 | - "/admin/audit", | 386 | + pages, |
| 242 | - &[ | 387 | + "/admin/audit", |
| 243 | - ("action", action.as_str()), | 388 | + &[("action", action.as_str()), ("actor", actor.as_str())], |
| 244 | - ("actor", actor.as_str()), | 389 | + ); |
| 245 | - ("before", cursor.as_str()), | ||
| 246 | - ], | ||
| 247 | - ) | ||
| 248 | - }); | ||
| 249 | let live = list_href( | 390 | let live = list_href( |
| 250 | "/admin/audit/events", | 391 | "/admin/audit/events", |
| 251 | &[("action", action.as_str()), ("actor", actor.as_str())], | 392 | &[("action", action.as_str()), ("actor", actor.as_str())], |
| 252 | ); | 393 | ); |
| 253 | let title = g::t(lang, K::AuditLog); | 394 | let title = g::t(lang, K::AuditLog); |
| 254 | Ok(view! { | 395 | Ok(view! { |
| 255 | - shell(title: title, viewer: Some(&viewer), admin_audit_view(lang: lang, live: live, action: action, actor: actor, notice: notice, rows: rows, older_href: older_href)) | 396 | + shell(title: title, viewer: Some(&viewer), admin_audit_view(lang: lang, live: live, action: action, actor: actor, notice: notice, rows: rows, page: page, pages: pages, nav: nav)) |
| 256 | }) | 397 | }) |
| 257 | } | 398 | } |
| 258 | 399 | ||
| @@ -272,7 +413,7 @@ async fn first_page_fingerprint(store: &Store, action: &str, actor: &str) -> Res | |||
| 272 | None => return Ok(String::new()), | 413 | None => return Ok(String::new()), |
| 273 | } | 414 | } |
| 274 | } | 415 | } |
| 275 | - let (entries, _) = fetch_page(store, &filter, None, ADMIN_PAGE_SIZE).await?; | 416 | + let (entries, _, _) = fetch_page(store, &filter, 1, ADMIN_PAGE_SIZE).await?; |
| 276 | Ok(entries | 417 | Ok(entries |
| 277 | .iter() | 418 | .iter() |
| 278 | .map(|entry| entry.id.as_str()) | 419 | .map(|entry| entry.id.as_str()) |
| @@ -307,15 +448,15 @@ async fn own_log_page(cx: &Cx) -> Result<impl View> { | |||
| 307 | involving_user: Some(viewer.0.id.clone()), | 448 | involving_user: Some(viewer.0.id.clone()), |
| 308 | ..Default::default() | 449 | ..Default::default() |
| 309 | }; | 450 | }; |
| 310 | - let (entries, next) = | 451 | + let (entries, page, pages) = |
| 311 | - fetch_page(store, &filter, query.before.as_deref(), OWN_PAGE_SIZE).await?; | 452 | + fetch_page(store, &filter, requested_page(&query), OWN_PAGE_SIZE).await?; |
| 312 | 453 | ||
| 313 | - let rows: Vec<RowView> = entries.iter().map(|entry| row_view(entry, lang)).collect(); | 454 | + let rows = fold_rows(&entries, lang); |
| 314 | - let older_href = | 455 | + let nav = nav_for(page, pages, "/settings/security/log", &[]); |
| 315 | - next.map(|cursor| list_href("/settings/security/log", &[("before", cursor.as_str())])); | 456 | + let items = security_rail_for(app_context::<AppState>(cx), lang, &viewer, "log").await?; |
| 316 | let title = g::t(lang, K::SecurityLogTitle); | 457 | let title = g::t(lang, K::SecurityLogTitle); |
| 317 | Ok(view! { | 458 | Ok(view! { |
| 318 | - shell(title: title, viewer: Some(&viewer), own_log_view(lang: lang, rows: rows, older_href: older_href)) | 459 | + shell(title: title, viewer: Some(&viewer), own_log_view(lang: lang, items: items, rows: rows, page: page, pages: pages, nav: nav)) |
| 319 | }) | 460 | }) |
| 320 | } | 461 | } |
| 321 | 462 | ||
| @@ -477,6 +618,6 @@ mod tests { | |||
| 477 | let row = row_view(&entry, Lang::En); | 618 | let row = row_view(&entry, Lang::En); |
| 478 | assert_eq!(row.actor, "anonymous"); | 619 | assert_eq!(row.actor, "anonymous"); |
| 479 | assert_eq!(row.target, "mallory"); | 620 | assert_eq!(row.target, "mallory"); |
| 480 | - assert_eq!(row.details, ""); | 621 | + assert_eq!(row.details_inline, ""); |
| 481 | } | 622 | } |
| 482 | } | 623 | } |
crates/forge-web/src/pages/branches.rsmodified+23 -28
| @@ -143,36 +143,31 @@ async fn branch_table( | |||
| 143 | Ok(view! { | 143 | Ok(view! { |
| 144 | <div> | 144 | <div> |
| 145 | for row in rows.into_iter() { | 145 | for row in rows.into_iter() { |
| 146 | - <details class="row-open" data-kb-row=""> | 146 | + <div class="line" data-kb-row=""> |
| 147 | - <summary class="line"> | 147 | + <a class="name" href=(row.href.as_str())>(row.name.as_str())</a> |
| 148 | - <a class="name" href=(row.href.as_str())>(row.name.as_str())</a> | 148 | + if row.is_default { |
| 149 | - if row.is_default { | 149 | + <span class="hint">(g::t(lang, K::DefaultBadge))</span> |
| 150 | - <span class="hint">(g::t(lang, K::DefaultBadge))</span> | 150 | + } |
| 151 | - } | 151 | + <span class="val"> |
| 152 | - <span class="val">(row.author.as_str()) " · " <time data-rel="true" datetime=(row.iso.as_str())>(row.age.as_str())</time> | ||
| 153 | - if let Some(counts) = row.counts { | ||
| 154 | - " · " (counts.as_str()) | ||
| 155 | - } else if row.up_to_date { | ||
| 156 | - " · " (b::t(lang, b::K::UpToDate)) | ||
| 157 | - } | ||
| 158 | - </span> | ||
| 159 | - </summary> | ||
| 160 | - <div class="opened"> | ||
| 161 | if let Some(last) = row.last { | 152 | if let Some(last) = row.last { |
| 162 | - <p><a href=(last.href.as_str())>commit_line(subject: last.summary.clone())</a></p> | 153 | + <a href=(last.href.as_str())>commit_line(subject: last.summary.clone())</a> " · " |
| 154 | + } | ||
| 155 | + (row.author.as_str()) " · " <time data-rel="true" datetime=(row.iso.as_str())>(row.age.as_str())</time> | ||
| 156 | + if let Some(counts) = row.counts { | ||
| 157 | + " · " (counts.as_str()) | ||
| 158 | + } else if row.up_to_date { | ||
| 159 | + " · " (b::t(lang, b::K::UpToDate)) | ||
| 163 | } | 160 | } |
| 164 | - <div class="acts"> | 161 | + </span> |
| 165 | - if let Some(pr) = row.pr_href { | 162 | + if let Some(pr) = row.pr_href { |
| 166 | - <a class="act" href=(pr.as_str())>(b::t(lang, b::K::NewPr))</a> | 163 | + <a class="act" href=(pr.as_str())>(b::t(lang, b::K::NewPr))</a> |
| 167 | - } | 164 | + } |
| 168 | - if can_delete && !row.is_default { | 165 | + if can_delete && !row.is_default { |
| 169 | - confirm_act(lang: lang, label: b::t(lang, b::K::DeleteBranch), action: delete_action.as_str(), csrf: csrf.as_str(), | 166 | + confirm_act(lang: lang, label: b::t(lang, b::K::DeleteBranch), action: delete_action.as_str(), csrf: csrf.as_str(), |
| 170 | - fields: vec![("name".to_owned(), row.name.clone()), ("oid".to_owned(), row.oid.clone())], | 167 | + fields: vec![("name".to_owned(), row.name.clone()), ("oid".to_owned(), row.oid.clone())], |
| 171 | - note: Some(b::t(lang, b::K::DeleteConfirm).to_owned())) | 168 | + note: Some(b::t(lang, b::K::DeleteConfirm).to_owned())) |
| 172 | - } | 169 | + } |
| 173 | - </div> | 170 | + </div> |
| 174 | - </div> | ||
| 175 | - </details> | ||
| 176 | } | 171 | } |
| 177 | </div> | 172 | </div> |
| 178 | }) | 173 | }) |
crates/forge-web/src/pages/ci_job.rsmodified+6 -7
| @@ -449,7 +449,7 @@ async fn job_body( | |||
| 449 | } | 449 | } |
| 450 | </div> | 450 | </div> |
| 451 | <p class="head-sub"> | 451 | <p class="head-sub"> |
| 452 | - <a href=(job.run_href.as_str())>(g::t(lang, K::RunNumber)) " " (job.run_number)</a> | 452 | + <a href=(job.run_href.as_str())>(g::t(lang, K::RunNumber))(job.run_number)</a> |
| 453 | <span class="sep" aria-hidden="true">"·"</span> | 453 | <span class="sep" aria-hidden="true">"·"</span> |
| 454 | <span class=(job.state_class.as_str())>(job.state.as_str())</span> | 454 | <span class=(job.state_class.as_str())>(job.state.as_str())</span> |
| 455 | if !job.runner.is_empty() { | 455 | if !job.runner.is_empty() { |
| @@ -501,13 +501,10 @@ async fn job_body( | |||
| 501 | } | 501 | } |
| 502 | <pre class="ci-log ci-tl-code" data-live-log="true" data-offset=(log_offset.as_str()) data-first=(first_line.as_str())>(log.as_str())</pre> | 502 | <pre class="ci-log ci-tl-code" data-live-log="true" data-offset=(log_offset.as_str()) data-first=(first_line.as_str())>(log.as_str())</pre> |
| 503 | if !artifacts.is_empty() { | 503 | if !artifacts.is_empty() { |
| 504 | - <div class="sec"> | 504 | + <div class="ci-artifacts"> |
| 505 | <h2>(g::t(lang, K::Artifacts))</h2> | 505 | <h2>(g::t(lang, K::Artifacts))</h2> |
| 506 | for artifact in artifacts.iter() { | 506 | for artifact in artifacts.iter() { |
| 507 | - <div class="line"> | 507 | + <span><a href=(artifact.href.as_str())>(artifact.name.as_str())</a> " " <span class="val">(artifact.size.as_str())</span></span> |
| 508 | - <span class="name"><a href=(artifact.href.as_str())>(artifact.name.as_str())</a></span> | ||
| 509 | - <span class="val">(artifact.size.as_str())</span> | ||
| 510 | - </div> | ||
| 511 | } | 508 | } |
| 512 | </div> | 509 | </div> |
| 513 | } | 510 | } |
| @@ -614,8 +611,10 @@ async fn job_page(cx: &Cx) -> Result<impl View> { | |||
| 614 | let dock_owner = ctx.repo.owner_name.clone(); | 611 | let dock_owner = ctx.repo.owner_name.clone(); |
| 615 | let dock_repo = ctx.repo.name.clone(); | 612 | let dock_repo = ctx.repo.name.clone(); |
| 616 | let page_title = format!("{title} \u{b7} CI \u{b7} {}", view.name); | 613 | let page_title = format!("{title} \u{b7} CI \u{b7} {}", view.name); |
| 614 | + // The path bar shows the run the job belongs to, between CI and the job. | ||
| 615 | + let parents = vec![(format!("#{}", view.run_number), view.run_href.clone())]; | ||
| 617 | Ok(view! { | 616 | Ok(view! { |
| 618 | - shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 617 | + shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), parents: parents, |
| 619 | job_body(head: head, lang: lang, job: view, log: log, log_offset: log_offset.to_string(), first_line: first_line.to_string(), | 618 | job_body(head: head, lang: lang, job: view, log: log, log_offset: log_offset.to_string(), first_line: first_line.to_string(), |
| 620 | truncated: truncated, artifacts: artifacts, live: live, owner: dock_owner, repo: dock_repo, bars: bars)) | 619 | truncated: truncated, artifacts: artifacts, live: live, owner: dock_owner, repo: dock_repo, bars: bars)) |
| 621 | }) | 620 | }) |
crates/forge-web/src/pages/merge_queue.rsmodified+22 -26
| @@ -383,32 +383,28 @@ async fn queue_body( | |||
| 383 | } else { | 383 | } else { |
| 384 | for row in rows.iter() { | 384 | for row in rows.iter() { |
| 385 | if row.remove { | 385 | if row.remove { |
| 386 | - <details class="row-open"> | 386 | + <div class="line" data-kb-row=""> |
| 387 | - <summary class="line" data-kb-row=""> | 387 | + <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> |
| 388 | - <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> | 388 | + <span class="val"> |
| 389 | - <span class="val"> | 389 | + if !row.position.is_empty() { |
| 390 | - if !row.position.is_empty() { | 390 | + (g::t(lang, K::QueueColPosition)) " " (row.position.as_str()) " · " |
| 391 | - (g::t(lang, K::QueueColPosition)) " " (row.position.as_str()) " · " | 391 | + } |
| 392 | - } | 392 | + <span class=(row.state_class)>(row.state)</span> |
| 393 | - <span class=(row.state_class)>(row.state)</span> | 393 | + " · " <code>(row.branch.as_str())</code> |
| 394 | - " · " <code>(row.branch.as_str())</code> | 394 | + " · " (row.by.as_str()) |
| 395 | - " · " (row.by.as_str()) | 395 | + " · " rel_time(lang: lang, stamp: row.queued_at.as_str()) |
| 396 | - " · " rel_time(lang: lang, stamp: row.queued_at.as_str()) | 396 | + " · " |
| 397 | - " · " | 397 | + if let Some(href) = row.run_href.as_ref() { |
| 398 | - if let Some(href) = row.run_href.as_ref() { | 398 | + <a href=(href.as_str())>(row.run_label.as_str())</a> |
| 399 | - <a href=(href.as_str())>(row.run_label.as_str())</a> | 399 | + } else { |
| 400 | - } else { | 400 | + <span>(row.run_label.as_str())</span> |
| 401 | - <span>(row.run_label.as_str())</span> | 401 | + } |
| 402 | - } | 402 | + if !row.reason.is_empty() { |
| 403 | - if !row.reason.is_empty() { | 403 | + " · " (row.reason.as_str()) |
| 404 | - " · " (row.reason.as_str()) | 404 | + } |
| 405 | - } | 405 | + </span> |
| 406 | - </span> | 406 | + confirm_act(lang: lang, label: remove_label, action: row.remove_action.as_str(), csrf: csrf.as_str(), note: Some(remove_note.clone())) |
| 407 | - </summary> | 407 | + </div> |
| 408 | - <div class="opened"> | ||
| 409 | - confirm_act(lang: lang, label: remove_label, action: row.remove_action.as_str(), csrf: csrf.as_str(), note: Some(remove_note.clone())) | ||
| 410 | - </div> | ||
| 411 | - </details> | ||
| 412 | } else { | 408 | } else { |
| 413 | <div class="line" data-kb-row=""> | 409 | <div class="line" data-kb-row=""> |
| 414 | <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> | 410 | <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> |
crates/forge-web/src/pages/packages_oci.rsmodified+9 -16
| @@ -151,22 +151,15 @@ pub async fn oci_package_view(page: OciPage) -> Result<impl View> { | |||
| 151 | if has_tags { | 151 | if has_tags { |
| 152 | <div> | 152 | <div> |
| 153 | for (tag, short, full, size, created) in rows.iter() { | 153 | for (tag, short, full, size, created) in rows.iter() { |
| 154 | - <details class="row-open" data-kb-row=""> | 154 | + <div class="line" data-kb-row=""> |
| 155 | - <summary class="line"> | 155 | + <span class="name"><code>(tag.as_str())</code></span> |
| 156 | - <span class="name"><code>(tag.as_str())</code></span> | 156 | + <span class="val"><code>(short.as_str())</code> " · " (size.as_str()) " · " rel_time(lang: lang, stamp: created.as_str()) " · " <code>(full.as_str())</code></span> |
| 157 | - <span class="val"><code>(short.as_str())</code> " · " (size.as_str()) " · " rel_time(lang: lang, stamp: created.as_str())</span> | 157 | + if can_delete { |
| 158 | - </summary> | 158 | + confirm_act(lang: lang, label: pk::t(lang, K::DeleteTag), action: delete_action.as_str(), csrf: csrf.as_str(), |
| 159 | - <div class="opened"> | 159 | + fields: vec![("package".to_owned(), package.name.clone()), ("tag".to_owned(), tag.clone())], |
| 160 | - <code class="hint">(full.as_str())</code> | 160 | + note: Some(pk::t(lang, K::DeleteTagMessage).to_owned())) |
| 161 | - if can_delete { | 161 | + } |
| 162 | - <div class="acts"> | 162 | + </div> |
| 163 | - confirm_act(lang: lang, label: pk::t(lang, K::DeleteTag), action: delete_action.as_str(), csrf: csrf.as_str(), | ||
| 164 | - fields: vec![("package".to_owned(), package.name.clone()), ("tag".to_owned(), tag.clone())], | ||
| 165 | - note: Some(pk::t(lang, K::DeleteTagMessage).to_owned())) | ||
| 166 | - </div> | ||
| 167 | - } | ||
| 168 | - </div> | ||
| 169 | - </details> | ||
| 170 | } | 163 | } |
| 171 | </div> | 164 | </div> |
| 172 | } else { | 165 | } else { |
crates/forge-web/src/pages/palette.rsmodified+9 -5
| @@ -77,10 +77,6 @@ const SETTINGS_TERMS: &[(&str, &[&str])] = &[ | |||
| 77 | "/settings/tokens", | 77 | "/settings/tokens", |
| 78 | &["API", "PAT", "Personal access token", "Erişim belirteci"], | 78 | &["API", "PAT", "Personal access token", "Erişim belirteci"], |
| 79 | ), | 79 | ), |
| 80 | - ( | ||
| 81 | - "/settings/sessions", | ||
| 82 | - &["Devices", "Cihazlar", "Sign out", "Logged in", "Oturumlar"], | ||
| 83 | - ), | ||
| 84 | ( | 80 | ( |
| 85 | "/settings/security", | 81 | "/settings/security", |
| 86 | &[ | 82 | &[ |
| @@ -101,6 +97,12 @@ const SETTINGS_TERMS: &[(&str, &[&str])] = &[ | |||
| 101 | "Delete account", | 97 | "Delete account", |
| 102 | "Hesabı sil", | 98 | "Hesabı sil", |
| 103 | "Security log", | 99 | "Security log", |
| 100 | + "Sessions", | ||
| 101 | + "Devices", | ||
| 102 | + "Cihazlar", | ||
| 103 | + "Sign out", | ||
| 104 | + "Logged in", | ||
| 105 | + "Oturumlar", | ||
| 104 | ], | 106 | ], |
| 105 | ), | 107 | ), |
| 106 | ( | 108 | ( |
| @@ -224,7 +226,9 @@ fn term_in_lang(term: &str, lang: Lang) -> bool { | |||
| 224 | return true; | 226 | return true; |
| 225 | } | 227 | } |
| 226 | let turkish = term.chars().any(|c| "çğıöşüÇĞİÖŞÜ".contains(c)) | 228 | let turkish = term.chars().any(|c| "çğıöşüÇĞİÖŞÜ".contains(c)) |
| 227 | - || TURKISH_WORDS.iter().any(|word| word.eq_ignore_ascii_case(term)); | 229 | + || TURKISH_WORDS |
| 230 | + .iter() | ||
| 231 | + .any(|word| word.eq_ignore_ascii_case(term)); | ||
| 228 | turkish == matches!(lang, Lang::Tr) | 232 | turkish == matches!(lang, Lang::Tr) |
| 229 | } | 233 | } |
| 230 | 234 | ||
crates/forge-web/src/pages/refs.rsmodified+7 -12
| @@ -114,18 +114,13 @@ async fn refs_table(rows: Vec<RefRow>, lang: Lang) -> Result<impl View> { | |||
| 114 | <div class="sheet"> | 114 | <div class="sheet"> |
| 115 | for row in rows.into_iter() { | 115 | for row in rows.into_iter() { |
| 116 | if let Some(last) = row.last { | 116 | if let Some(last) = row.last { |
| 117 | - <details class="row-open" data-kb-row=""> | 117 | + <div class="line" data-kb-row=""> |
| 118 | - <summary class="line"> | 118 | + <a class="name" href=(row.href)>(row.name)</a> |
| 119 | - <a class="name" href=(row.href)>(row.name)</a> | 119 | + if row.is_default { |
| 120 | - if row.is_default { | 120 | + <span class="hint">(g::t(lang, K::DefaultBadge))</span> |
| 121 | - <span class="hint">(g::t(lang, K::DefaultBadge))</span> | 121 | + } |
| 122 | - } | 122 | + <span class="val"><a href=(last.href)>commit_line(subject: last.summary.clone())</a> " · " <time datetime=(last.iso.clone()) title=(last.absolute)>(last.age)</time></span> |
| 123 | - <span class="val"><time datetime=(last.iso.clone()) title=(last.absolute)>(last.age)</time></span> | 123 | + </div> |
| 124 | - </summary> | ||
| 125 | - <div class="opened"> | ||
| 126 | - <p><a href=(last.href)>commit_line(subject: last.summary.clone())</a></p> | ||
| 127 | - </div> | ||
| 128 | - </details> | ||
| 129 | } else { | 124 | } else { |
| 130 | <div class="line" data-kb-row=""> | 125 | <div class="line" data-kb-row=""> |
| 131 | <a class="name" href=(row.href)>(row.name)</a> | 126 | <a class="name" href=(row.href)>(row.name)</a> |
crates/forge-web/src/pages/repo.rsmodified+2 -4
| @@ -34,9 +34,7 @@ use crate::pages::tree::{ | |||
| 34 | use crate::state::AppState; | 34 | use crate::state::AppState; |
| 35 | use crate::views::parts::{SubPart, head_sub}; | 35 | use crate::views::parts::{SubPart, head_sub}; |
| 36 | use crate::views::repo_list::badge_class; | 36 | use crate::views::repo_list::badge_class; |
| 37 | -use crate::views::{ | 37 | +use crate::views::{now_unix, ref_selector, relative_time, repo_href, repo_tabs, shell}; |
| 38 | - now_unix, ref_selector, relative_time, repo_href, repo_tabs, shell, | ||
| 39 | -}; | ||
| 40 | 38 | ||
| 41 | path_param!(owner); | 39 | path_param!(owner); |
| 42 | path_param!(repo); | 40 | path_param!(repo); |
| @@ -63,7 +61,7 @@ pub fn ssh_clone_url(config: &Config, owner: &str, name: &str) -> String { | |||
| 63 | } | 61 | } |
| 64 | 62 | ||
| 65 | /// The title a repo page shows when it gives none: the tab it is on. | 63 | /// The title a repo page shows when it gives none: the tab it is on. |
| 66 | -fn tab_title(lang: Lang, active: &str, repo: &str) -> String { | 64 | +pub(crate) fn tab_title(lang: Lang, active: &str, repo: &str) -> String { |
| 67 | match active { | 65 | match active { |
| 68 | "issues" => g::t(lang, K::TabIssues).to_owned(), | 66 | "issues" => g::t(lang, K::TabIssues).to_owned(), |
| 69 | "pulls" => g::t(lang, K::TabPulls).to_owned(), | 67 | "pulls" => g::t(lang, K::TabPulls).to_owned(), |
crates/forge-web/src/pages/repo_secrets.rsmodified+7 -13
| @@ -241,19 +241,13 @@ async fn secrets_body( | |||
| 241 | <span class="val">rel_time(lang: lang, stamp: row.updated_at.as_str())</span> | 241 | <span class="val">rel_time(lang: lang, stamp: row.updated_at.as_str())</span> |
| 242 | </div> | 242 | </div> |
| 243 | } else { | 243 | } else { |
| 244 | - <details class="row-open"> | 244 | + <div class="line"> |
| 245 | - <summary class="line"> | 245 | + <span class="name"><code>(row.name.as_str())</code></span> |
| 246 | - <span class="name"><code>(row.name.as_str())</code></span> | 246 | + <span class="val">rel_time(lang: lang, stamp: row.updated_at.as_str())</span> |
| 247 | - <span class="val">rel_time(lang: lang, stamp: row.updated_at.as_str())</span> | 247 | + confirm_act(lang: lang, label: g::t(lang, K::Delete), action: delete_action.as_str(), csrf: csrf.as_str(), |
| 248 | - </summary> | 248 | + fields: vec![("name".to_owned(), row.name.clone())], |
| 249 | - <div class="opened"> | 249 | + note: Some(passkeys::s(lang, "Jobs that use it fail until it is set again.", "Onu kullanan işler, yeniden ayarlanana kadar başarısız olur.").to_owned())) |
| 250 | - <div class="acts"> | 250 | + </div> |
| 251 | - confirm_act(lang: lang, label: g::t(lang, K::Delete), action: delete_action.as_str(), csrf: csrf.as_str(), | ||
| 252 | - fields: vec![("name".to_owned(), row.name.clone())], | ||
| 253 | - note: Some(passkeys::s(lang, "Jobs that use it fail until it is set again.", "Onu kullanan işler, yeniden ayarlanana kadar başarısız olur.").to_owned())) | ||
| 254 | - </div> | ||
| 255 | - </div> | ||
| 256 | - </details> | ||
| 257 | } | 251 | } |
| 258 | } | 252 | } |
| 259 | </div> | 253 | </div> |
crates/forge-web/src/pages/repo_security.rsmodified+11 -18
| @@ -136,24 +136,17 @@ async fn security_body( | |||
| 136 | } | 136 | } |
| 137 | <div> | 137 | <div> |
| 138 | for row in rows.iter() { | 138 | for row in rows.iter() { |
| 139 | - <details class="row-open" data-kb-row=""> | 139 | + <div class="line" data-kb-row=""> |
| 140 | - <summary class="line"> | 140 | + <span class="name" title=(row.summary.as_str())>(row.advisory.as_str())</span> |
| 141 | - <span class="name">(row.advisory.as_str())</span> | 141 | + <span class="val"><code>(row.package.as_str())</code> " " <code>(row.version.as_str())</code> " · " (row.severity.as_str()) " · " <span class=(row.state_class)>(row.state_text)</span> " · " rel_time(lang: lang, stamp: row.created_at.as_str())</span> |
| 142 | - <span class="val"><code>(row.package.as_str())</code> " " <code>(row.version.as_str())</code> " · " (row.severity.as_str()) " · " <span class=(row.state_class)>(row.state_text)</span> " · " rel_time(lang: lang, stamp: row.created_at.as_str())</span> | 142 | + <a class="act" href=(row.osv_href.as_str()) rel="noopener noreferrer">(crate::pages::passkeys::s(lang, "osv.dev", "osv.dev"))</a> |
| 143 | - </summary> | 143 | + if row.open { |
| 144 | - <div class="opened"> | 144 | + post_act(label: g::t(lang, K::Dismiss), action: row.dismiss_action.as_str(), csrf: csrf.as_str(), fields: row.fields.clone()) |
| 145 | - <p class="hint"><a href=(row.osv_href.as_str()) rel="noopener noreferrer">(crate::pages::passkeys::s(lang, "Details on osv.dev", "osv.dev'de ayrıntılar"))</a></p> | 145 | + } |
| 146 | - <p class="hint">(row.summary.as_str())</p> | 146 | + if row.dismissed { |
| 147 | - <div class="acts"> | 147 | + post_act(label: g::t(lang, K::Reopen), action: row.reopen_action.as_str(), csrf: csrf.as_str(), fields: row.fields.clone()) |
| 148 | - if row.open { | 148 | + } |
| 149 | - post_act(label: g::t(lang, K::Dismiss), action: row.dismiss_action.as_str(), csrf: csrf.as_str(), fields: row.fields.clone()) | 149 | + </div> |
| 150 | - } | ||
| 151 | - if row.dismissed { | ||
| 152 | - post_act(label: g::t(lang, K::Reopen), action: row.reopen_action.as_str(), csrf: csrf.as_str(), fields: row.fields.clone()) | ||
| 153 | - } | ||
| 154 | - </div> | ||
| 155 | - </div> | ||
| 156 | - </details> | ||
| 157 | } | 150 | } |
| 158 | </div> | 151 | </div> |
| 159 | </section> | 152 | </section> |
crates/forge-web/src/pages/settings_appearance.rsmodified+6 -7
| @@ -345,7 +345,7 @@ async fn colour_row(row: ColourRow) -> Result<impl View> { | |||
| 345 | <label class="colour-choice"> | 345 | <label class="colour-choice"> |
| 346 | <input type="radio" name=(field) value=(value.as_str()) checked=(stripe.custom) data-hue-custom="true" data-autosubmit="true"> | 346 | <input type="radio" name=(field) value=(value.as_str()) checked=(stripe.custom) data-hue-custom="true" data-autosubmit="true"> |
| 347 | <span class=(custom_swatch) aria-hidden="true"></span> | 347 | <span class=(custom_swatch) aria-hidden="true"></span> |
| 348 | - <span class="sr-only">(custom_label)</span> | 348 | + <span class="custom-word">(custom_label)</span> |
| 349 | </label> | 349 | </label> |
| 350 | <div class="tune"> | 350 | <div class="tune"> |
| 351 | <input type="range" class="hue-stripe" min="0" max="359" value=(hue_value.as_str()) aria-label=(hue_label) data-hue-stripe="true" data-autosubmit="true"> | 351 | <input type="range" class="hue-stripe" min="0" max="359" value=(hue_value.as_str()) aria-label=(hue_label) data-hue-stripe="true" data-autosubmit="true"> |
| @@ -735,9 +735,7 @@ mod tests { | |||
| 735 | "base: empty" | 735 | "base: empty" |
| 736 | ); | 736 | ); |
| 737 | 737 | ||
| 738 | - for id in [ | 738 | + for id in ["sage", "ocean", "plum", "rose", "ember", "hue-0", "hue-359"] { |
| 739 | - "sage", "spark", "ocean", "plum", "rose", "gold", "ember", "hue-0", "hue-359", | ||
| 740 | - ] { | ||
| 741 | assert_eq!( | 739 | assert_eq!( |
| 742 | accent_choice(Lang::En, Some(id), "sage").unwrap(), | 740 | accent_choice(Lang::En, Some(id), "sage").unwrap(), |
| 743 | id, | 741 | id, |
| @@ -748,9 +746,7 @@ mod tests { | |||
| 748 | "accent upper case {id}" | 746 | "accent upper case {id}" |
| 749 | ); | 747 | ); |
| 750 | } | 748 | } |
| 751 | - for id in [ | 749 | + for id in ["fern", "graphite", "dusk", "ink", "anvil", "hue-120"] { |
| 752 | - "fern", "spark", "graphite", "dusk", "ink", "anvil", "hue-120", | ||
| 753 | - ] { | ||
| 754 | assert_eq!( | 750 | assert_eq!( |
| 755 | base_choice(Lang::Tr, Some(id), "fern").unwrap(), | 751 | base_choice(Lang::Tr, Some(id), "fern").unwrap(), |
| 756 | id, | 752 | id, |
| @@ -766,6 +762,8 @@ mod tests { | |||
| 766 | "teal", | 762 | "teal", |
| 767 | "moss", | 763 | "moss", |
| 768 | "terracotta", | 764 | "terracotta", |
| 765 | + "spark", | ||
| 766 | + "gold", | ||
| 769 | "hue-360", | 767 | "hue-360", |
| 770 | "hue-07", | 768 | "hue-07", |
| 771 | "hue-", | 769 | "hue-", |
| @@ -782,6 +780,7 @@ mod tests { | |||
| 782 | "blush", | 780 | "blush", |
| 783 | "pine", | 781 | "pine", |
| 784 | "slate-blue", | 782 | "slate-blue", |
| 783 | + "spark", | ||
| 785 | "hue-360", | 784 | "hue-360", |
| 786 | "hue-07", | 785 | "hue-07", |
| 787 | ] { | 786 | ] { |
crates/forge-web/src/pages/settings_gpg.rsmodified+7 -14
| @@ -14,10 +14,10 @@ use topcoat::view::{View, component, view}; | |||
| 14 | use crate::audit::{self, Actor, Target}; | 14 | use crate::audit::{self, Actor, Target}; |
| 15 | use crate::auth::{require_csrf, require_user}; | 15 | use crate::auth::{require_csrf, require_user}; |
| 16 | use crate::i18n::{self, Key, Lang, t}; | 16 | use crate::i18n::{self, Key, Lang, t}; |
| 17 | -use crate::signatures; | ||
| 18 | -use crate::state::AppState; | ||
| 19 | use crate::pages::passkeys::s; | 17 | use crate::pages::passkeys::s; |
| 20 | use crate::pages::settings_keys::{AddQuery, KeyKind, KeysDraft, keys_page_view}; | 18 | use crate::pages::settings_keys::{AddQuery, KeyKind, KeysDraft, keys_page_view}; |
| 19 | +use crate::signatures; | ||
| 20 | +use crate::state::AppState; | ||
| 21 | use crate::views::parts::confirm_act; | 21 | use crate::views::parts::confirm_act; |
| 22 | use crate::views::{added_status, alert, user_facing_message}; | 22 | use crate::views::{added_status, alert, user_facing_message}; |
| 23 | 23 | ||
| @@ -75,18 +75,11 @@ pub(crate) async fn gpg_section( | |||
| 75 | <p class="state">(t(lang, Key::NoGpgKeys))</p> | 75 | <p class="state">(t(lang, Key::NoGpgKeys))</p> |
| 76 | } | 76 | } |
| 77 | for key in keys.into_iter() { | 77 | for key in keys.into_iter() { |
| 78 | - <details class="row-open"> | 78 | + <div class="line"> |
| 79 | - <summary class="line"> | 79 | + <span class="name">(key.emails.join(", "))</span> |
| 80 | - <span class="name">(key.emails.join(", "))</span> | 80 | + <span class="val"><code>(key.fingerprint.clone())</code> " · " added_status(lang: lang, added: Some(key.created_at.as_str()), used: None)</span> |
| 81 | - <span class="val">added_status(lang: lang, added: Some(key.created_at.as_str()), used: None)</span> | 81 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/gpg/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) |
| 82 | - </summary> | 82 | + </div> |
| 83 | - <div class="opened"> | ||
| 84 | - <code class="hint">(key.fingerprint.clone())</code> | ||
| 85 | - <div class="acts"> | ||
| 86 | - confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/gpg/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) | ||
| 87 | - </div> | ||
| 88 | - </div> | ||
| 89 | - </details> | ||
| 90 | } | 83 | } |
| 91 | }) | 84 | }) |
| 92 | } | 85 | } |
crates/forge-web/src/pages/settings_keys.rsmodified+20 -18
| @@ -15,10 +15,10 @@ use topcoat::view::{View, component, view}; | |||
| 15 | use crate::audit::{self, Actor, Target}; | 15 | use crate::audit::{self, Actor, Target}; |
| 16 | use crate::auth::{require_csrf, require_user}; | 16 | use crate::auth::{require_csrf, require_user}; |
| 17 | use crate::i18n::{self, Key, Lang, t, unsupported_key_type}; | 17 | use crate::i18n::{self, Key, Lang, t, unsupported_key_type}; |
| 18 | -use crate::state::AppState; | 18 | +use crate::pages::passkeys::s; |
| 19 | use crate::pages::settings_gpg::gpg_section; | 19 | use crate::pages::settings_gpg::gpg_section; |
| 20 | use crate::pages::settings_tokens::tokens_section; | 20 | use crate::pages::settings_tokens::tokens_section; |
| 21 | -use crate::pages::passkeys::s; | 21 | +use crate::state::AppState; |
| 22 | use crate::views::parts::{RailItem, SubPart, confirm_act, head, rail}; | 22 | use crate::views::parts::{RailItem, SubPart, confirm_act, head, rail}; |
| 23 | use crate::views::{added_status, alert, shell, user_facing_message}; | 23 | use crate::views::{added_status, alert, shell, user_facing_message}; |
| 24 | 24 | ||
| @@ -189,8 +189,16 @@ impl KeyKind { | |||
| 189 | fn about(self, lang: Lang) -> &'static str { | 189 | fn about(self, lang: Lang) -> &'static str { |
| 190 | match self { | 190 | match self { |
| 191 | KeyKind::Ssh => s(lang, "Push and pull over SSH", "SSH ile gönder ve çek"), | 191 | KeyKind::Ssh => s(lang, "Push and pull over SSH", "SSH ile gönder ve çek"), |
| 192 | - KeyKind::Gpg => s(lang, "Verify the commits you sign", "İmzaladığın commit'leri doğrula"), | 192 | + KeyKind::Gpg => s( |
| 193 | - KeyKind::Tokens => s(lang, "Sign in from the command line and from scripts", "Komut satırından ve betiklerden giriş yap"), | 193 | + lang, |
| 194 | + "Verify the commits you sign", | ||
| 195 | + "İmzaladığın commit'leri doğrula", | ||
| 196 | + ), | ||
| 197 | + KeyKind::Tokens => s( | ||
| 198 | + lang, | ||
| 199 | + "Sign in from the command line and from scripts", | ||
| 200 | + "Komut satırından ve betiklerden giriş yap", | ||
| 201 | + ), | ||
| 194 | } | 202 | } |
| 195 | } | 203 | } |
| 196 | } | 204 | } |
| @@ -237,8 +245,10 @@ pub(crate) async fn keys_page_view( | |||
| 237 | || draft.ssh_error.is_some() | 245 | || draft.ssh_error.is_some() |
| 238 | || draft.gpg_error.is_some() | 246 | || draft.gpg_error.is_some() |
| 239 | || draft.token_error.is_some(); | 247 | || draft.token_error.is_some(); |
| 248 | + // The path bar names the Keys tab between Settings and the kind, as every tab's page does. | ||
| 249 | + let parents = vec![(pk_title(lang).to_owned(), "/settings/keys".to_owned())]; | ||
| 240 | Ok(view! { | 250 | Ok(view! { |
| 241 | - shell(title: kind.title(lang), viewer: Some(viewer), | 251 | + shell(title: kind.title(lang), viewer: Some(viewer), parents: parents, |
| 242 | head(title: kind.title(lang), sub: sub, | 252 | head(title: kind.title(lang), sub: sub, |
| 243 | <a class="button primary" href=(add_href)>(kind.add_label(lang))</a> | 253 | <a class="button primary" href=(add_href)>(kind.add_label(lang))</a> |
| 244 | ) | 254 | ) |
| @@ -308,19 +318,11 @@ async fn ssh_section( | |||
| 308 | <p class="state">(t(lang, Key::NoSshKeys))</p> | 318 | <p class="state">(t(lang, Key::NoSshKeys))</p> |
| 309 | } | 319 | } |
| 310 | for key in keys.into_iter() { | 320 | for key in keys.into_iter() { |
| 311 | - <details class="row-open"> | 321 | + <div class="line"> |
| 312 | - <summary class="line"> | 322 | + <span class="name">(key.title.clone())</span> |
| 313 | - <span class="name">(key.title.clone())</span> | 323 | + <span class="val"><code>(key.algorithm.clone()) " " (key.fingerprint.clone())</code> " · " added_status(lang: lang, added: Some(key.created_at.as_str()), used: key.last_used_at.as_deref())</span> |
| 314 | - <span class="val mono">(key.fingerprint.chars().take(15).collect::<String>())</span> | 324 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/keys/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) |
| 315 | - <span class="val">added_status(lang: lang, added: Some(key.created_at.as_str()), used: key.last_used_at.as_deref())</span> | 325 | + </div> |
| 316 | - </summary> | ||
| 317 | - <div class="opened"> | ||
| 318 | - <code class="hint">(key.algorithm.clone()) " " (key.fingerprint.clone())</code> | ||
| 319 | - <div class="acts"> | ||
| 320 | - confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/keys/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) | ||
| 321 | - </div> | ||
| 322 | - </div> | ||
| 323 | - </details> | ||
| 324 | } | 326 | } |
| 325 | }) | 327 | }) |
| 326 | } | 328 | } |
crates/forge-web/src/pages/settings_notifications.rsmodified+11 -18
| @@ -126,24 +126,17 @@ async fn notifications_body(page: NotificationsPage) -> Result<impl View> { | |||
| 126 | <p class="state">(push_text::t(lang, push_text::K::DevicesEmpty))</p> | 126 | <p class="state">(push_text::t(lang, push_text::K::DevicesEmpty))</p> |
| 127 | } | 127 | } |
| 128 | for device in devices.into_iter() { | 128 | for device in devices.into_iter() { |
| 129 | - <details class="row-open"> | 129 | + <div class="line"> |
| 130 | - <summary class="line"> | 130 | + <span class="name">(device.agent_label.as_str())</span> |
| 131 | - <span class="name">(device.agent_label.as_str())</span> | 131 | + <span class="val">(push_text::added_label(lang)) " " rel_time(lang: lang, stamp: device.created_at.as_str()) " · " |
| 132 | - <span class="val">(push_text::added_label(lang)) " " rel_time(lang: lang, stamp: device.created_at.as_str())</span> | 132 | + if let Some(stamp) = device.last_success_at.as_deref() { |
| 133 | - </summary> | 133 | + (push_text::last_delivered_label(lang)) " " rel_time(lang: lang, stamp: stamp) |
| 134 | - <div class="opened"> | 134 | + } else { |
| 135 | - <p class="hint"> | 135 | + (push_text::t(lang, push_text::K::NeverDelivered)) |
| 136 | - if let Some(stamp) = device.last_success_at.as_deref() { | 136 | + } |
| 137 | - (push_text::last_delivered_label(lang)) " " rel_time(lang: lang, stamp: stamp) | 137 | + </span> |
| 138 | - } else { | 138 | + confirm_act(lang: lang, label: push_text::t(lang, push_text::K::RemoveDevice), action: "/settings/notifications/push/remove", csrf: csrf.as_str(), fields: vec![("id".to_owned(), device.id.clone())]) |
| 139 | - (push_text::t(lang, push_text::K::NeverDelivered)) | 139 | + </div> |
| 140 | - } | ||
| 141 | - </p> | ||
| 142 | - <div class="acts"> | ||
| 143 | - confirm_act(lang: lang, label: push_text::t(lang, push_text::K::RemoveDevice), action: "/settings/notifications/push/remove", csrf: csrf.as_str(), fields: vec![("id".to_owned(), device.id.clone())]) | ||
| 144 | - </div> | ||
| 145 | - </div> | ||
| 146 | - </details> | ||
| 147 | } | 140 | } |
| 148 | </section> | 141 | </section> |
| 149 | </div> | 142 | </div> |
crates/forge-web/src/pages/settings_security.rsmodified+192 -107
| @@ -26,9 +26,10 @@ use crate::i18n::packages::{self as pk, K as PK}; | |||
| 26 | use crate::i18n::releases_ci::{self as rc, K as RC}; | 26 | use crate::i18n::releases_ci::{self as rc, K as RC}; |
| 27 | use crate::i18n::{self, Key, Lang, password_too_long, password_too_short, t}; | 27 | use crate::i18n::{self, Key, Lang, password_too_long, password_too_short, t}; |
| 28 | use crate::pages::passkeys::{PasskeyPanel, build_panel, passkeys_panel, s}; | 28 | use crate::pages::passkeys::{PasskeyPanel, build_panel, passkeys_panel, s}; |
| 29 | +use crate::pages::settings_sessions::session_label; | ||
| 29 | use crate::state::AppState; | 30 | use crate::state::AppState; |
| 30 | use crate::throttle::{self, LOGIN_USER_LIMIT, TWO_FACTOR_USER_LIMIT}; | 31 | use crate::throttle::{self, LOGIN_USER_LIMIT, TWO_FACTOR_USER_LIMIT}; |
| 31 | -use crate::views::parts::{RailItem, SubPart, head, post_act, rail, reveal}; | 32 | +use crate::views::parts::{RailItem, SubPart, confirm_act, head, post_act, rail, reveal}; |
| 32 | use crate::views::{added_status, alert, rel_time, shell, user_facing_message}; | 33 | use crate::views::{added_status, alert, rel_time, shell, user_facing_message}; |
| 33 | 34 | ||
| 34 | /// Shortest and longest new passwords, in characters. | 35 | /// Shortest and longest new passwords, in characters. |
| @@ -186,12 +187,106 @@ struct SecurityPage { | |||
| 186 | passkeys: PasskeyPanel, | 187 | passkeys: PasskeyPanel, |
| 187 | /// Repositories still owned by the user. Deletion is refused while there are any. | 188 | /// Repositories still owned by the user. Deletion is refused while there are any. |
| 188 | owned_repos: Vec<String>, | 189 | owned_repos: Vec<String>, |
| 189 | - /// Web sessions open on the account, the count the Sessions topic shows. | 190 | + /// Web sessions open on the account, listed by the Sessions topic. |
| 190 | - session_count: usize, | 191 | + sessions: Vec<Session>, |
| 192 | + /// The id of the session that is viewing the page. | ||
| 193 | + current_session_id: String, | ||
| 191 | /// The topic asked for in the address, when no error or notice picks one. | 194 | /// The topic asked for in the address, when no error or notice picks one. |
| 192 | part: Option<String>, | 195 | part: Option<String>, |
| 193 | } | 196 | } |
| 194 | 197 | ||
| 198 | +/// The rail's kinds of security, one per topic. `active` names the topic that is shown, or | ||
| 199 | +/// "log" for the security log page, which the last item opens. | ||
| 200 | +pub(crate) fn security_rail_items( | ||
| 201 | + lang: Lang, | ||
| 202 | + active: &str, | ||
| 203 | + two_factor_on: bool, | ||
| 204 | + passkey_count: usize, | ||
| 205 | + session_count: usize, | ||
| 206 | +) -> Vec<RailItem> { | ||
| 207 | + let two_factor_val = if two_factor_on { | ||
| 208 | + t(lang, Key::PillOn) | ||
| 209 | + } else { | ||
| 210 | + t(lang, Key::PillOff) | ||
| 211 | + }; | ||
| 212 | + vec![ | ||
| 213 | + RailItem { | ||
| 214 | + name: t(lang, Key::Password).to_owned(), | ||
| 215 | + val: String::new(), | ||
| 216 | + href: "/settings/security?part=password".to_owned(), | ||
| 217 | + current: active == "password", | ||
| 218 | + }, | ||
| 219 | + RailItem { | ||
| 220 | + name: t(lang, Key::Email).to_owned(), | ||
| 221 | + val: String::new(), | ||
| 222 | + href: "/settings/security?part=email".to_owned(), | ||
| 223 | + current: active == "email", | ||
| 224 | + }, | ||
| 225 | + RailItem { | ||
| 226 | + name: t(lang, Key::TwoFactorAuth).to_owned(), | ||
| 227 | + val: two_factor_val.to_owned(), | ||
| 228 | + href: "/settings/security?part=two-factor".to_owned(), | ||
| 229 | + current: active == "two-factor", | ||
| 230 | + }, | ||
| 231 | + RailItem { | ||
| 232 | + name: s(lang, "Passkeys", "Geçiş anahtarları").to_owned(), | ||
| 233 | + val: passkey_count.to_string(), | ||
| 234 | + href: "/settings/security?part=passkeys".to_owned(), | ||
| 235 | + current: active == "passkeys", | ||
| 236 | + }, | ||
| 237 | + RailItem { | ||
| 238 | + name: t(lang, Key::Sessions).to_owned(), | ||
| 239 | + val: session_count.to_string(), | ||
| 240 | + href: "/settings/security?part=sessions".to_owned(), | ||
| 241 | + current: active == "sessions", | ||
| 242 | + }, | ||
| 243 | + RailItem { | ||
| 244 | + name: t(lang, Key::SecurityLog).to_owned(), | ||
| 245 | + val: String::new(), | ||
| 246 | + href: "/settings/security/log".to_owned(), | ||
| 247 | + current: active == "log", | ||
| 248 | + }, | ||
| 249 | + RailItem { | ||
| 250 | + name: t(lang, Key::DangerZone).to_owned(), | ||
| 251 | + val: String::new(), | ||
| 252 | + href: "/settings/security?part=danger".to_owned(), | ||
| 253 | + current: active == "danger", | ||
| 254 | + }, | ||
| 255 | + ] | ||
| 256 | +} | ||
| 257 | + | ||
| 258 | +/// The Security tab's head line, shared by the topics and the security log. | ||
| 259 | +pub(crate) fn security_sub(lang: Lang) -> &'static str { | ||
| 260 | + s( | ||
| 261 | + lang, | ||
| 262 | + "Sign-in, email, two-factor, passkeys and sessions", | ||
| 263 | + "Giriş, e-posta, iki adımlı doğrulama, geçiş anahtarları ve oturumlar", | ||
| 264 | + ) | ||
| 265 | +} | ||
| 266 | + | ||
| 267 | +/// The rail for a page outside the topics (the security log), with live counts. | ||
| 268 | +pub(crate) async fn security_rail_for( | ||
| 269 | + state: &AppState, | ||
| 270 | + lang: Lang, | ||
| 271 | + viewer: &(User, Session), | ||
| 272 | + active: &str, | ||
| 273 | +) -> forge_core::Result<Vec<RailItem>> { | ||
| 274 | + let two_factor_on = state | ||
| 275 | + .store | ||
| 276 | + .totp_state(&viewer.0.id) | ||
| 277 | + .await? | ||
| 278 | + .is_some_and(|totp| totp.enabled); | ||
| 279 | + let passkey_count = state.store.list_passkeys(&viewer.0.id).await?.len(); | ||
| 280 | + let session_count = state.store.list_sessions(&viewer.0.id).await?.len(); | ||
| 281 | + Ok(security_rail_items( | ||
| 282 | + lang, | ||
| 283 | + active, | ||
| 284 | + two_factor_on, | ||
| 285 | + passkey_count, | ||
| 286 | + session_count, | ||
| 287 | + )) | ||
| 288 | +} | ||
| 289 | + | ||
| 195 | #[component] | 290 | #[component] |
| 196 | async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { | 291 | async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { |
| 197 | let SecurityPage { | 292 | let SecurityPage { |
| @@ -213,11 +308,17 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { | |||
| 213 | delete_error, | 308 | delete_error, |
| 214 | passkeys, | 309 | passkeys, |
| 215 | owned_repos, | 310 | owned_repos, |
| 216 | - session_count, | 311 | + sessions, |
| 312 | + current_session_id, | ||
| 217 | part, | 313 | part, |
| 218 | } = page; | 314 | } = page; |
| 219 | let two_factor_on = two_factor.is_some(); | 315 | let two_factor_on = two_factor.is_some(); |
| 220 | let passkey_count = passkeys.items.len(); | 316 | let passkey_count = passkeys.items.len(); |
| 317 | + let session_count = sessions.len(); | ||
| 318 | + let others = sessions | ||
| 319 | + .iter() | ||
| 320 | + .filter(|session| session.id != current_session_id) | ||
| 321 | + .count(); | ||
| 221 | let pending_set = pending.is_some(); | 322 | let pending_set = pending.is_some(); |
| 222 | let password_open = password_error.is_some(); | 323 | let password_open = password_error.is_some(); |
| 223 | let email_open = email_error.is_some(); | 324 | let email_open = email_error.is_some(); |
| @@ -234,19 +335,25 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { | |||
| 234 | let disable_open = disable_error.is_some(); | 335 | let disable_open = disable_error.is_some(); |
| 235 | let delete_open = delete_error.is_some(); | 336 | let delete_open = delete_error.is_some(); |
| 236 | let delete_blocked = !owned_repos.is_empty(); | 337 | let delete_blocked = !owned_repos.is_empty(); |
| 237 | - let sessions_line = format!("{session_count} {}", s(lang, "active", "etkin")); | ||
| 238 | - let two_factor_val = if two_factor_on { | ||
| 239 | - t(lang, Key::PillOn) | ||
| 240 | - } else { | ||
| 241 | - t(lang, Key::PillOff) | ||
| 242 | - }; | ||
| 243 | // One topic shows at a time: the one with an error or fresh codes, else the one asked for. | 338 | // One topic shows at a time: the one with an error or fresh codes, else the one asked for. |
| 244 | - const TOPICS: [&str; 6] = ["password", "email", "two-factor", "passkeys", "sessions", "danger"]; | 339 | + const TOPICS: [&str; 6] = [ |
| 340 | + "password", | ||
| 341 | + "email", | ||
| 342 | + "two-factor", | ||
| 343 | + "passkeys", | ||
| 344 | + "sessions", | ||
| 345 | + "danger", | ||
| 346 | + ]; | ||
| 245 | let active: &'static str = if password_open { | 347 | let active: &'static str = if password_open { |
| 246 | "password" | 348 | "password" |
| 247 | } else if email_open { | 349 | } else if email_open { |
| 248 | "email" | 350 | "email" |
| 249 | - } else if regenerate_open || disable_open || setup_error.is_some() || codes.is_some() || (pending_set && part.is_none()) { | 351 | + } else if regenerate_open |
| 352 | + || disable_open | ||
| 353 | + || setup_error.is_some() | ||
| 354 | + || codes.is_some() | ||
| 355 | + || (pending_set && part.is_none()) | ||
| 356 | + { | ||
| 250 | "two-factor" | 357 | "two-factor" |
| 251 | } else if delete_open { | 358 | } else if delete_open { |
| 252 | "danger" | 359 | "danger" |
| @@ -255,47 +362,9 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { | |||
| 255 | .and_then(|asked| TOPICS.into_iter().find(|topic| *topic == asked)) | 362 | .and_then(|asked| TOPICS.into_iter().find(|topic| *topic == asked)) |
| 256 | .unwrap_or("password") | 363 | .unwrap_or("password") |
| 257 | }; | 364 | }; |
| 258 | - // The kinds of security, one per topic. Each shows its topic in the sheet. | 365 | + let items = security_rail_items(lang, active, two_factor_on, passkey_count, session_count); |
| 259 | - let items: Vec<RailItem> = vec![ | ||
| 260 | - RailItem { | ||
| 261 | - name: t(lang, Key::Password).to_owned(), | ||
| 262 | - val: String::new(), | ||
| 263 | - href: "?part=password".to_owned(), | ||
| 264 | - current: active == "password", | ||
| 265 | - }, | ||
| 266 | - RailItem { | ||
| 267 | - name: t(lang, Key::Email).to_owned(), | ||
| 268 | - val: String::new(), | ||
| 269 | - href: "?part=email".to_owned(), | ||
| 270 | - current: active == "email", | ||
| 271 | - }, | ||
| 272 | - RailItem { | ||
| 273 | - name: t(lang, Key::TwoFactorAuth).to_owned(), | ||
| 274 | - val: two_factor_val.to_owned(), | ||
| 275 | - href: "?part=two-factor".to_owned(), | ||
| 276 | - current: active == "two-factor", | ||
| 277 | - }, | ||
| 278 | - RailItem { | ||
| 279 | - name: s(lang, "Passkeys", "Geçiş anahtarları").to_owned(), | ||
| 280 | - val: passkey_count.to_string(), | ||
| 281 | - href: "?part=passkeys".to_owned(), | ||
| 282 | - current: active == "passkeys", | ||
| 283 | - }, | ||
| 284 | - RailItem { | ||
| 285 | - name: t(lang, Key::Sessions).to_owned(), | ||
| 286 | - val: session_count.to_string(), | ||
| 287 | - href: "?part=sessions".to_owned(), | ||
| 288 | - current: active == "sessions", | ||
| 289 | - }, | ||
| 290 | - RailItem { | ||
| 291 | - name: t(lang, Key::DangerZone).to_owned(), | ||
| 292 | - val: String::new(), | ||
| 293 | - href: "?part=danger".to_owned(), | ||
| 294 | - current: active == "danger", | ||
| 295 | - }, | ||
| 296 | - ]; | ||
| 297 | Ok(view! { | 366 | Ok(view! { |
| 298 | - head(title: t(lang, Key::Security), sub: vec![SubPart::text(s(lang, "Sign-in, email, two-factor, passkeys and sessions", "Giriş, e-posta, iki adımlı doğrulama, geçiş anahtarları ve oturumlar"))]) | 367 | + head(title: t(lang, Key::Security), sub: vec![SubPart::text(security_sub(lang))]) |
| 299 | if let Some(message) = notice { | 368 | if let Some(message) = notice { |
| 300 | <p class="state" role="status">(message)</p> | 369 | <p class="state" role="status">(message)</p> |
| 301 | } | 370 | } |
| @@ -307,30 +376,26 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { | |||
| 307 | if let Some(stamp) = password_changed { | 376 | if let Some(stamp) = password_changed { |
| 308 | <p class="state">(i18n::last_changed_label(lang)) " " rel_time(lang: lang, stamp: stamp.as_str())</p> | 377 | <p class="state">(i18n::last_changed_label(lang)) " " rel_time(lang: lang, stamp: stamp.as_str())</p> |
| 309 | } | 378 | } |
| 310 | - <div class="acts"> | 379 | + if let Some(message) = password_error { |
| 311 | - reveal(label: t(lang, Key::ChangeAction), open: password_open, | 380 | + alert(message: message.as_str()) |
| 312 | - if let Some(message) = password_error { | 381 | + } |
| 313 | - alert(message: message.as_str()) | 382 | + <form data-hard="true" method="post" action="/settings/security/password" class="fields"> |
| 314 | - } | 383 | + <input type="hidden" name="csrf" value=(csrf)> |
| 315 | - <form data-hard="true" method="post" action="/settings/security/password" class="fields"> | 384 | + <div class="field"> |
| 316 | - <input type="hidden" name="csrf" value=(csrf)> | 385 | + <label for="current-password">(t(lang, Key::CurrentPassword))</label> |
| 317 | - <div class="field"> | 386 | + <input id="current-password" type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 318 | - <label for="current-password">(t(lang, Key::CurrentPassword))</label> | 387 | + </div> |
| 319 | - <input id="current-password" type="password" name="current_password" autocomplete="current-password" required=(true)> | 388 | + <div class="field"> |
| 320 | - </div> | 389 | + <label for="new-password">(t(lang, Key::NewPassword))</label> |
| 321 | - <div class="field"> | 390 | + <input id="new-password" type="password" name="new_password" autocomplete="new-password" minlength="10" maxlength="1024" required=(true)> |
| 322 | - <label for="new-password">(t(lang, Key::NewPassword))</label> | 391 | + <p class="hint">(t(lang, Key::NewPasswordHint))</p> |
| 323 | - <input id="new-password" type="password" name="new_password" autocomplete="new-password" minlength="10" maxlength="1024" required=(true)> | 392 | + </div> |
| 324 | - <p class="hint">(t(lang, Key::NewPasswordHint))</p> | 393 | + <div class="field"> |
| 325 | - </div> | 394 | + <label for="confirm-password">(t(lang, Key::ConfirmNewPassword))</label> |
| 326 | - <div class="field"> | 395 | + <input id="confirm-password" type="password" name="confirm_password" autocomplete="new-password" required=(true)> |
| 327 | - <label for="confirm-password">(t(lang, Key::ConfirmNewPassword))</label> | 396 | + </div> |
| 328 | - <input id="confirm-password" type="password" name="confirm_password" autocomplete="new-password" required=(true)> | 397 | + <button type="submit" class="primary">(t(lang, Key::ChangePassword))</button> |
| 329 | - </div> | 398 | + </form> |
| 330 | - <button type="submit" class="primary">(t(lang, Key::ChangePassword))</button> | ||
| 331 | - </form> | ||
| 332 | - ) | ||
| 333 | - </div> | ||
| 334 | </section> | 399 | </section> |
| 335 | <section class="sec" id="email"> | 400 | <section class="sec" id="email"> |
| 336 | <h2>(t(lang, Key::Email))</h2> | 401 | <h2>(t(lang, Key::Email))</h2> |
| @@ -339,28 +404,26 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { | |||
| 339 | } else { | 404 | } else { |
| 340 | <p class="state"><span class="security-email">(stored_email.as_str())</span> (" · ")(email_status.as_str()) if let Some(stamp) = email_sent { " " rel_time(lang: lang, stamp: stamp.as_str()) }</p> | 405 | <p class="state"><span class="security-email">(stored_email.as_str())</span> (" · ")(email_status.as_str()) if let Some(stamp) = email_sent { " " rel_time(lang: lang, stamp: stamp.as_str()) }</p> |
| 341 | } | 406 | } |
| 342 | - <div class="acts"> | 407 | + if let Some(message) = email_error { |
| 343 | - reveal(label: t(lang, Key::ChangeAction), open: email_open, | 408 | + alert(message: message.as_str()) |
| 344 | - if let Some(message) = email_error { | 409 | + } |
| 345 | - alert(message: message.as_str()) | 410 | + <form method="post" action="/settings/security/email" class="fields"> |
| 346 | - } | 411 | + <input type="hidden" name="csrf" value=(csrf)> |
| 347 | - <form method="post" action="/settings/security/email" class="fields"> | 412 | + <div class="field"> |
| 348 | - <input type="hidden" name="csrf" value=(csrf)> | 413 | + <label for="email-address">(t(lang, Key::Email))</label> |
| 349 | - <div class="field"> | 414 | + <input id="email-address" type="email" name="email" autocomplete="email" maxlength="254" required=(true) value=(email.as_str())> |
| 350 | - <label for="email-address">(t(lang, Key::Email))</label> | 415 | + </div> |
| 351 | - <input id="email-address" type="email" name="email" autocomplete="email" maxlength="254" required=(true) value=(email.as_str())> | 416 | + <div class="field"> |
| 352 | - </div> | 417 | + <label for="email-current-password">(t(lang, Key::CurrentPassword))</label> |
| 353 | - <div class="field"> | 418 | + <input id="email-current-password" type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 354 | - <label for="email-current-password">(t(lang, Key::CurrentPassword))</label> | 419 | + </div> |
| 355 | - <input id="email-current-password" type="password" name="current_password" autocomplete="current-password" required=(true)> | 420 | + <button type="submit" class="primary">(t(lang, Key::SaveEmail))</button> |
| 356 | - </div> | 421 | + </form> |
| 357 | - <button type="submit" class="primary">(t(lang, Key::SaveEmail))</button> | 422 | + if show_resend { |
| 358 | - </form> | 423 | + <div class="acts"> |
| 359 | - ) | ||
| 360 | - if show_resend { | ||
| 361 | post_act(label: t(lang, Key::VerifyResend), action: "/settings/security/email/resend", csrf: csrf) | 424 | post_act(label: t(lang, Key::VerifyResend), action: "/settings/security/email/resend", csrf: csrf) |
| 362 | - } | 425 | + </div> |
| 363 | - </div> | 426 | + } |
| 364 | </section> | 427 | </section> |
| 365 | <section class="sec" id="two-factor"> | 428 | <section class="sec" id="two-factor"> |
| 366 | <h2>(t(lang, Key::TwoFactorAuth))</h2> | 429 | <h2>(t(lang, Key::TwoFactorAuth))</h2> |
| @@ -458,12 +521,28 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { | |||
| 458 | passkeys_panel(lang: lang, csrf: csrf, panel: passkeys) | 521 | passkeys_panel(lang: lang, csrf: csrf, panel: passkeys) |
| 459 | <section class="sec" id="sessions"> | 522 | <section class="sec" id="sessions"> |
| 460 | <h2>(t(lang, Key::Sessions))</h2> | 523 | <h2>(t(lang, Key::Sessions))</h2> |
| 461 | - <p class="state">(sessions_line.as_str())</p> | 524 | + if others > 0 { |
| 462 | - <p class="hint">(t(lang, Key::SecurityLog))(t(lang, Key::SecurityLogRest))</p> | 525 | + <div class="acts"> |
| 463 | - <div class="acts"> | 526 | + confirm_act(lang: lang, label: t(lang, Key::RevokeAllOthers), action: "/settings/sessions/revoke-others", csrf: csrf, note: Some(s(lang, "Every other browser is signed out at once. This one stays signed in.", "Diğer tüm tarayıcılarda oturum hemen kapanır. Bu tarayıcıda oturum açık kalır.").to_owned())) |
| 464 | - <a class="act" href="/settings/sessions">(s(lang, "Review", "Gözden geçir"))</a> | 527 | + </div> |
| 465 | - <a class="act" href="/settings/security/log">(t(lang, Key::SecurityLog))</a> | 528 | + } |
| 466 | - </div> | 529 | + for session in sessions.into_iter() { |
| 530 | + <div class="line"> | ||
| 531 | + <span class="name">(session_label(lang, &session))</span> | ||
| 532 | + <span class="val"> | ||
| 533 | + if session.id == current_session_id { | ||
| 534 | + (t(lang, Key::ThisSession)) " · " | ||
| 535 | + } | ||
| 536 | + if let Some(ip) = session.last_ip.as_deref() { | ||
| 537 | + (ip) " · " | ||
| 538 | + } | ||
| 539 | + (i18n::dated_label(lang, Key::LastSeen)) " " rel_time(lang: lang, stamp: session.last_seen.as_str()) " · " (t(lang, Key::SignedIn)) " " rel_time(lang: lang, stamp: session.created_at.as_str()) | ||
| 540 | + </span> | ||
| 541 | + if session.id != current_session_id { | ||
| 542 | + confirm_act(lang: lang, label: t(lang, Key::Revoke), action: "/settings/sessions/revoke", csrf: csrf, fields: vec![("id".to_owned(), session.id.clone())], note: Some(s(lang, "This browser is signed out at once.", "Bu tarayıcıda oturum hemen kapanır.").to_owned())) | ||
| 543 | + } | ||
| 544 | + </div> | ||
| 545 | + } | ||
| 467 | </section> | 546 | </section> |
| 468 | <section class="sec" id="danger"> | 547 | <section class="sec" id="danger"> |
| 469 | <h2>(t(lang, Key::DangerZone))</h2> | 548 | <h2>(t(lang, Key::DangerZone))</h2> |
| @@ -625,7 +704,8 @@ async fn build_page( | |||
| 625 | pending, | 704 | pending, |
| 626 | password_changed, | 705 | password_changed, |
| 627 | two_factor, | 706 | two_factor, |
| 628 | - session_count: state.store.list_sessions(&viewer.0.id).await?.len(), | 707 | + sessions: state.store.list_sessions(&viewer.0.id).await?, |
| 708 | + current_session_id: viewer.1.id.clone(), | ||
| 629 | part: shown.part, | 709 | part: shown.part, |
| 630 | }) | 710 | }) |
| 631 | } | 711 | } |
| @@ -1708,7 +1788,11 @@ mod tests { | |||
| 1708 | assert!(page.body.contains("Added "), "{}", page.body); | 1788 | assert!(page.body.contains("Added "), "{}", page.body); |
| 1709 | assert!(page.body.contains("1 of 10 recovery codes unused")); | 1789 | assert!(page.body.contains("1 of 10 recovery codes unused")); |
| 1710 | assert!(page.body.contains("Running low")); | 1790 | assert!(page.body.contains("Running low")); |
| 1711 | - assert!(page.body.contains("<p class=\"state\">On · "), "{}", page.body); | 1791 | + assert!( |
| 1792 | + page.body.contains("<p class=\"state\">On · "), | ||
| 1793 | + "{}", | ||
| 1794 | + page.body | ||
| 1795 | + ); | ||
| 1712 | 1796 | ||
| 1713 | let bad = format!( | 1797 | let bad = format!( |
| 1714 | "csrf={CSRF}¤t_password=nope&code={}", | 1798 | "csrf={CSRF}¤t_password=nope&code={}", |
| @@ -1729,8 +1813,9 @@ mod tests { | |||
| 1729 | .expect("turn-off panel should stay open"); | 1813 | .expect("turn-off panel should stay open"); |
| 1730 | assert!( | 1814 | assert!( |
| 1731 | opened.contains("Turn off") | 1815 | opened.contains("Turn off") |
| 1732 | - && opened.split("<details").next().is_some_and(|panel| panel | 1816 | + && opened.split("<details").next().is_some_and( |
| 1733 | - .contains("action=\"/settings/security/2fa/disable\"")), | 1817 | + |panel| panel.contains("action=\"/settings/security/2fa/disable\"") |
| 1818 | + ), | ||
| 1734 | "the open panel should be the turn-off form: {opened}" | 1819 | "the open panel should be the turn-off form: {opened}" |
| 1735 | ); | 1820 | ); |
| 1736 | assert!( | 1821 | assert!( |
crates/forge-web/src/pages/settings_sessions.rsmodified+38 -163
| @@ -1,22 +1,19 @@ | |||
| 1 | -//! Page: web sessions (`/settings/sessions`). Revoke one or all other sessions, and a detail page | 1 | +//! Page: web sessions. The list and the per-session facts live in Security's Sessions topic |
| 2 | -//! per session (`/settings/sessions/{id}`). | 2 | +//! (`/settings/security?part=sessions`); `/settings/sessions` and `/settings/sessions/{id}` only |
| 3 | +//! redirect there. This module keeps the revoke actions, which that topic posts to. | ||
| 3 | 4 | ||
| 4 | use forge_core::{AuditAction, Session}; | 5 | use forge_core::{AuditAction, Session}; |
| 5 | use serde::Deserialize; | 6 | use serde::Deserialize; |
| 6 | use topcoat::Result; | 7 | use topcoat::Result; |
| 7 | use topcoat::context::{Cx, app_context}; | 8 | use topcoat::context::{Cx, app_context}; |
| 8 | use topcoat::router::content::Form; | 9 | use topcoat::router::content::Form; |
| 9 | -use topcoat::router::error::{SeeOther, not_found, see_other}; | 10 | +use topcoat::router::error::{SeeOther, see_other}; |
| 10 | -use topcoat::router::{page, path_param_segment, route}; | 11 | +use topcoat::router::route; |
| 11 | -use topcoat::view::{View, component, view}; | ||
| 12 | 12 | ||
| 13 | use crate::audit::{self, Actor, Target}; | 13 | use crate::audit::{self, Actor, Target}; |
| 14 | use crate::auth::{logout, require_csrf, require_user}; | 14 | use crate::auth::{logout, require_csrf, require_user}; |
| 15 | -use crate::i18n::{self, Key, Lang, t}; | 15 | +use crate::i18n::{Key, Lang, t}; |
| 16 | -use crate::pages::passkeys::s; | ||
| 17 | use crate::state::AppState; | 16 | use crate::state::AppState; |
| 18 | -use crate::views::parts::{SubPart, confirm_act, head}; | ||
| 19 | -use crate::views::{rel_time, shell}; | ||
| 20 | use crate::web_push::agent_label_in; | 17 | use crate::web_push::agent_label_in; |
| 21 | 18 | ||
| 22 | #[derive(Deserialize)] | 19 | #[derive(Deserialize)] |
| @@ -34,151 +31,23 @@ struct CsrfForm { | |||
| 34 | } | 31 | } |
| 35 | 32 | ||
| 36 | /// A short title for a session: "Chrome on Linux", or the unknown-browser label. | 33 | /// A short title for a session: "Chrome on Linux", or the unknown-browser label. |
| 37 | -fn session_label(lang: Lang, session: &Session) -> String { | 34 | +pub(crate) fn session_label(lang: Lang, session: &Session) -> String { |
| 38 | - session | 35 | + session.user_agent.as_deref().map_or_else( |
| 39 | - .user_agent | 36 | + || t(lang, Key::UnknownBrowser).to_owned(), |
| 40 | - .as_deref() | 37 | + |agent| agent_label_in(lang, agent), |
| 41 | - .map_or_else(|| t(lang, Key::UnknownBrowser).to_owned(), |agent| agent_label_in(lang, agent)) | 38 | + ) |
| 42 | } | 39 | } |
| 43 | 40 | ||
| 44 | -#[component] | 41 | +#[route(GET "/settings/sessions")] |
| 45 | -async fn sessions_view( | 42 | +async fn sessions_page(cx: &Cx) -> Result<SeeOther> { |
| 46 | - lang: Lang, | 43 | + require_user(cx).await?; |
| 47 | - csrf: &str, | 44 | + Ok(see_other("/settings/security?part=sessions")) |
| 48 | - current_id: &str, | ||
| 49 | - sessions: Vec<Session>, | ||
| 50 | -) -> Result<impl View> { | ||
| 51 | - let others = sessions.iter().filter(|s| s.id != current_id).count(); | ||
| 52 | - Ok(view! { | ||
| 53 | - head(title: t(lang, Key::Sessions), sub: vec![SubPart::text(s(lang, "Where you are signed in", "Oturum açık olduğun yerler"))]) | ||
| 54 | - <div class="sheet fit"> | ||
| 55 | - if others > 0 { | ||
| 56 | - <div class="acts"> | ||
| 57 | - confirm_act(lang: lang, label: t(lang, Key::RevokeAllOthers), action: "/settings/sessions/revoke-others", csrf: csrf, note: Some(s(lang, "Every other browser is signed out at once. This one stays signed in.", "Diğer tüm tarayıcılarda oturum hemen kapanır. Bu tarayıcıda oturum açık kalır.").to_owned())) | ||
| 58 | - </div> | ||
| 59 | - } | ||
| 60 | - for session in sessions.into_iter() { | ||
| 61 | - <details class="row-open"> | ||
| 62 | - <summary class="line"> | ||
| 63 | - <span class="name">(session_label(lang, &session))</span> | ||
| 64 | - <span class="val"> | ||
| 65 | - if session.id == current_id { | ||
| 66 | - (t(lang, Key::ThisSession)) " · " | ||
| 67 | - } | ||
| 68 | - (i18n::dated_label(lang, Key::LastSeen)) " " rel_time(lang: lang, stamp: session.last_seen.as_str()) | ||
| 69 | - </span> | ||
| 70 | - </summary> | ||
| 71 | - <div class="opened"> | ||
| 72 | - session_details(lang: lang, csrf: csrf, session: session.clone(), current: session.id == current_id) | ||
| 73 | - <div class="acts"> | ||
| 74 | - <a class="act" href=(format!("/settings/sessions/{}", session.id))>(s(lang, "Open page", "Sayfayı aç"))</a> | ||
| 75 | - </div> | ||
| 76 | - </div> | ||
| 77 | - </details> | ||
| 78 | - } | ||
| 79 | - </div> | ||
| 80 | - }) | ||
| 81 | } | 45 | } |
| 82 | 46 | ||
| 83 | -/// The facts about one session, shared by its row on the list and its detail page: the badge | 47 | +#[route(GET "/settings/sessions/{id}")] |
| 84 | -/// when it is the current session, the key/value grid, and the revoke action for any other one. | 48 | +async fn session_page(cx: &Cx) -> Result<SeeOther> { |
| 85 | -#[component] | 49 | + require_user(cx).await?; |
| 86 | -async fn session_details( | 50 | + Ok(see_other("/settings/security?part=sessions")) |
| 87 | - lang: Lang, | ||
| 88 | - csrf: &str, | ||
| 89 | - session: Session, | ||
| 90 | - current: bool, | ||
| 91 | -) -> Result<impl View> { | ||
| 92 | - let user_agent = session | ||
| 93 | - .user_agent | ||
| 94 | - .clone() | ||
| 95 | - .unwrap_or_else(|| t(lang, Key::UnknownBrowser).to_owned()); | ||
| 96 | - // Sessions from before IP recording have no sign-in address. | ||
| 97 | - let sign_in_ip = session | ||
| 98 | - .ip | ||
| 99 | - .clone() | ||
| 100 | - .unwrap_or_else(|| t(lang, Key::NotRecorded).to_owned()); | ||
| 101 | - let last_ip = session | ||
| 102 | - .last_ip | ||
| 103 | - .clone() | ||
| 104 | - .unwrap_or_else(|| t(lang, Key::NotRecorded).to_owned()); | ||
| 105 | - let id = session.id.clone(); | ||
| 106 | - Ok(view! { | ||
| 107 | - if current { | ||
| 108 | - <p class="state">(t(lang, Key::ThisSession))</p> | ||
| 109 | - } | ||
| 110 | - <dl class="kv-grid"> | ||
| 111 | - <div><dt>(t(lang, Key::UserAgent))</dt><dd>(user_agent.as_str())</dd></div> | ||
| 112 | - <div><dt>(t(lang, Key::SignInIp))</dt><dd>(sign_in_ip.as_str())</dd></div> | ||
| 113 | - <div><dt>(t(lang, Key::LastIp))</dt><dd>(last_ip.as_str())</dd></div> | ||
| 114 | - <div><dt>(t(lang, Key::SignedIn))</dt><dd>rel_time(lang: lang, stamp: session.created_at.as_str())</dd></div> | ||
| 115 | - <div><dt>(t(lang, Key::LastSeenAt))</dt><dd>rel_time(lang: lang, stamp: session.last_seen.as_str())</dd></div> | ||
| 116 | - <div><dt>(t(lang, Key::ExpiresAt))</dt><dd>rel_time(lang: lang, stamp: session.expires_at.as_str())</dd></div> | ||
| 117 | - </dl> | ||
| 118 | - if !current { | ||
| 119 | - <div class="acts"> | ||
| 120 | - confirm_act(lang: lang, label: t(lang, Key::Revoke), action: "/settings/sessions/revoke", csrf: csrf, fields: vec![("id".to_owned(), id)], note: Some(s(lang, "This browser is signed out at once.", "Bu tarayıcıda oturum hemen kapanır.").to_owned())) | ||
| 121 | - </div> | ||
| 122 | - } | ||
| 123 | - }) | ||
| 124 | -} | ||
| 125 | - | ||
| 126 | -#[component] | ||
| 127 | -async fn session_detail_view( | ||
| 128 | - lang: Lang, | ||
| 129 | - csrf: &str, | ||
| 130 | - session: Session, | ||
| 131 | - current: bool, | ||
| 132 | -) -> Result<impl View> { | ||
| 133 | - let label = session_label(lang, &session); | ||
| 134 | - Ok(view! { | ||
| 135 | - head(title: label.as_str()) | ||
| 136 | - <div class="sheet fit"> | ||
| 137 | - <div class="sheet-tools"> | ||
| 138 | - <a class="act" href="/settings/sessions">(t(lang, Key::BackToSessions))</a> | ||
| 139 | - </div> | ||
| 140 | - <section class="sec"> | ||
| 141 | - <p class="hint">(i18n::dated_label(lang, Key::LastSeen)) " " rel_time(lang: lang, stamp: session.last_seen.as_str())</p> | ||
| 142 | - session_details(lang: lang, csrf: csrf, session: session.clone(), current: current) | ||
| 143 | - </section> | ||
| 144 | - </div> | ||
| 145 | - }) | ||
| 146 | -} | ||
| 147 | - | ||
| 148 | -#[page("/settings/sessions")] | ||
| 149 | -async fn sessions_page(cx: &Cx) -> Result<impl View> { | ||
| 150 | - let viewer = require_user(cx).await?; | ||
| 151 | - let lang = i18n::lang(cx, Some(&viewer.0)); | ||
| 152 | - let sessions = app_context::<AppState>(cx) | ||
| 153 | - .store | ||
| 154 | - .list_sessions(&viewer.0.id) | ||
| 155 | - .await?; | ||
| 156 | - let csrf = viewer.1.csrf_token.clone(); | ||
| 157 | - let current_id = viewer.1.id.clone(); | ||
| 158 | - Ok(view! { | ||
| 159 | - shell(title: t(lang, Key::Sessions), viewer: Some(&viewer), sessions_view(lang: lang, csrf: csrf.as_str(), current_id: current_id.as_str(), sessions: sessions)) | ||
| 160 | - }) | ||
| 161 | -} | ||
| 162 | - | ||
| 163 | -#[page("/settings/sessions/{id}")] | ||
| 164 | -async fn session_page(cx: &Cx) -> Result<impl View> { | ||
| 165 | - let viewer = require_user(cx).await?; | ||
| 166 | - let lang = i18n::lang(cx, Some(&viewer.0)); | ||
| 167 | - let id = path_param_segment(cx, "id").to_owned(); | ||
| 168 | - // Only the signed-in user's own sessions are shown; anything else is not found. | ||
| 169 | - let sessions = app_context::<AppState>(cx) | ||
| 170 | - .store | ||
| 171 | - .list_sessions(&viewer.0.id) | ||
| 172 | - .await?; | ||
| 173 | - let Some(session) = sessions.into_iter().find(|s| s.id == id) else { | ||
| 174 | - return Err(not_found().into()); | ||
| 175 | - }; | ||
| 176 | - let current = session.id == viewer.1.id; | ||
| 177 | - let csrf = viewer.1.csrf_token.clone(); | ||
| 178 | - let title = session_label(lang, &session); | ||
| 179 | - Ok(view! { | ||
| 180 | - shell(title: title.as_str(), viewer: Some(&viewer), session_detail_view(lang: lang, csrf: csrf.as_str(), session: session, current: current)) | ||
| 181 | - }) | ||
| 182 | } | 51 | } |
| 183 | 52 | ||
| 184 | #[route(POST "/settings/sessions/revoke")] | 53 | #[route(POST "/settings/sessions/revoke")] |
| @@ -220,7 +89,7 @@ async fn sessions_revoke(cx: &Cx, Form(form): Form<RevokeForm>) -> Result<SeeOth | |||
| 220 | ) | 89 | ) |
| 221 | .await; | 90 | .await; |
| 222 | } | 91 | } |
| 223 | - Ok(see_other("/settings/sessions")) | 92 | + Ok(see_other("/settings/security?part=sessions")) |
| 224 | } | 93 | } |
| 225 | 94 | ||
| 226 | #[route(POST "/settings/sessions/revoke-others")] | 95 | #[route(POST "/settings/sessions/revoke-others")] |
| @@ -249,7 +118,7 @@ async fn sessions_revoke_others(cx: &Cx, Form(form): Form<CsrfForm>) -> Result<S | |||
| 249 | ) | 118 | ) |
| 250 | .await; | 119 | .await; |
| 251 | } | 120 | } |
| 252 | - Ok(see_other("/settings/sessions")) | 121 | + Ok(see_other("/settings/security?part=sessions")) |
| 253 | } | 122 | } |
| 254 | 123 | ||
| 255 | #[cfg(test)] | 124 | #[cfg(test)] |
| @@ -263,7 +132,7 @@ mod tests { | |||
| 263 | const CSRF: &str = "sessions-test-csrf"; | 132 | const CSRF: &str = "sessions-test-csrf"; |
| 264 | 133 | ||
| 265 | #[tokio::test] | 134 | #[tokio::test] |
| 266 | - async fn sessions_list_renders_a_row_open_per_session() { | 135 | + async fn sessions_list_moves_to_the_security_sessions_topic() { |
| 267 | let dir = tempfile::tempdir().expect("tempdir"); | 136 | let dir = tempfile::tempdir().expect("tempdir"); |
| 268 | let state = crate::test_support::test_state(dir.path()).await; | 137 | let state = crate::test_support::test_state(dir.path()).await; |
| 269 | let store = state.store.clone(); | 138 | let store = state.store.clone(); |
| @@ -273,12 +142,6 @@ mod tests { | |||
| 273 | .await | 142 | .await |
| 274 | .expect("tahinli"); | 143 | .expect("tahinli"); |
| 275 | crate::test_support::create_session(&store, &tahinli.id, "tahinli-token", CSRF).await; | 144 | crate::test_support::create_session(&store, &tahinli.id, "tahinli-token", CSRF).await; |
| 276 | - let current = store | ||
| 277 | - .list_sessions(&tahinli.id) | ||
| 278 | - .await | ||
| 279 | - .expect("sessions") | ||
| 280 | - .pop() | ||
| 281 | - .expect("one session"); | ||
| 282 | 145 | ||
| 283 | let req = Request::builder() | 146 | let req = Request::builder() |
| 284 | .method("GET") | 147 | .method("GET") |
| @@ -287,13 +150,25 @@ mod tests { | |||
| 287 | .body(Body::empty()) | 150 | .body(Body::empty()) |
| 288 | .expect("request"); | 151 | .expect("request"); |
| 289 | let res = router.handle(req).await; | 152 | let res = router.handle(req).await; |
| 153 | + assert_eq!(res.status().as_u16(), 303); | ||
| 154 | + assert_eq!( | ||
| 155 | + res.headers().get("location").and_then(|v| v.to_str().ok()), | ||
| 156 | + Some("/settings/security?part=sessions") | ||
| 157 | + ); | ||
| 158 | + let _ = to_bytes(res.into_body(), usize::MAX).await; | ||
| 159 | + | ||
| 160 | + let req = Request::builder() | ||
| 161 | + .method("GET") | ||
| 162 | + .uri("/settings/security?part=sessions") | ||
| 163 | + .header("cookie", format!("__Host-{SESSION_COOKIE}=tahinli-token")) | ||
| 164 | + .body(Body::empty()) | ||
| 165 | + .expect("request"); | ||
| 166 | + let res = router.handle(req).await; | ||
| 290 | assert_eq!(res.status().as_u16(), 200); | 167 | assert_eq!(res.status().as_u16(), 200); |
| 291 | let body = to_bytes(res.into_body(), usize::MAX).await.expect("body"); | 168 | let body = to_bytes(res.into_body(), usize::MAX).await.expect("body"); |
| 292 | let html = String::from_utf8_lossy(&body); | 169 | let html = String::from_utf8_lossy(&body); |
| 293 | - assert!(html.contains("<details class=\"row-open\">")); | 170 | + assert!(html.contains("<div class=\"line\">")); |
| 294 | - assert!(html.contains("<div class=\"opened\">")); | 171 | + assert!(html.contains("This session")); |
| 295 | - assert!(html.contains("<dl class=\"kv-grid\">")); | ||
| 296 | - assert!(html.contains(&format!("href=\"/settings/sessions/{}\"", current.id))); | ||
| 297 | } | 172 | } |
| 298 | 173 | ||
| 299 | #[tokio::test] | 174 | #[tokio::test] |
crates/forge-web/src/pages/settings_tokens.rsmodified+5 -12
| @@ -130,18 +130,11 @@ pub(crate) async fn tokens_section( | |||
| 130 | <p class="state">(t(lang, Key::NoAccessTokens))</p> | 130 | <p class="state">(t(lang, Key::NoAccessTokens))</p> |
| 131 | } | 131 | } |
| 132 | for token in tokens.into_iter() { | 132 | for token in tokens.into_iter() { |
| 133 | - <details class="row-open"> | 133 | + <div class="line"> |
| 134 | - <summary class="line"> | 134 | + <span class="name">(token.name.clone())</span> |
| 135 | - <span class="name">(token.name.clone())</span> | 135 | + <span class="val">(i18n::dated_label(lang, Key::LastUsed)) " " rel_time_or_never(lang: lang, stamp: token.last_used_at.as_deref()) " · " (i18n::dated_label(lang, Key::ExpiresLabel)) " " rel_time_or_never(lang: lang, stamp: token.expires_at.as_deref()) " · " (i18n::dated_label(lang, Key::Created)) " " rel_time(lang: lang, stamp: token.created_at.as_str())</span> |
| 136 | - <span class="val">(i18n::dated_label(lang, Key::LastUsed)) " " rel_time_or_never(lang: lang, stamp: token.last_used_at.as_deref()) ", " (i18n::dated_label(lang, Key::ExpiresLabel)) " " rel_time_or_never(lang: lang, stamp: token.expires_at.as_deref())</span> | 136 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/tokens/delete", csrf: csrf, fields: vec![("id".to_owned(), token.id.clone())], note: Some(delete_message(lang).to_owned())) |
| 137 | - </summary> | 137 | + </div> |
| 138 | - <div class="opened"> | ||
| 139 | - <p class="hint">(i18n::dated_label(lang, Key::Created)) " " rel_time(lang: lang, stamp: token.created_at.as_str())</p> | ||
| 140 | - <div class="acts"> | ||
| 141 | - confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/tokens/delete", csrf: csrf, fields: vec![("id".to_owned(), token.id.clone())], note: Some(delete_message(lang).to_owned())) | ||
| 142 | - </div> | ||
| 143 | - </div> | ||
| 144 | - </details> | ||
| 145 | } | 138 | } |
| 146 | }) | 139 | }) |
| 147 | } | 140 | } |
crates/forge-web/src/views/mod.rsmodified+231 -40
| @@ -149,11 +149,39 @@ fn crumb_label(part: &str) -> String { | |||
| 149 | } | 149 | } |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | -/// The path bar for a request path, as `(label, href)` pairs. The root and the top-level pages | 152 | +/// The word a path bar shows for the last step of a path below an item, such as `edit` or `files`. |
| 153 | -/// return no segments: their page head already shows the name, so the bar only holds its hint. A | 153 | +fn step_label(lang: Lang, word: &str) -> String { |
| 154 | -/// repo path shows the owner, the repo and, for a `tree` or `blob` path, one segment per path | 154 | + match word { |
| 155 | -/// part. The last segment never links. Labels are decoded. | 155 | + "new" => s(lang, "New", "Yeni").to_owned(), |
| 156 | -fn path_segments(path: &str, title: &str) -> Vec<(String, Option<String>)> { | 156 | + "edit" => s(lang, "Edit", "Düzenle").to_owned(), |
| 157 | + "history" => s(lang, "History", "Geçmiş").to_owned(), | ||
| 158 | + "revisions" => s(lang, "Revisions", "Sürümler").to_owned(), | ||
| 159 | + "files" => s(lang, "Files", "Dosyalar").to_owned(), | ||
| 160 | + "commits" => g::t(lang, K::TabCommits).to_owned(), | ||
| 161 | + other => crumb_label(other), | ||
| 162 | + } | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | +/// The name of a repo section in the path bar, for a page under it. `None` for a word that is no | ||
| 166 | +/// section, such as `scrub`. | ||
| 167 | +fn repo_section_label(lang: Lang, kind: &str) -> Option<String> { | ||
| 168 | + match kind { | ||
| 169 | + "issues" | "pulls" | "ci" | "commits" | "branches" | "tags" | "releases" | ||
| 170 | + | "discussions" | "wiki" | "security" | "settings" => { | ||
| 171 | + Some(crate::pages::repo::tab_title(lang, kind, "")) | ||
| 172 | + } | ||
| 173 | + "milestones" => Some(s(lang, "Milestones", "Kilometre taşları").to_owned()), | ||
| 174 | + "labels" => Some(s(lang, "Labels", "Etiketler").to_owned()), | ||
| 175 | + _ => None, | ||
| 176 | + } | ||
| 177 | +} | ||
| 178 | + | ||
| 179 | +/// The path bar for a request path, as `(label, href)` pairs: every place above the page links, | ||
| 180 | +/// so a page is always one click from the one it belongs to. The root and the top-level pages | ||
| 181 | +/// return no segments (their section names them). A repo path shows the owner, the repo, then for | ||
| 182 | +/// a page under a section the section, the item (`#12`) and the page; a `tree` or `blob` path has | ||
| 183 | +/// one segment per path part. The last segment never links. Labels are decoded. | ||
| 184 | +fn path_segments(lang: Lang, path: &str, title: &str) -> Vec<(String, Option<String>)> { | ||
| 157 | let parts: Vec<String> = path | 185 | let parts: Vec<String> = path |
| 158 | .trim_matches('/') | 186 | .trim_matches('/') |
| 159 | .split('/') | 187 | .split('/') |
| @@ -163,6 +191,42 @@ fn path_segments(path: &str, title: &str) -> Vec<(String, Option<String>)> { | |||
| 163 | let Some(owner) = parts.first() else { | 191 | let Some(owner) = parts.first() else { |
| 164 | return Vec::new(); | 192 | return Vec::new(); |
| 165 | }; | 193 | }; |
| 194 | + // The page's own name: the part of its title after the last " · ", when there is one. | ||
| 195 | + let titled = title.rsplit_once(" · ").map(|(_, last)| last.to_owned()); | ||
| 196 | + match parts | ||
| 197 | + .iter() | ||
| 198 | + .map(String::as_str) | ||
| 199 | + .collect::<Vec<_>>() | ||
| 200 | + .as_slice() | ||
| 201 | + { | ||
| 202 | + ["snippets", id, rest @ ..] => { | ||
| 203 | + let mut segments = vec![( | ||
| 204 | + cm::t(lang, CK::Snippets).to_owned(), | ||
| 205 | + Some("/snippets".to_owned()), | ||
| 206 | + )]; | ||
| 207 | + match rest { | ||
| 208 | + // A snippet's own page is named by its title. | ||
| 209 | + [] => segments.push((title.to_owned(), None)), | ||
| 210 | + // A page under a snippet goes back to the snippet, then names its step. The revisions | ||
| 211 | + // page is titled by the snippet; the edit page by what it does. | ||
| 212 | + [.., last] => { | ||
| 213 | + let back = if *last == "revisions" { | ||
| 214 | + title.to_owned() | ||
| 215 | + } else { | ||
| 216 | + s(lang, "Snippet", "Parçacık").to_owned() | ||
| 217 | + }; | ||
| 218 | + segments.push((back, Some(format!("/snippets/{}", enc(id))))); | ||
| 219 | + segments.push((step_label(lang, last), None)); | ||
| 220 | + } | ||
| 221 | + } | ||
| 222 | + return segments; | ||
| 223 | + } | ||
| 224 | + ["org", name, rest @ ..] if *name != "new" && !rest.is_empty() => { | ||
| 225 | + let page = titled.unwrap_or_else(|| step_label(lang, rest[rest.len() - 1])); | ||
| 226 | + return vec![((*name).to_owned(), Some(user_href(name))), (page, None)]; | ||
| 227 | + } | ||
| 228 | + _ => {} | ||
| 229 | + } | ||
| 166 | if owner.starts_with('-') || TOP_LEVEL_PAGES.contains(&owner.as_str()) { | 230 | if owner.starts_with('-') || TOP_LEVEL_PAGES.contains(&owner.as_str()) { |
| 167 | return Vec::new(); | 231 | return Vec::new(); |
| 168 | } | 232 | } |
| @@ -182,27 +246,115 @@ fn path_segments(path: &str, title: &str) -> Vec<(String, Option<String>)> { | |||
| 182 | } | 246 | } |
| 183 | // The repo's home: the repo name is the last segment already. | 247 | // The repo's home: the repo name is the last segment already. |
| 184 | [] => {} | 248 | [] => {} |
| 185 | - // Titles read "owner/repo · Page": the path bar has the repo already. A page titled by | 249 | + [kind, rest @ ..] => { |
| 186 | - // the repo alone is named by its route. | 250 | + // Titles read "owner/repo · Page": the path bar has the repo already. A page titled by |
| 187 | - [_, ..] => { | 251 | + // the repo alone is named by its route. A title ending in the repo plus a word |
| 188 | - // A title ending in the repo plus a word ("Install · owner/repo wiki") reads by | 252 | + // ("Install · owner/repo wiki") reads by the part before it. |
| 189 | - // the part before it. | ||
| 190 | let full = format!("{owner}/{repo}"); | 253 | let full = format!("{owner}/{repo}"); |
| 191 | let mut tail = title.rsplit(" · "); | 254 | let mut tail = title.rsplit(" · "); |
| 192 | let named = match tail.next() { | 255 | let named = match tail.next() { |
| 193 | Some(last) if last == full => None, | 256 | Some(last) if last == full => None, |
| 194 | Some(last) if last.starts_with(&format!("{full} ")) => tail.next(), | 257 | Some(last) if last.starts_with(&format!("{full} ")) => tail.next(), |
| 195 | last => last, | 258 | last => last, |
| 259 | + } | ||
| 260 | + .map(str::to_owned); | ||
| 261 | + let section = if kind == "commit" { | ||
| 262 | + "commits" | ||
| 263 | + } else { | ||
| 264 | + kind.as_str() | ||
| 196 | }; | 265 | }; |
| 197 | - let page = match named { | 266 | + match (repo_section_label(lang, section), rest) { |
| 198 | - Some(page) => page.to_owned(), | 267 | + // Files at one commit, from the home page's timeline: under that commit. |
| 199 | - None => parts[2..] | 268 | + (None, [oid]) if kind == "scrub" => { |
| 200 | - .iter() | 269 | + let short: String = oid.chars().take(7).collect(); |
| 201 | - .map(|part| crumb_label(part)) | 270 | + segments.push(( |
| 202 | - .collect::<Vec<_>>() | 271 | + g::t(lang, K::TabCommits).to_owned(), |
| 203 | - .join("/"), | 272 | + Some(repo_href(owner, repo, "commits", "")), |
| 204 | - }; | 273 | + )); |
| 205 | - segments.push((page, None)); | 274 | + segments.push((short, Some(repo_href(owner, repo, "commit", oid)))); |
| 275 | + segments.push((step_label(lang, "files"), None)); | ||
| 276 | + } | ||
| 277 | + // Compare and search: their word, then what is compared. | ||
| 278 | + (None, rest) if matches!(kind.as_str(), "compare" | "search") => { | ||
| 279 | + let word = if kind == "compare" { | ||
| 280 | + s(lang, "Compare", "Karşılaştır") | ||
| 281 | + } else { | ||
| 282 | + s(lang, "Search", "Ara") | ||
| 283 | + }; | ||
| 284 | + if rest.is_empty() { | ||
| 285 | + segments.push((word.to_owned(), None)); | ||
| 286 | + } else { | ||
| 287 | + segments | ||
| 288 | + .push((word.to_owned(), Some(repo_href(owner, repo, kind, "")))); | ||
| 289 | + segments.push((rest.join("/"), None)); | ||
| 290 | + } | ||
| 291 | + } | ||
| 292 | + // A section's own page, or a word that is no section: one segment. | ||
| 293 | + (None, _) | (Some(_), []) => { | ||
| 294 | + let page = named.unwrap_or_else(|| { | ||
| 295 | + parts[2..] | ||
| 296 | + .iter() | ||
| 297 | + .map(|part| crumb_label(part)) | ||
| 298 | + .collect::<Vec<_>>() | ||
| 299 | + .join("/") | ||
| 300 | + }); | ||
| 301 | + segments.push((page, None)); | ||
| 302 | + } | ||
| 303 | + (Some(label), rest) => { | ||
| 304 | + segments.push((label, Some(repo_href(owner, repo, section, "")))); | ||
| 305 | + let item = rest[0].as_str(); | ||
| 306 | + let numbered = matches!(section, "issues" | "pulls" | "discussions") | ||
| 307 | + && item.bytes().all(|b| b.is_ascii_digit()); | ||
| 308 | + match (section, rest) { | ||
| 309 | + ("ci", [runs, number]) if runs == "runs" => { | ||
| 310 | + segments.push((format!("#{number}"), None)); | ||
| 311 | + } | ||
| 312 | + _ if numbered && rest.len() == 1 => { | ||
| 313 | + segments.push((format!("#{item}"), None)); | ||
| 314 | + } | ||
| 315 | + _ if numbered => { | ||
| 316 | + segments.push(( | ||
| 317 | + format!("#{item}"), | ||
| 318 | + Some(repo_href(owner, repo, section, item)), | ||
| 319 | + )); | ||
| 320 | + // The step, by its word: an edit history ends in an id, so its | ||
| 321 | + // word is History; a comment's edit is Edit. | ||
| 322 | + let step = if rest.iter().any(|part| part == "history") { | ||
| 323 | + "history" | ||
| 324 | + } else { | ||
| 325 | + rest[rest.len() - 1].as_str() | ||
| 326 | + }; | ||
| 327 | + segments.push((step_label(lang, step), None)); | ||
| 328 | + } | ||
| 329 | + ("wiki", [dash, new]) if dash == "-" && new == "new" => { | ||
| 330 | + segments.push((s(lang, "New page", "Yeni sayfa").to_owned(), None)); | ||
| 331 | + } | ||
| 332 | + ("wiki" | "settings", [page, more @ ..]) | ||
| 333 | + if !more.is_empty() && page != "-" => | ||
| 334 | + { | ||
| 335 | + let page_label = match page.as_str() { | ||
| 336 | + "hooks" => { | ||
| 337 | + i18n::integrations::t(lang, i18n::integrations::K::Webhooks) | ||
| 338 | + .to_owned() | ||
| 339 | + } | ||
| 340 | + other => crumb_label(other), | ||
| 341 | + }; | ||
| 342 | + segments.push(( | ||
| 343 | + page_label, | ||
| 344 | + Some(repo_href(owner, repo, section, page)), | ||
| 345 | + )); | ||
| 346 | + let last = more[more.len() - 1].as_str(); | ||
| 347 | + segments.push((step_label(lang, last), None)); | ||
| 348 | + } | ||
| 349 | + _ => { | ||
| 350 | + let page = named.unwrap_or_else(|| { | ||
| 351 | + step_label(lang, rest[rest.len() - 1].as_str()) | ||
| 352 | + }); | ||
| 353 | + segments.push((page, None)); | ||
| 354 | + } | ||
| 355 | + } | ||
| 356 | + } | ||
| 357 | + } | ||
| 206 | } | 358 | } |
| 207 | } | 359 | } |
| 208 | } | 360 | } |
| @@ -398,7 +550,7 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> | |||
| 398 | <img class="avatar corner-avatar" src=(corner.avatar.as_str()) alt="" width="32" height="32"> | 550 | <img class="avatar corner-avatar" src=(corner.avatar.as_str()) alt="" width="32" height="32"> |
| 399 | </summary> | 551 | </summary> |
| 400 | <div class="corner-menu"> | 552 | <div class="corner-menu"> |
| 401 | - <p class="corner-who" title=(corner.username.as_str())>(corner.name.as_str())</p> | 553 | + <a class="corner-who" href=(profile_href.as_str()) title=(profile_label)>(corner.name.as_str())</a> |
| 402 | <a class="corner-link corner-bell" href="/notifications" title=(bell_label) aria-expanded="false"> | 554 | <a class="corner-link corner-bell" href="/notifications" title=(bell_label) aria-expanded="false"> |
| 403 | <span>(bell_title)</span> | 555 | <span>(bell_title)</span> |
| 404 | if corner.unread > 0 { | 556 | if corner.unread > 0 { |
| @@ -430,7 +582,6 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> | |||
| 430 | } | 582 | } |
| 431 | </div> | 583 | </div> |
| 432 | <div class="corner-sep"></div> | 584 | <div class="corner-sep"></div> |
| 433 | - <a class="corner-link" href=(profile_href.as_str())>(profile_label)</a> | ||
| 434 | <a class="corner-link" href="/settings/profile">(settings_label)</a> | 585 | <a class="corner-link" href="/settings/profile">(settings_label)</a> |
| 435 | if corner.is_admin { | 586 | if corner.is_admin { |
| 436 | <a class="corner-link" href="/admin/users">(admin_label)</a> | 587 | <a class="corner-link" href="/admin/users">(admin_label)</a> |
| @@ -470,6 +621,7 @@ pub async fn shell( | |||
| 470 | title: &str, | 621 | title: &str, |
| 471 | viewer: Option<&(User, Session)>, | 622 | viewer: Option<&(User, Session)>, |
| 472 | #[default] extra_stylesheet: Option<&str>, | 623 | #[default] extra_stylesheet: Option<&str>, |
| 624 | + #[default] parents: Vec<(String, String)>, | ||
| 473 | #[default] child: Child<'_>, | 625 | #[default] child: Child<'_>, |
| 474 | ) -> Result<impl View> { | 626 | ) -> Result<impl View> { |
| 475 | let full_title = format!("{title} \u{b7} forge"); | 627 | let full_title = format!("{title} \u{b7} forge"); |
| @@ -573,17 +725,32 @@ pub async fn shell( | |||
| 573 | let palette_label = br::t(lang, br::K::PaletteOpen).to_owned(); | 725 | let palette_label = br::t(lang, br::K::PaletteOpen).to_owned(); |
| 574 | let explore_label = t(lang, Key::Explore); | 726 | let explore_label = t(lang, Key::Explore); |
| 575 | // The path bar: one segment per part of the request path, the last one unlinked. | 727 | // The path bar: one segment per part of the request path, the last one unlinked. |
| 576 | - let mut segments = path_segments(uri(__cx).path(), title); | 728 | + let mut segments = path_segments(lang, uri(__cx).path(), title); |
| 577 | // A page with no place of its own in the path, such as settings, names its section and itself. | 729 | // A page with no place of its own in the path, such as settings, names its section and itself. |
| 730 | + // A page below one of the section's tabs (an account under Users) names that tab too. | ||
| 578 | if segments.is_empty() { | 731 | if segments.is_empty() { |
| 579 | if let Some(section) = §ion { | 732 | if let Some(section) = §ion { |
| 580 | let first = section.items.first().map(|item| item.href.clone()); | 733 | let first = section.items.first().map(|item| item.href.clone()); |
| 581 | if section.title != title { | 734 | if section.title != title { |
| 582 | segments.push((section.title.clone(), first)); | 735 | segments.push((section.title.clone(), first)); |
| 583 | } | 736 | } |
| 737 | + let path = uri(__cx).path(); | ||
| 738 | + if let Some(item) = section.items.iter().find(|item| { | ||
| 739 | + path.strip_prefix(item.href.as_str()) | ||
| 740 | + .is_some_and(|below| below.starts_with('/')) | ||
| 741 | + }) { | ||
| 742 | + segments.push((item.label.to_owned(), Some(item.href.clone()))); | ||
| 743 | + } | ||
| 584 | } | 744 | } |
| 585 | segments.push((title.to_owned(), None)); | 745 | segments.push((title.to_owned(), None)); |
| 586 | } | 746 | } |
| 747 | + // Places the path does not show, such as a job's run, go just before the page itself. | ||
| 748 | + if !parents.is_empty() { | ||
| 749 | + let at = segments.len().saturating_sub(1); | ||
| 750 | + for (offset, (label, href)) in parents.into_iter().enumerate() { | ||
| 751 | + segments.insert(at + offset, (label, Some(href))); | ||
| 752 | + } | ||
| 753 | + } | ||
| 587 | let path_attr = segments | 754 | let path_attr = segments |
| 588 | .iter() | 755 | .iter() |
| 589 | .map(|(label, _)| label.as_str()) | 756 | .map(|(label, _)| label.as_str()) |
| @@ -821,7 +988,10 @@ pub fn page_width(path: &str) -> &'static str { | |||
| 821 | ["settings" | "admin", ..] | ["new", ..] | ["org", "new"] | ["org", _, "settings", ..] => { | 988 | ["settings" | "admin", ..] | ["new", ..] | ["org", "new"] | ["org", _, "settings", ..] => { |
| 822 | "col" | 989 | "col" |
| 823 | } | 990 | } |
| 824 | - ["login" | "register" | "forgot" | "reset" | "setup" | "invite", ..] => "col", | 991 | + [ |
| 992 | + "login" | "register" | "forgot" | "reset" | "setup" | "invite", | ||
| 993 | + .., | ||
| 994 | + ] => "col", | ||
| 825 | [_, _, section, ..] => match *section { | 995 | [_, _, section, ..] => match *section { |
| 826 | "settings" | "new" | "edit" | "fork" | "transfer" | "rename" => "col", | 996 | "settings" | "new" | "edit" | "fork" | "transfer" | "rename" => "col", |
| 827 | "tree" | "blob" | "blame" | "commit" | "compare" | "ci" | "raw" | "edit-file" | 997 | "tree" | "blob" | "blame" | "commit" | "compare" | "ci" | "raw" | "edit-file" |
| @@ -973,8 +1143,16 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { | |||
| 973 | let first = parts.next()?; | 1143 | let first = parts.next()?; |
| 974 | let second = parts.next().unwrap_or(""); | 1144 | let second = parts.next().unwrap_or(""); |
| 975 | let (key, title, items) = match first { | 1145 | let (key, title, items) = match first { |
| 976 | - "admin" => ("admin", ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), | 1146 | + "admin" => ( |
| 977 | - "settings" => ("settings", o::t(lang, OK::Settings).to_owned(), settings_items(lang)), | 1147 | + "admin", |
| 1148 | + ad::t(lang, AK::AdminArea).to_owned(), | ||
| 1149 | + admin_items(lang), | ||
| 1150 | + ), | ||
| 1151 | + "settings" => ( | ||
| 1152 | + "settings", | ||
| 1153 | + o::t(lang, OK::Settings).to_owned(), | ||
| 1154 | + settings_items(lang), | ||
| 1155 | + ), | ||
| 978 | _ => return None, | 1156 | _ => return None, |
| 979 | }; | 1157 | }; |
| 980 | let second = match second { | 1158 | let second = match second { |
| @@ -1619,7 +1797,7 @@ mod tests { | |||
| 1619 | #[test] | 1797 | #[test] |
| 1620 | fn path_segments_follow_the_request_path() { | 1798 | fn path_segments_follow_the_request_path() { |
| 1621 | assert_eq!( | 1799 | assert_eq!( |
| 1622 | - path_segments("/tahinli/forge/blob/main/src/main.rs", "main.rs"), | 1800 | + path_segments(Lang::En, "/tahinli/forge/blob/main/src/main.rs", "main.rs"), |
| 1623 | vec![ | 1801 | vec![ |
| 1624 | ("tahinli".to_owned(), Some("/tahinli".to_owned())), | 1802 | ("tahinli".to_owned(), Some("/tahinli".to_owned())), |
| 1625 | ("forge".to_owned(), Some("/tahinli/forge".to_owned())), | 1803 | ("forge".to_owned(), Some("/tahinli/forge".to_owned())), |
| @@ -1631,24 +1809,37 @@ mod tests { | |||
| 1631 | ] | 1809 | ] |
| 1632 | ); | 1810 | ); |
| 1633 | assert_eq!( | 1811 | assert_eq!( |
| 1634 | - path_segments("/tahinli/forge", "tahinli/forge"), | 1812 | + path_segments(Lang::En, "/tahinli/forge", "tahinli/forge"), |
| 1635 | vec![ | 1813 | vec![ |
| 1636 | ("tahinli".to_owned(), Some("/tahinli".to_owned())), | 1814 | ("tahinli".to_owned(), Some("/tahinli".to_owned())), |
| 1637 | ("forge".to_owned(), None), | 1815 | ("forge".to_owned(), None), |
| 1638 | ] | 1816 | ] |
| 1639 | ); | 1817 | ); |
| 1640 | - let (last, _) = path_segments("/tahinli/forge/issues", "tahinli/forge · Issues").remove(2); | 1818 | + let (last, _) = |
| 1819 | + path_segments(Lang::En, "/tahinli/forge/issues", "tahinli/forge · Issues").remove(2); | ||
| 1641 | assert_eq!(last, "Issues"); | 1820 | assert_eq!(last, "Issues"); |
| 1642 | - let (last, _) = path_segments("/tahinli/forge/commits/main", "tahinli/forge").remove(2); | 1821 | + let crumbs = path_segments(Lang::En, "/tahinli/forge/commits/main", "tahinli/forge"); |
| 1643 | - assert_eq!(last, "commits/main"); | 1822 | + assert_eq!( |
| 1644 | - assert!(path_segments("/explore", "Explore").is_empty()); | 1823 | + crumbs[2], |
| 1645 | - assert!(path_segments("/", "Home").is_empty()); | 1824 | + ( |
| 1825 | + "Commits".to_owned(), | ||
| 1826 | + Some("/tahinli/forge/commits".to_owned()) | ||
| 1827 | + ) | ||
| 1828 | + ); | ||
| 1829 | + assert_eq!(crumbs[3], ("main".to_owned(), None)); | ||
| 1830 | + let crumbs = path_segments(Lang::En, "/tahinli/forge/issues/4/edit", "tahinli/forge"); | ||
| 1831 | + let labels: Vec<&str> = crumbs.iter().map(|(label, _)| label.as_str()).collect(); | ||
| 1832 | + assert_eq!(labels, ["tahinli", "forge", "Issues", "#4", "Edit"]); | ||
| 1833 | + assert_eq!(crumbs[3].1.as_deref(), Some("/tahinli/forge/issues/4")); | ||
| 1834 | + assert!(path_segments(Lang::En, "/explore", "Explore").is_empty()); | ||
| 1835 | + assert!(path_segments(Lang::En, "/", "Home").is_empty()); | ||
| 1646 | let (last, _) = path_segments( | 1836 | let (last, _) = path_segments( |
| 1837 | + Lang::En, | ||
| 1647 | "/tahinli/forge/commit/0123456789abcdef0123456789abcdef01234567", | 1838 | "/tahinli/forge/commit/0123456789abcdef0123456789abcdef01234567", |
| 1648 | "tahinli/forge", | 1839 | "tahinli/forge", |
| 1649 | ) | 1840 | ) |
| 1650 | - .remove(2); | 1841 | + .remove(3); |
| 1651 | - assert_eq!(last, "commit/0123456"); | 1842 | + assert_eq!(last, "0123456"); |
| 1652 | } | 1843 | } |
| 1653 | 1844 | ||
| 1654 | #[test] | 1845 | #[test] |
| @@ -1725,7 +1916,7 @@ mod tests { | |||
| 1725 | ); | 1916 | ); |
| 1726 | } | 1917 | } |
| 1727 | 1918 | ||
| 1728 | - /// Renders `/settings/sessions` (a page that uses the shell) for a freshly signed-in user. | 1919 | + /// Renders `/settings/security` (a page that uses the shell) for a freshly signed-in user. |
| 1729 | async fn menu_html( | 1920 | async fn menu_html( |
| 1730 | router: &topcoat::router::Router, | 1921 | router: &topcoat::router::Router, |
| 1731 | store: &forge_core::Store, | 1922 | store: &forge_core::Store, |
| @@ -1744,7 +1935,7 @@ mod tests { | |||
| 1744 | crate::test_support::create_session(store, &user.id, token, "menu-csrf").await; | 1935 | crate::test_support::create_session(store, &user.id, token, "menu-csrf").await; |
| 1745 | let req = Request::builder() | 1936 | let req = Request::builder() |
| 1746 | .method("GET") | 1937 | .method("GET") |
| 1747 | - .uri("/settings/sessions") | 1938 | + .uri("/settings/security") |
| 1748 | .header("cookie", format!("__Host-{SESSION_COOKIE}={token}")) | 1939 | .header("cookie", format!("__Host-{SESSION_COOKIE}={token}")) |
| 1749 | .body(Body::empty()) | 1940 | .body(Body::empty()) |
| 1750 | .expect("request"); | 1941 | .expect("request"); |
| @@ -1848,7 +2039,7 @@ mod shell_tests { | |||
| 1848 | &page[at..at + len + 1] | 2039 | &page[at..at + len + 1] |
| 1849 | } | 2040 | } |
| 1850 | 2041 | ||
| 1851 | - /// The `<html>` tag of `/settings/sessions` for a signed-in user whose stored colours are the | 2042 | + /// The `<html>` tag of `/settings/security` for a signed-in user whose stored colours are the |
| 1852 | /// four ids given, in the order light accent, dark accent, light base, dark base. | 2043 | /// four ids given, in the order light accent, dark accent, light base, dark base. |
| 1853 | async fn html_tag_for_colours( | 2044 | async fn html_tag_for_colours( |
| 1854 | router: &topcoat::router::Router, | 2045 | router: &topcoat::router::Router, |
| @@ -1870,7 +2061,7 @@ mod shell_tests { | |||
| 1870 | crate::test_support::create_session(store, &user.id, token, "colour-csrf").await; | 2061 | crate::test_support::create_session(store, &user.id, token, "colour-csrf").await; |
| 1871 | let req = Request::builder() | 2062 | let req = Request::builder() |
| 1872 | .method("GET") | 2063 | .method("GET") |
| 1873 | - .uri("/settings/sessions") | 2064 | + .uri("/settings/security") |
| 1874 | .header("cookie", format!("__Host-{SESSION_COOKIE}={token}")) | 2065 | .header("cookie", format!("__Host-{SESSION_COOKIE}={token}")) |
| 1875 | .body(Body::empty()) | 2066 | .body(Body::empty()) |
| 1876 | .unwrap(); | 2067 | .unwrap(); |
| @@ -1932,12 +2123,12 @@ mod shell_tests { | |||
| 1932 | &store, | 2123 | &store, |
| 1933 | "hued", | 2124 | "hued", |
| 1934 | "hued-token", | 2125 | "hued-token", |
| 1935 | - ["hue-215", "hue-7", "hue-300", "spark"], | 2126 | + ["hue-215", "hue-7", "hue-300", "ink"], |
| 1936 | ) | 2127 | ) |
| 1937 | .await; | 2128 | .await; |
| 1938 | assert!(hued.contains("data-accent-light=\"hue-215\""), "{hued}"); | 2129 | assert!(hued.contains("data-accent-light=\"hue-215\""), "{hued}"); |
| 1939 | assert!(hued.contains("data-accent-dark=\"hue-7\""), "{hued}"); | 2130 | assert!(hued.contains("data-accent-dark=\"hue-7\""), "{hued}"); |
| 1940 | assert!(hued.contains("data-base-light=\"hue-300\""), "{hued}"); | 2131 | assert!(hued.contains("data-base-light=\"hue-300\""), "{hued}"); |
| 1941 | - assert!(hued.contains("data-base-dark=\"spark\""), "{hued}"); | 2132 | + assert!(hued.contains("data-base-dark=\"ink\""), "{hued}"); |
| 1942 | } | 2133 | } |
| 1943 | } | 2134 | } |
docs/ui-language.mdmodified+34 -8
| @@ -46,15 +46,20 @@ Sections never go in the rail: they go in `.tabs`. | |||
| 46 | ## Rows | 46 | ## Rows |
| 47 | 47 | ||
| 48 | `<a class="line" data-kb-row=""><span class="name">..</span><span class="val">..</span></a>` when the item | 48 | `<a class="line" data-kb-row=""><span class="name">..</span><span class="val">..</span></a>` when the item |
| 49 | -has its own page. When it opens in place: | 49 | +has its own page. Otherwise the row shows everything at once: its facts in the one `.val`, joined with |
| 50 | +" · ", and its actions right after them on the same line. A confirm opens in place of its word, on the row. | ||
| 50 | 51 | ||
| 51 | ```html | 52 | ```html |
| 52 | -<details class="row-open"> | 53 | +<div class="line"> |
| 53 | - <summary class="line"><span class="name">laptop</span><span class="val">SHA256:9fK2c1Qx</span></summary> | 54 | + <span class="name">laptop</span><span class="val">SHA256:9fK2c1Qx · added 3 days ago</span> |
| 54 | - <div class="opened">..</div> | 55 | + confirm_act(..Delete..) |
| 55 | -</details> | 56 | +</div> |
| 56 | ``` | 57 | ``` |
| 57 | 58 | ||
| 59 | +`<details class="row-open">` only for a row whose hidden part is an edit form (a rename, a role). Never a | ||
| 60 | +row that opens to show facts or a single action, never a link to a page that shows the same row again: | ||
| 61 | +one click to see, one to act. | ||
| 62 | + | ||
| 58 | Details come right after the title on one line. Nothing is pushed to the far end of a row: | 63 | Details come right after the title on one line. Nothing is pushed to the far end of a row: |
| 59 | no `margin-left:auto`, no `justify-content:space-between`, no second column at the right. | 64 | no `margin-left:auto`, no `justify-content:space-between`, no second column at the right. |
| 60 | 65 | ||
| @@ -96,7 +101,11 @@ label. Errors are `alert` at the top of the form they belong to, which stays ope | |||
| 96 | 101 | ||
| 97 | Every search bar is live: `data-live-search` on a real GET form's input in `.plain-search`. It sits in the | 102 | Every search bar is live: `data-live-search` on a real GET form's input in `.plain-search`. It sits in the |
| 98 | tools row or above the rail's list. Filters are the rail, or `.tabs` when there are only a few. Pagers | 103 | tools row or above the rail's list. Filters are the rail, or `.tabs` when there are only a few. Pagers |
| 99 | -appear only when another page exists, as one `nav.pager` row (Newer, the page, Older) under the list. An empty list is `.state` with one line and its action as `.act`. | 104 | +appear only when another page exists, as one `nav.pager` row (Newer, the page, Older) under the list, on |
| 105 | +the sheet's inset with a hairline above. A long log (the audit log) numbers its pages in the same row | ||
| 106 | +(`nav.pager.pager-numbered`), the current page held like a pressed tool. An empty list is `.state` with | ||
| 107 | +one line and its action as `.act`. A log reads as text: action words, then facts joined with " · ", never | ||
| 108 | +raw JSON; repeats in a row fold into one line with "×N". | ||
| 100 | 109 | ||
| 101 | ## Menus | 110 | ## Menus |
| 102 | 111 | ||
| @@ -108,8 +117,13 @@ triangles. It never leaves the window, on a phone either. | |||
| 108 | 117 | ||
| 109 | Tokens only: `--bg`, `--surface`, `--surface-2`, `--text`, `--muted`, `--border`, `--border-strong`, `--accent`, | 118 | Tokens only: `--bg`, `--surface`, `--surface-2`, `--text`, `--muted`, `--border`, `--border-strong`, `--accent`, |
| 110 | `--accent-soft`, `--bad`, `--danger-bg`, `--add-bg`, `--del-bg`. Accent marks the one live or selected | 119 | `--accent-soft`, `--bad`, `--danger-bg`, `--add-bg`, `--del-bg`. Accent marks the one live or selected |
| 111 | -thing. Running colour is the accent. Passed is neutral. Failed is `--bad`. Cancelled is grey, never red. | 120 | +thing. In CI, running is the accent, passed is `--ok` green and failed is `--bad`, everywhere a result |
| 112 | -Added is blue and deleted is rose. Graphs use the same set: neutral marks, accent for now. | 121 | +shows (ticks, step strips, timeline, history bars). `--ok` takes the accent's lightness and strength |
| 122 | +with a green hue, so results sit with whichever accent is chosen. Cancelled is grey, never red. Added | ||
| 123 | +is blue and deleted is rose. | ||
| 124 | + | ||
| 125 | +A colour choice offers five presets and a Custom chip (its swatch and the word), on the same columns | ||
| 126 | +in every row. | ||
| 113 | 127 | ||
| 114 | ## Type | 128 | ## Type |
| 115 | 129 | ||
| @@ -132,3 +146,15 @@ Turkish page shows no English, an English page no Turkish. | |||
| 132 | - A setting must visibly change something, or it goes. | 146 | - A setting must visibly change something, or it goes. |
| 133 | - A phone (390px) is one column: no sideways scroll, tabs scroll inside their row. | 147 | - A phone (390px) is one column: no sideways scroll, tabs scroll inside their row. |
| 134 | - Pages fit one screen where they can: use tabs and the rail, not stacked unrelated topics. | 148 | - Pages fit one screen where they can: use tabs and the rail, not stacked unrelated topics. |
| 149 | + | ||
| 150 | +## Fixed places | ||
| 151 | + | ||
| 152 | +- Every head on a page with tabs is one height (a 38px title line and one sub line), so the tabs and the | ||
| 153 | + sheet never move when you switch tabs. | ||
| 154 | +- The path bar names every place above the page as a link: section, item (`#12`), page. A page whose | ||
| 155 | + parent is not in its address (a job's run) passes it to `shell(parents: ..)`. No page needs the browser's | ||
| 156 | + Back button. | ||
| 157 | +- A form of one field puts its submit beside the field. | ||
| 158 | +- Every control has one focus ring: 2px in `--focus`, inside its own edge (`outline-offset: -2px`), so | ||
| 159 | + no sheet, row or scrolling list cuts it. | ||
| 160 | +- A tab's own pages sit in its rail: the Security log is a Security rail item, not a page of its own. | ||
style/_one.scssmodified+183 -7
| @@ -2260,10 +2260,13 @@ main > .diff-section, | |||
| 2260 | display: contents; | 2260 | display: contents; |
| 2261 | } | 2261 | } |
| 2262 | 2262 | ||
| 2263 | +// Log or Timeline: the current one held like a pressed tool inside the sheet, as a sort choice is, | ||
| 2264 | +// with no underline or accent of its own. | ||
| 2263 | #ci-view-log:checked ~ .ci-logbar .ci-tl-tab-log, | 2265 | #ci-view-log:checked ~ .ci-logbar .ci-tl-tab-log, |
| 2264 | #ci-view-timeline:checked ~ .ci-logbar .ci-tl-tab-timeline { | 2266 | #ci-view-timeline:checked ~ .ci-logbar .ci-tl-tab-timeline { |
| 2265 | - background: var(--accent-soft); | 2267 | + background: var(--surface-2); |
| 2266 | - color: var(--accent); | 2268 | + color: var(--text); |
| 2269 | + box-shadow: none; | ||
| 2267 | font-weight: 500; // the same as its neighbours, so choosing never shifts the row | 2270 | font-weight: 500; // the same as its neighbours, so choosing never shifts the row |
| 2268 | } | 2271 | } |
| 2269 | 2272 | ||
| @@ -3042,18 +3045,17 @@ details:not([open])::details-content { | |||
| 3042 | align-self: center; | 3045 | align-self: center; |
| 3043 | } | 3046 | } |
| 3044 | 3047 | ||
| 3045 | -// Colour rows: the swatches sit on nine fixed columns, the most any row has, so the sliders and the hex | 3048 | +// Colour rows: five presets on fixed columns, then the Custom chip, then hue, vividness and hex, |
| 3046 | -// box of Background and Accent start on one edge whatever each row holds. Hue, vividness and hex | 3049 | +// so Background and Accent line up column for column. A note about a lightened hex goes under them. |
| 3047 | -// follow on one line, each its own width; a note about a lightened hex goes under them. | ||
| 3048 | .colour-choices { | 3050 | .colour-choices { |
| 3049 | display: grid; | 3051 | display: grid; |
| 3050 | - grid-template-columns: repeat(9, 30px) auto; | 3052 | + grid-template-columns: repeat(5, 30px) auto auto; |
| 3051 | align-items: center; | 3053 | align-items: center; |
| 3052 | gap: 8px; | 3054 | gap: 8px; |
| 3053 | } | 3055 | } |
| 3054 | 3056 | ||
| 3055 | .colour-choices > .tune { | 3057 | .colour-choices > .tune { |
| 3056 | - grid-column: 10; | 3058 | + grid-column: 7; |
| 3057 | display: flex; | 3059 | display: flex; |
| 3058 | flex-wrap: wrap; | 3060 | flex-wrap: wrap; |
| 3059 | align-items: center; | 3061 | align-items: center; |
| @@ -3097,3 +3099,177 @@ details:not([open])::details-content { | |||
| 3097 | margin: 0; | 3099 | margin: 0; |
| 3098 | } | 3100 | } |
| 3099 | } | 3101 | } |
| 3102 | + | ||
| 3103 | +// Every head of a page with tabs is one height: a 38px title line (as tall as the button beside a | ||
| 3104 | +// title) and one sub line, so switching tabs never moves the tabs or what is under them. | ||
| 3105 | +.head-title { | ||
| 3106 | + min-height: 38px; | ||
| 3107 | +} | ||
| 3108 | + | ||
| 3109 | +main:has(> nav.tabs) > .head { | ||
| 3110 | + min-height: 64px; | ||
| 3111 | +} | ||
| 3112 | + | ||
| 3113 | +// A focus ring sits inside what has it, so a list that scrolls on its own never cuts it off. | ||
| 3114 | +:is(.rail-item, .line, summary, nav.tabs a, .tabs a, .sub a, .choice label):focus-visible { | ||
| 3115 | + outline-offset: -2px; | ||
| 3116 | +} | ||
| 3117 | + | ||
| 3118 | +// A row's actions follow its text on the same line. A confirm opens in place of its word: the | ||
| 3119 | +// question, then the danger button and Keep it, all on the row. | ||
| 3120 | +.line { | ||
| 3121 | + flex-wrap: wrap; | ||
| 3122 | +} | ||
| 3123 | + | ||
| 3124 | +.line > :is(details.reveal, .act-form, a.act, button.act) { | ||
| 3125 | + flex: none; | ||
| 3126 | + align-self: center; | ||
| 3127 | +} | ||
| 3128 | + | ||
| 3129 | +.line > details.reveal[open] > summary { | ||
| 3130 | + display: none; | ||
| 3131 | +} | ||
| 3132 | + | ||
| 3133 | +.line > details.reveal > form.opened { | ||
| 3134 | + display: flex; | ||
| 3135 | + flex-direction: row; | ||
| 3136 | + flex-wrap: wrap; | ||
| 3137 | + align-items: center; | ||
| 3138 | + gap: 8px; | ||
| 3139 | + margin: 0; | ||
| 3140 | + padding: 0; | ||
| 3141 | + | ||
| 3142 | + > .hint { | ||
| 3143 | + margin: 0; | ||
| 3144 | + } | ||
| 3145 | + | ||
| 3146 | + > .acts.asks { | ||
| 3147 | + margin: 0; | ||
| 3148 | + } | ||
| 3149 | +} | ||
| 3150 | + | ||
| 3151 | +// The account menu's name is its profile link: a menu row in the name's weight. | ||
| 3152 | +a.corner-who { | ||
| 3153 | + display: flex; | ||
| 3154 | + align-items: center; | ||
| 3155 | + min-height: 34px; | ||
| 3156 | + box-sizing: border-box; | ||
| 3157 | + border-radius: 12px; | ||
| 3158 | + color: var(--text); | ||
| 3159 | + font-weight: 600; | ||
| 3160 | + text-decoration: none; | ||
| 3161 | + | ||
| 3162 | + &:hover { | ||
| 3163 | + background: var(--surface-2); | ||
| 3164 | + } | ||
| 3165 | +} | ||
| 3166 | + | ||
| 3167 | +// Run alerts: the previews stand on the switch's middle line, as tall as its choices. | ||
| 3168 | +.sound-row > .act.play { | ||
| 3169 | + align-self: center; | ||
| 3170 | + height: 32px; | ||
| 3171 | + border-radius: 16px; | ||
| 3172 | +} | ||
| 3173 | + | ||
| 3174 | +// The custom colour reads as a word with its swatch, not as one more circle. | ||
| 3175 | +.colour-choice:has(> .custom-word) { | ||
| 3176 | + display: inline-flex; | ||
| 3177 | + flex-direction: row; | ||
| 3178 | + align-items: center; | ||
| 3179 | + gap: 8px; | ||
| 3180 | + width: auto; | ||
| 3181 | + height: 32px; | ||
| 3182 | + padding: 0 12px 0 4px; | ||
| 3183 | + border-radius: 16px; | ||
| 3184 | + background: var(--surface-2); | ||
| 3185 | + color: var(--text); | ||
| 3186 | + font-size: 14px; | ||
| 3187 | + cursor: pointer; | ||
| 3188 | + | ||
| 3189 | + > .hue-swatch { | ||
| 3190 | + width: 24px; | ||
| 3191 | + height: 24px; | ||
| 3192 | + } | ||
| 3193 | + | ||
| 3194 | + > .custom-word { | ||
| 3195 | + max-width: none; | ||
| 3196 | + overflow: visible; | ||
| 3197 | + font-size: 14px; | ||
| 3198 | + font-weight: 400; | ||
| 3199 | + color: var(--text); | ||
| 3200 | + } | ||
| 3201 | +} | ||
| 3202 | + | ||
| 3203 | +// A form of one field sends from beside it: the field, then its button on the same line. | ||
| 3204 | +form.fields:has(> .field + button[type="submit"]):not(:has(> :not(.field, button[type="submit"], input[type="hidden"]))):not(:has(> .field ~ .field)) { | ||
| 3205 | + flex-direction: row; | ||
| 3206 | + flex-wrap: wrap; | ||
| 3207 | + align-items: flex-start; | ||
| 3208 | + column-gap: 8px; | ||
| 3209 | + | ||
| 3210 | + > .field { | ||
| 3211 | + flex: none; | ||
| 3212 | + } | ||
| 3213 | + | ||
| 3214 | + > button[type="submit"] { | ||
| 3215 | + margin: 0; | ||
| 3216 | + } | ||
| 3217 | +} | ||
| 3218 | + | ||
| 3219 | +// Numbered pages are the same row as every pager: on the sheet's inset with a hairline above, the | ||
| 3220 | +// numbers quiet words, the current one held like a pressed tool at the same weight, so moving | ||
| 3221 | +// between pages never shifts the row. | ||
| 3222 | +nav.pager.pager-numbered { | ||
| 3223 | + display: flex; | ||
| 3224 | + flex-wrap: wrap; | ||
| 3225 | + align-items: center; | ||
| 3226 | + gap: 4px; | ||
| 3227 | + margin: 0; | ||
| 3228 | + padding: 8px 18px; | ||
| 3229 | + border-top: 1px solid var(--border); | ||
| 3230 | + font-size: 14px; | ||
| 3231 | + | ||
| 3232 | + .pager-page, | ||
| 3233 | + .pager-step { | ||
| 3234 | + color: var(--muted); | ||
| 3235 | + font-weight: 500; | ||
| 3236 | + } | ||
| 3237 | + | ||
| 3238 | + > :first-child { | ||
| 3239 | + margin-left: -8px; | ||
| 3240 | + } | ||
| 3241 | + | ||
| 3242 | + .current { | ||
| 3243 | + background: var(--surface-2); | ||
| 3244 | + color: var(--text); | ||
| 3245 | + font-weight: 500; | ||
| 3246 | + } | ||
| 3247 | + | ||
| 3248 | + a:hover { | ||
| 3249 | + color: var(--text); | ||
| 3250 | + } | ||
| 3251 | +} | ||
| 3252 | + | ||
| 3253 | +// A commit subject among a row's facts stays inline with the facts after it. | ||
| 3254 | +.line .val .commit-line { | ||
| 3255 | + display: inline-flex; | ||
| 3256 | + max-width: 40ch; | ||
| 3257 | + vertical-align: bottom; | ||
| 3258 | +} | ||
| 3259 | + | ||
| 3260 | +// Passed is green everywhere, but a green with the accent's lightness and strength, so CI results | ||
| 3261 | +// sit with the chosen accent instead of beside it. A grey accent still gets a readable green. | ||
| 3262 | +@supports (color: oklch(from red l c h)) { | ||
| 3263 | + :root:root:root { | ||
| 3264 | + --ok: oklch(from var(--accent) l clamp(0.09, c, 0.15) 158); | ||
| 3265 | + } | ||
| 3266 | +} | ||
| 3267 | + | ||
| 3268 | +// One focus ring for every control: 2px in the focus colour, drawn inside the control's own edge, | ||
| 3269 | +// so a sheet's or a row's edge never clips it and it looks the same on a button, a quiet action, a | ||
| 3270 | +// pager number or a tab. | ||
| 3271 | +:is(button, .button, a.act, .act, nav.pager a, .ci-tl-tab, .corner-who):focus-visible { | ||
| 3272 | + outline: 2px solid var(--focus); | ||
| 3273 | + outline-offset: -2px; | ||
| 3274 | + box-shadow: none; | ||
| 3275 | +} | ||
style/_one_ci.scssmodified+96 -0
| @@ -356,3 +356,99 @@ main:has(> .ci-job) > .sheet { | |||
| 356 | .ci-job .ci-dock { | 356 | .ci-job .ci-dock { |
| 357 | padding: 12px 18px; | 357 | padding: 12px 18px; |
| 358 | } | 358 | } |
| 359 | + | ||
| 360 | +// Log lines: the number column fits five digits on one line in the log's own font, so a number | ||
| 361 | +// never wraps under itself and every line is one line tall. | ||
| 362 | +.ci-log .ll { | ||
| 363 | + grid-template-columns: 7ch minmax(0, 1fr); | ||
| 364 | + column-gap: 2ch; | ||
| 365 | +} | ||
| 366 | + | ||
| 367 | +.ci-log .ln { | ||
| 368 | + width: auto; | ||
| 369 | + padding-right: 0; | ||
| 370 | + white-space: nowrap; | ||
| 371 | +} | ||
| 372 | + | ||
| 373 | +// A group's name is a line like the others, with its number, and keeps a hairline under it while | ||
| 374 | +// it sticks. | ||
| 375 | +.ci-log details.lg > summary { | ||
| 376 | + display: grid; | ||
| 377 | +} | ||
| 378 | + | ||
| 379 | +// A run or job page fills the window under the top bar, whatever stands between them (a banner, | ||
| 380 | +// a notice): the page is a column, and the log takes the room left. | ||
| 381 | +body:has(> .shell main > :is(.ci-run, .ci-job)) { | ||
| 382 | + height: 100dvh; | ||
| 383 | + min-height: 600px; | ||
| 384 | + | ||
| 385 | + > .shell { | ||
| 386 | + flex: 1 1 0; | ||
| 387 | + min-height: 0; | ||
| 388 | + } | ||
| 389 | + | ||
| 390 | + .shell-body { | ||
| 391 | + min-height: 0; | ||
| 392 | + } | ||
| 393 | +} | ||
| 394 | + | ||
| 395 | +.shell-body > main:has(> :is(.ci-run, .ci-job)) { | ||
| 396 | + flex: 1 1 0; | ||
| 397 | + height: auto; | ||
| 398 | + min-height: 0; | ||
| 399 | +} | ||
| 400 | + | ||
| 401 | +// Artifacts are one line of links under the log, not a list that pushes the page past the window. | ||
| 402 | +.ci-job .ci-artifacts { | ||
| 403 | + display: flex; | ||
| 404 | + flex: none; | ||
| 405 | + flex-wrap: wrap; | ||
| 406 | + align-items: baseline; | ||
| 407 | + gap: 4px 16px; | ||
| 408 | + padding: 10px 18px; | ||
| 409 | + border-top: 1px solid var(--border); | ||
| 410 | + font-size: 14px; | ||
| 411 | + | ||
| 412 | + > h2 { | ||
| 413 | + margin: 0; | ||
| 414 | + color: var(--muted); | ||
| 415 | + font-size: 13px; | ||
| 416 | + font-weight: 600; | ||
| 417 | + } | ||
| 418 | + | ||
| 419 | + .val { | ||
| 420 | + color: var(--muted); | ||
| 421 | + font-size: 13px; | ||
| 422 | + } | ||
| 423 | +} | ||
| 424 | + | ||
| 425 | +// The state in a head's sub line is its word in its colour after a dot, on the line's middle, not a | ||
| 426 | +// box that stands taller than the text around it. | ||
| 427 | +.head-sub .ci-state { | ||
| 428 | + display: inline-flex; | ||
| 429 | + align-items: center; | ||
| 430 | + gap: 6px; | ||
| 431 | + height: auto; | ||
| 432 | + padding: 0; | ||
| 433 | + border: 0; | ||
| 434 | + background: none; | ||
| 435 | + font-size: 14px; | ||
| 436 | + line-height: 20px; | ||
| 437 | +} | ||
| 438 | + | ||
| 439 | +.head-sub .ci-state::before { | ||
| 440 | + margin-right: 0; | ||
| 441 | +} | ||
| 442 | + | ||
| 443 | +// The Timeline tab is the chart and one line a job: what ran where and for how long, with its Re-run. | ||
| 444 | +// The output lives in the Log tab, so no tail of it repeats here. | ||
| 445 | +.ci-tl-panel-timeline { | ||
| 446 | + :is(.ci-job-head, .ci-job-last, .ci-job-tail, .ci-chev) { | ||
| 447 | + display: none; | ||
| 448 | + } | ||
| 449 | + | ||
| 450 | + .ci-job-list { | ||
| 451 | + margin-top: 8px; | ||
| 452 | + border-top: 1px solid var(--border); | ||
| 453 | + } | ||
| 454 | +} | ||
style/_one_people.scssmodified+46 -0
| @@ -305,3 +305,49 @@ | |||
| 305 | .snippet-form .snippet-tabs { | 305 | .snippet-form .snippet-tabs { |
| 306 | flex: 0 1 auto; | 306 | flex: 0 1 auto; |
| 307 | } | 307 | } |
| 308 | + | ||
| 309 | +// A snippet's files are one row on the control column: the file chips, Add file, then how many of | ||
| 310 | +// how many, the way every control starts on the fields' edge. | ||
| 311 | +.snippet-form > .snippet-files { | ||
| 312 | + display: flex; | ||
| 313 | + flex-direction: row; | ||
| 314 | + flex-wrap: wrap; | ||
| 315 | + align-items: center; | ||
| 316 | + column-gap: 8px; | ||
| 317 | + row-gap: 6px; | ||
| 318 | + padding-left: calc(var(--label-w, 130px) + 16px); | ||
| 319 | + | ||
| 320 | + > .snippet-tabbar { | ||
| 321 | + display: contents; | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | + .snippet-tabs { | ||
| 325 | + order: 1; | ||
| 326 | + margin: 0; | ||
| 327 | + padding: 0; | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + > .acts { | ||
| 331 | + order: 2; | ||
| 332 | + margin: 0; | ||
| 333 | + } | ||
| 334 | + | ||
| 335 | + .snippet-count { | ||
| 336 | + order: 3; | ||
| 337 | + margin: 0; | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + > fieldset { | ||
| 341 | + order: 4; | ||
| 342 | + flex: 1 1 100%; | ||
| 343 | + margin: 0 0 0 calc(-1 * (var(--label-w, 130px) + 16px)); | ||
| 344 | + } | ||
| 345 | + | ||
| 346 | + @media (max-width: 700px) { | ||
| 347 | + padding-left: 0; | ||
| 348 | + | ||
| 349 | + > fieldset { | ||
| 350 | + margin-left: 0; | ||
| 351 | + } | ||
| 352 | + } | ||
| 353 | +} | ||