| | @@ -138,8 +138,8 @@ fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) { |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | async fn create_token(http: &Http, session: &str) -> String { |
| 141 | | - let page = http.get_cookie("/settings/tokens", session).await; |
| 142 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 141 | + let page = http.get_cookie("/settings/keys", session).await; |
| 142 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 143 | 143 | let csrf = input_value(&page.body, "csrf"); |
| 144 | 144 | let res = http |
| 145 | 145 | .post_form( |
| | @@ -99,8 +99,8 @@ fn remote_sha(repo: &Path, reference: &str) -> String { |
| 99 | 99 | |
| 100 | 100 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 101 | 101 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 102 | | - let page = http.get_cookie("/settings/tokens", session).await; |
| 103 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 102 | + let page = http.get_cookie("/settings/keys", session).await; |
| 103 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 104 | 104 | let csrf = input_value(&page.body, "csrf"); |
| 105 | 105 | let res = http |
| 106 | 106 | .post_form( |
| | @@ -272,8 +272,8 @@ async fn login(http: &Http, username: &str, password: &str) -> String { |
| 272 | 272 | |
| 273 | 273 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 274 | 274 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 275 | | - let page = http.get("/settings/tokens", Some(session)).await; |
| 276 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 275 | + let page = http.get("/settings/keys", Some(session)).await; |
| 276 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 277 | 277 | let csrf = input_value(&page.body(), "csrf"); |
| 278 | 278 | let res = http |
| 279 | 279 | .post_form( |
| | @@ -199,7 +199,7 @@ async fn csrf_from(http: &Http, path: &str, session: &str) -> String { |
| 199 | 199 | |
| 200 | 200 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 201 | 201 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 202 | | - let csrf = csrf_from(http, "/settings/tokens", session).await; |
| 202 | + let csrf = csrf_from(http, "/settings/keys", session).await; |
| 203 | 203 | let res = http |
| 204 | 204 | .post_form( |
| 205 | 205 | "/settings/tokens", |
| | @@ -622,7 +622,7 @@ async fn fork_pull_waits_for_approval_and_runs_without_secrets() { |
| 622 | 622 | // Bob forks and changes the workflow on a branch. |
| 623 | 623 | let bob = login(&b.http, "bob", BOB_PW).await; |
| 624 | 624 | let bob_token = create_token(&b.http, &bob, "bob-token").await; |
| 625 | | - let csrf = csrf_from(&b.http, "/settings/tokens", &bob).await; |
| 625 | + let csrf = csrf_from(&b.http, "/settings/keys", &bob).await; |
| 626 | 626 | let fork = b |
| 627 | 627 | .http |
| 628 | 628 | .post_form(&format!("{REPO_PATH}/fork"), &[("csrf", &csrf)], Some(&bob)) |
| | @@ -656,7 +656,7 @@ async fn fork_pull_waits_for_approval_and_runs_without_secrets() { |
| 656 | 656 | ) |
| 657 | 657 | .await; |
| 658 | 658 | assert_eq!(compare.status, 200, "GET compare"); |
| 659 | | - let csrf = csrf_from(&b.http, "/settings/tokens", &bob).await; |
| 659 | + let csrf = csrf_from(&b.http, "/settings/keys", &bob).await; |
| 660 | 660 | let open = b |
| 661 | 661 | .http |
| 662 | 662 | .post_form( |
| | @@ -50,7 +50,10 @@ async fn snippets_page_follows_the_browser_language() { |
| 50 | 50 | assert_eq!(turkish.status().as_u16(), 200); |
| 51 | 51 | let body = turkish.text().await.expect("read body"); |
| 52 | 52 | assert!(body.contains("<html lang=\"tr\""), "html lang is tr"); |
| 53 | | - assert!(body.contains("<h1>Parçacıklar</h1>"), "Turkish heading"); |
| 53 | + assert!( |
| 54 | + body.contains("<h1 class=\"sr-only\">Parçacıklar</h1>"), |
| 55 | + "Turkish heading" |
| 56 | + ); |
| 54 | 57 | assert!( |
| 55 | 58 | body.contains("Gösterilecek parçacık yok."), |
| 56 | 59 | "Turkish empty state" |
| | @@ -64,6 +67,9 @@ async fn snippets_page_follows_the_browser_language() { |
| 64 | 67 | .await |
| 65 | 68 | .expect("GET /snippets (en)"); |
| 66 | 69 | let body = english.text().await.expect("read body"); |
| 67 | | - assert!(body.contains("<h1>Snippets</h1>"), "English heading"); |
| 70 | + assert!( |
| 71 | + body.contains("<h1 class=\"sr-only\">Snippets</h1>"), |
| 72 | + "English heading" |
| 73 | + ); |
| 68 | 74 | assert!(body.contains("No snippets to show."), "English empty state"); |
| 69 | 75 | } |
| | @@ -142,8 +142,8 @@ fn read(path: PathBuf) -> String { |
| 142 | 142 | |
| 143 | 143 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 144 | 144 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 145 | | - let page = http.get_cookie("/settings/tokens", session).await; |
| 146 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 145 | + let page = http.get_cookie("/settings/keys", session).await; |
| 146 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 147 | 147 | let csrf = input_value(&page.body, "csrf"); |
| 148 | 148 | let res = http |
| 149 | 149 | .post_form( |
| | @@ -546,9 +546,14 @@ async fn suspended_user_token_is_refused_over_http_git() { |
| 546 | 546 | assert_eq!(list.status, 200, "GET /admin/users"); |
| 547 | 547 | let doc = scraper::Html::parse_document(&list.body); |
| 548 | 548 | let link = scraper::Selector::parse("a[href^=\"/admin/users/\"]").expect("selector"); |
| 549 | + let name = scraper::Selector::parse(".name").expect("selector"); |
| 549 | 550 | let bob_href = doc |
| 550 | 551 | .select(&link) |
| 551 | | - .find(|a| a.text().collect::<String>().trim() == "bob") |
| 552 | + .find(|a| { |
| 553 | + a.select(&name) |
| 554 | + .next() |
| 555 | + .is_some_and(|n| n.text().collect::<String>().trim() == "bob") |
| 556 | + }) |
| 552 | 557 | .and_then(|a| a.value().attr("href")) |
| 553 | 558 | .expect("bob's admin link") |
| 554 | 559 | .to_owned(); |
| | @@ -80,8 +80,8 @@ fn commit_file(repo: &Path, name: &str, message: &str) -> String { |
| 80 | 80 | |
| 81 | 81 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 82 | 82 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 83 | | - let page = http.get_cookie("/settings/tokens", session).await; |
| 84 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 83 | + let page = http.get_cookie("/settings/keys", session).await; |
| 84 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 85 | 85 | let csrf = input_value(&page.body, "csrf"); |
| 86 | 86 | let res = http |
| 87 | 87 | .post_form( |
| | @@ -62,8 +62,8 @@ fn payload() -> Vec<u8> { |
| 62 | 62 | |
| 63 | 63 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 64 | 64 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 65 | | - let page = http.get("/settings/tokens", Some(session)).await; |
| 66 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 65 | + let page = http.get("/settings/keys", Some(session)).await; |
| 66 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 67 | 67 | let csrf = input_value(&page.body, "csrf"); |
| 68 | 68 | let res = http |
| 69 | 69 | .post_form( |
| | @@ -141,7 +141,7 @@ async fn csrf_from(http: &Http, path: &str, session: &str) -> String { |
| 141 | 141 | |
| 142 | 142 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 143 | 143 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 144 | | - let csrf = csrf_from(http, "/settings/tokens", session).await; |
| 144 | + let csrf = csrf_from(http, "/settings/keys", session).await; |
| 145 | 145 | let res = http |
| 146 | 146 | .post_form( |
| 147 | 147 | "/settings/tokens", |
| | @@ -169,8 +169,8 @@ async fn wait_for(what: &str, check: impl Fn() -> bool) { |
| 169 | 169 | |
| 170 | 170 | /// The session's CSRF token, scraped from the token settings page. |
| 171 | 171 | async fn csrf_token(http: &Http, session: &str) -> String { |
| 172 | | - let page = http.get_cookie("/settings/tokens", session).await; |
| 173 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 172 | + let page = http.get_cookie("/settings/keys", session).await; |
| 173 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 174 | 174 | input_value(&page.body, "csrf") |
| 175 | 175 | } |
| 176 | 176 | |
| | @@ -48,8 +48,8 @@ fn admin(config: &Path, args: &[&str]) -> Output { |
| 48 | 48 | |
| 49 | 49 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 50 | 50 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 51 | | - let page = http.get("/settings/tokens", Some(session)).await; |
| 52 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 51 | + let page = http.get("/settings/keys", Some(session)).await; |
| 52 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 53 | 53 | input_value(&page.body, "csrf") |
| 54 | 54 | } |
| 55 | 55 | |
| | @@ -61,8 +61,8 @@ fn admin(config: &Path, args: &[&str]) -> Output { |
| 61 | 61 | |
| 62 | 62 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 63 | 63 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 64 | | - let page = http.get("/settings/tokens", Some(session)).await; |
| 65 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 64 | + let page = http.get("/settings/keys", Some(session)).await; |
| 65 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 66 | 66 | input_value(&page.body, "csrf") |
| 67 | 67 | } |
| 68 | 68 | |
| | @@ -126,8 +126,8 @@ fn parent_count(dir: &Path, commit: &str) -> usize { |
| 126 | 126 | |
| 127 | 127 | /// The session's CSRF token, scraped from the token settings page. |
| 128 | 128 | async fn csrf_token(http: &Http, session: &str) -> String { |
| 129 | | - let page = http.get_cookie("/settings/tokens", session).await; |
| 130 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 129 | + let page = http.get_cookie("/settings/keys", session).await; |
| 130 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 131 | 131 | input_value(&page.body, "csrf") |
| 132 | 132 | } |
| 133 | 133 | |
| | @@ -35,8 +35,8 @@ fn admin(config: &Path, args: &[&str]) -> Output { |
| 35 | 35 | |
| 36 | 36 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 37 | 37 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 38 | | - let page = http.get("/settings/tokens", Some(session)).await; |
| 39 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 38 | + let page = http.get("/settings/keys", Some(session)).await; |
| 39 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 40 | 40 | input_value(&page.body, "csrf") |
| 41 | 41 | } |
| 42 | 42 | |
| | @@ -47,8 +47,8 @@ fn admin(config: &Path, args: &[&str]) { |
| 47 | 47 | |
| 48 | 48 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 49 | 49 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 50 | | - let page = http.get("/settings/tokens", Some(session)).await; |
| 51 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 50 | + let page = http.get("/settings/keys", Some(session)).await; |
| 51 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 52 | 52 | input_value(&page.body, "csrf") |
| 53 | 53 | } |
| 54 | 54 | |
| | @@ -37,8 +37,8 @@ fn admin(config: &Path, args: &[&str]) -> Output { |
| 37 | 37 | |
| 38 | 38 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 39 | 39 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 40 | | - let page = http.get("/settings/tokens", Some(session)).await; |
| 41 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 40 | + let page = http.get("/settings/keys", Some(session)).await; |
| 41 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 42 | 42 | input_value(&page.body, "csrf") |
| 43 | 43 | } |
| 44 | 44 | |
| | @@ -379,16 +379,18 @@ async fn repo_settings_deletes_rows_when_repo_dir_is_missing() { |
| 379 | 379 | /// of its summary pills. The built-in default-branch row has no rule behind it, so it is skipped. |
| 380 | 380 | fn branch_rows(body: &str) -> Vec<Vec<String>> { |
| 381 | 381 | let doc = scraper::Html::parse_document(body); |
| 382 | | - let cards = scraper::Selector::parse("details.rule-row:not(.rule-new)").expect("selector"); |
| 383 | | - let pattern = scraper::Selector::parse("summary code.rule-pattern").expect("selector"); |
| 384 | | - let pills = scraper::Selector::parse("summary .rule-pill").expect("selector"); |
| 382 | + // Every rule row is a `details` with the pattern in its summary's name; the "+ New rule" row |
| 383 | + // has no pattern there, so it drops out. |
| 384 | + let cards = scraper::Selector::parse("details.row-open").expect("selector"); |
| 385 | + let pattern = scraper::Selector::parse("summary .name code").expect("selector"); |
| 386 | + let pills = scraper::Selector::parse("summary .rule-pills span").expect("selector"); |
| 385 | 387 | let text = |el: scraper::ElementRef| el.text().collect::<String>().trim().to_owned(); |
| 386 | 388 | doc.select(&cards) |
| 387 | | - .map(|card| { |
| 388 | | - let mut cells: Vec<String> = |
| 389 | | - card.select(&pattern).next().map(text).into_iter().collect(); |
| 389 | + .filter_map(|card| { |
| 390 | + let name = card.select(&pattern).next().map(text)?; |
| 391 | + let mut cells = vec![name]; |
| 390 | 392 | cells.extend(card.select(&pills).map(text)); |
| 391 | | - cells |
| 393 | + Some(cells) |
| 392 | 394 | }) |
| 393 | 395 | .collect() |
| 394 | 396 | } |
| | @@ -47,8 +47,8 @@ fn admin(config: &std::path::Path, args: &[&str]) { |
| 47 | 47 | |
| 48 | 48 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 49 | 49 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 50 | | - let page = http.get("/settings/tokens", Some(session)).await; |
| 51 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 50 | + let page = http.get("/settings/keys", Some(session)).await; |
| 51 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 52 | 52 | input_value(&page.body, "csrf") |
| 53 | 53 | } |
| 54 | 54 | |
| | @@ -1,5 +1,5 @@ |
| 1 | | -//! Black-box tests for the admin and settings section sidebars: every page under `/admin` and |
| 2 | | -//! `/settings` swaps the global links for the section's own list, marks the current entry with |
| 1 | +//! Black-box tests for the admin and settings section tabs: every page under `/admin` and |
| 2 | +//! `/settings` shows the section's own tab row above the page, marks the current tab with |
| 3 | 3 | //! `aria-current="page"`, and has no " · "-joined link row. |
| 4 | 4 | |
| 5 | 5 | #![allow(dead_code)] |
| | @@ -130,11 +130,14 @@ async fn start() -> Env { |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | | -/// The sidebar links as (href, aria-current) pairs. |
| 134 | | -fn sidebar(body: &str) -> Vec<(String, Option<String>)> { |
| 133 | +/// The section's tab row as (href, aria-current) pairs. The row is the first `nav.tabs` in `main`, |
| 134 | +/// which the shell puts before the page's own content, so a page's own tabs are not read here. |
| 135 | +fn tab_links(body: &str) -> Vec<(String, Option<String>)> { |
| 135 | 136 | let doc = scraper::Html::parse_document(body); |
| 136 | | - let sel = scraper::Selector::parse("aside.shell-sidebar a.side-link").expect("selector"); |
| 137 | | - doc.select(&sel) |
| 137 | + let row = scraper::Selector::parse("main nav.tabs").expect("selector"); |
| 138 | + let links = scraper::Selector::parse("a").expect("selector"); |
| 139 | + let row = doc.select(&row).next().expect("section tab row"); |
| 140 | + row.select(&links) |
| 138 | 141 | .map(|a| { |
| 139 | 142 | ( |
| 140 | 143 | a.value().attr("href").unwrap_or("").to_owned(), |
| | @@ -144,9 +147,11 @@ fn sidebar(body: &str) -> Vec<(String, Option<String>)> { |
| 144 | 147 | .collect() |
| 145 | 148 | } |
| 146 | 149 | |
| 147 | | -fn assert_section(body: &str, current: &str, hrefs: &[&str]) { |
| 148 | | - let links = sidebar(body); |
| 149 | | - assert_eq!(links[0].0, "/", "first entry is the way back"); |
| 150 | +/// Checks the section's tab row: its first tab is the section's first, every tab in `hrefs` is |
| 151 | +/// there, and exactly one tab, the one at `current`, is marked. |
| 152 | +fn assert_tabs(body: &str, current: &str, hrefs: &[&str]) { |
| 153 | + let links = tab_links(body); |
| 154 | + assert_eq!(links[0].0, hrefs[0], "first tab is the section's first"); |
| 150 | 155 | for href in hrefs { |
| 151 | 156 | assert!(links.iter().any(|(h, _)| h == href), "missing {href}"); |
| 152 | 157 | } |
| | @@ -154,13 +159,13 @@ fn assert_section(body: &str, current: &str, hrefs: &[&str]) { |
| 154 | 159 | .iter() |
| 155 | 160 | .filter(|(_, c)| c.as_deref() == Some("page")) |
| 156 | 161 | .collect(); |
| 157 | | - assert_eq!(marked.len(), 1, "exactly one current entry: {links:?}"); |
| 162 | + assert_eq!(marked.len(), 1, "exactly one current tab: {links:?}"); |
| 158 | 163 | assert_eq!(marked[0].0, current); |
| 159 | 164 | assert!(!body.contains("</a> · <a"), "no dot-separated link row"); |
| 160 | 165 | } |
| 161 | 166 | |
| 162 | 167 | #[tokio::test] |
| 163 | | -async fn admin_pages_get_the_admin_sidebar() { |
| 168 | +async fn admin_pages_get_the_admin_tabs() { |
| 164 | 169 | let env = start().await; |
| 165 | 170 | let session = login(&env.http, "tahinli", PW).await; |
| 166 | 171 | let want = [ |
| | @@ -176,31 +181,44 @@ async fn admin_pages_get_the_admin_sidebar() { |
| 176 | 181 | for path in want { |
| 177 | 182 | let page = env.http.get(path, Some(&session)).await; |
| 178 | 183 | assert_eq!(page.status, 200, "GET {path}"); |
| 179 | | - assert_section(&page.body, path, &want); |
| 184 | + assert_tabs(&page.body, path, &want); |
| 180 | 185 | assert!( |
| 181 | | - !sidebar(&page.body).iter().any(|(h, _)| h == "/explore"), |
| 186 | + !tab_links(&page.body).iter().any(|(h, _)| h == "/explore"), |
| 182 | 187 | "global links are swapped out" |
| 183 | 188 | ); |
| 184 | 189 | } |
| 185 | 190 | } |
| 186 | 191 | |
| 187 | 192 | #[tokio::test] |
| 188 | | -async fn settings_pages_get_the_settings_sidebar() { |
| 193 | +async fn settings_pages_get_the_settings_tabs() { |
| 189 | 194 | let env = start().await; |
| 190 | 195 | let session = login(&env.http, "tahinli", PW).await; |
| 191 | | - let want = [ |
| 196 | + let tabs = [ |
| 192 | 197 | "/settings/profile", |
| 193 | | - "/settings/keys", |
| 194 | | - "/settings/gpg", |
| 195 | | - "/settings/tokens", |
| 196 | | - "/settings/sessions", |
| 197 | | - "/settings/security", |
| 198 | | - "/settings/notifications", |
| 199 | 198 | "/settings/appearance", |
| 199 | + "/settings/notifications", |
| 200 | + "/settings/security", |
| 201 | + "/settings/keys", |
| 202 | + "/settings/export", |
| 200 | 203 | ]; |
| 201 | | - for path in want { |
| 204 | + // A page folded into another tab marks that tab: sessions under security, GPG keys and |
| 205 | + // tokens under keys. |
| 206 | + let pages = [ |
| 207 | + ("/settings/profile", "/settings/profile"), |
| 208 | + ("/settings/keys", "/settings/keys"), |
| 209 | + ("/settings/sessions", "/settings/security"), |
| 210 | + ("/settings/security", "/settings/security"), |
| 211 | + ("/settings/notifications", "/settings/notifications"), |
| 212 | + ("/settings/appearance", "/settings/appearance"), |
| 213 | + ]; |
| 214 | + for (path, current) in pages { |
| 202 | 215 | let page = env.http.get(path, Some(&session)).await; |
| 203 | 216 | assert_eq!(page.status, 200, "GET {path}"); |
| 204 | | - assert_section(&page.body, path, &want); |
| 217 | + assert_tabs(&page.body, current, &tabs); |
| 218 | + } |
| 219 | + // GPG keys and tokens moved into the Keys tab; their old addresses go there. |
| 220 | + for path in ["/settings/gpg", "/settings/tokens"] { |
| 221 | + let page = env.http.get(path, Some(&session)).await; |
| 222 | + assert_eq!(page.status, 303, "GET {path}"); |
| 205 | 223 | } |
| 206 | 224 | } |
| | @@ -727,10 +727,6 @@ async fn appearance_sidebar_side_saves_and_renders_on_html() { |
| 727 | 727 | html_attr(&page.body, "data-sidebar").as_deref(), |
| 728 | 728 | Some("left") |
| 729 | 729 | ); |
| 730 | | - assert_eq!( |
| 731 | | - checked_radio(&page.body, "sidebar_side").as_deref(), |
| 732 | | - Some("left") |
| 733 | | - ); |
| 734 | 730 | let csrf = input_value(&page.body, "csrf"); |
| 735 | 731 | |
| 736 | 732 | let saved = env |
| | @@ -753,10 +749,6 @@ async fn appearance_sidebar_side_saves_and_renders_on_html() { |
| 753 | 749 | html_attr(&page.body, "data-sidebar").as_deref(), |
| 754 | 750 | Some("right") |
| 755 | 751 | ); |
| 756 | | - assert_eq!( |
| 757 | | - checked_radio(&page.body, "sidebar_side").as_deref(), |
| 758 | | - Some("right") |
| 759 | | - ); |
| 760 | 752 | |
| 761 | 753 | // A save without the field keeps the side; a malformed side changes nothing. |
| 762 | 754 | let saved = env |
| | @@ -37,8 +37,8 @@ fn admin(config: &Path, args: &[&str]) { |
| 37 | 37 | |
| 38 | 38 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 39 | 39 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 40 | | - let page = http.get("/settings/tokens", Some(session)).await; |
| 41 | | - assert_eq!(page.status, 200, "GET /settings/tokens"); |
| 40 | + let page = http.get("/settings/keys", Some(session)).await; |
| 41 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 42 | 42 | input_value(&page.body, "csrf") |
| 43 | 43 | } |
| 44 | 44 | |
| | @@ -4090,7 +4090,12 @@ |
| 4090 | 4090 | function paletteMeta(item) { |
| 4091 | 4091 | if (!item.meta || item.metaGen !== pal.scanGen) { |
| 4092 | 4092 | var read = (item.scan && pal.scan.texts[item.scan]) || []; |
| 4093 | | - item.meta = { label: paletteParts(item.label), terms: (item.terms || []).concat(read).map(paletteParts) }; |
| 4093 | + // Only the terms in the viewer's language (shownTerms) may be given as the reason for a row. |
| 4094 | + var shown = {}; |
| 4095 | + (item.shownTerms || []).forEach(function (t) { shown[t] = true; }); |
| 4096 | + var own = (item.terms || []).map(function (t) { var p = paletteParts(t); p.shows = !!shown[t]; return p; }); |
| 4097 | + var page = read.map(function (t) { var p = paletteParts(t); p.shows = true; return p; }); |
| 4098 | + item.meta = { label: paletteParts(item.label), terms: own.concat(page) }; |
| 4094 | 4099 | item.metaGen = pal.scanGen; |
| 4095 | 4100 | } |
| 4096 | 4101 | return item.meta; |
| | @@ -4304,7 +4309,8 @@ |
| 4304 | 4309 | m.terms.forEach(function (term) { |
| 4305 | 4310 | var raw = paletteField(t, term); |
| 4306 | 4311 | if (raw >= PALETTE_EXACT) { exact = true; } |
| 4307 | | - if (raw * 0.8 > best) { best = raw * 0.8; why = PALETTE_KEY.test(term.text) || m.label.s.indexOf(term.s) >= 0 ? '' : term.text; } |
| 4312 | + // A typo guess is never the reason for a row, nor a word in the other language. |
| 4313 | + if (raw * 0.8 > best) { best = raw * 0.8; why = raw >= PALETTE_EXACT && term.shows && !PALETTE_KEY.test(term.text) && m.label.s.indexOf(term.s) < 0 ? term.text : ''; } |
| 4308 | 4314 | }); |
| 4309 | 4315 | if (!best && paletteInOrder(t, m.label.s)) { best = 1; } |
| 4310 | 4316 | if (why) { item.why = why; } |
| | @@ -4338,7 +4344,7 @@ |
| 4338 | 4344 | best = Math.max(best, paletteField(fq, m.label)); |
| 4339 | 4345 | // The words side by side in one sentence say more than the same words all over the page. |
| 4340 | 4346 | m.terms.some(function (term) { |
| 4341 | | - if (term.s.indexOf(fq) < 0) { return false; } |
| 4347 | + if (!term.shows || term.s.indexOf(fq) < 0) { return false; } |
| 4342 | 4348 | best += 1; |
| 4343 | 4349 | item.why = term.text; |
| 4344 | 4350 | item.near = false; |
| | @@ -4358,7 +4364,7 @@ |
| 4358 | 4364 | var href = base + '/' + p.path; |
| 4359 | 4365 | if ((p.admin && !admin) || seen[href]) { return; } |
| 4360 | 4366 | seen[href] = true; |
| 4361 | | - out.push({ label: label + ' · ' + p.label, href: href, kind: 'repo', terms: p.terms, scan: p.admin ? 'repo:' + p.path : '' }); |
| 4367 | + out.push({ label: label + ' · ' + p.label, href: href, kind: 'repo', terms: p.terms, shownTerms: p.shownTerms, scan: p.admin ? 'repo:' + p.path : '' }); |
| 4362 | 4368 | }); |
| 4363 | 4369 | } |
| 4364 | 4370 | if (current) { add(current.name, current.href, current.admin); } |
| | @@ -4507,7 +4513,7 @@ |
| 4507 | 4513 | if (!Object.prototype.hasOwnProperty.call(pal.str.heads, item.kind)) { return; } |
| 4508 | 4514 | var s; |
| 4509 | 4515 | if (!pathMode) { s = paletteScore(q, item); } |
| 4510 | | - else if (item.label.toLowerCase().indexOf(q) === 0) { s = item.label.length === q.length ? 3.5 : 3; item.why = ''; } |
| 4516 | + else if (item.label.toLowerCase().indexOf(q) === 0) { s = item.label.length === q.length ? 3.5 : 3; item.why = ''; item.near = false; } |
| 4511 | 4517 | else { s = words && item.kind !== 'file' && item.kind !== 'action' ? Math.min(2.9, paletteScore(words, item)) : 0; } |
| 4512 | 4518 | // Above a path match (3), which would otherwise fill the list and cut the actions off. Text typed |
| 4513 | 4519 | // after the opening path searches the page's actions by name. |
| | @@ -24,6 +24,7 @@ use crate::live::{Topic, stream_changes}; |
| 24 | 24 | use crate::pages::admin_users::admin_only; |
| 25 | 25 | use crate::pages::issues_list::stamp_unix; |
| 26 | 26 | use crate::state::AppState; |
| 27 | +use crate::views::parts::post_act; |
| 27 | 28 | use crate::views::{enc, rel_time, shell}; |
| 28 | 29 | |
| 29 | 30 | /// Runs shown on the page. |
| | @@ -143,136 +144,78 @@ async fn backups_view( |
| 143 | 144 | matches!(running, Some(RunKind::Fsck)).then(|| g::running_line(lang, RunKind::Fsck)); |
| 144 | 145 | Ok(view! { |
| 145 | 146 | <div data-live="/admin/backups/events"> |
| 146 | | - <section class="page-head"> |
| 147 | | - <h1>(g::t(lang, K::Backups))</h1> |
| 148 | | - </section> |
| 149 | | - <p class="muted page-lede">(g::t(lang, K::BackupsIntro))</p> |
| 147 | + <h1 class="sr-only">(g::t(lang, K::Backups))</h1> |
| 148 | + <p class="hint">(g::t(lang, K::BackupsIntro))</p> |
| 150 | 149 | if let Some(message) = notice { |
| 151 | | - <section class="card notice" role="status"> |
| 152 | | - <p>(message.as_str())</p> |
| 153 | | - </section> |
| 150 | + <p class="state" role="status">(message.as_str())</p> |
| 154 | 151 | } |
| 155 | | - <section class="card rows-pane" aria-label=(g::t(lang, K::Settings))> |
| 152 | + <section class="sec"> |
| 156 | 153 | if settings.enabled { |
| 157 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Configuration", "Yapılandırma"))</h2> |
| 158 | | - <div class="row-line"> |
| 159 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg> |
| 160 | | - <div class="row-main"> |
| 161 | | - <h2 class="row-title">(g::t(lang, K::Directory))</h2> |
| 162 | | - <p class="row-status"><code>(settings.dir.as_str())</code></p> |
| 163 | | - </div> |
| 154 | + <h2>(crate::pages::passkeys::s(lang, "Configuration", "Yapılandırma"))</h2> |
| 155 | + <div class="line" data-kb-row=""> |
| 156 | + <span class="name">(g::t(lang, K::Directory))</span> |
| 157 | + <span class="val"><code>(settings.dir.as_str())</code></span> |
| 164 | 158 | </div> |
| 165 | | - <div class="row-line"> |
| 166 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg> |
| 167 | | - <div class="row-main"> |
| 168 | | - <h2 class="row-title">(g::t(lang, K::BackupInterval))</h2> |
| 169 | | - <p class="row-status">(settings.interval.as_str())</p> |
| 170 | | - </div> |
| 159 | + <div class="line" data-kb-row=""> |
| 160 | + <span class="name">(g::t(lang, K::BackupInterval))</span> |
| 161 | + <span class="val">(settings.interval.as_str())</span> |
| 171 | 162 | </div> |
| 172 | | - <div class="row-line"> |
| 173 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="5" rx="1"/><path d="M5 9v10h14V9M10 13h4"/></svg> |
| 174 | | - <div class="row-main"> |
| 175 | | - <h2 class="row-title">(g::t(lang, K::Retention))</h2> |
| 176 | | - <p class="row-status">(settings.keep.as_str())</p> |
| 177 | | - </div> |
| 163 | + <div class="line" data-kb-row=""> |
| 164 | + <span class="name">(g::t(lang, K::Retention))</span> |
| 165 | + <span class="val">(settings.keep.as_str())</span> |
| 178 | 166 | </div> |
| 179 | | - <div class="row-line"> |
| 180 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l8 3v6c0 4.5-3.4 8.3-8 9-4.6-.7-8-4.5-8-9V6z"/><path d="M9 12l2 2 4-4"/></svg> |
| 181 | | - <div class="row-main"> |
| 182 | | - <h2 class="row-title">(g::t(lang, K::Fsck))</h2> |
| 183 | | - <p class="row-status">(settings.fsck_interval.as_str())</p> |
| 184 | | - </div> |
| 167 | + <div class="line" data-kb-row=""> |
| 168 | + <span class="name">(g::t(lang, K::Fsck))</span> |
| 169 | + <span class="val">(settings.fsck_interval.as_str())</span> |
| 185 | 170 | </div> |
| 186 | | - <div class="row-line"> |
| 187 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12h4l2-5 4 10 2-5h6"/></svg> |
| 188 | | - <div class="row-main"> |
| 189 | | - <h2 class="row-title">(g::t(lang, K::Healthcheck))</h2> |
| 190 | | - <p class="row-status">(settings.healthcheck.as_str())</p> |
| 191 | | - </div> |
| 171 | + <div class="line" data-kb-row=""> |
| 172 | + <span class="name">(g::t(lang, K::Healthcheck))</span> |
| 173 | + <span class="val">(settings.healthcheck.as_str())</span> |
| 192 | 174 | </div> |
| 193 | 175 | } else { |
| 194 | | - <div class="row-line"> |
| 195 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg> |
| 196 | | - <div class="row-main"> |
| 197 | | - <h2 class="row-title">(g::t(lang, K::Settings))</h2> |
| 198 | | - <p class="row-status">(g::t(lang, K::ScheduledBackupsOff))</p> |
| 199 | | - </div> |
| 200 | | - </div> |
| 176 | + <h2>(g::t(lang, K::Settings))</h2> |
| 177 | + <p class="state">(g::t(lang, K::ScheduledBackupsOff))</p> |
| 201 | 178 | } |
| 202 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Run now", "Şimdi çalıştır"))</h2> |
| 203 | | - <div class="row-line"> |
| 204 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4l13 8-13 8z"/></svg> |
| 205 | | - <div class="row-main"> |
| 206 | | - <h2 class="row-title">(g::kind_name(lang, RunKind::Backup))</h2> |
| 207 | | - if let Some(line) = backup_running { |
| 208 | | - <p class="row-status">(line)</p> |
| 209 | | - } |
| 210 | | - </div> |
| 211 | | - <form id="run-backup" method="post" action="/admin/backups/run" class="row-form"> |
| 212 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 213 | | - <button type="submit" class="primary">(g::t(lang, K::RunBackupNow))</button> |
| 214 | | - </form> |
| 215 | | - </div> |
| 216 | | - <div class="row-line"> |
| 217 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4l13 8-13 8z"/></svg> |
| 218 | | - <div class="row-main"> |
| 219 | | - <h2 class="row-title">(g::kind_name(lang, RunKind::Fsck))</h2> |
| 220 | | - if let Some(line) = fsck_running { |
| 221 | | - <p class="row-status">(line)</p> |
| 222 | | - } |
| 223 | | - </div> |
| 224 | | - <form method="post" action="/admin/backups/fsck" class="row-form"> |
| 179 | + </section> |
| 180 | + <section class="sec"> |
| 181 | + <h2>(crate::pages::passkeys::s(lang, "Run now", "Şimdi çalıştır"))</h2> |
| 182 | + if let Some(line) = backup_running { |
| 183 | + <p class="state">(line)</p> |
| 184 | + } |
| 185 | + if let Some(line) = fsck_running { |
| 186 | + <p class="state">(line)</p> |
| 187 | + } |
| 188 | + <div class="acts"> |
| 189 | + <form id="run-backup" method="post" action="/admin/backups/run" class="act-form"> |
| 225 | 190 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 226 | | - <button type="submit">(g::t(lang, K::RunFsckNow))</button> |
| 191 | + <button type="submit" class="act">(g::t(lang, K::RunBackupNow))</button> |
| 227 | 192 | </form> |
| 193 | + post_act(label: g::t(lang, K::RunFsckNow), action: "/admin/backups/fsck", csrf: csrf.as_str()) |
| 228 | 194 | </div> |
| 229 | 195 | </section> |
| 230 | | - if rows.is_empty() { |
| 231 | | - <section class="card rows-pane" aria-label=(g::t(lang, K::RecentRuns))> |
| 232 | | - <div class="row-line"> |
| 233 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg> |
| 234 | | - <div class="row-main"> |
| 235 | | - <h2 class="row-title">(g::t(lang, K::NoRunsYet))</h2> |
| 236 | | - <p class="row-status">(g::t(lang, K::BackupsEmptyHint))</p> |
| 237 | | - </div> |
| 238 | | - </div> |
| 239 | | - </section> |
| 240 | | - } else { |
| 241 | | - <section class="card"> |
| 196 | + <section class="sec"> |
| 242 | 197 | <h2>(g::t(lang, K::RecentRuns))</h2> |
| 243 | | - <div class="table-wrap"> |
| 244 | | - <table class="table queue-table"> |
| 245 | | - <thead> |
| 246 | | - <tr> |
| 247 | | - <th>(g::t(lang, K::TableKind))</th> |
| 248 | | - <th>(g::t(lang, K::TableTrigger))</th> |
| 249 | | - <th>(g::t(lang, K::TableStarted))</th> |
| 250 | | - <th>(g::t(lang, K::TableDuration))</th> |
| 251 | | - <th>(g::t(lang, K::TableSize))</th> |
| 252 | | - <th>(g::t(lang, K::TableResult))</th> |
| 253 | | - </tr> |
| 254 | | - </thead> |
| 255 | | - <tbody> |
| 256 | | - for row in rows.into_iter() { |
| 257 | | - <tr> |
| 258 | | - <td data-label=(g::t(lang, K::TableKind))>(row.kind.as_str())</td> |
| 259 | | - <td data-label=(g::t(lang, K::TableTrigger))>(row.trigger.as_str())</td> |
| 260 | | - <td class="small" data-label=(g::t(lang, K::TableStarted))>rel_time(lang: lang, stamp: row.started.as_str())</td> |
| 261 | | - <td class="small" data-label=(g::t(lang, K::TableDuration))>(row.duration.as_str())</td> |
| 262 | | - <td class="small" data-label=(g::t(lang, K::TableSize))>(row.size.as_str())</td> |
| 263 | | - <td data-label=(g::t(lang, K::TableResult))> |
| 264 | | - (row.status.as_str()) |
| 265 | | - if !row.detail.is_empty() { |
| 266 | | - <div class="small muted">(row.detail.as_str())</div> |
| 267 | | - } |
| 268 | | - </td> |
| 269 | | - </tr> |
| 270 | | - } |
| 271 | | - </tbody> |
| 272 | | - </table> |
| 273 | | - </div> |
| 198 | + if rows.is_empty() { |
| 199 | + <p class="state">(g::t(lang, K::NoRunsYet))</p> |
| 200 | + <p class="hint">(g::t(lang, K::BackupsEmptyHint))</p> |
| 201 | + } else { |
| 202 | + for row in rows.into_iter() { |
| 203 | + <div class="line" data-kb-row=""> |
| 204 | + <span class="name">(row.kind.as_str()) " · " (row.trigger.as_str())</span> |
| 205 | + <span class="val">(row.status.as_str()) " · " rel_time(lang: lang, stamp: row.started.as_str())</span> |
| 206 | + </div> |
| 207 | + <p class="hint"> |
| 208 | + (row.duration.as_str()) |
| 209 | + if !row.size.is_empty() { |
| 210 | + " · " (row.size.as_str()) |
| 211 | + } |
| 212 | + </p> |
| 213 | + if !row.detail.is_empty() { |
| 214 | + <p class="hint bad">(row.detail.as_str())</p> |
| 215 | + } |
| 216 | + } |
| 217 | + } |
| 274 | 218 | </section> |
| 275 | | - } |
| 276 | 219 | </div> |
| 277 | 220 | }) |
| 278 | 221 | } |
| | @@ -1,5 +1,5 @@ |
| 1 | | -//! Page: instance health for admins (`/admin/health`). A summary line, a storage card with the data |
| 2 | | -//! disk's usage bar, and a services card. Every number is a cheap query or a short external probe |
| 1 | +//! Page: instance health for admins (`/admin/health`). A summary line, a storage topic with the data |
| 2 | +//! disk's usage bar, and a services topic. Every number is a cheap query or a short external probe |
| 3 | 3 | //! (`df`), so there is no polling; reloading the page, or opening it again, reads fresh values. The |
| 4 | 4 | //! tree size of the repos (`du`) walks every repo, so a background task caches it (see |
| 5 | 5 | //! [`spawn_repo_size`]) and the page only reads the cache. Non-admins get 404. |
| | @@ -84,7 +84,6 @@ struct Usage { |
| 84 | 84 | /// The icon a status row shows. |
| 85 | 85 | #[derive(Clone, Copy)] |
| 86 | 86 | enum Glyph { |
| 87 | | - Disk, |
| 88 | 87 | Database, |
| 89 | 88 | Folder, |
| 90 | 89 | Archive, |
| | @@ -98,9 +97,6 @@ enum Glyph { |
| 98 | 97 | #[component] |
| 99 | 98 | async fn glyph(kind: Glyph) -> Result<impl View> { |
| 100 | 99 | Ok(view! { |
| 101 | | - if matches!(kind, Glyph::Disk) { |
| 102 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="6" rx="1.5"/><rect x="3" y="14" width="18" height="6" rx="1.5"/><path d="M7 7h.01M7 17h.01"/></svg> |
| 103 | | - } |
| 104 | 100 | if matches!(kind, Glyph::Database) { |
| 105 | 101 | <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><ellipse cx="12" cy="6" rx="8" ry="3"/><path d="M4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6"/><path d="M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3"/></svg> |
| 106 | 102 | } |
| | @@ -557,78 +553,67 @@ async fn health_view( |
| 557 | 553 | }; |
| 558 | 554 | Ok(view! { |
| 559 | 555 | <div data-live="/admin/health/events" class="health-page"> |
| 560 | | - <section class="page-head"> |
| 561 | | - <h1>(at(lang, A::Health))</h1> |
| 562 | | - </section> |
| 563 | | - <p class="health-summary page-lede"> |
| 556 | + <h1 class="sr-only">(at(lang, A::Health))</h1> |
| 557 | + <p class="state"> |
| 564 | 558 | <span class=(format!("health-dot {}", summary_dot.class()))></span> |
| 565 | | - (summary) |
| 559 | + " " (summary) |
| 566 | 560 | </p> |
| 567 | | - <p class="muted small page-lede">(at(lang, A::HealthIntro))</p> |
| 561 | + <p class="hint">(at(lang, A::HealthIntro))</p> |
| 568 | 562 | if count > 0 { |
| 569 | | - <section class="admin-alerts" role="alert"> |
| 563 | + <section class="sec" role="alert"> |
| 570 | 564 | <h2>(alert_text::banner_heading(lang, count))</h2> |
| 571 | | - <ul> |
| 572 | | - for a in alerts.into_iter() { |
| 573 | | - <li> |
| 574 | | - <strong>(a.title.as_str())</strong> |
| 575 | | - <span class="muted small">since_line(lang: lang, stamp: a.stamp.as_str())</span> |
| 576 | | - if !a.body.is_empty() { |
| 577 | | - <div class="small">(a.body.as_str())</div> |
| 578 | | - } |
| 579 | | - </li> |
| 565 | + for a in alerts.into_iter() { |
| 566 | + <div class="line" data-kb-row=""> |
| 567 | + <span class="name">(a.title.as_str())</span> |
| 568 | + <span class="val">since_line(lang: lang, stamp: a.stamp.as_str())</span> |
| 569 | + </div> |
| 570 | + if !a.body.is_empty() { |
| 571 | + <p class="hint">(a.body.as_str())</p> |
| 580 | 572 | } |
| 581 | | - </ul> |
| 573 | + } |
| 582 | 574 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 583 | | - <a class="small" href="/admin/server?tab=alerts">(alert_text::settings_link(lang))</a> |
| 575 | + <div class="acts"> |
| 576 | + <a class="act" href="/admin/server?tab=alerts">(alert_text::settings_link(lang))</a> |
| 577 | + </div> |
| 584 | 578 | </section> |
| 585 | 579 | } |
| 586 | | - <section class="card rows-pane" aria-label=(at(lang, A::Storage))> |
| 587 | | - <div class="row-line"> |
| 588 | | - glyph(kind: Glyph::Disk) |
| 589 | | - <div class="row-main"> |
| 590 | | - <h2 class="row-title">(at(lang, A::Storage))</h2> |
| 591 | | - if let Some(u) = usage { |
| 592 | | - <p class="row-status"><strong>(u.used.as_str())</strong> " " (at(lang, A::DiskUsed)) " · " (u.free_of_total.as_str())</p> |
| 593 | | - <progress class=(if u.bad { "meter bad" } else { "meter" }) max="100" value=(u.pct.to_string())></progress> |
| 594 | | - <p class="row-status muted small health-path">(u.path.as_str())</p> |
| 595 | | - } else { |
| 596 | | - <p class="row-status">(at(lang, A::Unavailable))</p> |
| 597 | | - } |
| 598 | | - </div> |
| 599 | | - </div> |
| 580 | + <section class="sec"> |
| 581 | + <h2>(at(lang, A::Storage))</h2> |
| 582 | + if let Some(u) = usage { |
| 583 | + <p class="state"><strong>(u.used.as_str())</strong> " " (at(lang, A::DiskUsed)) " · " (u.free_of_total.as_str())</p> |
| 584 | + <progress class=(if u.bad { "meter bad" } else { "meter" }) max="100" value=(u.pct.to_string())></progress> |
| 585 | + <p class="hint health-path">(u.path.as_str())</p> |
| 586 | + } else { |
| 587 | + <p class="state">(at(lang, A::Unavailable))</p> |
| 588 | + } |
| 600 | 589 | for f in facts.into_iter() { |
| 601 | | - <div class="row-line"> |
| 602 | | - glyph(kind: f.glyph) |
| 603 | | - <div class="row-main"> |
| 604 | | - <h2 class="row-title">(f.label)</h2> |
| 605 | | - <p class=(format!("row-status {}", f.dot.value_class()))>(f.value.as_str())</p> |
| 606 | | - if !f.detail.is_empty() { |
| 607 | | - <p class="row-status muted small health-path">(f.detail.as_str())</p> |
| 608 | | - } |
| 609 | | - </div> |
| 590 | + <div class="line" data-kb-row=""> |
| 591 | + <span class="name">glyph(kind: f.glyph) (f.label)</span> |
| 592 | + <span class=(format!("val {}", f.dot.value_class()))>(f.value.as_str())</span> |
| 610 | 593 | </div> |
| 594 | + if !f.detail.is_empty() { |
| 595 | + <p class="hint health-path">(f.detail.as_str())</p> |
| 596 | + } |
| 611 | 597 | } |
| 598 | + <p class="hint">(meta.as_str())</p> |
| 612 | 599 | </section> |
| 613 | | - <section class="card rows-pane" aria-label=(at(lang, A::Services))> |
| 600 | + <section class="sec"> |
| 601 | + <h2>(at(lang, A::Services))</h2> |
| 614 | 602 | for s in services.into_iter() { |
| 615 | | - <div class="row-line"> |
| 616 | | - glyph(kind: s.glyph) |
| 617 | | - <div class="row-main"> |
| 618 | | - <h2 class="row-title">(s.label)</h2> |
| 619 | | - <p class="row-status"><span class=(format!("health-dot {}", s.dot.class()))></span> <span class=(s.dot.value_class())>(s.value.as_str())</span> |
| 620 | | - if !s.detail.is_empty() { |
| 621 | | - " · " (s.detail.as_str()) |
| 622 | | - } |
| 623 | | - if let Some(stamp) = s.stamp.as_deref() { |
| 624 | | - " · " rel_time(lang: lang, stamp: stamp) |
| 625 | | - } |
| 626 | | - </p> |
| 627 | | - </div> |
| 603 | + <div class="line" data-kb-row=""> |
| 604 | + <span class="name">glyph(kind: s.glyph) (s.label)</span> |
| 605 | + <span class="val"> |
| 606 | + <span class=(format!("health-dot {}", s.dot.class()))></span> <span class=(s.dot.value_class())>(s.value.as_str())</span> |
| 607 | + if !s.detail.is_empty() { |
| 608 | + " · " (s.detail.as_str()) |
| 609 | + } |
| 610 | + if let Some(stamp) = s.stamp.as_deref() { |
| 611 | + " · " rel_time(lang: lang, stamp: stamp) |
| 612 | + } |
| 613 | + </span> |
| 628 | 614 | </div> |
| 629 | 615 | } |
| 630 | 616 | </section> |
| 631 | | - <p class="muted small health-meta">(meta.as_str())</p> |
| 632 | 617 | </div> |
| 633 | 618 | }) |
| 634 | 619 | } |
| | @@ -33,7 +33,8 @@ use crate::mail::{enqueue, live, templates}; |
| 33 | 33 | use crate::pages::admin_users::admin_only; |
| 34 | 34 | use crate::pages::ci_runs::{changed_event, events_response}; |
| 35 | 35 | use crate::state::AppState; |
| 36 | | -use crate::views::{empty_state, enc, rel_time, shell}; |
| 36 | +use crate::views::parts::{confirm_act, post_act}; |
| 37 | +use crate::views::{enc, rel_time, shell}; |
| 37 | 38 | |
| 38 | 39 | /// Rows shown in the queue at most. |
| 39 | 40 | const LIST_LIMIT: u32 = 100; |
| | @@ -72,7 +73,7 @@ struct FilterChip { |
| 72 | 73 | href: String, |
| 73 | 74 | label: &'static str, |
| 74 | 75 | count: u32, |
| 75 | | - class: &'static str, |
| 76 | + current: bool, |
| 76 | 77 | } |
| 77 | 78 | |
| 78 | 79 | /// The queue tab: the filter chips, the rows and the state the filter is on, for the forms. |
| | @@ -116,14 +117,6 @@ fn transport_name(transport: MailTransport) -> &'static str { |
| 116 | 117 | } |
| 117 | 118 | } |
| 118 | 119 | |
| 119 | | -fn tab_class(on: bool) -> &'static str { |
| 120 | | - if on { |
| 121 | | - "subnav-link current" |
| 122 | | - } else { |
| 123 | | - "subnav-link" |
| 124 | | - } |
| 125 | | -} |
| 126 | | - |
| 127 | 120 | fn row_view(entry: &OutboxEntry, now: &str, lang: Lang) -> QueueRow { |
| 128 | 121 | let state = entry.state_at(now); |
| 129 | 122 | QueueRow { |
| | @@ -154,14 +147,14 @@ async fn queue_data( |
| 154 | 147 | href: "/admin/mail?tab=queue".to_owned(), |
| 155 | 148 | label: g::t(lang, K::MailFilterAll), |
| 156 | 149 | count: total, |
| 157 | | - class: tab_class(filter.is_none()), |
| 150 | + current: filter.is_none(), |
| 158 | 151 | }]; |
| 159 | 152 | for (kind, count) in counts { |
| 160 | 153 | chips.push(FilterChip { |
| 161 | 154 | href: format!("/admin/mail?tab=queue&state={}", kind.as_str()), |
| 162 | 155 | label: g::mail_state(lang, kind), |
| 163 | 156 | count, |
| 164 | | - class: tab_class(filter == Some(kind)), |
| 157 | + current: filter == Some(kind), |
| 165 | 158 | }); |
| 166 | 159 | } |
| 167 | 160 | let rows = state |
| | @@ -220,165 +213,128 @@ async fn mail_view( |
| 220 | 213 | g::t(lang, K::NoPasswordStored) |
| 221 | 214 | }; |
| 222 | 215 | let settings_on = data.tab == Tab::Settings; |
| 223 | | - let settings_class = tab_class(settings_on); |
| 224 | | - let queue_class = tab_class(!settings_on); |
| 225 | 216 | let filter_param = data |
| 226 | 217 | .queue |
| 227 | 218 | .as_ref() |
| 228 | 219 | .map(|q| q.filter_param.clone()) |
| 229 | 220 | .unwrap_or_default(); |
| 230 | 221 | Ok(view! { |
| 231 | | - <section class="page-head"> |
| 232 | | - <h1>(g::t(lang, K::Mail))</h1> |
| 233 | | - </section> |
| 234 | | - <p class="muted page-lede">(g::t(lang, K::MailIntro))</p> |
| 235 | | - <nav class="subnav" aria-label=(g::t(lang, K::Mail))> |
| 236 | | - <a class=(settings_class) href="/admin/mail">(g::t(lang, K::MailTabSettings))</a> |
| 237 | | - <a class=(queue_class) href="/admin/mail?tab=queue">(g::t(lang, K::MailTabQueue))</a> |
| 222 | + <h1 class="sr-only">(g::t(lang, K::Mail))</h1> |
| 223 | + <nav class="sub" aria-label=(g::t(lang, K::Mail))> |
| 224 | + <a href="/admin/mail" aria-current=(settings_on.then_some("page"))>(g::t(lang, K::MailTabSettings))</a> |
| 225 | + <a href="/admin/mail?tab=queue" aria-current=((!settings_on).then_some("page"))>(g::t(lang, K::MailTabQueue))</a> |
| 238 | 226 | </nav> |
| 227 | + <p class="hint">(g::t(lang, K::MailIntro))</p> |
| 239 | 228 | if let Some(message) = notice { |
| 240 | | - <section class="card notice" role="status"> |
| 241 | | - <p>(message.as_str())</p> |
| 242 | | - </section> |
| 229 | + <p class="state" role="status">(message.as_str())</p> |
| 243 | 230 | } |
| 244 | 231 | if settings_on { |
| 245 | 232 | // Saved by any admin session: the stream re-renders the settings with the same signal |
| 246 | 233 | // as the queue (the save bumps it too), and the form keeps what was typed. |
| 247 | 234 | <div data-live="/admin/mail/events"> |
| 248 | | - <section class="card rows-pane"> |
| 249 | | - <div class="row-line"> |
| 250 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/></svg> |
| 251 | | - <div class="row-main"> |
| 252 | | - <h2 class="row-title">(g::t(lang, K::SmtpServer))</h2> |
| 253 | | - <p class="row-status">(g::t(lang, K::MailTransportNote))</p> |
| 254 | | - <p class="row-status">(g::t(lang, K::MailTransportInUse)) " " <code>(data.transport)</code></p> |
| 255 | | - </div> |
| 256 | | - </div> |
| 257 | | - <form method="post" action="/admin/mail"> |
| 258 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 259 | | - <label class="row-line row-field"> |
| 260 | | - <span class="row-main"><span class="row-title">(g::t(lang, K::MailHost))</span></span> |
| 261 | | - <span class="row-control"><input type="text" name="host" value=(data.host.as_str()) maxlength="253" autocomplete="off"></span> |
| 262 | | - </label> |
| 263 | | - <label class="row-line row-field"> |
| 264 | | - <span class="row-main"><span class="row-title">(g::t(lang, K::MailPort))</span></span> |
| 265 | | - <span class="row-control"><input type="number" name="port" value=(data.port.as_str()) min="1" max="65535"></span> |
| 266 | | - </label> |
| 267 | | - <label class="row-line row-field"> |
| 268 | | - <span class="row-main"><span class="row-title">(i18n::t(lang, Key::Security))</span></span> |
| 269 | | - <span class="row-control"> |
| 270 | | - <select name="security"> |
| 235 | + <form method="post" action="/admin/mail"> |
| 236 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 237 | + <section class="sec" id="smtp"> |
| 238 | + <h2>(g::t(lang, K::SmtpServer))</h2> |
| 239 | + <p class="hint">(g::t(lang, K::MailTransportNote))</p> |
| 240 | + <p class="hint">(g::t(lang, K::MailTransportInUse)) " " <code>(data.transport)</code></p> |
| 241 | + <div class="fields"> |
| 242 | + <div class="field"> |
| 243 | + <label for="mail-host">(g::t(lang, K::MailHost))</label> |
| 244 | + <input id="mail-host" type="text" name="host" value=(data.host.as_str()) maxlength="253" autocomplete="off"> |
| 245 | + </div> |
| 246 | + <div class="field"> |
| 247 | + <label for="mail-port">(g::t(lang, K::MailPort))</label> |
| 248 | + <input id="mail-port" type="number" name="port" value=(data.port.as_str()) min="1" max="65535"> |
| 249 | + </div> |
| 250 | + <div class="field"> |
| 251 | + <label for="mail-security">(i18n::t(lang, Key::Security))</label> |
| 252 | + <select id="mail-security" name="security"> |
| 271 | 253 | <option value="starttls" selected=(starttls)>"STARTTLS"</option> |
| 272 | 254 | <option value="tls" selected=(tls)>"TLS"</option> |
| 273 | 255 | <option value="none" selected=(plain)>(g::t(lang, K::SecurityNone))</option> |
| 274 | 256 | </select> |
| 275 | | - </span> |
| 276 | | - </label> |
| 277 | | - <label class="row-line row-field"> |
| 278 | | - <span class="row-main"><span class="row-title">(i18n::t(lang, Key::Username))</span></span> |
| 279 | | - <span class="row-control"><input type="text" name="username" value=(data.username.as_str()) maxlength="256" autocomplete="off"></span> |
| 280 | | - </label> |
| 281 | | - <label class="row-line row-field"> |
| 282 | | - <span class="row-main"> |
| 283 | | - <span class="row-title">(i18n::t(lang, Key::Password))</span> |
| 284 | | - <span class="row-status">(password_hint)</span> |
| 285 | | - </span> |
| 286 | | - <span class="row-control"><input type="password" name="password" autocomplete="new-password" maxlength="1024"></span> |
| 287 | | - </label> |
| 288 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Sending", "Gönderim"))</h2> |
| 289 | | - <label class="row-line row-field"> |
| 290 | | - <span class="row-main"><span class="row-title">(g::t(lang, K::FromAddress))</span></span> |
| 291 | | - <span class="row-control"><input type="email" name="from_addr" value=(data.from_addr.as_str()) maxlength="254"></span> |
| 292 | | - </label> |
| 293 | | - <label class="row-line row-field"> |
| 294 | | - <span class="row-main"><span class="row-title">(g::t(lang, K::FromName))</span></span> |
| 295 | | - <span class="row-control"><input type="text" name="from_name" value=(data.from_name.as_str()) maxlength="100"></span> |
| 296 | | - </label> |
| 297 | | - <label class="row-line row-field"> |
| 298 | | - <span class="row-main"><span class="row-title">(g::t(lang, K::SendMailCheckbox))</span></span> |
| 299 | | - <span class="row-control"><input type="checkbox" name="enabled" value="on" checked=(data.enabled)></span> |
| 300 | | - </label> |
| 301 | | - <div class="row-foot"> |
| 257 | + </div> |
| 258 | + <div class="field"> |
| 259 | + <label for="mail-username">(i18n::t(lang, Key::Username))</label> |
| 260 | + <input id="mail-username" type="text" name="username" value=(data.username.as_str()) maxlength="256" autocomplete="off"> |
| 261 | + </div> |
| 262 | + <div class="field"> |
| 263 | + <label for="mail-password">(i18n::t(lang, Key::Password))</label> |
| 264 | + <input id="mail-password" type="password" name="password" autocomplete="new-password" maxlength="1024"> |
| 265 | + <p class="hint">(password_hint)</p> |
| 266 | + </div> |
| 267 | + </div> |
| 268 | + </section> |
| 269 | + <section class="sec"> |
| 270 | + <h2>(crate::pages::passkeys::s(lang, "Sending", "Gönderim"))</h2> |
| 271 | + <div class="fields"> |
| 272 | + <div class="field"> |
| 273 | + <label for="mail-from-addr">(g::t(lang, K::FromAddress))</label> |
| 274 | + <input id="mail-from-addr" type="email" name="from_addr" value=(data.from_addr.as_str()) maxlength="254"> |
| 275 | + </div> |
| 276 | + <div class="field"> |
| 277 | + <label for="mail-from-name">(g::t(lang, K::FromName))</label> |
| 278 | + <input id="mail-from-name" type="text" name="from_name" value=(data.from_name.as_str()) maxlength="100"> |
| 279 | + </div> |
| 280 | + <label class="switch"> |
| 281 | + <input type="checkbox" name="enabled" value="on" checked=(data.enabled)> |
| 282 | + <span>(g::t(lang, K::SendMailCheckbox))</span> |
| 283 | + </label> |
| 302 | 284 | <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> |
| 303 | | - <button type="submit" form="mail-test">(g::t(lang, K::SendTestMailToMe))</button> |
| 304 | 285 | </div> |
| 305 | | - </form> |
| 306 | | - <form id="mail-test" method="post" action="/admin/mail/test"> |
| 307 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 308 | | - </form> |
| 309 | | - </section> |
| 286 | + <div class="acts"> |
| 287 | + <button type="submit" form="mail-test" class="act">(g::t(lang, K::SendTestMailToMe))</button> |
| 288 | + </div> |
| 289 | + </section> |
| 290 | + </form> |
| 291 | + <form id="mail-test" method="post" action="/admin/mail/test"> |
| 292 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 293 | + </form> |
| 310 | 294 | </div> |
| 311 | 295 | } else if let Some(queue) = data.queue { |
| 312 | | - <section class="card fit-pane"> |
| 313 | | - <p class="muted small">(g::t(lang, K::MailQueueIntro))</p> |
| 314 | | - <div class="mail-filters"> |
| 315 | | - for chip in queue.chips.into_iter() { |
| 316 | | - <a class=(chip.class) href=(chip.href.as_str())>(chip.label) " " <span class="tab-count">(chip.count)</span></a> |
| 317 | | - } |
| 318 | | - </div> |
| 319 | | - <div data-live="/admin/mail/events"> |
| 320 | | - if queue.rows.is_empty() { |
| 321 | | - if queue.filter_param.is_empty() { |
| 322 | | - empty_state(title: g::t(lang, K::MailQueueEmpty)) |
| 323 | | - } else { |
| 324 | | - empty_state(title: g::t(lang, K::MailNothingMatches)) |
| 325 | | - } |
| 296 | + <nav class="sub" aria-label=(g::t(lang, K::MailTabQueue))> |
| 297 | + for chip in queue.chips.into_iter() { |
| 298 | + <a href=(chip.href.as_str()) aria-current=(chip.current.then_some("page"))>(chip.label) " (" (chip.count) ")"</a> |
| 299 | + } |
| 300 | + </nav> |
| 301 | + <p class="hint">(g::t(lang, K::MailQueueIntro))</p> |
| 302 | + <div data-live="/admin/mail/events"> |
| 303 | + if queue.rows.is_empty() { |
| 304 | + if queue.filter_param.is_empty() { |
| 305 | + <p class="state">(g::t(lang, K::MailQueueEmpty))</p> |
| 326 | 306 | } else { |
| 327 | | - <div class="table-wrap"> |
| 328 | | - <table class="table mail-queue queue-table"> |
| 329 | | - <thead> |
| 330 | | - <tr> |
| 331 | | - <th>(g::t(lang, K::TableQueued))</th> |
| 332 | | - <th>(g::t(lang, K::TableTo))</th> |
| 333 | | - <th>(g::t(lang, K::TableKind))</th> |
| 334 | | - <th>(g::t(lang, K::TableSubject))</th> |
| 335 | | - <th>(g::t(lang, K::TableState))</th> |
| 336 | | - <th>(g::t(lang, K::TableTries))</th> |
| 337 | | - <th>(g::t(lang, K::MailSentAt))</th> |
| 338 | | - <th>(g::t(lang, K::TableLastError))</th> |
| 339 | | - <th></th> |
| 340 | | - </tr> |
| 341 | | - </thead> |
| 342 | | - <tbody> |
| 343 | | - for row in queue.rows.into_iter() { |
| 344 | | - <tr> |
| 345 | | - <td class="small" data-label=(g::t(lang, K::TableQueued))>rel_time(lang: lang, stamp: row.created.as_str())</td> |
| 346 | | - <td data-label=(g::t(lang, K::TableTo))>(row.to.as_str())</td> |
| 347 | | - <td data-label=(g::t(lang, K::TableKind))>(row.kind)</td> |
| 348 | | - <td data-label=(g::t(lang, K::TableSubject))>(row.subject.as_str())</td> |
| 349 | | - <td data-label=(g::t(lang, K::TableState))><span class=(row.state_class)>(row.state)</span></td> |
| 350 | | - <td data-label=(g::t(lang, K::TableTries))>(row.attempts)</td> |
| 351 | | - <td class="small" data-label=(g::t(lang, K::MailSentAt))>if let Some(sent) = row.sent.as_deref() { rel_time(lang: lang, stamp: sent) }</td> |
| 352 | | - <td class="small" data-label=(g::t(lang, K::TableLastError))>(row.error.as_str())</td> |
| 353 | | - <td class="mail-actions"> |
| 354 | | - if row.failed { |
| 355 | | - <form method="post" action="/admin/mail/queue/retry"> |
| 356 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 357 | | - <input type="hidden" name="id" value=(row.id.as_str())> |
| 358 | | - <input type="hidden" name="state" value=(filter_param.as_str())> |
| 359 | | - <button type="submit">(g::t(lang, K::MailRetryNow))</button> |
| 360 | | - </form> |
| 361 | | - <details class="row-menu"> |
| 362 | | - <summary class="button row-menu-btn" aria-label=(g::t(lang, K::RowActions)) aria-haspopup="menu">"⋯"</summary> |
| 363 | | - <div class="row-menu-panel" role="menu"> |
| 364 | | - <form method="post" action="/admin/mail/queue/discard" class="inline-form"> |
| 365 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 366 | | - <input type="hidden" name="id" value=(row.id.as_str())> |
| 367 | | - <input type="hidden" name="state" value=(filter_param.as_str())> |
| 368 | | - <button type="submit" class="danger">(g::t(lang, K::MailDiscard))</button> |
| 369 | | - </form> |
| 370 | | - </div> |
| 371 | | - </details> |
| 372 | | - } |
| 373 | | - </td> |
| 374 | | - </tr> |
| 375 | | - } |
| 376 | | - </tbody> |
| 377 | | - </table> |
| 378 | | - </div> |
| 307 | + <p class="state">(g::t(lang, K::MailNothingMatches))</p> |
| 379 | 308 | } |
| 380 | | - </div> |
| 381 | | - </section> |
| 309 | + } else { |
| 310 | + <div> |
| 311 | + for row in queue.rows.into_iter() { |
| 312 | + <details class="row-open"> |
| 313 | + <summary class="line"> |
| 314 | + <span class="name">(row.subject.as_str())</span> |
| 315 | + <span class="val">(row.to.as_str()) " · " (row.kind) " · " <span class=(row.state_class)>(row.state)</span></span> |
| 316 | + </summary> |
| 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() { |
| 321 | + <p class="hint">(g::t(lang, K::MailSentAt)) " " rel_time(lang: lang, stamp: sent)</p> |
| 322 | + } |
| 323 | + if !row.error.is_empty() { |
| 324 | + <p class="hint">(g::t(lang, K::TableLastError)) " " (row.error.as_str())</p> |
| 325 | + } |
| 326 | + if row.failed { |
| 327 | + <div class="acts"> |
| 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())]) |
| 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())) |
| 330 | + </div> |
| 331 | + } |
| 332 | + </div> |
| 333 | + </details> |
| 334 | + } |
| 335 | + </div> |
| 336 | + } |
| 337 | + </div> |
| 382 | 338 | } |
| 383 | 339 | }) |
| 384 | 340 | } |
| | @@ -27,6 +27,7 @@ use crate::i18n::{self, Lang}; |
| 27 | 27 | use crate::live::{Topic, stream_changes}; |
| 28 | 28 | use crate::pages::admin_users::admin_only; |
| 29 | 29 | use crate::state::AppState; |
| 30 | +use crate::views::parts::post_act; |
| 30 | 31 | use crate::views::{enc, rel_time_or_never, shell}; |
| 31 | 32 | |
| 32 | 33 | #[query_params(error = bad_request)] |
| | @@ -189,106 +190,72 @@ async fn replication_view( |
| 189 | 190 | ) -> Result<impl View> { |
| 190 | 191 | Ok(view! { |
| 191 | 192 | <div data-live="/admin/replication/events"> |
| 192 | | - <section class="page-head"> |
| 193 | | - <h1>(g::t(lang, K::Replication))</h1> |
| 194 | | - </section> |
| 195 | | - <p class="muted page-lede">(g::t(lang, K::ReplicationIntro))</p> |
| 193 | + <h1 class="sr-only">(g::t(lang, K::Replication))</h1> |
| 194 | + <p class="hint">(g::t(lang, K::ReplicationIntro))</p> |
| 196 | 195 | if let Some(message) = notice { |
| 197 | | - <section class="card notice" role="status"> |
| 198 | | - <p>(message.as_str())</p> |
| 199 | | - </section> |
| 196 | + <p class="state" role="status">(message.as_str())</p> |
| 200 | 197 | } |
| 201 | | - <section class="card rows-pane" aria-label=(g::t(lang, K::Standby))> |
| 202 | | - if data.enabled { |
| 203 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Target and schedule", "Hedef ve zamanlama"))</h2> |
| 204 | | - <div class="row-line"> |
| 205 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h13l-3-3M20 17H7l3 3"/></svg> |
| 206 | | - <div class="row-main"> |
| 207 | | - <h2 class="row-title">(g::t(lang, K::ReplicationTarget))</h2> |
| 208 | | - <p class="row-status"><code>(data.target.as_str())</code></p> |
| 209 | | - </div> |
| 198 | + if data.enabled { |
| 199 | + <section class="sec"> |
| 200 | + <h2>(crate::pages::passkeys::s(lang, "Target and schedule", "Hedef ve zamanlama"))</h2> |
| 201 | + <div class="line" data-kb-row=""> |
| 202 | + <span class="name">(g::t(lang, K::ReplicationTarget))</span> |
| 203 | + <span class="val"><code>(data.target.as_str())</code></span> |
| 210 | 204 | </div> |
| 211 | | - <div class="row-line"> |
| 212 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg> |
| 213 | | - <div class="row-main"> |
| 214 | | - <h2 class="row-title">(g::t(lang, K::Interval))</h2> |
| 215 | | - <p class="row-status">(data.interval.as_str())</p> |
| 216 | | - </div> |
| 205 | + <div class="line" data-kb-row=""> |
| 206 | + <span class="name">(g::t(lang, K::Interval))</span> |
| 207 | + <span class="val">(data.interval.as_str())</span> |
| 217 | 208 | </div> |
| 218 | | - <div class="row-line"> |
| 219 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12h4l2-5 4 10 2-5h6"/></svg> |
| 220 | | - <div class="row-main"> |
| 221 | | - <h2 class="row-title">(g::t(lang, K::Healthcheck))</h2> |
| 222 | | - <p class="row-status">(data.healthcheck)</p> |
| 223 | | - </div> |
| 209 | + <div class="line" data-kb-row=""> |
| 210 | + <span class="name">(g::t(lang, K::Healthcheck))</span> |
| 211 | + <span class="val">(data.healthcheck)</span> |
| 224 | 212 | </div> |
| 225 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Status", "Durum"))</h2> |
| 226 | | - <div class="row-line"> |
| 227 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><ellipse cx="12" cy="6" rx="8" ry="3"/><path d="M4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6"/><path d="M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3"/></svg> |
| 228 | | - <div class="row-main"> |
| 229 | | - <h2 class="row-title">(g::t(lang, K::Database))</h2> |
| 230 | | - <p class="row-status"><span class=(data.db_dot) aria-hidden="true"></span> (data.db_health)</p> |
| 231 | | - if !data.db_error.is_empty() { |
| 232 | | - <p class="row-status bad">(g::t(lang, K::DatabaseErrorPrefix))(data.db_error.as_str())</p> |
| 233 | | - } |
| 234 | | - </div> |
| 235 | | - </div> |
| 236 | | - <div class="row-line"> |
| 237 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg> |
| 238 | | - <div class="row-main"> |
| 239 | | - <h2 class="row-title">(g::t(lang, K::LastDbSnapshotShipped))</h2> |
| 240 | | - <p class="row-status">rel_time_or_never(lang: lang, stamp: data.db_last_ok.as_deref())</p> |
| 241 | | - </div> |
| 242 | | - </div> |
| 243 | | - <div class="row-line"> |
| 244 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg> |
| 245 | | - <div class="row-main"> |
| 246 | | - <h2 class="row-title">(g::t(lang, K::LastDbAttempt))</h2> |
| 247 | | - <p class="row-status">rel_time_or_never(lang: lang, stamp: data.db_last_attempt.as_deref())</p> |
| 248 | | - </div> |
| 213 | + </section> |
| 214 | + <section class="sec"> |
| 215 | + <h2>(crate::pages::passkeys::s(lang, "Status", "Durum"))</h2> |
| 216 | + <div class="line" data-kb-row=""> |
| 217 | + <span class="name">(g::t(lang, K::Database))</span> |
| 218 | + <span class="val"><span class=(data.db_dot) aria-hidden="true"></span> (data.db_health)</span> |
| 249 | 219 | </div> |
| 250 | | - } else { |
| 251 | | - <div class="row-line"> |
| 252 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h13l-3-3M20 17H7l3 3"/></svg> |
| 253 | | - <div class="row-main"> |
| 254 | | - <h2 class="row-title">(g::t(lang, K::Replication))</h2> |
| 255 | | - <p class="row-status">(g::t(lang, K::ReplicationOff))</p> |
| 256 | | - </div> |
| 220 | + if !data.db_error.is_empty() { |
| 221 | + <p class="hint bad">(g::t(lang, K::DatabaseErrorPrefix))(data.db_error.as_str())</p> |
| 222 | + } |
| 223 | + <div class="line" data-kb-row=""> |
| 224 | + <span class="name">(g::t(lang, K::LastDbSnapshotShipped))</span> |
| 225 | + <span class="val">rel_time_or_never(lang: lang, stamp: data.db_last_ok.as_deref())</span> |
| 257 | 226 | </div> |
| 258 | | - } |
| 259 | | - <div class="row-line"> |
| 260 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h13l-3-3M20 17H7l3 3"/></svg> |
| 261 | | - <div class="row-main"> |
| 262 | | - <h2 class="row-title">(g::t(lang, K::Standby))</h2> |
| 227 | + <div class="line" data-kb-row=""> |
| 228 | + <span class="name">(g::t(lang, K::LastDbAttempt))</span> |
| 229 | + <span class="val">rel_time_or_never(lang: lang, stamp: data.db_last_attempt.as_deref())</span> |
| 263 | 230 | </div> |
| 264 | | - <form method="post" action="/admin/replication/reconcile" class="row-form"> |
| 265 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 266 | | - <button type="submit" class="primary">(g::t(lang, K::ReconcileNow))</button> |
| 267 | | - </form> |
| 231 | + </section> |
| 232 | + } else { |
| 233 | + <section class="sec"> |
| 234 | + <h2>(g::t(lang, K::Replication))</h2> |
| 235 | + <p class="state">(g::t(lang, K::ReplicationOff))</p> |
| 236 | + </section> |
| 237 | + } |
| 238 | + <section class="sec"> |
| 239 | + <h2>(g::t(lang, K::Standby))</h2> |
| 240 | + <div class="acts"> |
| 241 | + post_act(label: g::t(lang, K::ReconcileNow), action: "/admin/replication/reconcile", csrf: csrf.as_str()) |
| 268 | 242 | </div> |
| 269 | 243 | </section> |
| 270 | | - <section class="card rows-pane" aria-label=(g::t(lang, K::Repos))> |
| 244 | + <section class="sec"> |
| 245 | + <h2>(g::t(lang, K::Repos))</h2> |
| 271 | 246 | if data.repos.is_empty() { |
| 272 | | - <div class="row-line"> |
| 273 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg> |
| 274 | | - <div class="row-main"> |
| 275 | | - <h2 class="row-title">(g::t(lang, K::NoReposYet))</h2> |
| 276 | | - <p class="row-status">(g::t(lang, K::ReposEmptyHint))</p> |
| 277 | | - <p class="row-status muted small">(g::t(lang, K::ReplicationConfigHint))</p> |
| 278 | | - </div> |
| 279 | | - </div> |
| 247 | + <p class="state">(g::t(lang, K::NoReposYet))</p> |
| 248 | + <p class="hint">(g::t(lang, K::ReposEmptyHint))</p> |
| 249 | + <p class="hint">(g::t(lang, K::ReplicationConfigHint))</p> |
| 280 | 250 | } else { |
| 281 | 251 | for row in data.repos.into_iter() { |
| 282 | | - <div class="row-line"> |
| 283 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg> |
| 284 | | - <div class="row-main"> |
| 285 | | - <strong class="row-name">(row.name.as_str())</strong> |
| 286 | | - <p class="row-status"><span class=(row.dot) aria-hidden="true"></span> <span class=(row.tone)>(row.health)</span> " · " (g::t(lang, K::LastSuccess)) ": " rel_time_or_never(lang: lang, stamp: row.last_ok.as_deref())</p> |
| 287 | | - if !row.error.is_empty() { |
| 288 | | - <p class="row-status bad">(row.error.as_str())</p> |
| 289 | | - } |
| 290 | | - </div> |
| 252 | + <div class="line" data-kb-row=""> |
| 253 | + <span class="name">(row.name.as_str())</span> |
| 254 | + <span class="val"><span class=(row.dot) aria-hidden="true"></span> <span class=(row.tone)>(row.health)</span> " · " (g::t(lang, K::LastSuccess)) ": " rel_time_or_never(lang: lang, stamp: row.last_ok.as_deref())</span> |
| 291 | 255 | </div> |
| 256 | + if !row.error.is_empty() { |
| 257 | + <p class="hint bad">(row.error.as_str())</p> |
| 258 | + } |
| 292 | 259 | } |
| 293 | 260 | } |
| 294 | 261 | </section> |
| | @@ -36,8 +36,9 @@ use crate::pages::admin_users::admin_only; |
| 36 | 36 | use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; |
| 37 | 37 | use crate::pages::repo_mirrors::stamp_in_tz; |
| 38 | 38 | use crate::state::AppState; |
| 39 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 39 | 40 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 40 | | -use crate::views::{enc, now_unix, relative_time, shell}; |
| 41 | +use crate::views::{alert, enc, now_unix, relative_time, shell}; |
| 41 | 42 | |
| 42 | 43 | path_param!(runner_id); |
| 43 | 44 | |
| | @@ -196,6 +197,10 @@ struct RunnerRow { |
| 196 | 197 | /// The concurrency the admin set or the runner reported, for the load meter's maximum. |
| 197 | 198 | /// Empty when the runner has not reported one. |
| 198 | 199 | concurrency_max: u32, |
| 200 | + /// What it is doing now, then disabled and restart-pending when they apply, joined with " · ". |
| 201 | + status: String, |
| 202 | + /// The id of the concurrency input, unique per runner on the list. |
| 203 | + field_id: String, |
| 199 | 204 | } |
| 200 | 205 | |
| 201 | 206 | /// How the runner's reported build compares with this server's: the label, the `.ci-state` class |
| | @@ -259,6 +264,22 @@ fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { |
| 259 | 264 | let (build_label, build_class, build_tone) = build_badge(lang, runner); |
| 260 | 265 | let (dot_class, state_text) = dot_of(lang, runner, now); |
| 261 | 266 | let concurrency_max = concurrency.parse().unwrap_or(0); |
| 267 | + let doing = if runner.running_jobs == 0 { |
| 268 | + s(lang, "idle", "boşta").to_owned() |
| 269 | + } else { |
| 270 | + match lang { |
| 271 | + Lang::En => format!("{} running", runner.running_jobs), |
| 272 | + Lang::Tr => format!("{} çalışıyor", runner.running_jobs), |
| 273 | + } |
| 274 | + }; |
| 275 | + let mut parts = vec![doing]; |
| 276 | + if runner.disabled { |
| 277 | + parts.push(g::t(lang, K::Disabled).to_owned()); |
| 278 | + } |
| 279 | + if runner.restart.is_some() { |
| 280 | + parts.push(s(lang, "restart pending", "yeniden başlatma bekliyor").to_owned()); |
| 281 | + } |
| 282 | + let field_id = format!("conc-{}", enc(&runner.id)); |
| 262 | 283 | RunnerRow { |
| 263 | 284 | name: runner.name.clone(), |
| 264 | 285 | labels: runner.labels.join(" · "), |
| | @@ -290,6 +311,8 @@ fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { |
| 290 | 311 | build_class, |
| 291 | 312 | build_tone, |
| 292 | 313 | concurrency_max, |
| 314 | + status: parts.join(" · "), |
| 315 | + field_id, |
| 293 | 316 | } |
| 294 | 317 | } |
| 295 | 318 | |
| | @@ -335,91 +358,72 @@ async fn runners_view( |
| 335 | 358 | let (links, prev, next) = nav; |
| 336 | 359 | Ok(view! { |
| 337 | 360 | <div data-live="/admin/runners/events"> |
| 338 | | - <section class="page-head"> |
| 339 | | - <h1>(g::t(lang, K::CiRunners))</h1> |
| 340 | | - </section> |
| 361 | + <h1 class="sr-only">(g::t(lang, K::CiRunners))</h1> |
| 341 | 362 | if let Some((text, is_error)) = notice { |
| 342 | 363 | if is_error { |
| 343 | | - <section class="card notice alert" role="alert">(text)</section> |
| 364 | + alert(message: text) |
| 344 | 365 | } else { |
| 345 | | - <section class="card notice" role="status">(text)</section> |
| 366 | + <p class="state" role="status">(text)</p> |
| 346 | 367 | } |
| 347 | 368 | } |
| 348 | | - <section class="card rows-pane"> |
| 349 | | - <div class="row-line"> |
| 350 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 351 | | - <div class="row-main"> |
| 352 | | - <h2 class="row-title">(g::t(lang, K::AddARunner))</h2> |
| 369 | + <section class="sec"> |
| 370 | + <h2>(g::t(lang, K::AddARunner))</h2> |
| 371 | + if rows.is_empty() { |
| 372 | + <p class="state">(g::t(lang, K::NoRunnersYet))</p> |
| 373 | + } |
| 374 | + <div class="acts"> |
| 375 | + reveal(label: g::t(lang, K::CreateRegistrationToken), id: Some("add-runner"), |
| 376 | + <p class="hint">(note.as_str())</p> |
| 353 | 377 | if rows.is_empty() { |
| 354 | | - <p class="row-status">(g::t(lang, K::NoRunnersYet))</p> |
| 378 | + <p class="hint">(g::t(lang, K::RunnersEmptyHint))</p> |
| 379 | + <pre><code>"forge runner register --url <forge-url> --token <token> --name <name> --labels linux,x86_64"</code></pre> |
| 355 | 380 | } |
| 356 | | - </div> |
| 357 | | - <details class="row-action" id="add-runner"> |
| 358 | | - <summary>(g::t(lang, K::CreateRegistrationToken))</summary> |
| 359 | | - <div class="row-panel"> |
| 360 | | - <p class="muted small">(note.as_str())</p> |
| 361 | | - if rows.is_empty() { |
| 362 | | - <p class="muted small">(g::t(lang, K::RunnersEmptyHint))</p> |
| 363 | | - <pre><code>"forge runner register --url <forge-url> --token <token> --name <name> --labels linux,x86_64"</code></pre> |
| 364 | | - } |
| 365 | | - <form method="post" action="/admin/runners/tokens" class="stack"> |
| 366 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 367 | | - <button type="submit" class="primary">(g::t(lang, K::CreateRegistrationToken))</button> |
| 368 | | - </form> |
| 369 | | - </div> |
| 370 | | - </details> |
| 381 | + <form method="post" action="/admin/runners/tokens" class="fields"> |
| 382 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 383 | + <button type="submit" class="primary">(g::t(lang, K::CreateRegistrationToken))</button> |
| 384 | + </form> |
| 385 | + ) |
| 371 | 386 | </div> |
| 387 | + </section> |
| 388 | + <section class="sec"> |
| 372 | 389 | for row in rows.iter() { |
| 373 | | - <div class="row-line runner-row is-linked"> |
| 374 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="6" rx="1.5"/><rect x="3" y="14" width="18" height="6" rx="1.5"/><path d="M7 7h.01M7 17h.01"/></svg> |
| 375 | | - <div class="runner-id"> |
| 376 | | - <div class="runner-title"> |
| 377 | | - <span class=(row.dot_class) role="img" aria-label=(row.state_text) title=(row.state_text)></span> |
| 378 | | - <a class="runner-name" href=(row.detail_href.as_str())>(row.name.as_str())</a> |
| 379 | | - if row.disabled { |
| 380 | | - <span class="runner-off">(g::t(lang, K::Disabled))</span> |
| 381 | | - } |
| 382 | | - </div> |
| 383 | | - <p class="runner-meta muted"> |
| 384 | | - if !row.labels.is_empty() { |
| 385 | | - <span class="runner-labels">(row.labels.as_str())</span> |
| 386 | | - " · " |
| 387 | | - } |
| 388 | | - (s(lang, "seen", "görüldü"))" "<time data-rel="true" datetime=(row.last_seen_at.as_str()) title=(row.last_seen_full.as_str())>(row.last_seen.as_str())</time> |
| 389 | | - if row.restart_pending.is_some() { |
| 390 | | - " · " |
| 391 | | - <span class="runner-off">(s(lang, "restart pending", "yeniden başlatma bekliyor"))</span> |
| 392 | | - } |
| 393 | | - </p> |
| 394 | | - </div> |
| 395 | | - concurrency_form(lang: lang, csrf: csrf.as_str(), action: row.config_action.as_str(), key: "concurrency", value: row.concurrency.as_str(), source: row.concurrency_source, has_override: row.has_override, back: "list", running: row.running, max: row.concurrency_max) |
| 396 | | - <div class="runner-version" title=(row.build.as_str())> |
| 397 | | - if !row.build_short.is_empty() { |
| 398 | | - <code class="runner-hash">(row.build_short.as_str())</code> |
| 399 | | - } |
| 400 | | - if row.build_tone == "ok" { |
| 401 | | - <span class="runner-status"><span class="runner-tick" aria-hidden="true">"✓"</span>" "(row.build_label)</span> |
| 402 | | - } else { |
| 403 | | - <span class=(format!("runner-status {}", row.build_tone))>(row.build_label)</span> |
| 404 | | - } |
| 405 | | - </div> |
| 406 | | - <details class="row-menu"> |
| 407 | | - <summary class="button row-menu-btn" aria-label=(s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> |
| 408 | | - <div class="row-menu-panel" role="menu"> |
| 409 | | - if row.disabled { |
| 410 | | - <form method="post" action=(row.toggle_action.as_str()) class="inline-form"> |
| 411 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 412 | | - <input type="hidden" name="disabled" value="0"> |
| 413 | | - <button type="submit">(g::t(lang, K::Enable))</button> |
| 414 | | - </form> |
| 415 | | - } else { |
| 416 | | - confirm_post(lang: lang, csrf: csrf.as_str(), action: row.toggle_action.as_str(), label: g::t(lang, K::Disable), message: disable_message(lang, row.name.as_str()), confirm: s(lang, "Yes, disable", "Evet, devre dışı bırak"), danger: false, fields: vec![("disabled", "1".into())]) |
| 417 | | - } |
| 418 | | - restart_control(lang: lang, csrf: csrf.as_str(), action: row.restart_action.as_str(), back: "list", can_restart: row.can_restart, pending: row.restart_pending) |
| 419 | | - confirm_post(lang: lang, csrf: csrf.as_str(), action: row.delete_action.as_str(), label: i18n::t(lang, Key::Delete), message: delete_message(lang, row.name.as_str()), confirm: s(lang, "Yes, delete", "Evet, sil"), danger: true, fields: vec![]) |
| 420 | | - </div> |
| 421 | | - </details> |
| 422 | | - </div> |
| 390 | + <details class="row-open"> |
| 391 | + <summary class="line" data-kb-row=""> |
| 392 | + <span class=(row.dot_class) role="img" aria-label=(row.state_text) title=(row.state_text)></span> |
| 393 | + <span class="name">(row.name.as_str())</span> |
| 394 | + <span class="val">(row.status.as_str())</span> |
| 395 | + </summary> |
| 396 | + <div class="opened"> |
| 397 | + <p class="hint"> |
| 398 | + if !row.labels.is_empty() { |
| 399 | + <span class="runner-labels">(row.labels.as_str())</span> |
| 400 | + " · " |
| 401 | + } |
| 402 | + (s(lang, "seen", "görüldü"))" "<time data-rel="true" datetime=(row.last_seen_at.as_str()) title=(row.last_seen_full.as_str())>(row.last_seen.as_str())</time> |
| 403 | + </p> |
| 404 | + <div class="runner-version" title=(row.build.as_str())> |
| 405 | + if !row.build_short.is_empty() { |
| 406 | + <code class="runner-hash">(row.build_short.as_str())</code> |
| 407 | + } |
| 408 | + if row.build_tone == "ok" { |
| 409 | + <span class="runner-status"><span class="runner-tick" aria-hidden="true">"✓"</span>" "(row.build_label)</span> |
| 410 | + } else { |
| 411 | + <span class=(format!("runner-status {}", row.build_tone))>(row.build_label)</span> |
| 412 | + } |
| 413 | + </div> |
| 414 | + concurrency_form(lang: lang, csrf: csrf.as_str(), action: row.config_action.as_str(), id: row.field_id.as_str(), key: "concurrency", value: row.concurrency.as_str(), source: row.concurrency_source, has_override: row.has_override, back: "list", running: row.running, max: row.concurrency_max) |
| 415 | + <div class="acts"> |
| 416 | + <a class="act" href=(row.detail_href.as_str())>(s(lang, "Open", "Aç"))</a> |
| 417 | + if row.disabled { |
| 418 | + post_act(label: g::t(lang, K::Enable), action: row.toggle_action.as_str(), csrf: csrf.as_str(), fields: vec![("disabled".to_owned(), "0".to_owned())]) |
| 419 | + } else { |
| 420 | + confirm_post(lang: lang, csrf: csrf.as_str(), action: row.toggle_action.as_str(), label: g::t(lang, K::Disable), message: disable_message(lang, row.name.as_str()), confirm: s(lang, "Yes, disable", "Evet, devre dışı bırak"), danger: false, fields: vec![("disabled", "1".into())]) |
| 421 | + } |
| 422 | + restart_control(lang: lang, csrf: csrf.as_str(), action: row.restart_action.as_str(), back: "list", can_restart: row.can_restart, pending: row.restart_pending) |
| 423 | + confirm_post(lang: lang, csrf: csrf.as_str(), action: row.delete_action.as_str(), label: i18n::t(lang, Key::Delete), message: delete_message(lang, row.name.as_str()), confirm: s(lang, "Yes, delete", "Evet, sil"), danger: true, fields: vec![]) |
| 424 | + </div> |
| 425 | + </div> |
| 426 | + </details> |
| 423 | 427 | } |
| 424 | 428 | if !rows.is_empty() { |
| 425 | 429 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| | @@ -439,8 +443,7 @@ fn list_href(page: u64, notice: &str) -> String { |
| 439 | 443 | } |
| 440 | 444 | } |
| 441 | 445 | |
| 442 | | -/// A destructive button that opens the shared `confirm-inline` popover; the POST only fires from the |
| 443 | | -/// confirm button inside it, and Cancel closes the popover. |
| 446 | +/// A text link that asks first, in place; the POST only fires from the confirm button. |
| 444 | 447 | #[component] |
| 445 | 448 | pub(crate) async fn confirm_post( |
| 446 | 449 | lang: Lang, |
| | @@ -453,19 +456,19 @@ pub(crate) async fn confirm_post( |
| 453 | 456 | fields: Vec<(&'static str, String)>, |
| 454 | 457 | ) -> Result<impl View> { |
| 455 | 458 | Ok(view! { |
| 456 | | - <details class="confirm-inline"> |
| 457 | | - <summary class=(if danger { "button danger" } else { "button" })>(label)</summary> |
| 458 | | - <div class="confirm-pop"> |
| 459 | | - <p>(message)</p> |
| 460 | | - <form method="post" action=(action)> |
| 461 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 462 | | - for (name, value) in fields.iter() { |
| 463 | | - <input type="hidden" name=(*name) value=(value.as_str())> |
| 464 | | - } |
| 465 | | - <button type="submit" class=(if danger { "danger" } else { "primary" })>(confirm)</button> |
| 466 | | - <button type="button" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> |
| 467 | | - </form> |
| 468 | | - </div> |
| 459 | + <details class="reveal"> |
| 460 | + <summary class=(if danger { "act danger" } else { "act" })>(label)</summary> |
| 461 | + <form class="opened" method="post" action=(action)> |
| 462 | + <input type="hidden" name="csrf" value=(csrf)> |
| 463 | + for (name, value) in fields.iter() { |
| 464 | + <input type="hidden" name=(*name) value=(value.as_str())> |
| 465 | + } |
| 466 | + <p class="hint">(message)</p> |
| 467 | + <div class="acts"> |
| 468 | + <button type="submit" class=(if danger { "act danger" } else { "act" })>(confirm)</button> |
| 469 | + <button type="button" class="act quiet" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> |
| 470 | + </div> |
| 471 | + </form> |
| 469 | 472 | </details> |
| 470 | 473 | }) |
| 471 | 474 | } |
| | @@ -509,29 +512,21 @@ async fn restart_control( |
| 509 | 512 | ) -> Result<impl View> { |
| 510 | 513 | Ok(view! { |
| 511 | 514 | if pending.is_some() { |
| 512 | | - <span class="muted small">(if pending == Some(RestartMode::Now) { s(lang, "Restarting now...", "Şimdi yeniden başlatılıyor...") } else { s(lang, "Restarting after the current jobs...", "Mevcut işlerden sonra yeniden başlatılıyor...") })</span> |
| 515 | + <p class="state">(if pending == Some(RestartMode::Now) { s(lang, "Restarting now...", "Şimdi yeniden başlatılıyor...") } else { s(lang, "Restarting after the current jobs...", "Mevcut işlerden sonra yeniden başlatılıyor...") })</p> |
| 513 | 516 | } else if can_restart { |
| 514 | | - <details class="confirm-inline"> |
| 515 | | - <summary class="button">(s(lang, "Restart", "Yeniden başlat"))</summary> |
| 516 | | - <div class="confirm-pop"> |
| 517 | | - <p>(s(lang, "Restart this runner? It stops taking new jobs first.", "Bu çalıştırıcı yeniden başlatılsın mı? Önce yeni iş almayı bırakır."))</p> |
| 518 | | - <form method="post" action=(action) class="restart-choices"> |
| 519 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 520 | | - <input type="hidden" name="back" value=(back)> |
| 521 | | - <button type="submit" name="mode" value="drain" class="restart-choice"> |
| 522 | | - <strong>(s(lang, "Restart after current jobs", "Mevcut işlerden sonra yeniden başlat"))</strong> |
| 523 | | - <span>(s(lang, "The running jobs finish, then it restarts.", "Çalışan işler biter, sonra yeniden başlar."))</span> |
| 524 | | - </button> |
| 525 | | - <button type="submit" name="mode" value="now" class="restart-choice is-danger"> |
| 526 | | - <strong>(s(lang, "Restart now", "Şimdi yeniden başlat"))</strong> |
| 527 | | - <span>(s(lang, "The running jobs end as cancelled and can be run again.", "Çalışan işler iptal edilmiş olarak biter ve yeniden çalıştırılabilir."))</span> |
| 528 | | - </button> |
| 529 | | - <button type="button" class="restart-cancel" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> |
| 530 | | - </form> |
| 517 | + <details class="reveal"> |
| 518 | + <summary class="act">(s(lang, "Restart", "Yeniden başlat"))</summary> |
| 519 | + <div class="opened"> |
| 520 | + <p class="hint">(s(lang, "Restart this runner? It stops taking new jobs first.", "Bu çalıştırıcı yeniden başlatılsın mı? Önce yeni iş almayı bırakır."))</p> |
| 521 | + <p class="hint">(s(lang, "The running jobs finish, then it restarts.", "Çalışan işler biter, sonra yeniden başlar."))</p> |
| 522 | + <div class="acts"> |
| 523 | + post_act(label: s(lang, "Restart after current jobs", "Mevcut işlerden sonra yeniden başlat"), action: action, csrf: csrf, fields: vec![("mode".to_owned(), "drain".to_owned()), ("back".to_owned(), back.to_owned())]) |
| 524 | + confirm_act(lang: lang, label: s(lang, "Restart now", "Şimdi yeniden başlat"), action: action, csrf: csrf, fields: vec![("mode".to_owned(), "now".to_owned()), ("back".to_owned(), back.to_owned())], note: Some(s(lang, "The running jobs end as cancelled and can be run again.", "Çalışan işler iptal edilmiş olarak biter ve yeniden çalıştırılabilir.").to_owned())) |
| 525 | + </div> |
| 531 | 526 | </div> |
| 532 | 527 | </details> |
| 533 | 528 | } else { |
| 534 | | - <button type="button" disabled="disabled" title=(s(lang, "Runner too old, update it first", "Çalıştırıcı çok eski, önce güncelleyin"))>(s(lang, "Restart", "Yeniden başlat"))</button> |
| 529 | + <p class="hint">(s(lang, "Runner too old, update it first", "Çalıştırıcı çok eski, önce güncelleyin"))</p> |
| 535 | 530 | } |
| 536 | 531 | }) |
| 537 | 532 | } |
| | @@ -548,6 +543,7 @@ async fn concurrency_form( |
| 548 | 543 | lang: Lang, |
| 549 | 544 | csrf: &str, |
| 550 | 545 | action: &str, |
| 546 | + id: &str, |
| 551 | 547 | key: &str, |
| 552 | 548 | value: &str, |
| 553 | 549 | source: &'static str, |
| | @@ -573,34 +569,34 @@ async fn concurrency_form( |
| 573 | 569 | Lang::Tr => format!("{running}/{max} iş çalışıyor"), |
| 574 | 570 | }; |
| 575 | 571 | Ok(view! { |
| 576 | | - <form method="post" action=(action) class="runner-load" data-dirty-form=""> |
| 572 | + <form method="post" action=(action) class="fields runner-load" data-dirty-form=""> |
| 577 | 573 | <input type="hidden" name="csrf" value=(csrf)> |
| 578 | 574 | <input type="hidden" name="key" value=(key)> |
| 579 | 575 | <input type="hidden" name="back" value=(back)> |
| 580 | | - <div class="runner-running"> |
| 581 | | - <span class="runner-count"><span class="runner-n">(running_text.as_str())</span>" "<span class="muted">(s(lang, "running", "çalışıyor"))</span></span> |
| 582 | | - if use_pips { |
| 583 | | - <span class="runner-pips" role="img" aria-label=(pips_label.as_str())> |
| 584 | | - for pip in pips.iter() { |
| 585 | | - <span class=(*pip)></span> |
| 586 | | - } |
| 587 | | - </span> |
| 588 | | - } else { |
| 589 | | - <progress class="runner-meter" value=(running_text.as_str()) max=(meter_max.as_str()) aria-label=(s(lang, "Running jobs", "Çalışan işler"))></progress> |
| 590 | | - } |
| 591 | | - </div> |
| 592 | | - <div class="runner-stepper"> |
| 593 | | - <span class="runner-cap muted">(s(lang, "Max", "En çok"))</span> |
| 594 | | - <div class="runner-pill"> |
| 576 | + <div class="field"> |
| 577 | + <label for=(id)>(s(lang, "Concurrency", "Eşzamanlılık"))</label> |
| 578 | + <div class="runner-stepper"> |
| 595 | 579 | <button type="button" class="runner-step" data-step="-1" aria-label=(s(lang, "Fewer", "Azalt"))>"−"</button> |
| 596 | | - <input type="number" name="value" value=(value) min="1" max="64" step="1" inputmode="numeric" required="required" aria-label=(s(lang, "Concurrency", "Eşzamanlılık")) title=(source_title(lang, source))> |
| 580 | + <input id=(id) type="number" name="value" value=(value) min="1" max="64" step="1" inputmode="numeric" required="required" title=(source_title(lang, source))> |
| 597 | 581 | <button type="button" class="runner-step" data-step="1" aria-label=(s(lang, "More", "Artır"))>"+"</button> |
| 598 | 582 | </div> |
| 599 | | - <button type="submit" class="primary runner-save">(s(lang, "Save", "Kaydet"))</button> |
| 600 | | - if has_override { |
| 601 | | - <button type="submit" name="reset" value="1" class="runner-reset" formnovalidate="formnovalidate" title=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan")) aria-label=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan"))>"↺"</button> |
| 602 | | - } |
| 583 | + <div class="runner-running"> |
| 584 | + <span class="runner-count"><span class="runner-n">(running_text.as_str())</span>" "<span class="muted">(s(lang, "running", "çalışıyor"))</span></span> |
| 585 | + if use_pips { |
| 586 | + <span class="runner-pips" role="img" aria-label=(pips_label.as_str())> |
| 587 | + for pip in pips.iter() { |
| 588 | + <span class=(*pip)></span> |
| 589 | + } |
| 590 | + </span> |
| 591 | + } else { |
| 592 | + <progress class="runner-meter" value=(running_text.as_str()) max=(meter_max.as_str()) aria-label=(s(lang, "Running jobs", "Çalışan işler"))></progress> |
| 593 | + } |
| 594 | + </div> |
| 603 | 595 | </div> |
| 596 | + <button type="submit" class="primary runner-save">(s(lang, "Save", "Kaydet"))</button> |
| 597 | + if has_override { |
| 598 | + <button type="submit" name="reset" value="1" class="act" formnovalidate="formnovalidate" title=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan"))>(s(lang, "Use the runner.toml value", "runner.toml değerini kullan"))</button> |
| 599 | + } |
| 604 | 600 | </form> |
| 605 | 601 | }) |
| 606 | 602 | } |
| | @@ -613,26 +609,22 @@ async fn token_view( |
| 613 | 609 | expiry: String, |
| 614 | 610 | ) -> Result<impl View> { |
| 615 | 611 | Ok(view! { |
| 616 | | - <section class="page-head"> |
| 617 | | - <h1>(g::t(lang, K::RegistrationToken))</h1> |
| 618 | | - </section> |
| 619 | | - <section class="card notice" role="status"> |
| 620 | | - <p><strong>(g::t(lang, K::CopyTokenNow))</strong></p> |
| 621 | | - <p>(expiry.as_str())</p> |
| 622 | | - </section> |
| 623 | | - <section class="card" data-once=""> |
| 612 | + <h1 class="sr-only">(g::t(lang, K::RegistrationToken))</h1> |
| 613 | + <p class="state" role="status"><strong>(g::t(lang, K::CopyTokenNow))</strong></p> |
| 614 | + <p class="hint">(expiry.as_str())</p> |
| 615 | + <section class="sec" data-once=""> |
| 624 | 616 | <h2>(g::t(lang, K::Token))</h2> |
| 625 | 617 | <div class="copy-box"> |
| 626 | 618 | <code id="reg-token">(token.as_str())</code> |
| 627 | | - <button type="button" data-copy="reg-token" data-copied=(s(lang, "Copied", "Kopyalandı")) data-failed=(s(lang, "Failed", "Başarısız"))>(s(lang, "Copy", "Kopyala"))</button> |
| 619 | + <button type="button" class="act" data-copy="reg-token" data-copied=(s(lang, "Copied", "Kopyalandı")) data-failed=(s(lang, "Failed", "Başarısız"))>(s(lang, "Copy", "Kopyala"))</button> |
| 628 | 620 | </div> |
| 629 | 621 | <h2>(g::t(lang, K::RegisterARunner))</h2> |
| 630 | | - <p class="muted small">(g::t(lang, K::ReplacePrefix))<code>"<name>"</code>(g::t(lang, K::ReplaceSuffix))</p> |
| 622 | + <p class="hint">(g::t(lang, K::ReplacePrefix))<code>"<name>"</code>(g::t(lang, K::ReplaceSuffix))</p> |
| 631 | 623 | <div class="copy-box"> |
| 632 | 624 | <code id="reg-command">(command.as_str())</code> |
| 633 | | - <button type="button" data-copy="reg-command" data-copied=(s(lang, "Copied", "Kopyalandı")) data-failed=(s(lang, "Failed", "Başarısız"))>(s(lang, "Copy", "Kopyala"))</button> |
| 625 | + <button type="button" class="act" data-copy="reg-command" data-copied=(s(lang, "Copied", "Kopyalandı")) data-failed=(s(lang, "Failed", "Başarısız"))>(s(lang, "Copy", "Kopyala"))</button> |
| 634 | 626 | </div> |
| 635 | | - <p><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p> |
| 627 | + <p class="sub"><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p> |
| 636 | 628 | </section> |
| 637 | 629 | }) |
| 638 | 630 | } |
| | @@ -1084,7 +1076,6 @@ struct DetailField { |
| 1084 | 1076 | hint: &'static str, |
| 1085 | 1077 | value: String, |
| 1086 | 1078 | kind_label: &'static str, |
| 1087 | | - kind_class: &'static str, |
| 1088 | 1079 | source_label: &'static str, |
| 1089 | 1080 | pending_label: &'static str, |
| 1090 | 1081 | has_override: bool, |
| | @@ -1101,10 +1092,10 @@ fn detail_fields(lang: Lang, tab: &str, fields: &[FieldRow]) -> Vec<DetailField> |
| 1101 | 1092 | .filter_map(|key| fields.iter().find(|f| f.key == key)) |
| 1102 | 1093 | .map(|f| { |
| 1103 | 1094 | let (label, hint) = field_text(lang, f.key); |
| 1104 | | - let (kind_label, kind_class) = if f.kind == FieldKind::Live { |
| 1105 | | - (g::t(lang, K::SrvKindLive), "badge srv-live") |
| 1095 | + let kind_label = if f.kind == FieldKind::Live { |
| 1096 | + g::t(lang, K::SrvKindLive) |
| 1106 | 1097 | } else { |
| 1107 | | - (g::t(lang, K::SrvKindRestart), "badge srv-restart") |
| 1098 | + g::t(lang, K::SrvKindRestart) |
| 1108 | 1099 | }; |
| 1109 | 1100 | let choices: Vec<(&'static str, &'static str)> = match f.key { |
| 1110 | 1101 | "auto_update" => vec![ |
| | @@ -1132,7 +1123,6 @@ fn detail_fields(lang: Lang, tab: &str, fields: &[FieldRow]) -> Vec<DetailField> |
| 1132 | 1123 | hint, |
| 1133 | 1124 | value: f.value.clone(), |
| 1134 | 1125 | kind_label, |
| 1135 | | - kind_class, |
| 1136 | 1126 | source_label: source_text(lang, f.source), |
| 1137 | 1127 | pending_label: if !f.pending { |
| 1138 | 1128 | "" |
| | @@ -1596,12 +1586,9 @@ fn metrics_view(lang: Lang, samples: &[RunnerSample], now_ms: i64) -> MetricsVie |
| 1596 | 1586 | } |
| 1597 | 1587 | } |
| 1598 | 1588 | |
| 1599 | | -fn tab_class(on: bool) -> &'static str { |
| 1600 | | - if on { |
| 1601 | | - "subnav-link current" |
| 1602 | | - } else { |
| 1603 | | - "subnav-link" |
| 1604 | | - } |
| 1589 | +/// `aria-current` for the open tab of the detail page's tab row. |
| 1590 | +fn current(on: bool) -> Option<&'static str> { |
| 1591 | + on.then_some("page") |
| 1605 | 1592 | } |
| 1606 | 1593 | |
| 1607 | 1594 | #[component] |
| | @@ -1672,33 +1659,39 @@ async fn runner_detail_view( |
| 1672 | 1659 | let has_host = !metrics.empty || runner.reported.cpus.is_some(); |
| 1673 | 1660 | Ok(view! { |
| 1674 | 1661 | <div data-live="/admin/runners/events" class="runner-detail"> |
| 1675 | | - <section class="page-head"> |
| 1676 | | - <div class="runner-head"> |
| 1677 | | - <h1>(runner.name.as_str())</h1> |
| 1678 | | - <span class="runner-state"><span class=(row.dot_class)></span>(row.state_text)</span> |
| 1679 | | - if row.restart_pending.is_some() { |
| 1680 | | - <span class="ci-state runner-disabled">(s(lang, "restart pending", "yeniden başlatma bekliyor"))</span> |
| 1681 | | - } |
| 1682 | | - </div> |
| 1683 | | - <div class="runner-head-actions"> |
| 1684 | | - restart_control(lang: lang, csrf: csrf.as_str(), action: row.restart_action.as_str(), back: "detail", can_restart: row.can_restart, pending: row.restart_pending) |
| 1685 | | - <a href="/admin/runners">(g::t(lang, K::BackToRunners))</a> |
| 1686 | | - </div> |
| 1687 | | - </section> |
| 1662 | + <h1 class="h1">(runner.name.as_str())</h1> |
| 1663 | + <p class="hint runner-state"><span class=(row.dot_class)></span>(row.state_text) |
| 1664 | + if row.restart_pending.is_some() { |
| 1665 | + " · " |
| 1666 | + <span class="runner-off">(s(lang, "restart pending", "yeniden başlatma bekliyor"))</span> |
| 1667 | + } |
| 1668 | + </p> |
| 1669 | + <p class="sub"><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p> |
| 1688 | 1670 | if let Some((text, is_error)) = notice { |
| 1689 | 1671 | if is_error { |
| 1690 | | - <section class="card notice alert" role="alert">(text)</section> |
| 1672 | + alert(message: text) |
| 1691 | 1673 | } else { |
| 1692 | | - <section class="card notice" role="status">(text)</section> |
| 1674 | + <p class="state" role="status">(text)</p> |
| 1693 | 1675 | } |
| 1694 | 1676 | } |
| 1695 | | - <section class="card runner-overview"> |
| 1696 | | - <div class="srv-grid srv-stats"> |
| 1697 | | - <div class="srv-field"><span class="srv-label">(s(lang, "Running jobs", "Çalışan işler"))</span><strong><a href=(jobs_href.as_str())>(in_use.as_str())</a></strong></div> |
| 1698 | | - <div class="srv-field"><span class="srv-label">(g::t(lang, K::LastSeen))</span><strong title=(row.last_seen_full.as_str())><time data-rel="true" datetime=(row.last_seen_at.as_str())>(row.last_seen.as_str())</time></strong></div> |
| 1699 | | - <div class="srv-field"><span class="srv-label">(s(lang, "Build", "Derleme"))</span><strong class="runner-build-stat" title=(row.build.as_str())>(if row.build_short.is_empty() { "-" } else { row.build_short.as_str() })<span class=(format!("ci-state {}", row.build_class))>(row.build_label)</span></strong></div> |
| 1700 | | - <div class="srv-field"><span class="srv-label">(s(lang, "Runner version", "Çalıştırıcı sürümü"))</span><strong>(version.as_str())</strong></div> |
| 1677 | + <section class="sec"> |
| 1678 | + <h2>(s(lang, "Status", "Durum"))</h2> |
| 1679 | + <p class="state">(s(lang, "Running jobs", "Çalışan işler")) " " <a href=(jobs_href.as_str())>(in_use.as_str())</a></p> |
| 1680 | + <p class="hint">(g::t(lang, K::LastSeen)) " " <time data-rel="true" datetime=(row.last_seen_at.as_str()) title=(row.last_seen_full.as_str())>(row.last_seen.as_str())</time></p> |
| 1681 | + <p class="hint">(s(lang, "Build", "Derleme")) " " <span title=(row.build.as_str())>(if row.build_short.is_empty() { "-" } else { row.build_short.as_str() })</span> " " <span class=(format!("ci-state {}", row.build_class))>(row.build_label)</span></p> |
| 1682 | + <p class="hint">(s(lang, "Runner version", "Çalıştırıcı sürümü")) " " (version.as_str())</p> |
| 1683 | + <div class="acts"> |
| 1684 | + restart_control(lang: lang, csrf: csrf.as_str(), action: row.restart_action.as_str(), back: "detail", can_restart: row.can_restart, pending: row.restart_pending) |
| 1685 | + if row.disabled { |
| 1686 | + post_act(label: g::t(lang, K::Enable), action: row.toggle_action.as_str(), csrf: csrf.as_str(), fields: vec![("disabled".to_owned(), "0".to_owned())]) |
| 1687 | + } else { |
| 1688 | + confirm_post(lang: lang, csrf: csrf.as_str(), action: row.toggle_action.as_str(), label: g::t(lang, K::Disable), message: disable_message(lang, row.name.as_str()), confirm: s(lang, "Yes, disable", "Evet, devre dışı bırak"), danger: false, fields: vec![("disabled", "1".into())]) |
| 1689 | + } |
| 1690 | + confirm_post(lang: lang, csrf: csrf.as_str(), action: row.delete_action.as_str(), label: i18n::t(lang, Key::Delete), message: delete_message(lang, row.name.as_str()), confirm: s(lang, "Yes, delete", "Evet, sil"), danger: true, fields: vec![]) |
| 1701 | 1691 | </div> |
| 1692 | + </section> |
| 1693 | + <section class="sec"> |
| 1694 | + <h2>(s(lang, "Last hour", "Son bir saat"))</h2> |
| 1702 | 1695 | if has_host { |
| 1703 | 1696 | <div class="mx-panels"> |
| 1704 | 1697 | for (c, fact) in metrics.charts.iter().zip(facts.iter()) { |
| | @@ -1706,7 +1699,7 @@ async fn runner_detail_view( |
| 1706 | 1699 | <div class="mx-head"> |
| 1707 | 1700 | <p class="mx-caption">(c.caption.as_str())</p> |
| 1708 | 1701 | if !fact.is_empty() { |
| 1709 | | - <p class="muted small mx-facts">(fact.as_str())</p> |
| 1702 | + <p class="hint mx-facts">(fact.as_str())</p> |
| 1710 | 1703 | } |
| 1711 | 1704 | if !c.legend.is_empty() { |
| 1712 | 1705 | <ul class="mx-legend"> |
| | @@ -1753,7 +1746,7 @@ async fn runner_detail_view( |
| 1753 | 1746 | </div> |
| 1754 | 1747 | } |
| 1755 | 1748 | if metrics.empty { |
| 1756 | | - <p class="muted small">(s(lang, "No metrics yet. A runner sends them from this version on; an older one sends nothing.", "Henüz ölçüm yok. Ölçümleri bu sürümden itibaren çalıştırıcı gönderir; eski sürüm hiçbir şey göndermez."))</p> |
| 1749 | + <p class="hint">(s(lang, "No metrics yet. A runner sends them from this version on; an older one sends nothing.", "Henüz ölçüm yok. Ölçümleri bu sürümden itibaren çalıştırıcı gönderir; eski sürüm hiçbir şey göndermez."))</p> |
| 1757 | 1750 | } else { |
| 1758 | 1751 | <details class="mx-table"> |
| 1759 | 1752 | <summary>(s(lang, "Show as table", "Tablo olarak göster"))</summary> |
| | @@ -1776,61 +1769,54 @@ async fn runner_detail_view( |
| 1776 | 1769 | </details> |
| 1777 | 1770 | } |
| 1778 | 1771 | </section> |
| 1779 | | - <nav class="subnav" aria-label=(s(lang, "Configuration", "Yapılandırma"))> |
| 1772 | + <nav class="tabs" aria-label=(s(lang, "Configuration", "Yapılandırma"))> |
| 1780 | 1773 | for (slug, _) in TABS.iter() { |
| 1781 | | - <a class=(tab_class(*slug == tab)) href=(format!("{}?tab={}", row.detail_href, slug))>(tab_label(lang, slug))</a> |
| 1774 | + <a href=(format!("{}?tab={}", row.detail_href, slug)) aria-current=(current(*slug == tab))>(tab_label(lang, slug))</a> |
| 1782 | 1775 | } |
| 1783 | 1776 | </nav> |
| 1784 | 1777 | if editing { |
| 1785 | | - <section class="card rows-pane"> |
| 1786 | | - <form method="post" action=(save_action.as_str())> |
| 1778 | + <section class="sec"> |
| 1779 | + <form method="post" action=(save_action.as_str()) class="fields"> |
| 1787 | 1780 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1788 | 1781 | <input type="hidden" name="tab" value=(tab)> |
| 1789 | 1782 | for f in shown.iter() { |
| 1790 | | - <div class="row-line row-field"> |
| 1791 | | - <div class="row-main"> |
| 1792 | | - <label class="row-title" for=(format!("rf-{}", f.key))>(f.label) |
| 1793 | | - <span class=(f.kind_class)>(f.kind_label)</span> |
| 1794 | | - <span class="badge srv-source">(f.source_label)</span> |
| 1795 | | - if !f.pending_label.is_empty() { |
| 1796 | | - <span class="badge srv-pending">(f.pending_label)</span> |
| 1783 | + <div class="field"> |
| 1784 | + <label for=(format!("rf-{}", f.key))>(f.label)</label> |
| 1785 | + if f.input == "select" { |
| 1786 | + <select id=(format!("rf-{}", f.key)) name=(f.key)> |
| 1787 | + for (value, text, on) in f.options.iter() { |
| 1788 | + <option value=(*value) selected=(sel(*on))>(*text)</option> |
| 1797 | 1789 | } |
| 1798 | | - </label> |
| 1799 | | - <p class="row-status">(f.hint)</p> |
| 1800 | | - </div> |
| 1801 | | - <div class="row-control"> |
| 1802 | | - if f.input == "select" { |
| 1803 | | - <select id=(format!("rf-{}", f.key)) name=(f.key)> |
| 1804 | | - for (value, text, on) in f.options.iter() { |
| 1805 | | - <option value=(*value) selected=(sel(*on))>(*text)</option> |
| 1806 | | - } |
| 1807 | | - </select> |
| 1808 | | - } else if f.input == "number" { |
| 1809 | | - <input id=(format!("rf-{}", f.key)) type="number" name=(f.key) value=(f.value.as_str()) step="1" inputmode="numeric" min=(f.min) max=(f.max) placeholder=(s(lang, "(from runner.toml)", "(runner.toml'dan)"))> |
| 1810 | | - } else { |
| 1811 | | - <input id=(format!("rf-{}", f.key)) type="text" name=(f.key) value=(f.value.as_str()) placeholder=(s(lang, "(from runner.toml)", "(runner.toml'dan)")) autocomplete="off" spellcheck="false"> |
| 1812 | | - } |
| 1813 | | - if f.has_override { |
| 1814 | | - <button type="submit" form="rn-reset" name="key" value=(f.key)>(s(lang, "Reset to runner.toml", "runner.toml değerine sıfırla"))</button> |
| 1790 | + </select> |
| 1791 | + } else if f.input == "number" { |
| 1792 | + <input id=(format!("rf-{}", f.key)) type="number" name=(f.key) value=(f.value.as_str()) step="1" inputmode="numeric" min=(f.min) max=(f.max) placeholder=(s(lang, "(from runner.toml)", "(runner.toml'dan)"))> |
| 1793 | + } else { |
| 1794 | + <input id=(format!("rf-{}", f.key)) type="text" name=(f.key) value=(f.value.as_str()) placeholder=(s(lang, "(from runner.toml)", "(runner.toml'dan)")) autocomplete="off" spellcheck="false"> |
| 1795 | + } |
| 1796 | + <p class="hint">(f.hint)</p> |
| 1797 | + <p class="hint">(f.kind_label) " · " (f.source_label) |
| 1798 | + if !f.pending_label.is_empty() { |
| 1799 | + " · " (f.pending_label) |
| 1815 | 1800 | } |
| 1816 | | - </div> |
| 1801 | + </p> |
| 1802 | + if f.has_override { |
| 1803 | + <div class="acts"> |
| 1804 | + <button type="submit" form="rn-reset" name="key" value=(f.key) class="act">(s(lang, "Reset to runner.toml", "runner.toml değerine sıfırla"))</button> |
| 1805 | + </div> |
| 1806 | + } |
| 1817 | 1807 | </div> |
| 1818 | 1808 | } |
| 1819 | 1809 | for (i, (label, value)) in identity.iter().enumerate().filter(|_| tab == "identity") { |
| 1820 | | - <div class="row-line row-field"> |
| 1821 | | - <div class="row-main"> |
| 1822 | | - <span class="row-title">(*label)<span class="badge srv-ro">(g::t(lang, K::SrvKindReadOnly))</span></span> |
| 1823 | | - if i == 0 { |
| 1824 | | - <p class="row-status">(s(lang, "Set when the runner registered. These cannot be changed from the forge.", "Çalıştırıcı kaydolurken belirlenir. Forge üzerinden değiştirilemez."))</p> |
| 1825 | | - } |
| 1826 | | - </div> |
| 1827 | | - <div class="row-control"><code class="srv-fixed">(value.as_str())</code></div> |
| 1810 | + <div class="field"> |
| 1811 | + <p class="state">(*label) " " <code class="srv-fixed">(value.as_str())</code></p> |
| 1812 | + <p class="hint">(g::t(lang, K::SrvKindReadOnly))</p> |
| 1813 | + if i == 0 { |
| 1814 | + <p class="hint">(s(lang, "Set when the runner registered. These cannot be changed from the forge.", "Çalıştırıcı kaydolurken belirlenir. Forge üzerinden değiştirilemez."))</p> |
| 1815 | + } |
| 1828 | 1816 | </div> |
| 1829 | 1817 | } |
| 1830 | 1818 | if tab != "identity" { |
| 1831 | | - <div class="row-foot"> |
| 1832 | | - <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> |
| 1833 | | - </div> |
| 1819 | + <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> |
| 1834 | 1820 | } |
| 1835 | 1821 | </form> |
| 1836 | 1822 | <form id="rn-reset" method="post" action=(reset_action.as_str())> |
| | @@ -1841,13 +1827,13 @@ async fn runner_detail_view( |
| 1841 | 1827 | </form> |
| 1842 | 1828 | </section> |
| 1843 | 1829 | } else { |
| 1844 | | - <section class="card"> |
| 1830 | + <section class="sec"> |
| 1845 | 1831 | if tab == "logs" { |
| 1846 | 1832 | if log.is_empty() { |
| 1847 | | - <p class="muted small">(s(lang, "No log lines yet. Only a runner from the version that sends its log does so; an older runner sends nothing.", "Henüz günlük satırı yok. Günlüğünü yalnızca bunu destekleyen sürüm gönderir; eski sürüm hiçbir şey göndermez."))</p> |
| 1833 | + <p class="hint">(s(lang, "No log lines yet. Only a runner from the version that sends its log does so; an older runner sends nothing.", "Henüz günlük satırı yok. Günlüğünü yalnızca bunu destekleyen sürüm gönderir; eski sürüm hiçbir şey göndermez."))</p> |
| 1848 | 1834 | } else { |
| 1849 | 1835 | <div class="runner-log-bar"> |
| 1850 | | - <button type="button" class="ci-mini" data-copy="runner-log" data-copied=(rc::t(lang, rc::K::CopyDone)) data-failed=(rc::t(lang, rc::K::CopyFailed))>(s(lang, "Copy all", "Tümünü kopyala"))</button> |
| 1836 | + <button type="button" class="act" data-copy="runner-log" data-copied=(rc::t(lang, rc::K::CopyDone)) data-failed=(rc::t(lang, rc::K::CopyFailed))>(s(lang, "Copy all", "Tümünü kopyala"))</button> |
| 1851 | 1837 | </div> |
| 1852 | 1838 | <pre id="runner-log" class="ci-log runner-log" role="log" aria-label=(s(lang, "Runner log", "Çalıştırıcı günlüğü"))> |
| 1853 | 1839 | for row in log.iter() { |
| | @@ -1858,7 +1844,7 @@ async fn runner_detail_view( |
| 1858 | 1844 | } else if tab == "jobs" { |
| 1859 | 1845 | <h2>(s(lang, "Running now", "Şu an çalışan"))</h2> |
| 1860 | 1846 | if running_jobs.is_empty() { |
| 1861 | | - <p class="muted small">(s(lang, "Not running any job.", "Hiçbir iş çalıştırmıyor."))</p> |
| 1847 | + <p class="hint">(s(lang, "Not running any job.", "Hiçbir iş çalıştırmıyor."))</p> |
| 1862 | 1848 | } else { |
| 1863 | 1849 | <div class="table-wrap"> |
| 1864 | 1850 | <table class="table queue-table"> |
| | @@ -1879,7 +1865,7 @@ async fn runner_detail_view( |
| 1879 | 1865 | } |
| 1880 | 1866 | <h2>(s(lang, "Recent", "Son"))</h2> |
| 1881 | 1867 | if recent_jobs.is_empty() { |
| 1882 | | - <p class="muted small">(s(lang, "No finished jobs yet.", "Henüz biten iş yok."))</p> |
| 1868 | + <p class="hint">(s(lang, "No finished jobs yet.", "Henüz biten iş yok."))</p> |
| 1883 | 1869 | } else { |
| 1884 | 1870 | <div class="table-wrap"> |
| 1885 | 1871 | <table class="table queue-table"> |
| | @@ -2356,7 +2342,7 @@ mod tests { |
| 2356 | 2342 | assert!(!page.contains("linux, x86_64"), "labels are not joined"); |
| 2357 | 2343 | // Never seen, so offline; not disabled, so no disabled word. |
| 2358 | 2344 | assert!(page.contains(r#"class="runner-dot is-offline""#)); |
| 2359 | | - assert!(!page.contains(r#"<span class="runner-off">disabled</span>"#)); |
| 2345 | + assert!(!page.contains(r#"<span class="val">idle · disabled</span>"#)); |
| 2360 | 2346 | |
| 2361 | 2347 | let runner = store.list_runners().await.expect("list").remove(0); |
| 2362 | 2348 | store |
| | @@ -2365,7 +2351,7 @@ mod tests { |
| 2365 | 2351 | .expect("disable"); |
| 2366 | 2352 | let (_, page) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; |
| 2367 | 2353 | assert!(page.contains(r#"class="runner-dot is-disabled""#)); |
| 2368 | | - assert!(page.contains(r#"<span class="runner-off">disabled</span>"#)); |
| 2354 | + assert!(page.contains(r#"<span class="val">idle · disabled</span>"#)); |
| 2369 | 2355 | } |
| 2370 | 2356 | |
| 2371 | 2357 | // Scenario: restart is capability-gated and audited, then the runner is disabled, enabled and deleted. |
| | @@ -1,6 +1,6 @@ |
| 1 | 1 | //! Page: the forge's own settings (`/admin/server`). Instance admins only; anyone else gets 404. |
| 2 | 2 | //! |
| 3 | | -//! One tab per group of settings. Each field shows its effective value, where that value comes |
| 3 | +//! One category of settings at a time (`?cat=`). Each field shows its effective value, where that value comes |
| 4 | 4 | //! from (default, config file, or a UI override) and how a change reaches the process: live |
| 5 | 5 | //! (applied at once), restart (saved, applied at the next start) or read-only. Saving a tab stores |
| 6 | 6 | //! the changed fields as database overrides on top of the config file, which is never rewritten. |
| | @@ -35,26 +35,25 @@ use crate::i18n::{self, Key, Lang}; |
| 35 | 35 | use crate::live::Topic; |
| 36 | 36 | use crate::pages::admin_users::admin_only; |
| 37 | 37 | use crate::pages::ci_runs::{changed_event, events_response}; |
| 38 | +use crate::pages::passkeys::s; |
| 38 | 39 | use crate::self_update; |
| 39 | 40 | use crate::state::AppState; |
| 41 | +use crate::views::parts::{confirm_act, reveal}; |
| 40 | 42 | use crate::views::{enc, shell}; |
| 41 | 43 | |
| 42 | 44 | #[query_params(error = bad_request)] |
| 43 | 45 | pub(crate) struct ServerQuery { |
| 44 | 46 | notice: Option<String>, |
| 47 | + /// The category shown: `general`, `limits`, `storage`, `backups`, `integrations` or `alerts`. |
| 48 | + cat: Option<String>, |
| 49 | + /// The search text: when set, the page lists the matching settings from every category instead. |
| 50 | + q: Option<String>, |
| 51 | + /// The older name for `cat`, still read so an old link opens the same category. |
| 45 | 52 | tab: Option<String>, |
| 46 | 53 | /// The boot id of the server that was asked to restart. |
| 47 | 54 | restarting: Option<String>, |
| 48 | 55 | } |
| 49 | 56 | |
| 50 | | -/// Picks the English or Turkish text. |
| 51 | | -fn s(lang: Lang, en: &'static str, tr: &'static str) -> &'static str { |
| 52 | | - match lang { |
| 53 | | - Lang::En => en, |
| 54 | | - Lang::Tr => tr, |
| 55 | | - } |
| 56 | | -} |
| 57 | | - |
| 58 | 57 | /// How long the restart waits after the request is answered, so the redirect that follows is |
| 59 | 58 | /// served by the old process. |
| 60 | 59 | const RESTART_GRACE: std::time::Duration = std::time::Duration::from_millis(750); |
| | @@ -87,11 +86,13 @@ struct OptionRow { |
| 87 | 86 | /// One field, already formatted for the template. A secret's value is never in here. |
| 88 | 87 | struct Row { |
| 89 | 88 | key: &'static str, |
| 89 | + /// The category the setting belongs to, for a search result's link. |
| 90 | + group: Group, |
| 90 | 91 | label: &'static str, |
| 91 | 92 | help: &'static str, |
| 92 | 93 | kind_label: &'static str, |
| 93 | | - kind_class: &'static str, |
| 94 | | - source_label: &'static str, |
| 94 | + /// What a line shows for the value: the text, the chosen option, On or Off, or the secret state. |
| 95 | + value_text: String, |
| 95 | 96 | value: String, |
| 96 | 97 | file_value: String, |
| 97 | 98 | show_file_value: bool, |
| | @@ -107,6 +108,10 @@ struct Row { |
| 107 | 108 | is_select: bool, |
| 108 | 109 | is_secret: bool, |
| 109 | 110 | fixed: bool, |
| 111 | + /// A value the config file sets: it reads as a line and opens in place to change. |
| 112 | + file_line: bool, |
| 113 | + /// A short control: two of them in a row share a `.field-pair`. |
| 114 | + short: bool, |
| 110 | 115 | } |
| 111 | 116 | |
| 112 | 117 | pub(crate) fn tab_label(lang: Lang, group: Group) -> &'static str { |
| | @@ -123,25 +128,13 @@ pub(crate) fn tab_label(lang: Lang, group: Group) -> &'static str { |
| 123 | 128 | ) |
| 124 | 129 | } |
| 125 | 130 | |
| 126 | | -fn tab_class(on: bool) -> &'static str { |
| 127 | | - if on { |
| 128 | | - "subnav-link current" |
| 129 | | - } else { |
| 130 | | - "subnav-link" |
| 131 | | - } |
| 132 | | -} |
| 133 | | - |
| 134 | 131 | fn row(lang: Lang, view: &FieldView) -> Row { |
| 135 | 132 | let field: &Field = view.field; |
| 136 | | - let (kind_label, kind_class) = match field.kind { |
| 137 | | - Kind::Live => (g::t(lang, K::SrvKindLive), "badge srv-live"), |
| 138 | | - Kind::Restart => (g::t(lang, K::SrvKindRestart), "badge srv-restart"), |
| 139 | | - Kind::ReadOnly => (g::t(lang, K::SrvKindReadOnly), "badge srv-ro"), |
| 140 | | - }; |
| 141 | | - let source_label = match view.source { |
| 142 | | - Source::Default => g::t(lang, K::SrvSourceDefault), |
| 143 | | - Source::File => g::t(lang, K::SrvSourceFile), |
| 144 | | - Source::Ui => g::t(lang, K::SrvSourceUi), |
| 133 | + let kind_label = match field.kind { |
| 134 | + // A live field needs no word: applying at once is what a field is expected to do. |
| 135 | + Kind::Live => "", |
| 136 | + Kind::Restart => g::t(lang, K::SrvKindRestart), |
| 137 | + Kind::ReadOnly => g::t(lang, K::SrvKindReadOnly), |
| 145 | 138 | }; |
| 146 | 139 | let (min, max) = match field.ty { |
| 147 | 140 | Ty::Uint(min, max) => (min.to_string(), max.to_string()), |
| | @@ -163,41 +156,81 @@ fn row(lang: Lang, view: &FieldView) -> Row { |
| 163 | 156 | _ => Vec::new(), |
| 164 | 157 | }; |
| 165 | 158 | let editable = field.kind != Kind::ReadOnly; |
| 159 | + let is_secret = field.is_secret(); |
| 160 | + let is_bool = field.ty == Ty::Bool && editable; |
| 161 | + let is_number = matches!(field.ty, Ty::Uint(..)) && editable; |
| 162 | + let is_select = matches!(field.ty, Ty::Choice(_)) && editable; |
| 163 | + let file_line = editable && view.source == Source::File; |
| 164 | + let secret_state = if view.secret_set { |
| 165 | + g::t(lang, K::SrvSecretSet) |
| 166 | + } else { |
| 167 | + g::t(lang, K::SrvSecretNotSet) |
| 168 | + }; |
| 169 | + let value_text = if is_secret { |
| 170 | + secret_state.to_owned() |
| 171 | + } else if field.ty == Ty::Bool { |
| 172 | + let (en, tr) = if view.value == "true" { |
| 173 | + ("On", "Açık") |
| 174 | + } else { |
| 175 | + ("Off", "Kapalı") |
| 176 | + }; |
| 177 | + s(lang, en, tr).to_owned() |
| 178 | + } else if let Some(option) = options.iter().find(|option| option.selected) { |
| 179 | + option.label.clone() |
| 180 | + } else if view.value.is_empty() { |
| 181 | + g::t(lang, K::SrvEmpty).to_owned() |
| 182 | + } else { |
| 183 | + view.value.clone() |
| 184 | + }; |
| 166 | 185 | let (label, help) = match (lang, i18n::server_settings::field_tr(field.key)) { |
| 167 | 186 | (Lang::Tr, Some(tr)) => tr, |
| 168 | 187 | _ => (field.label, field.help), |
| 169 | 188 | }; |
| 170 | 189 | Row { |
| 171 | 190 | key: field.key, |
| 191 | + group: field.group, |
| 172 | 192 | label, |
| 173 | 193 | help, |
| 174 | 194 | kind_label, |
| 175 | | - kind_class, |
| 176 | | - source_label, |
| 195 | + value_text, |
| 177 | 196 | value: view.value.clone(), |
| 178 | 197 | file_value: if view.file_value.is_empty() { |
| 179 | 198 | g::t(lang, K::SrvEmpty).to_owned() |
| 180 | 199 | } else { |
| 181 | 200 | view.file_value.clone() |
| 182 | 201 | }, |
| 183 | | - show_file_value: editable && view.source == Source::Ui && !field.is_secret(), |
| 202 | + show_file_value: editable && view.source == Source::Ui && !is_secret, |
| 184 | 203 | has_override: editable && view.source == Source::Ui, |
| 185 | 204 | pending: view.restart_pending, |
| 186 | 205 | checked: view.value == "true", |
| 187 | 206 | min, |
| 188 | 207 | max, |
| 189 | 208 | options, |
| 190 | | - secret_state: if view.secret_set { |
| 191 | | - g::t(lang, K::SrvSecretSet) |
| 192 | | - } else { |
| 193 | | - g::t(lang, K::SrvSecretNotSet) |
| 194 | | - }, |
| 195 | | - is_bool: field.ty == Ty::Bool && editable, |
| 196 | | - is_number: matches!(field.ty, Ty::Uint(..)) && editable, |
| 197 | | - is_select: matches!(field.ty, Ty::Choice(_)) && editable, |
| 198 | | - is_secret: field.is_secret(), |
| 209 | + secret_state, |
| 210 | + is_bool, |
| 211 | + is_number, |
| 212 | + is_select, |
| 213 | + is_secret, |
| 199 | 214 | fixed: !editable, |
| 215 | + file_line, |
| 216 | + short: editable && !file_line && !is_secret && (is_number || is_select), |
| 217 | + } |
| 218 | +} |
| 219 | + |
| 220 | +/// Groups the rows into blocks. Two short controls in a row share one `.field-pair`. |
| 221 | +fn into_blocks(rows: Vec<Row>) -> Vec<Vec<Row>> { |
| 222 | + let mut blocks: Vec<Vec<Row>> = Vec::new(); |
| 223 | + for row in rows { |
| 224 | + let joins = row.short && blocks.last().is_some_and(|b| b.len() == 1 && b[0].short); |
| 225 | + if joins { |
| 226 | + if let Some(last) = blocks.last_mut() { |
| 227 | + last.push(row); |
| 228 | + } |
| 229 | + } else { |
| 230 | + blocks.push(vec![row]); |
| 231 | + } |
| 200 | 232 | } |
| 233 | + blocks |
| 201 | 234 | } |
| 202 | 235 | |
| 203 | 236 | async fn rows_for(state: &AppState, lang: Lang, group: Group) -> forge_core::Result<Vec<Row>> { |
| | @@ -211,17 +244,138 @@ async fn rows_for(state: &AppState, lang: Lang, group: Group) -> forge_core::Res |
| 211 | 244 | .collect()) |
| 212 | 245 | } |
| 213 | 246 | |
| 247 | +/// The settings from every category whose key, label or help holds `needle` (already lowercase). |
| 248 | +async fn search_hits(state: &AppState, lang: Lang, needle: &str) -> forge_core::Result<Vec<Row>> { |
| 249 | + let overrides = state.store.server_overrides().await?; |
| 250 | + Ok(state |
| 251 | + .settings |
| 252 | + .views(&overrides) |
| 253 | + .iter() |
| 254 | + .map(|view| row(lang, view)) |
| 255 | + .filter(|hit| { |
| 256 | + hit.key.contains(needle) |
| 257 | + || hit.label.to_lowercase().contains(needle) |
| 258 | + || hit.help.to_lowercase().contains(needle) |
| 259 | + }) |
| 260 | + .collect()) |
| 261 | +} |
| 262 | + |
| 263 | +/// One setting. A value the config file sets reads as a line, and opens in place to change. |
| 264 | +#[component] |
| 265 | +async fn srv_row(lang: Lang, row: &Row) -> Result<impl View> { |
| 266 | + let id = format!("srv-{}", row.key); |
| 267 | + let input = format!("srv-{}-in", row.key); |
| 268 | + Ok(view! { |
| 269 | + <div class="srv-row" id=(id.as_str())> |
| 270 | + if row.fixed { |
| 271 | + <div class="line"> |
| 272 | + <span class="name">(row.label)</span> |
| 273 | + <span class="val">(row.value_text.as_str())</span> |
| 274 | + </div> |
| 275 | + srv_hints(lang: lang, row: row) |
| 276 | + } else if row.file_line { |
| 277 | + <div class="line"> |
| 278 | + <span class="name">(row.label)</span> |
| 279 | + <span class="val">(row.value_text.as_str())</span> |
| 280 | + </div> |
| 281 | + reveal(label: s(lang, "Set here", "Burada ayarla"), |
| 282 | + srv_control(lang: lang, row: row, input: input.as_str()) |
| 283 | + ) |
| 284 | + } else { |
| 285 | + srv_control(lang: lang, row: row, input: input.as_str()) |
| 286 | + } |
| 287 | + </div> |
| 288 | + }) |
| 289 | +} |
| 290 | + |
| 291 | +/// The control of one setting, labelled for the viewer, with its hints under it. A switch carries |
| 292 | +/// its own label, and its hints sit under the switch. |
| 293 | +#[component] |
| 294 | +async fn srv_control(lang: Lang, row: &Row, input: &str) -> Result<impl View> { |
| 295 | + Ok(view! { |
| 296 | + <div class="srv-control"> |
| 297 | + if row.is_bool { |
| 298 | + <label class="switch"> |
| 299 | + <input type="checkbox" id=(input) name=(row.key) value="true" checked=(row.checked)> |
| 300 | + <span>(row.label)</span> |
| 301 | + </label> |
| 302 | + srv_hints(lang: lang, row: row) |
| 303 | + } else { |
| 304 | + <div class="field"> |
| 305 | + <label for=(input)>(row.label)</label> |
| 306 | + if row.is_select { |
| 307 | + <select id=(input) name=(row.key)> |
| 308 | + for option in row.options.iter() { |
| 309 | + <option value=(option.value.as_str()) selected=(option.selected)>(option.label.as_str())</option> |
| 310 | + } |
| 311 | + </select> |
| 312 | + } else if row.is_number && row.max.parse::<u64>().is_ok_and(|max| max <= 100) { |
| 313 | + // A small range steps with − and +, like the runner's Max. |
| 314 | + <div class="runner-pill"> |
| 315 | + <button type="button" class="runner-step" data-step="-1" aria-label=(s(lang, "Fewer", "Azalt"))>"−"</button> |
| 316 | + <input type="number" id=(input) name=(row.key) value=(row.value.as_str()) min=(row.min.as_str()) max=(row.max.as_str()) step="1" inputmode="numeric"> |
| 317 | + <button type="button" class="runner-step" data-step="1" aria-label=(s(lang, "More", "Artır"))>"+"</button> |
| 318 | + </div> |
| 319 | + } else if row.is_number { |
| 320 | + <input type="number" id=(input) name=(row.key) value=(row.value.as_str()) min=(row.min.as_str()) max=(row.max.as_str())> |
| 321 | + } else if row.is_secret { |
| 322 | + <input type="password" id=(input) name=(row.key) autocomplete="new-password" maxlength="1024"> |
| 323 | + } else { |
| 324 | + <input type="text" id=(input) name=(row.key) value=(row.value.as_str()) maxlength="1024" autocomplete="off"> |
| 325 | + } |
| 326 | + srv_hints(lang: lang, row: row) |
| 327 | + </div> |
| 328 | + } |
| 329 | + </div> |
| 330 | + }) |
| 331 | +} |
| 332 | + |
| 333 | +/// What a setting says under its control: its help, its kind, a secret's rule and its override. |
| 334 | +#[component] |
| 335 | +async fn srv_hints(lang: Lang, row: &Row) -> Result<impl View> { |
| 336 | + Ok(view! { |
| 337 | + <div class="srv-hints"> |
| 338 | + if !row.help.is_empty() { |
| 339 | + <p class="hint">(row.help)</p> |
| 340 | + } |
| 341 | + if row.is_secret { |
| 342 | + <p class="hint">(row.secret_state) ". " (g::t(lang, K::SrvSecretHint))</p> |
| 343 | + } |
| 344 | + if !row.kind_label.is_empty() { |
| 345 | + <p class="hint">(row.kind_label)</p> |
| 346 | + } |
| 347 | + if row.pending { |
| 348 | + <p class="hint">(g::t(lang, K::SrvRestartNeeded))</p> |
| 349 | + } |
| 350 | + if row.has_override { |
| 351 | + <p class="hint"> |
| 352 | + (s(lang, "Set here.", "Burada ayarlandı.")) |
| 353 | + if row.show_file_value { |
| 354 | + " " (g::t(lang, K::SrvFileValue)) ": " <code>(row.file_value.as_str())</code> |
| 355 | + } |
| 356 | + " " |
| 357 | + <button type="submit" class="act" form="srv-reset" name="key" value=(row.key)>(g::t(lang, K::SrvResetToFile))</button> |
| 358 | + </p> |
| 359 | + } |
| 360 | + </div> |
| 361 | + }) |
| 362 | +} |
| 363 | + |
| 214 | 364 | #[component] |
| 215 | 365 | async fn server_view( |
| 216 | 366 | lang: Lang, |
| 217 | 367 | csrf: String, |
| 218 | 368 | group: Group, |
| 219 | 369 | rows: Vec<Row>, |
| 370 | + q: String, |
| 371 | + search: Option<Vec<Row>>, |
| 220 | 372 | notice: Option<String>, |
| 221 | 373 | restart: Restart, |
| 222 | 374 | ) -> Result<impl View> { |
| 223 | 375 | let tab = group.slug(); |
| 224 | 376 | let any_editable = rows.iter().any(|r| !r.fixed); |
| 377 | + let blocks = into_blocks(rows); |
| 378 | + let search_label = s(lang, "Search server settings", "Sunucu ayarlarında ara"); |
| 225 | 379 | // A pending restart names the boot id it waits for: the stream then sends at once when a new |
| 226 | 380 | // process answers, and the page re-renders. |
| 227 | 381 | let live = match restart { |
| | @@ -232,124 +386,86 @@ async fn server_view( |
| 232 | 386 | _ => "/admin/server/events".to_owned(), |
| 233 | 387 | }; |
| 234 | 388 | Ok(view! { |
| 235 | | - <div data-live=(live.as_str()) class="srv-page"> |
| 236 | | - <section class="page-head"> |
| 237 | | - <h1>(g::t(lang, K::ServerSettings))</h1> |
| 238 | | - </section> |
| 239 | | - <p class="muted page-lede">(g::t(lang, K::ServerSettingsIntro))</p> |
| 240 | | - <p class="muted small page-lede">(match lang { Lang::Tr => "Sürüm", _ => "Version" }) " " (forge_ci::build::display())</p> |
| 241 | | - if restart == Restart::Pending { |
| 242 | | - <section class="card notice srv-restarting" role="status" aria-live="polite"> |
| 243 | | - <p><strong>(s(lang, "Restarting...", "Yeniden başlatılıyor..."))</strong> " " (s(lang, "This page comes back by itself when the server is up again.", "Sunucu tekrar ayağa kalkınca bu sayfa kendiliğinden geri gelir."))</p> |
| 244 | | - </section> |
| 245 | | - } else if restart == Restart::Done { |
| 246 | | - <section class="card notice" role="status"> |
| 247 | | - <p>(s(lang, "The server restarted. Settings that needed a restart are applied now.", "Sunucu yeniden başladı. Yeniden başlatma gerektiren ayarlar artık uygulandı."))</p> |
| 248 | | - </section> |
| 249 | | - } |
| 250 | | - <nav class="subnav" aria-label=(g::t(lang, K::ServerSettings))> |
| 251 | | - for g_tab in Group::ALL.into_iter() { |
| 252 | | - <a class=(tab_class(g_tab == group)) href=(format!("/admin/server?tab={}", g_tab.slug()))>(tab_label(lang, g_tab))</a> |
| 389 | + <div data-live=(live.as_str())> |
| 390 | + <h1 class="sr-only">(g::t(lang, K::ServerSettings))</h1> |
| 391 | + <form class="plain-search" method="get" action="/admin/server" role="search"> |
| 392 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> |
| 393 | + <label class="sr-only" for="server-search">(search_label)</label> |
| 394 | + <input id="server-search" type="search" name="q" value=(q.as_str()) placeholder=(search_label) data-live-search="" autocomplete="off"> |
| 395 | + </form> |
| 396 | + <nav class="sub" aria-label=(g::t(lang, K::ServerSettings))> |
| 397 | + for g_tab in Group::ALL.into_iter() { |
| 398 | + if g_tab == group { |
| 399 | + <a aria-current="page" href=(format!("/admin/server?cat={}", g_tab.slug()))>(tab_label(lang, g_tab))</a> |
| 400 | + } else { |
| 401 | + <a href=(format!("/admin/server?cat={}", g_tab.slug()))>(tab_label(lang, g_tab))</a> |
| 402 | + } |
| 403 | + } |
| 404 | + </nav> |
| 405 | + <p class="hint">(g::t(lang, K::ServerSettingsIntro))</p> |
| 406 | + <p class="hint">(s(lang, "Version", "Sürüm")) " " (forge_ci::build::display())</p> |
| 407 | + if restart == Restart::Pending { |
| 408 | + <p class="state" role="status" aria-live="polite"><strong>(s(lang, "Restarting...", "Yeniden başlatılıyor..."))</strong> " " (s(lang, "This page comes back by itself when the server is up again.", "Sunucu tekrar ayağa kalkınca bu sayfa kendiliğinden geri gelir."))</p> |
| 409 | + } else if restart == Restart::Done { |
| 410 | + <p class="state" role="status">(s(lang, "The server restarted. Settings that needed a restart are applied now.", "Sunucu yeniden başladı. Yeniden başlatma gerektiren ayarlar artık uygulandı."))</p> |
| 253 | 411 | } |
| 254 | | - </nav> |
| 255 | | - if let Some(message) = notice { |
| 256 | | - <section class="card notice" role="status"> |
| 257 | | - <p>(message.as_str())</p> |
| 258 | | - </section> |
| 259 | | - } |
| 260 | | - <section class="card rows-pane"> |
| 261 | | - <form method="post" action="/admin/server" class="srv-form"> |
| 262 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 263 | | - <input type="hidden" name="tab" value=(tab)> |
| 264 | | - for r in rows.iter() { |
| 265 | | - <div class="row-line row-field srv-field" id=(format!("srv-{}", r.key))> |
| 266 | | - <div class="row-main"> |
| 267 | | - <span class="row-title"> |
| 268 | | - <span class="srv-label" title=(r.label)>(r.label)</span> |
| 269 | | - <span class=(r.kind_class)>(r.kind_label)</span> |
| 270 | | - <span class="badge srv-source">(r.source_label)</span> |
| 271 | | - if r.pending { |
| 272 | | - <span class="badge srv-pending">(g::t(lang, K::SrvRestartNeeded))</span> |
| 273 | | - } |
| 274 | | - </span> |
| 275 | | - if !r.help.is_empty() { |
| 276 | | - <p class="row-status">(r.help)</p> |
| 277 | | - } |
| 278 | | - if r.is_secret { |
| 279 | | - <p class="row-status"><strong>(r.secret_state)</strong> ". " (g::t(lang, K::SrvSecretHint))</p> |
| 280 | | - } |
| 281 | | - if r.has_override && r.show_file_value { |
| 282 | | - <p class="row-status">(g::t(lang, K::SrvFileValue)) ": " <code>(r.file_value.as_str())</code></p> |
| 283 | | - } |
| 284 | | - </div> |
| 285 | | - <div class="row-control"> |
| 286 | | - if r.is_bool { |
| 287 | | - <input type="checkbox" name=(r.key) value="true" checked=(r.checked) aria-label=(r.label)> |
| 288 | | - } else if r.is_select { |
| 289 | | - <select name=(r.key) aria-label=(r.label)> |
| 290 | | - for option in r.options.iter() { |
| 291 | | - <option value=(option.value.as_str()) selected=(option.selected)>(option.label.as_str())</option> |
| 412 | + if let Some(message) = notice { |
| 413 | + <p class="state" role="status">(message.as_str())</p> |
| 414 | + } |
| 415 | + if let Some(hits) = search { |
| 416 | + <section class="sec"> |
| 417 | + <h2>(s(lang, "Results", "Sonuçlar"))</h2> |
| 418 | + if hits.is_empty() { |
| 419 | + <p class="state">(s(lang, "No setting matches.", "Eşleşen ayar yok."))</p> |
| 420 | + } |
| 421 | + for hit in hits.iter() { |
| 422 | + <a class="line" href=(format!("/admin/server?cat={}#srv-{}", hit.group.slug(), hit.key))> |
| 423 | + <span class="name">(hit.label)</span> |
| 424 | + <span class="val">(tab_label(lang, hit.group))</span> |
| 425 | + </a> |
| 426 | + } |
| 427 | + </section> |
| 428 | + } else { |
| 429 | + <section class="sec"> |
| 430 | + <h2>(tab_label(lang, group))</h2> |
| 431 | + <form method="post" action="/admin/server" class="fields"> |
| 432 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 433 | + <input type="hidden" name="tab" value=(tab)> |
| 434 | + for block in blocks.iter() { |
| 435 | + if block.len() > 1 { |
| 436 | + <div class="field-pair"> |
| 437 | + for r in block.iter() { |
| 438 | + srv_row(lang: lang, row: r) |
| 292 | 439 | } |
| 293 | | - </select> |
| 294 | | - } else if r.is_number && r.max.parse::<u64>().is_ok_and(|max| max <= 100) { |
| 295 | | - // A small range steps with − and +, like the runner's Max. |
| 296 | | - <div class="runner-pill"> |
| 297 | | - <button type="button" class="runner-step" data-step="-1" aria-label=(s(lang, "Fewer", "Azalt"))>"−"</button> |
| 298 | | - <input type="number" name=(r.key) value=(r.value.as_str()) min=(r.min.as_str()) max=(r.max.as_str()) step="1" inputmode="numeric" aria-label=(r.label)> |
| 299 | | - <button type="button" class="runner-step" data-step="1" aria-label=(s(lang, "More", "Artır"))>"+"</button> |
| 300 | 440 | </div> |
| 301 | | - } else if r.is_number { |
| 302 | | - <input type="number" name=(r.key) value=(r.value.as_str()) min=(r.min.as_str()) max=(r.max.as_str()) aria-label=(r.label)> |
| 303 | | - } else if r.is_secret { |
| 304 | | - <input type="password" name=(r.key) autocomplete="new-password" maxlength="1024" aria-label=(r.label)> |
| 305 | | - } else if r.fixed { |
| 306 | | - <code class="srv-fixed" title=(r.value.as_str())>(r.value.as_str())</code> |
| 307 | 441 | } else { |
| 308 | | - <input type="text" name=(r.key) value=(r.value.as_str()) maxlength="1024" autocomplete="off" aria-label=(r.label)> |
| 309 | | - } |
| 310 | | - if r.has_override { |
| 311 | | - <button type="submit" form="srv-reset" name="key" value=(r.key)>(g::t(lang, K::SrvResetToFile))</button> |
| 442 | + for r in block.iter() { |
| 443 | + srv_row(lang: lang, row: r) |
| 444 | + } |
| 312 | 445 | } |
| 313 | | - </div> |
| 314 | | - </div> |
| 315 | | - } |
| 316 | | - if any_editable { |
| 317 | | - <div class="row-foot"> |
| 318 | | - <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> |
| 319 | | - </div> |
| 320 | | - } |
| 321 | | - </form> |
| 446 | + } |
| 447 | + if any_editable { |
| 448 | + <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> |
| 449 | + } |
| 450 | + </form> |
| 451 | + </section> |
| 452 | + } |
| 322 | 453 | <form id="srv-reset" method="post" action="/admin/server/reset"> |
| 323 | 454 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 324 | 455 | <input type="hidden" name="tab" value=(tab)> |
| 325 | 456 | </form> |
| 326 | | - </section> |
| 327 | | - <section class="card rows-pane"> |
| 328 | | - <div class="row-line"> |
| 329 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.3-5.7"/><path d="M20 4v5h-5"/></svg> |
| 330 | | - <div class="row-main"> |
| 331 | | - <h2 class="row-title">(s(lang, "Restart server", "Sunucuyu yeniden başlat"))</h2> |
| 332 | | - <p class="row-status">(s(lang, "Stops gracefully and starts again, so a newly installed binary and every setting marked restart needed take effect. Needs a supervisor such as systemd to start it again.", "Düzgünce durdurup yeniden başlatır; böylece yeni kurulan ikili ve \"yeniden başlatma gerekli\" işaretli her ayar devreye girer. Yeniden başlatmak için systemd gibi bir gözetmen gerekir."))</p> |
| 333 | | - if restart == Restart::Pending { |
| 334 | | - <p class="row-status">(s(lang, "A restart is in progress.", "Yeniden başlatma sürüyor."))</p> |
| 335 | | - } |
| 336 | | - </div> |
| 457 | + <section class="sec"> |
| 458 | + <h2>(s(lang, "Restart server", "Sunucuyu yeniden başlat"))</h2> |
| 459 | + <p class="hint">(s(lang, "Stops gracefully and starts again, so a newly installed binary and every setting marked restart needed take effect. Needs a supervisor such as systemd to start it again.", "Düzgünce durdurup yeniden başlatır; böylece yeni kurulan ikili ve \"yeniden başlatma gerekli\" işaretli her ayar devreye girer. Yeniden başlatmak için systemd gibi bir gözetmen gerekir."))</p> |
| 460 | + if restart == Restart::Pending { |
| 461 | + <p class="state">(s(lang, "A restart is in progress.", "Yeniden başlatma sürüyor."))</p> |
| 462 | + } |
| 337 | 463 | if restart != Restart::Pending { |
| 338 | | - <details class="row-action danger"> |
| 339 | | - <summary>(s(lang, "Restart server", "Sunucuyu yeniden başlat"))</summary> |
| 340 | | - <div class="row-panel"> |
| 341 | | - <p>(s(lang, "Restart the server now? Requests in flight finish first, and the site is unavailable for a few seconds.", "Sunucu şimdi yeniden başlatılsın mı? Süren istekler önce biter, site birkaç saniye kullanılamaz."))</p> |
| 342 | | - <form method="post" action="/admin/server/restart"> |
| 343 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 344 | | - <input type="hidden" name="tab" value=(tab)> |
| 345 | | - <button type="submit" class="danger">(s(lang, "Yes, restart", "Evet, yeniden başlat"))</button> |
| 346 | | - <button type="button" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> |
| 347 | | - </form> |
| 348 | | - </div> |
| 349 | | - </details> |
| 464 | + <div class="acts"> |
| 465 | + confirm_act(lang: lang, label: s(lang, "Restart server", "Sunucuyu yeniden başlat"), action: "/admin/server/restart", csrf: csrf.as_str(), fields: vec![("tab".to_owned(), tab.to_owned())], note: Some(s(lang, "Restart the server now? Requests in flight finish first, and the site is unavailable for a few seconds.", "Sunucu şimdi yeniden başlatılsın mı? Süren istekler önce biter, site birkaç saniye kullanılamaz.").to_owned())) |
| 466 | + </div> |
| 350 | 467 | } |
| 351 | | - </div> |
| 352 | | - </section> |
| 468 | + </section> |
| 353 | 469 | </div> |
| 354 | 470 | }) |
| 355 | 471 | } |
| | @@ -361,15 +477,22 @@ async fn server_page(cx: &Cx) -> Result<impl View> { |
| 361 | 477 | let state = app_context::<AppState>(cx); |
| 362 | 478 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 363 | 479 | let group = query |
| 364 | | - .tab |
| 480 | + .cat |
| 365 | 481 | .as_deref() |
| 482 | + .or(query.tab.as_deref()) |
| 366 | 483 | .and_then(Group::parse) |
| 367 | 484 | .unwrap_or(Group::General); |
| 368 | | - let rows = rows_for(state, lang, group).await?; |
| 485 | + let q = query.q.clone().unwrap_or_default(); |
| 486 | + let needle = q.trim().to_lowercase(); |
| 487 | + let (rows, search) = if needle.is_empty() { |
| 488 | + (rows_for(state, lang, group).await?, None) |
| 489 | + } else { |
| 490 | + (Vec::new(), Some(search_hits(state, lang, &needle).await?)) |
| 491 | + }; |
| 369 | 492 | let csrf = viewer.1.csrf_token.clone(); |
| 370 | 493 | let title = g::t(lang, K::ServerSettings); |
| 371 | 494 | Ok(view! { |
| 372 | | - shell(title: title, viewer: Some(&viewer), server_view(lang: lang, csrf: csrf, group: group, rows: rows, notice: query.notice.clone(), restart: restart_state(query.restarting.as_deref()))) |
| 495 | + shell(title: title, viewer: Some(&viewer), server_view(lang: lang, csrf: csrf, group: group, rows: rows, q: q, search: search, notice: query.notice.clone(), restart: restart_state(query.restarting.as_deref()))) |
| 373 | 496 | }) |
| 374 | 497 | } |
| 375 | 498 | |
| | @@ -402,7 +525,7 @@ async fn server_save(cx: &Cx, Form(mut form): Form<HashMap<String, String>>) -> |
| 402 | 525 | Err(other) => other.to_string(), |
| 403 | 526 | }; |
| 404 | 527 | Err(see_other(format!( |
| 405 | | - "/admin/server?tab={}¬ice={}", |
| 528 | + "/admin/server?cat={}¬ice={}", |
| 406 | 529 | group.slug(), |
| 407 | 530 | enc(¬ice) |
| 408 | 531 | )) |
| | @@ -485,7 +608,7 @@ async fn server_restart(cx: &Cx, Form(form): Form<RestartForm>) -> Result<Respon |
| 485 | 608 | self_update::request_restart(); |
| 486 | 609 | }); |
| 487 | 610 | Err(see_other(format!( |
| 488 | | - "/admin/server?tab={}&restarting={}", |
| 611 | + "/admin/server?cat={}&restarting={}", |
| 489 | 612 | group.slug(), |
| 490 | 613 | enc(self_update::boot_id()) |
| 491 | 614 | )) |
| | @@ -540,7 +663,7 @@ async fn server_reset(cx: &Cx, Form(form): Form<ResetForm>) -> Result<Response> |
| 540 | 663 | Err(other) => other.to_string(), |
| 541 | 664 | }; |
| 542 | 665 | Err(see_other(format!( |
| 543 | | - "/admin/server?tab={}¬ice={}", |
| 666 | + "/admin/server?cat={}¬ice={}", |
| 544 | 667 | group.slug(), |
| 545 | 668 | enc(¬ice) |
| 546 | 669 | )) |
| | @@ -1,6 +1,7 @@ |
| 1 | 1 | //! Page: one account for admins (`/admin/users/{id}`). Facts, suspend or lift, admin flag, a |
| 2 | 2 | //! one-time password reset link and disabling two-factor for a locked-out user. Every action is |
| 3 | | -//! audited. Non-admins get 404, like the rest of the admin area. |
| 3 | +//! audited. An organization opens here too, with its members and a delete. Non-admins get 404, |
| 4 | +//! like the rest of the admin area. |
| 4 | 5 | |
| 5 | 6 | use forge_core::names::normalize_name; |
| 6 | 7 | use forge_core::store::suspension::{AccountFacts, Suspension}; |
| | @@ -19,14 +20,14 @@ use crate::audit::{self, Actor, Target}; |
| 19 | 20 | use crate::auth::{check_csrf, two_factor_enabled}; |
| 20 | 21 | use crate::i18n::accounts::{A, t as at}; |
| 21 | 22 | use crate::i18n::admin::{self as g, K}; |
| 23 | +use crate::i18n::orgs::{self as og, K as OG}; |
| 22 | 24 | use crate::i18n::{self, Key, Lang}; |
| 23 | 25 | use crate::live::{Topic, stream_changes}; |
| 24 | 26 | use crate::pages::admin_users::admin_only; |
| 25 | 27 | use crate::pages::passkeys::s; |
| 26 | 28 | use crate::state::AppState; |
| 27 | | -use crate::views::{ |
| 28 | | - alert, avatar_url, enc, rel_time, rel_time_or_never, shell, user_facing_message, |
| 29 | | -}; |
| 29 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 30 | +use crate::views::{alert, enc, rel_time, rel_time_or_never, shell, user_facing_message}; |
| 30 | 31 | |
| 31 | 32 | #[query_params(error = bad_request)] |
| 32 | 33 | pub(crate) struct DoneQuery { |
| | @@ -134,11 +135,6 @@ async fn detail_body( |
| 134 | 135 | } else { |
| 135 | 136 | at(lang, A::Active) |
| 136 | 137 | }; |
| 137 | | - let dot_class = if suspended { |
| 138 | | - "user-dot is-suspended" |
| 139 | | - } else { |
| 140 | | - "user-dot is-active" |
| 141 | | - }; |
| 142 | 138 | let tfa_on = facts.two_factor; |
| 143 | 139 | let tfa = if tfa_on { |
| 144 | 140 | at(lang, A::On) |
| | @@ -146,12 +142,16 @@ async fn detail_body( |
| 146 | 142 | at(lang, A::Off) |
| 147 | 143 | }; |
| 148 | 144 | let is_admin = target.is_admin; |
| 145 | + let role = if is_admin { |
| 146 | + at(lang, A::Administrator) |
| 147 | + } else { |
| 148 | + g::t(lang, K::RoleUser) |
| 149 | + }; |
| 149 | 150 | let suspended_note = match suspension.as_ref().map(|s| s.reason.clone()) { |
| 150 | 151 | Some(reason) if !reason.is_empty() => reason, |
| 151 | 152 | _ => at(lang, A::AccountSuspended).to_owned(), |
| 152 | 153 | }; |
| 153 | 154 | let email = target.email.clone().unwrap_or_default(); |
| 154 | | - let avatar = avatar_url(&target.username, target.avatar_hash.as_deref()); |
| 155 | 155 | let suspend_action = format!("{base}/suspend"); |
| 156 | 156 | let unsuspend_action = format!("{base}/unsuspend"); |
| 157 | 157 | let admin_action = format!("{base}/admin"); |
| | @@ -161,176 +161,176 @@ async fn detail_body( |
| 161 | 161 | let passkey_count = passkeys.to_string(); |
| 162 | 162 | let delete_href = format!("{base}/delete"); |
| 163 | 163 | let live = format!("{base}/events"); |
| 164 | + let profile = format!("/{}", enc(&target.username)); |
| 165 | + let access_state = format!("{status} · {role}"); |
| 166 | + let admin_help = s( |
| 167 | + lang, |
| 168 | + "Opens the admin area: accounts, runners and server settings.", |
| 169 | + "Yönetim alanını açar: hesaplar, çalıştırıcılar ve sunucu ayarları.", |
| 170 | + ); |
| 171 | + let passkeys_help = s( |
| 172 | + lang, |
| 173 | + "For a user who lost their devices. They can still sign in with a password.", |
| 174 | + "Cihazlarını kaybeden kullanıcı için. Parolayla girmeye devam edebilir.", |
| 175 | + ); |
| 176 | + let reset_note = s( |
| 177 | + lang, |
| 178 | + "Their sessions end at once.", |
| 179 | + "Oturumları hemen sonlanır.", |
| 180 | + ); |
| 181 | + let passkeys_question = s( |
| 182 | + lang, |
| 183 | + "Remove every passkey of this user?", |
| 184 | + "Bu kullanıcının tüm geçiş anahtarları kaldırılsın mı?", |
| 185 | + ); |
| 186 | + let profile_label = s(lang, "Open profile", "Profili aç"); |
| 187 | + let access_title = s(lang, "Access", "Erişim"); |
| 188 | + let recovery_title = s(lang, "Recovery", "Kurtarma"); |
| 189 | + let passkeys_label = s(lang, "Passkeys", "Geçiş anahtarları"); |
| 190 | + let remove_label = s(lang, "Remove all", "Hepsini kaldır"); |
| 191 | + let suspend_title = at(lang, A::Suspend); |
| 164 | 192 | let Notice { done, error, link } = notice; |
| 193 | + let recovery_state = format!( |
| 194 | + "{}: {} · {}: {}", |
| 195 | + at(lang, A::TwoFactor), |
| 196 | + tfa, |
| 197 | + passkeys_label, |
| 198 | + passkey_count |
| 199 | + ); |
| 165 | 200 | Ok(view! { |
| 166 | | - <div data-live=(live.as_str()) class="user-page"> |
| 167 | | - <section class="user-head"> |
| 168 | | - <a class="user-back small" href="/admin/users">"← "(g::t(lang, K::Users))</a> |
| 169 | | - <div class="user-id"> |
| 170 | | - <img class="avatar user-avatar" src=(avatar.as_str()) alt="" width="56" height="56"> |
| 171 | | - <div class="user-id-text"> |
| 172 | | - <h1 class="user-name"> |
| 173 | | - <span class=(dot_class) role="img" aria-label=(status) title=(status)></span> |
| 174 | | - (target.username.as_str()) |
| 175 | | - if suspended { |
| 176 | | - <span class="user-off">(at(lang, A::Suspended))</span> |
| 177 | | - } |
| 178 | | - if is_admin { |
| 179 | | - <span class="badge user-role">(at(lang, A::Administrator))</span> |
| 180 | | - } |
| 181 | | - </h1> |
| 182 | | - <p class="user-meta muted small"> |
| 183 | | - if !email.is_empty() { |
| 184 | | - (email.as_str()) " · " |
| 185 | | - } |
| 186 | | - (at(lang, A::Joined)) " " rel_time(lang: lang, stamp: target.created_at.as_str()) " · " (at(lang, A::LastLogin)) " " rel_time_or_never(lang: lang, stamp: last_login.as_deref()) |
| 187 | | - </p> |
| 188 | | - </div> |
| 189 | | - </div> |
| 190 | | - <dl class="user-stats"> |
| 191 | | - <div><dt>(at(lang, A::Repositories))</dt><dd>(repos.as_str())</dd></div> |
| 192 | | - <div><dt>(at(lang, A::TwoFactor))</dt><dd>(tfa)</dd></div> |
| 193 | | - <div><dt>(s(lang, "Passkeys", "Geçiş anahtarları"))</dt><dd>(passkey_count.as_str())</dd></div> |
| 194 | | - </dl> |
| 195 | | - </section> |
| 201 | + <div data-live=(live.as_str())> |
| 202 | + <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 203 | + <h1 class="h1">(target.username.as_str())</h1> |
| 204 | + <p class="hint"> |
| 205 | + if !email.is_empty() { |
| 206 | + (email.as_str()) " · " |
| 207 | + } |
| 208 | + (at(lang, A::Joined)) " " rel_time(lang: lang, stamp: target.created_at.as_str()) " · " (at(lang, A::LastLogin)) " " rel_time_or_never(lang: lang, stamp: last_login.as_deref()) " · " (at(lang, A::Repositories)) " " (repos.as_str()) |
| 209 | + </p> |
| 196 | 210 | if let Some(message) = done { |
| 197 | | - <section class="card notice" role="status"> |
| 198 | | - <p>(message)</p> |
| 199 | | - </section> |
| 211 | + <p class="state" role="status">(message)</p> |
| 200 | 212 | } |
| 201 | 213 | if let Some(message) = error { |
| 202 | 214 | alert(message: message.as_str()) |
| 203 | 215 | } |
| 204 | | - <section class="card rows-pane"> |
| 216 | + <section class="sec"> |
| 217 | + <h2>(access_title)</h2> |
| 218 | + <p class="state">(access_state.as_str())</p> |
| 219 | + <div class="acts"> |
| 220 | + <a class="act" href=(profile.as_str())>(profile_label)</a> |
| 221 | + </div> |
| 205 | 222 | if suspended { |
| 206 | | - <div class="row-line"> |
| 207 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0"/></svg> |
| 208 | | - <div class="row-main"> |
| 209 | | - <h2 class="row-title">(at(lang, A::Unsuspend))</h2> |
| 210 | | - <p class="row-status">(suspended_note.as_str())</p> |
| 211 | | - </div> |
| 212 | | - <form method="post" action=(unsuspend_action.as_str()) class="row-form"> |
| 213 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 214 | | - <button type="submit">(at(lang, A::Unsuspend))</button> |
| 215 | | - </form> |
| 216 | | - </div> |
| 217 | | - } |
| 218 | | - <div class="row-line"> |
| 219 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l8 3v6c0 4.5-3.4 8.3-8 9-4.6-.7-8-4.5-8-9V6z"/><path d="M9 12l2 2 4-4"/></svg> |
| 220 | | - <div class="row-main"> |
| 221 | | - <h2 class="row-title">(at(lang, A::Administrator))</h2> |
| 222 | | - <p class="row-status">(s(lang, "Opens the admin area: accounts, runners and server settings.", "Yönetim alanını açar: hesaplar, çalıştırıcılar ve sunucu ayarları."))</p> |
| 223 | | - if last_admin { |
| 224 | | - <p class="row-status">(at(lang, A::AdminHelp))</p> |
| 225 | | - } |
| 223 | + <p class="hint">(suspended_note.as_str())</p> |
| 224 | + <div class="acts"> |
| 225 | + post_act(label: at(lang, A::Unsuspend), action: unsuspend_action.as_str(), csrf: csrf) |
| 226 | 226 | </div> |
| 227 | | - if !last_admin { |
| 228 | | - <form method="post" action=(admin_action.as_str()) class="row-form"> |
| 229 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 230 | | - <input type="hidden" name="admin" value=(if is_admin { "0" } else { "1" })> |
| 231 | | - <button type="submit">(if is_admin { at(lang, A::RevokeAdmin) } else { at(lang, A::GrantAdmin) })</button> |
| 232 | | - </form> |
| 227 | + } else { |
| 228 | + <p class="hint">(at(lang, A::SuspendHelp))</p> |
| 229 | + if own { |
| 230 | + <p class="hint">(at(lang, A::ErrSelf))</p> |
| 233 | 231 | } |
| 234 | | - </div> |
| 235 | | - <div class="row-line"> |
| 236 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></svg> |
| 237 | | - <div class="row-main"> |
| 238 | | - <h2 class="row-title">(at(lang, A::ResetPassword))</h2> |
| 239 | | - <p class="row-status">(at(lang, A::ResetHelp))</p> |
| 240 | | - if let Some(link) = link { |
| 241 | | - <p class="row-status">(at(lang, A::ResetLinkReady))</p> |
| 242 | | - <code class="reset-link">(link.as_str())</code> |
| 243 | | - } |
| 244 | | - </div> |
| 245 | | - <form method="post" action=(reset_action.as_str()) class="row-form"> |
| 246 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 247 | | - <button type="submit">(at(lang, A::GenerateLink))</button> |
| 248 | | - </form> |
| 249 | | - </div> |
| 250 | | - </section> |
| 251 | | - <section class="card rows-pane security-danger"> |
| 252 | | - <p class="security-danger-label">(i18n::t(lang, Key::DangerZone))</p> |
| 253 | | - if !suspended { |
| 254 | | - <div class="row-line"> |
| 255 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M10 9v6M14 9v6"/></svg> |
| 256 | | - <div class="row-main"> |
| 257 | | - <h2 class="row-title">(at(lang, A::Suspend))</h2> |
| 258 | | - <p class="row-status">(at(lang, A::SuspendHelp))</p> |
| 259 | | - if own { |
| 260 | | - <p class="row-status">(at(lang, A::ErrSelf))</p> |
| 261 | | - } |
| 232 | + if !own { |
| 233 | + <div class="acts"> |
| 234 | + reveal(label: suspend_title, id: Some("suspend"), open: false, |
| 235 | + <form method="post" action=(suspend_action.as_str()) class="fields"> |
| 236 | + <input type="hidden" name="csrf" value=(csrf)> |
| 237 | + <div class="field"> |
| 238 | + <label for="suspend-reason">(at(lang, A::SuspendReason))</label> |
| 239 | + <input id="suspend-reason" type="text" name="reason" maxlength="300" autocomplete="off"> |
| 240 | + </div> |
| 241 | + <div class="acts"> |
| 242 | + <button type="submit" class="act danger">(suspend_title)</button> |
| 243 | + </div> |
| 244 | + </form> |
| 245 | + ) |
| 262 | 246 | </div> |
| 263 | | - if !own { |
| 264 | | - <details class="row-action danger"> |
| 265 | | - <summary>(at(lang, A::Suspend))</summary> |
| 266 | | - <div class="row-panel"> |
| 267 | | - <form method="post" action=(suspend_action.as_str()) class="stack"> |
| 268 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 269 | | - <label> |
| 270 | | - <span>(at(lang, A::SuspendReason))</span> |
| 271 | | - <input type="text" name="reason" maxlength="300" autocomplete="off"> |
| 272 | | - </label> |
| 273 | | - <button type="submit" class="danger">(at(lang, A::Suspend))</button> |
| 274 | | - </form> |
| 275 | | - </div> |
| 276 | | - </details> |
| 277 | | - } |
| 247 | + } |
| 248 | + } |
| 249 | + <p class="hint">(admin_help)</p> |
| 250 | + if last_admin { |
| 251 | + <p class="hint">(at(lang, A::AdminHelp))</p> |
| 252 | + } |
| 253 | + if !last_admin && is_admin { |
| 254 | + <div class="acts"> |
| 255 | + confirm_act(lang: lang, label: at(lang, A::RevokeAdmin), action: admin_action.as_str(), csrf: csrf, fields: vec![("admin".to_owned(), "0".to_owned())]) |
| 278 | 256 | </div> |
| 279 | 257 | } |
| 280 | | - <div class="row-line"> |
| 281 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l8 3v6c0 4.5-3.4 8.3-8 9-4.6-.7-8-4.5-8-9V6z"/><path d="M9 9l6 6M15 9l-6 6"/></svg> |
| 282 | | - <div class="row-main"> |
| 283 | | - <h2 class="row-title">(at(lang, A::Disable2fa))</h2> |
| 284 | | - <p class="row-status">(at(lang, A::Disable2faHelp))</p> |
| 285 | | - if !tfa_on { |
| 286 | | - <p class="row-status">(at(lang, A::TwoFactorNotOn))</p> |
| 287 | | - } |
| 258 | + if !last_admin && !is_admin { |
| 259 | + <div class="acts"> |
| 260 | + post_act(label: at(lang, A::GrantAdmin), action: admin_action.as_str(), csrf: csrf, fields: vec![("admin".to_owned(), "1".to_owned())]) |
| 288 | 261 | </div> |
| 289 | | - if tfa_on { |
| 290 | | - <form method="post" action=(tfa_action.as_str()) class="row-form"> |
| 291 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 292 | | - <button type="submit" class="danger">(g::t(lang, K::Disable))</button> |
| 293 | | - </form> |
| 294 | | - } |
| 262 | + } |
| 263 | + </section> |
| 264 | + <section class="sec"> |
| 265 | + <h2>(recovery_title)</h2> |
| 266 | + <p class="state">(recovery_state.as_str())</p> |
| 267 | + <p class="hint">(at(lang, A::ResetHelp))</p> |
| 268 | + if let Some(link) = link { |
| 269 | + <p class="state">(at(lang, A::ResetLinkReady))</p> |
| 270 | + <code class="reset-link">(link.as_str())</code> |
| 271 | + } |
| 272 | + <div class="acts"> |
| 273 | + confirm_act(lang: lang, label: at(lang, A::GenerateLink), action: reset_action.as_str(), csrf: csrf, note: Some(reset_note.to_owned())) |
| 295 | 274 | </div> |
| 296 | | - <div class="row-line"> |
| 297 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="8" cy="15" r="4"/><path d="M11 12l9-9M17 6l3 3M14 9l3 3"/></svg> |
| 298 | | - <div class="row-main"> |
| 299 | | - <h2 class="row-title">(s(lang, "Remove all passkeys", "Tüm geçiş anahtarlarını kaldır"))</h2> |
| 300 | | - <p class="row-status">(s(lang, "For a user who lost their devices. They can still sign in with a password.", "Cihazlarını kaybeden kullanıcı için. Parolayla girmeye devam edebilir."))</p> |
| 301 | | - if passkeys == 0 { |
| 302 | | - <p class="row-status">(at(lang, A::NoPasskeysToRemove))</p> |
| 303 | | - } |
| 275 | + if tfa_on { |
| 276 | + <p class="hint">(at(lang, A::Disable2faHelp))</p> |
| 277 | + <div class="acts"> |
| 278 | + confirm_act(lang: lang, label: g::t(lang, K::Disable), action: tfa_action.as_str(), csrf: csrf) |
| 304 | 279 | </div> |
| 305 | | - if passkeys > 0 { |
| 306 | | - <details class="row-action danger"> |
| 307 | | - <summary>(s(lang, "Remove", "Kaldır"))</summary> |
| 308 | | - <div class="row-panel"> |
| 309 | | - <p>(s(lang, "Remove every passkey of this user?", "Bu kullanıcının tüm geçiş anahtarları kaldırılsın mı?"))</p> |
| 310 | | - <form method="post" action=(passkeys_action.as_str()) class="row-form"> |
| 311 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 312 | | - <button type="submit" class="danger">(s(lang, "Remove all", "Hepsini kaldır"))</button> |
| 313 | | - <button type="button" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> |
| 314 | | - </form> |
| 315 | | - </div> |
| 316 | | - </details> |
| 317 | | - } |
| 318 | | - </div> |
| 319 | | - if !own { |
| 320 | | - <div class="row-line"> |
| 321 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4l9 16H3z"/><path d="M12 10v4M12 17v.5"/></svg> |
| 322 | | - <div class="row-main"> |
| 323 | | - <h2 class="row-title">(g::t(lang, K::DeleteUser))</h2> |
| 324 | | - <p class="row-status">(at(lang, A::DeleteHelp))</p> |
| 325 | | - </div> |
| 326 | | - <a class="button danger" href=(delete_href.as_str())>(i18n::t(lang, Key::Delete))</a> |
| 280 | + } else { |
| 281 | + <p class="hint">(at(lang, A::TwoFactorNotOn))</p> |
| 282 | + } |
| 283 | + if passkeys > 0 { |
| 284 | + <p class="hint">(passkeys_help)</p> |
| 285 | + <div class="acts"> |
| 286 | + confirm_act(lang: lang, label: remove_label, action: passkeys_action.as_str(), csrf: csrf, note: Some(passkeys_question.to_owned())) |
| 327 | 287 | </div> |
| 288 | + } else { |
| 289 | + <p class="hint">(at(lang, A::NoPasskeysToRemove))</p> |
| 328 | 290 | } |
| 329 | 291 | </section> |
| 292 | + if !own { |
| 293 | + <section class="sec"> |
| 294 | + <h2>(i18n::t(lang, Key::Delete))</h2> |
| 295 | + <p class="hint">(at(lang, A::DeleteHelp))</p> |
| 296 | + <div class="acts"> |
| 297 | + <a class="act danger" href=(delete_href.as_str())>(i18n::t(lang, Key::Delete))</a> |
| 298 | + </div> |
| 299 | + </section> |
| 300 | + } |
| 330 | 301 | </div> |
| 331 | 302 | }) |
| 332 | 303 | } |
| 333 | 304 | |
| 305 | +/// An organization's page: its name, its member count, its profile, and its delete. An |
| 306 | +/// organization is not a person, so the delete goes through the same POST as a user's. |
| 307 | +#[component] |
| 308 | +async fn org_body(lang: Lang, csrf: &str, org: User, members: usize) -> Result<impl View> { |
| 309 | + let base = format!("/admin/users/{}", enc(&org.id)); |
| 310 | + let delete_action = format!("{base}/delete"); |
| 311 | + let profile = format!("/{}", enc(&org.username)); |
| 312 | + let members = members.to_string(); |
| 313 | + let access_title = s(lang, "Access", "Erişim"); |
| 314 | + let profile_label = s(lang, "Open profile", "Profili aç"); |
| 315 | + Ok(view! { |
| 316 | + <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 317 | + <h1 class="h1">(org.username.as_str())</h1> |
| 318 | + <p class="hint">(og::t(lang, OG::Members)) " " (members.as_str())</p> |
| 319 | + <section class="sec"> |
| 320 | + <h2>(access_title)</h2> |
| 321 | + <div class="acts"> |
| 322 | + <a class="act" href=(profile.as_str())>(profile_label)</a> |
| 323 | + </div> |
| 324 | + </section> |
| 325 | + <section class="sec"> |
| 326 | + <h2>(i18n::t(lang, Key::Delete))</h2> |
| 327 | + <div class="acts"> |
| 328 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteOrgTitle), action: delete_action.as_str(), csrf: csrf) |
| 329 | + </div> |
| 330 | + </section> |
| 331 | + }) |
| 332 | +} |
| 333 | + |
| 334 | 334 | /// What the page shows of one account, as one string. A missing or hidden account is a 404. |
| 335 | 335 | async fn account_fingerprint(store: &Store, user_id: &str) -> Result<String> { |
| 336 | 336 | let Some(target) = store.user_by_id(user_id).await? else { |
| | @@ -377,15 +377,34 @@ async fn detail_page(cx: &Cx) -> Result<impl View> { |
| 377 | 377 | let viewer = admin_only(cx).await?; |
| 378 | 378 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 379 | 379 | let query = query_params::<DoneQuery>(cx)?; |
| 380 | | - let detail = load(cx).await?; |
| 380 | + let store = &app_context::<AppState>(cx).store; |
| 381 | + let id = path_param_segment(cx, "user_id").to_owned(); |
| 382 | + let org = match store.user_by_id(&id).await? { |
| 383 | + Some(user) if user.is_org() => { |
| 384 | + let members = store.org_members(&user.id).await?.len(); |
| 385 | + Some((user, members)) |
| 386 | + } |
| 387 | + _ => None, |
| 388 | + }; |
| 389 | + let detail = if org.is_some() { |
| 390 | + None |
| 391 | + } else { |
| 392 | + Some(load(cx).await?) |
| 393 | + }; |
| 394 | + let title = org |
| 395 | + .as_ref() |
| 396 | + .map(|(user, _)| user.username.clone()) |
| 397 | + .or_else(|| detail.as_ref().map(|d| d.target.username.clone())) |
| 398 | + .unwrap_or_default(); |
| 381 | 399 | let notice = Notice { |
| 382 | 400 | done: query.done.as_deref().and_then(|d| done_text(lang, d)), |
| 383 | 401 | ..Notice::default() |
| 384 | 402 | }; |
| 385 | 403 | let csrf = viewer.1.csrf_token.clone(); |
| 386 | | - let title = detail.target.username.clone(); |
| 387 | 404 | Ok(view! { |
| 388 | | - shell(title: title.as_str(), viewer: Some(&viewer), detail_body(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), detail: detail, notice: notice)) |
| 405 | + shell(title: title.as_str(), viewer: Some(&viewer), |
| 406 | + if let Some((user, members)) = org { org_body(lang: lang, csrf: csrf.as_str(), org: user, members: members) } |
| 407 | + if let Some(detail) = detail { detail_body(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), detail: detail, notice: notice) }) |
| 389 | 408 | }) |
| 390 | 409 | } |
| 391 | 410 | |
| | @@ -1,4 +1,5 @@ |
| 1 | | -//! Page: admin user management (`/admin/users`). Non-admins get 404. |
| 1 | +//! Page: admin user management (`/admin/users`). Non-admins get 404. The list searches, filters |
| 2 | +//! by kind and pages 50 accounts at a time; every account opens its own page. |
| 2 | 3 | |
| 3 | 4 | use forge_core::names::{normalize_name, validate_username}; |
| 4 | 5 | use forge_core::store::orgs::OrgMemberRole; |
| | @@ -10,19 +11,27 @@ use topcoat::context::{Cx, app_context}; |
| 10 | 11 | use topcoat::router::content::Form; |
| 11 | 12 | use topcoat::router::error::{forbidden, not_found, see_other}; |
| 12 | 13 | use topcoat::router::response::Response; |
| 13 | | -use topcoat::router::{page, path_param_segment, route}; |
| 14 | +use topcoat::router::{page, path_param_segment, query_params, route}; |
| 14 | 15 | use topcoat::view::{View, component, view}; |
| 15 | 16 | |
| 16 | 17 | use crate::audit::{self, Actor, Target}; |
| 17 | 18 | use crate::auth::{check_csrf, current_user, hash_password_async}; |
| 18 | 19 | use crate::i18n::admin::{self as g, K}; |
| 20 | +use crate::i18n::orgs::{self as og, K as OG}; |
| 19 | 21 | use crate::i18n::{self, Key, Lang}; |
| 20 | 22 | use crate::live::{Topic, stream_changes}; |
| 23 | +use crate::pages::passkeys::s; |
| 21 | 24 | use crate::state::AppState; |
| 25 | +use crate::views::parts::reveal; |
| 26 | +use crate::views::repo_list::{pager, pager_links}; |
| 22 | 27 | use crate::views::{alert, enc, rel_time, shell, user_facing_message}; |
| 23 | 28 | |
| 24 | 29 | const MIN_PASSWORD_CHARS: usize = 12; |
| 25 | 30 | const MAX_PASSWORD_BYTES: usize = 1024; |
| 31 | +/// Accounts per page of the list. |
| 32 | +const PER_PAGE: u64 = 50; |
| 33 | +/// The longest search the list takes. |
| 34 | +const MAX_QUERY_CHARS: usize = 100; |
| 26 | 35 | |
| 27 | 36 | #[derive(Deserialize)] |
| 28 | 37 | struct CreateUserForm { |
| | @@ -47,6 +56,92 @@ struct DeleteForm { |
| 47 | 56 | confirm_username: String, |
| 48 | 57 | } |
| 49 | 58 | |
| 59 | +#[query_params(error = bad_request)] |
| 60 | +struct UsersQuery { |
| 61 | + q: Option<String>, |
| 62 | + kind: Option<String>, |
| 63 | + page: Option<String>, |
| 64 | +} |
| 65 | + |
| 66 | +/// The account kinds the list can show. |
| 67 | +#[derive(Clone, Copy, PartialEq, Eq)] |
| 68 | +enum Kind { |
| 69 | + All, |
| 70 | + People, |
| 71 | + Organizations, |
| 72 | +} |
| 73 | + |
| 74 | +impl Kind { |
| 75 | + /// Maps the `kind` query value; anything unknown means all accounts. |
| 76 | + fn parse(raw: Option<&str>) -> Kind { |
| 77 | + match raw { |
| 78 | + Some("people") => Kind::People, |
| 79 | + Some("organizations") => Kind::Organizations, |
| 80 | + _ => Kind::All, |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + fn key(self) -> &'static str { |
| 85 | + match self { |
| 86 | + Kind::All => "all", |
| 87 | + Kind::People => "people", |
| 88 | + Kind::Organizations => "organizations", |
| 89 | + } |
| 90 | + } |
| 91 | + |
| 92 | + fn keeps(self, user: &User) -> bool { |
| 93 | + match self { |
| 94 | + Kind::All => true, |
| 95 | + Kind::People => !user.is_org(), |
| 96 | + Kind::Organizations => user.is_org(), |
| 97 | + } |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +/// The search text, kind and page the query asks for, with the defaults filled in. |
| 102 | +fn listing_args(query: &UsersQuery) -> (String, Kind, u64) { |
| 103 | + let q: String = query |
| 104 | + .q |
| 105 | + .as_deref() |
| 106 | + .unwrap_or("") |
| 107 | + .trim() |
| 108 | + .chars() |
| 109 | + .take(MAX_QUERY_CHARS) |
| 110 | + .collect(); |
| 111 | + let kind = Kind::parse(query.kind.as_deref()); |
| 112 | + let page = query |
| 113 | + .page |
| 114 | + .as_deref() |
| 115 | + .and_then(|p| p.parse::<u64>().ok()) |
| 116 | + .unwrap_or(1) |
| 117 | + .max(1); |
| 118 | + (q, kind, page) |
| 119 | +} |
| 120 | + |
| 121 | +/// `/admin/users` with the search, the kind and the page. An empty search is left out. |
| 122 | +fn users_href(q: &str, kind: Kind, page: u64) -> String { |
| 123 | + let mut href = String::from("/admin/users?"); |
| 124 | + if !q.is_empty() { |
| 125 | + href.push_str("q="); |
| 126 | + href.push_str(&enc(q)); |
| 127 | + href.push('&'); |
| 128 | + } |
| 129 | + href.push_str(&format!("kind={}&page={page}", kind.key())); |
| 130 | + href |
| 131 | +} |
| 132 | + |
| 133 | +/// Whether the account's name or email holds the lowercase search text. An empty search holds all. |
| 134 | +fn matches_search(user: &User, needle: &str) -> bool { |
| 135 | + needle.is_empty() |
| 136 | + || user.username.to_lowercase().contains(needle) |
| 137 | + || user |
| 138 | + .email |
| 139 | + .as_deref() |
| 140 | + .unwrap_or("") |
| 141 | + .to_lowercase() |
| 142 | + .contains(needle) |
| 143 | +} |
| 144 | + |
| 50 | 145 | /// The ghost account is reserved and never shown as a deletable user. |
| 51 | 146 | fn is_ghost(user: &User) -> bool { |
| 52 | 147 | normalize_name(&user.username) == GHOST_USERNAME |
| | @@ -55,33 +150,20 @@ fn is_ghost(user: &User) -> bool { |
| 55 | 150 | /// One account row of the list, with the text and links it shows already decided. |
| 56 | 151 | struct UserRow { |
| 57 | 152 | href: String, |
| 58 | | - delete_href: String, |
| 59 | 153 | username: String, |
| 60 | | - /// Organizations and the ghost account have no detail page to link to. |
| 154 | + /// The ghost account has no detail page to link to. |
| 61 | 155 | linkable: bool, |
| 62 | | - /// Nobody deletes their own account here, and the ghost account is never deleted. |
| 63 | | - deletable: bool, |
| 64 | 156 | email: String, |
| 65 | 157 | role: String, |
| 66 | 158 | created_at: String, |
| 67 | 159 | } |
| 68 | 160 | |
| 69 | | -#[component] |
| 70 | | -async fn users_view( |
| 71 | | - lang: Lang, |
| 72 | | - csrf: &str, |
| 73 | | - viewer_id: &str, |
| 74 | | - users: Vec<User>, |
| 75 | | - error: Option<String>, |
| 76 | | -) -> Result<impl View> { |
| 77 | | - let rows: Vec<UserRow> = users |
| 78 | | - .iter() |
| 79 | | - .map(|user| UserRow { |
| 161 | +impl UserRow { |
| 162 | + fn new(lang: Lang, user: &User) -> UserRow { |
| 163 | + UserRow { |
| 80 | 164 | href: format!("/admin/users/{}", enc(&user.id)), |
| 81 | | - delete_href: format!("/admin/users/{}/delete", enc(&user.id)), |
| 82 | 165 | username: user.username.clone(), |
| 83 | | - linkable: !(user.is_org() || is_ghost(user)), |
| 84 | | - deletable: user.id != viewer_id && !is_ghost(user), |
| 166 | + linkable: !is_ghost(user), |
| 85 | 167 | email: user.email.clone().unwrap_or_default(), |
| 86 | 168 | role: if user.is_org() { |
| 87 | 169 | g::t(lang, K::RoleOrganization).to_owned() |
| | @@ -91,73 +173,120 @@ async fn users_view( |
| 91 | 173 | g::t(lang, K::RoleUser).to_owned() |
| 92 | 174 | }, |
| 93 | 175 | created_at: user.created_at.clone(), |
| 94 | | - }) |
| 176 | + } |
| 177 | + } |
| 178 | +} |
| 179 | + |
| 180 | +#[component] |
| 181 | +async fn users_view( |
| 182 | + lang: Lang, |
| 183 | + csrf: &str, |
| 184 | + users: Vec<User>, |
| 185 | + q: String, |
| 186 | + kind: Kind, |
| 187 | + page: u64, |
| 188 | + error: Option<String>, |
| 189 | +) -> Result<impl View> { |
| 190 | + let needle = q.to_lowercase(); |
| 191 | + let matching: Vec<User> = users |
| 192 | + .into_iter() |
| 193 | + .filter(|user| matches_search(user, &needle)) |
| 194 | + .collect(); |
| 195 | + let all_count = matching.len(); |
| 196 | + let org_count = matching.iter().filter(|user| user.is_org()).count(); |
| 197 | + let shown: Vec<&User> = matching.iter().filter(|user| kind.keeps(user)).collect(); |
| 198 | + let total = shown.len() as u64; |
| 199 | + let pages = total.div_ceil(PER_PAGE).max(1); |
| 200 | + let page = page.min(pages); |
| 201 | + let start = usize::try_from((page - 1) * PER_PAGE).unwrap_or(0); |
| 202 | + let rows: Vec<UserRow> = shown |
| 203 | + .into_iter() |
| 204 | + .skip(start) |
| 205 | + .take(PER_PAGE as usize) |
| 206 | + .map(|user| UserRow::new(lang, user)) |
| 95 | 207 | .collect(); |
| 208 | + let (links, prev, next) = pager_links(page, pages, |n| users_href(&q, kind, n)); |
| 209 | + let empty = rows.is_empty(); |
| 210 | + let open = error.is_some(); |
| 211 | + let search_label = s(lang, "Search users", "Kullanıcılarda ara"); |
| 212 | + let filter_label = s(lang, "Filter", "Filtre"); |
| 213 | + let all_label = format!("{} {}", s(lang, "All", "Tümü"), all_count); |
| 214 | + let people_label = format!( |
| 215 | + "{} {}", |
| 216 | + s(lang, "People", "Kişiler"), |
| 217 | + all_count - org_count |
| 218 | + ); |
| 219 | + let orgs_label = format!("{} {}", og::t(lang, OG::Organizations), org_count); |
| 220 | + let all_href = users_href(&q, Kind::All, 1); |
| 221 | + let people_href = users_href(&q, Kind::People, 1); |
| 222 | + let orgs_href = users_href(&q, Kind::Organizations, 1); |
| 96 | 223 | Ok(view! { |
| 97 | 224 | <div data-live="/admin/users/events"> |
| 98 | | - <section class="page-head"> |
| 99 | | - <h1>(g::t(lang, K::Users))</h1> |
| 100 | | - </section> |
| 101 | | - <section class="card rows-pane"> |
| 102 | | - <div class="row-line"> |
| 103 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 104 | | - <div class="row-main"> |
| 105 | | - <h2 class="row-title">(g::t(lang, K::CreateAUser))</h2> |
| 106 | | - </div> |
| 107 | | - <details class="row-action" open=(error.is_some())> |
| 108 | | - <summary>(g::t(lang, K::CreateUser))</summary> |
| 109 | | - <div class="row-panel"> |
| 110 | | - if let Some(message) = error { |
| 111 | | - alert(message: message.as_str()) |
| 112 | | - } |
| 113 | | - <form method="post" action="/admin/users" class="stack"> |
| 114 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 115 | | - <label> |
| 116 | | - <span>(i18n::t(lang, Key::Username))</span> |
| 117 | | - <input type="text" name="username" required=(true) autocomplete="off"> |
| 118 | | - </label> |
| 119 | | - <label> |
| 120 | | - <span>(i18n::t(lang, Key::EmailOptional))</span> |
| 121 | | - <input type="email" name="email" autocomplete="off"> |
| 122 | | - </label> |
| 123 | | - <label> |
| 124 | | - <span>(i18n::t(lang, Key::Password))</span> |
| 125 | | - <input type="password" name="password" required=(true) autocomplete="new-password"> |
| 126 | | - <small class="muted">(g::t(lang, K::AtLeast12Chars))</small> |
| 127 | | - </label> |
| 128 | | - <label class="inline"> |
| 129 | | - <input type="checkbox" name="is_admin" value="yes"> |
| 130 | | - <span>(g::t(lang, K::Administrator))</span> |
| 131 | | - </label> |
| 132 | | - <button type="submit" class="primary">(g::t(lang, K::CreateUser))</button> |
| 133 | | - </form> |
| 225 | + <h1 class="sr-only">(g::t(lang, K::Users))</h1> |
| 226 | + <form class="plain-search" method="get" action="/admin/users" role="search"> |
| 227 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> |
| 228 | + <label class="sr-only" for="user-search">(search_label)</label> |
| 229 | + <input id="user-search" type="search" name="q" value=(q.as_str()) placeholder=(search_label) data-live-search="" autocomplete="off"> |
| 230 | + <input type="hidden" name="kind" value=(kind.key())> |
| 231 | + </form> |
| 232 | + <nav class="sub" aria-label=(filter_label)> |
| 233 | + <a href=(all_href.as_str()) aria-current=((kind == Kind::All).then_some("page"))>(all_label.as_str())</a> |
| 234 | + <a href=(people_href.as_str()) aria-current=((kind == Kind::People).then_some("page"))>(people_label.as_str())</a> |
| 235 | + <a href=(orgs_href.as_str()) aria-current=((kind == Kind::Organizations).then_some("page"))>(orgs_label.as_str())</a> |
| 236 | + reveal(label: g::t(lang, K::CreateUser), id: Some("create-user"), open: open, |
| 237 | + if let Some(message) = error { |
| 238 | + alert(message: message.as_str()) |
| 239 | + } |
| 240 | + <form method="post" action="/admin/users" class="fields"> |
| 241 | + <input type="hidden" name="csrf" value=(csrf)> |
| 242 | + <div class="field"> |
| 243 | + <label for="new-username">(i18n::t(lang, Key::Username))</label> |
| 244 | + <input id="new-username" type="text" name="username" required=(true) autocomplete="off"> |
| 134 | 245 | </div> |
| 135 | | - </details> |
| 136 | | - </div> |
| 137 | | - for row in rows.into_iter() { |
| 138 | | - <div class="row-line"> |
| 139 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 3.6-7 8-7s8 3 8 7"/></svg> |
| 140 | | - <div class="row-main"> |
| 141 | | - <strong class="row-name"> |
| 142 | | - if row.linkable { |
| 143 | | - <a href=(row.href.as_str())>(row.username.as_str())</a> |
| 144 | | - } else { |
| 145 | | - (row.username.as_str()) |
| 146 | | - } |
| 147 | | - </strong> |
| 148 | | - <p class="row-status"> |
| 149 | | - if !row.email.is_empty() { |
| 150 | | - (row.email.as_str()) " · " |
| 151 | | - } |
| 152 | | - (row.role.as_str()) " · " rel_time(lang: lang, stamp: row.created_at.as_str()) |
| 153 | | - </p> |
| 246 | + <div class="field"> |
| 247 | + <label for="new-email">(i18n::t(lang, Key::EmailOptional))</label> |
| 248 | + <input id="new-email" type="email" name="email" autocomplete="off"> |
| 154 | 249 | </div> |
| 155 | | - if row.deletable { |
| 156 | | - <a class="button danger" href=(row.delete_href.as_str())>(i18n::t(lang, Key::Delete))</a> |
| 157 | | - } |
| 250 | + <div class="field"> |
| 251 | + <label for="new-password">(i18n::t(lang, Key::Password))</label> |
| 252 | + <input id="new-password" type="password" name="password" required=(true) autocomplete="new-password"> |
| 253 | + <p class="hint">(g::t(lang, K::AtLeast12Chars))</p> |
| 254 | + </div> |
| 255 | + <label class="switch"> |
| 256 | + <input type="checkbox" name="is_admin" value="yes"> |
| 257 | + <span>(g::t(lang, K::Administrator))</span> |
| 258 | + </label> |
| 259 | + <button type="submit" class="primary">(g::t(lang, K::CreateUser))</button> |
| 260 | + </form> |
| 261 | + ) |
| 262 | + </nav> |
| 263 | + if empty { |
| 264 | + <p class="state">(s(lang, "No account matches.", "Eşleşen hesap yok."))</p> |
| 265 | + } |
| 266 | + for row in rows.into_iter() { |
| 267 | + if row.linkable { |
| 268 | + <a class="line" href=(row.href.as_str()) data-kb-row=""> |
| 269 | + <span class="name">(row.username.as_str())</span> |
| 270 | + <span class="val"> |
| 271 | + if !row.email.is_empty() { |
| 272 | + (row.email.as_str()) " · " |
| 273 | + } |
| 274 | + (row.role.as_str()) " · " rel_time(lang: lang, stamp: row.created_at.as_str()) |
| 275 | + </span> |
| 276 | + </a> |
| 277 | + } else { |
| 278 | + <div class="line" data-kb-row=""> |
| 279 | + <span class="name">(row.username.as_str())</span> |
| 280 | + <span class="val"> |
| 281 | + if !row.email.is_empty() { |
| 282 | + (row.email.as_str()) " · " |
| 283 | + } |
| 284 | + (row.role.as_str()) " · " rel_time(lang: lang, stamp: row.created_at.as_str()) |
| 285 | + </span> |
| 158 | 286 | </div> |
| 159 | 287 | } |
| 160 | | - </section> |
| 288 | + } |
| 289 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 161 | 290 | </div> |
| 162 | 291 | }) |
| 163 | 292 | } |
| | @@ -198,11 +327,12 @@ async fn users_events(cx: &Cx) -> Result<Response> { |
| 198 | 327 | async fn users_page(cx: &Cx) -> Result<impl View> { |
| 199 | 328 | let viewer = admin_only(cx).await?; |
| 200 | 329 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 330 | + let (q, kind, page) = listing_args(query_params::<UsersQuery>(cx)?); |
| 201 | 331 | let users = app_context::<AppState>(cx).store.list_users().await?; |
| 202 | 332 | let csrf = viewer.1.csrf_token.clone(); |
| 203 | 333 | let title = g::t(lang, K::Users); |
| 204 | 334 | Ok(view! { |
| 205 | | - shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), users: users, error: None)) |
| 335 | + shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), users: users, q: q, kind: kind, page: page, error: None)) |
| 206 | 336 | }) |
| 207 | 337 | } |
| 208 | 338 | |
| | @@ -239,7 +369,7 @@ async fn users_create(cx: &Cx, Form(form): Form<CreateUserForm>) -> Result<impl |
| 239 | 369 | let csrf = viewer.1.csrf_token.clone(); |
| 240 | 370 | let title = g::t(lang, K::Users); |
| 241 | 371 | Ok(view! { |
| 242 | | - shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), users: users, error: Some(message))) |
| 372 | + shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), users: users, q: String::new(), kind: Kind::All, page: 1, error: Some(message))) |
| 243 | 373 | }) |
| 244 | 374 | } |
| 245 | 375 | } |
| | @@ -351,50 +481,50 @@ async fn delete_body( |
| 351 | 481 | let action = format!("/admin/users/{}/delete", enc(&target.id)); |
| 352 | 482 | let prompt = g::type_to_confirm(lang, &target.username); |
| 353 | 483 | Ok(view! { |
| 354 | | - <section class="page-head"> |
| 355 | | - <h1>(g::t(lang, K::DeleteUser))</h1> |
| 356 | | - </section> |
| 357 | | - <section class="card"> |
| 358 | | - if let Some(message) = error { |
| 359 | | - alert(message: message.as_str()) |
| 360 | | - } |
| 361 | | - if let Some(message) = refusal { |
| 362 | | - alert(message: message.as_str()) |
| 363 | | - } |
| 364 | | - <p>(g::t(lang, K::DeletesAccount))<strong>(target.username.as_str())</strong>(g::t(lang, K::DeleteAccountRest))</p> |
| 365 | | - if has_repos { |
| 366 | | - <p>(g::t(lang, K::TransferOrDeleteFirst))</p> |
| 367 | | - <ul class="item-list"> |
| 368 | | - for name in repos.into_iter() { |
| 369 | | - <li>(name)</li> |
| 370 | | - } |
| 371 | | - </ul> |
| 372 | | - } |
| 373 | | - if let Some(impact) = impact { |
| 484 | + <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 485 | + <h1 class="sr-only">(g::t(lang, K::DeleteUser))</h1> |
| 486 | + if let Some(message) = error { |
| 487 | + alert(message: message.as_str()) |
| 488 | + } |
| 489 | + if let Some(message) = refusal { |
| 490 | + alert(message: message.as_str()) |
| 491 | + } |
| 492 | + <p class="state">(g::t(lang, K::DeletesAccount))<strong>(target.username.as_str())</strong>(g::t(lang, K::DeleteAccountRest))</p> |
| 493 | + if has_repos { |
| 494 | + <p class="hint">(g::t(lang, K::TransferOrDeleteFirst))</p> |
| 495 | + <ul class="item-list"> |
| 496 | + for name in repos.into_iter() { |
| 497 | + <li>(name)</li> |
| 498 | + } |
| 499 | + </ul> |
| 500 | + } |
| 501 | + if let Some(impact) = impact { |
| 502 | + <section class="sec"> |
| 374 | 503 | <h2>(g::t(lang, K::WhatHappens))</h2> |
| 375 | | - <p>(g::t(lang, K::MovedToGhost))</p> |
| 504 | + <p class="hint">(g::t(lang, K::MovedToGhost))</p> |
| 376 | 505 | <ul class="item-list"> |
| 377 | 506 | for line in impact.moved.into_iter() { |
| 378 | 507 | <li>(line)</li> |
| 379 | 508 | } |
| 380 | 509 | </ul> |
| 381 | | - <p>(g::t(lang, K::RemovedWithAccount))</p> |
| 510 | + <p class="hint">(g::t(lang, K::RemovedWithAccount))</p> |
| 382 | 511 | <ul class="item-list"> |
| 383 | 512 | for line in impact.removed.into_iter() { |
| 384 | 513 | <li>(line)</li> |
| 385 | 514 | } |
| 386 | 515 | </ul> |
| 387 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 388 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 389 | | - <label> |
| 390 | | - <span>(prompt.as_str())</span> |
| 391 | | - <input type="text" name="confirm_username" autocomplete="off" required=(true)> |
| 392 | | - </label> |
| 393 | | - <button type="submit" class="danger">(g::t(lang, K::DeleteUser))</button> |
| 394 | | - </form> |
| 395 | | - } |
| 396 | | - <p><a href="/admin/users">(g::t(lang, K::BackToUsers))</a></p> |
| 397 | | - </section> |
| 516 | + </section> |
| 517 | + <form method="post" action=(action.as_str()) class="fields"> |
| 518 | + <input type="hidden" name="csrf" value=(csrf)> |
| 519 | + <div class="field"> |
| 520 | + <label for="confirm-username">(prompt.as_str())</label> |
| 521 | + <input id="confirm-username" type="text" name="confirm_username" autocomplete="off" required=(true)> |
| 522 | + </div> |
| 523 | + <div class="acts"> |
| 524 | + <button type="submit" class="act danger">(g::t(lang, K::DeleteUser))</button> |
| 525 | + </div> |
| 526 | + </form> |
| 527 | + } |
| 398 | 528 | }) |
| 399 | 529 | } |
| 400 | 530 | |
| | @@ -410,29 +540,24 @@ async fn org_delete_note( |
| 410 | 540 | let settings = format!("/org/{}/settings", enc(&target.username)); |
| 411 | 541 | let profile = format!("/{}", enc(&target.username)); |
| 412 | 542 | Ok(view! { |
| 413 | | - <section class="page-head"> |
| 414 | | - <h1>(g::t(lang, K::DeleteOrgTitle))</h1> |
| 415 | | - </section> |
| 416 | | - <section class="card"> |
| 417 | | - <p><strong>(target.username.as_str())</strong>(g::t(lang, K::OrgNotAUser))</p> |
| 418 | | - if has_repos { |
| 419 | | - <p>(g::t(lang, K::OrgReposFirst))</p> |
| 420 | | - <ul class="item-list"> |
| 421 | | - for name in repos.into_iter() { |
| 422 | | - <li>(name)</li> |
| 423 | | - } |
| 424 | | - </ul> |
| 425 | | - } |
| 426 | | - <p> |
| 427 | | - if is_owner { |
| 428 | | - <a href=(settings.as_str())>(g::t(lang, K::OpenOrgSettings))</a> |
| 429 | | - } else { |
| 430 | | - <a href=(profile.as_str())>(g::t(lang, K::ViewOrg))</a> |
| 543 | + <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 544 | + <h1 class="sr-only">(g::t(lang, K::DeleteOrgTitle))</h1> |
| 545 | + <p class="state"><strong>(target.username.as_str())</strong>(g::t(lang, K::OrgNotAUser))</p> |
| 546 | + if has_repos { |
| 547 | + <p class="hint">(g::t(lang, K::OrgReposFirst))</p> |
| 548 | + <ul class="item-list"> |
| 549 | + for name in repos.into_iter() { |
| 550 | + <li>(name)</li> |
| 431 | 551 | } |
| 432 | | - " · " |
| 433 | | - <a href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 434 | | - </p> |
| 435 | | - </section> |
| 552 | + </ul> |
| 553 | + } |
| 554 | + <div class="acts"> |
| 555 | + if is_owner { |
| 556 | + <a class="act" href=(settings.as_str())>(g::t(lang, K::OpenOrgSettings))</a> |
| 557 | + } else { |
| 558 | + <a class="act" href=(profile.as_str())>(g::t(lang, K::ViewOrg))</a> |
| 559 | + } |
| 560 | + </div> |
| 436 | 561 | }) |
| 437 | 562 | } |
| 438 | 563 | |
| | @@ -17,7 +17,7 @@ use crate::live::{Topic, stream_changes}; |
| 17 | 17 | use crate::pages::admin_users::admin_only; |
| 18 | 18 | use crate::pages::issues_list::list_href; |
| 19 | 19 | use crate::state::AppState; |
| 20 | | -use crate::views::{empty_state, rel_time, shell}; |
| 20 | +use crate::views::{rel_time, shell}; |
| 21 | 21 | |
| 22 | 22 | /// Entries per page of the admin audit log, under its filter bar. |
| 23 | 23 | const ADMIN_PAGE_SIZE: usize = 8; |
| | @@ -98,38 +98,26 @@ async fn fetch_page( |
| 98 | 98 | async fn audit_table(lang: Lang, rows: Vec<RowView>, show_actor: bool) -> Result<impl View> { |
| 99 | 99 | Ok(view! { |
| 100 | 100 | if rows.is_empty() { |
| 101 | | - empty_state(title: g::t(lang, K::NoEntries)) |
| 101 | + <p class="state">(g::t(lang, K::NoEntries))</p> |
| 102 | 102 | } else { |
| 103 | | - <div class="table-wrap"> |
| 104 | | - <table class="table audit-table queue-table"> |
| 105 | | - <thead> |
| 106 | | - <tr> |
| 107 | | - <th>(g::t(lang, K::TableWhen))</th> |
| 108 | | - if show_actor { |
| 109 | | - <th>(g::t(lang, K::TableActor))</th> |
| 110 | | - } |
| 111 | | - <th>(g::t(lang, K::ActionLabel))</th> |
| 112 | | - <th>(g::t(lang, K::TableTarget))</th> |
| 113 | | - <th>"IP"</th> |
| 114 | | - <th>(g::t(lang, K::TableDetails))</th> |
| 115 | | - </tr> |
| 116 | | - </thead> |
| 117 | | - <tbody> |
| 118 | | - for row in rows.into_iter() { |
| 119 | | - <tr> |
| 120 | | - <td class="small nowrap" data-label=(g::t(lang, K::TableWhen))>rel_time(lang: lang, stamp: row.when.as_str())</td> |
| 121 | | - if show_actor { |
| 122 | | - <td data-label=(g::t(lang, K::TableActor))>(row.actor.as_str())</td> |
| 123 | | - } |
| 124 | | - <td data-label=(g::t(lang, K::ActionLabel))><code>(row.action.as_str())</code></td> |
| 125 | | - <td data-label=(g::t(lang, K::TableTarget))>(row.target.as_str())</td> |
| 126 | | - <td class="small nowrap" data-label="IP">(row.ip.as_str())</td> |
| 127 | | - <td class="small" data-label=(g::t(lang, K::TableDetails))>(row.details.as_str())</td> |
| 128 | | - </tr> |
| 103 | + for row in rows.into_iter() { |
| 104 | + <div class="line" data-kb-row=""> |
| 105 | + <span class="name"><code>(row.action.as_str())</code></span> |
| 106 | + <span class="val"> |
| 107 | + rel_time(lang: lang, stamp: row.when.as_str()) |
| 108 | + if show_actor { |
| 109 | + " · " (row.actor.as_str()) |
| 129 | 110 | } |
| 130 | | - </tbody> |
| 131 | | - </table> |
| 132 | | - </div> |
| 111 | + " · " (row.target.as_str()) |
| 112 | + </span> |
| 113 | + </div> |
| 114 | + if !row.ip.is_empty() { |
| 115 | + <p class="hint">"IP " (row.ip.as_str())</p> |
| 116 | + } |
| 117 | + if !row.details.is_empty() { |
| 118 | + <p class="hint"><code>(row.details.as_str())</code></p> |
| 119 | + } |
| 120 | + } |
| 133 | 121 | } |
| 134 | 122 | }) |
| 135 | 123 | } |
| | @@ -146,14 +134,17 @@ async fn admin_audit_view( |
| 146 | 134 | ) -> Result<impl View> { |
| 147 | 135 | Ok(view! { |
| 148 | 136 | <div data-live=(live.as_str())> |
| 149 | | - <section class="page-head"> |
| 150 | | - <h1>(g::t(lang, K::AuditLog))</h1> |
| 151 | | - </section> |
| 152 | | - <p class="muted page-lede">(g::t(lang, K::AuditIntro))</p> |
| 153 | | - <section class="card"> |
| 154 | | - <form method="get" action="/admin/audit" class="filter-bar"> |
| 155 | | - <label class="filter-action"> |
| 156 | | - <span>(g::t(lang, K::ActionLabel))</span> |
| 137 | + <h1 class="sr-only">(g::t(lang, K::AuditLog))</h1> |
| 138 | + <p class="hint">(g::t(lang, K::AuditIntro))</p> |
| 139 | + <form method="get" action="/admin/audit"> |
| 140 | + <div class="plain-search"> |
| 141 | + <label class="sr-only" for="audit-actor">(g::t(lang, K::ActorUsername))</label> |
| 142 | + <input id="audit-actor" type="text" name="actor" value=(actor.as_str()) autocomplete="off"> |
| 143 | + <button type="submit" class="act">(g::t(lang, K::Filter))</button> |
| 144 | + </div> |
| 145 | + <div class="sub"> |
| 146 | + <label> |
| 147 | + (g::t(lang, K::ActionLabel)) " " |
| 157 | 148 | <select name="action" data-autosubmit="true"> |
| 158 | 149 | <option value="" selected=(action.is_empty())>(g::t(lang, K::AllActions))</option> |
| 159 | 150 | for known in AuditAction::ALL.iter().copied() { |
| | @@ -161,26 +152,17 @@ async fn admin_audit_view( |
| 161 | 152 | } |
| 162 | 153 | </select> |
| 163 | 154 | </label> |
| 164 | | - <label class="filter-actor"> |
| 165 | | - <span>(g::t(lang, K::ActorUsername))</span> |
| 166 | | - <input type="text" name="actor" value=(actor.as_str()) autocomplete="off"> |
| 167 | | - </label> |
| 168 | | - <button type="submit" class="primary">(g::t(lang, K::Filter))</button> |
| 169 | | - </form> |
| 170 | | - </section> |
| 155 | + </div> |
| 156 | + </form> |
| 171 | 157 | if let Some(message) = notice { |
| 172 | | - <section class="card notice" role="status"> |
| 173 | | - <p>(message.as_str())</p> |
| 174 | | - </section> |
| 158 | + <p class="state" role="status">(message.as_str())</p> |
| 159 | + } |
| 160 | + audit_table(lang: lang, rows: rows, show_actor: true) |
| 161 | + if let Some(href) = older_href { |
| 162 | + <nav class="sub"> |
| 163 | + <a href=(href.as_str())>(g::t(lang, K::Older))</a> |
| 164 | + </nav> |
| 175 | 165 | } |
| 176 | | - <section class="card fit-pane fit-list"> |
| 177 | | - audit_table(lang: lang, rows: rows, show_actor: true) |
| 178 | | - if let Some(href) = older_href { |
| 179 | | - <nav class="pager"> |
| 180 | | - <a href=(href.as_str())>(g::t(lang, K::Older))</a> |
| 181 | | - </nav> |
| 182 | | - } |
| 183 | | - </section> |
| 184 | 166 | </div> |
| 185 | 167 | }) |
| 186 | 168 | } |
| | @@ -192,18 +174,14 @@ async fn own_log_view( |
| 192 | 174 | older_href: Option<String>, |
| 193 | 175 | ) -> Result<impl View> { |
| 194 | 176 | Ok(view! { |
| 195 | | - <section class="page-head"> |
| 196 | | - <h1>(g::t(lang, K::SecurityLogTitle))</h1> |
| 197 | | - </section> |
| 198 | | - <p class="muted page-lede">(g::t(lang, K::OwnLogIntro))</p> |
| 199 | | - <section class="card fit-pane fit-list"> |
| 200 | | - audit_table(lang: lang, rows: rows, show_actor: false) |
| 201 | | - if let Some(href) = older_href { |
| 202 | | - <nav class="pager"> |
| 203 | | - <a href=(href.as_str())>(g::t(lang, K::Older))</a> |
| 204 | | - </nav> |
| 205 | | - } |
| 206 | | - </section> |
| 177 | + <h1 class="sr-only">(g::t(lang, K::SecurityLogTitle))</h1> |
| 178 | + <p class="hint">(g::t(lang, K::OwnLogIntro))</p> |
| 179 | + audit_table(lang: lang, rows: rows, show_actor: false) |
| 180 | + if let Some(href) = older_href { |
| 181 | + <nav class="sub"> |
| 182 | + <a href=(href.as_str())>(g::t(lang, K::Older))</a> |
| 183 | + </nav> |
| 184 | + } |
| 207 | 185 | }) |
| 208 | 186 | } |
| 209 | 187 | |
| | @@ -228,16 +228,16 @@ async fn blame_page(cx: &Cx) -> Result<impl View> { |
| 228 | 228 | <div class="browse-bar"> |
| 229 | 229 | breadcrumb(lang: lang, crumbs: crumbs) |
| 230 | 230 | </div> |
| 231 | | - <section class="file fit-pane" data-lines=""> |
| 231 | + <section class="file" data-lines=""> |
| 232 | 232 | <header class="file-head"> |
| 233 | | - <span class="muted small">(b::t(lang, b::K::BlameTitle)) " \u{b7} " (size)</span> |
| 234 | | - <nav class="file-actions" aria-label=(g::t(lang, K::FileNav))> |
| 235 | | - <a href=(blob_href.as_str())>(b::t(lang, b::K::BlameBackToFile))</a> |
| 236 | | - <a href=(history.as_str())>(g::t(lang, K::HistoryLink))</a> |
| 233 | + <span class="hint">(b::t(lang, b::K::BlameTitle)) " \u{b7} " (size)</span> |
| 234 | + <nav class="acts file-actions" aria-label=(g::t(lang, K::FileNav))> |
| 235 | + <a class="act" href=(blob_href.as_str())>(b::t(lang, b::K::BlameBackToFile))</a> |
| 236 | + <a class="act" href=(history.as_str())>(g::t(lang, K::HistoryLink))</a> |
| 237 | 237 | </nav> |
| 238 | 238 | </header> |
| 239 | 239 | if let Some(text) = message { |
| 240 | | - <p class="notice">(text)</p> |
| 240 | + <p class="state">(text)</p> |
| 241 | 241 | } |
| 242 | 242 | if has_rows { |
| 243 | 243 | blame_table(rows: rows, lang: lang) |
| | @@ -280,21 +280,21 @@ async fn blob_page(cx: &Cx) -> Result<impl View> { |
| 280 | 280 | breadcrumb(lang: lang, crumbs: crumbs) |
| 281 | 281 | file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) |
| 282 | 282 | </div> |
| 283 | | - <section class="file fit-pane" data-lines="" data-permalink=(permalink.as_str())> |
| 283 | + <section class="file" data-lines="" data-permalink=(permalink.as_str())> |
| 284 | 284 | <header class="file-head"> |
| 285 | | - <span class="muted small">(size)</span> |
| 286 | | - <nav class="file-actions" aria-label=(g::t(lang, K::FileNav))> |
| 285 | + <span class="hint">(size)</span> |
| 286 | + <nav class="acts file-actions" aria-label=(g::t(lang, K::FileNav))> |
| 287 | 287 | if let Some((label, href)) = toggle { |
| 288 | | - <a href=(href)>(label)</a> |
| 288 | + <a class="act" href=(href)>(label)</a> |
| 289 | 289 | } |
| 290 | 290 | if is_text { |
| 291 | | - <a href=(blame.as_str())>(b::t(lang, b::K::BlameLink))</a> |
| 292 | | - <button type="button" class="link-button" data-copy-permalink="" title=(b::t(lang, b::K::PermalinkHint)) |
| 291 | + <a class="act" href=(blame.as_str())>(b::t(lang, b::K::BlameLink))</a> |
| 292 | + <button type="button" class="act" data-copy-permalink="" title=(b::t(lang, b::K::PermalinkHint)) |
| 293 | 293 | data-copied=(b::t(lang, b::K::PermalinkCopied))>(b::t(lang, b::K::CopyPermalink))</button> |
| 294 | 294 | } |
| 295 | | - <a href=(history)>(g::t(lang, K::HistoryLink))</a> |
| 296 | | - <a href=(raw.clone())>(g::t(lang, K::RawLink))</a> |
| 297 | | - <a href=(download_href) download=(download_name)>(g::t(lang, K::DownloadLink))</a> |
| 295 | + <a class="act" href=(history)>(g::t(lang, K::HistoryLink))</a> |
| 296 | + <a class="act" href=(raw.clone())>(g::t(lang, K::RawLink))</a> |
| 297 | + <a class="act" href=(download_href) download=(download_name)>(g::t(lang, K::DownloadLink))</a> |
| 298 | 298 | </nav> |
| 299 | 299 | </header> |
| 300 | 300 | if kind == "image" { |
| | @@ -309,19 +309,19 @@ async fn blob_page(cx: &Cx) -> Result<impl View> { |
| 309 | 309 | file_table(lines: lines) |
| 310 | 310 | } |
| 311 | 311 | if kind == "lfs" { |
| 312 | | - <p class="notice">(note.clone())</p> |
| 312 | + <p class="state">(note.clone())</p> |
| 313 | 313 | } |
| 314 | 314 | if kind == "binary" { |
| 315 | | - <p class="notice">(note.clone())</p> |
| 315 | + <p class="state">(note.clone())</p> |
| 316 | 316 | } |
| 317 | 317 | if kind == "symlink" { |
| 318 | | - <p class="notice">(g::t(lang, K::SymlinkPrefix)) <code>(note.clone())</code></p> |
| 318 | + <p class="state">(g::t(lang, K::SymlinkPrefix)) <code>(note.clone())</code></p> |
| 319 | 319 | } |
| 320 | 320 | if kind == "submodule" { |
| 321 | | - <p class="notice">(g::t(lang, K::SubmodulePrefix)) <code>(note.clone())</code> (g::t(lang, K::SubmoduleSuffix))</p> |
| 321 | + <p class="state">(g::t(lang, K::SubmodulePrefix)) <code>(note.clone())</code> (g::t(lang, K::SubmoduleSuffix))</p> |
| 322 | 322 | } |
| 323 | 323 | if truncated { |
| 324 | | - <p class="notice">(g::t(lang, K::TruncatedPrefix)) |
| 324 | + <p class="hint">(g::t(lang, K::TruncatedPrefix)) |
| 325 | 325 | <a href=(raw)>(g::t(lang, K::ViewFullRaw))</a> "."</p> |
| 326 | 326 | } |
| 327 | 327 | </section> |
| | @@ -30,7 +30,8 @@ use crate::pages::tree::{LastCommit, last_commit_view}; |
| 30 | 30 | use crate::post_update::after_ref_update; |
| 31 | 31 | use crate::state::AppState; |
| 32 | 32 | use crate::views::commit_line::commit_line; |
| 33 | | -use crate::views::{alert, empty_state, iso_time, now_unix, relative_time, repo_href, shell}; |
| 33 | +use crate::views::parts::{confirm_act, reveal}; |
| 34 | +use crate::views::{alert, iso_time, now_unix, relative_time, repo_href, shell}; |
| 34 | 35 | |
| 35 | 36 | path_param!(owner); |
| 36 | 37 | path_param!(repo); |
| | @@ -97,7 +98,6 @@ struct BranchRow { |
| 97 | 98 | counts: Option<String>, |
| 98 | 99 | up_to_date: bool, |
| 99 | 100 | pr_href: Option<String>, |
| 100 | | - delete_label: String, |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | #[component] |
| | @@ -109,19 +109,18 @@ async fn new_branch_form( |
| 109 | 109 | options: Vec<String>, |
| 110 | 110 | ) -> Result<impl View> { |
| 111 | 111 | Ok(view! { |
| 112 | | - <details class="new-branch"> |
| 113 | | - <summary class="button">(b::t(lang, b::K::NewBranchTitle))</summary> |
| 114 | | - <form method="post" action=(action.as_str()) class="new-branch-form"> |
| 112 | + reveal(label: b::t(lang, b::K::NewBranchTitle), id: Some("new-branch"), |
| 113 | + <form method="post" action=(action.as_str()) class="fields"> |
| 115 | 114 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 116 | | - <label> |
| 117 | | - <span>(b::t(lang, b::K::BranchNameLabel))</span> |
| 118 | | - <input type="text" name="name" required=(true) autocomplete="off" spellcheck="false" maxlength="200"> |
| 119 | | - </label> |
| 120 | | - <label> |
| 121 | | - <span>(b::t(lang, b::K::BranchFromLabel))</span> |
| 122 | | - <input type="text" name="from" list="branch-sources" value=(default_branch.as_str()) |
| 115 | + <div class="field"> |
| 116 | + <label for="branch-name">(b::t(lang, b::K::BranchNameLabel))</label> |
| 117 | + <input id="branch-name" type="text" name="name" required=(true) autocomplete="off" spellcheck="false" maxlength="200"> |
| 118 | + </div> |
| 119 | + <div class="field"> |
| 120 | + <label for="branch-from">(b::t(lang, b::K::BranchFromLabel))</label> |
| 121 | + <input id="branch-from" type="text" name="from" list="branch-sources" value=(default_branch.as_str()) |
| 123 | 122 | placeholder=(b::t(lang, b::K::BranchFromPlaceholder)) autocomplete="off" spellcheck="false"> |
| 124 | | - </label> |
| 123 | + </div> |
| 125 | 124 | <datalist id="branch-sources"> |
| 126 | 125 | for option in options.iter() { |
| 127 | 126 | <option value=(option.as_str())></option> |
| | @@ -129,7 +128,7 @@ async fn new_branch_form( |
| 129 | 128 | </datalist> |
| 130 | 129 | <button type="submit" class="primary">(b::t(lang, b::K::CreateBranch))</button> |
| 131 | 130 | </form> |
| 132 | | - </details> |
| 131 | + ) |
| 133 | 132 | }) |
| 134 | 133 | } |
| 135 | 134 | |
| | @@ -142,68 +141,39 @@ async fn branch_table( |
| 142 | 141 | can_delete: bool, |
| 143 | 142 | ) -> Result<impl View> { |
| 144 | 143 | Ok(view! { |
| 145 | | - <div class="table-wrap"> |
| 146 | | - <table class="table refs-table branch-table"> |
| 147 | | - <thead> |
| 148 | | - <tr> |
| 149 | | - <th>(g::t(lang, K::BranchLabel))</th> |
| 150 | | - <th>(g::t(lang, K::LastCommitHeader))</th> |
| 151 | | - <th>(b::t(lang, b::K::BranchAuthorHeader))</th> |
| 152 | | - <th>(b::t(lang, b::K::BranchAheadBehindHeader))</th> |
| 153 | | - <th class="branch-actions-col">(b::t(lang, b::K::BranchActionsHeader))</th> |
| 154 | | - </tr> |
| 155 | | - </thead> |
| 156 | | - <tbody> |
| 157 | | - for row in rows.into_iter() { |
| 158 | | - <tr data-kb-row=""> |
| 159 | | - <td class="tree-name"> |
| 160 | | - <span class="tree-label"> |
| 161 | | - <a href=(row.href.as_str())>(row.name.as_str())</a> |
| 162 | | - if row.is_default { |
| 163 | | - <span class="badge public">(g::t(lang, K::DefaultBadge))</span> |
| 164 | | - } |
| 165 | | - </span> |
| 166 | | - </td> |
| 167 | | - if let Some(last) = row.last { |
| 168 | | - <td class="tree-commit"><a href=(last.href.as_str())>commit_line(subject: last.summary.clone())</a></td> |
| 169 | | - } else { |
| 170 | | - <td class="tree-commit"></td> |
| 144 | + <div> |
| 145 | + for row in rows.into_iter() { |
| 146 | + <details class="row-open" data-kb-row=""> |
| 147 | + <summary class="line"> |
| 148 | + <a class="name" href=(row.href.as_str())>(row.name.as_str())</a> |
| 149 | + if row.is_default { |
| 150 | + <span class="badge public">(g::t(lang, K::DefaultBadge))</span> |
| 151 | + } |
| 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)) |
| 171 | 157 | } |
| 172 | | - <td class="branch-author"> |
| 173 | | - <span>(row.author.as_str())</span> |
| 174 | | - <span class="muted small"><time data-rel="true" datetime=(row.iso.as_str())>(row.age.as_str())</time></span> |
| 175 | | - </td> |
| 176 | | - <td class="branch-counts"> |
| 177 | | - if let Some(counts) = row.counts { |
| 178 | | - <span class="small">(counts.as_str())</span> |
| 179 | | - } else if row.up_to_date { |
| 180 | | - <span class="muted small">(b::t(lang, b::K::UpToDate))</span> |
| 181 | | - } |
| 182 | | - </td> |
| 183 | | - <td class="branch-actions"> |
| 184 | | - if let Some(pr) = row.pr_href { |
| 185 | | - <a class="button small" href=(pr.as_str())>(b::t(lang, b::K::NewPr))</a> |
| 186 | | - } |
| 187 | | - if can_delete && !row.is_default { |
| 188 | | - <details class="confirm-inline"> |
| 189 | | - <summary class="button small danger" aria-label=(row.delete_label.as_str())>(b::t(lang, b::K::DeleteBranch))</summary> |
| 190 | | - <div class="confirm-pop"> |
| 191 | | - <p>(b::t(lang, b::K::DeleteConfirm))</p> |
| 192 | | - <form method="post" action=(delete_action.as_str())> |
| 193 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 194 | | - <input type="hidden" name="name" value=(row.name.as_str())> |
| 195 | | - <input type="hidden" name="oid" value=(row.oid.as_str())> |
| 196 | | - <button type="submit" class="danger">(b::t(lang, b::K::DeleteConfirmYes))</button> |
| 197 | | - <button type="button" data-close-details="">(b::t(lang, b::K::DeleteCancel))</button> |
| 198 | | - </form> |
| 199 | | - </div> |
| 200 | | - </details> |
| 201 | | - } |
| 202 | | - </td> |
| 203 | | - </tr> |
| 204 | | - } |
| 205 | | - </tbody> |
| 206 | | - </table> |
| 158 | + </span> |
| 159 | + </summary> |
| 160 | + <div class="opened"> |
| 161 | + if let Some(last) = row.last { |
| 162 | + <p class="state"><a href=(last.href.as_str())>commit_line(subject: last.summary.clone())</a></p> |
| 163 | + } |
| 164 | + <div class="acts"> |
| 165 | + if let Some(pr) = row.pr_href { |
| 166 | + <a class="act" href=(pr.as_str())>(b::t(lang, b::K::NewPr))</a> |
| 167 | + } |
| 168 | + 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(), |
| 170 | + 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())) |
| 172 | + } |
| 173 | + </div> |
| 174 | + </div> |
| 175 | + </details> |
| 176 | + } |
| 207 | 177 | </div> |
| 208 | 178 | }) |
| 209 | 179 | } |
| | @@ -280,7 +250,6 @@ async fn branches_page(cx: &Cx) -> Result<impl View> { |
| 280 | 250 | counts, |
| 281 | 251 | up_to_date, |
| 282 | 252 | pr_href, |
| 283 | | - delete_label: b::delete_aria(lang, &info.name), |
| 284 | 253 | name: info.name, |
| 285 | 254 | }); |
| 286 | 255 | } |
| | @@ -310,24 +279,20 @@ async fn branches_page(cx: &Cx) -> Result<impl View> { |
| 310 | 279 | if is_error { |
| 311 | 280 | alert(message: b::t(lang, key)) |
| 312 | 281 | } else { |
| 313 | | - <p class="notice" role="status">(b::t(lang, key))</p> |
| 282 | + <p class="state" role="status">(b::t(lang, key))</p> |
| 314 | 283 | } |
| 315 | 284 | } |
| 316 | | - <div class="lang-list fit-pane"> |
| 317 | | - <div class="list-bar"> |
| 318 | | - if can_write { |
| 319 | | - new_branch_form(lang: lang, action: action.clone(), csrf: csrf.clone(), |
| 320 | | - default_branch: default_branch, options: options) |
| 321 | | - } |
| 322 | | - </div> |
| 323 | | - <div class="list-scroll"> |
| 324 | | - if empty { |
| 325 | | - empty_state(title: g::t(lang, K::NothingHere)) |
| 326 | | - } else { |
| 327 | | - branch_table(rows: rows, lang: lang, csrf: csrf.clone(), delete_action: delete_action, can_delete: can_write) |
| 328 | | - } |
| 285 | + if can_write { |
| 286 | + <div class="acts"> |
| 287 | + new_branch_form(lang: lang, action: action.clone(), csrf: csrf.clone(), |
| 288 | + default_branch: default_branch, options: options) |
| 329 | 289 | </div> |
| 330 | | - </div> |
| 290 | + } |
| 291 | + if empty { |
| 292 | + <p class="state">(g::t(lang, K::NothingHere))</p> |
| 293 | + } else { |
| 294 | + branch_table(rows: rows, lang: lang, csrf: csrf.clone(), delete_action: delete_action, can_delete: can_write) |
| 295 | + } |
| 331 | 296 | ) |
| 332 | 297 | }) |
| 333 | 298 | } |
| | @@ -281,10 +281,11 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) { |
| 281 | 281 | assert!(html.contains("1 ahead, 54 behind"), "{html}"); |
| 282 | 282 | assert!(html.contains(&format!("/{OWNER}/{REPO}/compare/main...feature"))); |
| 283 | 283 | assert!(html.contains("tahinli")); |
| 284 | | - assert!(html.contains("confirm-inline")); |
| 284 | + let delete_form = format!("action=\"/{OWNER}/{REPO}/branches/delete\""); |
| 285 | + assert!(html.contains(&delete_form), "{html}"); |
| 285 | 286 | // Anonymous viewers get no create or delete controls. |
| 286 | 287 | let (_, _, anon) = send(&fx.router, "GET", &page, None, &[]).await; |
| 287 | | - assert!(!anon.contains("confirm-inline")); |
| 288 | + assert!(!anon.contains(&delete_form)); |
| 288 | 289 | assert!(!anon.contains("new-branch")); |
| 289 | 290 | |
| 290 | 291 | // Create from a ref. |
| | @@ -435,12 +435,20 @@ async fn job_body( |
| 435 | 435 | ) -> Result<impl View> { |
| 436 | 436 | Ok(view! { |
| 437 | 437 | repo_head(head: RepoHead { live: String::new(), ..head }) |
| 438 | | - <div data-live=(live.as_str()) data-live-state=(job.fingerprint.as_str()) class="ci-job fit-pane"> |
| 438 | + <div data-live=(live.as_str()) data-live-state=(job.fingerprint.as_str()) class="ci-job"> |
| 439 | 439 | <header class="ci-tl-head"> |
| 440 | 440 | <div class="ci-tl-headmain"> |
| 441 | 441 | <div class="ci-tl-line"> |
| 442 | 442 | <span class="ci-tl-no"><a href=(job.run_href.as_str())>(g::t(lang, K::RunNumber)) (job.run_number)</a></span> |
| 443 | 443 | <h2 class="ci-tl-title ci-job-title">(job.name.as_str())</h2> |
| 444 | + if let Some((action, csrf)) = job.rerun.as_ref() { |
| 445 | + <div class="acts ci-tl-actions"> |
| 446 | + <form method="post" action=(action.as_str()) class="act-form"> |
| 447 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 448 | + <button type="submit" class="act" data-palette-action="post">(g::t(lang, K::RerunJob))</button> |
| 449 | + </form> |
| 450 | + </div> |
| 451 | + } |
| 444 | 452 | </div> |
| 445 | 453 | <div class="ci-tl-meta"> |
| 446 | 454 | <span class=(job.state_class.as_str())>(job.state.as_str())</span> |
| | @@ -455,14 +463,6 @@ async fn job_body( |
| 455 | 463 | } |
| 456 | 464 | </div> |
| 457 | 465 | </div> |
| 458 | | - if let Some((action, csrf)) = job.rerun.as_ref() { |
| 459 | | - <div class="ci-actions ci-tl-actions"> |
| 460 | | - <form method="post" action=(action.as_str()) class="inline-form"> |
| 461 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 462 | | - <button type="submit" data-palette-action="post">(g::t(lang, K::RerunJob))</button> |
| 463 | | - </form> |
| 464 | | - </div> |
| 465 | | - } |
| 466 | 466 | </header> |
| 467 | 467 | <div class="ci-tl-main"> |
| 468 | 468 | <section class="ci-pane ci-tl-jobs"> |
| | @@ -498,13 +498,13 @@ async fn job_body( |
| 498 | 498 | <div class="ci-tl-tools"> |
| 499 | 499 | <input type="search" class="ci-logsearch" data-log-q="true" placeholder=(g::t(lang, K::LogSearch)) aria-label=(g::t(lang, K::LogSearch)) autocomplete="off" spellcheck="false"> |
| 500 | 500 | <span class="ci-logcount" data-log-count="true" data-none=(g::t(lang, K::LogNoMatches)) aria-live="polite"></span> |
| 501 | | - <button type="button" class="ci-mini" data-log-prev="true" aria-label=(g::t(lang, K::LogPrev)) title=(g::t(lang, K::LogPrev))>"\u{2191}"</button> |
| 502 | | - <button type="button" class="ci-mini" data-log-next="true" aria-label=(g::t(lang, K::LogNext)) title=(g::t(lang, K::LogNext))>"\u{2193}"</button> |
| 503 | | - <button type="button" class="ci-mini" data-copy-log=(job.log_href.as_str()) data-palette-action="click" data-copied=(g::t(lang, K::CopyDone)) data-failed=(g::t(lang, K::CopyFailed))>(g::t(lang, K::CopyLog))</button> |
| 504 | | - <a class="ci-mini" href=(job.log_href.as_str())>(g::t(lang, K::FullLog))</a> |
| 501 | + <button type="button" class="act" data-log-prev="true" aria-label=(g::t(lang, K::LogPrev)) title=(g::t(lang, K::LogPrev))>"\u{2191}"</button> |
| 502 | + <button type="button" class="act" data-log-next="true" aria-label=(g::t(lang, K::LogNext)) title=(g::t(lang, K::LogNext))>"\u{2193}"</button> |
| 503 | + <button type="button" class="act" data-copy-log=(job.log_href.as_str()) data-palette-action="click" data-copied=(g::t(lang, K::CopyDone)) data-failed=(g::t(lang, K::CopyFailed))>(g::t(lang, K::CopyLog))</button> |
| 504 | + <a class="act" href=(job.log_href.as_str())>(g::t(lang, K::FullLog))</a> |
| 505 | 505 | <span class="ci-logfold" data-log-fold-box="true" hidden="hidden"> |
| 506 | | - <button type="button" class="ci-mini" data-log-fold="close">(g::t(lang, K::LogCollapseAll))</button> |
| 507 | | - <button type="button" class="ci-mini" data-log-fold="open">(g::t(lang, K::LogExpandAll))</button> |
| 506 | + <button type="button" class="act" data-log-fold="close">(g::t(lang, K::LogCollapseAll))</button> |
| 507 | + <button type="button" class="act" data-log-fold="open">(g::t(lang, K::LogExpandAll))</button> |
| 508 | 508 | </span> |
| 509 | 509 | </div> |
| 510 | 510 | </div> |
| | @@ -39,6 +39,7 @@ use crate::i18n::{ |
| 39 | 39 | self, Lang, |
| 40 | 40 | releases_ci::{self as g, K}, |
| 41 | 41 | }; |
| 42 | +use crate::pages::admin_runners::confirm_post; |
| 42 | 43 | use crate::pages::ci_estimate::{self, Est, Step}; |
| 43 | 44 | use crate::pages::ci_fail::{self, FailFirst, fail_first_block}; |
| 44 | 45 | use crate::pages::ci_job::{Tail, log_from, log_tail_of}; |
| | @@ -1576,9 +1577,9 @@ async fn usernames( |
| 1576 | 1577 | #[component] |
| 1577 | 1578 | async fn action_button(action: String, csrf: String, label: &'static str) -> Result<impl View> { |
| 1578 | 1579 | Ok(view! { |
| 1579 | | - <form method="post" action=(action.as_str()) class="inline-form"> |
| 1580 | + <form method="post" action=(action.as_str()) class="act-form"> |
| 1580 | 1581 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1581 | | - <button type="submit" data-palette-action="post">(label)</button> |
| 1582 | + <button type="submit" class="act" data-palette-action="post">(label)</button> |
| 1582 | 1583 | </form> |
| 1583 | 1584 | }) |
| 1584 | 1585 | } |
| | @@ -2139,7 +2140,7 @@ async fn run_side(lang: Lang, list: ListView) -> Result<impl View> { |
| 2139 | 2140 | next_scheduled, |
| 2140 | 2141 | } = list; |
| 2141 | 2142 | Ok(view! { |
| 2142 | | - <section class="card ci-side"> |
| 2143 | + <section class="ci-side"> |
| 2143 | 2144 | <div class="ci-side-head"> |
| 2144 | 2145 | <h2 class="ci-side-title">(g::t(lang, K::Runs)) <span class="ci-count">(total)</span></h2> |
| 2145 | 2146 | <div class="ci-tools"> |
| | @@ -2206,7 +2207,7 @@ async fn run_side(lang: Lang, list: ListView) -> Result<impl View> { |
| 2206 | 2207 | if let Some((action, token)) = row.rerun.as_ref() { |
| 2207 | 2208 | <form method="post" action=(action.as_str()) class="ci-row-rerun-form" data-kb-rerun=""> |
| 2208 | 2209 | <input type="hidden" name="csrf" value=(token.as_str())> |
| 2209 | | - <button type="submit" class="ci-row-rerun">(g::t(lang, K::Rerun))</button> |
| 2210 | + <button type="submit" class="act ci-row-rerun">(g::t(lang, K::Rerun))</button> |
| 2210 | 2211 | </form> |
| 2211 | 2212 | } |
| 2212 | 2213 | </li> |
| | @@ -2246,10 +2247,10 @@ async fn runs_body( |
| 2246 | 2247 | if is_error { |
| 2247 | 2248 | alert(message: text) |
| 2248 | 2249 | } else { |
| 2249 | | - <section class="card notice" role="status">(text)</section> |
| 2250 | + <p class="state" role="status">(text)</p> |
| 2250 | 2251 | } |
| 2251 | 2252 | } |
| 2252 | | - <div data-live=(live.as_deref()) class="ci-split fit-pane" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())> |
| 2253 | + <div data-live=(live.as_deref()) class="ci-split" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())> |
| 2253 | 2254 | <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true"> |
| 2254 | 2255 | <defs> |
| 2255 | 2256 | <pattern id="ci-hatch" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"> |
| | @@ -2343,9 +2344,9 @@ async fn run_timeline(lang: Lang, run: &RunDetail) -> Result<impl View> { |
| 2343 | 2344 | <span class="ci-chev" aria-hidden="true"></span> |
| 2344 | 2345 | </a> |
| 2345 | 2346 | if let (Some(action), Some(csrf)) = (job.rerun.as_ref(), run.writer_csrf.as_ref()) { |
| 2346 | | - <form method="post" action=(action.as_str()) class="inline-form ci-job-rerun"> |
| 2347 | + <form method="post" action=(action.as_str()) class="act-form ci-job-rerun"> |
| 2347 | 2348 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 2348 | | - <button type="submit" class="ci-mini">(g::t(lang, K::Rerun))</button> |
| 2349 | + <button type="submit" class="act">(g::t(lang, K::Rerun))</button> |
| 2349 | 2350 | </form> |
| 2350 | 2351 | } |
| 2351 | 2352 | </div> |
| | @@ -2358,7 +2359,7 @@ async fn run_timeline(lang: Lang, run: &RunDetail) -> Result<impl View> { |
| 2358 | 2359 | <pre class="ci-logpre">(job.tail.as_str())</pre> |
| 2359 | 2360 | <a class="ci-job-full" href=(job.href.as_str())>(g::t(lang, K::FullLog))</a> |
| 2360 | 2361 | " " |
| 2361 | | - <button type="button" class="ci-mini ci-job-copy" data-copy-log=(format!("{}/log.txt", job.href)) data-copied=(g::t(lang, K::CopyDone)) data-failed=(g::t(lang, K::CopyFailed))>(g::t(lang, K::CopyLog))</button> |
| 2362 | + <button type="button" class="act ci-job-copy" data-copy-log=(format!("{}/log.txt", job.href)) data-copied=(g::t(lang, K::CopyDone)) data-failed=(g::t(lang, K::CopyFailed))>(g::t(lang, K::CopyLog))</button> |
| 2362 | 2363 | </div> |
| 2363 | 2364 | } else if !job.preview.is_empty() { |
| 2364 | 2365 | <p class="ci-job-last" title=(job.preview.as_str())> |
| | @@ -2372,11 +2373,13 @@ async fn run_timeline(lang: Lang, run: &RunDetail) -> Result<impl View> { |
| 2372 | 2373 | }) |
| 2373 | 2374 | } |
| 2374 | 2375 | |
| 2375 | | -/// The head of a run: `Run #N` and the commit's first clause, the full message on demand, a meta line |
| 2376 | | -/// (the state in accent while it is live) and at most two actions at the right. `all_href` adds the All |
| 2376 | +/// The head of a run: `Run #N` and the commit's first clause, the full message on demand, the run's |
| 2377 | +/// actions as text links beside the title, and a meta line (the state in accent while it is live). |
| 2378 | +/// `all_href` adds the All |
| 2377 | 2379 | /// runs link, which the run page needs; the list page has the runs beside it. |
| 2378 | 2380 | #[component] |
| 2379 | 2381 | async fn run_head(lang: Lang, run: &RunDetail, all_href: Option<String>) -> Result<impl View> { |
| 2382 | + let cancel_action = format!("{}/cancel", run.action_base); |
| 2380 | 2383 | Ok(view! { |
| 2381 | 2384 | <header class="ci-tl-head" data-run=(run.number)> |
| 2382 | 2385 | <div class="ci-tl-headmain"> |
| | @@ -2387,6 +2390,24 @@ async fn run_head(lang: Lang, run: &RunDetail, all_href: Option<String>) -> Resu |
| 2387 | 2390 | <summary>(crate::i18n::code::t(lang, crate::i18n::code::K::ShowFullMessage))</summary> |
| 2388 | 2391 | <p class="small">(run.title.as_str())</p> |
| 2389 | 2392 | </details> |
| 2393 | + if let Some(csrf) = run.writer_csrf.as_ref() { |
| 2394 | + <div class="acts ci-tl-actions"> |
| 2395 | + if run.can_approve { |
| 2396 | + action_button(action: format!("{}/approve", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::ApproveAndRun)) |
| 2397 | + } |
| 2398 | + if run.can_cancel && run.stopping { |
| 2399 | + <button type="button" class="ci-stopping" disabled="disabled">(g::t(lang, K::StoppingButton))</button> |
| 2400 | + } else if run.can_cancel { |
| 2401 | + confirm_post(lang: lang, csrf: csrf.as_str(), action: cancel_action.as_str(), label: g::t(lang, K::Cancel), message: crate::pages::passkeys::s(lang, "The run stops and its unfinished jobs are cancelled.", "Çalıştırma durur ve bitmemiş işleri iptal edilir.").to_owned(), confirm: crate::pages::passkeys::s(lang, "Yes, cancel", "Evet, iptal et"), danger: true, fields: vec![]) |
| 2402 | + } |
| 2403 | + if run.can_rerun_failed && !run.can_approve && !run.can_cancel { |
| 2404 | + action_button(action: format!("{}/rerun-failed", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::RerunFailed)) |
| 2405 | + } |
| 2406 | + if !run.can_approve && run.reachable { |
| 2407 | + action_button(action: format!("{}/rerun", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Rerun)) |
| 2408 | + } |
| 2409 | + </div> |
| 2410 | + } |
| 2390 | 2411 | </div> |
| 2391 | 2412 | <div class="ci-tl-meta"> |
| 2392 | 2413 | <span class=(run.state_class.as_str())>(run.state.as_str())</span> |
| | @@ -2415,24 +2436,6 @@ async fn run_head(lang: Lang, run: &RunDetail, all_href: Option<String>) -> Resu |
| 2415 | 2436 | <progress class="ci-est ci-est-run" max="100" value=(est.pct.as_str()) data-est="true" data-since=(run.since.as_deref()) data-expected=(est.expected.as_str())></progress> |
| 2416 | 2437 | } |
| 2417 | 2438 | </div> |
| 2418 | | - if let Some(csrf) = run.writer_csrf.as_ref() { |
| 2419 | | - <div class="ci-actions ci-tl-actions"> |
| 2420 | | - if run.can_approve { |
| 2421 | | - action_button(action: format!("{}/approve", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::ApproveAndRun)) |
| 2422 | | - } |
| 2423 | | - if run.can_cancel && run.stopping { |
| 2424 | | - <button type="button" class="ci-stopping" disabled="disabled">(g::t(lang, K::StoppingButton))</button> |
| 2425 | | - } else if run.can_cancel { |
| 2426 | | - action_button(action: format!("{}/cancel", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Cancel)) |
| 2427 | | - } |
| 2428 | | - if run.can_rerun_failed && !run.can_approve && !run.can_cancel { |
| 2429 | | - action_button(action: format!("{}/rerun-failed", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::RerunFailed)) |
| 2430 | | - } |
| 2431 | | - if !run.can_approve && run.reachable { |
| 2432 | | - action_button(action: format!("{}/rerun", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Rerun)) |
| 2433 | | - } |
| 2434 | | - </div> |
| 2435 | | - } |
| 2436 | 2439 | </header> |
| 2437 | 2440 | }) |
| 2438 | 2441 | } |
| | @@ -2536,7 +2539,7 @@ async fn run_jobs(lang: Lang, run: &RunDetail) -> Result<impl View> { |
| 2536 | 2539 | <div class="ci-tl-artline"> |
| 2537 | 2540 | <h3 class="ci-tl-label">(g::t(lang, K::Artifacts))</h3> |
| 2538 | 2541 | if let Some(href) = run.zip_href.as_ref() { |
| 2539 | | - <a class="button ci-mini" href=(href.as_str()) download="">(g::t(lang, K::DownloadAll))</a> |
| 2542 | + <a class="act" href=(href.as_str()) download="">(g::t(lang, K::DownloadAll))</a> |
| 2540 | 2543 | } |
| 2541 | 2544 | </div> |
| 2542 | 2545 | <ul class="ci-art-list"> |
| | @@ -2562,7 +2565,7 @@ async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result<impl Vie |
| 2562 | 2565 | <input type="radio" name="ci-view" id="ci-view-log" class="ci-tl-radio" checked=(if timeline { None } else { Some("checked") })> |
| 2563 | 2566 | <input type="radio" name="ci-view" id="ci-view-timeline" class="ci-tl-radio" checked=(if timeline { Some("checked") } else { None })> |
| 2564 | 2567 | <div class="ci-logbar ci-tl-logbar"> |
| 2565 | | - <div class="ci-tl-tabs"> |
| 2568 | + <div class="tabs ci-tl-tabs"> |
| 2566 | 2569 | <label for="ci-view-log" class="ci-tl-tab ci-tl-tab-log">(g::t(lang, K::Log))</label> |
| 2567 | 2570 | <label for="ci-view-timeline" class="ci-tl-tab ci-tl-tab-timeline">(g::t(lang, K::Timeline))</label> |
| 2568 | 2571 | </div> |
| | @@ -2570,19 +2573,19 @@ async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result<impl Vie |
| 2570 | 2573 | <div class="ci-tl-tools"> |
| 2571 | 2574 | <input type="search" class="ci-logsearch" data-log-q="true" placeholder=(g::t(lang, K::LogSearch)) aria-label=(g::t(lang, K::LogSearch)) autocomplete="off" spellcheck="false"> |
| 2572 | 2575 | <span class="ci-logcount" data-log-count="true" data-none=(g::t(lang, K::LogNoMatches)) aria-live="polite"></span> |
| 2573 | | - <button type="button" class="ci-mini" data-log-prev="true" aria-label=(g::t(lang, K::LogPrev)) title=(g::t(lang, K::LogPrev))>"\u{2191}"</button> |
| 2574 | | - <button type="button" class="ci-mini" data-log-next="true" aria-label=(g::t(lang, K::LogNext)) title=(g::t(lang, K::LogNext))>"\u{2193}"</button> |
| 2575 | | - <button type="button" class="ci-mini" data-copy-log=(log.log_href.as_str()) data-palette-action="click" data-copied=(g::t(lang, K::CopyDone)) data-failed=(g::t(lang, K::CopyFailed))>(g::t(lang, K::CopyLog))</button> |
| 2576 | | - <a class="ci-mini" href=(log.href.as_str())>(g::t(lang, K::FullLog))</a> |
| 2576 | + <button type="button" class="act" data-log-prev="true" aria-label=(g::t(lang, K::LogPrev)) title=(g::t(lang, K::LogPrev))>"\u{2191}"</button> |
| 2577 | + <button type="button" class="act" data-log-next="true" aria-label=(g::t(lang, K::LogNext)) title=(g::t(lang, K::LogNext))>"\u{2193}"</button> |
| 2578 | + <button type="button" class="act" data-copy-log=(log.log_href.as_str()) data-palette-action="click" data-copied=(g::t(lang, K::CopyDone)) data-failed=(g::t(lang, K::CopyFailed))>(g::t(lang, K::CopyLog))</button> |
| 2579 | + <a class="act" href=(log.href.as_str())>(g::t(lang, K::FullLog))</a> |
| 2577 | 2580 | if let (Some(action), Some(csrf)) = (log.rerun.as_ref(), run.writer_csrf.as_ref()) { |
| 2578 | | - <form method="post" action=(action.as_str()) class="inline-form ci-job-rerun"> |
| 2581 | + <form method="post" action=(action.as_str()) class="act-form ci-job-rerun"> |
| 2579 | 2582 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 2580 | | - <button type="submit" class="ci-mini">(crate::pages::passkeys::s(lang, "Re-run job", "İşi yeniden çalıştır"))</button> |
| 2583 | + <button type="submit" class="act">(crate::pages::passkeys::s(lang, "Re-run job", "İşi yeniden çalıştır"))</button> |
| 2581 | 2584 | </form> |
| 2582 | 2585 | } |
| 2583 | 2586 | <span class="ci-logfold" data-log-fold-box="true" hidden="hidden"> |
| 2584 | | - <button type="button" class="ci-mini" data-log-fold="close">(g::t(lang, K::LogCollapseAll))</button> |
| 2585 | | - <button type="button" class="ci-mini" data-log-fold="open">(g::t(lang, K::LogExpandAll))</button> |
| 2587 | + <button type="button" class="act" data-log-fold="close">(g::t(lang, K::LogCollapseAll))</button> |
| 2588 | + <button type="button" class="act" data-log-fold="open">(g::t(lang, K::LogExpandAll))</button> |
| 2586 | 2589 | </span> |
| 2587 | 2590 | </div> |
| 2588 | 2591 | } |
| | @@ -2648,10 +2651,10 @@ async fn run_body( |
| 2648 | 2651 | if is_error { |
| 2649 | 2652 | alert(message: text) |
| 2650 | 2653 | } else { |
| 2651 | | - <section class="card notice" role="status">(text)</section> |
| 2654 | + <p class="state" role="status">(text)</p> |
| 2652 | 2655 | } |
| 2653 | 2656 | } |
| 2654 | | - <div data-live=(live.as_deref()) class="ci-split fit-pane" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())> |
| 2657 | + <div data-live=(live.as_deref()) class="ci-split" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())> |
| 2655 | 2658 | <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true"> |
| 2656 | 2659 | <defs> |
| 2657 | 2660 | <pattern id="ci-hatch" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"> |
| | @@ -209,30 +209,44 @@ async fn search_page(cx: &Cx) -> Result<impl View> { |
| 209 | 209 | Ok(view! { |
| 210 | 210 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 211 | 211 | repo_head(head: header) |
| 212 | | - <div class="search-page fit-pane"> |
| 212 | + <div class="search-page"> |
| 213 | 213 | <form method="get" action=(action.as_str()) class="search-form" role="search"> |
| 214 | | - <div class="search-row"> |
| 214 | + <div class="plain-search"> |
| 215 | 215 | <input type="search" name="q" value=(q.as_str()) placeholder=(g::t(lang, K::SearchCodePlaceholder)) aria-label=(g::t(lang, K::SearchCodePlaceholder))> |
| 216 | | - <button type="submit">(g::t(lang, K::SearchButton))</button> |
| 217 | 216 | </div> |
| 218 | | - <div class="search-row search-options"> |
| 219 | | - <label>(g::t(lang, K::RefField)) <input type="text" name="ref" value=(ref_value.as_str()) placeholder=(ctx.repo.default_branch.as_str())></label> |
| 220 | | - <label>(g::t(lang, K::PathField)) <input type="text" name="path" value=(path_value.as_str()) placeholder="src/**/*.rs"></label> |
| 221 | | - <label><input type="checkbox" name="case" value="1" checked=(match_case)> (g::t(lang, K::MatchCase))</label> |
| 222 | | - <label><input type="checkbox" name="regex" value="1" checked=(regex)> (g::t(lang, K::RegexOption))</label> |
| 217 | + <div class="field-pair"> |
| 218 | + <div class="field"> |
| 219 | + <label for="search-ref">(g::t(lang, K::RefField))</label> |
| 220 | + <input id="search-ref" type="text" name="ref" value=(ref_value.as_str()) placeholder=(ctx.repo.default_branch.as_str())> |
| 221 | + </div> |
| 222 | + <div class="field"> |
| 223 | + <label for="search-path">(g::t(lang, K::PathField))</label> |
| 224 | + <input id="search-path" type="text" name="path" value=(path_value.as_str()) placeholder="src/**/*.rs"> |
| 225 | + </div> |
| 226 | + </div> |
| 227 | + <label class="switch"> |
| 228 | + <input type="checkbox" name="case" value="1" checked=(match_case)> |
| 229 | + <span>(g::t(lang, K::MatchCase))</span> |
| 230 | + </label> |
| 231 | + <label class="switch"> |
| 232 | + <input type="checkbox" name="regex" value="1" checked=(regex)> |
| 233 | + <span>(g::t(lang, K::RegexOption))</span> |
| 234 | + </label> |
| 235 | + <div class="acts"> |
| 236 | + <button type="submit" class="primary">(g::t(lang, K::SearchButton))</button> |
| 223 | 237 | </div> |
| 224 | 238 | </form> |
| 225 | 239 | if empty_repo { |
| 226 | | - <p class="notice">(empty_message.as_str())</p> |
| 240 | + <p class="state">(empty_message.as_str())</p> |
| 227 | 241 | } else if no_query { |
| 228 | | - <p class="muted">(g::t(lang, K::SearchFilesAt)) <code>(ref_label.as_str())</code> "."</p> |
| 242 | + <p class="state">(g::t(lang, K::SearchFilesAt)) <code>(ref_label.as_str())</code> "."</p> |
| 229 | 243 | } |
| 230 | 244 | if let Some(msg) = notice { |
| 231 | | - <p class="notice" role="alert">(msg.as_str())</p> |
| 245 | + <p class="state" role="alert">(msg.as_str())</p> |
| 232 | 246 | } |
| 233 | 247 | if !no_query && !empty_repo { |
| 234 | 248 | if has_results { |
| 235 | | - <p class="muted small">(summary.as_str()) |
| 249 | + <p class="hint">(summary.as_str()) |
| 236 | 250 | if truncated { |
| 237 | 251 | (g::t(lang, K::ShowingFirst)) (shown.as_str()) (g::t(lang, K::ShowingFirstEnd)) |
| 238 | 252 | } |
| | @@ -258,9 +258,9 @@ async fn commit_page(cx: &Cx) -> Result<impl View> { |
| 258 | 258 | Ok(view! { |
| 259 | 259 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 260 | 260 | repo_head(head: header) |
| 261 | | - <h2 class="commit-summary-title">(heading.as_str())</h2> |
| 262 | | - <div class="commit-facts muted"> |
| 263 | | - <button type="button" class="commit-hash" data-copy="commit-oid" data-copied=(copied) data-failed=(copy_failed) title=(full_oid.as_str())>(short.as_str())</button> |
| 261 | + <h1 class="h1 commit-summary-title">(heading.as_str())</h1> |
| 262 | + <div class="hint commit-facts"> |
| 263 | + <button type="button" class="act quiet commit-hash" data-copy="commit-oid" data-copied=(copied) data-failed=(copy_failed) title=(full_oid.as_str())>(short.as_str())</button> |
| 264 | 264 | <code id="commit-oid" class="sr-only">(full_oid.as_str())</code> |
| 265 | 265 | if let Some(badge) = sig { |
| 266 | 266 | <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> |
| | @@ -285,7 +285,7 @@ async fn commit_page(cx: &Cx) -> Result<impl View> { |
| 285 | 285 | if folded { |
| 286 | 286 | ", " |
| 287 | 287 | <details class="coauthors-more"> |
| 288 | | - <summary>(others.as_str())</summary> |
| 288 | + <summary class="act">(others.as_str())</summary> |
| 289 | 289 | <ul class="coauthors-list" aria-label=(coauthors_label)> |
| 290 | 290 | for c in rest.iter() { |
| 291 | 291 | <li> |
| | @@ -319,7 +319,9 @@ async fn commit_page(cx: &Cx) -> Result<impl View> { |
| 319 | 319 | if let Some(summary) = checks { |
| 320 | 320 | checks_summary(summary: summary, lang: StatusLang(lang)) |
| 321 | 321 | } |
| 322 | | - <a class="commit-browse" href=(tree_href.as_str())>(g::t(lang, K::BrowseFiles))</a> |
| 322 | + </div> |
| 323 | + <div class="acts"> |
| 324 | + <a class="act" href=(tree_href.as_str())>(g::t(lang, K::BrowseFiles))</a> |
| 323 | 325 | </div> |
| 324 | 326 | if let Some(msg) = parsed.as_ref() { |
| 325 | 327 | <ul class="commit-groups" aria-label=(changes_label)> |
| | @@ -334,15 +336,17 @@ async fn commit_page(cx: &Cx) -> Result<impl View> { |
| 334 | 336 | </li> |
| 335 | 337 | } |
| 336 | 338 | </ul> |
| 337 | | - <details class="commit-full-message"> |
| 338 | | - <summary>(show_full)</summary> |
| 339 | | - <pre class="code commit-message"><code>(message.as_str())</code></pre> |
| 339 | + <details class="reveal commit-full-message"> |
| 340 | + <summary class="act">(show_full)</summary> |
| 341 | + <div class="opened"> |
| 342 | + <pre class="code commit-message"><code>(message.as_str())</code></pre> |
| 343 | + </div> |
| 340 | 344 | </details> |
| 341 | 345 | } |
| 342 | 346 | if parsed.is_none() && has_body { |
| 343 | 347 | <pre class="code commit-message"><code>(message.as_str())</code></pre> |
| 344 | 348 | } |
| 345 | | - <div class="commit-diff fit-pane"> |
| 349 | + <div class="commit-diff"> |
| 346 | 350 | diff_section(diff: &diff, owner: owner_name.as_str(), repo: repo_name.as_str(), oid: info.oid.as_str(), parent: parent.as_deref(), subject: g::t(lang, K::ThisCommit), lang: DiffLang(lang), opts: opts) |
| 347 | 351 | </div> |
| 348 | 352 | ) |
| | @@ -28,7 +28,7 @@ use crate::signatures::{self, SigBadge}; |
| 28 | 28 | use crate::state::AppState; |
| 29 | 29 | use crate::views::commit_line::commit_line; |
| 30 | 30 | use crate::views::commit_status::{StatusLang, StatusSummary, commit_status, status_list}; |
| 31 | | -use crate::views::{empty_state, shell}; |
| 31 | +use crate::views::shell; |
| 32 | 32 | |
| 33 | 33 | path_param!(owner); |
| 34 | 34 | path_param!(repo); |
| | @@ -355,81 +355,74 @@ async fn commits_page(cx: &Cx) -> Result<impl View> { |
| 355 | 355 | Ok(view! { |
| 356 | 356 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 357 | 357 | repo_head(head: header) |
| 358 | | - <div class="commits-fit fit-pane lang-list"> |
| 359 | | - <div class="commits-head"> |
| 360 | | - <span class="label">(g::t(lang, K::CommitsOn))</span> |
| 361 | | - <span class="tag">(ref_name.as_str())</span> |
| 358 | + <p class="hint">(g::t(lang, K::CommitsOn)) <code>(ref_name.as_str())</code></p> |
| 359 | + if has_filter { |
| 360 | + <p class="sub">(g::t(lang, K::FilteredTo)) <code>(filter_text.as_str())</code> <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilter))</a></p> |
| 361 | + } |
| 362 | + if empty { |
| 363 | + <p class="state">(g::t(lang, K::NoCommits))</p> |
| 362 | 364 | if has_filter { |
| 363 | | - <span class="commits-filter small muted">(g::t(lang, K::FilteredTo)) <code>(filter_text.as_str())</code> " · " <a href=(clear_href.as_str())>(g::t(lang, K::ClearFilter))</a></span> |
| 365 | + <div class="acts"><a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilter))</a></div> |
| 364 | 366 | } |
| 365 | | - </div> |
| 366 | | - if empty { |
| 367 | | - empty_state(title: g::t(lang, K::NoCommits), |
| 368 | | - if has_filter { |
| 369 | | - <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearFilter))</a> |
| 370 | | - } |
| 371 | | - ) |
| 372 | 367 | } else { |
| 373 | | - <div class="commits-pane"> |
| 374 | | - for group in groups.iter() { |
| 375 | | - <div class="commits-g"><span class="label">(group.label.as_str())</span></div> |
| 376 | | - <ul class="commits-list"> |
| 368 | + for group in groups.iter() { |
| 369 | + <section class="sec"> |
| 370 | + <h2>(group.label.as_str())</h2> |
| 371 | + <div class="commits-list"> |
| 377 | 372 | for row in group.rows.iter() { |
| 378 | | - <li class="commits-item" data-kb-row="" data-arrive=(row.oid.as_str())> |
| 379 | | - if let Some(body) = row.body.clone() { |
| 380 | | - <details class="commits-d"> |
| 381 | | - <summary class="commits-r"> |
| 382 | | - <span class="commits-slot"><span class="commits-chev" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg></span></span> |
| 383 | | - <span class=(row.dot())></span> |
| 384 | | - <a class="commits-sub commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> |
| 385 | | - <span class="commits-au" title=(row.email.as_str())>(row.author.as_str())</span> |
| 386 | | - if let Some(badge) = row.sig.clone() { |
| 387 | | - <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> |
| 388 | | - } |
| 389 | | - <time class="commits-age" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 390 | | - <a class="sha commits-sha" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 391 | | - <a class="commits-ic" href=(row.tree_href.as_str()) aria-label=(g::t(lang, K::BrowseFilesShort))><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg></a> |
| 392 | | - </summary> |
| 393 | | - <pre class="commits-x">(body.as_str())</pre> |
| 394 | | - if !row.status.items.is_empty() { |
| 395 | | - <div class="commit-status"> |
| 396 | | - status_list(items: row.status.items.clone(), lang: lang) |
| 397 | | - </div> |
| 398 | | - } |
| 399 | | - </details> |
| 400 | | - } else { |
| 401 | | - <div class="commits-r"> |
| 402 | | - <span class="commits-slot"></span> |
| 373 | + if let Some(body) = row.body.clone() { |
| 374 | + <details class="row-open commits-d" data-kb-row="" data-arrive=(row.oid.as_str())> |
| 375 | + <summary class="line commits-r"> |
| 376 | + <span class="commits-chev" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg></span> |
| 403 | 377 | <span class=(row.dot())></span> |
| 404 | | - <a class="commits-sub commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> |
| 405 | | - <span class="commits-au" title=(row.email.as_str())>(row.author.as_str())</span> |
| 378 | + <a class="name commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> |
| 379 | + <span class="val"><span title=(row.email.as_str())>(row.author.as_str())</span> " · " <time class="commits-age" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time></span> |
| 406 | 380 | if let Some(badge) = row.sig.clone() { |
| 407 | 381 | <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> |
| 408 | 382 | } |
| 409 | | - <time class="commits-age" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 410 | 383 | <a class="sha commits-sha" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 411 | | - commit_status(summary: row.status.clone(), lang: StatusLang(lang)) |
| 412 | | - <a class="commits-ic" href=(row.tree_href.as_str()) aria-label=(g::t(lang, K::BrowseFilesShort))><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg></a> |
| 384 | + </summary> |
| 385 | + <div class="opened"> |
| 386 | + <pre class="code commits-x">(body.as_str())</pre> |
| 387 | + if !row.status.items.is_empty() { |
| 388 | + <div class="commit-status"> |
| 389 | + status_list(items: row.status.items.clone(), lang: lang) |
| 390 | + </div> |
| 391 | + } |
| 392 | + <div class="acts"> |
| 393 | + <a class="act quiet" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFilesShort))</a> |
| 394 | + </div> |
| 413 | 395 | </div> |
| 414 | | - } |
| 415 | | - </li> |
| 396 | + </details> |
| 397 | + } else { |
| 398 | + <div class="line commits-r" data-kb-row="" data-arrive=(row.oid.as_str())> |
| 399 | + <span class=(row.dot())></span> |
| 400 | + <a class="name commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> |
| 401 | + <span class="val"><span title=(row.email.as_str())>(row.author.as_str())</span> " · " <time class="commits-age" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time></span> |
| 402 | + if let Some(badge) = row.sig.clone() { |
| 403 | + <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> |
| 404 | + } |
| 405 | + <a class="sha commits-sha" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 406 | + commit_status(summary: row.status.clone(), lang: StatusLang(lang)) |
| 407 | + <a class="act quiet" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFilesShort))</a> |
| 408 | + </div> |
| 409 | + } |
| 416 | 410 | } |
| 417 | | - </ul> |
| 418 | | - } |
| 419 | | - </div> |
| 411 | + </div> |
| 412 | + </section> |
| 413 | + } |
| 420 | 414 | } |
| 421 | 415 | if has_newer || has_older { |
| 422 | | - <nav class="pager"> |
| 416 | + <nav class="sub"> |
| 423 | 417 | if has_newer { |
| 424 | 418 | <a href=(newer_href.as_str())>(g::t(lang, K::NewerLink))</a> |
| 425 | 419 | } |
| 426 | | - <span class="muted small">(page_label.as_str())</span> |
| 420 | + <span>(page_label.as_str())</span> |
| 427 | 421 | if has_older { |
| 428 | 422 | <a href=(older_href.as_str())>(g::t(lang, K::OlderLink))</a> |
| 429 | 423 | } |
| 430 | 424 | </nav> |
| 431 | 425 | } |
| 432 | | - </div> |
| 433 | 426 | ) |
| 434 | 427 | }) |
| 435 | 428 | } |
| | @@ -639,7 +632,7 @@ mod tests { |
| 639 | 632 | let (status, _, body) = get(&fx.router, &base).await; |
| 640 | 633 | assert_eq!(status, 200); |
| 641 | 634 | let html = String::from_utf8(body).unwrap(); |
| 642 | | - assert_eq!(html.matches("class=\"commits-r\"").count(), 50); |
| 635 | + assert_eq!(html.matches("class=\"line commits-r\"").count(), 50); |
| 643 | 636 | assert!(html.contains("filler 53")); |
| 644 | 637 | assert!(!html.contains("root commit")); |
| 645 | 638 | assert!(html.contains(">Older<")); |
| | @@ -652,7 +645,7 @@ mod tests { |
| 652 | 645 | let (status, _, body) = get(&fx.router, &format!("{base}?page=2")).await; |
| 653 | 646 | assert_eq!(status, 200); |
| 654 | 647 | let html = String::from_utf8(body).unwrap(); |
| 655 | | - assert_eq!(html.matches("class=\"commits-r\"").count(), 5); |
| 648 | + assert_eq!(html.matches("class=\"line commits-r\"").count(), 5); |
| 656 | 649 | assert!(html.contains("root commit")); |
| 657 | 650 | assert!(html.contains(">Newer<")); |
| 658 | 651 | assert!(!html.contains(">Older<")); |
| | @@ -671,9 +664,9 @@ mod tests { |
| 671 | 664 | get(&fx.router, &format!("/{OWNER}/{REPO}/commits/main/a.txt")).await; |
| 672 | 665 | assert_eq!(status, 200); |
| 673 | 666 | let html = String::from_utf8(body).unwrap(); |
| 674 | | - assert_eq!(html.matches("class=\"commits-r\"").count(), 2); |
| 667 | + assert_eq!(html.matches("class=\"line commits-r\"").count(), 2); |
| 675 | 668 | // Only the modified commit has a body, so only its row has a disclosure. |
| 676 | | - assert_eq!(html.matches("class=\"commits-d\"").count(), 1); |
| 669 | + assert_eq!(html.matches("class=\"row-open commits-d\"").count(), 1); |
| 677 | 670 | assert!(html.contains("Body line one.")); |
| 678 | 671 | assert!(html.contains("Modify a.txt and add new.txt")); |
| 679 | 672 | assert!(html.contains("root commit")); |
| | @@ -38,7 +38,8 @@ use crate::state::AppState; |
| 38 | 38 | use crate::templates; |
| 39 | 39 | use crate::views::commit_line::commit_line; |
| 40 | 40 | use crate::views::diff::{DiffLang, DiffOpts, LIMITS, diff_section}; |
| 41 | | -use crate::views::{alert, empty_state, repo_href, shell, user_facing_message}; |
| 41 | +use crate::views::parts::reveal; |
| 42 | +use crate::views::{alert, repo_href, shell, user_facing_message}; |
| 42 | 43 | use crate::webhooks::emit::{Sender, emit_pull}; |
| 43 | 44 | |
| 44 | 45 | path_param!(owner); |
| | @@ -332,82 +333,77 @@ async fn compare_view( |
| 332 | 333 | Ok(view! { |
| 333 | 334 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 334 | 335 | repo_head(head: header) |
| 335 | | - <div class="lang-split is-list"> |
| 336 | 336 | if has_commits { |
| 337 | | - <div class="lang-list fit-pane"> |
| 338 | | - <div class="list-bar"> |
| 339 | | - <h2>(commits_label.as_str())</h2> |
| 340 | | - </div> |
| 341 | | - <div class="list-scroll"> |
| 342 | | - <ul class="commit-list compare-commits"> |
| 343 | | - for row in rows.iter() { |
| 344 | | - <li class="commit-row" data-kb-row=""> |
| 345 | | - <div class="commit-main"> |
| 346 | | - <a class="commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> |
| 347 | | - <div class="commit-meta muted small"> |
| 348 | | - <span class="commit-author">(row.author.as_str())</span> |
| 349 | | - if !row.email.is_empty() { |
| 350 | | - <span class="commit-email">(row.email.as_str())</span> |
| 351 | | - } |
| 352 | | - if lang == i18n::Lang::Tr { |
| 353 | | - <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 354 | | - <span>(g::t(lang, K::Committed))</span> |
| 355 | | - } else { |
| 356 | | - <span>(g::t(lang, K::Committed))</span> |
| 357 | | - <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 358 | | - } |
| 359 | | - </div> |
| 360 | | - </div> |
| 361 | | - <div class="commit-actions"> |
| 362 | | - <a class="mono commit-oid" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 363 | | - <a class="small muted" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFiles))</a> |
| 364 | | - </div> |
| 365 | | - </li> |
| 366 | | - } |
| 367 | | - </ul> |
| 337 | + <section class="sec"> |
| 338 | + <h2>(commits_label.as_str())</h2> |
| 339 | + <div> |
| 340 | + for row in rows.iter() { |
| 341 | + <div class="line" data-kb-row=""> |
| 342 | + <a class="name commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> |
| 343 | + <span class="val"> |
| 344 | + (row.author.as_str()) |
| 345 | + if !row.email.is_empty() { |
| 346 | + " · " (row.email.as_str()) |
| 347 | + } |
| 348 | + if lang == i18n::Lang::Tr { |
| 349 | + " · " <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> " " (g::t(lang, K::Committed)) |
| 350 | + } else { |
| 351 | + " · " (g::t(lang, K::Committed)) " " <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 352 | + } |
| 353 | + </span> |
| 354 | + <a class="sha commit-oid" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 355 | + <a class="act quiet" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFiles))</a> |
| 356 | + </div> |
| 357 | + } |
| 368 | 358 | </div> |
| 369 | | - </div> |
| 359 | + </section> |
| 370 | 360 | } |
| 371 | | - <div class="lang-pane fit-pane compare-detail"> |
| 361 | + <section class="sec"> |
| 372 | 362 | <h2>(g::t(lang, K::ComparingPrefix)) <code>(heading_base.as_str())</code> "..." <code>(heading_head.as_str())</code></h2> |
| 373 | 363 | if unrelated { |
| 374 | | - <p class="muted">(g::t(lang, K::Unrelated))</p> |
| 364 | + <p class="state">(g::t(lang, K::Unrelated))</p> |
| 375 | 365 | } |
| 376 | 366 | if nothing { |
| 377 | | - empty_state(title: g::t(lang, K::NothingToCompare)) |
| 367 | + <p class="state">(g::t(lang, K::NothingToCompare))</p> |
| 378 | 368 | } |
| 379 | 369 | if show_form { |
| 380 | | - <section class="compare-open"> |
| 381 | | - <h2>(g::t(lang, K::OpenPullRequest))</h2> |
| 370 | + <div class="acts"> |
| 371 | + reveal(label: g::t(lang, K::OpenPullRequest), id: Some("open-pull"), open: has_error, |
| 382 | 372 | if has_error { |
| 383 | 373 | alert(message: error_text.as_str()) |
| 384 | 374 | } |
| 385 | | - <form method="post" action=(pulls_action.as_str())> |
| 375 | + <form method="post" action=(pulls_action.as_str()) class="fields"> |
| 386 | 376 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 387 | 377 | <input type="hidden" name="base" value=(base.as_str())> |
| 388 | 378 | <input type="hidden" name="head" value=(head_for_form.as_str())> |
| 389 | | - <p><label>(g::t(lang, K::TitleLabel)) <input type="text" name="title" value=(form_title.as_str())></label></p> |
| 390 | | - <p><label>(g::t(lang, K::DescriptionLabel)) <textarea name="body" rows="8">(form_body.as_str())</textarea></label></p> |
| 391 | | - <p class="form-actions"> |
| 379 | + <div class="field"> |
| 380 | + <label for="pull-title">(g::t(lang, K::TitleLabel))</label> |
| 381 | + <input id="pull-title" type="text" name="title" value=(form_title.as_str())> |
| 382 | + </div> |
| 383 | + <div class="field"> |
| 384 | + <label for="pull-body">(g::t(lang, K::DescriptionLabel))</label> |
| 385 | + <textarea id="pull-body" name="body" rows="8">(form_body.as_str())</textarea> |
| 386 | + </div> |
| 387 | + <div class="acts"> |
| 392 | 388 | <button type="submit" class="primary">(g::t(lang, K::CreatePullRequest))</button> |
| 393 | | - <button type="submit" name="draft" value="1">(g::t(lang, K::CreateDraftPullRequest))</button> |
| 394 | | - </p> |
| 389 | + <button type="submit" class="act" name="draft" value="1">(g::t(lang, K::CreateDraftPullRequest))</button> |
| 390 | + </div> |
| 395 | 391 | </form> |
| 396 | | - </section> |
| 392 | + ) |
| 393 | + </div> |
| 397 | 394 | } |
| 398 | 395 | if has_existing { |
| 399 | | - <p class="muted">(g::t(lang, K::AlreadyOpen)) <a href=(existing_href.as_str())>(g::t(lang, K::ViewIt))</a></p> |
| 396 | + <p class="state">(g::t(lang, K::AlreadyOpen)) <a class="act" href=(existing_href.as_str())>(g::t(lang, K::ViewIt))</a></p> |
| 400 | 397 | } |
| 401 | 398 | if archived_note { |
| 402 | | - <p class="muted">(g::t(lang, K::ArchivedNoPulls))</p> |
| 399 | + <p class="state">(g::t(lang, K::ArchivedNoPulls))</p> |
| 403 | 400 | } |
| 401 | + </section> |
| 404 | 402 | if show_diff { |
| 405 | 403 | for d in diff.iter() { |
| 406 | 404 | diff_section(diff: d, owner: owner.as_str(), repo: name.as_str(), oid: cmp.head_oid.as_str(), parent: parent.as_deref(), subject: g::t(lang, K::ThisComparison), lang: DiffLang(lang), opts: opts.clone()) |
| 407 | 405 | } |
| 408 | 406 | } |
| 409 | | - </div> |
| 410 | | - </div> |
| 411 | 407 | ) |
| 412 | 408 | }) |
| 413 | 409 | } |
| | @@ -431,11 +427,17 @@ async fn picker_view(cx: &Cx, ctx: RepoCtx, base: String, head: String) -> Resul |
| 431 | 427 | Ok(view! { |
| 432 | 428 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 433 | 429 | repo_head(head: header) |
| 434 | | - <section class="lang-form compare-pick"> |
| 430 | + <section class="sec"> |
| 435 | 431 | <h2>(g::t(lang, K::CompareBranches))</h2> |
| 436 | | - <form method="get" action=(action.as_str()) class="filter-bar"> |
| 437 | | - <label>(g::t(lang, K::BasePrefix)) <input type="text" name="base" list="compare-branches" value=(base.as_str())></label> |
| 438 | | - <label>(g::t(lang, K::HeadPrefix)) <input type="text" name="head" list="compare-branches" value=(head.as_str()) placeholder=(g::t(lang, K::BranchOrOwner))></label> |
| 432 | + <form method="get" action=(action.as_str()) class="fields"> |
| 433 | + <div class="field"> |
| 434 | + <label for="compare-base">(g::t(lang, K::BasePrefix))</label> |
| 435 | + <input id="compare-base" type="text" name="base" list="compare-branches" value=(base.as_str())> |
| 436 | + </div> |
| 437 | + <div class="field"> |
| 438 | + <label for="compare-head">(g::t(lang, K::HeadPrefix))</label> |
| 439 | + <input id="compare-head" type="text" name="head" list="compare-branches" value=(head.as_str()) placeholder=(g::t(lang, K::BranchOrOwner))> |
| 440 | + </div> |
| 439 | 441 | <datalist id="compare-branches"> |
| 440 | 442 | for name in branches.iter() { |
| 441 | 443 | <option value=(name.as_str())></option> |
| | @@ -23,8 +23,8 @@ use crate::views::repo_href; |
| 23 | 23 | path_param!(owner); |
| 24 | 24 | path_param!(repo); |
| 25 | 25 | |
| 26 | | -/// The settings card: one switch row. `enabled` is the current state. The switch submits the form |
| 27 | | -/// on change (`data-autosubmit`); an unchecked box sends no `enabled`, which the handler reads as off. |
| 26 | +/// The Discussions topic: a hint, then one switch. `enabled` is the current state. The switch submits |
| 27 | +/// the form on change (`data-autosubmit`); an unchecked box sends no `enabled`, which the handler reads as off. |
| 28 | 28 | #[component] |
| 29 | 29 | pub(crate) async fn discussions_card( |
| 30 | 30 | lang: Lang, |
| | @@ -32,17 +32,21 @@ pub(crate) async fn discussions_card( |
| 32 | 32 | csrf: String, |
| 33 | 33 | enabled: bool, |
| 34 | 34 | ) -> Result<impl View> { |
| 35 | + let switch_label = if enabled { |
| 36 | + g::t(lang, K::TurnOffDiscussions) |
| 37 | + } else { |
| 38 | + g::t(lang, K::TurnOnDiscussions) |
| 39 | + }; |
| 35 | 40 | Ok(view! { |
| 36 | | - <section class="card rows-pane" id="discussions"> |
| 37 | | - <form method="post" action=(action.as_str()) class="row-line row-field"> |
| 41 | + <section class="sec" id="discussions"> |
| 42 | + <h2>(g::t(lang, K::Discussions))</h2> |
| 43 | + <p class="hint">(g::t(lang, K::DiscussionsDescription))</p> |
| 44 | + <form method="post" action=(action.as_str())> |
| 38 | 45 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 39 | | - <span class="row-main"> |
| 40 | | - <span class="row-title" id="discussions-switch-label">(g::t(lang, K::Discussions))</span> |
| 41 | | - <span class="row-status">(g::t(lang, K::DiscussionsDescription))</span> |
| 42 | | - </span> |
| 43 | | - <span class="row-control"> |
| 44 | | - <input type="checkbox" name="enabled" value="1" checked=(enabled) data-autosubmit="true" aria-labelledby="discussions-switch-label"> |
| 45 | | - </span> |
| 46 | + <label class="switch"> |
| 47 | + <input type="checkbox" name="enabled" value="1" checked=(enabled) data-autosubmit="true"> |
| 48 | + <span>(switch_label)</span> |
| 49 | + </label> |
| 46 | 50 | </form> |
| 47 | 51 | </section> |
| 48 | 52 | }) |
| | @@ -25,12 +25,22 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 25 | 25 | use crate::pages::tree::link_context; |
| 26 | 26 | use crate::render::markdown::{LinkContext, render_markdown}; |
| 27 | 27 | use crate::state::AppState; |
| 28 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 28 | 29 | use crate::views::{avatar_url, display_name, now_unix, shell, user_href, user_link}; |
| 29 | 30 | |
| 30 | 31 | path_param!(owner); |
| 31 | 32 | path_param!(repo); |
| 32 | 33 | path_param!(number); |
| 33 | 34 | |
| 35 | +/// What deleting the discussion costs. |
| 36 | +fn delete_note(lang: Lang) -> &'static str { |
| 37 | + crate::pages::passkeys::s( |
| 38 | + lang, |
| 39 | + "Its comments are deleted with it.", |
| 40 | + "Yorumlarıyla birlikte silinir.", |
| 41 | + ) |
| 42 | +} |
| 43 | + |
| 34 | 44 | /// One comment, with every string the template shows already built. |
| 35 | 45 | pub(crate) struct CommentView { |
| 36 | 46 | lang: Lang, |
| | @@ -174,64 +184,68 @@ async fn comment_article(item: CommentView) -> Result<impl View> { |
| 174 | 184 | } = item; |
| 175 | 185 | let profile = user_href(&login); |
| 176 | 186 | let class = if accepted { |
| 177 | | - "issue-item discussion-accepted" |
| 187 | + "sec discussion-accepted" |
| 178 | 188 | } else { |
| 179 | | - "issue-item" |
| 189 | + "sec" |
| 180 | 190 | }; |
| 191 | + let answer_fields = vec![ |
| 192 | + ("comment_id".to_owned(), id.clone()), |
| 193 | + ("answer".to_owned(), answer_value.to_owned()), |
| 194 | + ]; |
| 195 | + let reply_id = format!("reply-{id}"); |
| 196 | + let reply_open = format!("reply-open-{id}"); |
| 197 | + let edit_id = format!("edit-{id}"); |
| 198 | + let edit_open = format!("edit-open-{id}"); |
| 181 | 199 | Ok(view! { |
| 182 | 200 | <article class=(class) id=(anchor.as_str())> |
| 183 | | - <header class="issue-item-head"> |
| 201 | + <p class="state"> |
| 184 | 202 | if deleted { |
| 185 | | - <span class="muted">(g::t(lang, K::CommentDeleted))</span> |
| 203 | + (g::t(lang, K::CommentDeleted)) |
| 186 | 204 | } else { |
| 187 | 205 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> |
| 188 | | - <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> |
| 189 | | - <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> |
| 206 | + " " user_link(shown: author.as_str(), login: login.as_str()) |
| 207 | + " " <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> |
| 190 | 208 | } |
| 191 | 209 | if accepted { |
| 192 | | - <span class="issue-badge issue-badge-completed">(g::t(lang, K::Answer))</span> |
| 210 | + " · " (g::t(lang, K::Answer)) |
| 193 | 211 | } |
| 194 | | - </header> |
| 212 | + </p> |
| 195 | 213 | if !deleted { |
| 196 | | - <div class="issue-item-body markdown-body">(Unescaped::new_unchecked(html))</div> |
| 214 | + <div class="markdown-body">(Unescaped::new_unchecked(html))</div> |
| 197 | 215 | if let Some(bar) = reactions { |
| 198 | 216 | reaction_row(lang: lang, bar: bar) |
| 199 | 217 | } |
| 200 | | - <div class="discussion-actions"> |
| 218 | + <div class="acts"> |
| 201 | 219 | if let Some(action) = answer_action { |
| 202 | | - <form method="post" action=(action.as_str())> |
| 203 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 204 | | - <input type="hidden" name="comment_id" value=(id.as_str())> |
| 205 | | - <input type="hidden" name="answer" value=(answer_value)> |
| 206 | | - <button type="submit" class="link-button">(answer_label)</button> |
| 207 | | - </form> |
| 220 | + post_act(label: answer_label, action: action.as_str(), csrf: csrf.as_str(), fields: answer_fields) |
| 208 | 221 | } |
| 209 | 222 | if let Some(action) = reply_action { |
| 210 | | - <details class="discussion-reply"> |
| 211 | | - <summary>(g::t(lang, K::Reply))</summary> |
| 212 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 223 | + reveal(label: g::t(lang, K::Reply), id: Some(reply_open.as_str()), |
| 224 | + <form method="post" action=(action.as_str()) class="fields"> |
| 213 | 225 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 214 | 226 | <input type="hidden" name="parent" value=(id.as_str())> |
| 215 | | - <textarea name="body" rows="4" aria-label=(g::t(lang, K::Reply))></textarea> |
| 216 | | - <div><button type="submit">(g::t(lang, K::Reply))</button></div> |
| 227 | + <div class="field"> |
| 228 | + <label for=(reply_id.as_str())>(g::t(lang, K::Reply))</label> |
| 229 | + <textarea id=(reply_id.as_str()) name="body" rows="4"></textarea> |
| 230 | + </div> |
| 231 | + <button type="submit" class="primary">(g::t(lang, K::Reply))</button> |
| 217 | 232 | </form> |
| 218 | | - </details> |
| 233 | + ) |
| 219 | 234 | } |
| 220 | 235 | if let Some(action) = edit_action { |
| 221 | | - <details class="discussion-reply"> |
| 222 | | - <summary>(g::t(lang, K::Edit))</summary> |
| 223 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 236 | + reveal(label: g::t(lang, K::Edit), id: Some(edit_open.as_str()), |
| 237 | + <form method="post" action=(action.as_str()) class="fields"> |
| 224 | 238 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 225 | | - <textarea name="body" rows="6" aria-label=(g::t(lang, K::EditComment))>(raw.as_str())</textarea> |
| 226 | | - <div><button type="submit">(g::t(lang, K::Save))</button></div> |
| 239 | + <div class="field"> |
| 240 | + <label for=(edit_id.as_str())>(g::t(lang, K::EditComment))</label> |
| 241 | + <textarea id=(edit_id.as_str()) name="body" rows="6">(raw.as_str())</textarea> |
| 242 | + </div> |
| 243 | + <button type="submit" class="primary">(g::t(lang, K::Save))</button> |
| 227 | 244 | </form> |
| 228 | | - </details> |
| 245 | + ) |
| 229 | 246 | } |
| 230 | 247 | if let Some(action) = delete_action { |
| 231 | | - <form method="post" action=(action.as_str())> |
| 232 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 233 | | - <button type="submit" class="link-button">(g::t(lang, K::Delete))</button> |
| 234 | | - </form> |
| 248 | + confirm_act(lang: lang, label: g::t(lang, K::Delete), action: action.as_str(), csrf: csrf.as_str()) |
| 235 | 249 | } |
| 236 | 250 | </div> |
| 237 | 251 | } |
| | @@ -403,93 +417,83 @@ async fn discussion_page( |
| 403 | 417 | Ok(view! { cx => |
| 404 | 418 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 405 | 419 | repo_head(head: header) |
| 406 | | - <section class="issue-head" data-live=(live_href.as_str()) data-live-now=""> |
| 407 | | - <h1 class="issue-heading">(discussion.title.as_str()) " " <span class="issue-number">(number_label.as_str())</span></h1> |
| 408 | | - <p class="issue-byline"> |
| 409 | | - <span class="discussion-category">(category)</span> |
| 420 | + <section class="sec" data-live=(live_href.as_str()) data-live-now=""> |
| 421 | + <h1 class="h1">(discussion.title.as_str()) " " <span class="hint">(number_label.as_str())</span></h1> |
| 422 | + <p class="hint"> |
| 423 | + (category) |
| 410 | 424 | if answered { |
| 411 | | - " " <span class="issue-badge issue-badge-completed">(g::t(lang, K::Answered))</span> |
| 425 | + " " (g::t(lang, K::Answered)) |
| 412 | 426 | } |
| 413 | 427 | if locked { |
| 414 | | - " " <span class="issue-badge">(g::t(lang, K::Locked))</span> |
| 428 | + " " (g::t(lang, K::Locked)) |
| 415 | 429 | } |
| 416 | | - " " <strong>user_link(shown: author.as_str(), login: author_login.as_str())</strong> |
| 417 | | - (g::t(lang, K::OpenedThis)) |
| 430 | + " " user_link(shown: author.as_str(), login: author_login.as_str()) |
| 431 | + " " (g::t(lang, K::OpenedThis)) " " |
| 418 | 432 | <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> |
| 419 | | - (g::t(lang, K::OpenedSeparator)) |
| 433 | + " " (g::t(lang, K::OpenedSeparator)) " " |
| 420 | 434 | (comments_label.as_str()) |
| 421 | 435 | </p> |
| 422 | 436 | </section> |
| 423 | | - <div class="issue-layout"> |
| 424 | | - <div class="issue-column fit-pane"> |
| 425 | | - <article class="issue-item" id="discussion-body"> |
| 426 | | - <header class="issue-item-head"> |
| 427 | | - <a href=(author_profile.as_str()) aria-label=(author.as_str())><img class="avatar avatar-sm" src=(author_avatar.as_str()) alt="" width="24" height="24"></a> |
| 428 | | - <strong>user_link(shown: author.as_str(), login: author_login.as_str())</strong> |
| 429 | | - </header> |
| 430 | | - <div class="issue-item-body markdown-body">(Unescaped::new_unchecked(body_html))</div> |
| 431 | | - if let Some(bar) = body_bar { |
| 432 | | - reaction_row(lang: lang, bar: bar) |
| 433 | | - } |
| 434 | | - if body_mine_actions { |
| 435 | | - <div class="discussion-actions"> |
| 436 | | - <details class="discussion-reply"> |
| 437 | | - <summary>(g::t(lang, K::Edit))</summary> |
| 438 | | - <form method="post" action=(edit_action.as_str()) class="stack"> |
| 439 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 440 | | - <label><span>(g::t(lang, K::Title))</span> |
| 441 | | - <input type="text" name="title" value=(discussion.title.as_str()) required=(true) autocomplete="off"> |
| 442 | | - </label> |
| 443 | | - <label><span>(g::t(lang, K::Description))</span> |
| 444 | | - <textarea name="body" rows="8">(discussion.body.as_str())</textarea> |
| 445 | | - </label> |
| 446 | | - <div><button type="submit">(g::t(lang, K::Save))</button></div> |
| 447 | | - </form> |
| 448 | | - </details> |
| 449 | | - <form method="post" action=(delete_action.as_str()) class="inline-form"> |
| 450 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 451 | | - <button type="submit" class="link-button">(g::t(lang, K::DeleteDiscussion))</button> |
| 452 | | - </form> |
| 453 | | - </div> |
| 454 | | - } |
| 455 | | - </article> |
| 456 | | - for thread in threads.into_iter() { |
| 457 | | - comment_thread(root: thread.root, replies: thread.replies) |
| 458 | | - } |
| 459 | | - if can_converse { |
| 460 | | - <section class="card"> |
| 461 | | - <form method="post" action=(comment_action.as_str()) class="stack"> |
| 462 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 463 | | - <label> |
| 464 | | - <span>(g::t(lang, K::AddComment))</span> |
| 465 | | - <textarea name="body" rows="6"></textarea> |
| 466 | | - <span class="muted small">(g::t(lang, K::MarkdownSupported))</span> |
| 467 | | - </label> |
| 468 | | - <div><button type="submit" class="primary">(g::t(lang, K::CommentButton))</button></div> |
| 469 | | - </form> |
| 470 | | - </section> |
| 471 | | - } else if locked && signed_in && !archived { |
| 472 | | - <p class="muted">(lock_notice)</p> |
| 473 | | - } else if !signed_in { |
| 474 | | - <p class="muted">(g::comment_login_lead(lang))<a href=(login_href.as_str())>(g::t(lang, K::LogInLink))</a>(g::t(lang, K::ToCommentSuffix))</p> |
| 475 | | - } |
| 476 | | - if archived { |
| 477 | | - <p class="muted">(g::t(lang, K::ArchivedDiscussions))</p> |
| 478 | | - } |
| 479 | | - </div> |
| 480 | | - <aside class="issue-sidebar fit-pane"> |
| 481 | | - if triage && !archived { |
| 482 | | - <section class="card"> |
| 483 | | - <h2>(g::t(lang, K::Conversation))</h2> |
| 484 | | - <form method="post" action=(lock_action.as_str()) class="stack"> |
| 437 | + <article class="sec" id="discussion-body"> |
| 438 | + <p class="state"> |
| 439 | + <a href=(author_profile.as_str()) aria-label=(author.as_str())><img class="avatar avatar-sm" src=(author_avatar.as_str()) alt="" width="24" height="24"></a> |
| 440 | + " " user_link(shown: author.as_str(), login: author_login.as_str()) |
| 441 | + </p> |
| 442 | + <div class="markdown-body">(Unescaped::new_unchecked(body_html))</div> |
| 443 | + if let Some(bar) = body_bar { |
| 444 | + reaction_row(lang: lang, bar: bar) |
| 445 | + } |
| 446 | + if body_mine_actions { |
| 447 | + <div class="acts"> |
| 448 | + reveal(label: g::t(lang, K::Edit), id: Some("edit-open"), |
| 449 | + <form method="post" action=(edit_action.as_str()) class="fields"> |
| 485 | 450 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 486 | | - <input type="hidden" name="locked" value=(lock_value)> |
| 487 | | - <button type="submit">(lock_label)</button> |
| 451 | + <div class="field"> |
| 452 | + <label for="edit-title">(g::t(lang, K::Title))</label> |
| 453 | + <input id="edit-title" type="text" name="title" value=(discussion.title.as_str()) required=(true) autocomplete="off"> |
| 454 | + </div> |
| 455 | + <div class="field"> |
| 456 | + <label for="edit-body">(g::t(lang, K::Description))</label> |
| 457 | + <textarea id="edit-body" name="body" rows="8">(discussion.body.as_str())</textarea> |
| 458 | + </div> |
| 459 | + <button type="submit" class="primary">(g::t(lang, K::Save))</button> |
| 488 | 460 | </form> |
| 489 | | - </section> |
| 490 | | - } |
| 491 | | - </aside> |
| 492 | | - </div> |
| 461 | + ) |
| 462 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteDiscussion), action: delete_action.as_str(), csrf: csrf.as_str(), note: Some(delete_note(lang).to_owned())) |
| 463 | + </div> |
| 464 | + } |
| 465 | + </article> |
| 466 | + for thread in threads.into_iter() { |
| 467 | + comment_thread(root: thread.root, replies: thread.replies) |
| 468 | + } |
| 469 | + if can_converse { |
| 470 | + <section class="sec"> |
| 471 | + <form method="post" action=(comment_action.as_str()) class="fields"> |
| 472 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 473 | + <div class="field"> |
| 474 | + <label for="new-comment">(g::t(lang, K::AddComment))</label> |
| 475 | + <textarea id="new-comment" name="body" rows="6"></textarea> |
| 476 | + <p class="hint">(g::t(lang, K::MarkdownSupported))</p> |
| 477 | + </div> |
| 478 | + <button type="submit" class="primary">(g::t(lang, K::CommentButton))</button> |
| 479 | + </form> |
| 480 | + </section> |
| 481 | + } else if locked && signed_in && !archived { |
| 482 | + <p class="state">(lock_notice)</p> |
| 483 | + } else if !signed_in { |
| 484 | + <p class="state">(g::comment_login_lead(lang))<a href=(login_href.as_str())>(g::t(lang, K::LogInLink))</a>(g::t(lang, K::ToCommentSuffix))</p> |
| 485 | + } |
| 486 | + if archived { |
| 487 | + <p class="state">(g::t(lang, K::ArchivedDiscussions))</p> |
| 488 | + } |
| 489 | + if triage && !archived { |
| 490 | + <section class="sec"> |
| 491 | + <h2>(g::t(lang, K::Conversation))</h2> |
| 492 | + <div class="acts"> |
| 493 | + post_act(label: lock_label, action: lock_action.as_str(), csrf: csrf.as_str(), fields: vec![("locked".to_owned(), lock_value.to_owned())]) |
| 494 | + </div> |
| 495 | + </section> |
| 496 | + } |
| 493 | 497 | ) |
| 494 | 498 | }) |
| 495 | 499 | } |
| | @@ -22,12 +22,12 @@ use crate::i18n::{self, Lang}; |
| 22 | 22 | use crate::pages::discussion_live::list_live_url; |
| 23 | 23 | use crate::pages::issue_meta::{can_triage, form_field, form_pairs, refusal_message}; |
| 24 | 24 | use crate::pages::issue_parts::When; |
| 25 | | -use crate::pages::issues_list::{list_href, state_tab_class}; |
| 25 | +use crate::pages::issues_list::{list_href, state_tab}; |
| 26 | 26 | use crate::pages::repo::repo_head; |
| 27 | 27 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 28 | 28 | use crate::render::markdown::mentioned_usernames; |
| 29 | 29 | use crate::state::AppState; |
| 30 | | -use crate::views::{alert, csrf_field, empty_state, now_unix, repo_href, shell, user_link}; |
| 30 | +use crate::views::{alert, csrf_field, now_unix, repo_href, shell, user_link}; |
| 31 | 31 | |
| 32 | 32 | path_param!(owner); |
| 33 | 33 | path_param!(repo); |
| | @@ -260,17 +260,17 @@ async fn discussions_list_page(cx: &Cx) -> Result<impl View> { |
| 260 | 260 | |
| 261 | 261 | let base = discussions_href(&owner_name, &repo_name, ""); |
| 262 | 262 | let selected = category.map_or("", |c| c.as_str()); |
| 263 | | - let all_class = state_tab_class(category.is_none()); |
| 263 | + let all_on = category.is_none(); |
| 264 | 264 | let all_href = list_href(&base, &[]); |
| 265 | 265 | let all_label = g::t(lang, K::AllCategories); |
| 266 | 266 | let nav_label = g::t(lang, K::CategoriesNav); |
| 267 | | - let tabs: Vec<(&'static str, String, &'static str)> = DISCUSSION_CATEGORIES |
| 267 | + let tabs: Vec<(&'static str, String, bool)> = DISCUSSION_CATEGORIES |
| 268 | 268 | .iter() |
| 269 | 269 | .map(|c| { |
| 270 | 270 | ( |
| 271 | 271 | g::category_label(lang, *c), |
| 272 | 272 | list_href(&base, &[("category", c.as_str())]), |
| 273 | | - state_tab_class(category == Some(*c)), |
| 273 | + category == Some(*c), |
| 274 | 274 | ) |
| 275 | 275 | }) |
| 276 | 276 | .collect(); |
| | @@ -303,30 +303,30 @@ async fn discussions_list_page(cx: &Cx) -> Result<impl View> { |
| 303 | 303 | Ok(view! { |
| 304 | 304 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 305 | 305 | repo_head(head: header) |
| 306 | | - <section class="issue-pane fit-pane"> |
| 307 | | - <div class="issue-toolbar" data-live=(live_href.as_str()) data-live-now=""> |
| 308 | | - <nav class="issue-tabs" aria-label=(nav_label)> |
| 309 | | - <a class=(all_class) href=(all_href.as_str())>(all_label)</a> |
| 310 | | - for tab in tabs.iter() { |
| 311 | | - <a class=(tab.2) href=(tab.1.as_str())>(tab.0)</a> |
| 312 | | - } |
| 313 | | - </nav> |
| 306 | + <div data-live=(live_href.as_str()) data-live-now=""> |
| 307 | + <h1 class="sr-only">(title.as_str())</h1> |
| 308 | + <nav class="tabs" aria-label=(nav_label)> |
| 309 | + state_tab(href: all_href.as_str(), text: all_label, current: all_on) |
| 310 | + for tab in tabs.iter() { |
| 311 | + state_tab(href: tab.1.as_str(), text: tab.0, current: tab.2) |
| 312 | + } |
| 313 | + </nav> |
| 314 | + if can_start { |
| 315 | + <div class="sub"> |
| 316 | + <a class="act" href=(new_href.as_str())>(new_label)</a> |
| 317 | + </div> |
| 318 | + } |
| 319 | + if rows.is_empty() { |
| 320 | + <p class="state">(empty_text)</p> |
| 314 | 321 | if can_start { |
| 315 | | - <div class="issue-tools"> |
| 316 | | - <a class="button" href=(new_href.as_str())>(new_label)</a> |
| 322 | + <div class="acts"> |
| 323 | + <a class="act" href=(new_href.as_str())>(new_label)</a> |
| 317 | 324 | </div> |
| 318 | 325 | } |
| 319 | | - </div> |
| 320 | | - if rows.is_empty() { |
| 321 | | - empty_state(title: empty_text, |
| 322 | | - if can_start { |
| 323 | | - <a class="button primary" href=(new_href.as_str())>(new_label)</a> |
| 324 | | - } |
| 325 | | - ) |
| 326 | 326 | } else { |
| 327 | | - <ul class="issue-list"> |
| 327 | + <div> |
| 328 | 328 | for row in rows.iter() { |
| 329 | | - <li class="issue-row"> |
| 329 | + <div class="line issue-row" data-kb-row=""> |
| 330 | 330 | <div class="issue-main"> |
| 331 | 331 | <div class="issue-title-line"> |
| 332 | 332 | <a class="issue-title" href=(row.href.as_str())>(row.title.as_str())</a> |
| | @@ -340,27 +340,25 @@ async fn discussions_list_page(cx: &Cx) -> Result<impl View> { |
| 340 | 340 | if !by_after.is_empty() { |
| 341 | 341 | <span>(by_after)</span> |
| 342 | 342 | } |
| 343 | + <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> |
| 343 | 344 | </div> |
| 344 | 345 | </div> |
| 345 | | - <div class="issue-aside"> |
| 346 | | - <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> |
| 347 | | - </div> |
| 348 | | - </li> |
| 346 | + </div> |
| 349 | 347 | } |
| 350 | | - </ul> |
| 348 | + </div> |
| 351 | 349 | } |
| 352 | 350 | if has_newer || has_older { |
| 353 | | - <nav class="pager"> |
| 351 | + <nav class="sub"> |
| 354 | 352 | if has_newer { |
| 355 | 353 | <a href=(newer_href.as_str())>(newer_label)</a> |
| 356 | 354 | } |
| 357 | | - <span class="muted small">(page_label.as_str())</span> |
| 355 | + <span>(page_label.as_str())</span> |
| 358 | 356 | if has_older { |
| 359 | 357 | <a href=(older_href.as_str())>(older_label)</a> |
| 360 | 358 | } |
| 361 | 359 | </nav> |
| 362 | 360 | } |
| 363 | | - </section> |
| 361 | + </div> |
| 364 | 362 | ) |
| 365 | 363 | }) |
| 366 | 364 | } |
| | @@ -385,36 +383,34 @@ async fn new_discussion_body( |
| 385 | 383 | let cancel = discussions_href(&head.owner, &head.name, ""); |
| 386 | 384 | Ok(view! { |
| 387 | 385 | repo_head(head: head) |
| 388 | | - <section class="card issue-new"> |
| 389 | | - <h2>(g::t(lang, K::NewDiscussion))</h2> |
| 390 | | - if let Some(message) = draft.error { |
| 391 | | - alert(message: message.as_str()) |
| 392 | | - } |
| 393 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 394 | | - csrf_field(token: csrf.as_str()) |
| 395 | | - <label> |
| 396 | | - <span>(g::t(lang, K::Category))</span> |
| 397 | | - <select name="category"> |
| 398 | | - for option in options.iter() { |
| 399 | | - <option value=(option.value) selected=(option.selected)>(option.label)</option> |
| 400 | | - } |
| 401 | | - </select> |
| 402 | | - </label> |
| 403 | | - <label> |
| 404 | | - <span>(g::t(lang, K::Title))</span> |
| 405 | | - <input type="text" name="title" value=(draft.title.as_str()) required=(true) autocomplete="off"> |
| 406 | | - </label> |
| 407 | | - <label> |
| 408 | | - <span>(g::t(lang, K::Description))</span> |
| 409 | | - <textarea name="body" rows="12">(draft.body.as_str())</textarea> |
| 410 | | - <span class="muted small">(g::t(lang, K::MarkdownSupported))</span> |
| 411 | | - </label> |
| 412 | | - <div class="issue-actions"> |
| 413 | | - <button type="submit" class="primary">(g::t(lang, K::StartDiscussion))</button> |
| 414 | | - <a href=(cancel.as_str())>(g::t(lang, K::Cancel))</a> |
| 415 | | - </div> |
| 416 | | - </form> |
| 417 | | - </section> |
| 386 | + <h1 class="sr-only">(g::t(lang, K::NewDiscussion))</h1> |
| 387 | + if let Some(message) = draft.error { |
| 388 | + alert(message: message.as_str()) |
| 389 | + } |
| 390 | + <form method="post" action=(action.as_str()) class="fields"> |
| 391 | + csrf_field(token: csrf.as_str()) |
| 392 | + <div class="field"> |
| 393 | + <label for="discussion-category">(g::t(lang, K::Category))</label> |
| 394 | + <select id="discussion-category" name="category"> |
| 395 | + for option in options.iter() { |
| 396 | + <option value=(option.value) selected=(option.selected)>(option.label)</option> |
| 397 | + } |
| 398 | + </select> |
| 399 | + </div> |
| 400 | + <div class="field"> |
| 401 | + <label for="discussion-title">(g::t(lang, K::Title))</label> |
| 402 | + <input id="discussion-title" type="text" name="title" value=(draft.title.as_str()) required=(true) autocomplete="off"> |
| 403 | + </div> |
| 404 | + <div class="field"> |
| 405 | + <label for="discussion-body">(g::t(lang, K::Description))</label> |
| 406 | + <textarea id="discussion-body" name="body" rows="12">(draft.body.as_str())</textarea> |
| 407 | + <p class="hint">(g::t(lang, K::MarkdownSupported))</p> |
| 408 | + </div> |
| 409 | + <div class="acts"> |
| 410 | + <button type="submit" class="primary">(g::t(lang, K::StartDiscussion))</button> |
| 411 | + <a class="act quiet" href=(cancel.as_str())>(g::t(lang, K::Cancel))</a> |
| 412 | + </div> |
| 413 | + </form> |
| 418 | 414 | }) |
| 419 | 415 | } |
| 420 | 416 | |
| | @@ -237,17 +237,17 @@ async fn history_page( |
| 237 | 237 | Ok(view! { cx => |
| 238 | 238 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 239 | 239 | repo_head(head: header) |
| 240 | | - <section class="issue-head" data-live=(live.as_str()) data-live-now=""> |
| 241 | | - <h1 class="issue-heading">(heading.as_str())</h1> |
| 242 | | - <p class="issue-byline"> |
| 240 | + <section class="sec" data-live=(live.as_str()) data-live-now=""> |
| 241 | + <h1 class="h1">(heading.as_str())</h1> |
| 242 | + <p class="hint"> |
| 243 | 243 | <a href=(back.as_str())>(back_label.as_str())</a> |
| 244 | 244 | " · " |
| 245 | 245 | (count_label.as_str()) |
| 246 | 246 | </p> |
| 247 | 247 | </section> |
| 248 | | - <div class="issue-timeline fit-pane"> |
| 248 | + <div class="issue-timeline"> |
| 249 | 249 | if entries.is_empty() { |
| 250 | | - <p class="muted">(g::t(lang, K::NoEarlierVersions))</p> |
| 250 | + <p class="hint">(g::t(lang, K::NoEarlierVersions))</p> |
| 251 | 251 | } |
| 252 | 252 | for entry in entries.into_iter() { |
| 253 | 253 | history_entry(lang: lang, entry: entry) |
| | @@ -270,8 +270,8 @@ async fn history_entry(lang: Lang, entry: HistoryEntry) -> Result<impl View> { |
| 270 | 270 | } = entry; |
| 271 | 271 | let title_text = title_change.map(|(from, to)| g::title_change(lang, &from, &to)); |
| 272 | 272 | Ok(view! { |
| 273 | | - <article class="issue-item"> |
| 274 | | - <header class="issue-item-head"> |
| 273 | + <article class="thread-entry"> |
| 274 | + <header class="thread-head"> |
| 275 | 275 | <strong>(editor.as_str())</strong> |
| 276 | 276 | (g::t(lang, K::EditedBy)) |
| 277 | 277 | <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> |
| | @@ -281,7 +281,7 @@ async fn history_entry(lang: Lang, entry: HistoryEntry) -> Result<impl View> { |
| 281 | 281 | <p class="mono">(text.as_str())</p> |
| 282 | 282 | } |
| 283 | 283 | if body_unchanged { |
| 284 | | - <p class="muted">(g::t(lang, K::NoTextChange))</p> |
| 284 | + <p class="hint">(g::t(lang, K::NoTextChange))</p> |
| 285 | 285 | } else { |
| 286 | 286 | <div class="diff-file"> |
| 287 | 287 | <div class="diff-file-body"> |
| | @@ -297,9 +297,11 @@ async fn history_entry(lang: Lang, entry: HistoryEntry) -> Result<impl View> { |
| 297 | 297 | </div> |
| 298 | 298 | </div> |
| 299 | 299 | } |
| 300 | | - <details> |
| 301 | | - <summary>(g::t(lang, K::Raw))</summary> |
| 302 | | - <pre class="review-hunk"><code>(raw.as_str())</code></pre> |
| 300 | + <details class="reveal"> |
| 301 | + <summary class="act">(g::t(lang, K::Raw))</summary> |
| 302 | + <div class="opened"> |
| 303 | + <pre class="review-hunk"><code>(raw.as_str())</code></pre> |
| 304 | + </div> |
| 303 | 305 | </details> |
| 304 | 306 | </article> |
| 305 | 307 | }) |
| | @@ -18,7 +18,7 @@ use crate::state::AppState; |
| 18 | 18 | use crate::views::repo_list::{ |
| 19 | 19 | PageLink, RepoRow, SortLink, pager, pager_links, repo_rows, sort_chips, |
| 20 | 20 | }; |
| 21 | | -use crate::views::{empty_state, enc, now_unix, shell}; |
| 21 | +use crate::views::{enc, now_unix, shell}; |
| 22 | 22 | |
| 23 | 23 | const PER_PAGE: u64 = 30; |
| 24 | 24 | /// Longest search text kept, in characters. |
| | @@ -199,42 +199,40 @@ async fn explore_body( |
| 199 | 199 | let (links, prev, next) = nav; |
| 200 | 200 | let clear_href = explore_href("", sort, 1); |
| 201 | 201 | Ok(view! { |
| 202 | | - <section class="page-head"> |
| 203 | | - <h1>(g::t(lang, K::Explore))</h1> |
| 204 | | - <p class="muted small page-note">(g::t(lang, K::PublicReposIntro))</p> |
| 205 | | - </section> |
| 206 | | - <section class="explore list-pane fit-pane" data-live=(live.as_str())> |
| 207 | | - if has_orgs { |
| 208 | | - <section class="explore-orgs"> |
| 209 | | - <h2>(g::t(lang, K::Organizations))</h2> |
| 210 | | - <ul class="item-list"> |
| 211 | | - for org in orgs.iter() { |
| 212 | | - <li><a href=(format!("/{}", org.as_str()))>(org.as_str())</a></li> |
| 213 | | - } |
| 214 | | - </ul> |
| 215 | | - </section> |
| 216 | | - } |
| 217 | | - <div class="explore-toolbar"> |
| 218 | | - <form method="get" action="/explore" class="explore-search" role="search"> |
| 219 | | - <input type="search" name="q" value=(q.as_str()) data-live-search="" |
| 220 | | - placeholder=(g::t(lang, K::SearchPublicRepos)) aria-label=(g::t(lang, K::SearchPublicRepos))> |
| 221 | | - <input type="hidden" name="sort" value=(sort)> |
| 222 | | - <button type="submit">(g::t(lang, K::Search))</button> |
| 223 | | - </form> |
| 224 | | - <div class="repo-subbar"> |
| 225 | | - sort_chips(links: sort_links, lang: lang) |
| 226 | | - <p class="muted small repo-count">(g::repo_count(lang, total))</p> |
| 227 | | - </div> |
| 202 | + <h1 class="sr-only">(g::t(lang, K::Explore))</h1> |
| 203 | + <section class="explore" data-live=(live.as_str())> |
| 204 | + <p class="hint">(g::t(lang, K::PublicReposIntro))</p> |
| 205 | + <form method="get" action="/explore" class="plain-search" role="search"> |
| 206 | + <input type="search" name="q" value=(q.as_str()) data-live-search="" |
| 207 | + placeholder=(g::t(lang, K::SearchPublicRepos)) aria-label=(g::t(lang, K::SearchPublicRepos))> |
| 208 | + <input type="hidden" name="sort" value=(sort)> |
| 209 | + <button type="submit" class="act">(g::t(lang, K::Search))</button> |
| 210 | + </form> |
| 211 | + <div class="sub"> |
| 212 | + sort_chips(links: sort_links, lang: lang) |
| 213 | + <span>(g::repo_count(lang, total))</span> |
| 228 | 214 | </div> |
| 229 | 215 | if empty { |
| 230 | | - empty_state(title: g::t(lang, K::NoPublicReposMatch), |
| 231 | | - if has_search { |
| 232 | | - <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearSearch))</a> |
| 233 | | - }) |
| 216 | + <p class="state">(g::t(lang, K::NoPublicReposMatch))</p> |
| 217 | + if has_search { |
| 218 | + <div class="acts"> |
| 219 | + <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearSearch))</a> |
| 220 | + </div> |
| 221 | + } |
| 234 | 222 | } else { |
| 235 | 223 | repo_rows(rows: rows, lang: lang) |
| 236 | 224 | } |
| 237 | 225 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 226 | + if has_orgs { |
| 227 | + <section class="sec"> |
| 228 | + <h2>(g::t(lang, K::Organizations))</h2> |
| 229 | + <div> |
| 230 | + for org in orgs.iter() { |
| 231 | + <a class="line" href=(format!("/{}", org.as_str()))><span class="name">(org.as_str())</span></a> |
| 232 | + } |
| 233 | + </div> |
| 234 | + </section> |
| 235 | + } |
| 238 | 236 | </section> |
| 239 | 237 | }) |
| 240 | 238 | } |
| | @@ -36,7 +36,7 @@ pub async fn file_finder( |
| 36 | 36 | let src = repo_href(&owner, &repo, "paths", &ref_name); |
| 37 | 37 | let base = format!("{}/", repo_href(&owner, &repo, "blob", &ref_name)); |
| 38 | 38 | Ok(view! { |
| 39 | | - <button type="button" class="button finder-open" data-finder-open="" data-palette-action="click" title=(b::t(lang, b::K::FinderHint))> |
| 39 | + <button type="button" class="act finder-open" data-finder-open="" data-palette-action="click" title=(b::t(lang, b::K::FinderHint))> |
| 40 | 40 | <span class="finder-label">(b::t(lang, b::K::GoToFile))</span> |
| 41 | 41 | <kbd>"t"</kbd> |
| 42 | 42 | </button> |
| | @@ -49,7 +49,7 @@ pub async fn file_finder( |
| 49 | 49 | placeholder=(b::t(lang, b::K::FinderPlaceholder)) aria-label=(b::t(lang, b::K::FinderPlaceholder)) |
| 50 | 50 | role="combobox" aria-expanded="true" aria-controls="finder-list" aria-autocomplete="list"> |
| 51 | 51 | <ul id="finder-list" class="finder-list" role="listbox" data-finder-list=""></ul> |
| 52 | | - <p class="finder-note muted small" data-finder-note="">(b::t(lang, b::K::FinderHint))</p> |
| 52 | + <p class="finder-note hint" data-finder-note="">(b::t(lang, b::K::FinderHint))</p> |
| 53 | 53 | </div> |
| 54 | 54 | </dialog> |
| 55 | 55 | }) |
| | @@ -58,15 +58,15 @@ enum ResetMode { |
| 58 | 58 | #[component] |
| 59 | 59 | async fn forgot_form(lang: Lang, precsrf: &str) -> Result<impl View> { |
| 60 | 60 | Ok(view! { |
| 61 | | - <section class="card narrow"> |
| 61 | + <section> |
| 62 | 62 | <h1>(t(lang, Key::ForgotTitle))</h1> |
| 63 | | - <p class="muted">(t(lang, Key::ForgotSub))</p> |
| 64 | | - <form data-hard="true" method="post" action="/forgot" class="stack"> |
| 63 | + <p class="hint">(t(lang, Key::ForgotSub))</p> |
| 64 | + <form data-hard="true" method="post" action="/forgot" class="fields"> |
| 65 | 65 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 66 | | - <label> |
| 67 | | - <span>(t(lang, Key::Email))</span> |
| 68 | | - <input type="email" name="email" autocomplete="email" maxlength="254" required=(true)> |
| 69 | | - </label> |
| 66 | + <div class="field"> |
| 67 | + <label for="forgot-email">(t(lang, Key::Email))</label> |
| 68 | + <input id="forgot-email" type="email" name="email" autocomplete="email" maxlength="254" required=(true)> |
| 69 | + </div> |
| 70 | 70 | <button type="submit" class="primary">(t(lang, Key::ForgotSubmit))</button> |
| 71 | 71 | </form> |
| 72 | 72 | </section> |
| | @@ -76,11 +76,9 @@ async fn forgot_form(lang: Lang, precsrf: &str) -> Result<impl View> { |
| 76 | 76 | #[component] |
| 77 | 77 | async fn forgot_sent(lang: Lang) -> Result<impl View> { |
| 78 | 78 | Ok(view! { |
| 79 | | - <section class="card narrow"> |
| 79 | + <section> |
| 80 | 80 | <h1>(t(lang, Key::ForgotTitle))</h1> |
| 81 | | - <section class="card notice" role="status"> |
| 82 | | - <p>(t(lang, Key::ForgotSent))</p> |
| 83 | | - </section> |
| 81 | + <p class="state" role="status">(t(lang, Key::ForgotSent))</p> |
| 84 | 82 | </section> |
| 85 | 83 | }) |
| 86 | 84 | } |
| | @@ -152,34 +150,38 @@ async fn reset_body( |
| 152 | 150 | error: Option<String>, |
| 153 | 151 | ) -> Result<impl View> { |
| 154 | 152 | Ok(view! { |
| 155 | | - <section class="card narrow"> |
| 153 | + <section> |
| 156 | 154 | <h1>(t(lang, Key::ResetTitle))</h1> |
| 157 | 155 | if mode == ResetMode::Form { |
| 158 | | - <p class="muted">(t(lang, Key::ResetSub))</p> |
| 159 | | - if let Some(message) = error { |
| 160 | | - alert(message: message.as_str()) |
| 161 | | - } |
| 162 | | - <form data-hard="true" method="post" action=(format!("/reset/{token}")) class="stack"> |
| 156 | + <p class="hint">(t(lang, Key::ResetSub))</p> |
| 157 | + <form data-hard="true" method="post" action=(format!("/reset/{token}")) class="fields"> |
| 158 | + if let Some(message) = error { |
| 159 | + alert(message: message.as_str()) |
| 160 | + } |
| 163 | 161 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 164 | | - <label> |
| 165 | | - <span>(t(lang, Key::NewPassword))</span> |
| 166 | | - <input type="password" name="password" autocomplete="new-password" required=(true)> |
| 167 | | - <small class="muted">(t(lang, Key::AtLeast12Chars))</small> |
| 168 | | - </label> |
| 169 | | - <label> |
| 170 | | - <span>(t(lang, Key::ConfirmNewPassword))</span> |
| 171 | | - <input type="password" name="confirm" autocomplete="new-password" required=(true)> |
| 172 | | - </label> |
| 162 | + <div class="field"> |
| 163 | + <label for="reset-password">(t(lang, Key::NewPassword))</label> |
| 164 | + <input id="reset-password" type="password" name="password" autocomplete="new-password" required=(true)> |
| 165 | + <p class="hint">(t(lang, Key::AtLeast12Chars))</p> |
| 166 | + </div> |
| 167 | + <div class="field"> |
| 168 | + <label for="reset-confirm">(t(lang, Key::ConfirmNewPassword))</label> |
| 169 | + <input id="reset-confirm" type="password" name="confirm" autocomplete="new-password" required=(true)> |
| 170 | + </div> |
| 173 | 171 | <button type="submit" class="primary">(t(lang, Key::ResetSubmit))</button> |
| 174 | 172 | </form> |
| 175 | 173 | } |
| 176 | 174 | if mode == ResetMode::Invalid { |
| 177 | | - <p class="muted">(t(lang, Key::ResetInvalid))</p> |
| 178 | | - <p><a href="/forgot">(t(lang, Key::ForgotTitle))</a></p> |
| 175 | + <p class="state">(t(lang, Key::ResetInvalid))</p> |
| 176 | + <div class="acts"> |
| 177 | + <a class="act" href="/forgot">(t(lang, Key::ForgotTitle))</a> |
| 178 | + </div> |
| 179 | 179 | } |
| 180 | 180 | if mode == ResetMode::Done { |
| 181 | | - <p>(t(lang, Key::ResetDone))</p> |
| 182 | | - <p><a href="/login">(t(lang, Key::LogIn))</a></p> |
| 181 | + <p class="state">(t(lang, Key::ResetDone))</p> |
| 182 | + <div class="acts"> |
| 183 | + <a class="act" href="/login">(t(lang, Key::LogIn))</a> |
| 184 | + </div> |
| 183 | 185 | } |
| 184 | 186 | </section> |
| 185 | 187 | }) |
| | @@ -33,13 +33,13 @@ async fn home(cx: &Cx) -> Result<impl View> { |
| 33 | 33 | #[component] |
| 34 | 34 | async fn landing(has_users: bool, lang: Lang) -> Result<impl View> { |
| 35 | 35 | Ok(view! { |
| 36 | | - <section class="page-head home-head"> |
| 37 | | - <h1>"forge"</h1> |
| 38 | | - <p class="muted small page-note">(g::t(lang, K::LandingTagline))</p> |
| 39 | | - <div class="actions"> |
| 40 | | - <a class="button primary" href="/login">(g::t(lang, K::LogIn))</a> |
| 36 | + <section class="sec"> |
| 37 | + <h1 class="sr-only">"forge"</h1> |
| 38 | + <p class="state">(g::t(lang, K::LandingTagline))</p> |
| 39 | + <div class="acts"> |
| 40 | + <a class="act" href="/login">(g::t(lang, K::LogIn))</a> |
| 41 | 41 | if !has_users { |
| 42 | | - <a class="button" href="/setup">(g::t(lang, K::SetUpForge))</a> |
| 42 | + <a class="act" href="/setup">(g::t(lang, K::SetUpForge))</a> |
| 43 | 43 | } |
| 44 | 44 | </div> |
| 45 | 45 | </section> |
| | @@ -20,7 +20,7 @@ use topcoat::view::{View, component, view}; |
| 20 | 20 | use crate::audit::{self, Actor, Target}; |
| 21 | 21 | use crate::auth::{require_csrf, require_user}; |
| 22 | 22 | use crate::i18n::migrate::{self as g, K}; |
| 23 | | -use crate::i18n::{self, Key, Lang}; |
| 23 | +use crate::i18n::{self, Lang}; |
| 24 | 24 | use crate::importer::api::{ApiError, RemoteApi}; |
| 25 | 25 | use crate::importer::{ |
| 26 | 26 | self, ImportOptions, JobSpec, Source, default_name, make_forgejo, make_github, make_gitlab, |
| | @@ -31,7 +31,7 @@ use crate::pages::ci_runs::{changed_event, events_response}; |
| 31 | 31 | use crate::pages::new_repo::{owner_choices, repo_owner}; |
| 32 | 32 | use crate::pages::repo_ctx::still_readable; |
| 33 | 33 | use crate::state::AppState; |
| 34 | | -use crate::views::{alert, csrf_field, empty_state, rel_time, shell, user_facing_message}; |
| 34 | +use crate::views::{alert, csrf_field, rel_time, shell, user_facing_message}; |
| 35 | 35 | |
| 36 | 36 | path_param!(job_id); |
| 37 | 37 | |
| | @@ -165,9 +165,9 @@ pub(crate) async fn newrepo_tabs(lang: Lang, active: &str) -> Result<impl View> |
| 165 | 165 | let create = active == "create"; |
| 166 | 166 | let import = active == "import"; |
| 167 | 167 | Ok(view! { |
| 168 | | - <nav class="import-tabs" aria-label=(g::t(lang, K::ImportTitle))> |
| 169 | | - <a href="/new" class="import-tab" aria-current=(create.then_some("page"))>(g::t(lang, K::TabCreate))</a> |
| 170 | | - <a href="/new/import" class="import-tab" aria-current=(import.then_some("page"))>(g::t(lang, K::TabImport))</a> |
| 168 | + <nav class="tabs" aria-label=(g::t(lang, K::ImportTitle))> |
| 169 | + <a href="/new" aria-current=(create.then_some("page"))>(g::t(lang, K::TabCreate))</a> |
| 170 | + <a href="/new/import" aria-current=(import.then_some("page"))>(g::t(lang, K::TabImport))</a> |
| 171 | 171 | </nav> |
| 172 | 172 | }) |
| 173 | 173 | } |
| | @@ -179,32 +179,31 @@ async fn source_tabs(lang: Lang, base: &str, active: Source) -> Result<impl View |
| 179 | 179 | let gitlab = format!("{base}?source=gitlab"); |
| 180 | 180 | let forgejo = format!("{base}?source=forgejo"); |
| 181 | 181 | Ok(view! { |
| 182 | | - <nav class="import-sources" aria-label=(g::t(lang, K::TabImport))> |
| 183 | | - <a href=(git.as_str()) class="import-source" aria-current=((active == Source::Git).then_some("page"))>(g::t(lang, K::SrcGit))</a> |
| 184 | | - <a href=(github.as_str()) class="import-source" aria-current=((active == Source::GitHub).then_some("page"))>(g::t(lang, K::SrcGitHub))</a> |
| 185 | | - <a href=(gitlab.as_str()) class="import-source" aria-current=((active == Source::GitLab).then_some("page"))>(g::t(lang, K::SrcGitLab))</a> |
| 186 | | - <a href=(forgejo.as_str()) class="import-source" aria-current=((active == Source::Forgejo).then_some("page"))>(g::t(lang, K::SrcForgejo))</a> |
| 182 | + <nav class="sub" aria-label=(g::t(lang, K::TabImport))> |
| 183 | + <a href=(git.as_str()) aria-current=((active == Source::Git).then_some("page"))>(g::t(lang, K::SrcGit))</a> |
| 184 | + <a href=(github.as_str()) aria-current=((active == Source::GitHub).then_some("page"))>(g::t(lang, K::SrcGitHub))</a> |
| 185 | + <a href=(gitlab.as_str()) aria-current=((active == Source::GitLab).then_some("page"))>(g::t(lang, K::SrcGitLab))</a> |
| 186 | + <a href=(forgejo.as_str()) aria-current=((active == Source::Forgejo).then_some("page"))>(g::t(lang, K::SrcForgejo))</a> |
| 187 | 187 | </nav> |
| 188 | 188 | }) |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | +/// Public or private, as two switches with what each means under it. Shared with the create page. |
| 191 | 192 | #[component] |
| 192 | | -async fn visibility_pick(lang: Lang, private: bool) -> Result<impl View> { |
| 193 | +pub(crate) async fn visibility_pick(lang: Lang, private: bool) -> Result<impl View> { |
| 193 | 194 | Ok(view! { |
| 194 | | - <fieldset class="newrepo-visibility"> |
| 195 | | - <legend class="sr-only">(i18n::t(lang, Key::NewRepository))</legend> |
| 196 | | - <div class="segmented snippet-segmented"> |
| 197 | | - <label class="segment"> |
| 198 | | - <input type="radio" name="visibility" value="private" checked=(private)> |
| 199 | | - <svg viewBox="0 0 24 24" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg> |
| 200 | | - <span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPrivate))</span> |
| 201 | | - </label> |
| 202 | | - <label class="segment"> |
| 203 | | - <input type="radio" name="visibility" value="public" checked=(!private)> |
| 204 | | - <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"/></svg> |
| 205 | | - <span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPublic))</span> |
| 206 | | - </label> |
| 207 | | - </div> |
| 195 | + <fieldset class="rule-group"> |
| 196 | + <legend>(crate::i18n::misc::t(lang, crate::i18n::misc::K::VisibilityLegend))</legend> |
| 197 | + <label class="switch"> |
| 198 | + <input type="radio" name="visibility" value="private" checked=(private)> |
| 199 | + <span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPrivate))</span> |
| 200 | + </label> |
| 201 | + <p class="hint">(crate::i18n::misc::t(lang, crate::i18n::misc::K::PrivateHelp))</p> |
| 202 | + <label class="switch"> |
| 203 | + <input type="radio" name="visibility" value="public" checked=(!private)> |
| 204 | + <span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPublic))</span> |
| 205 | + </label> |
| 206 | + <p class="hint">(crate::i18n::misc::t(lang, crate::i18n::misc::K::PublicHelp))</p> |
| 208 | 207 | </fieldset> |
| 209 | 208 | }) |
| 210 | 209 | } |
| | @@ -212,13 +211,13 @@ async fn visibility_pick(lang: Lang, private: bool) -> Result<impl View> { |
| 212 | 211 | #[component] |
| 213 | 212 | async fn option_boxes(lang: Lang, opts: ImportOptions) -> Result<impl View> { |
| 214 | 213 | Ok(view! { |
| 215 | | - <fieldset class="import-opts"> |
| 214 | + <fieldset class="rule-group"> |
| 216 | 215 | <legend>(g::t(lang, K::WhatToImport))</legend> |
| 217 | | - <label class="inline"><input type="checkbox" name="opt_labels" value="on" checked=(opts.labels)><span>(g::t(lang, K::OptLabels))</span></label> |
| 218 | | - <label class="inline"><input type="checkbox" name="opt_issues" value="on" checked=(opts.issues)><span>(g::t(lang, K::OptIssues))</span></label> |
| 219 | | - <label class="inline"><input type="checkbox" name="opt_pulls" value="on" checked=(opts.pulls)><span>(g::t(lang, K::OptPulls))</span></label> |
| 220 | | - <label class="inline"><input type="checkbox" name="opt_releases" value="on" checked=(opts.releases)><span>(g::t(lang, K::OptReleases))</span></label> |
| 221 | | - <p class="muted small">(g::t(lang, K::OptionsNote))</p> |
| 216 | + <label class="switch"><input type="checkbox" name="opt_labels" value="on" checked=(opts.labels)><span>(g::t(lang, K::OptLabels))</span></label> |
| 217 | + <label class="switch"><input type="checkbox" name="opt_issues" value="on" checked=(opts.issues)><span>(g::t(lang, K::OptIssues))</span></label> |
| 218 | + <label class="switch"><input type="checkbox" name="opt_pulls" value="on" checked=(opts.pulls)><span>(g::t(lang, K::OptPulls))</span></label> |
| 219 | + <label class="switch"><input type="checkbox" name="opt_releases" value="on" checked=(opts.releases)><span>(g::t(lang, K::OptReleases))</span></label> |
| 220 | + <p class="hint">(g::t(lang, K::OptionsNote))</p> |
| 222 | 221 | </fieldset> |
| 223 | 222 | }) |
| 224 | 223 | } |
| | @@ -319,81 +318,68 @@ async fn import_form( |
| 319 | 318 | let private = draft.private; |
| 320 | 319 | let opts = draft.opts; |
| 321 | 320 | Ok(view! { |
| 322 | | - if let Some(message) = error { |
| 323 | | - alert(message: message.as_str()) |
| 321 | + <h1 class="sr-only">(g::t(lang, K::ImportTitle))</h1> |
| 322 | + newrepo_tabs(lang: lang, active: "import") |
| 323 | + source_tabs(lang: lang, base: "/new/import", active: source) |
| 324 | + if !is_git { |
| 325 | + <section class="sec"> |
| 326 | + <h2>(g::t(lang, K::BulkLink))</h2> |
| 327 | + <p class="hint">(g::t(lang, K::BulkIntro))</p> |
| 328 | + <div class="acts"> |
| 329 | + <a class="act" href=(bulk_href.as_str())>(g::t(lang, K::BulkLinkButton))</a> |
| 330 | + </div> |
| 331 | + </section> |
| 324 | 332 | } |
| 325 | | - <form method="post" action="/new/import" class="newrepo-form fit-pane"> |
| 333 | + <form method="post" action="/new/import" class="fields"> |
| 334 | + if let Some(message) = error { |
| 335 | + alert(message: message.as_str()) |
| 336 | + } |
| 326 | 337 | csrf_field(token: csrf) |
| 327 | 338 | <input type="hidden" name="source" value=(source_value)> |
| 328 | | - <header class="newrepo-head page-head"> |
| 329 | | - <h1>(g::t(lang, K::ImportTitle))</h1> |
| 330 | | - newrepo_tabs(lang: lang, active: "import") |
| 331 | | - <div class="newrepo-head-actions"> |
| 332 | | - visibility_pick(lang: lang, private: private) |
| 333 | | - <button type="submit" class="primary">(g::t(lang, K::StartImport))</button> |
| 339 | + <p class="hint">(g::t(lang, K::ImportIntro))</p> |
| 340 | + if has_instance { |
| 341 | + <div class="field"> |
| 342 | + <label for="import-instance">(instance_label)</label> |
| 343 | + <input id="import-instance" type="url" name="instance" value=(draft.instance.as_str()) autocomplete="off" spellcheck="false" maxlength="2048"> |
| 334 | 344 | </div> |
| 335 | | - </header> |
| 336 | | - source_tabs(lang: lang, base: "/new/import", active: source) |
| 337 | | - if !is_git { |
| 338 | | - <div class="newrepo-card import-bulk"> |
| 339 | | - <div class="import-bulk-text"> |
| 340 | | - <strong>(g::t(lang, K::BulkLink))</strong> |
| 341 | | - <span class="muted small">(g::t(lang, K::BulkIntro))</span> |
| 342 | | - </div> |
| 343 | | - <a class="button" href=(bulk_href.as_str())>(g::t(lang, K::BulkLinkButton))</a> |
| 345 | + } |
| 346 | + <div class="field"> |
| 347 | + <label for="import-remote">(remote_label)</label> |
| 348 | + <input id="import-remote" type="text" name="remote" value=(draft.remote.as_str()) placeholder=(remote_placeholder) required=(true) autocomplete="off" spellcheck="false" maxlength="2048"> |
| 349 | + </div> |
| 350 | + if is_git { |
| 351 | + <div class="field"> |
| 352 | + <label for="import-git-user">(g::t(lang, K::GitUser))</label> |
| 353 | + <input id="import-git-user" type="text" name="git_user" value=(draft.git_user.as_str()) autocomplete="off" maxlength="255"> |
| 344 | 354 | </div> |
| 345 | 355 | } |
| 346 | | - <p class="muted small">(g::t(lang, K::ImportIntro))</p> |
| 347 | | - <div class="newrepo-card"> |
| 348 | | - if has_instance { |
| 349 | | - <label> |
| 350 | | - <span>(instance_label)</span> |
| 351 | | - <input type="url" name="instance" value=(draft.instance.as_str()) autocomplete="off" spellcheck="false" maxlength="2048" class="newrepo-mono"> |
| 352 | | - </label> |
| 353 | | - } |
| 354 | | - <label> |
| 355 | | - <span>(remote_label)</span> |
| 356 | | - <input type="text" name="remote" value=(draft.remote.as_str()) placeholder=(remote_placeholder) required=(true) autocomplete="off" spellcheck="false" maxlength="2048" class="newrepo-mono"> |
| 357 | | - </label> |
| 358 | | - <div class="newrepo-row"> |
| 359 | | - if is_git { |
| 360 | | - <label class="newrepo-half"> |
| 361 | | - <span>(g::t(lang, K::GitUser))</span> |
| 362 | | - <input type="text" name="git_user" value=(draft.git_user.as_str()) autocomplete="off" maxlength="255"> |
| 363 | | - </label> |
| 356 | + <div class="field"> |
| 357 | + <label for="import-token">(token_label)</label> |
| 358 | + <input id="import-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 359 | + <p class="hint">(g::t(lang, K::TokenHelp))</p> |
| 360 | + </div> |
| 361 | + if !is_git { |
| 362 | + option_boxes(lang: lang, opts: opts) |
| 363 | + } |
| 364 | + <div class="field"> |
| 365 | + <label for="import-owner">(g::t(lang, K::TargetOwner))</label> |
| 366 | + <select id="import-owner" name="owner"> |
| 367 | + for name in owners.iter() { |
| 368 | + <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> |
| 364 | 369 | } |
| 365 | | - <label class="newrepo-half"> |
| 366 | | - <span>(token_label)</span> |
| 367 | | - <input type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 368 | | - </label> |
| 369 | | - </div> |
| 370 | | - <p class="muted small">(g::t(lang, K::TokenHelp))</p> |
| 371 | | - if !is_git { |
| 372 | | - option_boxes(lang: lang, opts: opts) |
| 373 | | - } |
| 370 | + </select> |
| 374 | 371 | </div> |
| 375 | | - <div class="newrepo-card"> |
| 376 | | - <div class="newrepo-row newrepo-slug"> |
| 377 | | - <label class="newrepo-owner"> |
| 378 | | - <span>(g::t(lang, K::TargetOwner))</span> |
| 379 | | - <select name="owner"> |
| 380 | | - for name in owners.iter() { |
| 381 | | - <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> |
| 382 | | - } |
| 383 | | - </select> |
| 384 | | - </label> |
| 385 | | - <span class="newrepo-slash" aria-hidden="true">("/")</span> |
| 386 | | - <label class="newrepo-name"> |
| 387 | | - <span>(g::t(lang, K::TargetName))</span> |
| 388 | | - <input type="text" name="name" value=(draft.name.as_str()) maxlength="64" autocomplete="off" class="newrepo-mono"> |
| 389 | | - </label> |
| 390 | | - </div> |
| 391 | | - <p class="muted small">(g::t(lang, K::TargetNameHelp))</p> |
| 392 | | - <label> |
| 393 | | - <span>(g::t(lang, K::Description))</span> |
| 394 | | - <textarea name="description" rows="2" maxlength="350">(draft.description.as_str())</textarea> |
| 395 | | - </label> |
| 372 | + <div class="field"> |
| 373 | + <label for="import-name">(g::t(lang, K::TargetName))</label> |
| 374 | + <input id="import-name" type="text" name="name" value=(draft.name.as_str()) maxlength="64" autocomplete="off"> |
| 375 | + <p class="hint">(g::t(lang, K::TargetNameHelp))</p> |
| 396 | 376 | </div> |
| 377 | + <div class="field"> |
| 378 | + <label for="import-description">(g::t(lang, K::Description))</label> |
| 379 | + <textarea id="import-description" name="description" rows="2" maxlength="350">(draft.description.as_str())</textarea> |
| 380 | + </div> |
| 381 | + visibility_pick(lang: lang, private: private) |
| 382 | + <button type="submit" class="primary">(g::t(lang, K::StartImport))</button> |
| 397 | 383 | </form> |
| 398 | 384 | }) |
| 399 | 385 | } |
| | @@ -401,7 +387,7 @@ async fn import_form( |
| 401 | 387 | /// How many imports the Import tab lists under the form. |
| 402 | 388 | const RECENT_IMPORTS: usize = 5; |
| 403 | 389 | |
| 404 | | -/// The GET import page: the tabs, then the form and the recent imports side by side on wide windows. |
| 390 | +/// The GET import page: the form, then the recent imports under it. |
| 405 | 391 | #[component] |
| 406 | 392 | async fn import_home( |
| 407 | 393 | lang: Lang, |
| | @@ -412,10 +398,8 @@ async fn import_home( |
| 412 | 398 | more: bool, |
| 413 | 399 | ) -> Result<impl View> { |
| 414 | 400 | Ok(view! { |
| 415 | | - <div class="import-home"> |
| 416 | | - import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners) |
| 417 | | - recent_imports(lang: lang, jobs: jobs, more: more) |
| 418 | | - </div> |
| 401 | + import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners) |
| 402 | + recent_imports(lang: lang, jobs: jobs, more: more) |
| 419 | 403 | }) |
| 420 | 404 | } |
| 421 | 405 | |
| | @@ -429,9 +413,7 @@ async fn import_error_body( |
| 429 | 413 | owners: Vec<String>, |
| 430 | 414 | ) -> Result<impl View> { |
| 431 | 415 | Ok(view! { |
| 432 | | - <div class="import-home"> |
| 433 | | - import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(error), owners: owners) |
| 434 | | - </div> |
| 416 | + import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(error), owners: owners) |
| 435 | 417 | }) |
| 436 | 418 | } |
| 437 | 419 | |
| | @@ -629,40 +611,34 @@ async fn bulk_form( |
| 629 | 611 | // A Forgejo token can list its own repositories, so the owner may stay empty. |
| 630 | 612 | let owner_required = source != Source::Forgejo; |
| 631 | 613 | Ok(view! { |
| 632 | | - if let Some(message) = error { |
| 633 | | - alert(message: message.as_str()) |
| 634 | | - } |
| 635 | | - <form method="post" action="/new/import/bulk" class="newrepo-form"> |
| 614 | + <h1 class="sr-only">(g::t(lang, K::BulkTitle))</h1> |
| 615 | + newrepo_tabs(lang: lang, active: "import") |
| 616 | + source_tabs(lang: lang, base: "/new/import/bulk", active: source) |
| 617 | + <form method="post" action="/new/import/bulk" class="fields"> |
| 618 | + if let Some(message) = error { |
| 619 | + alert(message: message.as_str()) |
| 620 | + } |
| 636 | 621 | csrf_field(token: csrf) |
| 637 | 622 | <input type="hidden" name="source" value=(source_value)> |
| 638 | 623 | <input type="hidden" name="stage" value="list"> |
| 639 | | - <header class="newrepo-head page-head"> |
| 640 | | - <h1>(g::t(lang, K::BulkTitle))</h1> |
| 641 | | - newrepo_tabs(lang: lang, active: "import") |
| 642 | | - <div class="newrepo-head-actions"> |
| 643 | | - <button type="submit" class="primary">(g::t(lang, K::BulkListButton))</button> |
| 624 | + <p class="hint">(g::t(lang, K::BulkIntro))</p> |
| 625 | + if has_instance { |
| 626 | + <div class="field"> |
| 627 | + <label for="bulk-instance">(instance_label)</label> |
| 628 | + <input id="bulk-instance" type="url" name="instance" value=(instance) autocomplete="off" spellcheck="false" maxlength="2048"> |
| 644 | 629 | </div> |
| 645 | | - </header> |
| 646 | | - source_tabs(lang: lang, base: "/new/import/bulk", active: source) |
| 647 | | - <p class="muted small">(g::t(lang, K::BulkIntro))</p> |
| 648 | | - <div class="newrepo-card"> |
| 649 | | - if has_instance { |
| 650 | | - <label> |
| 651 | | - <span>(instance_label)</span> |
| 652 | | - <input type="url" name="instance" value=(instance) autocomplete="off" spellcheck="false" maxlength="2048" class="newrepo-mono"> |
| 653 | | - </label> |
| 654 | | - } |
| 655 | | - <label> |
| 656 | | - <span>(owner_label)</span> |
| 657 | | - <input type="text" name="from" required=(owner_required) autocomplete="off" spellcheck="false" maxlength="100" class="newrepo-mono"> |
| 658 | | - </label> |
| 659 | | - <label> |
| 660 | | - <span>(g::t(lang, K::TokenOptional))</span> |
| 661 | | - <input type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 662 | | - </label> |
| 663 | | - <p class="muted small">(g::t(lang, K::TokenHelp))</p> |
| 630 | + } |
| 631 | + <div class="field"> |
| 632 | + <label for="bulk-from">(owner_label)</label> |
| 633 | + <input id="bulk-from" type="text" name="from" required=(owner_required) autocomplete="off" spellcheck="false" maxlength="100"> |
| 634 | + </div> |
| 635 | + <div class="field"> |
| 636 | + <label for="bulk-token">(g::t(lang, K::TokenOptional))</label> |
| 637 | + <input id="bulk-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 638 | + <p class="hint">(g::t(lang, K::TokenHelp))</p> |
| 664 | 639 | </div> |
| 665 | 640 | <input type="hidden" name="owner" value=(owners.first().map(String::as_str).unwrap_or(""))> |
| 641 | + <button type="submit" class="primary">(g::t(lang, K::BulkListButton))</button> |
| 666 | 642 | </form> |
| 667 | 643 | }) |
| 668 | 644 | } |
| | @@ -694,81 +670,57 @@ async fn bulk_select( |
| 694 | 670 | form.owner.clone() |
| 695 | 671 | }; |
| 696 | 672 | Ok(view! { |
| 697 | | - <form method="post" action="/new/import/bulk" class="newrepo-form"> |
| 673 | + <h1 class="sr-only">(g::t(lang, K::BulkSelectHeading))</h1> |
| 674 | + newrepo_tabs(lang: lang, active: "import") |
| 675 | + <form method="post" action="/new/import/bulk" class="fields"> |
| 698 | 676 | csrf_field(token: csrf) |
| 699 | 677 | <input type="hidden" name="stage" value="run"> |
| 700 | 678 | <input type="hidden" name="source" value=(form.source.as_str())> |
| 701 | 679 | <input type="hidden" name="instance" value=(form.instance.as_str())> |
| 702 | 680 | <input type="hidden" name="token" value=(form.token.as_str())> |
| 703 | 681 | <input type="hidden" name="from" value=(form.from.as_str())> |
| 704 | | - <header class="newrepo-head page-head"> |
| 705 | | - <h1>(g::t(lang, K::BulkSelectHeading))</h1> |
| 706 | | - newrepo_tabs(lang: lang, active: "import") |
| 707 | | - <div class="newrepo-head-actions"> |
| 708 | | - visibility_pick(lang: lang, private: private) |
| 709 | | - if !empty { |
| 710 | | - <button type="submit" class="primary">(g::t(lang, K::BulkImportSelected))</button> |
| 711 | | - } |
| 712 | | - </div> |
| 713 | | - </header> |
| 714 | 682 | if empty { |
| 715 | | - empty_state(title: g::t(lang, K::BulkNone)) |
| 683 | + <p class="state">(g::t(lang, K::BulkNone))</p> |
| 716 | 684 | } else { |
| 717 | | - <div class="newrepo-card import-into"> |
| 718 | | - <div class="action-row"> |
| 719 | | - <div class="action-text"> |
| 720 | | - <h3>(g::t(lang, K::TargetOwner))</h3> |
| 721 | | - <p class="muted small">(g::t(lang, K::BulkOwnerHelp))</p> |
| 722 | | - </div> |
| 723 | | - <div class="action-control"> |
| 724 | | - <select name="owner" aria-label=(g::t(lang, K::TargetOwner))> |
| 725 | | - for name in owners.iter() { |
| 726 | | - <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> |
| 685 | + <div class="field"> |
| 686 | + <label for="bulk-owner">(g::t(lang, K::TargetOwner))</label> |
| 687 | + <select id="bulk-owner" name="owner"> |
| 688 | + for name in owners.iter() { |
| 689 | + <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> |
| 690 | + } |
| 691 | + </select> |
| 692 | + <p class="hint">(g::t(lang, K::BulkOwnerHelp))</p> |
| 693 | + </div> |
| 694 | + visibility_pick(lang: lang, private: private) |
| 695 | + if form.source != "git" { |
| 696 | + option_boxes(lang: lang, opts: opts) |
| 697 | + } |
| 698 | + <label class="line" data-kb-row=""> |
| 699 | + <input type="checkbox" data-select-all=".import-pick-list"> |
| 700 | + <span class="name">(g::t(lang, K::BulkSelectAll))</span> |
| 701 | + <span class="val">(count)</span> |
| 702 | + </label> |
| 703 | + <div class="import-pick-list"> |
| 704 | + for (i, repo) in repos.iter().enumerate() { |
| 705 | + <label class="line" data-kb-row=""> |
| 706 | + <input type="checkbox" name=(format!("sel_{i}")) value=(repo.full_name.as_str())> |
| 707 | + <span class="name">(repo.name.as_str())</span> |
| 708 | + <span class="val"> |
| 709 | + if repo.private { |
| 710 | + <span class="badge private">(g::t(lang, K::BulkPrivate))</span> |
| 727 | 711 | } |
| 728 | | - </select> |
| 729 | | - </div> |
| 730 | | - </div> |
| 731 | | - if form.source != "git" { |
| 732 | | - <div class="import-into-opts"> |
| 733 | | - option_boxes(lang: lang, opts: opts) |
| 734 | | - </div> |
| 712 | + if repo.fork { |
| 713 | + <span class="badge">(g::t(lang, K::BulkFork))</span> |
| 714 | + } |
| 715 | + if repo.archived { |
| 716 | + <span class="badge">(g::t(lang, K::BulkArchived))</span> |
| 717 | + } |
| 718 | + (repo.description.as_str()) |
| 719 | + </span> |
| 720 | + </label> |
| 735 | 721 | } |
| 736 | 722 | </div> |
| 737 | | - <div class="newrepo-card import-pick"> |
| 738 | | - <label class="import-pick-row import-pick-all"> |
| 739 | | - <input type="checkbox" data-select-all=".import-pick-list"> |
| 740 | | - <span class="import-pick-main"> |
| 741 | | - <span class="import-pick-title">(g::t(lang, K::BulkSelectAll))</span> |
| 742 | | - </span> |
| 743 | | - <span class="muted small">(count)</span> |
| 744 | | - </label> |
| 745 | | - <ul class="import-pick-list"> |
| 746 | | - for (i, repo) in repos.iter().enumerate() { |
| 747 | | - <li> |
| 748 | | - <label class="import-pick-row"> |
| 749 | | - <input type="checkbox" name=(format!("sel_{i}")) value=(repo.full_name.as_str())> |
| 750 | | - <span class="import-pick-main"> |
| 751 | | - <span class="import-pick-title"> |
| 752 | | - <span class="import-pick-name">(repo.name.as_str())</span> |
| 753 | | - if repo.private { |
| 754 | | - <span class="badge private">(g::t(lang, K::BulkPrivate))</span> |
| 755 | | - } |
| 756 | | - if repo.fork { |
| 757 | | - <span class="badge">(g::t(lang, K::BulkFork))</span> |
| 758 | | - } |
| 759 | | - if repo.archived { |
| 760 | | - <span class="badge">(g::t(lang, K::BulkArchived))</span> |
| 761 | | - } |
| 762 | | - </span> |
| 763 | | - if !repo.description.is_empty() { |
| 764 | | - <span class="muted small import-pick-desc">(repo.description.as_str())</span> |
| 765 | | - } |
| 766 | | - </span> |
| 767 | | - </label> |
| 768 | | - </li> |
| 769 | | - } |
| 770 | | - </ul> |
| 771 | | - </div> |
| 723 | + <button type="submit" class="primary">(g::t(lang, K::BulkImportSelected))</button> |
| 772 | 724 | } |
| 773 | 725 | </form> |
| 774 | 726 | }) |
| | @@ -1073,24 +1025,24 @@ async fn load_job_rows( |
| 1073 | 1025 | #[component] |
| 1074 | 1026 | async fn job_rows(lang: Lang, jobs: Vec<(ImportJob, Option<Repo>)>) -> Result<impl View> { |
| 1075 | 1027 | Ok(view! { |
| 1076 | | - <ul class="item-list import-jobs"> |
| 1028 | + <div> |
| 1077 | 1029 | for (job, repo) in jobs.iter() { |
| 1078 | | - <li class="item import-job-row"> |
| 1079 | | - <div class="item-main"> |
| 1080 | | - <a href=(format!("/import/{}", job.id)) class="import-job-name">(job.source_ref.as_str())</a> |
| 1081 | | - <span class="muted small">(g::t(lang, K::JobStarted)) " " rel_time(lang: lang, stamp: job.created_at.as_str())</span> |
| 1082 | | - </div> |
| 1083 | | - if let Some(repo) = repo { |
| 1084 | | - <a href=(format!("/{}/{}", repo.owner_name, repo.name)) class="muted small mono">(format!("{}/{}", repo.owner_name, repo.name))</a> |
| 1085 | | - } |
| 1086 | | - <span class=(state_badge(lang, job.state).0)>(state_badge(lang, job.state).1)</span> |
| 1087 | | - </li> |
| 1030 | + <div class="line" data-kb-row=""> |
| 1031 | + <a class="name" href=(format!("/import/{}", job.id))>(job.source_ref.as_str())</a> |
| 1032 | + <span class="val"> |
| 1033 | + <span class=(state_badge(lang, job.state).0)>(state_badge(lang, job.state).1)</span> |
| 1034 | + " · " (g::t(lang, K::JobStarted)) " " rel_time(lang: lang, stamp: job.created_at.as_str()) |
| 1035 | + if let Some(repo) = repo { |
| 1036 | + " · " <a class="act" href=(format!("/{}/{}", repo.owner_name, repo.name))>(format!("{}/{}", repo.owner_name, repo.name))</a> |
| 1037 | + } |
| 1038 | + </span> |
| 1039 | + </div> |
| 1088 | 1040 | } |
| 1089 | | - </ul> |
| 1041 | + </div> |
| 1090 | 1042 | }) |
| 1091 | 1043 | } |
| 1092 | 1044 | |
| 1093 | | -/// The few most recent imports, shown under the import form. Nothing renders without any. |
| 1045 | +/// The few most recent imports, listed under the import form. Nothing renders without any. |
| 1094 | 1046 | /// `more` says there are older ones, which the "View all" link opens. |
| 1095 | 1047 | #[component] |
| 1096 | 1048 | async fn recent_imports( |
| | @@ -1102,21 +1054,18 @@ async fn recent_imports( |
| 1102 | 1054 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); |
| 1103 | 1055 | Ok(view! { |
| 1104 | 1056 | if !empty { |
| 1105 | | - <section class="card import-recent fit-pane"> |
| 1057 | + <section class="sec"> |
| 1106 | 1058 | <h2>(g::t(lang, K::RecentImports))</h2> |
| 1107 | 1059 | job_rows(lang: lang, jobs: jobs) |
| 1108 | 1060 | if more || retry { |
| 1109 | | - <p class="small"> |
| 1061 | + <div class="acts"> |
| 1110 | 1062 | if more { |
| 1111 | | - <a href="/import">(g::t(lang, K::ViewAll))</a> |
| 1112 | | - } |
| 1113 | | - if more && retry { |
| 1114 | | - " · " |
| 1063 | + <a class="act quiet" href="/import">(g::t(lang, K::ViewAll))</a> |
| 1115 | 1064 | } |
| 1116 | 1065 | if retry { |
| 1117 | | - <a href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a> |
| 1066 | + <a class="act" href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a> |
| 1118 | 1067 | } |
| 1119 | | - </p> |
| 1068 | + </div> |
| 1120 | 1069 | } |
| 1121 | 1070 | </section> |
| 1122 | 1071 | } |
| | @@ -1132,23 +1081,25 @@ async fn jobs_list( |
| 1132 | 1081 | let empty = jobs.is_empty(); |
| 1133 | 1082 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); |
| 1134 | 1083 | Ok(view! { |
| 1135 | | - <section class="page-head" data-live="/import/events"> |
| 1136 | | - <h1>(g::t(lang, K::JobsTitle))</h1> |
| 1084 | + <section data-live="/import/events"> |
| 1085 | + <h1 class="sr-only">(g::t(lang, K::JobsTitle))</h1> |
| 1137 | 1086 | if retry { |
| 1138 | | - <a class="button" href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a> |
| 1087 | + <div class="acts"> |
| 1088 | + <a class="act" href="/import/retry">(g::t(lang, K::RetryFailedTitle))</a> |
| 1089 | + </div> |
| 1139 | 1090 | } |
| 1140 | | - </section> |
| 1141 | | - if let Some(message) = skipped { |
| 1142 | | - alert(message: message.as_str()) |
| 1143 | | - } |
| 1144 | | - if empty { |
| 1145 | | - empty_state(title: g::t(lang, K::NoJobs), |
| 1146 | | - <a class="button" href="/new/import">(g::t(lang, K::ImportTitle))</a>) |
| 1147 | | - } else { |
| 1148 | | - <section class="card"> |
| 1091 | + if let Some(message) = skipped { |
| 1092 | + alert(message: message.as_str()) |
| 1093 | + } |
| 1094 | + if empty { |
| 1095 | + <p class="state">(g::t(lang, K::NoJobs))</p> |
| 1096 | + <div class="acts"> |
| 1097 | + <a class="act" href="/new/import">(g::t(lang, K::ImportTitle))</a> |
| 1098 | + </div> |
| 1099 | + } else { |
| 1149 | 1100 | job_rows(lang: lang, jobs: jobs) |
| 1150 | | - </section> |
| 1151 | | - } |
| 1101 | + } |
| 1102 | + </section> |
| 1152 | 1103 | }) |
| 1153 | 1104 | } |
| 1154 | 1105 | |
| | @@ -1238,25 +1189,16 @@ async fn job_view( |
| 1238 | 1189 | let empty_log = log.is_empty(); |
| 1239 | 1190 | Ok(view! { |
| 1240 | 1191 | <section class="import-job" data-live=(live.as_deref()) data-live-state=(state_word)> |
| 1241 | | - <header class="newrepo-head page-head"> |
| 1242 | | - <h1 class="import-job-title">(job.source_ref.as_str())</h1> |
| 1243 | | - <span class=(badge_class)>(badge_text)</span> |
| 1244 | | - <div class="newrepo-head-actions"> |
| 1245 | | - if let Some(href) = repo_href.as_ref() { |
| 1246 | | - if done { |
| 1247 | | - <a href=(href.as_str()) class="button primary">(g::t(lang, K::JobOpenRepo))</a> |
| 1248 | | - } |
| 1249 | | - } |
| 1250 | | - </div> |
| 1251 | | - </header> |
| 1252 | | - <div class="newrepo-card"> |
| 1192 | + <h1 class="h1">(job.source_ref.as_str())</h1> |
| 1193 | + <p class="state"><span class=(badge_class)>(badge_text)</span></p> |
| 1194 | + <section class="sec"> |
| 1253 | 1195 | if !stage.is_empty() { |
| 1254 | | - <div class="import-stage"> |
| 1255 | | - <strong>(stage)</strong> |
| 1196 | + <p class="state"> |
| 1197 | + (stage) |
| 1256 | 1198 | if has_progress { |
| 1257 | | - <span class="muted small">(progress_text.as_str())</span> |
| 1199 | + " · " (progress_text.as_str()) |
| 1258 | 1200 | } |
| 1259 | | - </div> |
| 1201 | + </p> |
| 1260 | 1202 | } |
| 1261 | 1203 | if has_progress { |
| 1262 | 1204 | <progress class="import-progress" value=(job.done) max=(job.total)></progress> |
| | @@ -1266,22 +1208,31 @@ async fn job_view( |
| 1266 | 1208 | if let Some(message) = error { |
| 1267 | 1209 | alert(message: message.as_str()) |
| 1268 | 1210 | } |
| 1269 | | - if failed { |
| 1270 | | - <form method="post" action=(retry_action.as_str()) class="import-retry"> |
| 1211 | + if let Some(href) = repo_href.as_ref() { |
| 1212 | + if done { |
| 1213 | + <div class="acts"> |
| 1214 | + <a class="act" href=(href.as_str())>(g::t(lang, K::JobOpenRepo))</a> |
| 1215 | + </div> |
| 1216 | + } |
| 1217 | + } |
| 1218 | + </section> |
| 1219 | + if failed { |
| 1220 | + <section class="sec"> |
| 1221 | + <form method="post" action=(retry_action.as_str()) class="fields"> |
| 1271 | 1222 | csrf_field(token: csrf) |
| 1272 | | - <label> |
| 1273 | | - <span>(g::t(lang, K::TokenOptional))</span> |
| 1274 | | - <input type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 1275 | | - </label> |
| 1276 | | - <p class="muted small">(g::t(lang, K::JobRetryHelp))</p> |
| 1223 | + <div class="field"> |
| 1224 | + <label for="retry-token">(g::t(lang, K::TokenOptional))</label> |
| 1225 | + <input id="retry-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 1226 | + <p class="hint">(g::t(lang, K::JobRetryHelp))</p> |
| 1227 | + </div> |
| 1277 | 1228 | <button type="submit" class="primary">(g::t(lang, K::JobRetry))</button> |
| 1278 | 1229 | </form> |
| 1279 | | - } |
| 1280 | | - </div> |
| 1281 | | - <div class="newrepo-card"> |
| 1282 | | - <h2 class="import-log-title">(g::t(lang, K::JobProgress))</h2> |
| 1230 | + </section> |
| 1231 | + } |
| 1232 | + <section class="sec"> |
| 1233 | + <h2>(g::t(lang, K::JobProgress))</h2> |
| 1283 | 1234 | if empty_log { |
| 1284 | | - <p class="muted small">(g::t(lang, K::JobNoLog))</p> |
| 1235 | + <p class="hint">(g::t(lang, K::JobNoLog))</p> |
| 1285 | 1236 | } else { |
| 1286 | 1237 | <ol class="import-log"> |
| 1287 | 1238 | for line in log.iter() { |
| | @@ -1289,7 +1240,7 @@ async fn job_view( |
| 1289 | 1240 | } |
| 1290 | 1241 | </ol> |
| 1291 | 1242 | } |
| 1292 | | - </div> |
| 1243 | + </section> |
| 1293 | 1244 | </section> |
| 1294 | 1245 | }) |
| 1295 | 1246 | } |
| | @@ -1458,54 +1409,38 @@ async fn retry_list(lang: Lang, csrf: &str, rows: Vec<(ImportJob, Repo)>) -> Res |
| 1458 | 1409 | let count = rows.len(); |
| 1459 | 1410 | let empty = rows.is_empty(); |
| 1460 | 1411 | Ok(view! { |
| 1461 | | - <form method="post" action="/import/retry" class="newrepo-form"> |
| 1412 | + <h1 class="sr-only">(g::t(lang, K::RetryFailedTitle))</h1> |
| 1413 | + <form method="post" action="/import/retry" class="fields"> |
| 1462 | 1414 | csrf_field(token: csrf) |
| 1463 | | - <header class="newrepo-head page-head"> |
| 1464 | | - <h1>(g::t(lang, K::RetryFailedTitle))</h1> |
| 1465 | | - <div class="newrepo-head-actions"> |
| 1466 | | - if !empty { |
| 1467 | | - <button type="submit" class="primary">(g::t(lang, K::RetrySelected))</button> |
| 1468 | | - } |
| 1469 | | - </div> |
| 1470 | | - </header> |
| 1471 | 1415 | if empty { |
| 1472 | | - empty_state(title: g::t(lang, K::RetryNone)) |
| 1416 | + <p class="state">(g::t(lang, K::RetryNone))</p> |
| 1473 | 1417 | } else { |
| 1474 | | - <div class="newrepo-card"> |
| 1475 | | - <label> |
| 1476 | | - <span>(g::t(lang, K::TokenOptional))</span> |
| 1477 | | - <input type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 1478 | | - </label> |
| 1479 | | - <p class="muted small">(g::t(lang, K::RetryTokenHelp))</p> |
| 1418 | + <div class="field"> |
| 1419 | + <label for="retry-token">(g::t(lang, K::TokenOptional))</label> |
| 1420 | + <input id="retry-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 1421 | + <p class="hint">(g::t(lang, K::RetryTokenHelp))</p> |
| 1480 | 1422 | </div> |
| 1481 | | - <div class="newrepo-card import-pick"> |
| 1482 | | - <label class="import-pick-row import-pick-all"> |
| 1483 | | - <input type="checkbox" data-select-all=".import-pick-list"> |
| 1484 | | - <span class="import-pick-main"> |
| 1485 | | - <span class="import-pick-title">(g::t(lang, K::BulkSelectAll))</span> |
| 1486 | | - </span> |
| 1487 | | - <span class="muted small">(count)</span> |
| 1488 | | - </label> |
| 1489 | | - <ul class="import-pick-list"> |
| 1490 | | - for (i, (job, repo)) in rows.iter().enumerate() { |
| 1491 | | - <li> |
| 1492 | | - <label class="import-pick-row"> |
| 1493 | | - <input type="checkbox" name=(format!("sel_{i}")) value=(job.id.as_str())> |
| 1494 | | - <span class="import-pick-main"> |
| 1495 | | - <span class="import-pick-title"> |
| 1496 | | - <span class="import-pick-name">(format!("{}/{}", repo.owner_name, repo.name))</span> |
| 1497 | | - <span class="badge">(source_label(&job.source))</span> |
| 1498 | | - </span> |
| 1499 | | - <span class="muted small import-pick-desc">(job.source_ref.as_str())</span> |
| 1500 | | - if let Some(message) = job.error.as_ref() { |
| 1501 | | - <span class="muted small import-pick-desc">(message.as_str())</span> |
| 1502 | | - } |
| 1503 | | - </span> |
| 1504 | | - </label> |
| 1505 | | - </li> |
| 1506 | | - } |
| 1507 | | - </ul> |
| 1423 | + <label class="line" data-kb-row=""> |
| 1424 | + <input type="checkbox" data-select-all=".import-pick-list"> |
| 1425 | + <span class="name">(g::t(lang, K::BulkSelectAll))</span> |
| 1426 | + <span class="val">(count)</span> |
| 1427 | + </label> |
| 1428 | + <div class="import-pick-list"> |
| 1429 | + for (i, (job, repo)) in rows.iter().enumerate() { |
| 1430 | + <label class="line" data-kb-row=""> |
| 1431 | + <input type="checkbox" name=(format!("sel_{i}")) value=(job.id.as_str())> |
| 1432 | + <span class="name">(format!("{}/{}", repo.owner_name, repo.name))</span> |
| 1433 | + <span class="val"> |
| 1434 | + <span class="badge">(source_label(&job.source))</span> |
| 1435 | + " " (job.source_ref.as_str()) |
| 1436 | + if let Some(message) = job.error.as_ref() { |
| 1437 | + " · " (message.as_str()) |
| 1438 | + } |
| 1439 | + </span> |
| 1440 | + </label> |
| 1441 | + } |
| 1508 | 1442 | </div> |
| 1443 | + <button type="submit" class="primary">(g::t(lang, K::RetrySelected))</button> |
| 1509 | 1444 | } |
| 1510 | 1445 | </form> |
| 1511 | 1446 | }) |
| | @@ -18,6 +18,7 @@ use crate::mail::account; |
| 18 | 18 | use crate::pages::admin_users::admin_only; |
| 19 | 19 | use crate::pages::passkeys::s; |
| 20 | 20 | use crate::state::AppState; |
| 21 | +use crate::views::parts::reveal; |
| 21 | 22 | use crate::views::{alert, shell, user_facing_message}; |
| 22 | 23 | |
| 23 | 24 | #[derive(Deserialize)] |
| | @@ -35,38 +36,29 @@ async fn invite_body( |
| 35 | 36 | notice: Option<&'static str>, |
| 36 | 37 | error: Option<String>, |
| 37 | 38 | ) -> Result<impl View> { |
| 39 | + let open = error.is_some(); |
| 38 | 40 | Ok(view! { |
| 39 | | - <section class="page-head"> |
| 40 | | - <h1>(t(lang, Key::InvitesTitle))</h1> |
| 41 | | - </section> |
| 42 | | - <p class="muted page-lede">(t(lang, Key::InvitesSub))</p> |
| 43 | | - if let Some(message) = notice { |
| 44 | | - <section class="card notice" role="status"> |
| 45 | | - <p>(message)</p> |
| 46 | | - </section> |
| 47 | | - } |
| 48 | | - <section class="card rows-pane"> |
| 49 | | - <div class="row-line"> |
| 50 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 51 | | - <div class="row-main"> |
| 52 | | - <h2 class="row-title">(s(lang, "Invite by email", "E-posta ile davet et"))</h2> |
| 53 | | - </div> |
| 54 | | - <details class="row-action" open=(error.is_some())> |
| 55 | | - <summary>(t(lang, Key::InvitesSubmit))</summary> |
| 56 | | - <div class="row-panel"> |
| 57 | | - if let Some(message) = error { |
| 58 | | - alert(message: message.as_str()) |
| 59 | | - } |
| 60 | | - <form method="post" action="/admin/invites" class="stack"> |
| 61 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 62 | | - <label> |
| 63 | | - <span>(t(lang, Key::Email))</span> |
| 64 | | - <input type="email" name="email" autocomplete="off" maxlength="254" required=(true)> |
| 65 | | - </label> |
| 66 | | - <button type="submit" class="primary">(t(lang, Key::InvitesSubmit))</button> |
| 67 | | - </form> |
| 68 | | - </div> |
| 69 | | - </details> |
| 41 | + <h1 class="sr-only">(t(lang, Key::InvitesTitle))</h1> |
| 42 | + <section class="sec"> |
| 43 | + <h2>(s(lang, "Invite by email", "E-posta ile davet et"))</h2> |
| 44 | + <p class="hint">(t(lang, Key::InvitesSub))</p> |
| 45 | + if let Some(message) = notice { |
| 46 | + <p class="state" role="status">(message)</p> |
| 47 | + } |
| 48 | + <div class="acts"> |
| 49 | + reveal(label: t(lang, Key::InvitesSubmit), id: Some("invite-email"), open: open, |
| 50 | + if let Some(message) = error { |
| 51 | + alert(message: message.as_str()) |
| 52 | + } |
| 53 | + <form method="post" action="/admin/invites" class="fields"> |
| 54 | + <input type="hidden" name="csrf" value=(csrf)> |
| 55 | + <div class="field"> |
| 56 | + <label for="invite-email">(t(lang, Key::Email))</label> |
| 57 | + <input id="invite-email" type="email" name="email" autocomplete="off" maxlength="254" required=(true)> |
| 58 | + </div> |
| 59 | + <button type="submit" class="primary">(t(lang, Key::InvitesSubmit))</button> |
| 60 | + </form> |
| 61 | + ) |
| 70 | 62 | </div> |
| 71 | 63 | </section> |
| 72 | 64 | }) |
| | @@ -81,16 +81,8 @@ pub(crate) fn refusal_message(e: forge_core::Error) -> Result<String> { |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | | -/// Class for one sub-navigation link: the one named by `active` is marked current. |
| 85 | | -fn subnav_class(active: &str, link: &str) -> &'static str { |
| 86 | | - if active == link { |
| 87 | | - "subnav-link current" |
| 88 | | - } else { |
| 89 | | - "subnav-link" |
| 90 | | - } |
| 91 | | -} |
| 92 | | - |
| 93 | | -/// Links between the issue-adjacent pages of a repo: Issues, Labels and Milestones. |
| 84 | +/// Links between the issue-adjacent pages of a repo: Issues, Labels and Milestones. The one named |
| 85 | +/// by `active` is the current page. |
| 94 | 86 | #[component] |
| 95 | 87 | pub(crate) async fn issue_subnav(lang: Lang, title: String, active: String) -> Result<impl View> { |
| 96 | 88 | let issues = format!("/{title}/issues"); |
| | @@ -98,11 +90,26 @@ pub(crate) async fn issue_subnav(lang: Lang, title: String, active: String) -> R |
| 98 | 90 | let milestones = format!("/{title}/milestones"); |
| 99 | 91 | // The repo's issue stream: the labels and milestones pages follow it (see `issues_live`). |
| 100 | 92 | let live = format!("/{title}/issues/live"); |
| 93 | + let on_issues = active == "issues"; |
| 94 | + let on_labels = active == "labels"; |
| 95 | + let on_milestones = active == "milestones"; |
| 101 | 96 | Ok(view! { |
| 102 | | - <nav class="subnav" aria-label=(g::t(lang, K::IssuePages)) data-live=(live.as_str()) data-live-now=""> |
| 103 | | - <a class=(subnav_class(&active, "issues")) href=(issues.as_str())>(g::t(lang, K::Issues))</a> |
| 104 | | - <a class=(subnav_class(&active, "labels")) href=(labels.as_str())>(g::t(lang, K::Labels))</a> |
| 105 | | - <a class=(subnav_class(&active, "milestones")) href=(milestones.as_str())>(g::t(lang, K::Milestones))</a> |
| 97 | + <nav class="sub" aria-label=(g::t(lang, K::IssuePages)) data-live=(live.as_str()) data-live-now=""> |
| 98 | + if on_issues { |
| 99 | + <a href=(issues.as_str()) aria-current="page">(g::t(lang, K::Issues))</a> |
| 100 | + } else { |
| 101 | + <a href=(issues.as_str())>(g::t(lang, K::Issues))</a> |
| 102 | + } |
| 103 | + if on_labels { |
| 104 | + <a href=(labels.as_str()) aria-current="page">(g::t(lang, K::Labels))</a> |
| 105 | + } else { |
| 106 | + <a href=(labels.as_str())>(g::t(lang, K::Labels))</a> |
| 107 | + } |
| 108 | + if on_milestones { |
| 109 | + <a href=(milestones.as_str()) aria-current="page">(g::t(lang, K::Milestones))</a> |
| 110 | + } else { |
| 111 | + <a href=(milestones.as_str())>(g::t(lang, K::Milestones))</a> |
| 112 | + } |
| 106 | 113 | </nav> |
| 107 | 114 | }) |
| 108 | 115 | } |
| | @@ -194,9 +201,12 @@ pub(crate) async fn action_error_at( |
| 194 | 201 | back: String, |
| 195 | 202 | ) -> Result<impl View> { |
| 196 | 203 | Ok(view! { |
| 197 | | - <section class="card"> |
| 204 | + <section class="sec"> |
| 205 | + <h1 class="sr-only">(g::t(lang, K::CouldNotSave))</h1> |
| 198 | 206 | alert(message: message.as_str()) |
| 199 | | - <p><a href=(back.as_str())>(g::t(lang, K::GoBack))</a></p> |
| 207 | + <div class="acts"> |
| 208 | + <a class="act" href=(back.as_str())>(g::t(lang, K::GoBack))</a> |
| 209 | + </div> |
| 200 | 210 | </section> |
| 201 | 211 | }) |
| 202 | 212 | } |
| | @@ -31,6 +31,7 @@ use crate::views::{ |
| 31 | 31 | alert, avatar_url, display_name, iso_time, now_unix, relative_time, repo_href, short_oid, |
| 32 | 32 | user_href, user_link, |
| 33 | 33 | }; |
| 34 | +use crate::views::parts::{confirm_act, reveal}; |
| 34 | 35 | use crate::webhooks::emit::{Sender, emit_comment, emit_item_action}; |
| 35 | 36 | |
| 36 | 37 | /// Which kind of item a page shows. It decides the URL segment of the item's own links and which |
| | @@ -434,26 +435,16 @@ pub(crate) async fn comment_item(lang: Lang, item: CommentView) -> Result<impl V |
| 434 | 435 | reactions, |
| 435 | 436 | } = item; |
| 436 | 437 | let profile = user_href(&login); |
| 438 | + let has_acts = edit_href.is_some() || delete_href.is_some(); |
| 437 | 439 | Ok(view! { |
| 438 | | - <article class="issue-item" id=(anchor.as_str())> |
| 439 | | - <header class="issue-item-head"> |
| 440 | + <article class="thread-entry" id=(anchor.as_str())> |
| 441 | + <header class="thread-head"> |
| 440 | 442 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> |
| 441 | 443 | <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> |
| 442 | 444 | <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> |
| 443 | 445 | if let Some(href) = history_href { |
| 444 | | - <a class="issue-edited" href=(href.as_str())>(g::t(lang, K::Edited))</a> |
| 446 | + <a class="act quiet issue-edited" href=(href.as_str())>(g::t(lang, K::Edited))</a> |
| 445 | 447 | } |
| 446 | | - <span class="issue-item-actions"> |
| 447 | | - if let Some(href) = edit_href { |
| 448 | | - <a href=(href.as_str())>(g::t(lang, K::Edit))</a> |
| 449 | | - } |
| 450 | | - if let Some(action) = delete_href { |
| 451 | | - <form method="post" action=(action.as_str())> |
| 452 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 453 | | - <button type="submit" class="link-button">(g::t(lang, K::Delete))</button> |
| 454 | | - </form> |
| 455 | | - } |
| 456 | | - </span> |
| 457 | 448 | </header> |
| 458 | 449 | if let Some(task) = tasks { |
| 459 | 450 | <div class="issue-item-body markdown-body" data-task-action=(task.action.as_str()) data-task-kind=(task.kind) data-task-id=(task.id.as_str()) data-csrf=(csrf.as_str())>(Unescaped::new_unchecked(html))</div> |
| | @@ -463,6 +454,16 @@ pub(crate) async fn comment_item(lang: Lang, item: CommentView) -> Result<impl V |
| 463 | 454 | if let Some(bar) = reactions { |
| 464 | 455 | reaction_row(lang: lang, bar: bar) |
| 465 | 456 | } |
| 457 | + if has_acts { |
| 458 | + <div class="acts"> |
| 459 | + if let Some(href) = edit_href { |
| 460 | + <a class="act" href=(href.as_str())>(g::t(lang, K::Edit))</a> |
| 461 | + } |
| 462 | + if let Some(action) = delete_href { |
| 463 | + confirm_act(lang: lang, label: g::t(lang, K::Delete), action: action.as_str(), csrf: csrf.as_str()) |
| 464 | + } |
| 465 | + </div> |
| 466 | + } |
| 466 | 467 | </article> |
| 467 | 468 | }) |
| 468 | 469 | } |
| | @@ -553,7 +554,7 @@ pub(crate) async fn event_item(line: EventLine) -> Result<impl View> { |
| 553 | 554 | after, |
| 554 | 555 | } = line; |
| 555 | 556 | Ok(view! { |
| 556 | | - <div class="issue-event"> |
| 557 | + <div class="thread-event"> |
| 557 | 558 | <strong>(actor.as_str())</strong> |
| 558 | 559 | " " |
| 559 | 560 | (before.as_str()) |
| | @@ -608,8 +609,8 @@ pub(crate) async fn review_item(lang: Lang, review: ReviewView) -> Result<impl V |
| 608 | 609 | "review-verb" |
| 609 | 610 | }; |
| 610 | 611 | Ok(view! { |
| 611 | | - <article class="issue-item review-item" id=(anchor.as_str())> |
| 612 | | - <header class="issue-item-head"> |
| 612 | + <article class="thread-entry review-item" id=(anchor.as_str())> |
| 613 | + <header class="thread-head"> |
| 613 | 614 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> |
| 614 | 615 | <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> |
| 615 | 616 | <span class=(verb_class)>(verb)</span> |
| | @@ -878,7 +879,7 @@ pub(crate) fn reaction_bar_for( |
| 878 | 879 | .collect(); |
| 879 | 880 | let picker = Reaction::ALL |
| 880 | 881 | .into_iter() |
| 881 | | - .map(|r| button(r.name(), r.emoji(), 0, r.name().to_owned(), false)) |
| 882 | + .map(|r| button(r.name(), r.emoji(), 0, reaction_label(lang, r).to_owned(), false)) |
| 882 | 883 | .collect(); |
| 883 | 884 | Some(ReactionBar { |
| 884 | 885 | chips, |
| | @@ -888,6 +889,21 @@ pub(crate) fn reaction_bar_for( |
| 888 | 889 | } |
| 889 | 890 | |
| 890 | 891 | /// The hover text of a reaction: who made it, and how many more beyond the first names. |
| 892 | +/// A reaction's name in the viewer's language, for its picker button. |
| 893 | +fn reaction_label(lang: Lang, reaction: Reaction) -> &'static str { |
| 894 | + use crate::pages::passkeys::s; |
| 895 | + match reaction { |
| 896 | + Reaction::PlusOne => "+1", |
| 897 | + Reaction::MinusOne => "-1", |
| 898 | + Reaction::Laugh => s(lang, "Laugh", "Gülme"), |
| 899 | + Reaction::Hooray => s(lang, "Hooray", "Yaşasın"), |
| 900 | + Reaction::Confused => s(lang, "Confused", "Kafası karışık"), |
| 901 | + Reaction::Heart => s(lang, "Heart", "Kalp"), |
| 902 | + Reaction::Rocket => s(lang, "Rocket", "Roket"), |
| 903 | + Reaction::Eyes => s(lang, "Eyes", "Gözler"), |
| 904 | + } |
| 905 | +} |
| 906 | + |
| 891 | 907 | fn reaction_title(lang: Lang, users: &[String], count: usize) -> String { |
| 892 | 908 | let names = users.join(", "); |
| 893 | 909 | match count.saturating_sub(users.len()) { |
| | @@ -1067,35 +1083,36 @@ pub(crate) async fn labels_box( |
| 1067 | 1083 | ) -> Result<impl View> { |
| 1068 | 1084 | let any_attached = labels.iter().any(|row| row.attached); |
| 1069 | 1085 | Ok(view! { |
| 1070 | | - <section class="issue-side-section"> |
| 1071 | | - <h2>(g::t(lang, K::Labels))</h2> |
| 1072 | | - if write { |
| 1073 | | - <form method="post" action=(action.as_str()) class="stack" data-apply="true"> |
| 1074 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1075 | | - if labels.is_empty() { |
| 1076 | | - <p class="muted small">(g::t(lang, K::NoRepoLabels))</p> |
| 1077 | | - } |
| 1078 | | - for row in labels.iter() { |
| 1079 | | - <label class="issue-check"> |
| 1080 | | - <input type="checkbox" name="label" value=(row.id.as_str()) checked=(row.attached)> |
| 1081 | | - <span class=(row.chip.as_str())>(row.name.as_str())</span> |
| 1082 | | - </label> |
| 1083 | | - } |
| 1084 | | - <noscript><div><button type="submit">(g::t(lang, K::SaveLabels))</button></div></noscript> |
| 1085 | | - </form> |
| 1086 | | - } else { |
| 1086 | + <div class="acts"> |
| 1087 | + <span class="state"> |
| 1088 | + (g::t(lang, K::Labels)) ": " |
| 1087 | 1089 | if !any_attached { |
| 1088 | | - <p class="muted small">(g::t(lang, K::NoneYet))</p> |
| 1090 | + (g::t(lang, K::NoneYet)) |
| 1089 | 1091 | } |
| 1090 | | - <div class="issue-chips"> |
| 1091 | | - for row in labels.iter() { |
| 1092 | | - if row.attached { |
| 1093 | | - <span class=(row.chip.as_str())>(row.name.as_str())</span> |
| 1094 | | - } |
| 1092 | + for row in labels.iter() { |
| 1093 | + if row.attached { |
| 1094 | + <span class=(row.chip.as_str())>(row.name.as_str())</span> |
| 1095 | 1095 | } |
| 1096 | | - </div> |
| 1096 | + } |
| 1097 | + </span> |
| 1098 | + if write { |
| 1099 | + reveal(label: g::t(lang, K::Edit), |
| 1100 | + <form method="post" action=(action.as_str()) class="fields" data-apply="true"> |
| 1101 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1102 | + if labels.is_empty() { |
| 1103 | + <p class="hint">(g::t(lang, K::NoRepoLabels))</p> |
| 1104 | + } |
| 1105 | + for row in labels.iter() { |
| 1106 | + <label class="switch"> |
| 1107 | + <input type="checkbox" name="label" value=(row.id.as_str()) checked=(row.attached)> |
| 1108 | + <span class=(row.chip.as_str())>(row.name.as_str())</span> |
| 1109 | + </label> |
| 1110 | + } |
| 1111 | + <noscript><div><button type="submit" class="primary">(g::t(lang, K::SaveLabels))</button></div></noscript> |
| 1112 | + </form> |
| 1113 | + ) |
| 1097 | 1114 | } |
| 1098 | | - </section> |
| 1115 | + </div> |
| 1099 | 1116 | }) |
| 1100 | 1117 | } |
| 1101 | 1118 | |
| | @@ -1110,32 +1127,36 @@ pub(crate) async fn assignees_box( |
| 1110 | 1127 | ) -> Result<impl View> { |
| 1111 | 1128 | let text = names.join(", "); |
| 1112 | 1129 | Ok(view! { |
| 1113 | | - <section class="issue-side-section"> |
| 1114 | | - <h2>(g::t(lang, K::Assignees))</h2> |
| 1115 | | - if write { |
| 1116 | | - if let Some(next) = assign_next { |
| 1117 | | - <form method="post" action=(action.as_str()) class="assign-me-form"> |
| 1118 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1119 | | - <input type="hidden" name="assignees" value=(next.as_str())> |
| 1120 | | - <button type="submit" class="link-button" data-palette-action="post">(g::t(lang, K::AssignToMe))</button> |
| 1121 | | - </form> |
| 1122 | | - } |
| 1123 | | - <form method="post" action=(action.as_str()) class="stack" data-apply="true"> |
| 1124 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1125 | | - <input type="text" name="assignees" value=(text.as_str()) autocomplete="off" spellcheck="false" aria-label=(g::t(lang, K::Assignees)) title=(g::t(lang, K::CommaUsernames)) placeholder=(crate::pages::passkeys::s(lang, "Type a username", "Kullanıcı adı yaz"))> |
| 1126 | | - <noscript><div><button type="submit">(g::t(lang, K::SaveAssignees))</button></div></noscript> |
| 1127 | | - </form> |
| 1128 | | - } else { |
| 1130 | + <div class="acts"> |
| 1131 | + <span class="state"> |
| 1132 | + (g::t(lang, K::Assignees)) ": " |
| 1129 | 1133 | if names.is_empty() { |
| 1130 | | - <p class="muted small">(g::t(lang, K::NoOneAssigned))</p> |
| 1134 | + (g::t(lang, K::NoOneAssigned)) |
| 1135 | + } else { |
| 1136 | + (text.as_str()) |
| 1131 | 1137 | } |
| 1132 | | - <ul class="issue-names"> |
| 1133 | | - for name in names.iter() { |
| 1134 | | - <li>(name.as_str())</li> |
| 1138 | + </span> |
| 1139 | + if write { |
| 1140 | + reveal(label: g::t(lang, K::Edit), |
| 1141 | + if let Some(next) = assign_next { |
| 1142 | + <form method="post" action=(action.as_str()) class="act-form"> |
| 1143 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1144 | + <input type="hidden" name="assignees" value=(next.as_str())> |
| 1145 | + <button type="submit" class="act" data-palette-action="post">(g::t(lang, K::AssignToMe))</button> |
| 1146 | + </form> |
| 1135 | 1147 | } |
| 1136 | | - </ul> |
| 1148 | + <form method="post" action=(action.as_str()) class="fields" data-apply="true"> |
| 1149 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1150 | + <div class="field"> |
| 1151 | + <label for="issue-assignees">(g::t(lang, K::Assignees))</label> |
| 1152 | + <input id="issue-assignees" type="text" name="assignees" value=(text.as_str()) autocomplete="off" spellcheck="false" placeholder=(crate::pages::passkeys::s(lang, "Type a username", "Kullanıcı adı yaz"))> |
| 1153 | + <p class="hint">(g::t(lang, K::CommaUsernames))</p> |
| 1154 | + </div> |
| 1155 | + <noscript><div><button type="submit" class="primary">(g::t(lang, K::SaveAssignees))</button></div></noscript> |
| 1156 | + </form> |
| 1157 | + ) |
| 1137 | 1158 | } |
| 1138 | | - </section> |
| 1159 | + </div> |
| 1139 | 1160 | }) |
| 1140 | 1161 | } |
| 1141 | 1162 | |
| | @@ -1150,27 +1171,33 @@ pub(crate) async fn milestone_box( |
| 1150 | 1171 | none_selected: bool, |
| 1151 | 1172 | ) -> Result<impl View> { |
| 1152 | 1173 | Ok(view! { |
| 1153 | | - <section class="issue-side-section"> |
| 1154 | | - <h2>(g::t(lang, K::MilestoneBox))</h2> |
| 1155 | | - if write { |
| 1156 | | - <form method="post" action=(action.as_str()) class="stack" data-apply="true"> |
| 1157 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1158 | | - <select name="milestone_id" aria-label=(g::t(lang, K::MilestoneBox))> |
| 1159 | | - <option value="" selected=(none_selected)>(g::t(lang, K::NoneOption))</option> |
| 1160 | | - for row in options.iter() { |
| 1161 | | - <option value=(row.id.as_str()) selected=(row.selected)>(row.title.as_str())</option> |
| 1162 | | - } |
| 1163 | | - </select> |
| 1164 | | - <noscript><div><button type="submit">(g::t(lang, K::SaveMilestone))</button></div></noscript> |
| 1165 | | - </form> |
| 1166 | | - } else { |
| 1174 | + <div class="acts"> |
| 1175 | + <span class="state"> |
| 1176 | + (g::t(lang, K::MilestoneBox)) ": " |
| 1167 | 1177 | if current.is_empty() { |
| 1168 | | - <p class="muted small">(g::t(lang, K::NoMilestone))</p> |
| 1178 | + (g::t(lang, K::NoMilestone)) |
| 1169 | 1179 | } else { |
| 1170 | | - <p>(current.as_str())</p> |
| 1180 | + (current.as_str()) |
| 1171 | 1181 | } |
| 1182 | + </span> |
| 1183 | + if write { |
| 1184 | + reveal(label: g::t(lang, K::Edit), |
| 1185 | + <form method="post" action=(action.as_str()) class="fields" data-apply="true"> |
| 1186 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1187 | + <div class="field"> |
| 1188 | + <label for="issue-milestone">(g::t(lang, K::MilestoneBox))</label> |
| 1189 | + <select id="issue-milestone" name="milestone_id"> |
| 1190 | + <option value="" selected=(none_selected)>(g::t(lang, K::NoneOption))</option> |
| 1191 | + for row in options.iter() { |
| 1192 | + <option value=(row.id.as_str()) selected=(row.selected)>(row.title.as_str())</option> |
| 1193 | + } |
| 1194 | + </select> |
| 1195 | + </div> |
| 1196 | + <noscript><div><button type="submit" class="primary">(g::t(lang, K::SaveMilestone))</button></div></noscript> |
| 1197 | + </form> |
| 1198 | + ) |
| 1172 | 1199 | } |
| 1173 | | - </section> |
| 1200 | + </div> |
| 1174 | 1201 | }) |
| 1175 | 1202 | } |
| 1176 | 1203 | |
| | @@ -1192,48 +1219,43 @@ pub(crate) async fn lock_box( |
| 1192 | 1219 | .to_owned(); |
| 1193 | 1220 | let none = reason.is_none(); |
| 1194 | 1221 | Ok(view! { |
| 1195 | | - <section class="issue-side-section"> |
| 1196 | | - <h2>(g::t(lang, K::ConversationBox))</h2> |
| 1197 | | - if write { |
| 1198 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 1199 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1200 | | - if locked { |
| 1201 | | - <p class="muted small"> |
| 1202 | | - (g::t(lang, K::Locked)) |
| 1203 | | - if !none { |
| 1204 | | - " (" (reason_text.as_str()) ")" |
| 1205 | | - } |
| 1206 | | - </p> |
| 1207 | | - <input type="hidden" name="locked" value="0"> |
| 1208 | | - <div><button type="submit">(g::t(lang, K::UnlockConversation))</button></div> |
| 1209 | | - } else { |
| 1210 | | - <label> |
| 1211 | | - <span>(g::t(lang, K::Reason))</span> |
| 1212 | | - <select name="reason" aria-label=(g::t(lang, K::LockReasonAria))> |
| 1213 | | - <option value="" selected=(true)>(g::t(lang, K::NoReason))</option> |
| 1214 | | - <option value="off_topic">(g::t(lang, K::OptOffTopic))</option> |
| 1215 | | - <option value="too_heated">(g::t(lang, K::OptTooHeated))</option> |
| 1216 | | - <option value="resolved">(g::t(lang, K::OptResolved))</option> |
| 1217 | | - <option value="spam">(g::t(lang, K::OptSpam))</option> |
| 1218 | | - </select> |
| 1219 | | - </label> |
| 1220 | | - <input type="hidden" name="locked" value="1"> |
| 1221 | | - <div><button type="submit">(g::t(lang, K::LockConversation))</button></div> |
| 1222 | + <div class="acts"> |
| 1223 | + <span class="state"> |
| 1224 | + (g::t(lang, K::ConversationBox)) ": " |
| 1225 | + if locked { |
| 1226 | + (g::t(lang, K::LockedToCollaborators)) |
| 1227 | + if !none { |
| 1228 | + " (" (reason_text.as_str()) ")" |
| 1222 | 1229 | } |
| 1223 | | - </form> |
| 1224 | | - } else { |
| 1225 | | - <p class="muted small"> |
| 1226 | | - if locked { |
| 1227 | | - (g::t(lang, K::LockedToCollaborators)) |
| 1228 | | - if !none { |
| 1229 | | - " (" (reason_text.as_str()) ")" |
| 1230 | + } else { |
| 1231 | + (g::t(lang, K::OpenToEveryone)) |
| 1232 | + } |
| 1233 | + </span> |
| 1234 | + if write { |
| 1235 | + reveal(label: g::t(lang, K::Edit), |
| 1236 | + <form method="post" action=(action.as_str()) class="fields"> |
| 1237 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1238 | + if locked { |
| 1239 | + <input type="hidden" name="locked" value="0"> |
| 1240 | + <button type="submit" class="primary">(g::t(lang, K::UnlockConversation))</button> |
| 1241 | + } else { |
| 1242 | + <div class="field"> |
| 1243 | + <label for="issue-lock-reason">(g::t(lang, K::Reason))</label> |
| 1244 | + <select id="issue-lock-reason" name="reason"> |
| 1245 | + <option value="" selected=(true)>(g::t(lang, K::NoReason))</option> |
| 1246 | + <option value="off_topic">(g::t(lang, K::OptOffTopic))</option> |
| 1247 | + <option value="too_heated">(g::t(lang, K::OptTooHeated))</option> |
| 1248 | + <option value="resolved">(g::t(lang, K::OptResolved))</option> |
| 1249 | + <option value="spam">(g::t(lang, K::OptSpam))</option> |
| 1250 | + </select> |
| 1251 | + </div> |
| 1252 | + <input type="hidden" name="locked" value="1"> |
| 1253 | + <button type="submit" class="primary">(g::t(lang, K::LockConversation))</button> |
| 1230 | 1254 | } |
| 1231 | | - } else { |
| 1232 | | - (g::t(lang, K::OpenToEveryone)) |
| 1233 | | - } |
| 1234 | | - </p> |
| 1255 | + </form> |
| 1256 | + ) |
| 1235 | 1257 | } |
| 1236 | | - </section> |
| 1258 | + </div> |
| 1237 | 1259 | }) |
| 1238 | 1260 | } |
| 1239 | 1261 | |
| | @@ -1299,25 +1321,28 @@ pub(crate) async fn comment_form( |
| 1299 | 1321 | open: bool, |
| 1300 | 1322 | ) -> Result<impl View> { |
| 1301 | 1323 | Ok(view! { |
| 1302 | | - <section class="card issue-comment"> |
| 1303 | | - <h2 class="label">(g::t(lang, K::AddComment))</h2> |
| 1324 | + <section class="sec issue-comment"> |
| 1325 | + <h2>(g::t(lang, K::AddComment))</h2> |
| 1304 | 1326 | if let Some(message) = error { |
| 1305 | 1327 | alert(message: message.as_str()) |
| 1306 | 1328 | } |
| 1307 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 1329 | + <form method="post" action=(action.as_str()) class="fields"> |
| 1308 | 1330 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1309 | | - <textarea name="body" rows="3" aria-label=(g::t(lang, K::Comment))>(draft.as_str())</textarea> |
| 1310 | | - <div class="issue-actions"> |
| 1311 | | - <button type="submit" class="primary" name="action" value="comment">(g::t(lang, K::Comment))</button> |
| 1312 | | - if can_close { |
| 1331 | + <div class="field"> |
| 1332 | + <label for="issue-comment-body">(g::t(lang, K::Comment))</label> |
| 1333 | + <textarea id="issue-comment-body" name="body" rows="3">(draft.as_str())</textarea> |
| 1334 | + </div> |
| 1335 | + <button type="submit" class="primary" name="action" value="comment">(g::t(lang, K::Comment))</button> |
| 1336 | + if can_close { |
| 1337 | + <div class="acts"> |
| 1313 | 1338 | if open { |
| 1314 | | - <button type="submit" name="action" value="close_completed" formaction=(state_action.as_str()) data-palette-action="post">(g::t(lang, K::CloseCompleted))</button> |
| 1315 | | - <button type="submit" name="action" value="close_not_planned" formaction=(state_action.as_str()) data-palette-action="post">(g::t(lang, K::CloseNotPlanned))</button> |
| 1339 | + <button type="submit" class="act" name="action" value="close_completed" formaction=(state_action.as_str()) data-palette-action="post">(g::t(lang, K::CloseCompleted))</button> |
| 1340 | + <button type="submit" class="act" name="action" value="close_not_planned" formaction=(state_action.as_str()) data-palette-action="post">(g::t(lang, K::CloseNotPlanned))</button> |
| 1316 | 1341 | } else { |
| 1317 | | - <button type="submit" name="action" value="reopen" formaction=(state_action.as_str()) data-palette-action="post">(g::t(lang, K::ReopenWithComment))</button> |
| 1342 | + <button type="submit" class="act" name="action" value="reopen" formaction=(state_action.as_str()) data-palette-action="post">(g::t(lang, K::ReopenWithComment))</button> |
| 1318 | 1343 | } |
| 1319 | | - } |
| 1320 | | - </div> |
| 1344 | + </div> |
| 1345 | + } |
| 1321 | 1346 | </form> |
| 1322 | 1347 | </section> |
| 1323 | 1348 | }) |
| | @@ -20,6 +20,7 @@ use crate::pages::issue_meta::{ |
| 20 | 20 | use crate::pages::issue_parts::{ItemKind, bump_live}; |
| 21 | 21 | use crate::pages::repo_ctx::load_repo; |
| 22 | 22 | use crate::state::AppState; |
| 23 | +use crate::views::parts::post_act; |
| 23 | 24 | use crate::views::shell; |
| 24 | 25 | |
| 25 | 26 | path_param!(owner); |
| | @@ -91,21 +92,18 @@ pub(crate) async fn pin_box( |
| 91 | 92 | g::t(lang, K::PinIssue) |
| 92 | 93 | }; |
| 93 | 94 | Ok(view! { |
| 94 | | - <section class="issue-side-section"> |
| 95 | | - <h2>(g::t(lang, K::Pinned))</h2> |
| 96 | | - if write { |
| 97 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 98 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 99 | | - <input type="hidden" name="pinned" value=(next)> |
| 100 | | - <div><button type="submit">(label)</button></div> |
| 101 | | - </form> |
| 102 | | - } else { |
| 95 | + <div class="acts"> |
| 96 | + <span class="state"> |
| 97 | + (g::t(lang, K::Pinned)) ": " |
| 103 | 98 | if pinned { |
| 104 | | - <p>(g::t(lang, K::PinnedTopNote))</p> |
| 99 | + (g::t(lang, K::PinnedTopNote)) |
| 105 | 100 | } else { |
| 106 | | - <p class="muted small">(g::t(lang, K::NotPinned))</p> |
| 101 | + (g::t(lang, K::NotPinned)) |
| 107 | 102 | } |
| 103 | + </span> |
| 104 | + if write { |
| 105 | + post_act(label: label, action: action.as_str(), csrf: csrf.as_str(), fields: vec![("pinned".to_owned(), next.to_owned())]) |
| 108 | 106 | } |
| 109 | | - </section> |
| 107 | + </div> |
| 110 | 108 | }) |
| 111 | 109 | } |
| | @@ -318,15 +318,18 @@ async fn pin_controls_and_cards_show_for_the_right_viewers() { |
| 318 | 318 | |
| 319 | 319 | let reply = call(&s.site, "GET", "/tahinli/forge/issues", None, None).await; |
| 320 | 320 | assert_eq!(reply.status, 200, "issue list"); |
| 321 | | - assert!(reply.body.contains("pinned-card"), "pinned card shown"); |
| 321 | + assert!( |
| 322 | + reply.body.contains("aria-label=\"Pinned issues\""), |
| 323 | + "pinned card shown" |
| 324 | + ); |
| 322 | 325 | assert!( |
| 323 | 326 | reply |
| 324 | 327 | .body |
| 325 | 328 | .contains(&format!("/tahinli/forge/issues/{number}\"")), |
| 326 | 329 | "pinned card links the pinned issue" |
| 327 | 330 | ); |
| 328 | | - let card_at = reply.body.find("pinned-card").expect("card"); |
| 329 | | - let list_at = reply.body.find("issue-list").expect("list"); |
| 331 | + let card_at = reply.body.find("aria-label=\"Pinned issues\"").expect("card"); |
| 332 | + let list_at = reply.body.find("class=\"line issue-row\"").expect("list"); |
| 330 | 333 | assert!(card_at < list_at, "pinned cards sit above the list"); |
| 331 | 334 | |
| 332 | 335 | let (_, first_number) = s.issues[0].clone(); |
| | @@ -94,39 +94,39 @@ async fn issue_page( |
| 94 | 94 | Ok(view! { cx => |
| 95 | 95 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), |
| 96 | 96 | repo_head(head: header) |
| 97 | | - <section class="issue-head" data-live=(live_href.as_str()) data-live-now=""> |
| 98 | | - <h1 class="issue-heading">(issue.title.as_str()) " " <span class="issue-number">(number_label.as_str())</span></h1> |
| 99 | | - <p class="issue-byline"> |
| 97 | + <section class="sec" data-live=(live_href.as_str()) data-live-now=""> |
| 98 | + <h1 class="h1">(issue.title.as_str()) " " <span class="hint">(number_label.as_str())</span></h1> |
| 99 | + <p class="hint"> |
| 100 | 100 | <span class=(state_class)>(state_text)</span> |
| 101 | + " · " |
| 101 | 102 | <strong>user_link(shown: author.as_str(), login: author_login.as_str())</strong> |
| 103 | + " " |
| 102 | 104 | (g::t(lang, K::OpenedThis)) |
| 105 | + " " |
| 103 | 106 | <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> |
| 107 | + " " |
| 104 | 108 | (g::opened_after(lang)) |
| 105 | 109 | " · " |
| 106 | 110 | (comments_label.as_str()) |
| 107 | 111 | </p> |
| 108 | 112 | </section> |
| 109 | | - <div class="issue-layout"> |
| 110 | | - <div class="issue-column fit-pane"> |
| 111 | | - discussion_timeline(lang: lang, discussion: discussion) |
| 112 | | - if can_comment { |
| 113 | | - comment_form(lang: lang, action: comment_action.clone(), state_action: comment_action.clone(), |
| 114 | | - csrf: csrf.clone(), draft: draft, error: error, can_close: editable_issue, open: open) |
| 115 | | - } |
| 116 | | - if archived { |
| 117 | | - <p class="muted">(g::t(lang, K::ArchivedIssuesReadOnly))</p> |
| 118 | | - } |
| 119 | | - if locked_for_viewer { |
| 120 | | - <p class="muted">(lock_notice.as_str())</p> |
| 121 | | - } else if !signed_in { |
| 122 | | - <p class="muted">(g::comment_login_lead(lang))<a href=(login_href.as_str())>(g::t(lang, K::LogInLink))</a>(g::t(lang, K::ToComment))</p> |
| 123 | | - } |
| 124 | | - </div> |
| 125 | | - <aside class="issue-sidebar fit-pane"> |
| 126 | | - pin_box(lang: lang, write: write_meta, pinned: pinned, action: pin_action.clone(), csrf: csrf.clone()) |
| 127 | | - item_sidebar(lang: lang, write: write_meta, base: issue_href.clone(), csrf: csrf.clone(), viewer: viewer_login, sidebar: sidebar, notify: notify) |
| 128 | | - </aside> |
| 129 | | - </div> |
| 113 | + <section class="sec"> |
| 114 | + pin_box(lang: lang, write: write_meta, pinned: pinned, action: pin_action.clone(), csrf: csrf.clone()) |
| 115 | + item_sidebar(lang: lang, write: write_meta, base: issue_href.clone(), csrf: csrf.clone(), viewer: viewer_login, sidebar: sidebar, notify: notify) |
| 116 | + </section> |
| 117 | + discussion_timeline(lang: lang, discussion: discussion) |
| 118 | + if can_comment { |
| 119 | + comment_form(lang: lang, action: comment_action.clone(), state_action: comment_action.clone(), |
| 120 | + csrf: csrf.clone(), draft: draft, error: error, can_close: editable_issue, open: open) |
| 121 | + } |
| 122 | + if archived { |
| 123 | + <p class="hint">(g::t(lang, K::ArchivedIssuesReadOnly))</p> |
| 124 | + } |
| 125 | + if locked_for_viewer { |
| 126 | + <p class="hint">(lock_notice.as_str())</p> |
| 127 | + } else if !signed_in { |
| 128 | + <p class="hint">(g::comment_login_lead(lang))<a href=(login_href.as_str())>(g::t(lang, K::LogInLink))</a>(g::t(lang, K::ToComment))</p> |
| 129 | + } |
| 130 | 130 | ) |
| 131 | 131 | }) |
| 132 | 132 | } |
| | @@ -217,26 +217,26 @@ async fn edit_item_page( |
| 217 | 217 | Ok(view! { cx => |
| 218 | 218 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 219 | 219 | repo_head(head: header) |
| 220 | | - <section class="card issue-edit"> |
| 221 | | - <h2>(heading.as_str())</h2> |
| 220 | + <section class="sec"> |
| 221 | + <h1 class="h1">(heading.as_str())</h1> |
| 222 | 222 | if let Some(message) = error { |
| 223 | 223 | alert(message: message.as_str()) |
| 224 | 224 | } |
| 225 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 225 | + <form method="post" action=(action.as_str()) class="fields"> |
| 226 | 226 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 227 | | - <label> |
| 228 | | - <span>(g::t(lang, K::Title))</span> |
| 229 | | - <input type="text" name="title" value=(title.as_str()) required=(true) autocomplete="off"> |
| 230 | | - </label> |
| 231 | | - <label> |
| 232 | | - <span>(g::t(lang, K::Description))</span> |
| 233 | | - <textarea name="body" rows="12">(body.as_str())</textarea> |
| 234 | | - </label> |
| 235 | | - <div class="issue-actions"> |
| 236 | | - <button type="submit" class="primary">(g::t(lang, K::SaveChanges))</button> |
| 237 | | - <a class="button" href=(back.as_str())>(g::t(lang, K::Cancel))</a> |
| 227 | + <div class="field"> |
| 228 | + <label for="item-title">(g::t(lang, K::Title))</label> |
| 229 | + <input id="item-title" type="text" name="title" value=(title.as_str()) required=(true) autocomplete="off"> |
| 230 | + </div> |
| 231 | + <div class="field"> |
| 232 | + <label for="item-body">(g::t(lang, K::Description))</label> |
| 233 | + <textarea id="item-body" name="body" rows="12">(body.as_str())</textarea> |
| 238 | 234 | </div> |
| 235 | + <button type="submit" class="primary">(g::t(lang, K::SaveChanges))</button> |
| 239 | 236 | </form> |
| 237 | + <div class="acts"> |
| 238 | + <a class="act quiet" href=(back.as_str())>(g::t(lang, K::Cancel))</a> |
| 239 | + </div> |
| 240 | 240 | </section> |
| 241 | 241 | ) |
| 242 | 242 | }) |
| | @@ -333,22 +333,22 @@ async fn edit_comment_page( |
| 333 | 333 | Ok(view! { cx => |
| 334 | 334 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 335 | 335 | repo_head(head: header) |
| 336 | | - <section class="card issue-edit"> |
| 337 | | - <h2>(g::t(lang, K::EditComment))</h2> |
| 336 | + <section class="sec"> |
| 337 | + <h1 class="h1">(g::t(lang, K::EditComment))</h1> |
| 338 | 338 | if let Some(message) = error { |
| 339 | 339 | alert(message: message.as_str()) |
| 340 | 340 | } |
| 341 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 341 | + <form method="post" action=(action.as_str()) class="fields"> |
| 342 | 342 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 343 | | - <label> |
| 344 | | - <span>(g::t(lang, K::Comment))</span> |
| 345 | | - <textarea name="body" rows="10">(body.as_str())</textarea> |
| 346 | | - </label> |
| 347 | | - <div class="issue-actions"> |
| 348 | | - <button type="submit" class="primary">(g::t(lang, K::SaveComment))</button> |
| 349 | | - <a class="button" href=(back.as_str())>(g::t(lang, K::Cancel))</a> |
| 343 | + <div class="field"> |
| 344 | + <label for="comment-body">(g::t(lang, K::Comment))</label> |
| 345 | + <textarea id="comment-body" name="body" rows="10">(body.as_str())</textarea> |
| 350 | 346 | </div> |
| 347 | + <button type="submit" class="primary">(g::t(lang, K::SaveComment))</button> |
| 351 | 348 | </form> |
| 349 | + <div class="acts"> |
| 350 | + <a class="act quiet" href=(back.as_str())>(g::t(lang, K::Cancel))</a> |
| 351 | + </div> |
| 352 | 352 | </section> |
| 353 | 353 | ) |
| 354 | 354 | }) |
| | @@ -26,7 +26,7 @@ use crate::pages::repo_ctx::{RepoHead, load_repo}; |
| 26 | 26 | use crate::state::AppState; |
| 27 | 27 | use crate::templates::{self, Template}; |
| 28 | 28 | use crate::views::{ |
| 29 | | - alert, avatar_url, csrf_field, empty_state, enc, iso_time, now_unix, relative_time, repo_href, |
| 29 | + alert, avatar_url, csrf_field, enc, iso_time, now_unix, relative_time, repo_href, |
| 30 | 30 | shell, user_facing_message, user_link, |
| 31 | 31 | }; |
| 32 | 32 | use crate::webhooks::emit::{Sender, emit_issue}; |
| | @@ -242,9 +242,16 @@ pub(crate) fn stamp_unix(stamp: &str) -> i64 { |
| 242 | 242 | .map_or(0, |t| t.unix_timestamp()) |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | | -/// Tab class for the state links. |
| 246 | | -pub(crate) fn state_tab_class(on: bool) -> &'static str { |
| 247 | | - if on { "issue-tab current" } else { "issue-tab" } |
| 245 | +/// One link of a tab row. The current tab carries `aria-current`. |
| 246 | +#[component] |
| 247 | +pub(crate) async fn state_tab(href: &str, text: &str, current: bool) -> Result<impl View> { |
| 248 | + Ok(view! { |
| 249 | + if current { |
| 250 | + <a aria-current="page" href=(href)>(text)</a> |
| 251 | + } else { |
| 252 | + <a href=(href)>(text)</a> |
| 253 | + } |
| 254 | + }) |
| 248 | 255 | } |
| 249 | 256 | |
| 250 | 257 | pub(crate) struct AssigneeView { |
| | @@ -493,82 +500,75 @@ async fn issues_list_page(cx: &Cx) -> Result<impl View> { |
| 493 | 500 | g::t(lang, K::NoIssuesYet) |
| 494 | 501 | }; |
| 495 | 502 | let state_word = sel.state; |
| 503 | + let open_on = state_word == "open"; |
| 504 | + let closed_on = state_word == "closed"; |
| 505 | + let all_on = state_word == "all"; |
| 496 | 506 | |
| 497 | 507 | let live_href = list_live_url(&owner_name, &repo_name); |
| 498 | 508 | let header = ctx.head(state, "issues").await?; |
| 499 | 509 | Ok(view! { |
| 500 | 510 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), |
| 501 | 511 | repo_head(head: header) |
| 502 | | - <section class="issue-pane fit-pane"> |
| 503 | | - <div class="issue-toolbar" data-live=(live_href.as_str()) data-live-now=""> |
| 504 | | - <nav class="issue-tabs" aria-label=(g::t(lang, K::IssuesByState))> |
| 505 | | - <a class=(state_tab_class(state_word == "open")) href=(open_href.as_str())>(open_text.as_str())</a> |
| 506 | | - <a class=(state_tab_class(state_word == "closed")) href=(closed_href.as_str())>(closed_text.as_str())</a> |
| 507 | | - <a class=(state_tab_class(state_word == "all")) href=(all_href.as_str())>(all_text.as_str())</a> |
| 508 | | - </nav> |
| 509 | | - <form method="get" action=(base.as_str()) class="issue-search"> |
| 510 | | - <input type="hidden" name="state" value=(sel.state)> |
| 511 | | - <input type="hidden" name="label" value=(sel.label.as_str())> |
| 512 | | - <input type="hidden" name="milestone" value=(sel.milestone.as_str())> |
| 513 | | - <input type="hidden" name="author" value=(sel.author.as_str())> |
| 514 | | - <input type="hidden" name="assignee" value=(sel.assignee.as_str())> |
| 512 | + <div data-live=(live_href.as_str()) data-live-now=""> |
| 513 | + <h1 class="sr-only">(title.as_str())</h1> |
| 514 | + <nav class="tabs" aria-label=(g::t(lang, K::IssuesByState))> |
| 515 | + state_tab(href: open_href.as_str(), text: open_text.as_str(), current: open_on) |
| 516 | + state_tab(href: closed_href.as_str(), text: closed_text.as_str(), current: closed_on) |
| 517 | + state_tab(href: all_href.as_str(), text: all_text.as_str(), current: all_on) |
| 518 | + </nav> |
| 519 | + <form method="get" action=(base.as_str())> |
| 520 | + <input type="hidden" name="state" value=(sel.state)> |
| 521 | + <input type="hidden" name="label" value=(sel.label.as_str())> |
| 522 | + <input type="hidden" name="milestone" value=(sel.milestone.as_str())> |
| 523 | + <input type="hidden" name="author" value=(sel.author.as_str())> |
| 524 | + <input type="hidden" name="assignee" value=(sel.assignee.as_str())> |
| 525 | + <div class="plain-search"> |
| 515 | 526 | <input type="search" name="q" value=(search_value.as_str()) placeholder=(g::t(lang, K::SearchTitles)) aria-label=(g::t(lang, K::SearchTitles)) maxlength="256"> |
| 527 | + <button type="submit" class="sr-only">(g::t(lang, K::Search))</button> |
| 528 | + </div> |
| 529 | + <div class="sub"> |
| 516 | 530 | <select name="sort" aria-label=(g::t(lang, K::Sort))> |
| 517 | 531 | for option in sort_options.iter() { |
| 518 | 532 | <option value=(option.value) selected=(option.selected)>(option.label)</option> |
| 519 | 533 | } |
| 520 | 534 | </select> |
| 521 | | - <button type="submit" class="sr-only">(g::t(lang, K::Search))</button> |
| 522 | | - </form> |
| 523 | | - <div class="issue-tools"> |
| 524 | | - <details class="list-more"> |
| 525 | | - <summary aria-label=(crate::pages::passkeys::s(lang, "More", "Diğer"))>"…"</summary> |
| 526 | | - <nav class="list-more-menu" aria-label=(g::t(lang, K::LabelsAndMilestones))> |
| 527 | | - <a href=(labels_page_href.as_str())>(g::t(lang, K::Labels))</a> |
| 528 | | - <a href=(milestones_href.as_str())>(g::t(lang, K::Milestones))</a> |
| 529 | | - </nav> |
| 530 | | - </details> |
| 535 | + <a href=(labels_page_href.as_str())>(g::t(lang, K::Labels))</a> |
| 536 | + <a href=(milestones_href.as_str())>(g::t(lang, K::Milestones))</a> |
| 531 | 537 | if can_create { |
| 532 | | - <a class="button" href=(new_href.as_str()) data-palette-action="go">(g::t(lang, K::NewIssue))</a> |
| 538 | + <a class="act" href=(new_href.as_str()) data-palette-action="go">(g::t(lang, K::NewIssue))</a> |
| 533 | 539 | } |
| 534 | 540 | </div> |
| 535 | | - </div> |
| 541 | + </form> |
| 536 | 542 | if has_filters { |
| 537 | | - <p class="muted small">(g::t(lang, K::FiltersApplied)) <a href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a></p> |
| 543 | + <p class="hint">(g::t(lang, K::FiltersApplied)) " " <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a></p> |
| 538 | 544 | } |
| 539 | 545 | if !pinned.is_empty() { |
| 540 | | - <section class="pinned-issues" aria-label=(g::t(lang, K::PinnedIssues))> |
| 546 | + <section class="sec" aria-label=(g::t(lang, K::PinnedIssues))> |
| 541 | 547 | <h2>(g::t(lang, K::Pinned))</h2> |
| 542 | | - <ul class="pinned-list"> |
| 543 | | - for card in pinned.iter() { |
| 544 | | - <li class="pinned-card"> |
| 545 | | - <div class="issue-meta muted small"> |
| 546 | | - <span class=(card.state_class) role="img" aria-label=(card.state_label)></span> |
| 547 | | - <span>(card.number_text.as_str())</span> |
| 548 | | - <span>(card.comments_text.as_str())</span> |
| 549 | | - </div> |
| 550 | | - <a class="pinned-title" href=(card.href.as_str())>(card.title.as_str())</a> |
| 551 | | - </li> |
| 552 | | - } |
| 553 | | - </ul> |
| 548 | + for card in pinned.iter() { |
| 549 | + <a class="line" href=(card.href.as_str())> |
| 550 | + <span class=(card.state_class) role="img" aria-label=(card.state_label)></span> |
| 551 | + <span class="name">(card.title.as_str())</span> |
| 552 | + <span class="val">(card.number_text.as_str()) " · " (card.comments_text.as_str())</span> |
| 553 | + </a> |
| 554 | + } |
| 554 | 555 | </section> |
| 555 | 556 | } |
| 556 | 557 | if rows.is_empty() { |
| 558 | + <p class="state">(empty_text)</p> |
| 557 | 559 | if has_filters { |
| 558 | | - empty_state(title: empty_text, |
| 559 | | - <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> |
| 560 | | - ) |
| 561 | | - } else { |
| 562 | | - empty_state(title: empty_text, |
| 563 | | - if can_create { |
| 564 | | - <a class="button primary" href=(new_href.as_str()) data-palette-action="go">(g::t(lang, K::NewIssue))</a> |
| 565 | | - } |
| 566 | | - ) |
| 560 | + <div class="acts"> |
| 561 | + <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> |
| 562 | + </div> |
| 563 | + } else if can_create { |
| 564 | + <div class="acts"> |
| 565 | + <a class="act" href=(new_href.as_str()) data-palette-action="go">(g::t(lang, K::NewIssue))</a> |
| 566 | + </div> |
| 567 | 567 | } |
| 568 | 568 | } else { |
| 569 | | - <ul class="issue-list"> |
| 569 | + <div> |
| 570 | 570 | for row in rows.iter() { |
| 571 | | - <li class="issue-row" data-kb-row="" data-arrive=(row.arrive.as_str())> |
| 571 | + <div class="line issue-row" data-kb-row="" data-arrive=(row.arrive.as_str())> |
| 572 | 572 | <span class=(row.state_class) role="img" aria-label=(row.state_label)></span> |
| 573 | 573 | <div class="issue-main"> |
| 574 | 574 | <div class="issue-title-line"> |
| | @@ -596,32 +596,30 @@ async fn issues_list_page(cx: &Cx) -> Result<impl View> { |
| 596 | 596 | if let Some(tasks) = row.tasks_text.clone() { |
| 597 | 597 | <span class="task-progress">(tasks.as_str())</span> |
| 598 | 598 | } |
| 599 | + for assignee in row.assignees.iter() { |
| 600 | + <img class="avatar avatar-sm" src=(assignee.avatar.as_str()) alt=(assignee.name.as_str()) title=(assignee.name.as_str()) width="20" height="20"> |
| 601 | + } |
| 602 | + if row.has_comments { |
| 603 | + <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> |
| 604 | + } |
| 599 | 605 | </div> |
| 600 | 606 | </div> |
| 601 | | - <div class="issue-aside"> |
| 602 | | - for assignee in row.assignees.iter() { |
| 603 | | - <img class="avatar avatar-sm" src=(assignee.avatar.as_str()) alt=(assignee.name.as_str()) title=(assignee.name.as_str()) width="20" height="20"> |
| 604 | | - } |
| 605 | | - if row.has_comments { |
| 606 | | - <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> |
| 607 | | - } |
| 608 | | - </div> |
| 609 | | - </li> |
| 607 | + </div> |
| 610 | 608 | } |
| 611 | | - </ul> |
| 609 | + </div> |
| 612 | 610 | } |
| 613 | 611 | if has_newer || has_older { |
| 614 | | - <nav class="pager"> |
| 612 | + <nav class="sub"> |
| 615 | 613 | if has_newer { |
| 616 | 614 | <a href=(newer_href.as_str())>(g::t(lang, K::Newer))</a> |
| 617 | 615 | } |
| 618 | | - <span class="muted small">(page_label.as_str())</span> |
| 616 | + <span>(page_label.as_str())</span> |
| 619 | 617 | if has_older { |
| 620 | 618 | <a href=(older_href.as_str())>(g::t(lang, K::Older))</a> |
| 621 | 619 | } |
| 622 | 620 | </nav> |
| 623 | 621 | } |
| 624 | | - </section> |
| 622 | + </div> |
| 625 | 623 | ) |
| 626 | 624 | }) |
| 627 | 625 | } |
| | @@ -712,59 +710,53 @@ async fn new_issue_body( |
| 712 | 710 | let has_labels = !labels.is_empty(); |
| 713 | 711 | Ok(view! { |
| 714 | 712 | repo_head(head: head) |
| 715 | | - <section class="card issue-new fit-pane"> |
| 716 | | - <h2>(g::t(lang, K::NewIssue))</h2> |
| 717 | | - if chooser_mode { |
| 718 | | - <p class="muted">(g::t(lang, K::ChooseTemplate))</p> |
| 719 | | - <ul class="issue-list"> |
| 720 | | - for row in rows.iter() { |
| 721 | | - <li class="issue-row"> |
| 722 | | - <div class="issue-main"> |
| 723 | | - <a class="issue-title" href=(row.href.as_str())>(row.name.as_str())</a> |
| 724 | | - if !row.about.is_empty() { |
| 725 | | - <div class="muted small">(row.about.as_str())</div> |
| 726 | | - } |
| 727 | | - </div> |
| 728 | | - </li> |
| 729 | | - } |
| 730 | | - </ul> |
| 731 | | - <div class="issue-actions"> |
| 732 | | - <a href=(blank.as_str())>(g::t(lang, K::BlankIssue))</a> |
| 733 | | - <a class="button" href=(cancel.as_str())>(g::t(lang, K::Cancel))</a> |
| 734 | | - </div> |
| 735 | | - } else { |
| 736 | | - if let Some(message) = draft.error { |
| 737 | | - alert(message: message.as_str()) |
| 713 | + <h1 class="sr-only">(g::t(lang, K::NewIssue))</h1> |
| 714 | + if chooser_mode { |
| 715 | + <p class="state">(g::t(lang, K::ChooseTemplate))</p> |
| 716 | + <div> |
| 717 | + for row in rows.iter() { |
| 718 | + <a class="line" href=(row.href.as_str())> |
| 719 | + <span class="name">(row.name.as_str())</span> |
| 720 | + <span class="val">(row.about.as_str())</span> |
| 721 | + </a> |
| 738 | 722 | } |
| 739 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 740 | | - csrf_field(token: csrf.as_str()) |
| 741 | | - <label> |
| 742 | | - <span>(g::t(lang, K::Title))</span> |
| 743 | | - <input type="text" name="title" value=(draft.title.as_str()) required=(true) autocomplete="off"> |
| 744 | | - </label> |
| 745 | | - <label> |
| 746 | | - <span>(g::t(lang, K::Description))</span> |
| 747 | | - <textarea name="body" rows="12">(draft.body.as_str())</textarea> |
| 748 | | - <span class="muted small">(g::t(lang, K::MarkdownSupported))</span> |
| 749 | | - </label> |
| 750 | | - if has_labels { |
| 751 | | - <fieldset class="label-picker"> |
| 752 | | - <legend>(g::t(lang, K::Labels))</legend> |
| 753 | | - for label in labels.iter() { |
| 754 | | - <label class="inline-form"> |
| 755 | | - <input type="checkbox" name="label" value=(label.id.as_str()) checked=(label.checked)> |
| 756 | | - <span>(label.name.as_str())</span> |
| 757 | | - </label> |
| 758 | | - } |
| 759 | | - </fieldset> |
| 760 | | - } |
| 761 | | - <div class="issue-actions"> |
| 762 | | - <button type="submit" class="primary">(g::t(lang, K::SubmitNewIssue))</button> |
| 763 | | - <a class="button" href=(cancel.as_str())>(g::t(lang, K::Cancel))</a> |
| 764 | | - </div> |
| 765 | | - </form> |
| 723 | + </div> |
| 724 | + <div class="acts"> |
| 725 | + <a class="act" href=(blank.as_str())>(g::t(lang, K::BlankIssue))</a> |
| 726 | + <a class="act quiet" href=(cancel.as_str())>(g::t(lang, K::Cancel))</a> |
| 727 | + </div> |
| 728 | + } else { |
| 729 | + if let Some(message) = draft.error { |
| 730 | + alert(message: message.as_str()) |
| 766 | 731 | } |
| 767 | | - </section> |
| 732 | + <form method="post" action=(action.as_str()) class="fields"> |
| 733 | + csrf_field(token: csrf.as_str()) |
| 734 | + <div class="field"> |
| 735 | + <label for="issue-title">(g::t(lang, K::Title))</label> |
| 736 | + <input id="issue-title" type="text" name="title" value=(draft.title.as_str()) required=(true) autocomplete="off"> |
| 737 | + </div> |
| 738 | + <div class="field"> |
| 739 | + <label for="issue-body">(g::t(lang, K::Description))</label> |
| 740 | + <textarea id="issue-body" name="body" rows="12">(draft.body.as_str())</textarea> |
| 741 | + <p class="hint">(g::t(lang, K::MarkdownSupported))</p> |
| 742 | + </div> |
| 743 | + if has_labels { |
| 744 | + <fieldset class="field"> |
| 745 | + <legend>(g::t(lang, K::Labels))</legend> |
| 746 | + for label in labels.iter() { |
| 747 | + <label class="switch"> |
| 748 | + <input type="checkbox" name="label" value=(label.id.as_str()) checked=(label.checked)> |
| 749 | + <span>(label.name.as_str())</span> |
| 750 | + </label> |
| 751 | + } |
| 752 | + </fieldset> |
| 753 | + } |
| 754 | + <div class="acts"> |
| 755 | + <button type="submit" class="primary">(g::t(lang, K::SubmitNewIssue))</button> |
| 756 | + <a class="act quiet" href=(cancel.as_str())>(g::t(lang, K::Cancel))</a> |
| 757 | + </div> |
| 758 | + </form> |
| 759 | + } |
| 768 | 760 | }) |
| 769 | 761 | } |
| 770 | 762 | |
| | @@ -1020,9 +1012,9 @@ mod tests { |
| 1020 | 1012 | format!("/{OWNER}/{REPO}/issues") |
| 1021 | 1013 | } |
| 1022 | 1014 | |
| 1023 | | - /// Number of issue rows in a page. |
| 1015 | + /// Number of issue rows in a page. Rows carry `line issue-row` plus `data-kb-row`. |
| 1024 | 1016 | fn rows(html: &str) -> usize { |
| 1025 | | - html.matches("class=\"issue-row\"").count() |
| 1017 | + html.matches("issue-row\" data-kb-row").count() |
| 1026 | 1018 | } |
| 1027 | 1019 | |
| 1028 | 1020 | /// One pristine public fixture, in order: empty list and toolbar links, Turkish empty state, |
| | @@ -21,6 +21,7 @@ use crate::pages::issues_live::list_live_url; |
| 21 | 21 | use crate::pages::repo::repo_head; |
| 22 | 22 | use crate::pages::repo_ctx::load_repo; |
| 23 | 23 | use crate::state::AppState; |
| 24 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 24 | 25 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 25 | 26 | use crate::views::{enc, shell}; |
| 26 | 27 | |
| | @@ -59,6 +60,8 @@ struct CsrfForm { |
| 59 | 60 | |
| 60 | 61 | /// One label as the page shows it. |
| 61 | 62 | struct LabelRow { |
| 63 | + /// The label's id, used to tie each edit field to its label. |
| 64 | + key: String, |
| 62 | 65 | name: String, |
| 63 | 66 | description: String, |
| 64 | 67 | color: String, |
| | @@ -96,101 +99,87 @@ async fn labels_body( |
| 96 | 99 | Ok(view! { |
| 97 | 100 | repo_head(head: header) |
| 98 | 101 | if archived { |
| 99 | | - <section class="card notice" role="status">(g::t(lang, K::LabelsArchived))</section> |
| 102 | + <p class="state" role="status">(g::t(lang, K::LabelsArchived))</p> |
| 100 | 103 | } |
| 101 | | - <div class="list-bar"> |
| 102 | | - issue_subnav(lang: lang, title: frame.title.clone(), active: "labels".to_owned()) |
| 103 | | - </div> |
| 104 | | - <section class="card rows-pane lang-list" data-live=(live.as_str()) data-live-now=""> |
| 104 | + issue_subnav(lang: lang, title: frame.title.clone(), active: "labels".to_owned()) |
| 105 | + <div class="lang-list" data-live=(live.as_str()) data-live-now=""> |
| 105 | 106 | <h2 class="sr-only">(g::t(lang, K::Labels))</h2> |
| 106 | 107 | if can_triage { |
| 107 | | - <div class="row-line"> |
| 108 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 109 | | - <div class="row-main"> |
| 110 | | - <h2 class="row-title">(g::t(lang, K::NewLabel))</h2> |
| 111 | | - if empty { |
| 112 | | - <p class="row-status">(g::t(lang, K::NoLabelsYet))</p> |
| 113 | | - } |
| 114 | | - </div> |
| 115 | | - if empty && !archived { |
| 116 | | - <form method="post" action=(defaults_action.as_str()) class="row-form"> |
| 117 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 118 | | - <button type="submit">(g::t(lang, K::AddDefaultLabels))</button> |
| 119 | | - </form> |
| 108 | + <section class="sec"> |
| 109 | + <h2>(g::t(lang, K::NewLabel))</h2> |
| 110 | + if empty { |
| 111 | + <p class="state">(g::t(lang, K::NoLabelsYet))</p> |
| 120 | 112 | } |
| 121 | | - <details class="row-action"> |
| 122 | | - <summary>(g::t(lang, K::CreateLabel))</summary> |
| 123 | | - <div class="row-panel"> |
| 124 | | - <form method="post" action=(labels_action.as_str()) class="stack"> |
| 113 | + <div class="acts"> |
| 114 | + if empty && !archived { |
| 115 | + post_act(label: g::t(lang, K::AddDefaultLabels), action: defaults_action.as_str(), csrf: csrf.as_str()) |
| 116 | + } |
| 117 | + reveal(label: g::t(lang, K::CreateLabel), id: Some("create-label"), open: false, |
| 118 | + <form method="post" action=(labels_action.as_str()) class="fields"> |
| 125 | 119 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 126 | | - <label> |
| 127 | | - <span>(g::t(lang, K::Name))</span> |
| 128 | | - <input type="text" name="name" autocomplete="off" required=(true) maxlength="50"> |
| 129 | | - </label> |
| 130 | | - <label> |
| 131 | | - <span>(g::t(lang, K::Color))</span> |
| 132 | | - <input type="color" name="color" value="#ededed"> |
| 133 | | - </label> |
| 134 | | - <label> |
| 135 | | - <span>(g::t(lang, K::Description))</span> |
| 136 | | - <input type="text" name="description" autocomplete="off" maxlength="500"> |
| 137 | | - </label> |
| 120 | + <div class="field"> |
| 121 | + <label for="label-create-name">(g::t(lang, K::Name))</label> |
| 122 | + <input id="label-create-name" type="text" name="name" autocomplete="off" required=(true) maxlength="50"> |
| 123 | + </div> |
| 124 | + <div class="field"> |
| 125 | + <label for="label-create-color">(g::t(lang, K::Color))</label> |
| 126 | + <input id="label-create-color" type="color" name="color" value="#ededed"> |
| 127 | + </div> |
| 128 | + <div class="field"> |
| 129 | + <label for="label-create-description">(g::t(lang, K::Description))</label> |
| 130 | + <input id="label-create-description" type="text" name="description" autocomplete="off" maxlength="500"> |
| 131 | + </div> |
| 138 | 132 | <button type="submit" class="primary">(g::t(lang, K::CreateLabel))</button> |
| 139 | 133 | </form> |
| 140 | | - </div> |
| 141 | | - </details> |
| 142 | | - </div> |
| 143 | | - } else if empty { |
| 144 | | - <div class="row-line"> |
| 145 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 146 | | - <div class="row-main"> |
| 147 | | - <h2 class="row-title">(g::t(lang, K::NoLabelsYet))</h2> |
| 134 | + ) |
| 148 | 135 | </div> |
| 149 | | - </div> |
| 136 | + </section> |
| 137 | + } else if empty { |
| 138 | + <p class="state">(g::t(lang, K::NoLabelsYet))</p> |
| 150 | 139 | } |
| 151 | | - for row in rows.iter() { |
| 152 | | - <div class="row-line" data-kb-row=""> |
| 153 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8z"/><circle cx="7.5" cy="7.5" r="1.5"/></svg> |
| 154 | | - <div class="row-main"> |
| 155 | | - <strong class="row-name"><a class=(row.chip_class.as_str()) href=(row.issues_href.as_str())>(row.name.as_str())</a></strong> |
| 156 | | - <p class="row-status"> |
| 157 | | - if !row.description.is_empty() { |
| 158 | | - <span>(row.description.as_str())</span> " \u{b7} " |
| 140 | + <div> |
| 141 | + for row in rows.iter() { |
| 142 | + <details class="row-open" data-kb-row=""> |
| 143 | + <summary class="line"> |
| 144 | + <span class="name"><span class=(row.chip_class.as_str())>(row.name.as_str())</span></span> |
| 145 | + <span class="val"> |
| 146 | + if !row.description.is_empty() { |
| 147 | + (row.description.as_str()) |
| 148 | + } |
| 149 | + </span> |
| 150 | + </summary> |
| 151 | + <div class="opened"> |
| 152 | + <p class="state"><a class="label-open" href=(row.issues_href.as_str())>(row.open_text.as_str())</a></p> |
| 153 | + if can_triage { |
| 154 | + <div class="acts"> |
| 155 | + reveal(label: g::t(lang, K::Edit), |
| 156 | + <form method="post" action=(row.edit_action.as_str()) class="fields label-edit-form"> |
| 157 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 158 | + <div class="field"> |
| 159 | + <label for=(format!("label-name-{}", row.key.as_str()))>(g::t(lang, K::Name))</label> |
| 160 | + <input id=(format!("label-name-{}", row.key.as_str())) type="text" name="name" value=(row.name.as_str()) autocomplete="off" required=(true)> |
| 161 | + </div> |
| 162 | + <div class="field"> |
| 163 | + <label for=(format!("label-color-{}", row.key.as_str()))>(g::t(lang, K::Color))</label> |
| 164 | + <input id=(format!("label-color-{}", row.key.as_str())) type="color" name="color" value=(row.color.as_str())> |
| 165 | + </div> |
| 166 | + <div class="field"> |
| 167 | + <label for=(format!("label-description-{}", row.key.as_str()))>(g::t(lang, K::Description))</label> |
| 168 | + <input id=(format!("label-description-{}", row.key.as_str())) type="text" name="description" value=(row.description.as_str()) autocomplete="off" maxlength="500"> |
| 169 | + </div> |
| 170 | + <button type="submit">(g::t(lang, K::SaveLabel))</button> |
| 171 | + </form> |
| 172 | + ) |
| 173 | + confirm_act(lang: lang, label: g::t(lang, K::Delete), action: row.delete_action.as_str(), csrf: csrf.as_str(), |
| 174 | + note: Some(crate::pages::passkeys::s(lang, "It is removed from every issue that has it.", "Onu taşıyan her konudan kaldırılır.").to_owned())) |
| 175 | + </div> |
| 159 | 176 | } |
| 160 | | - <a class="label-open" href=(row.issues_href.as_str())>(row.open_text.as_str())</a> |
| 161 | | - </p> |
| 162 | | - </div> |
| 163 | | - if can_triage { |
| 164 | | - <details class="row-action"> |
| 165 | | - <summary>(g::t(lang, K::Edit))</summary> |
| 166 | | - <div class="row-panel"> |
| 167 | | - <form method="post" action=(row.edit_action.as_str()) class="label-edit-form"> |
| 168 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 169 | | - <label> |
| 170 | | - <span>(g::t(lang, K::Name))</span> |
| 171 | | - <input type="text" name="name" value=(row.name.as_str()) autocomplete="off" required=(true)> |
| 172 | | - </label> |
| 173 | | - <label> |
| 174 | | - <span>(g::t(lang, K::Color))</span> |
| 175 | | - <input type="color" name="color" value=(row.color.as_str())> |
| 176 | | - </label> |
| 177 | | - <label> |
| 178 | | - <span>(g::t(lang, K::Description))</span> |
| 179 | | - <input type="text" name="description" value=(row.description.as_str()) autocomplete="off" maxlength="500"> |
| 180 | | - </label> |
| 181 | | - <button type="submit">(g::t(lang, K::SaveLabel))</button> |
| 182 | | - </form> |
| 183 | | - </div> |
| 184 | | - </details> |
| 185 | | - <form method="post" action=(row.delete_action.as_str()) class="row-form"> |
| 186 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 187 | | - <button type="submit" class="danger">(g::t(lang, K::Delete))</button> |
| 188 | | - </form> |
| 189 | | - } |
| 190 | | - </div> |
| 191 | | - } |
| 177 | + </div> |
| 178 | + </details> |
| 179 | + } |
| 180 | + </div> |
| 192 | 181 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 193 | | - </section> |
| 182 | + </div> |
| 194 | 183 | }) |
| 195 | 184 | } |
| 196 | 185 | |
| | @@ -217,6 +206,7 @@ async fn labels_page(cx: &Cx) -> Result<impl View> { |
| 217 | 206 | let open = counts.get(&label.id).copied().unwrap_or(0); |
| 218 | 207 | LabelRow { |
| 219 | 208 | chip_class: format!("label-chip label-{}", label.id), |
| 209 | + key: label.id.clone(), |
| 220 | 210 | issues_href: format!("/{title}/issues?label={}", enc(&label.name)), |
| 221 | 211 | open_text: g::open_label_count(lang, open), |
| 222 | 212 | edit_action: format!("{}/{}", labels_href(&title), label.id), |
| | @@ -78,22 +78,22 @@ async fn login_form( |
| 78 | 78 | passkeys: bool, |
| 79 | 79 | ) -> Result<impl View> { |
| 80 | 80 | Ok(view! { |
| 81 | | - <section class="card narrow"> |
| 81 | + <section> |
| 82 | 82 | <h1>(t(lang, Key::LogIn))</h1> |
| 83 | | - if let Some(message) = error { |
| 84 | | - alert(message: message.as_str()) |
| 85 | | - } |
| 86 | | - <form data-hard="true" method="post" action="/login" class="stack"> |
| 83 | + <form data-hard="true" method="post" action="/login" class="fields"> |
| 84 | + if let Some(message) = error { |
| 85 | + alert(message: message.as_str()) |
| 86 | + } |
| 87 | 87 | <input type="hidden" name="next" value=(next)> |
| 88 | 88 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 89 | | - <label> |
| 90 | | - <span>(t(lang, Key::Username))</span> |
| 91 | | - <input type="text" name="username" value=(username) autocomplete="username webauthn" required=(true)> |
| 92 | | - </label> |
| 93 | | - <label> |
| 94 | | - <span>(t(lang, Key::Password))</span> |
| 95 | | - <input type="password" name="password" autocomplete="current-password" required=(true)> |
| 96 | | - </label> |
| 89 | + <div class="field"> |
| 90 | + <label for="login-username">(t(lang, Key::Username))</label> |
| 91 | + <input id="login-username" type="text" name="username" value=(username) autocomplete="username webauthn" required=(true)> |
| 92 | + </div> |
| 93 | + <div class="field"> |
| 94 | + <label for="login-password">(t(lang, Key::Password))</label> |
| 95 | + <input id="login-password" type="password" name="password" autocomplete="current-password" required=(true)> |
| 96 | + </div> |
| 97 | 97 | <button type="submit" class="primary">(t(lang, Key::LogIn))</button> |
| 98 | 98 | </form> |
| 99 | 99 | if passkeys { |
| | @@ -269,18 +269,18 @@ async fn login_submit(cx: &Cx, Form(form): Form<LoginForm>) -> Result<impl View> |
| 269 | 269 | #[component] |
| 270 | 270 | async fn two_factor_form(lang: Lang, precsrf: &str, error: Option<String>) -> Result<impl View> { |
| 271 | 271 | Ok(view! { |
| 272 | | - <section class="card narrow"> |
| 272 | + <section> |
| 273 | 273 | <h1>(t(lang, Key::TwoFactorCheck))</h1> |
| 274 | | - <p class="muted">(t(lang, Key::TwoFactorCheckSub))</p> |
| 275 | | - if let Some(message) = error { |
| 276 | | - alert(message: message.as_str()) |
| 277 | | - } |
| 278 | | - <form data-hard="true" method="post" action="/login/2fa" class="stack"> |
| 274 | + <p class="hint">(t(lang, Key::TwoFactorCheckSub))</p> |
| 275 | + <form data-hard="true" method="post" action="/login/2fa" class="fields"> |
| 276 | + if let Some(message) = error { |
| 277 | + alert(message: message.as_str()) |
| 278 | + } |
| 279 | 279 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 280 | | - <label> |
| 281 | | - <span>(t(lang, Key::Code))</span> |
| 282 | | - <input type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 283 | | - </label> |
| 280 | + <div class="field"> |
| 281 | + <label for="login-code">(t(lang, Key::Code))</label> |
| 282 | + <input id="login-code" type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 283 | + </div> |
| 284 | 284 | <button type="submit" class="primary">(t(lang, Key::Verify))</button> |
| 285 | 285 | </form> |
| 286 | 286 | </section> |
| | @@ -35,6 +35,7 @@ use crate::pages::pulls_merge::ERR_NOT_OPEN; |
| 35 | 35 | use crate::pages::repo::repo_head; |
| 36 | 36 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 37 | 37 | use crate::state::AppState; |
| 38 | +use crate::views::parts::confirm_act; |
| 38 | 39 | use crate::views::{rel_time, repo_href, shell}; |
| 39 | 40 | |
| 40 | 41 | path_param!(owner); |
| | @@ -359,74 +360,85 @@ async fn queue_body( |
| 359 | 360 | ) -> Result<impl View> { |
| 360 | 361 | let remove_label = g::t(lang, K::RemoveFromQueue); |
| 361 | 362 | let hint = g::t(lang, K::MergeQueueHint); |
| 363 | + let remove_note = crate::pages::passkeys::s( |
| 364 | + lang, |
| 365 | + "The pull request leaves the queue. It can join again later.", |
| 366 | + "Çekme isteği sıradan çıkar. Daha sonra yeniden ekleyebilirsin.", |
| 367 | + ) |
| 368 | + .to_owned(); |
| 362 | 369 | Ok(view! { |
| 363 | 370 | repo_head(head: head) |
| 364 | 371 | if !protected { |
| 365 | | - <section class="card notice" role="status">(g::t(lang, K::QueueNoBranch))</section> |
| 372 | + <p class="state" role="status">(g::t(lang, K::QueueNoBranch))</p> |
| 366 | 373 | } |
| 367 | | - <div class="lang-list fit-pane" data-live=(live.as_str())> |
| 368 | | - <div class="list-bar"> |
| 369 | | - <nav class="issue-tabs" aria-label=(g::t(lang, K::MergeQueueNav))> |
| 370 | | - <a class=(tab_class(!history)) href=(waiting_href.as_str())>(g::t(lang, K::QueueWaiting))</a> |
| 371 | | - <a class=(tab_class(history)) href=(history_href.as_str())>(g::t(lang, K::QueueHistory))</a> |
| 372 | | - </nav> |
| 373 | | - </div> |
| 374 | | - <div class="list-scroll"> |
| 374 | + <div data-live=(live.as_str())> |
| 375 | + <nav class="tabs" aria-label=(g::t(lang, K::MergeQueueNav))> |
| 376 | + <a aria-current=(current_tab(!history)) href=(waiting_href.as_str())>(g::t(lang, K::QueueWaiting))</a> |
| 377 | + <a aria-current=(current_tab(history)) href=(history_href.as_str())>(g::t(lang, K::QueueHistory))</a> |
| 378 | + </nav> |
| 375 | 379 | if empty { |
| 376 | | - <p class="muted">(g::t(lang, K::QueueEmpty))</p> |
| 380 | + <p class="state">(g::t(lang, K::QueueEmpty))</p> |
| 377 | 381 | } else { |
| 378 | | - <div class="table-wrap"> |
| 379 | | - <table class="queue-table"> |
| 380 | | - <thead> |
| 381 | | - <tr> |
| 382 | | - <th>(g::t(lang, K::QueueColPosition))</th> |
| 383 | | - <th>(g::t(lang, K::QueueColPull))</th> |
| 384 | | - <th>(g::t(lang, K::QueueColBranch))</th> |
| 385 | | - <th>(g::t(lang, K::QueueColState))</th> |
| 386 | | - <th>(g::t(lang, K::QueueColBy))</th> |
| 387 | | - <th>(g::t(lang, K::QueueColQueued))</th> |
| 388 | | - <th>(g::t(lang, K::QueueColRun))</th> |
| 389 | | - <th>(g::t(lang, K::QueueColReason))</th> |
| 390 | | - <th></th> |
| 391 | | - </tr> |
| 392 | | - </thead> |
| 393 | | - <tbody> |
| 394 | | - for row in rows.iter() { |
| 395 | | - <tr data-kb-row=""> |
| 396 | | - <td class="mono" data-label=(g::t(lang, K::QueueColPosition))>(row.position.as_str())</td> |
| 397 | | - <td data-label=(g::t(lang, K::QueueColPull))><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></td> |
| 398 | | - <td data-label=(g::t(lang, K::QueueColBranch))><code>(row.branch.as_str())</code></td> |
| 399 | | - <td data-label=(g::t(lang, K::QueueColState))><span class=(row.state_class)>(row.state)</span></td> |
| 400 | | - <td data-label=(g::t(lang, K::QueueColBy))>(row.by.as_str())</td> |
| 401 | | - <td class="muted small" data-label=(g::t(lang, K::QueueColQueued))>rel_time(lang: lang, stamp: row.queued_at.as_str())</td> |
| 402 | | - <td data-label=(g::t(lang, K::QueueColRun))> |
| 382 | + <div> |
| 383 | + for row in rows.iter() { |
| 384 | + if row.remove { |
| 385 | + <details class="row-open"> |
| 386 | + <summary class="line" data-kb-row=""> |
| 387 | + <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> |
| 388 | + <span class="val"> |
| 389 | + if !row.position.is_empty() { |
| 390 | + (g::t(lang, K::QueueColPosition)) " " (row.position.as_str()) " · " |
| 391 | + } |
| 392 | + <span class=(row.state_class)>(row.state)</span> |
| 393 | + " · " <code>(row.branch.as_str())</code> |
| 394 | + " · " (row.by.as_str()) |
| 395 | + " · " rel_time(lang: lang, stamp: row.queued_at.as_str()) |
| 396 | + " · " |
| 403 | 397 | if let Some(href) = row.run_href.as_ref() { |
| 404 | 398 | <a href=(href.as_str())>(row.run_label.as_str())</a> |
| 405 | 399 | } else { |
| 406 | | - <span class="muted">(row.run_label.as_str())</span> |
| 400 | + <span>(row.run_label.as_str())</span> |
| 407 | 401 | } |
| 408 | | - </td> |
| 409 | | - <td class="muted small" data-label=(g::t(lang, K::QueueColReason))>(row.reason.as_str())</td> |
| 410 | | - <td> |
| 411 | | - if row.remove { |
| 412 | | - <form method="post" action=(row.remove_action.as_str()) class="merge-flow"> |
| 413 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 414 | | - <button type="submit">(remove_label)</button> |
| 415 | | - </form> |
| 402 | + if !row.reason.is_empty() { |
| 403 | + " · " (row.reason.as_str()) |
| 416 | 404 | } |
| 417 | | - </td> |
| 418 | | - </tr> |
| 419 | | - } |
| 420 | | - </tbody> |
| 421 | | - </table> |
| 405 | + </span> |
| 406 | + </summary> |
| 407 | + <div class="opened"> |
| 408 | + confirm_act(lang: lang, label: remove_label, action: row.remove_action.as_str(), csrf: csrf.as_str(), note: Some(remove_note.clone())) |
| 409 | + </div> |
| 410 | + </details> |
| 411 | + } else { |
| 412 | + <div class="line" data-kb-row=""> |
| 413 | + <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> |
| 414 | + <span class="val"> |
| 415 | + if !row.position.is_empty() { |
| 416 | + (g::t(lang, K::QueueColPosition)) " " (row.position.as_str()) " · " |
| 417 | + } |
| 418 | + <span class=(row.state_class)>(row.state)</span> |
| 419 | + " · " <code>(row.branch.as_str())</code> |
| 420 | + " · " (row.by.as_str()) |
| 421 | + " · " rel_time(lang: lang, stamp: row.queued_at.as_str()) |
| 422 | + " · " |
| 423 | + if let Some(href) = row.run_href.as_ref() { |
| 424 | + <a href=(href.as_str())>(row.run_label.as_str())</a> |
| 425 | + } else { |
| 426 | + <span>(row.run_label.as_str())</span> |
| 427 | + } |
| 428 | + if !row.reason.is_empty() { |
| 429 | + " · " (row.reason.as_str()) |
| 430 | + } |
| 431 | + </span> |
| 432 | + </div> |
| 433 | + } |
| 434 | + } |
| 422 | 435 | </div> |
| 423 | 436 | } |
| 424 | | - </div> |
| 425 | | - <p class="list-foot muted small">(hint)</p> |
| 437 | + <p class="hint">(hint)</p> |
| 426 | 438 | </div> |
| 427 | 439 | }) |
| 428 | 440 | } |
| 429 | 441 | |
| 430 | | -fn tab_class(on: bool) -> &'static str { |
| 431 | | - if on { "issue-tab on" } else { "issue-tab" } |
| 442 | +fn current_tab(on: bool) -> Option<&'static str> { |
| 443 | + on.then_some("page") |
| 432 | 444 | } |
| | @@ -25,6 +25,7 @@ use crate::pages::repo::repo_head; |
| 25 | 25 | use crate::pages::repo_ctx::load_repo; |
| 26 | 26 | use crate::render::markdown::render_markdown; |
| 27 | 27 | use crate::state::AppState; |
| 28 | +use crate::views::parts::{confirm_act, reveal}; |
| 28 | 29 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 29 | 30 | use crate::views::{enc, shell}; |
| 30 | 31 | |
| | @@ -102,25 +103,21 @@ fn due_on_field(raw: &str) -> Option<&str> { |
| 102 | 103 | async fn state_tabs(lang: Lang, title: String, closed: bool) -> Result<impl View> { |
| 103 | 104 | let open_href = format!("{}?state=open", milestones_href(&title)); |
| 104 | 105 | let closed_href = format!("{}?state=closed", milestones_href(&title)); |
| 105 | | - let open_class = if closed { |
| 106 | | - "subnav-link" |
| 107 | | - } else { |
| 108 | | - "subnav-link current" |
| 109 | | - }; |
| 110 | | - let closed_class = if closed { |
| 111 | | - "subnav-link current" |
| 112 | | - } else { |
| 113 | | - "subnav-link" |
| 114 | | - }; |
| 115 | 106 | Ok(view! { |
| 116 | | - <nav class="subnav" aria-label=(g::t(lang, K::MilestoneState))> |
| 117 | | - <a class=(open_class) href=(open_href.as_str())>(g::t(lang, K::Open))</a> |
| 118 | | - <a class=(closed_class) href=(closed_href.as_str())>(g::t(lang, K::Closed))</a> |
| 107 | + <nav class="sub" aria-label=(g::t(lang, K::MilestoneState))> |
| 108 | + if closed { |
| 109 | + <a href=(open_href.as_str())>(g::t(lang, K::Open))</a> |
| 110 | + <a href=(closed_href.as_str()) aria-current="page">(g::t(lang, K::Closed))</a> |
| 111 | + } else { |
| 112 | + <a href=(open_href.as_str()) aria-current="page">(g::t(lang, K::Open))</a> |
| 113 | + <a href=(closed_href.as_str())>(g::t(lang, K::Closed))</a> |
| 114 | + } |
| 119 | 115 | </nav> |
| 120 | 116 | }) |
| 121 | 117 | } |
| 122 | 118 | |
| 123 | | -/// One row: title, due date, description, progress and the triage controls. |
| 119 | +/// One milestone: its title and counts as the row, and on open its due date, progress, description |
| 120 | +/// and the triage controls. |
| 124 | 121 | #[component] |
| 125 | 122 | async fn milestone_row( |
| 126 | 123 | lang: Lang, |
| | @@ -133,11 +130,13 @@ async fn milestone_row( |
| 133 | 130 | let open_text = g::open_milestone_count(lang, row.open); |
| 134 | 131 | let closed_text = g::closed_milestone_count(lang, row.closed); |
| 135 | 132 | Ok(view! { |
| 136 | | - <div class="row-line" data-kb-row=""> |
| 137 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 21V4"/><path d="M5 4h11l-2 4 2 4H5"/></svg> |
| 138 | | - <div class="row-main"> |
| 139 | | - <strong class="row-name">(row.title.as_str())</strong> |
| 140 | | - <p class="row-status"> |
| 133 | + <details class="row-open" data-kb-row=""> |
| 134 | + <summary class="line"> |
| 135 | + <span class="name">(row.title.as_str())</span> |
| 136 | + <span class="val">(open_text.as_str()) " \u{b7} " (closed_text.as_str())</span> |
| 137 | + </summary> |
| 138 | + <div class="opened"> |
| 139 | + <p class="state"> |
| 141 | 140 | if let Some(due) = row.due.as_deref() { |
| 142 | 141 | (g::due_text(lang, due)) |
| 143 | 142 | if row.overdue { |
| | @@ -146,25 +145,24 @@ async fn milestone_row( |
| 146 | 145 | } else { |
| 147 | 146 | (g::t(lang, K::NoDueDate)) |
| 148 | 147 | } |
| 149 | | - " \u{b7} " |
| 150 | | - <progress value=(row.closed) max=(max)></progress> |
| 151 | | - " " |
| 148 | + </p> |
| 149 | + <progress value=(row.closed) max=(max)></progress> |
| 150 | + <div class="sub"> |
| 152 | 151 | <a href=(row.open_href.as_str())>(open_text.as_str())</a> |
| 153 | | - " \u{b7} " |
| 154 | 152 | <a href=(row.closed_href.as_str())>(closed_text.as_str())</a> |
| 155 | | - </p> |
| 153 | + </div> |
| 156 | 154 | if !row.description_html.is_empty() { |
| 157 | 155 | <div class="markdown-body">(Unescaped::new_unchecked(row.description_html.clone()))</div> |
| 158 | 156 | } |
| 157 | + if can_triage { |
| 158 | + <div class="acts"> |
| 159 | + <a class="act" href=(row.edit_href.as_str())>(g::t(lang, K::Edit))</a> |
| 160 | + confirm_act(lang: lang, label: g::t(lang, K::Delete), action: row.delete_action.as_str(), csrf: csrf.as_str(), |
| 161 | + note: Some(crate::pages::passkeys::s(lang, "Its issues stay open or closed and lose the milestone.", "Konular açık ya da kapalı kalır, yalnızca kilometre taşını kaybeder.").to_owned())) |
| 162 | + </div> |
| 163 | + } |
| 159 | 164 | </div> |
| 160 | | - if can_triage { |
| 161 | | - <a href=(row.edit_href.as_str())>(g::t(lang, K::Edit))</a> |
| 162 | | - <form method="post" action=(row.delete_action.as_str()) class="row-form"> |
| 163 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 164 | | - <button type="submit" class="danger">(g::t(lang, K::Delete))</button> |
| 165 | | - </form> |
| 166 | | - } |
| 167 | | - </div> |
| 165 | + </details> |
| 168 | 166 | }) |
| 169 | 167 | } |
| 170 | 168 | |
| | @@ -267,57 +265,48 @@ async fn milestones_body( |
| 267 | 265 | Ok(view! { |
| 268 | 266 | repo_head(head: header) |
| 269 | 267 | if frame.archived { |
| 270 | | - <section class="card notice" role="status">(g::t(lang, K::MilestonesArchived))</section> |
| 268 | + <p class="state" role="status">(g::t(lang, K::MilestonesArchived))</p> |
| 271 | 269 | } |
| 272 | | - <div class="list-bar"> |
| 273 | | - issue_subnav(lang: lang, title: title.clone(), active: "milestones".to_owned()) |
| 274 | | - state_tabs(lang: lang, title: title.clone(), closed: closed) |
| 275 | | - </div> |
| 276 | | - <section class="card rows-pane lang-list" data-live=(live.as_str()) data-live-now=""> |
| 270 | + issue_subnav(lang: lang, title: title.clone(), active: "milestones".to_owned()) |
| 271 | + state_tabs(lang: lang, title: title.clone(), closed: closed) |
| 272 | + <div class="lang-list" data-live=(live.as_str()) data-live-now=""> |
| 277 | 273 | if can_create { |
| 278 | | - <div class="row-line"> |
| 279 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 280 | | - <div class="row-main"> |
| 281 | | - <h2 class="row-title">(g::t(lang, K::NewMilestone))</h2> |
| 282 | | - if empty { |
| 283 | | - <p class="row-status">(empty_text)</p> |
| 284 | | - } |
| 285 | | - </div> |
| 286 | | - <details class="row-action"> |
| 287 | | - <summary>(g::t(lang, K::CreateMilestone))</summary> |
| 288 | | - <div class="row-panel"> |
| 289 | | - <form method="post" action=(create_action.as_str()) class="stack"> |
| 274 | + <section class="sec"> |
| 275 | + <h2>(g::t(lang, K::NewMilestone))</h2> |
| 276 | + if empty { |
| 277 | + <p class="state">(empty_text)</p> |
| 278 | + } |
| 279 | + <div class="acts"> |
| 280 | + reveal(label: g::t(lang, K::CreateMilestone), id: Some("create-milestone"), open: false, |
| 281 | + <form method="post" action=(create_action.as_str()) class="fields"> |
| 290 | 282 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 291 | | - <label> |
| 292 | | - <span>(g::t(lang, K::Title))</span> |
| 293 | | - <input type="text" name="title" autocomplete="off" required=(true) maxlength="256"> |
| 294 | | - </label> |
| 295 | | - <label> |
| 296 | | - <span>(g::t(lang, K::Description))</span> |
| 297 | | - <textarea name="description" rows="4"></textarea> |
| 298 | | - </label> |
| 299 | | - <label> |
| 300 | | - <span>(g::t(lang, K::DueDate))</span> |
| 301 | | - <input type="date" name="due_on"> |
| 302 | | - </label> |
| 283 | + <div class="field"> |
| 284 | + <label for="milestone-create-title">(g::t(lang, K::Title))</label> |
| 285 | + <input id="milestone-create-title" type="text" name="title" autocomplete="off" required=(true) maxlength="256"> |
| 286 | + </div> |
| 287 | + <div class="field"> |
| 288 | + <label for="milestone-create-description">(g::t(lang, K::Description))</label> |
| 289 | + <textarea id="milestone-create-description" name="description" rows="4"></textarea> |
| 290 | + </div> |
| 291 | + <div class="field"> |
| 292 | + <label for="milestone-create-due">(g::t(lang, K::DueDate))</label> |
| 293 | + <input id="milestone-create-due" type="date" name="due_on"> |
| 294 | + </div> |
| 303 | 295 | <button type="submit" class="primary">(g::t(lang, K::CreateMilestone))</button> |
| 304 | 296 | </form> |
| 305 | | - </div> |
| 306 | | - </details> |
| 307 | | - </div> |
| 308 | | - } else if empty { |
| 309 | | - <div class="row-line"> |
| 310 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 21V4"/><path d="M5 4h11l-2 4 2 4H5"/></svg> |
| 311 | | - <div class="row-main"> |
| 312 | | - <h2 class="row-title">(empty_text)</h2> |
| 297 | + ) |
| 313 | 298 | </div> |
| 314 | | - </div> |
| 315 | | - } |
| 316 | | - for row in rows.into_iter() { |
| 317 | | - milestone_row(lang: lang, row: row, csrf: row_csrf.clone(), can_triage: can_triage) |
| 299 | + </section> |
| 300 | + } else if empty { |
| 301 | + <p class="state">(empty_text)</p> |
| 318 | 302 | } |
| 303 | + <div> |
| 304 | + for row in rows.into_iter() { |
| 305 | + milestone_row(lang: lang, row: row, csrf: row_csrf.clone(), can_triage: can_triage) |
| 306 | + } |
| 307 | + </div> |
| 319 | 308 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 320 | | - </section> |
| 309 | + </div> |
| 321 | 310 | }) |
| 322 | 311 | } |
| 323 | 312 | |
| | @@ -404,33 +393,31 @@ async fn milestone_edit_body( |
| 404 | 393 | Ok(view! { |
| 405 | 394 | repo_head(head: header) |
| 406 | 395 | issue_subnav(lang: lang, title: frame.title.clone(), active: "milestones".to_owned()) |
| 407 | | - <section class="card"> |
| 396 | + <section class="sec"> |
| 408 | 397 | <h2>(g::t(lang, K::EditMilestone))</h2> |
| 409 | | - <p><a href=(back.as_str())>(g::t(lang, K::BackToMilestones))</a></p> |
| 410 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 398 | + <p class="sub"><a href=(back.as_str())>(g::t(lang, K::BackToMilestones))</a></p> |
| 399 | + <form method="post" action=(action.as_str()) class="fields"> |
| 411 | 400 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 412 | | - <label> |
| 413 | | - <span>(g::t(lang, K::Title))</span> |
| 414 | | - <input type="text" name="title" value=(title_value.as_str()) autocomplete="off" required=(true) maxlength="256"> |
| 415 | | - </label> |
| 416 | | - <label> |
| 417 | | - <span>(g::t(lang, K::Description))</span> |
| 418 | | - <textarea name="description" rows="4">(description.as_str())</textarea> |
| 419 | | - </label> |
| 420 | | - <label> |
| 421 | | - <span>(g::t(lang, K::DueDate))</span> |
| 422 | | - <input type="date" name="due_on" value=(due.as_str())> |
| 423 | | - </label> |
| 424 | | - <label> |
| 425 | | - <span>(g::t(lang, K::StateLabel))</span> |
| 426 | | - <select name="state"> |
| 401 | + <div class="field"> |
| 402 | + <label for="milestone-edit-title">(g::t(lang, K::Title))</label> |
| 403 | + <input id="milestone-edit-title" type="text" name="title" value=(title_value.as_str()) autocomplete="off" required=(true) maxlength="256"> |
| 404 | + </div> |
| 405 | + <div class="field"> |
| 406 | + <label for="milestone-edit-description">(g::t(lang, K::Description))</label> |
| 407 | + <textarea id="milestone-edit-description" name="description" rows="4">(description.as_str())</textarea> |
| 408 | + </div> |
| 409 | + <div class="field"> |
| 410 | + <label for="milestone-edit-due">(g::t(lang, K::DueDate))</label> |
| 411 | + <input id="milestone-edit-due" type="date" name="due_on" value=(due.as_str())> |
| 412 | + </div> |
| 413 | + <div class="field"> |
| 414 | + <label for="milestone-edit-state">(g::t(lang, K::StateLabel))</label> |
| 415 | + <select id="milestone-edit-state" name="state"> |
| 427 | 416 | <option value="open" selected=(is_open)>(g::t(lang, K::Open))</option> |
| 428 | 417 | <option value="closed" selected=(!is_open)>(g::t(lang, K::Closed))</option> |
| 429 | 418 | </select> |
| 430 | | - </label> |
| 431 | | - <div> |
| 432 | | - <button type="submit">(g::t(lang, K::SaveMilestone))</button> |
| 433 | 419 | </div> |
| 420 | + <button type="submit" class="primary">(g::t(lang, K::SaveMilestone))</button> |
| 434 | 421 | </form> |
| 435 | 422 | </section> |
| 436 | 423 | }) |
| | @@ -22,7 +22,7 @@ use crate::live::{Topic, stream_wakes}; |
| 22 | 22 | use crate::pages::ci_runs::run_href; |
| 23 | 23 | use crate::state::AppState; |
| 24 | 24 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 25 | | -use crate::views::{empty_state, rel_time, repo_href, shell}; |
| 25 | +use crate::views::{rel_time, repo_href, shell}; |
| 26 | 26 | |
| 27 | 27 | /// Most rows one section lists on the overview. |
| 28 | 28 | const SECTION_ROWS: usize = 8; |
| | @@ -358,22 +358,24 @@ pub(crate) async fn need_section(lang: Lang, section: NeedSection) -> Result<imp |
| 358 | 358 | }, |
| 359 | 359 | } = section; |
| 360 | 360 | Ok(view! { |
| 361 | | - <section class="card needs-section"> |
| 362 | | - <h2 class="needs-head">(heading)</h2> |
| 363 | | - <ul class="notif-list"> |
| 361 | + <section class="sec"> |
| 362 | + <h2>(heading)</h2> |
| 363 | + <div class="plain-rows"> |
| 364 | 364 | for row in rows.iter() { |
| 365 | | - <li class="notif-row"> |
| 365 | + <a class="line" href=(row.href.as_str()) data-kb-row=""> |
| 366 | + <span class="name">(row.title.as_str())</span> |
| 366 | 367 | if let Some(badge) = row.badge { |
| 367 | 368 | <span class="badge">(badge)</span> |
| 368 | 369 | } |
| 369 | | - <a class="notif-title" href=(row.href.as_str())>(row.title.as_str())</a> |
| 370 | | - <span class="muted small">(row.detail.as_str())</span> |
| 371 | | - <span class="muted small">rel_time(lang: lang, stamp: row.stamp.as_str())</span> |
| 372 | | - </li> |
| 370 | + <span class="val">(row.detail.as_str())</span> |
| 371 | + <span class="val">rel_time(lang: lang, stamp: row.stamp.as_str())</span> |
| 372 | + </a> |
| 373 | 373 | } |
| 374 | | - </ul> |
| 374 | + </div> |
| 375 | 375 | if let Some((href, text)) = more { |
| 376 | | - <a class="needs-more small" href=(href)>(text)</a> |
| 376 | + <div class="acts"> |
| 377 | + <a class="act" href=(href)>(text)</a> |
| 378 | + </div> |
| 377 | 379 | } |
| 378 | 380 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 379 | 381 | </section> |
| | @@ -411,24 +413,26 @@ async fn needs_you(cx: &Cx) -> Result<impl View> { |
| 411 | 413 | let heading = ni::t(lang, K::NeedsYou); |
| 412 | 414 | Ok(view! { |
| 413 | 415 | shell(title: heading, viewer: Some(&viewer), |
| 414 | | - <section class="page-head" data-live=(live.as_str())> |
| 415 | | - <h1>(heading)</h1> |
| 416 | + <section data-live=(live.as_str())> |
| 417 | + <h1 class="sr-only">(heading)</h1> |
| 416 | 418 | if let Some(back) = back { |
| 417 | | - <a class="needs-back small" href="/needs-you">(back)</a> |
| 419 | + <div class="acts"> |
| 420 | + <a class="act" href="/needs-you">(back)</a> |
| 421 | + </div> |
| 418 | 422 | } |
| 419 | 423 | </section> |
| 420 | 424 | if empty { |
| 421 | | - empty_state(title: ni::t(lang, K::AllClear)) |
| 425 | + <p class="state">(ni::t(lang, K::AllClear))</p> |
| 422 | 426 | } |
| 423 | 427 | if grid { |
| 424 | | - <div class="needs-grid"> |
| 428 | + <div class="needs-page"> |
| 425 | 429 | for section in sections.into_iter() { |
| 426 | 430 | need_section(lang: lang, section: section) |
| 427 | 431 | } |
| 428 | 432 | </div> |
| 429 | 433 | } |
| 430 | 434 | if let Some(section) = full { |
| 431 | | - <div class="needs-full"> |
| 435 | + <div class="needs-page"> |
| 432 | 436 | need_section(lang: lang, section: section) |
| 433 | 437 | </div> |
| 434 | 438 | } |
| | @@ -18,12 +18,12 @@ use topcoat::view::{View, component, view}; |
| 18 | 18 | |
| 19 | 19 | use crate::audit::{self, Actor, Target}; |
| 20 | 20 | use crate::auth::{require_csrf, require_user}; |
| 21 | | -use crate::i18n::community::{self as community, K as CommunityK}; |
| 22 | 21 | use crate::i18n::misc::{self as g, K}; |
| 23 | 22 | use crate::i18n::{self, Key, Lang}; |
| 24 | 23 | use crate::pages::org_ctx::may_create_repo_in; |
| 25 | 24 | use crate::pages::repo_mirrors::{Checked, check_form_in, redacted_url}; |
| 26 | 25 | use crate::state::AppState; |
| 26 | +use crate::views::parts::reveal; |
| 27 | 27 | use crate::views::{alert, csrf_field, shell, user_facing_message}; |
| 28 | 28 | |
| 29 | 29 | const MAX_DESCRIPTION_CHARS: usize = 350; |
| | @@ -234,108 +234,73 @@ async fn new_repo_form( |
| 234 | 234 | let draft_mirror_username = draft.mirror_username; |
| 235 | 235 | let draft_mirror_interval = draft.mirror_interval; |
| 236 | 236 | Ok(view! { |
| 237 | | - if let Some(message) = error { |
| 238 | | - alert(message: message.as_str()) |
| 239 | | - } |
| 240 | | - <form method="post" action="/new" class="newrepo-form"> |
| 237 | + <h1 class="sr-only">(i18n::t(lang, Key::NewRepository))</h1> |
| 238 | + crate::pages::import::newrepo_tabs(lang: lang, active: "create") |
| 239 | + <form method="post" action="/new" class="fields"> |
| 240 | + if let Some(message) = error { |
| 241 | + alert(message: message.as_str()) |
| 242 | + } |
| 241 | 243 | csrf_field(token: csrf) |
| 242 | | - <header class="newrepo-head page-head"> |
| 243 | | - <h1>(i18n::t(lang, Key::NewRepository))</h1> |
| 244 | | - crate::pages::import::newrepo_tabs(lang: lang, active: "create") |
| 245 | | - <div class="newrepo-head-actions"> |
| 246 | | - <fieldset class="newrepo-visibility"> |
| 247 | | - <legend class="sr-only">(g::t(lang, K::VisibilityLegend))</legend> |
| 248 | | - <div class="segmented snippet-segmented"> |
| 249 | | - <label class="segment" title=(g::t(lang, K::PrivateHelp))> |
| 250 | | - <input type="radio" name="visibility" value="private" checked=(private)> |
| 251 | | - <svg viewBox="0 0 24 24" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg> |
| 252 | | - <span>(community::t(lang, CommunityK::VisibilityPrivate))</span> |
| 253 | | - </label> |
| 254 | | - <label class="segment" title=(g::t(lang, K::PublicHelp))> |
| 255 | | - <input type="radio" name="visibility" value="public" checked=(!private)> |
| 256 | | - <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"/></svg> |
| 257 | | - <span>(community::t(lang, CommunityK::VisibilityPublic))</span> |
| 258 | | - </label> |
| 259 | | - </div> |
| 260 | | - </fieldset> |
| 261 | | - <button type="submit" class="primary">(g::t(lang, K::CreateRepository))</button> |
| 262 | | - </div> |
| 263 | | - </header> |
| 264 | | - <div class="newrepo-card"> |
| 265 | | - <div class="newrepo-row newrepo-slug"> |
| 266 | | - <label class="newrepo-owner"> |
| 267 | | - <span>(g::t(lang, K::NewOwner))</span> |
| 268 | | - <select name="owner"> |
| 269 | | - for name in owners.iter() { |
| 270 | | - <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> |
| 271 | | - } |
| 272 | | - </select> |
| 273 | | - </label> |
| 274 | | - <span class="newrepo-slash" aria-hidden="true">("/")</span> |
| 275 | | - <label class="newrepo-name"> |
| 276 | | - <span>(g::t(lang, K::RepoName))</span> |
| 277 | | - <input type="text" name="name" value=(draft.name) required=(true) maxlength="64" autocomplete="off" class="newrepo-mono"> |
| 278 | | - </label> |
| 244 | + <div class="field"> |
| 245 | + <label for="new-owner">(g::t(lang, K::NewOwner))</label> |
| 246 | + <select id="new-owner" name="owner"> |
| 247 | + for name in owners.iter() { |
| 248 | + <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> |
| 249 | + } |
| 250 | + </select> |
| 251 | + </div> |
| 252 | + <div class="field"> |
| 253 | + <label for="new-name">(g::t(lang, K::RepoName))</label> |
| 254 | + <input id="new-name" type="text" name="name" value=(draft.name) required=(true) maxlength="64" autocomplete="off" spellcheck="false"> |
| 255 | + </div> |
| 256 | + <div class="field"> |
| 257 | + <label for="new-description">(g::t(lang, K::DescriptionOptional))</label> |
| 258 | + <textarea id="new-description" name="description" rows="3" maxlength="350">(draft.description)</textarea> |
| 259 | + </div> |
| 260 | + <div class="field"> |
| 261 | + <label for="new-branch">(g::t(lang, K::DefaultBranch))</label> |
| 262 | + <input id="new-branch" type="text" name="default_branch" value=(branch) maxlength="255" autocomplete="off" spellcheck="false"> |
| 263 | + </div> |
| 264 | + <label class="switch"> |
| 265 | + <input type="checkbox" name="default_labels" value="on" checked=(default_labels)> |
| 266 | + <span>(g::t(lang, K::AddDefaultLabels))</span> |
| 267 | + </label> |
| 268 | + crate::pages::import::visibility_pick(lang: lang, private: private) |
| 269 | + <label class="switch"> |
| 270 | + <input type="checkbox" name="add_readme" value="on" checked=(add_readme)> |
| 271 | + <span>(g::t(lang, K::ReadmeLabel))</span> |
| 272 | + </label> |
| 273 | + <p class="hint">(g::t(lang, K::ReadmeHelp))</p> |
| 274 | + <div class="field"> |
| 275 | + <label for="new-license">(g::t(lang, K::LicenseLabel))</label> |
| 276 | + <select id="new-license" name="license"> |
| 277 | + <option value="" selected=(draft_license.is_empty())>(g::t(lang, K::LicenseNone))</option> |
| 278 | + for (id, label, _) in LICENSES.iter() { |
| 279 | + <option value=(*id) selected=(*id == draft_license.as_str())>(*label)</option> |
| 280 | + } |
| 281 | + </select> |
| 282 | + <p class="hint">(g::t(lang, K::LicenseHelp))</p> |
| 283 | + </div> |
| 284 | + reveal(label: g::t(lang, K::MirrorLegend), id: Some("new-mirror"), open: mirror_open, |
| 285 | + <p class="hint">(g::t(lang, K::MirrorIntro))</p> |
| 286 | + <div class="field"> |
| 287 | + <label for="new-mirror-url">(g::t(lang, K::SourceUrl))</label> |
| 288 | + <input id="new-mirror-url" type="url" name="mirror_url" value=(draft_mirror_url.as_str()) autocomplete="off" spellcheck="false" maxlength="2048"> |
| 279 | 289 | </div> |
| 280 | | - <label> |
| 281 | | - <span>(g::t(lang, K::DescriptionOptional))</span> |
| 282 | | - <textarea name="description" rows="3" maxlength="350">(draft.description)</textarea> |
| 283 | | - </label> |
| 284 | | - <div class="newrepo-row newrepo-options"> |
| 285 | | - <label class="newrepo-branch"> |
| 286 | | - <span>(g::t(lang, K::DefaultBranch))</span> |
| 287 | | - <input type="text" name="default_branch" value=(branch) maxlength="255" autocomplete="off" class="newrepo-mono"> |
| 288 | | - </label> |
| 289 | | - <label class="inline newrepo-labels"> |
| 290 | | - <input type="checkbox" name="default_labels" value="on" checked=(default_labels)> |
| 291 | | - <span>(g::t(lang, K::AddDefaultLabels))</span> |
| 292 | | - </label> |
| 290 | + <div class="field"> |
| 291 | + <label for="new-mirror-username">(g::t(lang, K::UsernameOptional))</label> |
| 292 | + <input id="new-mirror-username" type="text" name="mirror_username" value=(draft_mirror_username.as_str()) autocomplete="off" maxlength="255"> |
| 293 | 293 | </div> |
| 294 | | - <div class="newrepo-files"> |
| 295 | | - <label class="inline newrepo-readme"> |
| 296 | | - <input type="checkbox" name="add_readme" value="on" checked=(add_readme)> |
| 297 | | - <span>(g::t(lang, K::ReadmeLabel))</span> |
| 298 | | - </label> |
| 299 | | - <p class="muted small">(g::t(lang, K::ReadmeHelp))</p> |
| 300 | | - <label class="newrepo-license"> |
| 301 | | - <span>(g::t(lang, K::LicenseLabel))</span> |
| 302 | | - <select name="license"> |
| 303 | | - <option value="" selected=(draft_license.is_empty())>(g::t(lang, K::LicenseNone))</option> |
| 304 | | - for (id, label, _) in LICENSES.iter() { |
| 305 | | - <option value=(*id) selected=(*id == draft_license.as_str())>(*label)</option> |
| 306 | | - } |
| 307 | | - </select> |
| 308 | | - </label> |
| 309 | | - <p class="muted small">(g::t(lang, K::LicenseHelp))</p> |
| 294 | + <div class="field"> |
| 295 | + <label for="new-mirror-secret">(g::t(lang, K::PasswordOrToken))</label> |
| 296 | + <input id="new-mirror-secret" type="password" name="mirror_secret" autocomplete="new-password" maxlength="1024"> |
| 310 | 297 | </div> |
| 311 | | - </div> |
| 312 | | - <details class="newrepo-mirror" open=(mirror_open)> |
| 313 | | - <summary> |
| 314 | | - <span>(g::t(lang, K::MirrorLegend))</span> |
| 315 | | - <svg viewBox="0 0 24 24" aria-hidden="true" class="newrepo-chev"><path d="M6 9l6 6 6-6"/></svg> |
| 316 | | - </summary> |
| 317 | | - <div class="newrepo-mirror-body"> |
| 318 | | - <p class="muted small">(g::t(lang, K::MirrorIntro))</p> |
| 319 | | - <label> |
| 320 | | - <span>(g::t(lang, K::SourceUrl))</span> |
| 321 | | - <input type="url" name="mirror_url" value=(draft_mirror_url.as_str()) autocomplete="off" spellcheck="false" maxlength="2048"> |
| 322 | | - </label> |
| 323 | | - <div class="newrepo-row"> |
| 324 | | - <label class="newrepo-half"> |
| 325 | | - <span>(g::t(lang, K::UsernameOptional))</span> |
| 326 | | - <input type="text" name="mirror_username" value=(draft_mirror_username.as_str()) autocomplete="off" maxlength="255"> |
| 327 | | - </label> |
| 328 | | - <label class="newrepo-half"> |
| 329 | | - <span>(g::t(lang, K::PasswordOrToken))</span> |
| 330 | | - <input type="password" name="mirror_secret" autocomplete="new-password" maxlength="1024"> |
| 331 | | - </label> |
| 332 | | - </div> |
| 333 | | - <label class="newrepo-interval"> |
| 334 | | - <span>(g::t(lang, K::SyncInterval))</span> |
| 335 | | - <input type="number" name="mirror_interval" value=(draft_mirror_interval.as_str()) min="0" max="525600" step="1"> |
| 336 | | - </label> |
| 298 | + <div class="field"> |
| 299 | + <label for="new-mirror-interval">(g::t(lang, K::SyncInterval))</label> |
| 300 | + <input id="new-mirror-interval" type="number" name="mirror_interval" value=(draft_mirror_interval.as_str()) min="0" max="525600" step="1"> |
| 337 | 301 | </div> |
| 338 | | - </details> |
| 302 | + ) |
| 303 | + <button type="submit" class="primary">(g::t(lang, K::CreateRepository))</button> |
| 339 | 304 | </form> |
| 340 | 305 | }) |
| 341 | 306 | } |
| | @@ -49,8 +49,10 @@ async fn not_found_body(lang: Lang) -> Result<impl View> { |
| 49 | 49 | <section class="not-found"> |
| 50 | 50 | <p class="not-found-code">"404"</p> |
| 51 | 51 | <h1>(title)</h1> |
| 52 | | - <p class="muted">(hint)</p> |
| 53 | | - <a class="button primary" href="/">(back)</a> |
| 52 | + <p class="state">(hint)</p> |
| 53 | + <div class="acts"> |
| 54 | + <a class="act" href="/">(back)</a> |
| 55 | + </div> |
| 54 | 56 | </section> |
| 55 | 57 | }) |
| 56 | 58 | } |
| | @@ -35,13 +35,10 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 35 | 35 | use crate::pages::repo_transfer::transfer_list_for; |
| 36 | 36 | use crate::pages::star::return_path; |
| 37 | 37 | use crate::state::AppState; |
| 38 | | -use crate::views::{ |
| 39 | | - csrf_field, display_name, empty_state, iso_time, now_unix, relative_time, repo_href, shell, |
| 40 | | -}; |
| 38 | +use crate::views::parts::post_act; |
| 39 | +use crate::views::{csrf_field, display_name, iso_time, now_unix, relative_time, repo_href, shell}; |
| 41 | 40 | |
| 42 | | -/// Rows per inbox page: a group head and its rows, with the older link, fit the window's height |
| 43 | | -/// (about 44px a row and 62px a group head at 1440×900). The list scrolls inside its pane when a page |
| 44 | | -/// of many small groups is taller still. |
| 41 | +/// Rows per inbox page. Older rows come behind the older link, so one page stays short. |
| 45 | 42 | const PAGE_SIZE: u32 = 8; |
| 46 | 43 | |
| 47 | 44 | path_param!(owner); |
| | @@ -1120,65 +1117,62 @@ async fn inbox_list( |
| 1120 | 1117 | } else { |
| 1121 | 1118 | g::t(lang, K::NoUnreadNotifications) |
| 1122 | 1119 | }; |
| 1123 | | - let unread_class = if all { "" } else { "active" }; |
| 1124 | | - let all_class = if all { "active" } else { "" }; |
| 1120 | + let unread_current = if all { None } else { Some("page") }; |
| 1121 | + let all_current = if all { Some("page") } else { None }; |
| 1125 | 1122 | let unread_text = format!("{} ({unread_count})", g::t(lang, K::Unread)); |
| 1126 | 1123 | Ok(view! { |
| 1127 | | - <section class="page-head" data-live=(live.as_str())> |
| 1128 | | - <h1>(i18n::t(lang, Key::Notifications))</h1> |
| 1129 | | - if !empty { |
| 1130 | | - <form method="post" action="/notifications/mark_all_read" class="notif-inline-form"> |
| 1131 | | - csrf_field(token: csrf.as_str()) |
| 1132 | | - <button type="submit" class="button">(g::t(lang, K::MarkAllAsRead))</button> |
| 1133 | | - </form> |
| 1134 | | - } |
| 1135 | | - </section> |
| 1136 | | - transfer_list_for(lang: lang, transfers: transfers, csrf: csrf.clone()) |
| 1137 | | - // The filter tabs, the groups and the older link share one pane that fits the window, so the |
| 1138 | | - // page itself does not scroll; the older link ends the pane. |
| 1139 | | - <div class="notif-pane fit-pane list-pane"> |
| 1140 | | - <nav class="notif-tabs" aria-label=(g::t(lang, K::NotificationFilter))> |
| 1141 | | - <a href="/notifications" class=(unread_class)>(unread_text.as_str())</a> |
| 1142 | | - <a href="/notifications?all=1" class=(all_class)>(g::t(lang, K::AllTab))</a> |
| 1124 | + <div data-live=(live.as_str())> |
| 1125 | + <h1 class="sr-only">(i18n::t(lang, Key::Notifications))</h1> |
| 1126 | + <nav class="tabs" aria-label=(g::t(lang, K::NotificationFilter))> |
| 1127 | + <a href="/notifications" aria-current=(unread_current)>(unread_text.as_str())</a> |
| 1128 | + <a href="/notifications?all=1" aria-current=(all_current)>(g::t(lang, K::AllTab))</a> |
| 1143 | 1129 | <a href="/review-requests">(crate::i18n::authoring::t(lang, crate::i18n::authoring::K::ReviewRequestsTab))</a> |
| 1144 | 1130 | </nav> |
| 1131 | + if !empty { |
| 1132 | + <div class="acts"> |
| 1133 | + post_act(label: g::t(lang, K::MarkAllAsRead), action: "/notifications/mark_all_read", csrf: csrf.as_str()) |
| 1134 | + </div> |
| 1135 | + } |
| 1136 | + transfer_list_for(lang: lang, transfers: transfers, csrf: csrf.clone()) |
| 1145 | 1137 | if empty { |
| 1146 | | - empty_state(title: empty_text, |
| 1138 | + <section class="sec"> |
| 1139 | + <p class="state">(empty_text)</p> |
| 1147 | 1140 | if !all { |
| 1148 | | - <a class="button" href="/notifications?all=1">(g::t(lang, K::ViewAllNotifications))</a> |
| 1149 | | - }) |
| 1141 | + <div class="acts"> |
| 1142 | + <a class="act" href="/notifications?all=1">(g::t(lang, K::ViewAllNotifications))</a> |
| 1143 | + </div> |
| 1144 | + } |
| 1145 | + </section> |
| 1150 | 1146 | } |
| 1151 | 1147 | for group in groups.into_iter() { |
| 1152 | | - <section class="card notif-group"> |
| 1153 | | - <header class="notif-group-head"> |
| 1154 | | - <a class="notif-repo" href=(group.href.as_str())>(group.heading.as_str())</a> |
| 1155 | | - <form method="post" action=(group.mark_action.as_str()) class="notif-inline-form"> |
| 1156 | | - csrf_field(token: csrf.as_str()) |
| 1157 | | - <button type="submit" class="link-button">(g::t(lang, K::MarkAllRead))</button> |
| 1158 | | - </form> |
| 1159 | | - </header> |
| 1160 | | - <ul class="notif-list"> |
| 1148 | + <section class="sec"> |
| 1149 | + <h2><a href=(group.href.as_str())>(group.heading.as_str())</a></h2> |
| 1150 | + <div class="acts"> |
| 1151 | + post_act(label: g::t(lang, K::MarkAllRead), action: group.mark_action.as_str(), csrf: csrf.as_str()) |
| 1152 | + </div> |
| 1153 | + <div class="notif-rows"> |
| 1161 | 1154 | for row in group.rows.into_iter() { |
| 1162 | | - <li class=(row.item_class) data-kb-row=""> |
| 1163 | | - <span class=(row.icon_class) aria-hidden="true"></span> |
| 1164 | | - <span class="notif-sr">(row.kind_label)</span> |
| 1165 | | - <a class="notif-title" href=(row.open_href.as_str())>(row.title_line.as_str())</a> |
| 1166 | | - <span class="badge">(row.reason)</span> |
| 1167 | | - <span class="muted small">(row.activity.as_str())</span> |
| 1168 | | - <time class="muted small" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 1155 | + <div class=(row.item_class) data-kb-row=""> |
| 1156 | + <a class="line" href=(row.open_href.as_str())> |
| 1157 | + <span class=(row.icon_class) aria-hidden="true"></span> |
| 1158 | + <span class="notif-sr">(row.kind_label)</span> |
| 1159 | + <span class="name">(row.title_line.as_str())</span> |
| 1160 | + <span class="val">(row.reason) " · " (row.activity.as_str()) " · " <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time></span> |
| 1161 | + </a> |
| 1169 | 1162 | if row.unread { |
| 1170 | | - <form method="post" action=(row.read_action.as_str()) class="notif-inline-form"> |
| 1171 | | - csrf_field(token: csrf.as_str()) |
| 1172 | | - <button type="submit" class="link-button">(g::t(lang, K::MarkRead))</button> |
| 1173 | | - </form> |
| 1163 | + <div class="acts"> |
| 1164 | + post_act(label: g::t(lang, K::MarkRead), action: row.read_action.as_str(), csrf: csrf.as_str()) |
| 1165 | + </div> |
| 1174 | 1166 | } |
| 1175 | | - </li> |
| 1167 | + </div> |
| 1176 | 1168 | } |
| 1177 | | - </ul> |
| 1169 | + </div> |
| 1178 | 1170 | </section> |
| 1179 | 1171 | } |
| 1180 | 1172 | if let Some(href) = more { |
| 1181 | | - <p class="notif-more"><a class="button" href=(href.as_str())>(g::t(lang, K::Older))</a></p> |
| 1173 | + <div class="acts"> |
| 1174 | + <a class="act" href=(href.as_str())>(g::t(lang, K::Older))</a> |
| 1175 | + </div> |
| 1182 | 1176 | } |
| 1183 | 1177 | </div> |
| 1184 | 1178 | }) |
| | @@ -1200,13 +1194,12 @@ pub(crate) async fn notify_box( |
| 1200 | 1194 | (g::t(lang, K::Subscribe), "subscribe") |
| 1201 | 1195 | }; |
| 1202 | 1196 | Ok(view! { |
| 1203 | | - <section class="card notif-box"> |
| 1197 | + <section class="sec"> |
| 1204 | 1198 | <h2>(i18n::t(lang, Key::Notifications))</h2> |
| 1205 | | - <p class="muted small">(reason.as_str())</p> |
| 1206 | | - <form method="post" action=(action.as_str()) class="notif-inline-form"> |
| 1207 | | - csrf_field(token: csrf.as_str()) |
| 1208 | | - <button type="submit" name="action" value=(value_text)>(label)</button> |
| 1209 | | - </form> |
| 1199 | + <p class="state">(reason.as_str())</p> |
| 1200 | + <div class="acts"> |
| 1201 | + post_act(label: label, action: action.as_str(), csrf: csrf.as_str(), fields: vec![("action".to_owned(), value_text.to_owned())]) |
| 1202 | + </div> |
| 1210 | 1203 | </section> |
| 1211 | 1204 | }) |
| 1212 | 1205 | } |
| | @@ -18,9 +18,8 @@ use crate::auth::{check_csrf, require_user}; |
| 18 | 18 | use crate::i18n::Lang; |
| 19 | 19 | use crate::i18n::orgs::{self as g, K}; |
| 20 | 20 | use crate::pages::packages; |
| 21 | | -use crate::pages::profile::profile_tabs; |
| 22 | 21 | use crate::state::AppState; |
| 23 | | -use crate::views::profile_items; |
| 22 | +use crate::views::{alert, profile_items}; |
| 24 | 23 | |
| 25 | 24 | /// The query key that carries a notice on an org page. Its value is one of the fixed words in |
| 26 | 25 | /// `NOTICES`, never user text. The notice lives in the URL, not in a cookie: a live refresh of the |
| | @@ -185,19 +184,14 @@ pub fn take_notice(cx: &Cx, lang: Lang) -> Option<(&'static str, bool)> { |
| 185 | 184 | .map(|(_, key, is_error)| (g::t(lang, *key), *is_error)) |
| 186 | 185 | } |
| 187 | 186 | |
| 188 | | -/// The org's name and description. The members, teams and settings links live in the shell |
| 189 | | -/// sidebar (see `views::section_for`). |
| 187 | +/// The org's name for screen readers (the path bar shows it), and its description as one hint line. |
| 190 | 188 | #[component] |
| 191 | 189 | pub async fn org_head(name: String, description: String) -> Result<impl View> { |
| 192 | 190 | Ok(view! { |
| 193 | | - <section class="page-head org-head"> |
| 194 | | - <div class="org-head-text"> |
| 195 | | - <h1>(name.as_str())</h1> |
| 196 | | - if !description.is_empty() { |
| 197 | | - <p class="muted">(description.as_str())</p> |
| 198 | | - } |
| 199 | | - </div> |
| 200 | | - </section> |
| 191 | + <h1 class="sr-only">(name.as_str())</h1> |
| 192 | + if !description.is_empty() { |
| 193 | + <p class="hint">(description.as_str())</p> |
| 194 | + } |
| 201 | 195 | }) |
| 202 | 196 | } |
| 203 | 197 | |
| | @@ -214,35 +208,67 @@ pub async fn org_tab_counts(state: &AppState, org: &User, viewer: &User) -> Resu |
| 214 | 208 | Ok((repos, packages)) |
| 215 | 209 | } |
| 216 | 210 | |
| 217 | | -/// The profile tab bar on an organization's member pages (members, teams). Only members reach |
| 218 | | -/// them, so the Members and Teams tabs are always listed, and `current` marks the page's own. |
| 211 | +/// The org's tab bar, in the shared tab look. Only members reach the member pages, so Members and |
| 212 | +/// Teams are always listed; an owner also gets Settings. `current` marks the page's own tab. |
| 219 | 213 | #[component] |
| 220 | 214 | pub async fn org_tabs( |
| 221 | 215 | lang: Lang, |
| 222 | 216 | name: String, |
| 223 | 217 | current: String, |
| 218 | + owner: bool, |
| 224 | 219 | repo_count: u64, |
| 225 | 220 | package_count: usize, |
| 226 | 221 | ) -> Result<impl View> { |
| 227 | | - let items = profile_items(lang, &name, true, false, true); |
| 228 | | - let counts = vec![ |
| 229 | | - ("repositories", repo_count.to_string()), |
| 230 | | - ("packages", package_count.to_string()), |
| 231 | | - ]; |
| 222 | + let mut tabs: Vec<(String, String, bool, String, bool)> = |
| 223 | + profile_items(lang, &name, true, false, true) |
| 224 | + .into_iter() |
| 225 | + .map(|item| { |
| 226 | + let count = match item.key { |
| 227 | + "repositories" => Some(repo_count.to_string()), |
| 228 | + "packages" => Some(package_count.to_string()), |
| 229 | + _ => None, |
| 230 | + }; |
| 231 | + ( |
| 232 | + item.href, |
| 233 | + item.label.to_owned(), |
| 234 | + item.key == current, |
| 235 | + count.clone().unwrap_or_default(), |
| 236 | + count.is_some(), |
| 237 | + ) |
| 238 | + }) |
| 239 | + .collect(); |
| 240 | + if owner { |
| 241 | + tabs.push(( |
| 242 | + format!("/org/{name}/settings"), |
| 243 | + g::t(lang, K::Settings).to_owned(), |
| 244 | + current == "settings", |
| 245 | + String::new(), |
| 246 | + false, |
| 247 | + )); |
| 248 | + } |
| 232 | 249 | Ok(view! { |
| 233 | | - profile_tabs(username: name, items: items, current: current, counts: counts) |
| 250 | + <nav class="tabs" aria-label=(name.as_str())> |
| 251 | + for (href, label, on, count, has_count) in tabs.into_iter() { |
| 252 | + <a href=(href.as_str()) aria-current=(on.then_some("page"))> |
| 253 | + (label.as_str()) |
| 254 | + if has_count { |
| 255 | + " " <span class="tab-count">(count.as_str())</span> |
| 256 | + } |
| 257 | + </a> |
| 258 | + } |
| 259 | + </nav> |
| 234 | 260 | }) |
| 235 | 261 | } |
| 236 | 262 | |
| 237 | | -/// The notice banner: an error alert, or a status line. |
| 263 | +/// The notice after a write: an error alert, or a status line. |
| 238 | 264 | #[component] |
| 239 | 265 | pub async fn org_notice(notice: Option<(&'static str, bool)>) -> Result<impl View> { |
| 240 | 266 | Ok(view! { |
| 241 | 267 | if let Some((text, is_error)) = notice { |
| 242 | 268 | if is_error { |
| 243 | | - <section class="card error" role="alert">(text)</section> |
| 269 | + alert(message: text) |
| 244 | 270 | } else { |
| 245 | | - <section class="card notice" role="status">(text)</section> |
| 271 | + <p class="state" role="status">(text)</p> |
| 246 | 272 | } |
| 247 | 273 | } |
| 248 | 274 | }) |
| | @@ -24,6 +24,7 @@ use crate::pages::org_ctx::{ |
| 24 | 24 | }; |
| 25 | 25 | use crate::pages::passkeys; |
| 26 | 26 | use crate::state::AppState; |
| 27 | +use crate::views::parts::{confirm_act, reveal}; |
| 27 | 28 | use crate::views::{avatar_url, display_name, shell}; |
| 28 | 29 | |
| 29 | 30 | path_param!(org); |
| | @@ -87,80 +88,78 @@ async fn members_body( |
| 87 | 88 | let add_action = format!("{base}/members/add"); |
| 88 | 89 | Ok(view! { |
| 89 | 90 | <div data-live=(live.as_str())> |
| 90 | | - org_head(name: name.clone(), description: description) |
| 91 | | - org_tabs(lang: lang, name: name, current: "members".to_owned(), repo_count: repo_count, package_count: package_count) |
| 91 | + org_tabs(lang: lang, name: name.clone(), current: "members".to_owned(), owner: owner, repo_count: repo_count, package_count: package_count) |
| 92 | + org_head(name: name, description: description) |
| 92 | 93 | org_notice(notice: notice) |
| 93 | | - <section class="card rows-pane"> |
| 94 | + <section class="sec"> |
| 95 | + <h2>(g::t(lang, K::Members))</h2> |
| 94 | 96 | if owner { |
| 95 | | - <div class="row-line"> |
| 96 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 97 | | - <div class="row-main"> |
| 98 | | - <h2 class="row-title">(g::t(lang, K::AddMember))</h2> |
| 99 | | - <p class="row-status">(g::t(lang, K::OwnersHelp))</p> |
| 100 | | - </div> |
| 101 | | - <details class="row-action"> |
| 102 | | - <summary>(g::t(lang, K::AddMemberButton))</summary> |
| 103 | | - <div class="row-panel"> |
| 104 | | - <form method="post" action=(add_action.as_str()) class="stack"> |
| 105 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 106 | | - <label> |
| 107 | | - <span>(g::t(lang, K::Username))</span> |
| 108 | | - <input type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 109 | | - </label> |
| 110 | | - <label> |
| 111 | | - <span>(g::t(lang, K::Role))</span> |
| 112 | | - <select name="role"> |
| 113 | | - <option value="member" selected=(true)>(g::t(lang, K::RoleMember))</option> |
| 114 | | - <option value="owner">(g::t(lang, K::RoleOwner))</option> |
| 115 | | - </select> |
| 116 | | - </label> |
| 117 | | - <button type="submit" class="primary">(g::t(lang, K::AddMemberButton))</button> |
| 118 | | - </form> |
| 119 | | - </div> |
| 120 | | - </details> |
| 97 | + <p class="hint">(g::t(lang, K::OwnersHelp))</p> |
| 98 | + <div class="acts"> |
| 99 | + reveal(label: g::t(lang, K::AddMemberButton), id: Some("add-member"), |
| 100 | + <form method="post" action=(add_action.as_str()) class="fields"> |
| 101 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 102 | + <div class="field"> |
| 103 | + <label for="add-member-username">(g::t(lang, K::Username))</label> |
| 104 | + <input id="add-member-username" type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 105 | + </div> |
| 106 | + <div class="field"> |
| 107 | + <label for="add-member-role">(g::t(lang, K::Role))</label> |
| 108 | + <select id="add-member-role" name="role"> |
| 109 | + <option value="member" selected=(true)>(g::t(lang, K::RoleMember))</option> |
| 110 | + <option value="owner">(g::t(lang, K::RoleOwner))</option> |
| 111 | + </select> |
| 112 | + </div> |
| 113 | + <button type="submit" class="primary">(g::t(lang, K::AddMemberButton))</button> |
| 114 | + </form> |
| 115 | + ) |
| 121 | 116 | </div> |
| 122 | 117 | } |
| 123 | | - for row in rows.iter() { |
| 124 | | - <div class="row-line"> |
| 125 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 3.6-7 8-7s8 3 8 7"/></svg> |
| 126 | | - <div class="row-main"> |
| 127 | | - <strong class="row-name"> |
| 128 | | - <a class="user-link" href=(format!("/{}", row.username.as_str()))> |
| 129 | | - <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> |
| 130 | | - <span>(row.label.as_str())</span> |
| 131 | | - </a> |
| 132 | | - </strong> |
| 133 | | - if !owner { |
| 134 | | - <p class="row-status">(if row.is_owner { g::t(lang, K::RoleOwner) } else { g::t(lang, K::RoleMember) })</p> |
| 135 | | - } |
| 136 | | - </div> |
| 118 | + <div> |
| 119 | + for row in rows.iter() { |
| 137 | 120 | if owner || row.is_self { |
| 138 | | - <div class="row-actions"> |
| 139 | | - if owner { |
| 140 | | - <form method="post" action=(role_action.as_str()) class="row-form"> |
| 141 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 142 | | - <input type="hidden" name="user_id" value=(row.user_id.as_str())> |
| 143 | | - <select name="role" aria-label=(g::role_for(lang, row.username.as_str()))> |
| 144 | | - <option value="owner" selected=(row.is_owner)>(g::t(lang, K::RoleOwner))</option> |
| 145 | | - <option value="member" selected=(!row.is_owner)>(g::t(lang, K::RoleMember))</option> |
| 146 | | - </select> |
| 147 | | - <button type="submit">(g::t(lang, K::Save))</button> |
| 148 | | - </form> |
| 149 | | - } |
| 150 | | - <details class="row-menu"> |
| 151 | | - <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> |
| 152 | | - <div class="row-menu-panel" role="menu"> |
| 153 | | - <form method="post" action=(remove_action.as_str()) class="inline-form"> |
| 121 | + <details class="row-open"> |
| 122 | + <summary class="line" data-kb-row=""> |
| 123 | + <span class="name org-who"> |
| 124 | + <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> |
| 125 | + <span>(row.label.as_str())</span> |
| 126 | + </span> |
| 127 | + <span class="val">(if row.is_owner { g::t(lang, K::RoleOwner) } else { g::t(lang, K::RoleMember) })</span> |
| 128 | + </summary> |
| 129 | + <div class="opened"> |
| 130 | + if owner { |
| 131 | + <form method="post" action=(role_action.as_str()) class="fields"> |
| 154 | 132 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 155 | 133 | <input type="hidden" name="user_id" value=(row.user_id.as_str())> |
| 156 | | - <button type="submit" class="danger">(if row.is_self { g::t(lang, K::Leave) } else { g::t(lang, K::Remove) })</button> |
| 134 | + <div class="field"> |
| 135 | + <label for=(format!("role-{}", row.user_id))>(g::t(lang, K::Role))</label> |
| 136 | + <select id=(format!("role-{}", row.user_id)) name="role"> |
| 137 | + <option value="owner" selected=(row.is_owner)>(g::t(lang, K::RoleOwner))</option> |
| 138 | + <option value="member" selected=(!row.is_owner)>(g::t(lang, K::RoleMember))</option> |
| 139 | + </select> |
| 140 | + </div> |
| 141 | + <div class="acts"> |
| 142 | + <button type="submit" class="act">(g::t(lang, K::Save))</button> |
| 143 | + </div> |
| 157 | 144 | </form> |
| 145 | + } |
| 146 | + <a class="act quiet" href=(format!("/{}", row.username.as_str()))>(passkeys::s(lang, "Open profile", "Profili aç"))</a> |
| 147 | + <div class="acts"> |
| 148 | + confirm_act(lang: lang, label: g::t(lang, if row.is_self { K::Leave } else { K::Remove }), action: remove_action.as_str(), csrf: csrf.as_str(), fields: vec![("user_id".to_owned(), row.user_id.clone())]) |
| 158 | 149 | </div> |
| 159 | | - </details> |
| 160 | | - </div> |
| 150 | + </div> |
| 151 | + </details> |
| 152 | + } else { |
| 153 | + <a class="line" href=(format!("/{}", row.username.as_str())) data-kb-row=""> |
| 154 | + <span class="name org-who"> |
| 155 | + <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> |
| 156 | + <span>(row.label.as_str())</span> |
| 157 | + </span> |
| 158 | + <span class="val">(if row.is_owner { g::t(lang, K::RoleOwner) } else { g::t(lang, K::RoleMember) })</span> |
| 159 | + </a> |
| 161 | 160 | } |
| 162 | | - </div> |
| 163 | | - } |
| 161 | + } |
| 162 | + </div> |
| 164 | 163 | </section> |
| 165 | 164 | </div> |
| 166 | 165 | }) |
| | @@ -49,27 +49,23 @@ async fn new_org_form( |
| 49 | 49 | lang: Lang, |
| 50 | 50 | ) -> Result<impl View> { |
| 51 | 51 | Ok(view! { |
| 52 | | - <section class="page-head"> |
| 53 | | - <h1>(g::t(lang, K::NewOrganization))</h1> |
| 54 | | - </section> |
| 55 | | - <section class="card org-new"> |
| 56 | | - <p class="muted small">(g::t(lang, K::NewOrgIntro))</p> |
| 57 | | - if let Some(message) = error { |
| 58 | | - alert(message: message.as_str()) |
| 59 | | - } |
| 60 | | - <form method="post" action="/org/new" class="stack"> |
| 61 | | - csrf_field(token: csrf.as_str()) |
| 62 | | - <label> |
| 63 | | - <span>(g::t(lang, K::OrgName))</span> |
| 64 | | - <input type="text" name="name" value=(name.as_str()) required=(true) maxlength="64" autocomplete="off"> |
| 65 | | - </label> |
| 66 | | - <label> |
| 67 | | - <span>(g::t(lang, K::DescriptionOptional))</span> |
| 68 | | - <textarea name="description" rows="3" maxlength="2000">(description.as_str())</textarea> |
| 69 | | - </label> |
| 70 | | - <button type="submit" class="primary">(g::t(lang, K::CreateOrg))</button> |
| 71 | | - </form> |
| 72 | | - </section> |
| 52 | + <h1 class="sr-only">(g::t(lang, K::NewOrganization))</h1> |
| 53 | + <p class="hint">(g::t(lang, K::NewOrgIntro))</p> |
| 54 | + if let Some(message) = error { |
| 55 | + alert(message: message.as_str()) |
| 56 | + } |
| 57 | + <form method="post" action="/org/new" class="fields"> |
| 58 | + csrf_field(token: csrf.as_str()) |
| 59 | + <div class="field"> |
| 60 | + <label for="org-new-name">(g::t(lang, K::OrgName))</label> |
| 61 | + <input id="org-new-name" type="text" name="name" value=(name.as_str()) required=(true) maxlength="64" autocomplete="off"> |
| 62 | + </div> |
| 63 | + <div class="field"> |
| 64 | + <label for="org-new-description">(g::t(lang, K::DescriptionOptional))</label> |
| 65 | + <textarea id="org-new-description" name="description" rows="3" maxlength="2000">(description.as_str())</textarea> |
| 66 | + </div> |
| 67 | + <button type="submit" class="primary">(g::t(lang, K::CreateOrg))</button> |
| 68 | + </form> |
| 73 | 69 | }) |
| 74 | 70 | } |
| 75 | 71 | |
| | @@ -22,11 +22,12 @@ use crate::i18n::orgs::{self as g, K}; |
| 22 | 22 | use crate::i18n::{self, Key, Lang, t}; |
| 23 | 23 | use crate::live::Topic; |
| 24 | 24 | use crate::pages::org_ctx::{ |
| 25 | | - DEFAULT_ROLES, load_org, notice_href, org_head, org_notice, require_form_csrf, require_owner, |
| 26 | | - take_notice, |
| 25 | + DEFAULT_ROLES, load_org, notice_href, org_notice, org_tab_counts, org_tabs, require_form_csrf, |
| 26 | + require_owner, take_notice, |
| 27 | 27 | }; |
| 28 | 28 | use crate::pages::settings_profile::store_avatar; |
| 29 | 29 | use crate::state::AppState; |
| 30 | +use crate::views::parts::{confirm_act, reveal}; |
| 30 | 31 | use crate::views::{avatar_url, shell, user_facing_message}; |
| 31 | 32 | |
| 32 | 33 | path_param!(org); |
| | @@ -78,6 +79,8 @@ async fn settings_body( |
| 78 | 79 | notice: Option<(&'static str, bool)>, |
| 79 | 80 | lang: Lang, |
| 80 | 81 | live: String, |
| 82 | + repo_count: u64, |
| 83 | + package_count: usize, |
| 81 | 84 | ) -> Result<impl View> { |
| 82 | 85 | let save_action = format!("{base}/settings"); |
| 83 | 86 | let avatar_action = format!("{base}/settings/avatar"); |
| | @@ -86,101 +89,79 @@ async fn settings_body( |
| 86 | 89 | let confirm_label = g::type_to_confirm(lang, &name); |
| 87 | 90 | Ok(view! { |
| 88 | 91 | <div data-live=(live.as_str())> |
| 89 | | - org_head(name: name, description: description.clone()) |
| 92 | + org_tabs(lang: lang, name: name.clone(), current: "settings".to_owned(), owner: true, repo_count: repo_count, package_count: package_count) |
| 93 | + <h1 class="sr-only">(name.as_str())</h1> |
| 90 | 94 | org_notice(notice: notice) |
| 91 | | - <section class="card rows-pane"> |
| 92 | | - <form id="org-settings-form" method="post" action=(save_action.as_str())> |
| 93 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 94 | | - </form> |
| 95 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Details", "Ayrıntılar"))</h2> |
| 96 | | - <label class="row-line row-field"> |
| 97 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="5" y="3" width="14" height="18" rx="1"/><path d="M9 7h2M13 7h2M9 11h2M13 11h2M10 21v-4h4v4"/></svg> |
| 98 | | - <span class="row-main"> |
| 99 | | - <span class="row-title">(g::t(lang, K::DisplayNameLabel))</span> |
| 100 | | - </span> |
| 101 | | - <span class="row-control"> |
| 102 | | - <input form="org-settings-form" type="text" name="display_name" maxlength="80" value=(display_name.as_str())> |
| 103 | | - </span> |
| 104 | | - </label> |
| 105 | | - <label class="row-line row-field"> |
| 106 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 5h14v10H9l-4 4z"/></svg> |
| 107 | | - <span class="row-main"> |
| 108 | | - <span class="row-title">(g::t(lang, K::Description))</span> |
| 109 | | - </span> |
| 110 | | - <span class="row-control"> |
| 111 | | - <textarea form="org-settings-form" name="description" rows="2" maxlength="2000">(description.as_str())</textarea> |
| 112 | | - </span> |
| 113 | | - </label> |
| 114 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Members", "Üyeler"))</h2> |
| 115 | | - <label class="row-line row-field"> |
| 116 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l8 3v6c0 4.5-3.4 8.3-8 9-4.6-.7-8-4.5-8-9V6z"/></svg> |
| 117 | | - <span class="row-main"> |
| 118 | | - <span class="row-title">(g::t(lang, K::DefaultRoleLabel))</span> |
| 119 | | - <span class="row-status">(g::t(lang, K::DefaultRoleHelp))</span> |
| 120 | | - </span> |
| 121 | | - <span class="row-control"> |
| 122 | | - <select form="org-settings-form" name="default_repo_role"> |
| 95 | + <form id="org-settings-form" method="post" action=(save_action.as_str())> |
| 96 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 97 | + <section class="sec"> |
| 98 | + <h2>(crate::pages::passkeys::s(lang, "Details", "Ayrıntılar"))</h2> |
| 99 | + <div class="field"> |
| 100 | + <label for="org-display-name">(g::t(lang, K::DisplayNameLabel))</label> |
| 101 | + <input id="org-display-name" type="text" name="display_name" maxlength="80" value=(display_name.as_str())> |
| 102 | + </div> |
| 103 | + <div class="field"> |
| 104 | + <label for="org-description">(g::t(lang, K::Description))</label> |
| 105 | + <textarea id="org-description" name="description" rows="2" maxlength="2000">(description.as_str())</textarea> |
| 106 | + </div> |
| 107 | + </section> |
| 108 | + <section class="sec"> |
| 109 | + <h2>(crate::pages::passkeys::s(lang, "Members", "Üyeler"))</h2> |
| 110 | + <div class="field"> |
| 111 | + <label for="org-default-role">(g::t(lang, K::DefaultRoleLabel))</label> |
| 112 | + <select id="org-default-role" name="default_repo_role"> |
| 123 | 113 | for choice in DEFAULT_ROLES.iter() { |
| 124 | 114 | <option value=(*choice) selected=(*choice == default_role.as_str())>(g::role_name(lang, choice))</option> |
| 125 | 115 | } |
| 126 | 116 | </select> |
| 127 | | - </span> |
| 128 | | - </label> |
| 129 | | - <label class="row-line row-field"> |
| 130 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 12l5 5L20 6"/></svg> |
| 131 | | - <span class="row-main"> |
| 132 | | - <span class="row-title">(g::t(lang, K::MembersCanCreate))</span> |
| 133 | | - </span> |
| 134 | | - <span class="row-control"> |
| 135 | | - <input form="org-settings-form" type="checkbox" name="members_can_create" value="on" checked=(members_can_create)> |
| 136 | | - </span> |
| 137 | | - </label> |
| 138 | | - <div class="row-foot"> |
| 139 | | - <button type="submit" class="primary" form="org-settings-form">(g::t(lang, K::SaveSettings))</button> |
| 140 | | - </div> |
| 141 | | - </section> |
| 142 | | - <section class="card rows-pane"> |
| 143 | | - <div class="row-line row-field"> |
| 144 | | - <img class="avatar profile-settings-avatar-img" src=(avatar_src.as_str()) alt=(t(lang, Key::AvatarAlt)) width="40" height="40"> |
| 145 | | - <div class="row-main"> |
| 146 | | - <h2 class="row-title">(t(lang, Key::Avatar))</h2> |
| 147 | | - <p class="row-status">(t(lang, Key::AvatarHint))</p> |
| 117 | + <p class="hint">(g::t(lang, K::DefaultRoleHelp))</p> |
| 118 | + </div> |
| 119 | + <label class="switch"> |
| 120 | + <input type="checkbox" name="members_can_create" value="on" checked=(members_can_create)> |
| 121 | + <span>(g::t(lang, K::MembersCanCreate))</span> |
| 122 | + </label> |
| 123 | + <div class="acts"> |
| 124 | + <button type="submit" class="primary">(g::t(lang, K::SaveSettings))</button> |
| 148 | 125 | </div> |
| 149 | | - <div class="row-actions row-control"> |
| 150 | | - <form method="post" action=(avatar_action.as_str()) enctype="multipart/form-data" class="row-form profile-settings-avatar-upload"> |
| 126 | + </section> |
| 127 | + </form> |
| 128 | + <section class="sec"> |
| 129 | + <h2>(t(lang, Key::Avatar))</h2> |
| 130 | + <img class="avatar profile-settings-avatar-img" src=(avatar_src.as_str()) alt=(t(lang, Key::AvatarAlt)) width="40" height="40"> |
| 131 | + <p class="hint">(t(lang, Key::AvatarHint))</p> |
| 132 | + <div class="acts"> |
| 133 | + reveal(label: t(lang, Key::UploadPhoto), id: Some("org-avatar"), |
| 134 | + <form method="post" action=(avatar_action.as_str()) enctype="multipart/form-data" class="fields"> |
| 151 | 135 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 152 | | - <input class="profile-settings-avatar-file" type="file" id="org-settings-avatar-file" name="avatar" aria-label=(t(lang, Key::Image)) accept="image/png,image/jpeg,image/webp,image/gif" required=(true)> |
| 153 | | - <label class="profile-settings-avatar-item" for="org-settings-avatar-file">(t(lang, Key::UploadPhoto))</label> |
| 136 | + <div class="field"> |
| 137 | + <label for="org-settings-avatar-file">(t(lang, Key::Image))</label> |
| 138 | + <input id="org-settings-avatar-file" type="file" name="avatar" accept="image/png,image/jpeg,image/webp,image/gif" required=(true)> |
| 139 | + </div> |
| 154 | 140 | <button type="submit" class="primary">(t(lang, Key::Upload))</button> |
| 155 | 141 | </form> |
| 156 | | - if has_avatar { |
| 157 | | - <form method="post" action=(avatar_remove_action.as_str()) class="row-form"> |
| 158 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 159 | | - <button type="submit" class="link-button">(t(lang, Key::RemovePhoto))</button> |
| 160 | | - </form> |
| 161 | | - } |
| 162 | | - </div> |
| 142 | + ) |
| 143 | + if has_avatar { |
| 144 | + confirm_act(lang: lang, label: t(lang, Key::RemovePhoto), action: avatar_remove_action.as_str(), csrf: csrf.as_str()) |
| 145 | + } |
| 163 | 146 | </div> |
| 164 | 147 | </section> |
| 165 | | - <section class="card rows-pane security-danger"> |
| 166 | | - <div class="row-line"> |
| 167 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4l9 16H3z"/><path d="M12 10v4M12 17v.5"/></svg> |
| 168 | | - <div class="row-main"> |
| 169 | | - <h2 class="row-title">(g::t(lang, K::DeleteOrg))</h2> |
| 170 | | - <p class="row-status">(g::t(lang, K::DeleteOrgIntro))</p> |
| 171 | | - </div> |
| 172 | | - <details class="row-action danger"> |
| 173 | | - <summary>(g::t(lang, K::DeleteOrg))</summary> |
| 174 | | - <div class="row-panel"> |
| 175 | | - <form method="post" action=(delete_action.as_str()) class="stack"> |
| 176 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 177 | | - <label> |
| 178 | | - <span>(confirm_label.as_str())</span> |
| 179 | | - <input type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 180 | | - </label> |
| 181 | | - <button type="submit" class="danger">(g::t(lang, K::DeleteOrg))</button> |
| 182 | | - </form> |
| 183 | | - </div> |
| 148 | + <section class="sec"> |
| 149 | + <h2>(g::t(lang, K::DeleteOrg))</h2> |
| 150 | + <p class="hint">(g::t(lang, K::DeleteOrgIntro))</p> |
| 151 | + <div class="acts"> |
| 152 | + <details class="reveal"> |
| 153 | + <summary class="act danger">(g::t(lang, K::DeleteOrg))</summary> |
| 154 | + <form class="opened fields" method="post" action=(delete_action.as_str())> |
| 155 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 156 | + <div class="field"> |
| 157 | + <label for="org-delete-confirm">(confirm_label.as_str())</label> |
| 158 | + <input id="org-delete-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 159 | + </div> |
| 160 | + <div class="acts"> |
| 161 | + <button type="submit" class="act danger">(g::t(lang, K::DeleteOrg))</button> |
| 162 | + <button type="button" class="act quiet" data-close-details="">(crate::pages::passkeys::s(lang, "Cancel", "Vazgeç"))</button> |
| 163 | + </div> |
| 164 | + </form> |
| 184 | 165 | </details> |
| 185 | 166 | </div> |
| 186 | 167 | </section> |
| | @@ -209,11 +190,13 @@ async fn org_settings_page(cx: &Cx) -> Result<impl View> { |
| 209 | 190 | let base = ctx.href(""); |
| 210 | 191 | let csrf = ctx.viewer.1.csrf_token.clone(); |
| 211 | 192 | let live = ctx.href("/settings/events"); |
| 193 | + let (repo_count, package_count) = org_tab_counts(state, &ctx.org, &ctx.viewer.0).await?; |
| 212 | 194 | Ok(view! { cx => |
| 213 | 195 | shell(title: title.as_str(), viewer: Some(&ctx.viewer), |
| 214 | 196 | settings_body(name: name, display_name: display_name, description: description, |
| 215 | 197 | has_avatar: has_avatar, avatar_src: avatar_src, base: base, csrf: csrf, |
| 216 | | - default_role: default_role, members_can_create: members_can_create, notice: notice, lang: lang, live: live)) |
| 198 | + default_role: default_role, members_can_create: members_can_create, notice: notice, lang: lang, live: live, |
| 199 | + repo_count: repo_count, package_count: package_count)) |
| 217 | 200 | }) |
| 218 | 201 | } |
| 219 | 202 | |
| | @@ -24,6 +24,7 @@ use crate::pages::org_ctx::{ |
| 24 | 24 | }; |
| 25 | 25 | use crate::pages::passkeys; |
| 26 | 26 | use crate::state::AppState; |
| 27 | +use crate::views::parts::{confirm_act, reveal}; |
| 27 | 28 | use crate::views::{avatar_url, display_name, repo_href, shell}; |
| 28 | 29 | |
| 29 | 30 | path_param!(org); |
| | @@ -109,7 +110,6 @@ struct RepoChoice { |
| 109 | 110 | /// Everything the team page shows besides the notice. |
| 110 | 111 | struct TeamPage { |
| 111 | 112 | org_name: String, |
| 112 | | - org_description: String, |
| 113 | 113 | base: String, |
| 114 | 114 | /// The URL of the team page's change stream. |
| 115 | 115 | live: String, |
| | @@ -197,64 +197,59 @@ async fn teams_body( |
| 197 | 197 | ) -> Result<impl View> { |
| 198 | 198 | let create_action = format!("{base}/teams/new"); |
| 199 | 199 | Ok(view! { |
| 200 | | - <div data-live=(live.as_str()) class="teams-page"> |
| 201 | | - org_head(name: name.clone(), description: description) |
| 202 | | - org_tabs(lang: lang, name: name, current: "teams".to_owned(), repo_count: repo_count, package_count: package_count) |
| 200 | + <div data-live=(live.as_str())> |
| 201 | + org_tabs(lang: lang, name: name.clone(), current: "teams".to_owned(), owner: owner, repo_count: repo_count, package_count: package_count) |
| 202 | + org_head(name: name, description: description) |
| 203 | 203 | org_notice(notice: notice) |
| 204 | | - <section class="card rows-pane"> |
| 205 | | - <div class="row-line"> |
| 206 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="9" cy="8" r="3"/><circle cx="17" cy="9" r="2.5"/><path d="M3 20c0-3.3 2.7-6 6-6s6 2.7 6 6M15 14.2c2.7.2 6 2 6 5.8"/></svg> |
| 207 | | - <div class="row-main"> |
| 208 | | - <h2 class="row-title">(if owner { g::t(lang, K::NewTeam) } else { g::t(lang, K::Teams) })</h2> |
| 209 | | - <p class="row-status">(g::t(lang, K::TeamsIntro))</p> |
| 210 | | - if rows.is_empty() { |
| 211 | | - <p class="row-status">(g::t(lang, K::NoTeamsYet))</p> |
| 212 | | - } |
| 204 | + <section class="sec"> |
| 205 | + <h2>(g::t(lang, K::Teams))</h2> |
| 206 | + <p class="hint">(g::t(lang, K::TeamsIntro))</p> |
| 207 | + if owner { |
| 208 | + <div class="acts"> |
| 209 | + reveal(label: g::t(lang, K::CreateTeam), id: Some("new-team"), |
| 210 | + <form method="post" action=(create_action.as_str()) class="fields"> |
| 211 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 212 | + <div class="field"> |
| 213 | + <label for="new-team-name">(g::t(lang, K::Name))</label> |
| 214 | + <input id="new-team-name" type="text" name="name" autocomplete="off" required=(true) maxlength="64"> |
| 215 | + </div> |
| 216 | + <div class="field"> |
| 217 | + <label for="new-team-description">(g::t(lang, K::DescriptionOptional))</label> |
| 218 | + <textarea id="new-team-description" name="description" rows="2" maxlength="350"></textarea> |
| 219 | + </div> |
| 220 | + <div class="field"> |
| 221 | + <label for="new-team-role">(g::t(lang, K::Role))</label> |
| 222 | + <select id="new-team-role" name="role"> |
| 223 | + for role in TEAM_ROLES.iter() { |
| 224 | + <option value=(role.as_str()) selected=(*role == Role::Read)>(g::role_name(lang, role.as_str()))</option> |
| 225 | + } |
| 226 | + </select> |
| 227 | + </div> |
| 228 | + <label class="switch"> |
| 229 | + <input type="checkbox" name="all_repos" value="on"> |
| 230 | + <span>(g::t(lang, K::CoversAllRepos))</span> |
| 231 | + </label> |
| 232 | + <button type="submit" class="primary">(g::t(lang, K::CreateTeam))</button> |
| 233 | + </form> |
| 234 | + ) |
| 213 | 235 | </div> |
| 214 | | - if owner { |
| 215 | | - <details class="row-action" id="new-team"> |
| 216 | | - <summary>(g::t(lang, K::CreateTeam))</summary> |
| 217 | | - <div class="row-panel"> |
| 218 | | - <form method="post" action=(create_action.as_str()) class="stack"> |
| 219 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 220 | | - <label> |
| 221 | | - <span>(g::t(lang, K::Name))</span> |
| 222 | | - <input type="text" name="name" autocomplete="off" required=(true) maxlength="64"> |
| 223 | | - </label> |
| 224 | | - <label> |
| 225 | | - <span>(g::t(lang, K::DescriptionOptional))</span> |
| 226 | | - <textarea name="description" rows="2" maxlength="350"></textarea> |
| 227 | | - </label> |
| 228 | | - <label> |
| 229 | | - <span>(g::t(lang, K::Role))</span> |
| 230 | | - <select name="role"> |
| 231 | | - for role in TEAM_ROLES.iter() { |
| 232 | | - <option value=(role.as_str()) selected=(*role == Role::Read)>(g::role_name(lang, role.as_str()))</option> |
| 233 | | - } |
| 234 | | - </select> |
| 235 | | - </label> |
| 236 | | - <label class="inline"> |
| 237 | | - <input type="checkbox" name="all_repos" value="on"> |
| 238 | | - <span>(g::t(lang, K::CoversAllRepos))</span> |
| 239 | | - </label> |
| 240 | | - <button type="submit" class="primary">(g::t(lang, K::CreateTeam))</button> |
| 241 | | - </form> |
| 242 | | - </div> |
| 243 | | - </details> |
| 236 | + } |
| 237 | + if rows.is_empty() { |
| 238 | + <p class="state">(g::t(lang, K::NoTeamsYet))</p> |
| 239 | + } |
| 240 | + <div> |
| 241 | + for row in rows.iter() { |
| 242 | + <a class="line" href=(row.href.as_str()) data-kb-row=""> |
| 243 | + <span class="name">(row.name.as_str())</span> |
| 244 | + <span class="val"> |
| 245 | + (g::coverage_text(lang, row.role, row.all_repos)) |
| 246 | + if !row.description.is_empty() { |
| 247 | + " · " (row.description.as_str()) |
| 248 | + } |
| 249 | + </span> |
| 250 | + </a> |
| 244 | 251 | } |
| 245 | 252 | </div> |
| 246 | | - for row in rows.iter() { |
| 247 | | - <div class="row-line"> |
| 248 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="9" cy="8" r="3"/><circle cx="17" cy="9" r="2.5"/><path d="M3 20c0-3.3 2.7-6 6-6s6 2.7 6 6M15 14.2c2.7.2 6 2 6 5.8"/></svg> |
| 249 | | - <div class="row-main"> |
| 250 | | - <strong class="row-name"><a href=(row.href.as_str())>(row.name.as_str())</a></strong> |
| 251 | | - <p class="row-status">(g::coverage_text(lang, row.role, row.all_repos))</p> |
| 252 | | - if !row.description.is_empty() { |
| 253 | | - <p class="row-status">(row.description.as_str())</p> |
| 254 | | - } |
| 255 | | - </div> |
| 256 | | - </div> |
| 257 | | - } |
| 258 | 253 | </section> |
| 259 | 254 | </div> |
| 260 | 255 | }) |
| | @@ -314,181 +309,136 @@ async fn team_body( |
| 314 | 309 | let has_description = !data.team_description.is_empty(); |
| 315 | 310 | Ok(view! { |
| 316 | 311 | <div data-live=(data.live.as_str())> |
| 317 | | - org_head(name: data.org_name.clone(), description: data.org_description.clone()) |
| 318 | | - org_tabs(lang: lang, name: data.org_name.clone(), current: "teams".to_owned(), repo_count: data.repo_count, package_count: data.package_count) |
| 312 | + org_tabs(lang: lang, name: data.org_name.clone(), current: "teams".to_owned(), owner: owner, repo_count: data.repo_count, package_count: data.package_count) |
| 319 | 313 | org_notice(notice: notice) |
| 320 | | - <section class="card rows-pane"> |
| 321 | | - <div class="row-line"> |
| 322 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="9" cy="8" r="3"/><circle cx="17" cy="9" r="2.5"/><path d="M3 20c0-3.3 2.7-6 6-6s6 2.7 6 6M15 14.2c2.7.2 6 2 6 5.8"/></svg> |
| 323 | | - <div class="row-main"> |
| 324 | | - <h2 class="row-title">(data.team_name.as_str())</h2> |
| 325 | | - if has_description { |
| 326 | | - <p class="row-status">(data.team_description.as_str())</p> |
| 327 | | - } |
| 328 | | - <p class="row-status">(g::coverage_text(lang, data.team_role, data.team_all_repos))</p> |
| 329 | | - </div> |
| 330 | | - </div> |
| 314 | + <h1 class="h1">(data.team_name.as_str())</h1> |
| 315 | + <p class="hint"> |
| 316 | + (g::coverage_text(lang, data.team_role, data.team_all_repos)) |
| 317 | + if has_description { |
| 318 | + " · " (data.team_description.as_str()) |
| 319 | + } |
| 320 | + </p> |
| 321 | + <section class="sec"> |
| 322 | + <h2>(g::t(lang, K::Members))</h2> |
| 331 | 323 | if owner { |
| 332 | | - <form id="team-settings-form" method="post" action=(update_action.as_str())> |
| 333 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 334 | | - </form> |
| 335 | | - <label class="row-line row-field"> |
| 336 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h10M4 17h7"/></svg> |
| 337 | | - <span class="row-main"> |
| 338 | | - <span class="row-title">(g::t(lang, K::Name))</span> |
| 339 | | - </span> |
| 340 | | - <span class="row-control"> |
| 341 | | - <input form="team-settings-form" type="text" name="name" value=(data.team_name.as_str()) autocomplete="off" required=(true) maxlength="64"> |
| 342 | | - </span> |
| 343 | | - </label> |
| 344 | | - <label class="row-line row-field"> |
| 345 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 5h14v10H9l-4 4z"/></svg> |
| 346 | | - <span class="row-main"> |
| 347 | | - <span class="row-title">(g::t(lang, K::DescriptionOptional))</span> |
| 348 | | - </span> |
| 349 | | - <span class="row-control"> |
| 350 | | - <textarea form="team-settings-form" name="description" rows="2" maxlength="350">(data.team_description.as_str())</textarea> |
| 351 | | - </span> |
| 352 | | - </label> |
| 353 | | - <label class="row-line row-field"> |
| 354 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l8 3v6c0 4.5-3.4 8.3-8 9-4.6-.7-8-4.5-8-9V6z"/></svg> |
| 355 | | - <span class="row-main"> |
| 356 | | - <span class="row-title">(g::t(lang, K::Role))</span> |
| 357 | | - </span> |
| 358 | | - <span class="row-control"> |
| 359 | | - <select form="team-settings-form" name="role"> |
| 360 | | - for role in TEAM_ROLES.iter() { |
| 361 | | - <option value=(role.as_str()) selected=(role.as_str() == data.team_role)>(g::role_name(lang, role.as_str()))</option> |
| 362 | | - } |
| 363 | | - </select> |
| 364 | | - </span> |
| 365 | | - </label> |
| 366 | | - <label class="row-line row-field"> |
| 367 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 12l5 5L20 6"/></svg> |
| 368 | | - <span class="row-main"> |
| 369 | | - <span class="row-title">(g::t(lang, K::CoversAllRepos))</span> |
| 370 | | - </span> |
| 371 | | - <span class="row-control"> |
| 372 | | - <input form="team-settings-form" type="checkbox" name="all_repos" value="on" checked=(data.team_all_repos)> |
| 373 | | - </span> |
| 374 | | - </label> |
| 375 | | - <div class="row-foot"> |
| 376 | | - <button type="submit" class="primary" form="team-settings-form">(g::t(lang, K::SaveTeam))</button> |
| 324 | + <div class="acts"> |
| 325 | + reveal(label: g::t(lang, K::AddToTeam), id: Some("add-member"), |
| 326 | + <form method="post" action=(add_member_action.as_str()) class="fields"> |
| 327 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 328 | + <div class="field"> |
| 329 | + <label for="team-member-username">(g::t(lang, K::Username))</label> |
| 330 | + <input id="team-member-username" type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 331 | + </div> |
| 332 | + <button type="submit" class="primary">(g::t(lang, K::AddToTeam))</button> |
| 333 | + </form> |
| 334 | + ) |
| 377 | 335 | </div> |
| 378 | 336 | } |
| 379 | | - </section> |
| 380 | | - <section class="card rows-pane"> |
| 381 | | - <div class="row-line"> |
| 382 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 383 | | - <div class="row-main"> |
| 384 | | - <h2 class="row-title">(if owner { g::t(lang, K::AddMember) } else { g::t(lang, K::Members) })</h2> |
| 385 | | - if data.members.is_empty() { |
| 386 | | - <p class="row-status">(g::t(lang, K::NoTeamMembers))</p> |
| 387 | | - } |
| 388 | | - </div> |
| 389 | | - if owner { |
| 390 | | - <details class="row-action" id="add-member"> |
| 391 | | - <summary>(g::t(lang, K::AddToTeam))</summary> |
| 392 | | - <div class="row-panel"> |
| 393 | | - <form method="post" action=(add_member_action.as_str()) class="stack"> |
| 394 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 395 | | - <label> |
| 396 | | - <span>(g::t(lang, K::Username))</span> |
| 397 | | - <input type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 398 | | - </label> |
| 399 | | - <button type="submit" class="primary">(g::t(lang, K::AddToTeam))</button> |
| 400 | | - </form> |
| 401 | | - </div> |
| 402 | | - </details> |
| 403 | | - } |
| 404 | | - </div> |
| 405 | | - for member in data.members.iter() { |
| 406 | | - <div class="row-line"> |
| 407 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 3.6-7 8-7s8 3 8 7"/></svg> |
| 408 | | - <div class="row-main"> |
| 409 | | - <strong class="row-name"> |
| 410 | | - <a class="user-link" href=(format!("/{}", member.username.as_str()))> |
| 411 | | - <img class="avatar avatar-sm" src=(member.avatar.as_str()) alt="" width="24" height="24"> |
| 412 | | - <span>(member.label.as_str())</span> |
| 413 | | - </a> |
| 414 | | - </strong> |
| 415 | | - </div> |
| 337 | + if data.members.is_empty() { |
| 338 | + <p class="state">(g::t(lang, K::NoTeamMembers))</p> |
| 339 | + } |
| 340 | + <div> |
| 341 | + for member in data.members.iter() { |
| 416 | 342 | if owner { |
| 417 | | - <details class="row-menu"> |
| 418 | | - <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> |
| 419 | | - <div class="row-menu-panel" role="menu"> |
| 420 | | - <form method="post" action=(remove_member_action.as_str()) class="inline-form"> |
| 421 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 422 | | - <input type="hidden" name="user_id" value=(member.user_id.as_str())> |
| 423 | | - <button type="submit" class="danger">(g::t(lang, K::Remove))</button> |
| 424 | | - </form> |
| 343 | + <details class="row-open"> |
| 344 | + <summary class="line" data-kb-row=""> |
| 345 | + <span class="name org-who"> |
| 346 | + <img class="avatar avatar-sm" src=(member.avatar.as_str()) alt="" width="24" height="24"> |
| 347 | + <span>(member.label.as_str())</span> |
| 348 | + </span> |
| 349 | + </summary> |
| 350 | + <div class="opened"> |
| 351 | + <a class="act quiet" href=(format!("/{}", member.username.as_str()))>(passkeys::s(lang, "Open profile", "Profili aç"))</a> |
| 352 | + <div class="acts"> |
| 353 | + confirm_act(lang: lang, label: g::t(lang, K::Remove), action: remove_member_action.as_str(), csrf: csrf.as_str(), fields: vec![("user_id".to_owned(), member.user_id.clone())]) |
| 354 | + </div> |
| 425 | 355 | </div> |
| 426 | 356 | </details> |
| 357 | + } else { |
| 358 | + <a class="line" href=(format!("/{}", member.username.as_str())) data-kb-row=""> |
| 359 | + <span class="name org-who"> |
| 360 | + <img class="avatar avatar-sm" src=(member.avatar.as_str()) alt="" width="24" height="24"> |
| 361 | + <span>(member.label.as_str())</span> |
| 362 | + </span> |
| 363 | + </a> |
| 427 | 364 | } |
| 428 | | - </div> |
| 429 | | - } |
| 430 | | - </section> |
| 431 | | - <section class="card rows-pane"> |
| 432 | | - <div class="row-line"> |
| 433 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 434 | | - <div class="row-main"> |
| 435 | | - <h2 class="row-title">(if owner && has_choices { g::t(lang, K::LinkRepository) } else { g::t(lang, K::Repositories) })</h2> |
| 436 | | - if data.repos.is_empty() { |
| 437 | | - <p class="row-status">(g::t(lang, K::NoTeamRepos))</p> |
| 438 | | - } |
| 439 | | - </div> |
| 440 | | - if owner && has_choices { |
| 441 | | - <details class="row-action" id="link-repository"> |
| 442 | | - <summary>(g::t(lang, K::LinkRepository))</summary> |
| 443 | | - <div class="row-panel"> |
| 444 | | - <form method="post" action=(add_repo_action.as_str()) class="stack"> |
| 445 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 446 | | - <label> |
| 447 | | - <span>(g::t(lang, K::Repository))</span> |
| 448 | | - <select name="repo_id"> |
| 449 | | - for choice in data.choices.iter() { |
| 450 | | - <option value=(choice.id.as_str())>(choice.title.as_str())</option> |
| 451 | | - } |
| 452 | | - </select> |
| 453 | | - </label> |
| 454 | | - <button type="submit" class="primary">(g::t(lang, K::LinkRepository))</button> |
| 455 | | - </form> |
| 456 | | - </div> |
| 457 | | - </details> |
| 458 | 365 | } |
| 459 | 366 | </div> |
| 460 | | - for repo in data.repos.iter() { |
| 461 | | - <div class="row-line"> |
| 462 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 4h11a3 3 0 0 1 3 3v13H8a3 3 0 0 1-3-3z"/><path d="M5 17a3 3 0 0 1 3-3h11"/></svg> |
| 463 | | - <div class="row-main"> |
| 464 | | - <strong class="row-name"><a href=(repo.href.as_str())>(repo.title.as_str())</a></strong> |
| 465 | | - </div> |
| 367 | + </section> |
| 368 | + <section class="sec"> |
| 369 | + <h2>(g::t(lang, K::Repositories))</h2> |
| 370 | + if owner && has_choices { |
| 371 | + <div class="acts"> |
| 372 | + reveal(label: g::t(lang, K::LinkRepository), id: Some("link-repository"), |
| 373 | + <form method="post" action=(add_repo_action.as_str()) class="fields"> |
| 374 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 375 | + <div class="field"> |
| 376 | + <label for="team-repo-id">(g::t(lang, K::Repository))</label> |
| 377 | + <select id="team-repo-id" name="repo_id"> |
| 378 | + for choice in data.choices.iter() { |
| 379 | + <option value=(choice.id.as_str())>(choice.title.as_str())</option> |
| 380 | + } |
| 381 | + </select> |
| 382 | + </div> |
| 383 | + <button type="submit" class="primary">(g::t(lang, K::LinkRepository))</button> |
| 384 | + </form> |
| 385 | + ) |
| 386 | + </div> |
| 387 | + } |
| 388 | + if data.repos.is_empty() { |
| 389 | + <p class="state">(g::t(lang, K::NoTeamRepos))</p> |
| 390 | + } |
| 391 | + <div> |
| 392 | + for repo in data.repos.iter() { |
| 466 | 393 | if owner { |
| 467 | | - <details class="row-menu"> |
| 468 | | - <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> |
| 469 | | - <div class="row-menu-panel" role="menu"> |
| 470 | | - <form method="post" action=(remove_repo_action.as_str()) class="inline-form"> |
| 471 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 472 | | - <input type="hidden" name="repo_id" value=(repo.repo_id.as_str())> |
| 473 | | - <button type="submit" class="danger">(g::t(lang, K::Unlink))</button> |
| 474 | | - </form> |
| 394 | + <details class="row-open"> |
| 395 | + <summary class="line" data-kb-row=""> |
| 396 | + <span class="name">(repo.title.as_str())</span> |
| 397 | + </summary> |
| 398 | + <div class="opened"> |
| 399 | + <a class="act quiet" href=(repo.href.as_str())>(passkeys::s(lang, "Open repository", "Depoyu aç"))</a> |
| 400 | + <div class="acts"> |
| 401 | + confirm_act(lang: lang, label: g::t(lang, K::Unlink), action: remove_repo_action.as_str(), csrf: csrf.as_str(), fields: vec![("repo_id".to_owned(), repo.repo_id.clone())]) |
| 402 | + </div> |
| 475 | 403 | </div> |
| 476 | 404 | </details> |
| 405 | + } else { |
| 406 | + <a class="line" href=(repo.href.as_str()) data-kb-row=""> |
| 407 | + <span class="name">(repo.title.as_str())</span> |
| 408 | + </a> |
| 477 | 409 | } |
| 478 | | - </div> |
| 479 | | - } |
| 410 | + } |
| 411 | + </div> |
| 480 | 412 | </section> |
| 481 | 413 | if owner { |
| 482 | | - <section class="card rows-pane security-danger"> |
| 483 | | - <div class="row-line"> |
| 484 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4l9 16H3z"/><path d="M12 10v4M12 17v.5"/></svg> |
| 485 | | - <div class="row-main"> |
| 486 | | - <h2 class="row-title">(g::t(lang, K::DeleteTeam))</h2> |
| 414 | + <section class="sec"> |
| 415 | + <h2>(g::t(lang, K::Settings))</h2> |
| 416 | + <form id="team-settings-form" method="post" action=(update_action.as_str()) class="fields"> |
| 417 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 418 | + <div class="field"> |
| 419 | + <label for="team-name">(g::t(lang, K::Name))</label> |
| 420 | + <input id="team-name" type="text" name="name" value=(data.team_name.as_str()) autocomplete="off" required=(true) maxlength="64"> |
| 487 | 421 | </div> |
| 488 | | - <form method="post" action=(delete_action.as_str()) class="row-form"> |
| 489 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 490 | | - <button type="submit" class="danger">(g::t(lang, K::DeleteTeam))</button> |
| 491 | | - </form> |
| 422 | + <div class="field"> |
| 423 | + <label for="team-description">(g::t(lang, K::DescriptionOptional))</label> |
| 424 | + <textarea id="team-description" name="description" rows="2" maxlength="350">(data.team_description.as_str())</textarea> |
| 425 | + </div> |
| 426 | + <div class="field"> |
| 427 | + <label for="team-role">(g::t(lang, K::Role))</label> |
| 428 | + <select id="team-role" name="role"> |
| 429 | + for role in TEAM_ROLES.iter() { |
| 430 | + <option value=(role.as_str()) selected=(role.as_str() == data.team_role)>(g::role_name(lang, role.as_str()))</option> |
| 431 | + } |
| 432 | + </select> |
| 433 | + </div> |
| 434 | + <label class="switch"> |
| 435 | + <input type="checkbox" name="all_repos" value="on" checked=(data.team_all_repos)> |
| 436 | + <span>(g::t(lang, K::CoversAllRepos))</span> |
| 437 | + </label> |
| 438 | + <button type="submit" class="primary">(g::t(lang, K::SaveTeam))</button> |
| 439 | + </form> |
| 440 | + <div class="acts"> |
| 441 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteTeam), action: delete_action.as_str(), csrf: csrf.as_str()) |
| 492 | 442 | </div> |
| 493 | 443 | </section> |
| 494 | 444 | } |
| | @@ -535,7 +485,6 @@ async fn org_team_page(cx: &Cx) -> Result<impl View> { |
| 535 | 485 | repo_count, |
| 536 | 486 | package_count, |
| 537 | 487 | org_name: ctx.org.username.clone(), |
| 538 | | - org_description: ctx.org.about.clone(), |
| 539 | 488 | base: ctx.href(&format!("/teams/{}", team.id)), |
| 540 | 489 | live: ctx.href(&format!("/teams/{}/events", team.id)), |
| 541 | 490 | owner: ctx.is_owner(), |
| | @@ -296,8 +296,8 @@ async fn package_view(page: PackagePage) -> Result<impl View> { |
| 296 | 296 | let (repo_href, repo_text) = repo_link.unwrap_or_default(); |
| 297 | 297 | let private = package.private; |
| 298 | 298 | let readme_on = !versions_tab; |
| 299 | | - let readme_class = if readme_on { "tab active" } else { "tab" }; |
| 300 | | - let versions_class = if versions_tab { "tab active" } else { "tab" }; |
| 299 | + let readme_current: Option<&str> = readme_on.then_some("page"); |
| 300 | + let versions_current: Option<&str> = versions_tab.then_some("page"); |
| 301 | 301 | let has_versions = !version_rows.is_empty(); |
| 302 | 302 | let install = pk::t(lang, K::Install); |
| 303 | 303 | let copy_label = pk::t(lang, K::CopyCommand); |
| | @@ -305,78 +305,79 @@ async fn package_view(page: PackagePage) -> Result<impl View> { |
| 305 | 305 | let versions_label = pk::t(lang, K::PackageVersions); |
| 306 | 306 | let no_readme = pk::t(lang, K::NoReadme); |
| 307 | 307 | Ok(view! { |
| 308 | | - <article class="package-page" data-live=(events.as_str())> |
| 309 | | - <header class="package-head"> |
| 310 | | - <div> |
| 311 | | - <p class="muted small">(owner_name.as_str()) " / " (pk::t(lang, K::TabPackages))</p> |
| 312 | | - <h1>(package.name.as_str()) " " <span class="muted">(latest_text.as_str())</span></h1> |
| 313 | | - if !description.is_empty() { |
| 314 | | - <p class="muted">(description.as_str())</p> |
| 315 | | - } |
| 316 | | - if private { |
| 317 | | - <span class="badge">(pk::t(lang, K::PackagePrivate))</span> |
| 318 | | - } |
| 319 | | - if has_repo { |
| 320 | | - <p class="small">(pk::t(lang, K::PackageRepoLink)) ": " <a href=(repo_href.as_str())>(repo_text.as_str())</a></p> |
| 321 | | - } |
| 322 | | - </div> |
| 323 | | - </header> |
| 324 | | - <section class="package-install"> |
| 308 | + <div data-live=(events.as_str())> |
| 309 | + <h1 class="h1">(package.name.as_str()) " " <span class="muted">(latest_text.as_str())</span></h1> |
| 310 | + <p class="hint">(owner_name.as_str()) " / " (pk::t(lang, K::TabPackages))</p> |
| 311 | + if !description.is_empty() { |
| 312 | + <p class="state">(description.as_str())</p> |
| 313 | + } |
| 314 | + if private { |
| 315 | + <p class="hint"><span class="badge">(pk::t(lang, K::PackagePrivate))</span></p> |
| 316 | + } |
| 317 | + if has_repo { |
| 318 | + <p class="hint">(pk::t(lang, K::PackageRepoLink)) ": " <a href=(repo_href.as_str())>(repo_text.as_str())</a></p> |
| 319 | + } |
| 320 | + <section class="sec"> |
| 325 | 321 | <h2>(install)</h2> |
| 326 | | - <p class="muted small">(pk::t(lang, K::InstallHelp))</p> |
| 327 | | - <p class="small">(pk::t(lang, K::InstallRegistryConfig))</p> |
| 322 | + <p class="hint">(pk::t(lang, K::InstallHelp))</p> |
| 323 | + <p class="state">(pk::t(lang, K::InstallRegistryConfig))</p> |
| 328 | 324 | <div class="copy-box"> |
| 329 | 325 | <code id="pkg-config">(config_block.as_str())</code> |
| 330 | 326 | <button type="button" data-copy="pkg-config">(copy_label)</button> |
| 331 | 327 | </div> |
| 332 | | - <p class="small">(pk::t(lang, K::InstallAdd))</p> |
| 328 | + <p class="state">(pk::t(lang, K::InstallAdd))</p> |
| 333 | 329 | <div class="copy-box"> |
| 334 | 330 | <code id="pkg-add">(add_cmd.as_str())</code> |
| 335 | 331 | <button type="button" data-copy="pkg-add">(copy_label)</button> |
| 336 | 332 | </div> |
| 337 | | - <p class="small">(pk::t(lang, K::InstallPublish))</p> |
| 333 | + <p class="state">(pk::t(lang, K::InstallPublish))</p> |
| 338 | 334 | <div class="copy-box"> |
| 339 | 335 | <code id="pkg-publish">(publish_cmd.as_str())</code> |
| 340 | 336 | <button type="button" data-copy="pkg-publish">(copy_label)</button> |
| 341 | 337 | </div> |
| 342 | | - <p class="small">(pk::t(lang, K::InstallLogin))</p> |
| 338 | + <p class="state">(pk::t(lang, K::InstallLogin))</p> |
| 343 | 339 | <div class="copy-box"> |
| 344 | 340 | <code id="pkg-login">(login_cmd.as_str())</code> |
| 345 | 341 | <button type="button" data-copy="pkg-login">(copy_label)</button> |
| 346 | 342 | </div> |
| 347 | 343 | </section> |
| 348 | | - <nav class="profile-tabs" aria-label=(package.name.as_str())> |
| 349 | | - <a class=(readme_class) href=(readme_href.as_str())>(readme_label)</a> |
| 350 | | - <a class=(versions_class) href=(versions_href.as_str())>(versions_label)</a> |
| 344 | + <nav class="tabs" aria-label=(package.name.as_str())> |
| 345 | + <a href=(readme_href.as_str()) aria-current=(readme_current)>(readme_label)</a> |
| 346 | + <a href=(versions_href.as_str()) aria-current=(versions_current)>(versions_label)</a> |
| 351 | 347 | </nav> |
| 352 | 348 | if versions_tab { |
| 353 | 349 | if has_versions { |
| 354 | | - <ul class="item-list package-versions"> |
| 350 | + <div> |
| 355 | 351 | for (version, date, yanked, checksum) in version_rows.iter() { |
| 356 | | - <li> |
| 357 | | - <span class="repo-name">(version.as_str())</span> |
| 358 | | - " " |
| 359 | | - <span class="muted small">rel_time(lang: lang, stamp: date.as_str())</span> |
| 360 | | - if *yanked { |
| 361 | | - " " |
| 362 | | - <span class="badge">(pk::t(lang, K::VersionYanked))</span> |
| 363 | | - } |
| 364 | | - <br> |
| 365 | | - <code class="small">(checksum.as_str())</code> |
| 366 | | - </li> |
| 352 | + <details class="row-open" data-kb-row=""> |
| 353 | + <summary class="line"> |
| 354 | + <span class="name"> |
| 355 | + (version.as_str()) |
| 356 | + if *yanked { |
| 357 | + " " <span class="badge">(pk::t(lang, K::VersionYanked))</span> |
| 358 | + } |
| 359 | + </span> |
| 360 | + <span class="val">rel_time(lang: lang, stamp: date.as_str())</span> |
| 361 | + </summary> |
| 362 | + <div class="opened"> |
| 363 | + <code class="hint">(checksum.as_str())</code> |
| 364 | + </div> |
| 365 | + </details> |
| 367 | 366 | } |
| 368 | | - </ul> |
| 367 | + </div> |
| 369 | 368 | } else { |
| 370 | 369 | empty_state(title: pk::t(lang, K::NoVersions)) |
| 371 | 370 | } |
| 372 | 371 | } else { |
| 373 | 372 | if has_readme { |
| 374 | | - <section class="markdown-body package-readme">(Unescaped::new_unchecked(readme_html))</section> |
| 373 | + <section class="sec"> |
| 374 | + <div class="markdown-body package-readme">(Unescaped::new_unchecked(readme_html))</div> |
| 375 | + </section> |
| 375 | 376 | } else { |
| 376 | | - <p class="muted">(no_readme)</p> |
| 377 | + <p class="state">(no_readme)</p> |
| 377 | 378 | } |
| 378 | 379 | } |
| 379 | | - </article> |
| 380 | + </div> |
| 380 | 381 | }) |
| 381 | 382 | } |
| 382 | 383 | |
| | @@ -446,17 +447,16 @@ pub async fn repo_package_links( |
| 446 | 447 | pub async fn repo_packages_card(links: Vec<PackageLink>, lang: Lang) -> Result<impl View> { |
| 447 | 448 | let heading = pk::t(lang, K::TabPackages); |
| 448 | 449 | Ok(view! { |
| 449 | | - <section class="card repo-packages"> |
| 450 | | - <h3>(heading)</h3> |
| 451 | | - <ul class="item-list"> |
| 450 | + <section class="sec repo-packages"> |
| 451 | + <h2>(heading)</h2> |
| 452 | + <div> |
| 452 | 453 | for link in links.into_iter() { |
| 453 | | - <li> |
| 454 | | - <a href=(link.href.as_str())>(link.name.as_str())</a> |
| 455 | | - " " |
| 456 | | - <span class="muted small">(link.latest.as_str())</span> |
| 457 | | - </li> |
| 454 | + <a class="line" href=(link.href.as_str()) data-kb-row=""> |
| 455 | + <span class="name">(link.name.as_str())</span> |
| 456 | + <span class="val">(link.latest.as_str())</span> |
| 457 | + </a> |
| 458 | 458 | } |
| 459 | | - </ul> |
| 459 | + </div> |
| 460 | 460 | </section> |
| 461 | 461 | }) |
| 462 | 462 | } |
| | @@ -11,6 +11,7 @@ use crate::i18n::Lang; |
| 11 | 11 | use crate::i18n::packages::{self as pk, K}; |
| 12 | 12 | use crate::package_ops; |
| 13 | 13 | use crate::state::AppState; |
| 14 | +use crate::views::parts::confirm_act; |
| 14 | 15 | use crate::views::{empty_state, enc, human_size, rel_time}; |
| 15 | 16 | |
| 16 | 17 | /// What the container package page shows, prepared by the handler. |
| | @@ -110,86 +111,60 @@ pub async fn oci_package_view(page: OciPage) -> Result<impl View> { |
| 110 | 111 | }) |
| 111 | 112 | .collect(); |
| 112 | 113 | Ok(view! { |
| 113 | | - <article class="package-page" data-live=(events.as_str())> |
| 114 | | - <header class="package-head"> |
| 115 | | - <div> |
| 116 | | - <p class="muted small">(owner_name.as_str()) " / " (pk::t(lang, K::ContainerKind))</p> |
| 117 | | - <h1>(package.name.as_str()) " " <span class="muted">(newest_tag.as_str())</span></h1> |
| 118 | | - if private { |
| 119 | | - <span class="badge">(pk::t(lang, K::PackagePrivate))</span> |
| 120 | | - } |
| 121 | | - </div> |
| 122 | | - </header> |
| 123 | | - <section class="package-install"> |
| 114 | + <div data-live=(events.as_str())> |
| 115 | + <h1 class="h1">(package.name.as_str()) " " <span class="muted">(newest_tag.as_str())</span></h1> |
| 116 | + <p class="hint">(owner_name.as_str()) " / " (pk::t(lang, K::ContainerKind))</p> |
| 117 | + if private { |
| 118 | + <p class="hint"><span class="badge">(pk::t(lang, K::PackagePrivate))</span></p> |
| 119 | + } |
| 120 | + <section class="sec"> |
| 124 | 121 | <h2>(pk::t(lang, K::Install))</h2> |
| 125 | | - <p class="muted small">(pk::t(lang, K::ContainerInstallHelp))</p> |
| 126 | | - <p class="small">(pk::t(lang, K::ContainerLogin))</p> |
| 122 | + <p class="hint">(pk::t(lang, K::ContainerInstallHelp))</p> |
| 123 | + <p class="state">(pk::t(lang, K::ContainerLogin))</p> |
| 127 | 124 | <div class="copy-box"> |
| 128 | 125 | <code id="oci-login">(login.as_str())</code> |
| 129 | 126 | <button type="button" data-copy="oci-login">(copy_label)</button> |
| 130 | 127 | </div> |
| 131 | 128 | if has_tags { |
| 132 | | - <p class="small">(pk::t(lang, K::ContainerPull))</p> |
| 129 | + <p class="state">(pk::t(lang, K::ContainerPull))</p> |
| 133 | 130 | <div class="copy-box"> |
| 134 | 131 | <code id="oci-pull">(pull.as_str())</code> |
| 135 | 132 | <button type="button" data-copy="oci-pull">(copy_label)</button> |
| 136 | 133 | </div> |
| 137 | 134 | } |
| 138 | | - <p class="small">(pk::t(lang, K::ContainerPush))</p> |
| 135 | + <p class="state">(pk::t(lang, K::ContainerPush))</p> |
| 139 | 136 | <div class="copy-box"> |
| 140 | 137 | <code id="oci-push">(push.as_str())</code> |
| 141 | 138 | <button type="button" data-copy="oci-push">(copy_label)</button> |
| 142 | 139 | </div> |
| 143 | 140 | </section> |
| 144 | | - <section class="package-tags"> |
| 141 | + <section class="sec"> |
| 145 | 142 | <h2>(pk::t(lang, K::ContainerTags)) " " <span class="tab-count">(tag_count.as_str())</span></h2> |
| 146 | 143 | if has_tags { |
| 147 | | - <div class="table-wrap"> |
| 148 | | - <table class="table container-tags"> |
| 149 | | - <thead> |
| 150 | | - <tr> |
| 151 | | - <th>(pk::t(lang, K::ContainerTag))</th> |
| 152 | | - <th>(pk::t(lang, K::ContainerDigest))</th> |
| 153 | | - <th>(pk::t(lang, K::ContainerSize))</th> |
| 154 | | - <th>(pk::t(lang, K::ContainerCreated))</th> |
| 144 | + <div> |
| 145 | + for (tag, short, full, size, created) in rows.iter() { |
| 146 | + <details class="row-open" data-kb-row=""> |
| 147 | + <summary class="line"> |
| 148 | + <span class="name"><code>(tag.as_str())</code></span> |
| 149 | + <span class="val"><code>(short.as_str())</code> " · " (size.as_str()) " · " rel_time(lang: lang, stamp: created.as_str())</span> |
| 150 | + </summary> |
| 151 | + <div class="opened"> |
| 152 | + <code class="hint">(full.as_str())</code> |
| 155 | 153 | if can_delete { |
| 156 | | - <th></th> |
| 154 | + <div class="acts"> |
| 155 | + confirm_act(lang: lang, label: pk::t(lang, K::DeleteTag), action: delete_action.as_str(), csrf: csrf.as_str(), |
| 156 | + fields: vec![("package".to_owned(), package.name.clone()), ("tag".to_owned(), tag.clone())], |
| 157 | + note: Some(pk::t(lang, K::DeleteTagMessage).to_owned())) |
| 158 | + </div> |
| 157 | 159 | } |
| 158 | | - </tr> |
| 159 | | - </thead> |
| 160 | | - <tbody> |
| 161 | | - for (tag, short, full, size, created) in rows.iter() { |
| 162 | | - <tr> |
| 163 | | - <td><code>(tag.as_str())</code></td> |
| 164 | | - <td><code class="small" title=(full.as_str())>(short.as_str())</code></td> |
| 165 | | - <td class="muted small">(size.as_str())</td> |
| 166 | | - <td class="muted small">rel_time(lang: lang, stamp: created.as_str())</td> |
| 167 | | - if can_delete { |
| 168 | | - <td> |
| 169 | | - <details class="confirm-inline"> |
| 170 | | - <summary class="button danger">(pk::t(lang, K::DeleteTag))</summary> |
| 171 | | - <div class="confirm-pop"> |
| 172 | | - <p>(pk::t(lang, K::DeleteTagMessage))</p> |
| 173 | | - <form method="post" action=(delete_action.as_str())> |
| 174 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 175 | | - <input type="hidden" name="package" value=(package.name.as_str())> |
| 176 | | - <input type="hidden" name="tag" value=(tag.as_str())> |
| 177 | | - <button type="submit" class="danger">(pk::t(lang, K::DeleteTagConfirm))</button> |
| 178 | | - <button type="button" data-close-details="">(pk::t(lang, K::Cancel))</button> |
| 179 | | - </form> |
| 180 | | - </div> |
| 181 | | - </details> |
| 182 | | - </td> |
| 183 | | - } |
| 184 | | - </tr> |
| 185 | | - } |
| 186 | | - </tbody> |
| 187 | | - </table> |
| 160 | + </div> |
| 161 | + </details> |
| 162 | + } |
| 188 | 163 | </div> |
| 189 | 164 | } else { |
| 190 | 165 | empty_state(title: pk::t(lang, K::NoTags)) |
| 191 | 166 | } |
| 192 | 167 | </section> |
| 193 | | - </article> |
| 168 | + </div> |
| 194 | 169 | }) |
| 195 | 170 | } |
| | @@ -186,6 +186,65 @@ const ADMIN_TERMS: &[(&str, &[&str])] = &[ |
| 186 | 186 | ), |
| 187 | 187 | ]; |
| 188 | 188 | |
| 189 | +/// Turkish words with no Turkish letter in them. Words with one (ş, ı, ğ and the rest) are told |
| 190 | +/// apart by that letter. |
| 191 | +const TURKISH_WORDS: &[&str] = &[ |
| 192 | + "Saat dilimi", |
| 193 | + "Resim", |
| 194 | + "Cihazlar", |
| 195 | + "Oturumlar", |
| 196 | + "Parola", |
| 197 | + "E-posta", |
| 198 | + "Tema", |
| 199 | + "Koyu", |
| 200 | + "Renk", |
| 201 | + "Dil", |
| 202 | + "Ses", |
| 203 | + "Hesaplar", |
| 204 | + "Durum", |
| 205 | + "Ayarlar", |
| 206 | + "Bildirim", |
| 207 | + "Kurallar", |
| 208 | + "Yedek sunucu", |
| 209 | + "Geri yükle", |
| 210 | + "Davet et", |
| 211 | + "Vurgu rengi", |
| 212 | + "Arka plan", |
| 213 | + "Kurtarma kodları", |
| 214 | + "Verilerimi indir", |
| 215 | + "Depoyu sil", |
| 216 | + "Organizasyonu sil", |
| 217 | + "Sil", |
| 218 | + "Gönderen", |
| 219 | +]; |
| 220 | + |
| 221 | +/// Whether a term reads in `lang`. Acronyms and symbols such as 2FA or SSH read the same in both. |
| 222 | +fn term_in_lang(term: &str, lang: Lang) -> bool { |
| 223 | + if !term.chars().any(char::is_lowercase) { |
| 224 | + return true; |
| 225 | + } |
| 226 | + let turkish = term.chars().any(|c| "çğıöşüÇĞİÖŞÜ".contains(c)) |
| 227 | + || TURKISH_WORDS.iter().any(|word| word.eq_ignore_ascii_case(term)); |
| 228 | + turkish == matches!(lang, Lang::Tr) |
| 229 | +} |
| 230 | + |
| 231 | +/// Marks the terms that read in the viewer's language as `shownTerms`. Only those may show as the |
| 232 | +/// reason a row was listed. Every term still matches. |
| 233 | +fn mark_shown(items: &mut [Value], lang: Lang) { |
| 234 | + for item in items { |
| 235 | + let shown: Vec<Value> = item["terms"] |
| 236 | + .as_array() |
| 237 | + .into_iter() |
| 238 | + .flatten() |
| 239 | + .filter(|term| term.as_str().is_some_and(|term| term_in_lang(term, lang))) |
| 240 | + .cloned() |
| 241 | + .collect(); |
| 242 | + if !shown.is_empty() { |
| 243 | + item["shownTerms"] = json!(shown); |
| 244 | + } |
| 245 | + } |
| 246 | +} |
| 247 | + |
| 189 | 248 | /// One destination: its label, its path, what it is (`repo`, `org` or `page`) and its other words. |
| 190 | 249 | fn destination(label: &str, href: &str, kind: &str, terms: &[&str]) -> Value { |
| 191 | 250 | let mut item = json!({ "label": label, "href": href, "kind": kind }); |
| | @@ -415,7 +474,10 @@ async fn palette(cx: &Cx) -> Result<Response> { |
| 415 | 474 | } |
| 416 | 475 | |
| 417 | 476 | let scan_key = format!("{}:{lang:?}:{}", user.id, forge_ci::build::display()); |
| 418 | | - let body = json!({ "items": items, "repoPages": repo_pages(lang), "scanKey": scan_key }); |
| 477 | + mark_shown(&mut items, lang); |
| 478 | + let mut repo = repo_pages(lang); |
| 479 | + mark_shown(&mut repo, lang); |
| 480 | + let body = json!({ "items": items, "repoPages": repo, "scanKey": scan_key }); |
| 419 | 481 | let mut response = Response::new(Body::from(body.to_string().into_bytes())); |
| 420 | 482 | let headers = response.headers_mut(); |
| 421 | 483 | headers.insert( |
| | @@ -43,6 +43,7 @@ use crate::mail::account::{PasskeyChange, send_passkey_notice}; |
| 43 | 43 | use crate::state::AppState; |
| 44 | 44 | use crate::throttle::{self, LOGIN_IP_LIMIT}; |
| 45 | 45 | use crate::views::added_status; |
| 46 | +use crate::views::parts::{confirm_act, reveal}; |
| 46 | 47 | |
| 47 | 48 | /// How long a started ceremony stays valid. |
| 48 | 49 | const CEREMONY_TTL: Duration = Duration::from_secs(5 * 60); |
| | @@ -646,85 +647,80 @@ pub async fn build_panel(state: &AppState, user_id: &str) -> forge_core::Result< |
| 646 | 647 | }) |
| 647 | 648 | } |
| 648 | 649 | |
| 649 | | -/// The Passkeys block of the security page: the list, rename and delete, and the add form that |
| 650 | +/// The Passkeys topic of the security page: the list, rename and delete, and the add form that |
| 650 | 651 | /// `nav.js` drives. The add form stays hidden until the browser proves it supports passkeys. |
| 651 | 652 | #[component] |
| 652 | 653 | pub async fn passkeys_panel(lang: Lang, csrf: &str, panel: PasskeyPanel) -> Result<impl View> { |
| 653 | 654 | let PasskeyPanel { items, problem } = panel; |
| 654 | | - let count = items.len(); |
| 655 | | - let pill_class = if count > 0 { |
| 656 | | - "security-pill on" |
| 657 | | - } else { |
| 658 | | - "security-pill off" |
| 659 | | - }; |
| 660 | | - let pill_text = count.to_string(); |
| 655 | + let empty = items.is_empty(); |
| 656 | + let count_text = format!("{} {}", items.len(), s(lang, "passkeys", "geçiş anahtarı")); |
| 661 | 657 | let usable = problem.is_none(); |
| 662 | 658 | let problem_text = problem.map(|why| why.message(lang)); |
| 659 | + let rows: Vec<(PasskeyItem, String, String, String)> = items |
| 660 | + .into_iter() |
| 661 | + .map(|item| { |
| 662 | + let rename_action = format!("/settings/security/passkeys/{}/rename", item.id); |
| 663 | + let delete_action = format!("/settings/security/passkeys/{}/delete", item.id); |
| 664 | + let field = format!("passkey-name-{}", item.id); |
| 665 | + (item, rename_action, delete_action, field) |
| 666 | + }) |
| 667 | + .collect(); |
| 663 | 668 | Ok(view! { |
| 664 | | - <div class="rows-block" data-passkeys=""> |
| 665 | | - <div class="row-line"> |
| 666 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="9" cy="8" r="4"/><path d="M2 21v-1a6 6 0 0 1 6-6h2"/><circle cx="18" cy="14" r="2.5"/><path d="M18 16.5V22M18 19h2"/></svg> |
| 667 | | - <div class="row-main"> |
| 668 | | - <h2 class="row-title"> |
| 669 | | - <span>(s(lang, "Passkeys", "Geçiş anahtarları"))</span> |
| 670 | | - <span class=(pill_class)>(pill_text.as_str())</span> |
| 671 | | - </h2> |
| 672 | | - if let Some(text) = problem_text { |
| 673 | | - <p class="row-status warn">(text)</p> |
| 674 | | - } else { |
| 675 | | - <p class="row-status">(s(lang, "Sign in with your fingerprint, face or device PIN. A passkey counts as two factors, so it skips the code step.", "Parmak izi, yüz veya cihaz PIN'inizle giriş yapın. Geçiş anahtarı iki doğrulama sayılır, bu yüzden kod adımı atlanır."))</p> |
| 676 | | - } |
| 677 | | - </div> |
| 678 | | - </div> |
| 679 | | - if !items.is_empty() { |
| 680 | | - <ul class="security-devices"> |
| 681 | | - for item in items.into_iter() { |
| 682 | | - <li class="row-line security-device"> |
| 683 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="9" cy="8" r="4"/><path d="M2 21v-1a6 6 0 0 1 6-6h2"/><circle cx="18" cy="14" r="2.5"/></svg> |
| 684 | | - <div class="row-main"> |
| 685 | | - <p class="row-title">(item.name.as_str())</p> |
| 686 | | - <p class="row-status">added_status(lang: lang, added: Some(item.created_at.as_str()), used: item.last_used_at.as_deref())</p> |
| 687 | | - </div> |
| 688 | | - <details class="row-action"> |
| 689 | | - <summary>(s(lang, "Rename", "Yeniden adlandır"))</summary> |
| 690 | | - <div class="row-panel"> |
| 691 | | - <form method="post" action=(format!("/settings/security/passkeys/{}/rename", item.id)) class="stack"> |
| 692 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 693 | | - <label> |
| 694 | | - <span>(s(lang, "Name", "Ad"))</span> |
| 695 | | - <input type="text" name="name" value=(item.name.as_str()) maxlength="40" autocomplete="off" required=(true)> |
| 696 | | - </label> |
| 697 | | - <button type="submit" class="primary">(t(lang, Key::Save))</button> |
| 698 | | - </form> |
| 699 | | - </div> |
| 700 | | - </details> |
| 701 | | - <details class="confirm-inline"> |
| 702 | | - <summary class="button danger">(t(lang, Key::Delete))</summary> |
| 703 | | - <div class="confirm-pop"> |
| 704 | | - <p>(s(lang, "Delete this passkey? You can no longer sign in with it.", "Bu geçiş anahtarı silinsin mi? Artık onunla giriş yapamazsınız."))</p> |
| 705 | | - <form method="post" action=(format!("/settings/security/passkeys/{}/delete", item.id))> |
| 706 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 707 | | - <button type="submit" class="danger">(t(lang, Key::Delete))</button> |
| 708 | | - <button type="button" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> |
| 709 | | - </form> |
| 669 | + <section class="sec" id="passkeys" data-passkeys=""> |
| 670 | + <h2>(s(lang, "Passkeys", "Geçiş anahtarları"))</h2> |
| 671 | + if empty { |
| 672 | + <p class="state">(s(lang, "None", "Yok"))</p> |
| 673 | + } else { |
| 674 | + <p class="state">(count_text.as_str())</p> |
| 675 | + } |
| 676 | + if let Some(text) = problem_text { |
| 677 | + <p class="hint topic-warn">(text)</p> |
| 678 | + } else { |
| 679 | + <p class="hint">(s(lang, "Sign in with your fingerprint, face or device PIN. A passkey counts as two factors, so it skips the code step.", "Parmak izi, yüz veya cihaz PIN'inizle giriş yapın. Geçiş anahtarı iki doğrulama sayılır, bu yüzden kod adımı atlanır."))</p> |
| 680 | + } |
| 681 | + if !empty { |
| 682 | + <div> |
| 683 | + for (item, rename_action, delete_action, field) in rows.into_iter() { |
| 684 | + <details class="row-open"> |
| 685 | + <summary class="line"> |
| 686 | + <span class="name">(item.name.as_str())</span> |
| 687 | + <span class="val">added_status(lang: lang, added: Some(item.created_at.as_str()), used: item.last_used_at.as_deref())</span> |
| 688 | + </summary> |
| 689 | + <div class="opened"> |
| 690 | + <div class="acts"> |
| 691 | + reveal(label: s(lang, "Rename", "Yeniden adlandır"), |
| 692 | + <form method="post" action=(rename_action.as_str()) class="fields"> |
| 693 | + <input type="hidden" name="csrf" value=(csrf)> |
| 694 | + <div class="field"> |
| 695 | + <label for=(field.as_str())>(s(lang, "Name", "Ad"))</label> |
| 696 | + <input id=(field.as_str()) type="text" name="name" value=(item.name.as_str()) maxlength="40" autocomplete="off" required=(true)> |
| 697 | + </div> |
| 698 | + <button type="submit" class="primary">(t(lang, Key::Save))</button> |
| 699 | + </form> |
| 700 | + ) |
| 701 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: delete_action.as_str(), csrf: csrf, note: Some(s(lang, "Delete this passkey? You can no longer sign in with it.", "Bu geçiş anahtarı silinsin mi? Artık onunla giriş yapamazsınız.").to_owned())) |
| 710 | 702 | </div> |
| 711 | | - </details> |
| 712 | | - </li> |
| 703 | + </div> |
| 704 | + </details> |
| 713 | 705 | } |
| 714 | | - </ul> |
| 706 | + </div> |
| 715 | 707 | } |
| 716 | 708 | if usable { |
| 717 | | - <form data-hard="true" data-passkey-add="" hidden=(true) class="row-panel passkey-add stack" action="/settings/security" method="get"> |
| 718 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 719 | | - <label> |
| 720 | | - <span>(s(lang, "Name for the new passkey", "Yeni geçiş anahtarının adı"))</span> |
| 721 | | - <input type="text" name="name" maxlength="40" autocomplete="off" placeholder=(s(lang, "Laptop", "Dizüstü")) required=(true)> |
| 722 | | - </label> |
| 723 | | - <button type="submit" class="primary">(s(lang, "Add a passkey", "Geçiş anahtarı ekle"))</button> |
| 724 | | - <p class="passkey-error" role="alert" hidden=(true)></p> |
| 725 | | - </form> |
| 709 | + <div class="acts"> |
| 710 | + reveal(label: s(lang, "Add a passkey", "Geçiş anahtarı ekle"), |
| 711 | + <form data-hard="true" data-passkey-add="" hidden=(true) action="/settings/security" method="get" class="fields"> |
| 712 | + <input type="hidden" name="csrf" value=(csrf)> |
| 713 | + <div class="field"> |
| 714 | + <label for="passkey-new-name">(s(lang, "Name for the new passkey", "Yeni geçiş anahtarının adı"))</label> |
| 715 | + <input id="passkey-new-name" type="text" name="name" maxlength="40" autocomplete="off" placeholder=(s(lang, "Laptop", "Dizüstü")) required=(true)> |
| 716 | + </div> |
| 717 | + <button type="submit" class="primary">(s(lang, "Add a passkey", "Geçiş anahtarı ekle"))</button> |
| 718 | + <p class="passkey-error" role="alert" hidden=(true)></p> |
| 719 | + </form> |
| 720 | + ) |
| 721 | + </div> |
| 726 | 722 | } |
| 727 | | - </div> |
| 723 | + </section> |
| 728 | 724 | }) |
| 729 | 725 | } |
| 730 | 726 | |
| | @@ -734,7 +730,7 @@ pub async fn passkeys_panel(lang: Lang, csrf: &str, panel: PasskeyPanel) -> Resu |
| 734 | 730 | pub async fn login_passkey(lang: Lang) -> Result<impl View> { |
| 735 | 731 | Ok(view! { |
| 736 | 732 | <div class="passkey-login" data-passkey-login="" hidden=(true)> |
| 737 | | - <p class="passkey-or muted small">(s(lang, "or", "veya"))</p> |
| 733 | + <p class="passkey-or hint">(s(lang, "or", "veya"))</p> |
| 738 | 734 | <button type="button" class="passkey-button" data-passkey-signin="">(s(lang, "Sign in with a passkey", "Geçiş anahtarıyla giriş yap"))</button> |
| 739 | 735 | <p class="passkey-error" role="alert" hidden=(true)></p> |
| 740 | 736 | </div> |
| | @@ -583,7 +583,13 @@ async fn passkey_pages_show_the_ui_and_admins_remove_all_passkeys() { |
| 583 | 583 | .await; |
| 584 | 584 | assert!(page.body.contains("data-passkey-add")); |
| 585 | 585 | assert!(page.body.contains("Laptop")); |
| 586 | | - assert!(page.body.contains("confirm-inline")); |
| 586 | + let passkeys = fx.store.list_passkeys(&fx.owner_id).await.unwrap(); |
| 587 | + let delete_action = format!( |
| 588 | + "action=\"/settings/security/passkeys/{}/delete\"", |
| 589 | + passkeys[0].id |
| 590 | + ); |
| 591 | + assert!(page.body.contains(&delete_action)); |
| 592 | + assert!(page.body.contains("Delete this passkey?")); |
| 587 | 593 | let login = send(&fx.router, "GET", "/login", None, &[]).await; |
| 588 | 594 | assert!(login.body.contains("data-passkey-signin")); |
| 589 | 595 | assert!(login.body.contains("autocomplete=\"username webauthn\"")); |
| | @@ -592,7 +598,8 @@ async fn passkey_pages_show_the_ui_and_admins_remove_all_passkeys() { |
| 592 | 598 | let detail = format!("/admin/users/{}", fx.owner_id); |
| 593 | 599 | let page = send(&fx.router, "GET", &detail, session_cookie(ADMIN_TOKEN), &[]).await; |
| 594 | 600 | assert_eq!(page.status, 200); |
| 595 | | - assert!(page.body.contains("Remove all passkeys")); |
| 601 | + assert!(page.body.contains("Remove every passkey of this user?")); |
| 602 | + assert!(page.body.contains(&format!("action=\"{detail}/remove-passkeys\""))); |
| 596 | 603 | |
| 597 | 604 | let uri = format!("{detail}/remove-passkeys"); |
| 598 | 605 | let denied = send( |
| | @@ -40,7 +40,7 @@ use crate::views::repo_list::{ |
| 40 | 40 | PageLink, RepoRow, SortLink, badge_class, pager, pager_links, repo_rows, sort_chips, |
| 41 | 41 | }; |
| 42 | 42 | use crate::views::{ |
| 43 | | - NavItem, avatar_url, empty_state, enc, now_unix, profile_items, repo_href, shell, user_href, |
| 43 | + NavItem, avatar_url, enc, now_unix, profile_items, repo_href, shell, user_href, |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | path_param!(username); |
| | @@ -520,10 +520,6 @@ fn profile_href(name: &str, tab: &str, q: &str, sort: &str, page: u64) -> String |
| 520 | 520 | href |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | | -fn tab_class(on: bool) -> &'static str { |
| 524 | | - if on { "tab active" } else { "tab" } |
| 525 | | -} |
| 526 | | - |
| 527 | 523 | /// Whether the viewer may read `repo`. Public repos, and repos the viewer owns or administers, |
| 528 | 524 | /// need no role lookup. Other private repos get their collaborator and org roles, and `authorize` |
| 529 | 525 | /// makes the final call either way. |
| | @@ -619,11 +615,6 @@ async fn profile_card( |
| 619 | 615 | ]; |
| 620 | 616 | let base = format!("/{}", enc(&user.username)); |
| 621 | 617 | let overview_on = tab == "overview"; |
| 622 | | - let overview_class = if is_org { |
| 623 | | - "org-overview" |
| 624 | | - } else { |
| 625 | | - "profile-overview" |
| 626 | | - }; |
| 627 | 618 | let repos_on = tab == "repositories"; |
| 628 | 619 | let stars_on = tab == "stars"; |
| 629 | 620 | let list_on = repos_on || stars_on; |
| | @@ -655,31 +646,35 @@ async fn profile_card( |
| 655 | 646 | let new_repo_href = format!("/new?owner={}", enc(&user.username)); |
| 656 | 647 | let settings_href = format!("/org/{}/settings", enc(&user.username)); |
| 657 | 648 | let members_href = format!("/org/{}/members", enc(&user.username)); |
| 649 | + let has_acts = edit_profile || (is_org && (org_owner || org_can_create)); |
| 650 | + let members_more = org |
| 651 | + .as_ref() |
| 652 | + .is_some_and(|summary| org_member && summary.total > summary.members.len()); |
| 658 | 653 | Ok(view! { |
| 659 | 654 | <article class="profile-page" data-live=(format!("/users/{}/events", user.username))> |
| 660 | 655 | <header class="profile-head"> |
| 661 | 656 | <img class=(avatar_class) src=(src) alt="" width=(avatar_px) height=(avatar_px)> |
| 662 | 657 | <div class="profile-id"> |
| 663 | | - <h1>(heading)</h1> |
| 658 | + <h1 class="h1">(heading)</h1> |
| 664 | 659 | if has_name { |
| 665 | | - <p class="muted">(user.username.as_str())</p> |
| 660 | + <p class="hint">(user.username.as_str())</p> |
| 666 | 661 | } |
| 667 | 662 | if is_org { |
| 668 | | - <p class="muted small">(g::t(lang, K::Organization))</p> |
| 663 | + <p class="hint">(g::t(lang, K::Organization))</p> |
| 669 | 664 | } |
| 670 | 665 | if !is_org { |
| 671 | | - <p class="muted">(g::t(lang, K::LocalTime)) (local_time.as_str())</p> |
| 672 | | - } |
| 673 | | - if edit_profile { |
| 674 | | - <a class="button profile-edit" href="/settings/profile">(edit_label)</a> |
| 666 | + <p class="hint">(g::t(lang, K::LocalTime)) (local_time.as_str())</p> |
| 675 | 667 | } |
| 676 | | - if is_org && (org_owner || org_can_create) { |
| 677 | | - <div class="profile-org-actions"> |
| 668 | + if has_acts { |
| 669 | + <div class="acts"> |
| 670 | + if edit_profile { |
| 671 | + <a class="act" href="/settings/profile">(edit_label)</a> |
| 672 | + } |
| 678 | 673 | if org_owner { |
| 679 | | - <a class="button profile-edit" href=(settings_href.as_str())>(org_edit_label)</a> |
| 674 | + <a class="act" href=(settings_href.as_str())>(org_edit_label)</a> |
| 680 | 675 | } |
| 681 | 676 | if org_can_create { |
| 682 | | - <a class="button primary" href=(new_repo_href.as_str())>(g::t(lang, K::NewRepository))</a> |
| 677 | + <a class="act" href=(new_repo_href.as_str())>(g::t(lang, K::NewRepository))</a> |
| 683 | 678 | } |
| 684 | 679 | </div> |
| 685 | 680 | } |
| | @@ -694,9 +689,8 @@ async fn profile_card( |
| 694 | 689 | contribution_calendar(calendar: calendar, selected: selected, lang: lang, base: base.clone(), |
| 695 | 690 | live: Some(format!("/users/{}/events", user.username))) |
| 696 | 691 | } |
| 697 | | - <div class=(overview_class)> |
| 698 | | - <section class="profile-pinned"> |
| 699 | | - <div class="profile-section-head"> |
| 692 | + <section class="sec profile-pinned"> |
| 693 | + <div class="topic-head"> |
| 700 | 694 | <h2>(pinned_heading)</h2> |
| 701 | 695 | if let Some(menu) = pins_menu_data { |
| 702 | 696 | pins_menu(lang: lang, action: menu.action, csrf: menu.csrf, options: menu.options) |
| | @@ -706,37 +700,28 @@ async fn profile_card( |
| 706 | 700 | <p class="alert" role="alert">(g::t(lang, K::PinsTooMany))</p> |
| 707 | 701 | } |
| 708 | 702 | if has_cards { |
| 709 | | - <ul class="pin-grid"> |
| 703 | + <ul class="repo-list"> |
| 710 | 704 | for card in cards.into_iter() { |
| 711 | | - <li class="pin-card"> |
| 712 | | - <div class="pin-head"> |
| 713 | | - <a class="repo-name" href=(repo_href(&card.repo.owner_name, &card.repo.name, "", ""))> |
| 714 | | - (format!("{}/{}", card.repo.owner_name, card.repo.name)) |
| 715 | | - </a> |
| 716 | | - <span class=(badge_class(card.repo.visibility))>(i18n::visibility_label(lang, card.repo.visibility))</span> |
| 717 | | - </div> |
| 705 | + <li class="line repo-item" data-kb-row=""> |
| 706 | + <a class="name repo-name" href=(repo_href(&card.repo.owner_name, &card.repo.name, "", ""))>(format!("{}/{}", card.repo.owner_name, card.repo.name))</a> |
| 707 | + <span class=(badge_class(card.repo.visibility))>(i18n::visibility_label(lang, card.repo.visibility))</span> |
| 718 | 708 | if !card.repo.description.is_empty() { |
| 719 | | - <p class="muted pin-desc">(card.repo.description.as_str())</p> |
| 709 | + <span class="val" title=(card.repo.description.as_str())>(card.repo.description.as_str())</span> |
| 720 | 710 | } |
| 721 | | - <p class="muted small">"\u{2605} " (card.stars.to_string())</p> |
| 711 | + <span class="val">"\u{2605} " (card.stars.to_string())</span> |
| 722 | 712 | </li> |
| 723 | 713 | } |
| 724 | 714 | </ul> |
| 725 | 715 | } else { |
| 726 | | - empty_state(title: g::t(lang, K::NoVisibleRepos)) |
| 716 | + <p class="state">(g::t(lang, K::NoVisibleRepos))</p> |
| 727 | 717 | } |
| 728 | 718 | </section> |
| 729 | 719 | if let Some(summary) = org { |
| 730 | | - <section class="card profile-org"> |
| 731 | | - <div class="profile-section-head"> |
| 732 | | - <h2>(g::t(lang, K::Members))</h2> |
| 733 | | - if org_member && summary.total > summary.members.len() { |
| 734 | | - <a class="small" href=(members_href.as_str())>(g::t(lang, K::ViewAllMembers))</a> |
| 735 | | - } |
| 736 | | - </div> |
| 737 | | - <p class="muted small">(g::members_and_teams(lang, summary.total, summary.teams))</p> |
| 720 | + <section class="sec profile-org"> |
| 721 | + <h2>(g::t(lang, K::Members))</h2> |
| 722 | + <p class="hint">(g::members_and_teams(lang, summary.total, summary.teams))</p> |
| 738 | 723 | if summary.members.is_empty() { |
| 739 | | - empty_state(title: g::t(lang, K::NoMembers)) |
| 724 | + <p class="state">(g::t(lang, K::NoMembers))</p> |
| 740 | 725 | } else { |
| 741 | 726 | <ul class="org-members"> |
| 742 | 727 | for member in summary.members.into_iter() { |
| | @@ -749,108 +734,104 @@ async fn profile_card( |
| 749 | 734 | } |
| 750 | 735 | </ul> |
| 751 | 736 | } |
| 737 | + if members_more { |
| 738 | + <div class="acts"> |
| 739 | + <a class="act" href=(members_href.as_str())>(g::t(lang, K::ViewAllMembers))</a> |
| 740 | + </div> |
| 741 | + } |
| 752 | 742 | </section> |
| 753 | 743 | } |
| 754 | | - </div> |
| 755 | 744 | } |
| 756 | 745 | if list_on { |
| 757 | 746 | <section class="repo-listing"> |
| 758 | | - <div class="repo-tools"> |
| 759 | | - <form method="get" action=(base.as_str()) class="explore-search" role="search"> |
| 760 | | - <input type="hidden" name="tab" value=(tab.as_str())> |
| 761 | | - <input type="hidden" name="sort" value=(sort)> |
| 762 | | - <input type="search" name="q" value=(q.as_str()) data-live-search="" |
| 763 | | - placeholder=(filter_label) aria-label=(filter_label)> |
| 764 | | - <button type="submit">(g::t(lang, K::Search))</button> |
| 765 | | - </form> |
| 766 | | - if own_profile && repos_on { |
| 767 | | - <a class="button primary" href="/new">(g::t(lang, K::NewRepository))</a> |
| 768 | | - } |
| 769 | | - </div> |
| 770 | | - <div class="repo-subbar"> |
| 771 | | - sort_chips(links: sort_links, lang: lang) |
| 772 | | - <p class="muted small repo-count">(count_text.as_str())</p> |
| 773 | | - </div> |
| 747 | + <form method="get" action=(base.as_str()) class="plain-search" role="search"> |
| 748 | + <input type="hidden" name="tab" value=(tab.as_str())> |
| 749 | + <input type="hidden" name="sort" value=(sort)> |
| 750 | + <input type="search" name="q" value=(q.as_str()) data-live-search="" |
| 751 | + placeholder=(filter_label) aria-label=(filter_label)> |
| 752 | + <button type="submit" class="act">(g::t(lang, K::Search))</button> |
| 753 | + </form> |
| 754 | + sort_chips(links: sort_links, lang: lang) |
| 755 | + <p class="hint repo-count">(count_text.as_str())</p> |
| 774 | 756 | if has_rows { |
| 775 | 757 | repo_rows(rows: rows, lang: lang) |
| 776 | 758 | } else { |
| 777 | | - empty_state(title: empty) |
| 759 | + <p class="state">(empty)</p> |
| 760 | + } |
| 761 | + if own_profile && repos_on { |
| 762 | + <div class="acts"> |
| 763 | + <a class="act" href="/new">(g::t(lang, K::NewRepository))</a> |
| 764 | + </div> |
| 778 | 765 | } |
| 779 | 766 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 780 | 767 | </section> |
| 781 | 768 | } |
| 782 | 769 | if packages_on { |
| 783 | | - <section class="package-listing" data-live=(packages_events.as_str())> |
| 784 | | - <div class="profile-section-head"> |
| 785 | | - <h2>(pk::t(lang, PK::PackagesHeading))</h2> |
| 786 | | - </div> |
| 787 | | - <p class="muted small">(pk::t(lang, PK::PackagesHelp))</p> |
| 770 | + <section class="sec package-listing" data-live=(packages_events.as_str())> |
| 771 | + <h2>(pk::t(lang, PK::PackagesHeading))</h2> |
| 772 | + <p class="hint">(pk::t(lang, PK::PackagesHelp))</p> |
| 788 | 773 | if has_packages { |
| 789 | | - <ul class="item-list"> |
| 774 | + <div class="plain-rows"> |
| 790 | 775 | for row in package_rows.into_iter() { |
| 791 | | - <li> |
| 792 | | - <a class="repo-name" href=(row.href.as_str())>(row.name.as_str())</a> |
| 793 | | - " " |
| 776 | + <div class="line" data-kb-row=""> |
| 777 | + <a class="name" href=(row.href.as_str())>(row.name.as_str())</a> |
| 794 | 778 | if row.container { |
| 795 | 779 | <span class="badge">(pk::t(lang, PK::ContainerKind))</span> |
| 796 | | - " " |
| 797 | 780 | } |
| 798 | | - <span class="muted small">(row.latest.as_str())</span> |
| 799 | | - " " |
| 800 | | - <span class="muted small">(row.versions.to_string()) " " (pk::t(lang, match (row.container, row.versions == 1) { (true, true) => PK::PackageTagCountOne, (true, false) => PK::PackageTagCount, (false, true) => PK::PackageVersionCountOne, (false, false) => PK::PackageVersionCount }))</span> |
| 781 | + <span class="val">(row.latest.as_str())</span> |
| 782 | + <span class="val">(row.versions.to_string()) " " (pk::t(lang, match (row.container, row.versions == 1) { (true, true) => PK::PackageTagCountOne, (true, false) => PK::PackageTagCount, (false, true) => PK::PackageVersionCountOne, (false, false) => PK::PackageVersionCount }))</span> |
| 801 | 783 | if row.private { |
| 802 | | - " " |
| 803 | 784 | <span class="badge">(pk::t(lang, PK::PackagePrivate))</span> |
| 804 | 785 | } |
| 805 | 786 | if !row.description.is_empty() { |
| 806 | | - <p class="muted small">(row.description.as_str())</p> |
| 787 | + <span class="val">(row.description.as_str())</span> |
| 807 | 788 | } |
| 808 | | - </li> |
| 789 | + </div> |
| 809 | 790 | } |
| 810 | | - </ul> |
| 791 | + </div> |
| 811 | 792 | } else { |
| 812 | | - <p class="muted">(pk::t(lang, PK::NoPackages))</p> |
| 793 | + <p class="state">(pk::t(lang, PK::NoPackages))</p> |
| 813 | 794 | } |
| 814 | 795 | </section> |
| 815 | 796 | } |
| 816 | 797 | if snippets_on { |
| 817 | | - <section class="snippet-listing"> |
| 818 | | - <div class="profile-section-head"> |
| 819 | | - <h2>(cm::t(lang, CK::Snippets))</h2> |
| 820 | | - if own_profile { |
| 821 | | - <a class="button primary" href="/snippets/new">(cm::t(lang, CK::NewSnippet))</a> |
| 822 | | - } |
| 823 | | - </div> |
| 798 | + <section class="sec snippet-listing"> |
| 799 | + <h2>(cm::t(lang, CK::Snippets))</h2> |
| 800 | + if own_profile { |
| 801 | + <div class="acts"> |
| 802 | + <a class="act" href="/snippets/new">(cm::t(lang, CK::NewSnippet))</a> |
| 803 | + </div> |
| 804 | + } |
| 824 | 805 | if has_snippets { |
| 825 | 806 | snippet_rows(lang: lang, rows: snippets) |
| 826 | 807 | } else { |
| 827 | | - empty_state(title: cm::t(lang, CK::NoSnippets)) |
| 808 | + <p class="state">(cm::t(lang, CK::NoSnippets))</p> |
| 828 | 809 | } |
| 829 | 810 | </section> |
| 830 | 811 | } |
| 831 | 812 | if orgs_on { |
| 832 | | - <section class="profile-orgs"> |
| 833 | | - <div class="profile-section-head"> |
| 834 | | - <h2>(g::t(lang, K::Organizations))</h2> |
| 835 | | - if org_create_allowed { |
| 836 | | - <a class="button primary" href="/org/new">(g::t(lang, K::NewOrganization))</a> |
| 837 | | - } |
| 838 | | - </div> |
| 813 | + <section class="sec profile-orgs"> |
| 814 | + <h2>(g::t(lang, K::Organizations))</h2> |
| 815 | + if org_create_allowed { |
| 816 | + <div class="acts"> |
| 817 | + <a class="act" href="/org/new">(g::t(lang, K::NewOrganization))</a> |
| 818 | + </div> |
| 819 | + } |
| 839 | 820 | if has_orgs { |
| 840 | | - <ul class="item-list org-rows"> |
| 821 | + <div class="plain-rows"> |
| 841 | 822 | for org in orgs.into_iter() { |
| 842 | | - <li> |
| 823 | + <div class="line" data-kb-row=""> |
| 843 | 824 | <img class="avatar avatar-sm" src=(org.avatar.as_str()) alt="" width="24" height="24"> |
| 844 | | - <a class="repo-name" href=(org.href.as_str())>(org.name.as_str())</a> |
| 825 | + <a class="name" href=(org.href.as_str())>(org.name.as_str())</a> |
| 845 | 826 | if !org.display_name.is_empty() { |
| 846 | | - <span class="muted small">(org.display_name.as_str())</span> |
| 827 | + <span class="val">(org.display_name.as_str())</span> |
| 847 | 828 | } |
| 848 | 829 | <span class="badge">(org.role)</span> |
| 849 | | - </li> |
| 830 | + </div> |
| 850 | 831 | } |
| 851 | | - </ul> |
| 832 | + </div> |
| 852 | 833 | } else { |
| 853 | | - empty_state(title: g::t(lang, K::NoOrganizations)) |
| 834 | + <p class="state">(g::t(lang, K::NoOrganizations))</p> |
| 854 | 835 | } |
| 855 | 836 | </section> |
| 856 | 837 | } |
| | @@ -868,7 +849,7 @@ pub async fn profile_tabs( |
| 868 | 849 | current: String, |
| 869 | 850 | counts: Vec<(&'static str, String)>, |
| 870 | 851 | ) -> Result<impl View> { |
| 871 | | - let rows: Vec<(String, String, &'static str, String, bool)> = items |
| 852 | + let rows: Vec<(String, String, bool, String, bool)> = items |
| 872 | 853 | .into_iter() |
| 873 | 854 | .map(|item| { |
| 874 | 855 | let on = item.key == current; |
| | @@ -880,21 +861,30 @@ pub async fn profile_tabs( |
| 880 | 861 | ( |
| 881 | 862 | item.href, |
| 882 | 863 | item.label.to_owned(), |
| 883 | | - tab_class(on), |
| 864 | + on, |
| 884 | 865 | count.unwrap_or_default(), |
| 885 | 866 | has_count, |
| 886 | 867 | ) |
| 887 | 868 | }) |
| 888 | 869 | .collect(); |
| 889 | 870 | Ok(view! { |
| 890 | | - <nav class="profile-tabs" aria-label=(username.as_str())> |
| 891 | | - for (href, label, class, count, has_count) in rows.into_iter() { |
| 892 | | - <a class=(class) href=(href.as_str())> |
| 893 | | - (label.as_str()) |
| 894 | | - if has_count { |
| 895 | | - " " <span class="tab-count">(count.as_str())</span> |
| 896 | | - } |
| 897 | | - </a> |
| 871 | + <nav class="tabs" aria-label=(username.as_str())> |
| 872 | + for (href, label, on, count, has_count) in rows.into_iter() { |
| 873 | + if on { |
| 874 | + <a href=(href.as_str()) aria-current="page"> |
| 875 | + (label.as_str()) |
| 876 | + if has_count { |
| 877 | + " " <span class="tab-count">(count.as_str())</span> |
| 878 | + } |
| 879 | + </a> |
| 880 | + } else { |
| 881 | + <a href=(href.as_str())> |
| 882 | + (label.as_str()) |
| 883 | + if has_count { |
| 884 | + " " <span class="tab-count">(count.as_str())</span> |
| 885 | + } |
| 886 | + </a> |
| 887 | + } |
| 898 | 888 | } |
| 899 | 889 | </nav> |
| 900 | 890 | }) |
| | @@ -1018,7 +1008,10 @@ mod tests { |
| 1018 | 1008 | !anon.contains("tahinli/shared-repo"), |
| 1019 | 1009 | "anonymous: shared repo" |
| 1020 | 1010 | ); |
| 1021 | | - assert!(!anon.contains("profile-edit"), "anonymous: edit button"); |
| 1011 | + assert!( |
| 1012 | + !anon.contains("class=\"act\" href=\"/settings/profile\""), |
| 1013 | + "anonymous: edit button" |
| 1014 | + ); |
| 1022 | 1015 | |
| 1023 | 1016 | // Another user sees the same public-only list and no edit button. |
| 1024 | 1017 | let bob = site |
| | @@ -1040,7 +1033,10 @@ mod tests { |
| 1040 | 1033 | !other.contains("tahinli/shared-repo"), |
| 1041 | 1034 | "other user: shared repo" |
| 1042 | 1035 | ); |
| 1043 | | - assert!(!other.contains("profile-edit"), "other user: edit button"); |
| 1036 | + assert!( |
| 1037 | + !other.contains("class=\"act\" href=\"/settings/profile\""), |
| 1038 | + "other user: edit button" |
| 1039 | + ); |
| 1044 | 1040 | |
| 1045 | 1041 | // The owner sees every repo and the edit button. |
| 1046 | 1042 | let tahinli = user_id(&site.store, "tahinli").await; |
| | @@ -1049,7 +1045,7 @@ mod tests { |
| 1049 | 1045 | assert!(owner.contains("tahinli/secret-repo"), "owner: private repo"); |
| 1050 | 1046 | assert!(owner.contains("tahinli/shared-repo"), "owner: shared repo"); |
| 1051 | 1047 | assert!( |
| 1052 | | - owner.contains("class=\"button profile-edit\" href=\"/settings/profile\""), |
| 1048 | + owner.contains("class=\"act\" href=\"/settings/profile\""), |
| 1053 | 1049 | "owner: edit button" |
| 1054 | 1050 | ); |
| 1055 | 1051 | |
| | @@ -1174,7 +1170,7 @@ mod tests { |
| 1174 | 1170 | ); |
| 1175 | 1171 | let (_, member_profile) = get(&site.router, "/forge-org", Some(&member_cookie)).await; |
| 1176 | 1172 | assert!( |
| 1177 | | - !member_profile.contains("profile-edit"), |
| 1173 | + !member_profile.contains("href=\"/org/forge-org/settings\""), |
| 1178 | 1174 | "org profile: member has no edit button" |
| 1179 | 1175 | ); |
| 1180 | 1176 | // Settings keeps a sidebar of its own pages, and its back link goes to the profile. |
| | @@ -1184,12 +1180,12 @@ mod tests { |
| 1184 | 1180 | "org settings: pins live on the profile" |
| 1185 | 1181 | ); |
| 1186 | 1182 | assert!( |
| 1187 | | - !settings.contains("href=\"/org/forge-org/members\""), |
| 1188 | | - "org settings: sidebar has no members link" |
| 1183 | + !settings.contains("class=\"side-links\""), |
| 1184 | + "org settings: no sidebar, so no members link beside the form" |
| 1189 | 1185 | ); |
| 1190 | 1186 | assert!( |
| 1191 | | - settings.contains("class=\"side-link\" href=\"/forge-org\""), |
| 1192 | | - "org settings: back link goes to the profile" |
| 1187 | + settings.contains("href=\"/forge-org?tab=overview\""), |
| 1188 | + "org settings: Overview tab goes to the profile" |
| 1193 | 1189 | ); |
| 1194 | 1190 | |
| 1195 | 1191 | // Org pins show on the org profile, with an edit link for owners only. |
| | @@ -1216,7 +1212,7 @@ mod tests { |
| 1216 | 1212 | "org pins: anonymous has no edit link" |
| 1217 | 1213 | ); |
| 1218 | 1214 | assert!( |
| 1219 | | - owner.contains("class=\"button profile-edit\" href=\"/org/acme/settings\"") |
| 1215 | + owner.contains("class=\"act\" href=\"/org/acme/settings\"") |
| 1220 | 1216 | && owner.contains("/new?owner=acme"), |
| 1221 | 1217 | "org profile: owner sees Edit organization and New repository" |
| 1222 | 1218 | ); |
| | @@ -1245,7 +1241,7 @@ mod tests { |
| 1245 | 1241 | let (_, anon) = get(&site.router, "/tahinli", None).await; |
| 1246 | 1242 | assert!(anon.contains("<h2>Pinned</h2>"), "pins: section shown"); |
| 1247 | 1243 | assert_eq!( |
| 1248 | | - count(&anon, "class=\"pin-card\""), |
| 1244 | + count(&anon, "class=\"line repo-item\""), |
| 1249 | 1245 | 1, |
| 1250 | 1246 | "pins: anonymous pin count" |
| 1251 | 1247 | ); |
| | @@ -1262,7 +1258,7 @@ mod tests { |
| 1262 | 1258 | let cookie = sign_in(&site.store, &tahinli, "pins-owner-token").await; |
| 1263 | 1259 | let (_, owner) = get(&site.router, "/tahinli", Some(&cookie)).await; |
| 1264 | 1260 | assert_eq!( |
| 1265 | | - count(&owner, "class=\"pin-card\""), |
| 1261 | + count(&owner, "class=\"line repo-item\""), |
| 1266 | 1262 | 2, |
| 1267 | 1263 | "pins: owner pin count" |
| 1268 | 1264 | ); |
| | @@ -1300,22 +1296,22 @@ mod tests { |
| 1300 | 1296 | let (status, body) = get(&site.router, "/tahinli", None).await; |
| 1301 | 1297 | assert_eq!(status, 200, "display name: page"); |
| 1302 | 1298 | assert!( |
| 1303 | | - body.contains("<h1>Ahmet Kaan Gümüş</h1>"), |
| 1299 | + body.contains("<h1 class=\"h1\">Ahmet Kaan Gümüş</h1>"), |
| 1304 | 1300 | "display name: heading {body}" |
| 1305 | 1301 | ); |
| 1306 | 1302 | assert!( |
| 1307 | | - body.contains("<p class=\"muted\">tahinli</p>"), |
| 1303 | + body.contains("<p class=\"hint\">tahinli</p>"), |
| 1308 | 1304 | "display name: username below {body}" |
| 1309 | 1305 | ); |
| 1310 | 1306 | |
| 1311 | 1307 | site.store.set_display_name(&tahinli, " ").await.unwrap(); |
| 1312 | 1308 | let (_, body) = get(&site.router, "/tahinli", None).await; |
| 1313 | 1309 | assert!( |
| 1314 | | - body.contains("<h1>tahinli</h1>"), |
| 1310 | + body.contains("<h1 class=\"h1\">tahinli</h1>"), |
| 1315 | 1311 | "blank name: heading {body}" |
| 1316 | 1312 | ); |
| 1317 | 1313 | assert!( |
| 1318 | | - !body.contains("<p class=\"muted\">tahinli</p>"), |
| 1314 | + !body.contains("<p class=\"hint\">tahinli</p>"), |
| 1319 | 1315 | "blank name: no username line {body}" |
| 1320 | 1316 | ); |
| 1321 | 1317 | } |
| | @@ -1384,7 +1380,7 @@ mod tests { |
| 1384 | 1380 | let (status, first) = get(&site.router, "/tahinli?tab=repositories&sort=name", None).await; |
| 1385 | 1381 | assert_eq!(status, 200, "paging: first page"); |
| 1386 | 1382 | assert_eq!( |
| 1387 | | - count(&first, "class=\"repo-name\""), |
| 1383 | + count(&first, "class=\"name repo-name\""), |
| 1388 | 1384 | 30, |
| 1389 | 1385 | "paging: first page size" |
| 1390 | 1386 | ); |
| | @@ -1397,7 +1393,7 @@ mod tests { |
| 1397 | 1393 | ) |
| 1398 | 1394 | .await; |
| 1399 | 1395 | assert_eq!( |
| 1400 | | - count(&second, "class=\"repo-name\""), |
| 1396 | + count(&second, "class=\"name repo-name\""), |
| 1401 | 1397 | 5, |
| 1402 | 1398 | "paging: second page size" |
| 1403 | 1399 | ); |
| | @@ -1413,7 +1409,7 @@ mod tests { |
| 1413 | 1409 | // The name filter is a case-insensitive substring match. |
| 1414 | 1410 | let (_, body) = get(&site.router, "/tahinli?tab=repositories&q=BULK-1", None).await; |
| 1415 | 1411 | assert_eq!( |
| 1416 | | - count(&body, "class=\"repo-name\""), |
| 1412 | + count(&body, "class=\"name repo-name\""), |
| 1417 | 1413 | 10, |
| 1418 | 1414 | "filter: match count" |
| 1419 | 1415 | ); |
| | @@ -67,14 +67,14 @@ pub(crate) async fn pins_menu( |
| 67 | 67 | ) -> Result<impl View> { |
| 68 | 68 | Ok(view! { |
| 69 | 69 | <details class="pop pins-menu"> |
| 70 | | - <summary class="button small">(g::t(lang, K::CustomizePins))</summary> |
| 70 | + <summary class="act">(g::t(lang, K::CustomizePins))</summary> |
| 71 | 71 | <form method="post" action=(action.as_str()) class="pop-panel"> |
| 72 | 72 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 73 | | - <p class="muted small">(g::t(lang, K::PinsIntro))</p> |
| 73 | + <p class="hint">(g::t(lang, K::PinsIntro))</p> |
| 74 | 74 | <ul class="pin-options"> |
| 75 | 75 | for option in options.into_iter() { |
| 76 | 76 | <li> |
| 77 | | - <label> |
| 77 | + <label class="switch"> |
| 78 | 78 | <input type="checkbox" name="repo" value=(option.repo.id.as_str()) checked=(option.checked)> |
| 79 | 79 | <span>(option.repo.name.as_str())</span> |
| 80 | 80 | </label> |
| | @@ -33,6 +33,7 @@ use crate::pages::issue_parts::parse_number; |
| 33 | 33 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 34 | 34 | use crate::post_update::after_ref_update; |
| 35 | 35 | use crate::state::AppState; |
| 36 | +use crate::views::parts::{confirm_act, post_act}; |
| 36 | 37 | use crate::views::repo_href; |
| 37 | 38 | |
| 38 | 39 | path_param!(owner); |
| | @@ -377,24 +378,25 @@ pub(crate) async fn branch_box( |
| 377 | 378 | action: Option<BranchAction>, |
| 378 | 379 | error: Option<String>, |
| 379 | 380 | ) -> Result<impl View> { |
| 381 | + let heading = crate::pages::passkeys::s(lang, "Branch", "Dal"); |
| 380 | 382 | Ok(view! { |
| 381 | | - <section class="merge-box merge-muted"> |
| 383 | + <section class="sec merge-box merge-muted"> |
| 384 | + <h2>(heading)</h2> |
| 382 | 385 | if let Some(text) = error { |
| 383 | 386 | <p class="alert merge-error" role="alert">(text.as_str())</p> |
| 384 | 387 | } |
| 385 | 388 | if let Some(a) = action { |
| 386 | 389 | if a.restore { |
| 387 | | - <form method="post" action=(a.action.as_str()) class="stack"> |
| 388 | | - <input type="hidden" name="csrf" value=(a.csrf.as_str())> |
| 389 | | - <p class="merge-headline">(g::t(lang, K::BranchPrefix)) <code>(a.branch.as_str())</code> (g::t(lang, K::BranchWasDeleted))</p> |
| 390 | | - <div><button type="submit">(g::t(lang, K::RestoreBranch))</button></div> |
| 391 | | - </form> |
| 390 | + <p class="state merge-headline">(g::t(lang, K::BranchPrefix)) <code>(a.branch.as_str())</code> (g::t(lang, K::BranchWasDeleted))</p> |
| 391 | + <div class="acts"> |
| 392 | + post_act(label: g::t(lang, K::RestoreBranch), action: a.action.as_str(), csrf: a.csrf.as_str()) |
| 393 | + </div> |
| 392 | 394 | } else { |
| 393 | | - <form method="post" action=(a.action.as_str()) class="stack"> |
| 394 | | - <input type="hidden" name="csrf" value=(a.csrf.as_str())> |
| 395 | | - <p class="merge-headline">(g::t(lang, K::BranchPrefix)) <code>(a.branch.as_str())</code> (g::t(lang, K::BranchStillHere))</p> |
| 396 | | - <div><button type="submit">(g::t(lang, K::DeleteBranch))</button></div> |
| 397 | | - </form> |
| 395 | + <p class="state merge-headline">(g::t(lang, K::BranchPrefix)) <code>(a.branch.as_str())</code> (g::t(lang, K::BranchStillHere))</p> |
| 396 | + <div class="acts"> |
| 397 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteBranch), action: a.action.as_str(), csrf: a.csrf.as_str(), |
| 398 | + note: Some(crate::pages::passkeys::s(lang, "The branch is removed from the repo. Its commits stay in the pull request.", "Dal depodan kaldırılır. Commit'leri çekme isteğinde kalır.").to_owned())) |
| 399 | + </div> |
| 398 | 400 | } |
| 399 | 401 | } |
| 400 | 402 | </section> |
| | @@ -37,6 +37,7 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 37 | 37 | use crate::pages::tree::link_context; |
| 38 | 38 | use crate::state::AppState; |
| 39 | 39 | use crate::views::diff::{DiffLang, DiffOpts, LIMITS, LineComments, diff_section}; |
| 40 | +use crate::views::parts::confirm_act; |
| 40 | 41 | use crate::views::review_thread::ThreadCtx; |
| 41 | 42 | use crate::views::{alert, now_unix, repo_href, shell}; |
| 42 | 43 | |
| | @@ -224,9 +225,9 @@ async fn files_pane( |
| 224 | 225 | FileItem { |
| 225 | 226 | href: row.index.map(|i| format!("?file={i}#file-{}", i + 1)), |
| 226 | 227 | class: if current { |
| 227 | | - "pull-file current" |
| 228 | + "line pull-file current" |
| 228 | 229 | } else { |
| 229 | | - "pull-file" |
| 230 | + "line pull-file" |
| 230 | 231 | }, |
| 231 | 232 | additions: format!("+{}", row.additions), |
| 232 | 233 | deletions: format!("\u{2212}{}", row.deletions), |
| | @@ -242,42 +243,33 @@ async fn files_pane( |
| 242 | 243 | let hint = g::t(lang, K::ViewedHint); |
| 243 | 244 | let viewed_files = g::t(lang, K::ViewedFiles); |
| 244 | 245 | Ok(view! { |
| 245 | | - <section class="pane pull-files" data-viewed-panel="" data-action=(action.as_str()) data-csrf=(csrf.as_str()) aria-label=(viewed_files)> |
| 246 | | - <div class="pull-cap"> |
| 247 | | - <span class="label">(heading)</span> |
| 248 | | - if signed_in { |
| 249 | | - <span class="pull-count" title=(hint)>(count.as_str())</span> |
| 250 | | - } |
| 251 | | - </div> |
| 252 | | - <ul class="pull-file-list"> |
| 246 | + <section class="sec pull-files" data-viewed-panel="" data-action=(action.as_str()) data-csrf=(csrf.as_str()) aria-label=(viewed_files)> |
| 247 | + <h2>(heading)</h2> |
| 248 | + if signed_in { |
| 249 | + <p class="hint" title=(hint)>(count.as_str())</p> |
| 250 | + } |
| 251 | + <div> |
| 253 | 252 | for item in items.into_iter() { |
| 254 | | - <li class=(item.class) data-viewed-row="" data-state=(item.state.name()) data-label=(item.label.as_str())> |
| 253 | + <div class=(item.class) data-viewed-row="" data-state=(item.state.name()) data-label=(item.label.as_str())> |
| 255 | 254 | if let Some(href) = item.href { |
| 256 | | - <a class="pull-file-link" href=(href.as_str())> |
| 257 | | - <svg class="pull-file-ico" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg> |
| 258 | | - <span class="mono clip">(item.path.as_str())</span> |
| 259 | | - <span class="pull-counts"><span class="ok">(item.additions.as_str())</span> <span class="bad">(item.deletions.as_str())</span></span> |
| 260 | | - </a> |
| 255 | + <a class="name pull-file-link" href=(href.as_str())><span class="mono clip">(item.path.as_str())</span></a> |
| 261 | 256 | } else { |
| 262 | | - <span class="pull-file-link"> |
| 263 | | - <svg class="pull-file-ico" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg> |
| 264 | | - <span class="mono clip">(item.path.as_str())</span> |
| 265 | | - <span class="pull-counts"><span class="ok">(item.additions.as_str())</span> <span class="bad">(item.deletions.as_str())</span></span> |
| 266 | | - </span> |
| 257 | + <span class="name pull-file-link"><span class="mono clip">(item.path.as_str())</span></span> |
| 258 | + } |
| 259 | + <span class="val pull-counts"><span class="ok">(item.additions.as_str())</span> <span class="bad">(item.deletions.as_str())</span></span> |
| 260 | + if item.state == MarkState::Changed { |
| 261 | + <span class="viewed-note">(changed)</span> |
| 267 | 262 | } |
| 268 | 263 | if signed_in && !archived { |
| 269 | 264 | if item.state == MarkState::Viewed { |
| 270 | | - <input type="checkbox" checked="" data-viewed-toggle="" data-path=(item.path.as_str()) title=(mark)> |
| 265 | + <label class="switch"><input type="checkbox" checked="" data-viewed-toggle="" data-path=(item.path.as_str())><span>(mark)</span></label> |
| 271 | 266 | } else { |
| 272 | | - <input type="checkbox" data-viewed-toggle="" data-path=(item.path.as_str()) title=(mark)> |
| 267 | + <label class="switch"><input type="checkbox" data-viewed-toggle="" data-path=(item.path.as_str())><span>(mark)</span></label> |
| 273 | 268 | } |
| 274 | 269 | } |
| 275 | | - if item.state == MarkState::Changed { |
| 276 | | - <span class="viewed-note">(changed)</span> |
| 277 | | - } |
| 278 | | - </li> |
| 270 | + </div> |
| 279 | 271 | } |
| 280 | | - </ul> |
| 272 | + </div> |
| 281 | 273 | </section> |
| 282 | 274 | }) |
| 283 | 275 | } |
| | @@ -294,15 +286,17 @@ struct CheckItem { |
| 294 | 286 | async fn checks_pane(lang: Lang, items: Vec<CheckItem>) -> Result<impl View> { |
| 295 | 287 | let heading = passkeys::s(lang, "Checks", "Kontroller"); |
| 296 | 288 | Ok(view! { |
| 297 | | - <section class="pane pull-checks"> |
| 298 | | - <div class="pull-cap"><span class="label">(heading)</span></div> |
| 299 | | - for item in items.into_iter() { |
| 300 | | - <div class="pull-check"> |
| 301 | | - <span class=(item.dot)></span> |
| 302 | | - <span class="clip">(item.context.as_str())</span> |
| 303 | | - <time class="pull-time">(item.when.as_str())</time> |
| 304 | | - </div> |
| 305 | | - } |
| 289 | + <section class="sec pull-checks"> |
| 290 | + <h2>(heading)</h2> |
| 291 | + <div> |
| 292 | + for item in items.into_iter() { |
| 293 | + <div class="line"> |
| 294 | + <span class=(item.dot)></span> |
| 295 | + <span class="name clip">(item.context.as_str())</span> |
| 296 | + <span class="val"><time class="pull-time">(item.when.as_str())</time></span> |
| 297 | + </div> |
| 298 | + } |
| 299 | + </div> |
| 306 | 300 | </section> |
| 307 | 301 | }) |
| 308 | 302 | } |
| | @@ -321,13 +315,11 @@ async fn diff_top( |
| 321 | 315 | let split_pressed = if split_on { "true" } else { "false" }; |
| 322 | 316 | let ws_pressed = if ws_on { "true" } else { "false" }; |
| 323 | 317 | Ok(view! { |
| 324 | | - <div class="pull-diff-top"> |
| 325 | | - <div class="seg" role="group" aria-label=(b::t(lang, b::K::DiffView))> |
| 326 | | - <a class="seg-item" href=(unified.as_str()) aria-pressed=(unified_on)>(b::t(lang, b::K::Unified))</a> |
| 327 | | - <a class="seg-item" href=(split.as_str()) aria-pressed=(split_pressed)>(b::t(lang, b::K::Split))</a> |
| 328 | | - </div> |
| 329 | | - <a class="seg-item toggle" href=(ws.as_str()) aria-pressed=(ws_pressed)>(b::t(lang, b::K::IgnoreWhitespace))</a> |
| 330 | | - </div> |
| 318 | + <nav class="sub pull-diff-top" aria-label=(b::t(lang, b::K::DiffView))> |
| 319 | + <a href=(unified.as_str()) aria-pressed=(unified_on)>(b::t(lang, b::K::Unified))</a> |
| 320 | + <a href=(split.as_str()) aria-pressed=(split_pressed)>(b::t(lang, b::K::Split))</a> |
| 321 | + <a href=(ws.as_str()) aria-pressed=(ws_pressed)>(b::t(lang, b::K::IgnoreWhitespace))</a> |
| 322 | + </nav> |
| 331 | 323 | }) |
| 332 | 324 | } |
| 333 | 325 | |
| | @@ -408,20 +400,20 @@ async fn review_bar( |
| 408 | 400 | let comment = g::t(lang, K::CommentChoice).trim(); |
| 409 | 401 | let placeholder = passkeys::s(lang, "Leave a comment", "Yorum bırakın"); |
| 410 | 402 | Ok(view! { |
| 411 | | - <section class="review-bar pull-compose"> |
| 412 | | - <div class="pull-more"> |
| 413 | | - <h2>(finish)</h2> |
| 414 | | - <p class="muted">(pending_text.as_str())</p> |
| 415 | | - <form method="post" action=(discard_action.as_str()) class="review-inline"> |
| 416 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 417 | | - <button type="submit" class="link-button">(discard)</button> |
| 418 | | - </form> |
| 419 | | - </div> |
| 420 | | - <form id="review-form" method="post" action=(reviews_action.as_str()) class="pull-compose-form" aria-label=(submit)> |
| 403 | + <section class="sec pull-compose"> |
| 404 | + <h2>(finish)</h2> |
| 405 | + <p class="hint">(pending_text.as_str())</p> |
| 406 | + <form id="review-form" method="post" action=(reviews_action.as_str()) class="fields" aria-label=(submit)> |
| 421 | 407 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 422 | | - <input class="pull-input" type="text" name="body" aria-label=(summary) placeholder=(placeholder)> |
| 423 | | - <button type="submit" class="btn primary" name="state" value="comment">(comment)</button> |
| 408 | + <div class="field"> |
| 409 | + <label for="review-body">(summary)</label> |
| 410 | + <input id="review-body" class="pull-input" type="text" name="body" placeholder=(placeholder)> |
| 411 | + </div> |
| 412 | + <button type="submit" class="primary" name="state" value="comment">(comment)</button> |
| 424 | 413 | </form> |
| 414 | + <div class="acts"> |
| 415 | + confirm_act(lang: lang, label: discard, action: discard_action.as_str(), csrf: csrf.as_str()) |
| 416 | + </div> |
| 425 | 417 | </section> |
| 426 | 418 | }) |
| 427 | 419 | } |
| | @@ -597,24 +589,18 @@ async fn pull_files(cx: &Cx) -> Result<impl View> { |
| 597 | 589 | if let Some(message) = error { |
| 598 | 590 | alert(message: message.as_str()) |
| 599 | 591 | } |
| 600 | | - <div class="fit-pane pull-page" data-live=(live.as_str())> |
| 601 | | - <div class="pull-cols"> |
| 602 | | - <div class="pull-left"> |
| 603 | | - files_pane(lang: lang, rows: rows, selected: selected, controls: controls) |
| 604 | | - checks_pane(lang: lang, items: checks) |
| 605 | | - </div> |
| 606 | | - <section class="pane pull-diff"> |
| 607 | | - diff_top(lang: lang, unified: unified_href, split: split_href, ws: ws_href, split_on: split_on, ws_on: ws_on) |
| 608 | | - <div class="pull-diff-scroll"> |
| 609 | | - diff_section(diff: &diff, owner: owner.as_str(), repo: name.as_str(), |
| 610 | | - oid: pr.head_oid.as_str(), parent: parent.as_deref(), |
| 611 | | - subject: g::t(lang, K::ThisPullRequest), lang: DiffLang(lang), comments: comments, opts: section_opts) |
| 612 | | - </div> |
| 613 | | - if can_review { |
| 614 | | - review_bar(lang: lang, pr_href: href.clone(), csrf: csrf.clone(), pending: pending) |
| 615 | | - } |
| 616 | | - </section> |
| 592 | + <div class="pull-page" data-live=(live.as_str())> |
| 593 | + files_pane(lang: lang, rows: rows, selected: selected, controls: controls) |
| 594 | + checks_pane(lang: lang, items: checks) |
| 595 | + diff_top(lang: lang, unified: unified_href, split: split_href, ws: ws_href, split_on: split_on, ws_on: ws_on) |
| 596 | + <div class="pull-diff"> |
| 597 | + diff_section(diff: &diff, owner: owner.as_str(), repo: name.as_str(), |
| 598 | + oid: pr.head_oid.as_str(), parent: parent.as_deref(), |
| 599 | + subject: g::t(lang, K::ThisPullRequest), lang: DiffLang(lang), comments: comments, opts: section_opts) |
| 617 | 600 | </div> |
| 601 | + if can_review { |
| 602 | + review_bar(lang: lang, pr_href: href.clone(), csrf: csrf.clone(), pending: pending) |
| 603 | + } |
| 618 | 604 | </div> |
| 619 | 605 | ) |
| 620 | 606 | }) |
| | @@ -637,7 +623,8 @@ mod tests { |
| 637 | 623 | /// The page's own `<main>` element. The shell's header echoes the request URL (theme |
| 638 | 624 | /// form `back` field), so the body checks are scoped to `<main>`. |
| 639 | 625 | fn page_main(body: &str) -> &str { |
| 640 | | - body.split_once("<main tabindex=\"-1\">") |
| 626 | + body.split_once("<main tabindex=\"-1\"") |
| 627 | + .and_then(|(_, rest)| rest.split_once('>')) |
| 641 | 628 | .and_then(|(_, rest)| rest.split_once("</main>")) |
| 642 | 629 | .map(|(main, _)| main) |
| 643 | 630 | .expect("page has a <main> element") |
| | @@ -783,7 +770,7 @@ mod tests { |
| 783 | 770 | body.contains("?comment=0:new:1#L-0-new-1"), |
| 784 | 771 | "plus link: {body}" |
| 785 | 772 | ); |
| 786 | | - assert!(body.contains("review-bar"), "review bar: {body}"); |
| 773 | + assert!(body.contains("id=\"review-form\""), "review bar: {body}"); |
| 787 | 774 | |
| 788 | 775 | // A well-formed `comment` param opens the form under its line. |
| 789 | 776 | let (status, body) = get( |
| | @@ -848,7 +835,7 @@ mod tests { |
| 848 | 835 | assert!(!page_main(&body).contains("?comment="), "anonymous: {body}"); |
| 849 | 836 | assert!(!body.contains("id=\"L-"), "anonymous: {body}"); |
| 850 | 837 | assert!(!body.contains("name=\"file_index\""), "anonymous: {body}"); |
| 851 | | - assert!(!body.contains("review-bar"), "anonymous: {body}"); |
| 838 | + assert!(!body.contains("id=\"review-form\""), "anonymous: {body}"); |
| 852 | 839 | assert!(!body.contains("class=\"diff-plus\""), "anonymous: {body}"); |
| 853 | 840 | |
| 854 | 841 | // A known review error shows its message, an unknown code shows nothing. |
| | @@ -484,22 +484,22 @@ async fn edit_page( |
| 484 | 484 | Ok(view! { cx => |
| 485 | 485 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 486 | 486 | repo_head(head: header) |
| 487 | | - <section class="card issue-edit"> |
| 487 | + <section class="sec"> |
| 488 | 488 | <h2>(heading)</h2> |
| 489 | 489 | if let Some(message) = error { |
| 490 | 490 | alert(message: message) |
| 491 | 491 | } |
| 492 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 492 | + <form method="post" action=(action.as_str()) class="fields"> |
| 493 | 493 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 494 | | - <label> |
| 494 | + <label class="field"> |
| 495 | 495 | <span>(comment_label)</span> |
| 496 | 496 | <textarea name="body" rows="10">(comment.body.as_str())</textarea> |
| 497 | 497 | </label> |
| 498 | | - <div class="issue-actions"> |
| 499 | | - <button type="submit">(save_label)</button> |
| 500 | | - <a href=(back.as_str())>(cancel_label)</a> |
| 501 | | - </div> |
| 498 | + <button type="submit" class="primary">(save_label)</button> |
| 502 | 499 | </form> |
| 500 | + <div class="acts"> |
| 501 | + <a class="act quiet" href=(back.as_str())>(cancel_label)</a> |
| 502 | + </div> |
| 503 | 503 | </section> |
| 504 | 504 | ) |
| 505 | 505 | }) |
| | @@ -46,6 +46,7 @@ use crate::pages::review_requests::{load_reviewers, reviewers_box}; |
| 46 | 46 | use crate::state::AppState; |
| 47 | 47 | use crate::views::commit_status::{StatusLang, StatusSummary, checks_summary, commit_status}; |
| 48 | 48 | use crate::views::diff::LIMITS; |
| 49 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 49 | 50 | use crate::views::{alert, now_unix, repo_href, shell, short_oid, user_link}; |
| 50 | 51 | |
| 51 | 52 | path_param!(owner); |
| | @@ -230,18 +231,11 @@ pub(crate) async fn pull_header(frame: Frame) -> Result<impl View> { |
| 230 | 231 | ) |
| 231 | 232 | }); |
| 232 | 233 | Ok(view! { |
| 233 | | - <section class="issue-head pull-head" data-live=(live_url.as_str())> |
| 234 | | - <div class="pull-line1"> |
| 235 | | - <h1 class="issue-heading">(title.as_str()) " " <span class="issue-number">(number_label.as_str())</span></h1> |
| 236 | | - if head_review { |
| 237 | | - <div class="pull-actions" role="group" aria-label=(review_strings::t(lang, review_strings::K::ReviewType))> |
| 238 | | - <button type="submit" class="btn" form="review-form" name="state" value="request_changes">(changes_label)</button> |
| 239 | | - <button type="submit" class="btn main" form="review-form" name="state" value="approve">(approve_label)</button> |
| 240 | | - </div> |
| 241 | | - } |
| 242 | | - </div> |
| 243 | | - <p class="issue-byline pull-line2"> |
| 234 | + <section class="pull-head" data-live=(live_url.as_str())> |
| 235 | + <h1 class="h1">(title.as_str()) " " <span class="issue-number">(number_label.as_str())</span></h1> |
| 236 | + <p class="hint"> |
| 244 | 237 | <span class=(state_class)>(state_text)</span> |
| 238 | + " " |
| 245 | 239 | <strong> |
| 246 | 240 | if author_known { |
| 247 | 241 | user_link(shown: author.as_str(), login: author.as_str()) |
| | @@ -249,6 +243,7 @@ pub(crate) async fn pull_header(frame: Frame) -> Result<impl View> { |
| 249 | 243 | (author.as_str()) |
| 250 | 244 | } |
| 251 | 245 | </strong> |
| 246 | + " " |
| 252 | 247 | if turkish { |
| 253 | 248 | (wants) <code>(head_label.as_str())</code> |
| 254 | 249 | (from) <code>(base_branch.as_str())</code> |
| | @@ -258,22 +253,26 @@ pub(crate) async fn pull_header(frame: Frame) -> Result<impl View> { |
| 258 | 253 | (into) <code>(base_branch.as_str())</code> |
| 259 | 254 | } |
| 260 | 255 | (byline_end) |
| 256 | + " " |
| 261 | 257 | <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> |
| 262 | 258 | if let Some(text) = totals_text { |
| 259 | + " " |
| 263 | 260 | <span class="pull-totals">(text.as_str())</span> |
| 264 | 261 | } |
| 265 | 262 | </p> |
| 263 | + if head_review { |
| 264 | + <div class="acts" role="group" aria-label=(review_strings::t(lang, review_strings::K::ReviewType))> |
| 265 | + <button type="submit" class="act" form="review-form" name="state" value="request_changes">(changes_label)</button> |
| 266 | + <button type="submit" class="act" form="review-form" name="state" value="approve">(approve_label)</button> |
| 267 | + </div> |
| 268 | + } |
| 266 | 269 | </section> |
| 267 | 270 | }) |
| 268 | 271 | } |
| 269 | 272 | |
| 270 | | -/// Class for one sub-navigation link: the one named by `active` is marked current. |
| 271 | | -fn tab_class(active: &str, tab: &str) -> &'static str { |
| 272 | | - if active == tab { |
| 273 | | - "subnav-link current" |
| 274 | | - } else { |
| 275 | | - "subnav-link" |
| 276 | | - } |
| 273 | +/// The current tab carries `aria-current`; the others carry nothing. |
| 274 | +fn current_tab(active: &str, tab: &str) -> Option<&'static str> { |
| 275 | + (active == tab).then_some("page") |
| 277 | 276 | } |
| 278 | 277 | |
| 279 | 278 | /// The pull request's sub-tabs, with their labels in `lang`. |
| | @@ -292,10 +291,10 @@ pub(crate) async fn pull_subnav_in( |
| 292 | 291 | let conversation = g::t(lang, K::TabConversation); |
| 293 | 292 | let aria = g::t(lang, K::PullPages); |
| 294 | 293 | Ok(view! { |
| 295 | | - <nav class="subnav" aria-label=(aria)> |
| 296 | | - <a class=(tab_class(&active, "conversation")) href=(href.as_str())>(conversation)</a> |
| 297 | | - <a class=(tab_class(&active, "commits")) href=(commits_href.as_str())>(commits_label.as_str())</a> |
| 298 | | - <a class=(tab_class(&active, "files")) href=(files_href.as_str())>(files_label.as_str())</a> |
| 294 | + <nav class="tabs" aria-label=(aria)> |
| 295 | + <a aria-current=(current_tab(&active, "conversation")) href=(href.as_str())>(conversation)</a> |
| 296 | + <a aria-current=(current_tab(&active, "commits")) href=(commits_href.as_str())>(commits_label.as_str())</a> |
| 297 | + <a aria-current=(current_tab(&active, "files")) href=(files_href.as_str())>(files_label.as_str())</a> |
| 299 | 298 | </nav> |
| 300 | 299 | }) |
| 301 | 300 | } |
| | @@ -350,7 +349,8 @@ async fn merge_box( |
| 350 | 349 | flow: FlowView, |
| 351 | 350 | lang: Lang, |
| 352 | 351 | ) -> Result<impl View> { |
| 353 | | - let class = format!("merge-box merge-{tone}"); |
| 352 | + let class = format!("sec merge-box merge-{tone}"); |
| 353 | + let heading = crate::pages::passkeys::s(lang, "Merge", "Birleştirme"); |
| 354 | 354 | let required_heading = g::t(lang, K::RequiredChecksHeading); |
| 355 | 355 | let style_rebase = g::t(lang, K::StyleRebase); |
| 356 | 356 | let style_merge_option = g::t(lang, K::StyleMergeCommit); |
| | @@ -380,16 +380,17 @@ async fn merge_box( |
| 380 | 380 | let merge_button = g::t(lang, K::MergeButton); |
| 381 | 381 | Ok(view! { |
| 382 | 382 | <section class=(class.as_str())> |
| 383 | + <h2>(heading)</h2> |
| 383 | 384 | if let Some(text) = merge_error { |
| 384 | 385 | <p class="alert merge-error" role="alert">(text.as_str())</p> |
| 385 | 386 | } |
| 386 | | - <p class="merge-headline">(headline.as_str())</p> |
| 387 | + <p class="state merge-headline">(headline.as_str())</p> |
| 387 | 388 | if let Some(summary) = checks { |
| 388 | 389 | checks_summary(summary: summary, lang: StatusLang(lang)) |
| 389 | 390 | } |
| 390 | 391 | if !required.is_empty() { |
| 391 | 392 | <div class="required-checks"> |
| 392 | | - <p class="muted small">(required_heading)</p> |
| 393 | + <p class="hint">(required_heading)</p> |
| 393 | 394 | <ul class="required-check-list"> |
| 394 | 395 | for row in required.iter() { |
| 395 | 396 | <li class=(row.class)><code>(row.context.as_str())</code><span>(row.label)</span></li> |
| | @@ -398,10 +399,10 @@ async fn merge_box( |
| 398 | 399 | </div> |
| 399 | 400 | } |
| 400 | 401 | if let Some(text) = approvals { |
| 401 | | - <p class="muted small">(text.as_str())</p> |
| 402 | + <p class="hint">(text.as_str())</p> |
| 402 | 403 | } |
| 403 | 404 | if let Some(text) = blocked { |
| 404 | | - <p class="merge-blocked">(text.as_str())</p> |
| 405 | + <p class="hint merge-blocked">(text.as_str())</p> |
| 405 | 406 | } |
| 406 | 407 | if !conflicts.is_empty() { |
| 407 | 408 | <ul class="merge-files"> |
| | @@ -411,71 +412,76 @@ async fn merge_box( |
| 411 | 412 | </ul> |
| 412 | 413 | } |
| 413 | 414 | if let Some(href) = reload { |
| 414 | | - <p class="muted small"><a href=(href.as_str())>(reload_text)</a></p> |
| 415 | + <div class="acts"> |
| 416 | + <a class="act" href=(href.as_str())>(reload_text)</a> |
| 417 | + </div> |
| 415 | 418 | } |
| 416 | 419 | if let Some(f) = form { |
| 417 | | - <form method="post" action=(f.action.as_str()) class="stack merge-form"> |
| 420 | + <form method="post" action=(f.action.as_str()) class="fields merge-form"> |
| 418 | 421 | <input type="hidden" name="csrf" value=(f.csrf.as_str())> |
| 419 | 422 | <input type="hidden" name="head" value=(f.head.as_str())> |
| 420 | 423 | <fieldset class="merge-styles"> |
| 421 | 424 | <legend>(style_legend)</legend> |
| 422 | | - <label><input type="radio" name="style" value="merge" checked=(true)>(style_merge)</label> |
| 423 | | - <label><input type="radio" name="style" value="squash">(style_squash)</label> |
| 424 | | - <label><input type="radio" name="style" value="rebase">(style_rebase)</label> |
| 425 | + <label class="switch"><input type="radio" name="style" value="merge" checked=(true)><span>(style_merge)</span></label> |
| 426 | + <label class="switch"><input type="radio" name="style" value="squash"><span>(style_squash)</span></label> |
| 427 | + <label class="switch"><input type="radio" name="style" value="rebase"><span>(style_rebase)</span></label> |
| 425 | 428 | if f.ff { |
| 426 | | - <label><input type="radio" name="style" value="ff">(style_ff)</label> |
| 429 | + <label class="switch"><input type="radio" name="style" value="ff"><span>(style_ff)</span></label> |
| 427 | 430 | } |
| 428 | 431 | </fieldset> |
| 429 | | - <label> |
| 430 | | - <span>(message_label)</span> |
| 431 | | - <textarea name="message" rows="3"></textarea> |
| 432 | | - </label> |
| 433 | | - <div><button type="submit" class="primary">(merge_button)</button></div> |
| 432 | + <div class="field"> |
| 433 | + <label for="merge-message">(message_label)</label> |
| 434 | + <textarea id="merge-message" name="message" rows="3"></textarea> |
| 435 | + </div> |
| 436 | + <button type="submit" class="primary">(merge_button)</button> |
| 434 | 437 | </form> |
| 435 | 438 | } |
| 436 | 439 | if let Some((text, action)) = queue_position { |
| 437 | | - <form method="post" action=(action.as_str()) class="merge-flow"> |
| 438 | | - <input type="hidden" name="csrf" value=(flow_csrf.as_str())> |
| 439 | | - <p class="merge-headline">(text.as_str())</p> |
| 440 | | - <button type="submit">(queue_remove_label)</button> |
| 441 | | - </form> |
| 440 | + <p class="state">(text.as_str())</p> |
| 441 | + <div class="acts"> |
| 442 | + confirm_act(lang: lang, label: queue_remove_label, action: action.as_str(), csrf: flow_csrf.as_str()) |
| 443 | + </div> |
| 442 | 444 | } |
| 443 | 445 | if let Some(action) = queue_add { |
| 444 | | - <form method="post" action=(action.as_str()) class="merge-flow"> |
| 446 | + <form method="post" action=(action.as_str()) class="fields"> |
| 445 | 447 | <input type="hidden" name="csrf" value=(flow_csrf.as_str())> |
| 446 | | - <p class="muted small">(queue_hint)</p> |
| 447 | | - <select name="style" aria-label=(queue_add_label)> |
| 448 | | - <option value="merge">(style_merge_option.trim())</option> |
| 449 | | - <option value="squash">(style_squash_option.trim())</option> |
| 450 | | - <option value="rebase">(style_rebase.trim())</option> |
| 451 | | - </select> |
| 448 | + <p class="hint">(queue_hint)</p> |
| 449 | + <div class="field"> |
| 450 | + <label for="queue-style">(queue_add_label)</label> |
| 451 | + <select id="queue-style" name="style"> |
| 452 | + <option value="merge">(style_merge_option.trim())</option> |
| 453 | + <option value="squash">(style_squash_option.trim())</option> |
| 454 | + <option value="rebase">(style_rebase.trim())</option> |
| 455 | + </select> |
| 456 | + </div> |
| 452 | 457 | <button type="submit" class="primary">(queue_add_label)</button> |
| 453 | 458 | </form> |
| 454 | 459 | } |
| 455 | 460 | if let Some((text, action)) = auto_on { |
| 456 | | - <form method="post" action=(action.as_str()) class="merge-flow"> |
| 457 | | - <input type="hidden" name="csrf" value=(flow_csrf.as_str())> |
| 458 | | - <p class="muted small">(text.as_str())</p> |
| 459 | | - <button type="submit">(disable_auto)</button> |
| 460 | | - </form> |
| 461 | + <p class="state">(text.as_str())</p> |
| 462 | + <div class="acts"> |
| 463 | + post_act(label: disable_auto, action: action.as_str(), csrf: flow_csrf.as_str()) |
| 464 | + </div> |
| 461 | 465 | } |
| 462 | 466 | if let Some(action) = auto_enable { |
| 463 | | - <form method="post" action=(action.as_str()) class="merge-flow"> |
| 467 | + <form method="post" action=(action.as_str()) class="fields"> |
| 464 | 468 | <input type="hidden" name="csrf" value=(flow_csrf.as_str())> |
| 465 | | - <p class="muted small">(auto_hint)</p> |
| 466 | | - <select name="style" aria-label=(enable_auto)> |
| 467 | | - <option value="merge">(style_merge_option.trim())</option> |
| 468 | | - <option value="squash">(style_squash_option.trim())</option> |
| 469 | | - <option value="rebase">(style_rebase.trim())</option> |
| 470 | | - </select> |
| 471 | | - <button type="submit">(enable_auto)</button> |
| 469 | + <p class="hint">(auto_hint)</p> |
| 470 | + <div class="field"> |
| 471 | + <label for="auto-style">(enable_auto)</label> |
| 472 | + <select id="auto-style" name="style"> |
| 473 | + <option value="merge">(style_merge_option.trim())</option> |
| 474 | + <option value="squash">(style_squash_option.trim())</option> |
| 475 | + <option value="rebase">(style_rebase.trim())</option> |
| 476 | + </select> |
| 477 | + </div> |
| 478 | + <button type="submit" class="primary">(enable_auto)</button> |
| 472 | 479 | </form> |
| 473 | 480 | } |
| 474 | 481 | if let Some((action, label)) = draft_toggle { |
| 475 | | - <form method="post" action=(action.as_str()) class="merge-flow"> |
| 476 | | - <input type="hidden" name="csrf" value=(flow_csrf.as_str())> |
| 477 | | - <button type="submit">(label)</button> |
| 478 | | - </form> |
| 482 | + <div class="acts"> |
| 483 | + post_act(label: label, action: action.as_str(), csrf: flow_csrf.as_str()) |
| 484 | + </div> |
| 479 | 485 | } |
| 480 | 486 | </section> |
| 481 | 487 | }) |
| | @@ -494,9 +500,11 @@ async fn merged_notice( |
| 494 | 500 | let prefix = g::t(lang, K::MergedByPrefix); |
| 495 | 501 | let middle = g::t(lang, K::MergedByMiddle); |
| 496 | 502 | let as_sep = g::t(lang, K::MergedAsSep); |
| 503 | + let heading = g::t(lang, K::StateMerged); |
| 497 | 504 | Ok(view! { |
| 498 | | - <section class="merge-box merge-merged"> |
| 499 | | - <p class="merge-headline"> |
| 505 | + <section class="sec merge-box merge-merged"> |
| 506 | + <h2>(heading)</h2> |
| 507 | + <p class="state merge-headline"> |
| 500 | 508 | (prefix) <strong>user_link(shown: who.as_str(), login: who.as_str())</strong> (middle) |
| 501 | 509 | <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> |
| 502 | 510 | if !commit.is_empty() { |
| | @@ -532,26 +540,30 @@ async fn review_box( |
| 532 | 540 | lang: Lang, |
| 533 | 541 | ) -> Result<impl View> { |
| 534 | 542 | let dismiss_text = g::t(lang, K::DismissButton); |
| 543 | + let heading = crate::pages::passkeys::s(lang, "Reviews", "İncelemeler"); |
| 535 | 544 | Ok(view! { |
| 536 | | - <section class="review-box"> |
| 545 | + <section class="sec review-box"> |
| 546 | + <h2>(heading)</h2> |
| 537 | 547 | if let Some(text) = approved { |
| 538 | | - <p class="review-summary">(text.as_str())</p> |
| 548 | + <p class="state">(text.as_str())</p> |
| 539 | 549 | } |
| 540 | 550 | if let Some(text) = approved_before { |
| 541 | | - <p class="review-summary muted">(text.as_str())</p> |
| 551 | + <p class="hint">(text.as_str())</p> |
| 542 | 552 | } |
| 543 | 553 | if let Some(text) = changes { |
| 544 | | - <p class="review-summary">(text.as_str())</p> |
| 554 | + <p class="state">(text.as_str())</p> |
| 545 | 555 | } |
| 546 | 556 | for row in dismiss.iter() { |
| 547 | | - <form method="post" action=(row.action.as_str()) class="review-dismiss"> |
| 548 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 549 | | - <label> |
| 550 | | - <span>(row.label.as_str())</span> |
| 551 | | - <input type="text" name="reason" required=(true)> |
| 552 | | - </label> |
| 553 | | - <button type="submit" class="link-button">(dismiss_text)</button> |
| 554 | | - </form> |
| 557 | + reveal(label: dismiss_text, |
| 558 | + <form method="post" action=(row.action.as_str()) class="fields review-dismiss"> |
| 559 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 560 | + <label class="field"> |
| 561 | + <span>(row.label.as_str())</span> |
| 562 | + <input type="text" name="reason" required=(true)> |
| 563 | + </label> |
| 564 | + <button type="submit" class="primary">(dismiss_text)</button> |
| 565 | + </form> |
| 566 | + ) |
| 555 | 567 | } |
| 556 | 568 | </section> |
| 557 | 569 | }) |
| | @@ -599,27 +611,24 @@ async fn commit_list(rows: Vec<CommitRow>, lang: Lang) -> Result<impl View> { |
| 599 | 611 | let browse = g::t(lang, K::BrowseFiles); |
| 600 | 612 | Ok(view! { |
| 601 | 613 | if empty { |
| 602 | | - <p class="muted">(no_commits)</p> |
| 614 | + <p class="state">(no_commits)</p> |
| 603 | 615 | } else { |
| 604 | | - <ul class="commit-list"> |
| 616 | + <div> |
| 605 | 617 | for row in rows.iter() { |
| 606 | | - <li class="commit-row"> |
| 607 | | - <div class="commit-main"> |
| 608 | | - <a class="commit-summary" href=(row.commit_href.as_str())>(row.summary.as_str())</a> |
| 609 | | - <div class="commit-meta muted small"> |
| 610 | | - <span class="commit-author">(row.author.as_str())</span> |
| 611 | | - <span>(committed)</span> |
| 612 | | - <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 613 | | - </div> |
| 614 | | - </div> |
| 615 | | - <div class="commit-actions"> |
| 618 | + <div class="line" data-kb-row=""> |
| 619 | + <span class="name"><a href=(row.commit_href.as_str())>(row.summary.as_str())</a></span> |
| 620 | + <span class="val"> |
| 616 | 621 | commit_status(summary: row.status.clone(), lang: StatusLang(lang)) |
| 617 | | - <a class="mono commit-oid" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 618 | | - <a class="small muted" href=(row.tree_href.as_str())>(browse)</a> |
| 619 | | - </div> |
| 620 | | - </li> |
| 622 | + " " |
| 623 | + <a class="mono" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 624 | + " · " (row.author.as_str()) " " (committed) " " |
| 625 | + <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> |
| 626 | + " · " |
| 627 | + <a href=(row.tree_href.as_str())>(browse)</a> |
| 628 | + </span> |
| 629 | + </div> |
| 621 | 630 | } |
| 622 | | - </ul> |
| 631 | + </div> |
| 623 | 632 | } |
| 624 | 633 | }) |
| 625 | 634 | } |
| | @@ -938,43 +947,41 @@ async fn pull_conversation( |
| 938 | 947 | if let Some(message) = review_error { |
| 939 | 948 | alert(message: message) |
| 940 | 949 | } |
| 941 | | - <div class="issue-layout" data-live=(live.as_str())> |
| 942 | | - <div class="issue-column fit-pane"> |
| 943 | | - discussion_timeline(lang: lang, discussion: discussion) |
| 944 | | - if review_box_shown { |
| 945 | | - review_box(approved: approved, approved_before: approved_before, changes: changes, dismiss: dismiss, |
| 946 | | - csrf: csrf.clone(), lang: lang) |
| 947 | | - } |
| 948 | | - if open { |
| 949 | | - merge_box(headline: headline, tone: tone.to_owned(), conflicts: conflicts, |
| 950 | | - reload: reload, form: merge_form, merge_error: merge_error, |
| 951 | | - approvals: approvals, blocked: blocked, checks: checks, |
| 952 | | - required: required, flow: flow, lang: lang) |
| 953 | | - } |
| 954 | | - if let Some(when) = merged_when { |
| 955 | | - merged_notice(who: merged_who, when: when, commit: merge_commit, |
| 956 | | - commit_href: merge_commit_href, lang: lang) |
| 957 | | - } |
| 958 | | - if branch_shown { |
| 959 | | - branch_box(lang: lang, action: branch, error: branch_error) |
| 960 | | - } |
| 961 | | - if can_comment { |
| 962 | | - comment_form(lang: lang, action: comment_action, state_action: state_action, |
| 963 | | - csrf: csrf.clone(), draft: draft, error: error, can_close: can_close, open: open) |
| 964 | | - } |
| 965 | | - if archived { |
| 966 | | - <p class="muted">(archived_text)</p> |
| 967 | | - } |
| 968 | | - if locked_for_viewer { |
| 969 | | - <p class="muted">(lock_notice.as_str())</p> |
| 970 | | - } else if !signed_in { |
| 971 | | - <p class="muted">(login_before)<a href=(login_href.as_str())>(login_link)</a>(login_after)</p> |
| 972 | | - } |
| 973 | | - </div> |
| 974 | | - <aside class="issue-sidebar fit-pane"> |
| 950 | + <div data-live=(live.as_str())> |
| 951 | + <div class="pull-topics"> |
| 975 | 952 | item_sidebar(lang: lang, write: write_meta, base: href.clone(), csrf: csrf.clone(), viewer: viewer_login, sidebar: sidebar, notify: notify) |
| 976 | 953 | reviewers_box(lang: lang, reviewers: reviewers) |
| 977 | | - </aside> |
| 954 | + </div> |
| 955 | + discussion_timeline(lang: lang, discussion: discussion) |
| 956 | + if review_box_shown { |
| 957 | + review_box(approved: approved, approved_before: approved_before, changes: changes, dismiss: dismiss, |
| 958 | + csrf: csrf.clone(), lang: lang) |
| 959 | + } |
| 960 | + if open { |
| 961 | + merge_box(headline: headline, tone: tone.to_owned(), conflicts: conflicts, |
| 962 | + reload: reload, form: merge_form, merge_error: merge_error, |
| 963 | + approvals: approvals, blocked: blocked, checks: checks, |
| 964 | + required: required, flow: flow, lang: lang) |
| 965 | + } |
| 966 | + if let Some(when) = merged_when { |
| 967 | + merged_notice(who: merged_who, when: when, commit: merge_commit, |
| 968 | + commit_href: merge_commit_href, lang: lang) |
| 969 | + } |
| 970 | + if branch_shown { |
| 971 | + branch_box(lang: lang, action: branch, error: branch_error) |
| 972 | + } |
| 973 | + if can_comment { |
| 974 | + comment_form(lang: lang, action: comment_action, state_action: state_action, |
| 975 | + csrf: csrf.clone(), draft: draft, error: error, can_close: can_close, open: open) |
| 976 | + } |
| 977 | + if archived { |
| 978 | + <p class="hint">(archived_text)</p> |
| 979 | + } |
| 980 | + if locked_for_viewer { |
| 981 | + <p class="hint">(lock_notice.as_str())</p> |
| 982 | + } else if !signed_in { |
| 983 | + <p class="hint">(login_before)<a href=(login_href.as_str())>(login_link)</a>(login_after)</p> |
| 984 | + } |
| 978 | 985 | </div> |
| 979 | 986 | ) |
| 980 | 987 | }) |
| | @@ -1071,9 +1078,7 @@ async fn pull_commits(cx: &Cx) -> Result<impl View> { |
| 1071 | 1078 | pull_header(frame: frame.clone()) |
| 1072 | 1079 | pull_subnav_in(lang: lang, href: href, active: "commits".to_owned(), |
| 1073 | 1080 | commits: frame.commit_count, files: frame.file_count) |
| 1074 | | - <div class="issue-pane fit-pane"> |
| 1075 | | - commit_list(rows: rows, lang: lang) |
| 1076 | | - </div> |
| 1081 | + commit_list(rows: rows, lang: lang) |
| 1077 | 1082 | ) |
| 1078 | 1083 | }) |
| 1079 | 1084 | } |
| | @@ -1145,7 +1150,8 @@ mod tests { |
| 1145 | 1150 | /// The page's own `<main>` element. The shell's header also echoes the request URL |
| 1146 | 1151 | /// (theme form `back` field), so checks about the page body are scoped to `<main>`. |
| 1147 | 1152 | fn page_main(body: &str) -> &str { |
| 1148 | | - body.split_once("<main tabindex=\"-1\">") |
| 1153 | + body.split_once("<main tabindex=\"-1\"") |
| 1154 | + .and_then(|(_, rest)| rest.split_once('>')) |
| 1149 | 1155 | .and_then(|(_, rest)| rest.split_once("</main>")) |
| 1150 | 1156 | .map(|(main, _)| main) |
| 1151 | 1157 | .expect("page has a <main> element") |
| | @@ -17,13 +17,13 @@ use crate::i18n::pulls::{self as g, K}; |
| 17 | 17 | use crate::i18n::{self, Lang}; |
| 18 | 18 | use crate::pages::issues_list::{ |
| 19 | 19 | AssigneeView, LabelView, ListQuery, MilestoneView, Selection, SortOption, list_href, |
| 20 | | - stamp_unix, state_tab_class, |
| 20 | + stamp_unix, state_tab, |
| 21 | 21 | }; |
| 22 | 22 | use crate::pages::repo::repo_head; |
| 23 | 23 | use crate::pages::repo_ctx::load_repo; |
| 24 | 24 | use crate::state::AppState; |
| 25 | 25 | use crate::views::{ |
| 26 | | - avatar_url, empty_state, iso_time, now_unix, relative_time, repo_href, shell, user_link, |
| 26 | + avatar_url, iso_time, now_unix, relative_time, repo_href, shell, user_link, |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | 29 | path_param!(owner); |
| | @@ -261,6 +261,10 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> { |
| 261 | 261 | g::t(lang, K::NoPullRequestsMatch) |
| 262 | 262 | }; |
| 263 | 263 | let state_word = sel.state; |
| 264 | + let open_on = state_word == "open"; |
| 265 | + let closed_on = state_word == "closed"; |
| 266 | + let all_on = state_word == "all"; |
| 267 | + let no_pulls_yet = open_count + closed_count == 0; |
| 264 | 268 | let draft_label = g::t(lang, K::DraftBadge); |
| 265 | 269 | let draft_sel = sel.draft; |
| 266 | 270 | |
| | @@ -269,20 +273,24 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> { |
| 269 | 273 | Ok(view! { |
| 270 | 274 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), |
| 271 | 275 | repo_head(head: header) |
| 272 | | - <section class="issue-pane fit-pane"> |
| 273 | | - <div class="issue-toolbar" data-live=(live_url.as_str())> |
| 274 | | - <nav class="issue-tabs" aria-label=(g::t(lang, K::ListStateNavLabel))> |
| 275 | | - <a class=(state_tab_class(state_word == "open")) href=(open_href.as_str())>(open_text.as_str())</a> |
| 276 | | - <a class=(state_tab_class(state_word == "closed")) href=(closed_href.as_str())>(closed_text.as_str())</a> |
| 277 | | - <a class=(state_tab_class(state_word == "all")) href=(all_href.as_str())>(all_text.as_str())</a> |
| 278 | | - </nav> |
| 279 | | - <form method="get" action=(base.as_str()) class="issue-search"> |
| 280 | | - <input type="hidden" name="state" value=(sel.state)> |
| 281 | | - <input type="hidden" name="label" value=(sel.label.as_str())> |
| 282 | | - <input type="hidden" name="milestone" value=(sel.milestone.as_str())> |
| 283 | | - <input type="hidden" name="author" value=(sel.author.as_str())> |
| 284 | | - <input type="hidden" name="assignee" value=(sel.assignee.as_str())> |
| 276 | + <div data-live=(live_url.as_str())> |
| 277 | + <h1 class="sr-only">(title.as_str())</h1> |
| 278 | + <nav class="tabs" aria-label=(g::t(lang, K::ListStateNavLabel))> |
| 279 | + state_tab(href: open_href.as_str(), text: open_text.as_str(), current: open_on) |
| 280 | + state_tab(href: closed_href.as_str(), text: closed_text.as_str(), current: closed_on) |
| 281 | + state_tab(href: all_href.as_str(), text: all_text.as_str(), current: all_on) |
| 282 | + </nav> |
| 283 | + <form method="get" action=(base.as_str())> |
| 284 | + <input type="hidden" name="state" value=(sel.state)> |
| 285 | + <input type="hidden" name="label" value=(sel.label.as_str())> |
| 286 | + <input type="hidden" name="milestone" value=(sel.milestone.as_str())> |
| 287 | + <input type="hidden" name="author" value=(sel.author.as_str())> |
| 288 | + <input type="hidden" name="assignee" value=(sel.assignee.as_str())> |
| 289 | + <div class="plain-search"> |
| 285 | 290 | <input type="search" name="q" value=(search_value.as_str()) placeholder=(g::t(lang, K::SearchTitles)) aria-label=(g::t(lang, K::SearchTitles)) maxlength="256"> |
| 291 | + <button type="submit" class="sr-only">(g::t(lang, K::Search))</button> |
| 292 | + </div> |
| 293 | + <div class="sub"> |
| 286 | 294 | <select name="draft" aria-label=(g::t(lang, K::DraftFilterLabel)) data-autosubmit=(true)> |
| 287 | 295 | <option value="" selected=(draft_sel.is_empty())>(g::t(lang, K::DraftAny))</option> |
| 288 | 296 | <option value="true" selected=(draft_sel == "true")>(g::t(lang, K::DraftOnly))</option> |
| | @@ -293,36 +301,30 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> { |
| 293 | 301 | <option value=(option.value) selected=(option.selected)>(option.label)</option> |
| 294 | 302 | } |
| 295 | 303 | </select> |
| 296 | | - <button type="submit" class="sr-only">(g::t(lang, K::Search))</button> |
| 297 | | - </form> |
| 298 | | - <div class="issue-tools"> |
| 299 | | - <a class="issue-tab-link" href=(queue_href.as_str())>(mq::t(lang, mq::K::MergeQueueTitle))</a> |
| 304 | + <a href=(queue_href.as_str())>(mq::t(lang, mq::K::MergeQueueTitle))</a> |
| 300 | 305 | if can_create { |
| 301 | | - <a class="button" href=(compare_href.as_str()) data-palette-action="go">(g::t(lang, K::NewPullRequest))</a> |
| 306 | + <a class="act" href=(compare_href.as_str()) data-palette-action="go">(g::t(lang, K::NewPullRequest))</a> |
| 302 | 307 | } |
| 303 | 308 | </div> |
| 304 | | - </div> |
| 309 | + </form> |
| 305 | 310 | if has_filters { |
| 306 | | - <p class="muted small">(g::t(lang, K::FiltersApplied)) <a href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a></p> |
| 311 | + <p class="hint">(g::t(lang, K::FiltersApplied)) " " <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a></p> |
| 307 | 312 | } |
| 308 | 313 | if rows.is_empty() { |
| 314 | + <p class="state">(empty_text)</p> |
| 309 | 315 | if has_filters { |
| 310 | | - empty_state(title: empty_text, |
| 311 | | - <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> |
| 312 | | - ) |
| 313 | | - } else if open_count + closed_count == 0 { |
| 314 | | - empty_state(title: empty_text, |
| 315 | | - if can_create { |
| 316 | | - <a class="button primary" href=(compare_href.as_str()) data-palette-action="go">(g::t(lang, K::NewPullRequest))</a> |
| 317 | | - } |
| 318 | | - ) |
| 319 | | - } else { |
| 320 | | - empty_state(title: empty_text) |
| 316 | + <div class="acts"> |
| 317 | + <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> |
| 318 | + </div> |
| 319 | + } else if no_pulls_yet && can_create { |
| 320 | + <div class="acts"> |
| 321 | + <a class="act" href=(compare_href.as_str()) data-palette-action="go">(g::t(lang, K::NewPullRequest))</a> |
| 322 | + </div> |
| 321 | 323 | } |
| 322 | 324 | } else { |
| 323 | | - <ul class="issue-list"> |
| 325 | + <div> |
| 324 | 326 | for row in rows.iter() { |
| 325 | | - <li class="issue-row" data-kb-row="" data-arrive=(row.arrive.as_str())> |
| 327 | + <div class="line issue-row" data-kb-row="" data-arrive=(row.arrive.as_str())> |
| 326 | 328 | <span class=(row.state_class) role="img" aria-label=(row.state_label)></span> |
| 327 | 329 | <div class="issue-main"> |
| 328 | 330 | <div class="issue-title-line"> |
| | @@ -357,32 +359,30 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> { |
| 357 | 359 | if let Some(text) = row.reviewers_text.clone() { |
| 358 | 360 | <span class="review-pending">(text.as_str())</span> |
| 359 | 361 | } |
| 362 | + for assignee in row.assignees.iter() { |
| 363 | + <img class="avatar avatar-sm" src=(assignee.avatar.as_str()) alt=(assignee.name.as_str()) title=(assignee.name.as_str()) width="20" height="20"> |
| 364 | + } |
| 365 | + if row.has_comments { |
| 366 | + <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> |
| 367 | + } |
| 360 | 368 | </div> |
| 361 | 369 | </div> |
| 362 | | - <div class="issue-aside"> |
| 363 | | - for assignee in row.assignees.iter() { |
| 364 | | - <img class="avatar avatar-sm" src=(assignee.avatar.as_str()) alt=(assignee.name.as_str()) title=(assignee.name.as_str()) width="20" height="20"> |
| 365 | | - } |
| 366 | | - if row.has_comments { |
| 367 | | - <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> |
| 368 | | - } |
| 369 | | - </div> |
| 370 | | - </li> |
| 370 | + </div> |
| 371 | 371 | } |
| 372 | | - </ul> |
| 372 | + </div> |
| 373 | 373 | } |
| 374 | 374 | if has_newer || has_older { |
| 375 | | - <nav class="pager"> |
| 375 | + <nav class="sub"> |
| 376 | 376 | if has_newer { |
| 377 | 377 | <a href=(newer_href.as_str())>(g::t(lang, K::Newer))</a> |
| 378 | 378 | } |
| 379 | | - <span class="muted small">(page_label.as_str())</span> |
| 379 | + <span>(page_label.as_str())</span> |
| 380 | 380 | if has_older { |
| 381 | 381 | <a href=(older_href.as_str())>(g::t(lang, K::Older))</a> |
| 382 | 382 | } |
| 383 | 383 | </nav> |
| 384 | 384 | } |
| 385 | | - </section> |
| 385 | + </div> |
| 386 | 386 | ) |
| 387 | 387 | }) |
| 388 | 388 | } |
| | @@ -398,7 +398,7 @@ mod tests { |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | fn rows(html: &str) -> usize { |
| 401 | | - html.matches("class=\"issue-row\"").count() |
| 401 | + html.matches("class=\"line issue-row\"").count() |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | const HEAD_OID: &str = "1111111111111111111111111111111111111111"; |
| | @@ -19,7 +19,7 @@ use crate::pages::repo::repo_head; |
| 19 | 19 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 20 | 20 | use crate::pages::tree::{LastCommit, last_commit_view}; |
| 21 | 21 | use crate::views::commit_line::commit_line; |
| 22 | | -use crate::views::{RefLink, empty_state, now_unix, repo_href, shell}; |
| 22 | +use crate::views::{RefLink, now_unix, repo_href, shell}; |
| 23 | 23 | |
| 24 | 24 | path_param!(owner); |
| 25 | 25 | path_param!(repo); |
| | @@ -105,45 +105,36 @@ pub(crate) async fn ref_rows( |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | #[component] |
| 108 | | -async fn refs_table(rows: Vec<RefRow>, kind_label: &str, lang: Lang) -> Result<impl View> { |
| 108 | +async fn refs_table(rows: Vec<RefRow>, lang: Lang) -> Result<impl View> { |
| 109 | 109 | let empty = rows.is_empty(); |
| 110 | 110 | Ok(view! { |
| 111 | 111 | if empty { |
| 112 | | - empty_state(title: g::t(lang, K::NothingHere)) |
| 112 | + <p class="state">(g::t(lang, K::NothingHere))</p> |
| 113 | 113 | } else { |
| 114 | | - <div class="table-wrap"> |
| 115 | | - <table class="table refs-table"> |
| 116 | | - <thead> |
| 117 | | - <tr> |
| 118 | | - <th>(kind_label)</th> |
| 119 | | - <th>(g::t(lang, K::LastCommitHeader))</th> |
| 120 | | - <th class="age">(g::t(lang, K::AgeHeader))</th> |
| 121 | | - </tr> |
| 122 | | - </thead> |
| 123 | | - <tbody> |
| 124 | | - for row in rows.into_iter() { |
| 125 | | - <tr data-kb-row=""> |
| 126 | | - <td class="tree-name"> |
| 127 | | - <span class="tree-label"> |
| 128 | | - <a href=(row.href)>(row.name)</a> |
| 129 | | - if row.is_default { |
| 130 | | - <span class="badge public">(g::t(lang, K::DefaultBadge))</span> |
| 131 | | - } |
| 132 | | - </span> |
| 133 | | - </td> |
| 134 | | - if let Some(last) = row.last { |
| 135 | | - <td class="tree-commit"><a href=(last.href)>commit_line(subject: last.summary.clone())</a></td> |
| 136 | | - <td class="age"> |
| 137 | | - <time datetime=(last.iso.clone()) title=(last.absolute)>(last.age)</time> |
| 138 | | - </td> |
| 139 | | - } else { |
| 140 | | - <td class="tree-commit"></td> |
| 141 | | - <td class="age"></td> |
| 114 | + <div> |
| 115 | + for row in rows.into_iter() { |
| 116 | + if let Some(last) = row.last { |
| 117 | + <details class="row-open" data-kb-row=""> |
| 118 | + <summary class="line"> |
| 119 | + <a class="name" href=(row.href)>(row.name)</a> |
| 120 | + if row.is_default { |
| 121 | + <span class="badge public">(g::t(lang, K::DefaultBadge))</span> |
| 142 | 122 | } |
| 143 | | - </tr> |
| 144 | | - } |
| 145 | | - </tbody> |
| 146 | | - </table> |
| 123 | + <span class="val"><time datetime=(last.iso.clone()) title=(last.absolute)>(last.age)</time></span> |
| 124 | + </summary> |
| 125 | + <div class="opened"> |
| 126 | + <p class="state"><a href=(last.href)>commit_line(subject: last.summary.clone())</a></p> |
| 127 | + </div> |
| 128 | + </details> |
| 129 | + } else { |
| 130 | + <div class="line" data-kb-row=""> |
| 131 | + <a class="name" href=(row.href)>(row.name)</a> |
| 132 | + if row.is_default { |
| 133 | + <span class="badge public">(g::t(lang, K::DefaultBadge))</span> |
| 134 | + } |
| 135 | + </div> |
| 136 | + } |
| 137 | + } |
| 147 | 138 | </div> |
| 148 | 139 | } |
| 149 | 140 | }) |
| | @@ -193,14 +184,7 @@ async fn tags_page(cx: &Cx) -> Result<impl View> { |
| 193 | 184 | Ok(view! { |
| 194 | 185 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 195 | 186 | repo_head(head: header) |
| 196 | | - <div class="lang-list fit-pane"> |
| 197 | | - <div class="list-bar"> |
| 198 | | - <p class="label">(g::t(lang, K::TagsTitle))</p> |
| 199 | | - </div> |
| 200 | | - <div class="list-scroll"> |
| 201 | | - refs_table(rows: rows, kind_label: g::t(lang, K::TagKindLabel), lang: lang) |
| 202 | | - </div> |
| 203 | | - </div> |
| 187 | + refs_table(rows: rows, lang: lang) |
| 204 | 188 | ) |
| 205 | 189 | }) |
| 206 | 190 | } |
| | @@ -128,52 +128,52 @@ async fn register_form( |
| 128 | 128 | error: Option<String>, |
| 129 | 129 | ) -> Result<impl View> { |
| 130 | 130 | Ok(view! { |
| 131 | | - <section class="card narrow"> |
| 131 | + <section> |
| 132 | 132 | <h1>(t(lang, Key::RegisterTitle))</h1> |
| 133 | 133 | if gate == Gate::NeedsInvite { |
| 134 | | - <p class="muted">(t(lang, Key::RegisterNeedsInvite))</p> |
| 134 | + <p class="state">(t(lang, Key::RegisterNeedsInvite))</p> |
| 135 | 135 | } |
| 136 | 136 | if gate == Gate::BadInvite { |
| 137 | | - <p class="muted">(t(lang, Key::RegisterInvalidInvite))</p> |
| 137 | + <p class="state">(t(lang, Key::RegisterInvalidInvite))</p> |
| 138 | 138 | } |
| 139 | 139 | if gate == Gate::Form { |
| 140 | 140 | if invited { |
| 141 | | - <p class="muted">(t(lang, Key::RegisterInviteSub))</p> |
| 141 | + <p class="hint">(t(lang, Key::RegisterInviteSub))</p> |
| 142 | 142 | } |
| 143 | 143 | if !invited { |
| 144 | | - <p class="muted">(t(lang, Key::RegisterSub))</p> |
| 144 | + <p class="hint">(t(lang, Key::RegisterSub))</p> |
| 145 | 145 | } |
| 146 | | - if let Some(message) = error { |
| 147 | | - alert(message: message.as_str()) |
| 148 | | - } |
| 149 | | - <form data-hard="true" method="post" action="/register" class="stack"> |
| 146 | + <form data-hard="true" method="post" action="/register" class="fields"> |
| 147 | + if let Some(message) = error { |
| 148 | + alert(message: message.as_str()) |
| 149 | + } |
| 150 | 150 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 151 | 151 | <input type="hidden" name="invite" value=(invite)> |
| 152 | | - <label> |
| 153 | | - <span>(t(lang, Key::Username))</span> |
| 154 | | - <input type="text" name="username" value=(username) autocomplete="username" required=(true)> |
| 155 | | - </label> |
| 152 | + <div class="field"> |
| 153 | + <label for="register-username">(t(lang, Key::Username))</label> |
| 154 | + <input id="register-username" type="text" name="username" value=(username) autocomplete="username" required=(true)> |
| 155 | + </div> |
| 156 | 156 | if invited { |
| 157 | | - <label> |
| 158 | | - <span>(t(lang, Key::Email))</span> |
| 159 | | - <input type="email" name="email" value=(email) readonly=(true)> |
| 160 | | - </label> |
| 157 | + <div class="field"> |
| 158 | + <label for="register-email">(t(lang, Key::Email))</label> |
| 159 | + <input id="register-email" type="email" name="email" value=(email) readonly=(true)> |
| 160 | + </div> |
| 161 | 161 | } |
| 162 | 162 | if !invited { |
| 163 | | - <label> |
| 164 | | - <span>(t(lang, Key::Email))</span> |
| 165 | | - <input type="email" name="email" value=(email) autocomplete="email" maxlength="254" required=(true)> |
| 166 | | - </label> |
| 163 | + <div class="field"> |
| 164 | + <label for="register-email">(t(lang, Key::Email))</label> |
| 165 | + <input id="register-email" type="email" name="email" value=(email) autocomplete="email" maxlength="254" required=(true)> |
| 166 | + </div> |
| 167 | 167 | } |
| 168 | | - <label> |
| 169 | | - <span>(t(lang, Key::Password))</span> |
| 170 | | - <input type="password" name="password" autocomplete="new-password" required=(true)> |
| 171 | | - <small class="muted">(t(lang, Key::AtLeast12Chars))</small> |
| 172 | | - </label> |
| 173 | | - <label> |
| 174 | | - <span>(t(lang, Key::ConfirmPassword))</span> |
| 175 | | - <input type="password" name="confirm" autocomplete="new-password" required=(true)> |
| 176 | | - </label> |
| 168 | + <div class="field"> |
| 169 | + <label for="register-password">(t(lang, Key::Password))</label> |
| 170 | + <input id="register-password" type="password" name="password" autocomplete="new-password" required=(true)> |
| 171 | + <p class="hint">(t(lang, Key::AtLeast12Chars))</p> |
| 172 | + </div> |
| 173 | + <div class="field"> |
| 174 | + <label for="register-confirm">(t(lang, Key::ConfirmPassword))</label> |
| 175 | + <input id="register-confirm" type="password" name="confirm" autocomplete="new-password" required=(true)> |
| 176 | + </div> |
| 177 | 177 | <button type="submit" class="primary">(t(lang, Key::RegisterSubmit))</button> |
| 178 | 178 | </form> |
| 179 | 179 | } |
| | @@ -353,20 +353,20 @@ async fn verify_body( |
| 353 | 353 | mode: VerifyMode, |
| 354 | 354 | ) -> Result<impl View> { |
| 355 | 355 | Ok(view! { |
| 356 | | - <section class="card narrow"> |
| 356 | + <section> |
| 357 | 357 | <h1>(t(lang, Key::VerifyTitle))</h1> |
| 358 | 358 | if mode == VerifyMode::Confirm { |
| 359 | | - <p class="muted">(t(lang, Key::VerifyConfirmSub))</p> |
| 360 | | - <form data-hard="true" method="post" action=(format!("/verify/{token}")) class="stack"> |
| 359 | + <p class="hint">(t(lang, Key::VerifyConfirmSub))</p> |
| 360 | + <form data-hard="true" method="post" action=(format!("/verify/{token}")) class="fields"> |
| 361 | 361 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 362 | 362 | <button type="submit" class="primary">(t(lang, Key::VerifyConfirm))</button> |
| 363 | 363 | </form> |
| 364 | 364 | } |
| 365 | 365 | if mode == VerifyMode::Done { |
| 366 | | - <p>(t(lang, Key::VerifyDone))</p> |
| 366 | + <p class="state">(t(lang, Key::VerifyDone))</p> |
| 367 | 367 | } |
| 368 | 368 | if mode == VerifyMode::Invalid { |
| 369 | | - <p class="muted">(t(lang, Key::VerifyInvalid))</p> |
| 369 | + <p class="state">(t(lang, Key::VerifyInvalid))</p> |
| 370 | 370 | } |
| 371 | 371 | </section> |
| 372 | 372 | }) |
| | @@ -44,6 +44,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 44 | 44 | use crate::release_ops::{self, CreateRelease, EditRelease, ReleaseError}; |
| 45 | 45 | use crate::render::markdown::render_markdown; |
| 46 | 46 | use crate::state::AppState; |
| 47 | +use crate::views::parts::{confirm_act, reveal}; |
| 47 | 48 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 48 | 49 | use crate::views::{alert, empty_state, enc, now_unix, shell, user_link}; |
| 49 | 50 | |
| | @@ -363,68 +364,66 @@ async fn release_form( |
| 363 | 364 | let tag_hint = g::t(lang, K::TagHint); |
| 364 | 365 | let edit_tag_help = g::t(lang, K::EditTagHelp); |
| 365 | 366 | Ok(view! { |
| 366 | | - <form method="post" action=(action.as_str()) class="stack release-form"> |
| 367 | + <form method="post" action=(action.as_str()) class="fields release-form"> |
| 367 | 368 | if let Some(message) = draft.error { |
| 368 | 369 | alert(message: message.as_str()) |
| 369 | 370 | } |
| 370 | 371 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 371 | 372 | if is_new { |
| 372 | 373 | // The tag and the target branch are short, so they share a row. |
| 373 | | - <div class="release-pair"> |
| 374 | | - <label> |
| 375 | | - <span>(g::t(lang, K::Tag))</span> |
| 376 | | - <input type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> |
| 377 | | - </label> |
| 378 | | - <label> |
| 379 | | - <span>(g::t(lang, K::TargetBranch))</span> |
| 380 | | - <select name="target"> |
| 374 | + <div class="field-pair"> |
| 375 | + <div class="field"> |
| 376 | + <label for="release-tag">(g::t(lang, K::Tag))</label> |
| 377 | + <input id="release-tag" type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> |
| 378 | + </div> |
| 379 | + <div class="field"> |
| 380 | + <label for="release-target">(g::t(lang, K::TargetBranch))</label> |
| 381 | + <select id="release-target" name="target"> |
| 381 | 382 | for branch in branches.iter() { |
| 382 | 383 | <option value=(branch.as_str()) selected=(branch.as_str() == draft.target.as_str())>(branch.as_str())</option> |
| 383 | 384 | } |
| 384 | 385 | </select> |
| 385 | | - </label> |
| 386 | | - <p class="muted small">(tag_hint)</p> |
| 386 | + </div> |
| 387 | 387 | </div> |
| 388 | + <p class="hint">(tag_hint)</p> |
| 388 | 389 | } else { |
| 389 | | - <label> |
| 390 | | - <span>(g::t(lang, K::Tag))</span> |
| 391 | | - <input type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> |
| 392 | | - </label> |
| 393 | | - <p class="muted small">(edit_tag_help)</p> |
| 390 | + <div class="field"> |
| 391 | + <label for="release-tag">(g::t(lang, K::Tag))</label> |
| 392 | + <input id="release-tag" type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> |
| 393 | + <p class="hint">(edit_tag_help)</p> |
| 394 | + </div> |
| 394 | 395 | if move_target { |
| 395 | | - <label> |
| 396 | | - <span>(g::t(lang, K::EditTargetLabel))</span> |
| 397 | | - <select name="target"> |
| 396 | + <div class="field"> |
| 397 | + <label for="release-target">(g::t(lang, K::EditTargetLabel))</label> |
| 398 | + <select id="release-target" name="target"> |
| 398 | 399 | <option value="" selected=(draft.target.is_empty())>(g::t(lang, K::CurrentCommit))</option> |
| 399 | 400 | for branch in branches.iter() { |
| 400 | 401 | <option value=(branch.as_str()) selected=(branch.as_str() == draft.target.as_str())>(branch.as_str())</option> |
| 401 | 402 | } |
| 402 | 403 | </select> |
| 403 | | - </label> |
| 404 | | - <p class="muted small">(g::t(lang, K::TargetMoveHelp))</p> |
| 404 | + <p class="hint">(g::t(lang, K::TargetMoveHelp))</p> |
| 405 | + </div> |
| 405 | 406 | } else { |
| 406 | | - <p class="muted small">(g::t(lang, K::TargetLockedHelp))</p> |
| 407 | + <p class="hint">(g::t(lang, K::TargetLockedHelp))</p> |
| 407 | 408 | } |
| 408 | 409 | } |
| 409 | | - <label> |
| 410 | | - <span>(g::t(lang, K::Title))</span> |
| 411 | | - <input type="text" name="title" value=(draft.title.as_str()) required="required" maxlength="200"> |
| 412 | | - </label> |
| 413 | | - <label> |
| 414 | | - <span>(g::t(lang, K::ReleaseNotes))</span> |
| 415 | | - <textarea name="body" rows="10">(draft.body.as_str())</textarea> |
| 416 | | - </label> |
| 417 | | - <label class="inline"> |
| 410 | + <div class="field"> |
| 411 | + <label for="release-title">(g::t(lang, K::Title))</label> |
| 412 | + <input id="release-title" type="text" name="title" value=(draft.title.as_str()) required="required" maxlength="200"> |
| 413 | + </div> |
| 414 | + <div class="field"> |
| 415 | + <label for="release-body">(g::t(lang, K::ReleaseNotes))</label> |
| 416 | + <textarea id="release-body" name="body" rows="10">(draft.body.as_str())</textarea> |
| 417 | + </div> |
| 418 | + <label class="switch"> |
| 418 | 419 | <input type="checkbox" name="prerelease" value="on" checked=(draft.prerelease)> |
| 419 | 420 | <span>(g::t(lang, K::PrereleaseHelp))</span> |
| 420 | 421 | </label> |
| 421 | | - <label class="inline"> |
| 422 | + <label class="switch"> |
| 422 | 423 | <input type="checkbox" name="draft" value="on" checked=(draft.draft)> |
| 423 | 424 | <span>(g::t(lang, K::DraftHelp))</span> |
| 424 | 425 | </label> |
| 425 | | - <div> |
| 426 | | - <button type="submit" class="primary">(submit)</button> |
| 427 | | - </div> |
| 426 | + <button type="submit" class="primary">(submit)</button> |
| 428 | 427 | </form> |
| 429 | 428 | }) |
| 430 | 429 | } |
| | @@ -438,44 +437,43 @@ async fn asset_rows( |
| 438 | 437 | csrf: String, |
| 439 | 438 | lang: Lang, |
| 440 | 439 | ) -> Result<impl View> { |
| 440 | + let rows: Vec<(AssetLink, String, String)> = assets |
| 441 | + .into_iter() |
| 442 | + .zip(delete_actions.into_iter()) |
| 443 | + .enumerate() |
| 444 | + .map(|(index, (asset, action))| (asset, action, format!("replace-file-{index}"))) |
| 445 | + .collect(); |
| 441 | 446 | Ok(view! { |
| 442 | | - if assets.is_empty() { |
| 443 | | - <p class="muted">(g::t(lang, K::NoAssetsYet))</p> |
| 447 | + if rows.is_empty() { |
| 448 | + <p class="state">(g::t(lang, K::NoAssetsYet))</p> |
| 444 | 449 | } else { |
| 445 | | - <div class="table-wrap"> |
| 446 | | - <table class="table release-assets"> |
| 447 | | - <thead> |
| 448 | | - <tr> |
| 449 | | - <th>(g::t(lang, K::File))</th> |
| 450 | | - <th>(g::t(lang, K::Size))</th> |
| 451 | | - <th>(g::t(lang, K::Downloads))</th> |
| 452 | | - <th>"SHA-256"</th> |
| 453 | | - <th></th> |
| 454 | | - </tr> |
| 455 | | - </thead> |
| 456 | | - <tbody> |
| 457 | | - for (asset, action) in assets.iter().zip(delete_actions.iter()) { |
| 458 | | - <tr> |
| 459 | | - <td><a href=(asset.href.as_str())>(asset.name.as_str())</a></td> |
| 460 | | - <td>(asset.size.as_str())</td> |
| 461 | | - <td>(asset.downloads)</td> |
| 462 | | - <td><code class="small">(asset.sha256.as_str())</code></td> |
| 463 | | - <td class="asset-actions"> |
| 464 | | - <form method="post" action=(upload_action.as_str()) enctype="multipart/form-data" class="inline-form replace-form"> |
| 450 | + <div> |
| 451 | + for (asset, action, file_id) in rows.into_iter() { |
| 452 | + <details class="row-open" data-kb-row=""> |
| 453 | + <summary class="line"> |
| 454 | + <span class="name">(asset.name.as_str())</span> |
| 455 | + <span class="val">(asset.size.as_str()) " · " (g::download_count(lang, asset.downloads))</span> |
| 456 | + </summary> |
| 457 | + <div class="opened"> |
| 458 | + <code class="hint">(asset.sha256.as_str())</code> |
| 459 | + <div class="acts"> |
| 460 | + <a class="act" href=(asset.href.as_str())>(g::t(lang, K::Download))</a> |
| 461 | + reveal(label: g::t(lang, K::ReplaceAsset), |
| 462 | + <form method="post" action=(upload_action.as_str()) enctype="multipart/form-data" class="fields"> |
| 465 | 463 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 466 | 464 | <input type="hidden" name="name" value=(asset.name.as_str())> |
| 467 | | - <input type="file" name="file" required="required" aria-label=(asset.name.as_str())> |
| 465 | + <div class="field"> |
| 466 | + <label for=(file_id.as_str())>(g::t(lang, K::File))</label> |
| 467 | + <input id=(file_id.as_str()) type="file" name="file" required="required"> |
| 468 | + </div> |
| 468 | 469 | <button type="submit">(g::t(lang, K::ReplaceAsset))</button> |
| 469 | 470 | </form> |
| 470 | | - <form method="post" action=(action.as_str()) class="inline-form"> |
| 471 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 472 | | - <button type="submit">(i18n::t(lang, Key::Delete))</button> |
| 473 | | - </form> |
| 474 | | - </td> |
| 475 | | - </tr> |
| 476 | | - } |
| 477 | | - </tbody> |
| 478 | | - </table> |
| 471 | + ) |
| 472 | + confirm_act(lang: lang, label: i18n::t(lang, Key::Delete), action: action.as_str(), csrf: csrf.as_str()) |
| 473 | + </div> |
| 474 | + </div> |
| 475 | + </details> |
| 476 | + } |
| 479 | 477 | </div> |
| 480 | 478 | } |
| 481 | 479 | }) |
| | @@ -501,57 +499,60 @@ async fn list_body( |
| 501 | 499 | if is_error { |
| 502 | 500 | alert(message: text) |
| 503 | 501 | } else { |
| 504 | | - <section class="card notice" role="status">(text)</section> |
| 502 | + <p class="state" role="status">(text)</p> |
| 505 | 503 | } |
| 506 | 504 | } |
| 507 | | - <section class="lang-list fit-pane" data-live=(live.as_str())> |
| 508 | | - <div class="release-list-head list-bar"> |
| 505 | + <div data-live=(live.as_str())> |
| 506 | + <section class="sec"> |
| 509 | 507 | <h2>(g::t(lang, K::Releases))</h2> |
| 510 | 508 | if let Some(href) = &new_href { |
| 511 | | - <a class="button primary" href=(href.as_str())>(g::t(lang, K::NewRelease))</a> |
| 509 | + <div class="acts"> |
| 510 | + <a class="act" href=(href.as_str())>(g::t(lang, K::NewRelease))</a> |
| 511 | + </div> |
| 512 | 512 | } |
| 513 | | - </div> |
| 513 | + </section> |
| 514 | 514 | if cards.is_empty() { |
| 515 | 515 | empty_state(title: g::t(lang, K::NoReleasesYet)) |
| 516 | 516 | } |
| 517 | | - <div class="list-scroll"> |
| 518 | 517 | for card in cards.iter() { |
| 519 | | - <article class="release-card" data-kb-row="" title=(card.body.as_str())> |
| 520 | | - <code class="release-tag">(card.tag.as_str())</code> |
| 521 | | - <h3> |
| 522 | | - <a href=(card.href.as_str())>(card.title.as_str())</a> |
| 523 | | - if card.latest { |
| 524 | | - " " <span class="badge latest">(g::t(lang, K::Latest))</span> |
| 525 | | - } |
| 526 | | - if card.prerelease { |
| 527 | | - " " <span class="badge">(g::t(lang, K::PreRelease))</span> |
| 528 | | - } |
| 529 | | - if card.draft { |
| 530 | | - " " <span class="badge draft">(g::t(lang, K::Draft))</span> |
| 531 | | - } |
| 532 | | - </h3> |
| 533 | | - <span class="muted small release-meta"> |
| 534 | | - <time data-rel="true" datetime=(card.when.iso.as_str()) title=(card.when.absolute.as_str())>(card.when.relative.as_str())</time> |
| 518 | + <details class="row-open" data-kb-row="" title=(card.body.as_str())> |
| 519 | + <summary class="line"> |
| 520 | + <span class="name"> |
| 521 | + (card.title.as_str()) |
| 522 | + if card.latest { |
| 523 | + " " <span class="badge latest">(g::t(lang, K::Latest))</span> |
| 524 | + } |
| 525 | + if card.prerelease { |
| 526 | + " " <span class="badge">(g::t(lang, K::PreRelease))</span> |
| 527 | + } |
| 528 | + if card.draft { |
| 529 | + " " <span class="badge draft">(g::t(lang, K::Draft))</span> |
| 530 | + } |
| 531 | + </span> |
| 532 | + <span class="val"> |
| 533 | + <code>(card.tag.as_str())</code> " · " <time data-rel="true" datetime=(card.when.iso.as_str()) title=(card.when.absolute.as_str())>(card.when.relative.as_str())</time> |
| 534 | + </span> |
| 535 | + </summary> |
| 536 | + <div class="opened"> |
| 535 | 537 | if !card.author.is_empty() { |
| 536 | | - " \u{b7} " user_link(shown: card.author.as_str(), login: card.author.as_str()) |
| 538 | + <p class="hint">user_link(shown: card.author.as_str(), login: card.author.as_str())</p> |
| 537 | 539 | } |
| 538 | | - </span> |
| 539 | | - if !card.assets.is_empty() { |
| 540 | | - <details class="release-assets-pop"> |
| 541 | | - <summary class="small">(card.assets.len().to_string()) " " (crate::pages::passkeys::s(lang, "assets", "dosya"))</summary> |
| 542 | | - <ul class="release-asset-list"> |
| 540 | + if !card.assets.is_empty() { |
| 541 | + <div class="sub"> |
| 543 | 542 | for asset in card.assets.iter() { |
| 544 | | - <li><a href=(asset.href.as_str())>(asset.name.as_str())</a> " (" (asset.size.as_str()) ", " (g::download_count(lang, asset.downloads)) ")"</li> |
| 543 | + <a href=(asset.href.as_str())>(asset.name.as_str()) " (" (asset.size.as_str()) ", " (g::download_count(lang, asset.downloads)) ")"</a> |
| 545 | 544 | } |
| 546 | | - </ul> |
| 547 | | - </details> |
| 548 | | - } |
| 549 | | - <a class="small release-edit" href=(card.edit_href.as_str())>(g::t(lang, K::Edit))</a> |
| 550 | | - </article> |
| 545 | + </div> |
| 546 | + } |
| 547 | + <div class="acts"> |
| 548 | + <a class="act" href=(card.href.as_str())>(card.tag.as_str())</a> |
| 549 | + <a class="act" href=(card.edit_href.as_str())>(g::t(lang, K::Edit))</a> |
| 550 | + </div> |
| 551 | + </div> |
| 552 | + </details> |
| 551 | 553 | } |
| 552 | | - </div> |
| 553 | 554 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 554 | | - </section> |
| 555 | + </div> |
| 555 | 556 | }) |
| 556 | 557 | } |
| 557 | 558 | |
| | @@ -635,7 +636,7 @@ async fn new_form_body( |
| 635 | 636 | ) -> Result<impl View> { |
| 636 | 637 | Ok(view! { |
| 637 | 638 | repo_head(head: head) |
| 638 | | - <section class="lang-form"> |
| 639 | + <section class="sec"> |
| 639 | 640 | <h2>(g::t(lang, K::NewRelease))</h2> |
| 640 | 641 | release_form(action: action, csrf: csrf, lang: lang, is_new: true, move_target: true, draft: draft, branches: branches, submit: g::t(lang, K::SaveRelease)) |
| 641 | 642 | </section> |
| | @@ -810,14 +811,14 @@ async fn release_tag_page(cx: &Cx) -> Result<impl View> { |
| 810 | 811 | if is_error { |
| 811 | 812 | alert(message: text) |
| 812 | 813 | } else { |
| 813 | | - <section class="card notice" role="status">(text)</section> |
| 814 | + <p class="state" role="status">(text)</p> |
| 814 | 815 | } |
| 815 | 816 | } |
| 816 | | - <section class="card" data-live=(live.as_str())> |
| 817 | | - <p class="muted small"> |
| 817 | + <div data-live=(live.as_str())> |
| 818 | + <nav class="sub"> |
| 818 | 819 | <a href=(all_href.as_str())>(g::t(lang, K::AllReleases))</a> |
| 819 | | - </p> |
| 820 | | - <h2> |
| 820 | + </nav> |
| 821 | + <h1 class="h1"> |
| 821 | 822 | (card.title.as_str()) |
| 822 | 823 | if card.prerelease { |
| 823 | 824 | " " <span class="badge">(g::t(lang, K::PreRelease))</span> |
| | @@ -825,8 +826,8 @@ async fn release_tag_page(cx: &Cx) -> Result<impl View> { |
| 825 | 826 | if card.draft { |
| 826 | 827 | " " <span class="badge draft">(g::t(lang, K::Draft))</span> |
| 827 | 828 | } |
| 828 | | - </h2> |
| 829 | | - <p class="muted small"> |
| 829 | + </h1> |
| 830 | + <p class="hint"> |
| 830 | 831 | <code>(card.tag.as_str())</code> |
| 831 | 832 | " \u{b7} " <time data-rel="true" datetime=(card.when.iso.as_str()) title=(card.when.absolute.as_str())>(card.when.relative.as_str())</time> |
| 832 | 833 | if !card.author.is_empty() { |
| | @@ -834,45 +835,48 @@ async fn release_tag_page(cx: &Cx) -> Result<impl View> { |
| 834 | 835 | } |
| 835 | 836 | </p> |
| 836 | 837 | if !body_html.is_empty() { |
| 837 | | - <div class="markdown-body release-body">(Unescaped::new_unchecked(body_html))</div> |
| 838 | + <section class="sec"> |
| 839 | + <div class="markdown-body release-body">(Unescaped::new_unchecked(body_html))</div> |
| 840 | + </section> |
| 838 | 841 | } |
| 839 | | - <h3>(g::t(lang, K::Assets))</h3> |
| 840 | | - if card.assets.is_empty() { |
| 841 | | - <p class="muted">(g::t(lang, K::NoAssets))</p> |
| 842 | | - } else { |
| 843 | | - <ul class="release-asset-list"> |
| 842 | + <section class="sec"> |
| 843 | + <h2>(g::t(lang, K::Assets))</h2> |
| 844 | + if card.assets.is_empty() { |
| 845 | + <p class="state">(g::t(lang, K::NoAssets))</p> |
| 846 | + } else { |
| 844 | 847 | for asset in card.assets.iter() { |
| 845 | | - <li> |
| 846 | | - <a href=(asset.href.as_str())>(asset.name.as_str())</a> |
| 847 | | - " (" (asset.size.as_str()) ", " (g::download_count(lang, asset.downloads)) ")" |
| 848 | | - <div class="muted small"><code>(asset.sha256.as_str())</code></div> |
| 849 | | - </li> |
| 848 | + <details class="row-open" data-kb-row=""> |
| 849 | + <summary class="line"> |
| 850 | + <span class="name">(asset.name.as_str())</span> |
| 851 | + <span class="val">(asset.size.as_str()) " · " (g::download_count(lang, asset.downloads))</span> |
| 852 | + </summary> |
| 853 | + <div class="opened"> |
| 854 | + <code class="hint">(asset.sha256.as_str())</code> |
| 855 | + <div class="acts"> |
| 856 | + <a class="act" href=(asset.href.as_str())>(g::t(lang, K::Download))</a> |
| 857 | + </div> |
| 858 | + </div> |
| 859 | + </details> |
| 850 | 860 | } |
| 851 | | - </ul> |
| 852 | | - } |
| 853 | | - <h3>(g::t(lang, K::SourceCode))</h3> |
| 854 | | - <ul> |
| 855 | | - <li><a href=(archive_tar.as_str())>"tar.gz"</a></li> |
| 856 | | - <li><a href=(archive_zip.as_str())>"zip"</a></li> |
| 857 | | - </ul> |
| 858 | | - if writer { |
| 859 | | - <div class="release-actions"> |
| 860 | | - <a href=(edit_href.as_str())>(g::t(lang, K::Edit))</a> |
| 861 | | - <details class="confirm-inline"> |
| 862 | | - <summary class="button danger">(g::t(lang, K::DeleteRelease))</summary> |
| 863 | | - <div class="confirm-pop"> |
| 864 | | - <p>(g::t(lang, K::DeleteReleaseHelp))</p> |
| 865 | | - <form method="post" action=(delete_href.as_str())> |
| 866 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 867 | | - <input type="hidden" name="confirm" value="on"> |
| 868 | | - <button type="submit" class="danger">(g::t(lang, K::YesDeleteRelease))</button> |
| 869 | | - <button type="button" data-close-details="">(g::t(lang, K::Dismiss))</button> |
| 870 | | - </form> |
| 871 | | - </div> |
| 872 | | - </details> |
| 861 | + } |
| 862 | + </section> |
| 863 | + <section class="sec"> |
| 864 | + <h2>(g::t(lang, K::SourceCode))</h2> |
| 865 | + <div class="acts"> |
| 866 | + <a class="act" href=(archive_tar.as_str())>"tar.gz"</a> |
| 867 | + <a class="act" href=(archive_zip.as_str())>"zip"</a> |
| 873 | 868 | </div> |
| 869 | + </section> |
| 870 | + if writer { |
| 871 | + <section class="sec"> |
| 872 | + <div class="acts"> |
| 873 | + <a class="act" href=(edit_href.as_str())>(g::t(lang, K::Edit))</a> |
| 874 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteRelease), action: delete_href.as_str(), csrf: csrf.as_str(), |
| 875 | + fields: vec![("confirm".to_owned(), "on".to_owned())], note: Some(g::t(lang, K::DeleteReleaseHelp).to_owned())) |
| 876 | + </div> |
| 877 | + </section> |
| 874 | 878 | } |
| 875 | | - </section> |
| 879 | + </div> |
| 876 | 880 | ) |
| 877 | 881 | }) |
| 878 | 882 | } |
| | @@ -903,47 +907,37 @@ async fn edit_body( |
| 903 | 907 | if is_error { |
| 904 | 908 | alert(message: text) |
| 905 | 909 | } else { |
| 906 | | - <section class="card notice" role="status">(text)</section> |
| 910 | + <p class="state" role="status">(text)</p> |
| 907 | 911 | } |
| 908 | 912 | } |
| 909 | | - <div class="lang-split"> |
| 910 | | - <section class="lang-pane fit-pane"> |
| 911 | | - <p class="muted small"><a href=(view_tag.as_str())>(g::t(lang, K::BackToRelease))</a></p> |
| 913 | + <nav class="sub"> |
| 914 | + <a href=(view_tag.as_str())>(g::t(lang, K::BackToRelease))</a> |
| 915 | + </nav> |
| 916 | + <section class="sec"> |
| 912 | 917 | <h2>(g::t(lang, K::EditRelease))</h2> |
| 913 | 918 | release_form(action: action, csrf: csrf.clone(), lang: lang, is_new: false, move_target: move_target, draft: draft, branches: branches, submit: g::t(lang, K::SaveRelease)) |
| 914 | 919 | </section> |
| 915 | | - <section class="lang-pane fit-pane"> |
| 920 | + <section class="sec"> |
| 916 | 921 | <h2>(g::t(lang, K::Assets))</h2> |
| 917 | | - <p class="muted small">(upload_hint.as_str())</p> |
| 922 | + <p class="hint">(upload_hint.as_str())</p> |
| 918 | 923 | asset_rows(assets: assets, delete_actions: delete_actions, upload_action: upload_action.clone(), csrf: csrf.clone(), lang: lang) |
| 919 | | - <form method="post" action=(upload_action.as_str()) enctype="multipart/form-data" class="stack"> |
| 924 | + <form method="post" action=(upload_action.as_str()) enctype="multipart/form-data" class="fields"> |
| 920 | 925 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 921 | | - <label> |
| 922 | | - <span>(g::t(lang, K::File))</span> |
| 923 | | - <input type="file" name="file" required="required"> |
| 924 | | - </label> |
| 925 | | - <div> |
| 926 | | - <button type="submit">(g::t(lang, K::UploadAsset))</button> |
| 926 | + <div class="field"> |
| 927 | + <label for="upload-file">(g::t(lang, K::File))</label> |
| 928 | + <input id="upload-file" type="file" name="file" required="required"> |
| 927 | 929 | </div> |
| 930 | + <button type="submit" class="primary">(g::t(lang, K::UploadAsset))</button> |
| 928 | 931 | </form> |
| 932 | + </section> |
| 933 | + <section class="sec"> |
| 929 | 934 | <h2>(g::t(lang, K::DeleteRelease))</h2> |
| 930 | | - <p class="muted small">(g::t(lang, K::DeleteReleaseHelp))</p> |
| 931 | | - <div> |
| 932 | | - <details class="confirm-inline"> |
| 933 | | - <summary class="button danger">(g::t(lang, K::DeleteRelease))</summary> |
| 934 | | - <div class="confirm-pop"> |
| 935 | | - <p>(g::t(lang, K::DeleteReleaseHelp))</p> |
| 936 | | - <form method="post" action=(delete_href.as_str())> |
| 937 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 938 | | - <input type="hidden" name="confirm" value="on"> |
| 939 | | - <button type="submit" class="danger">(g::t(lang, K::YesDeleteRelease))</button> |
| 940 | | - <button type="button" data-close-details="">(g::t(lang, K::Dismiss))</button> |
| 941 | | - </form> |
| 942 | | - </div> |
| 943 | | - </details> |
| 935 | + <p class="hint">(g::t(lang, K::DeleteReleaseHelp))</p> |
| 936 | + <div class="acts"> |
| 937 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteRelease), action: delete_href.as_str(), csrf: csrf.as_str(), |
| 938 | + fields: vec![("confirm".to_owned(), "on".to_owned())]) |
| 944 | 939 | </div> |
| 945 | 940 | </section> |
| 946 | | - </div> |
| 947 | 941 | }) |
| 948 | 942 | } |
| 949 | 943 | |
| | @@ -78,7 +78,7 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> { |
| 78 | 78 | description, |
| 79 | 79 | archived, |
| 80 | 80 | active, |
| 81 | | - hide_search: _, |
| 81 | + hide_search, |
| 82 | 82 | can_admin, |
| 83 | 83 | can_delete: _, |
| 84 | 84 | open_issues, |
| | @@ -154,19 +154,21 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> { |
| 154 | 154 | None => ("", "", None, String::new()), |
| 155 | 155 | }; |
| 156 | 156 | let live_attr = (!live.is_empty()).then(|| live.clone()); |
| 157 | | - // Every repo page has one head row: the path bar names the repo, and the tabs share a row with |
| 158 | | - // the visibility and the counts and actions at the right end. |
| 157 | + // The head: the path bar names the repo; the actions sit as text links under it, then the tabs, |
| 158 | + // then the code search entry. |
| 159 | 159 | let has_origin = fork_line.is_some() || mirror_line.is_some(); |
| 160 | + let search_action = repo_href(&owner, &name, "search", ""); |
| 161 | + let search_label = g::t(lang, K::SearchCodePlaceholder); |
| 160 | 162 | Ok(view! { |
| 161 | | - <section class="page-head repo-head-code" data-live=(live_attr.as_deref())> |
| 163 | + <section class="repo-head" data-live=(live_attr.as_deref())> |
| 162 | 164 | <h1 class="sr-only">(owner.as_str()) "/" (name.as_str())</h1> |
| 163 | 165 | if has_origin { |
| 164 | 166 | <div> |
| 165 | 167 | if let Some((href, label)) = fork_line { |
| 166 | | - <p class="muted small">(g::t(lang, K::ForkedFrom)) <a href=(href.as_str())>(label.as_str())</a></p> |
| 168 | + <p class="hint">(g::t(lang, K::ForkedFrom)) <a href=(href.as_str())>(label.as_str())</a></p> |
| 167 | 169 | } |
| 168 | 170 | if let Some(source) = mirror_line { |
| 169 | | - <p class="muted small mirror-line">(g::t(lang, K::MirrorOf)) <code>(source.as_str())</code> ", " |
| 171 | + <p class="hint mirror-line">(g::t(lang, K::MirrorOf)) <code>(source.as_str())</code> ", " |
| 170 | 172 | if let Some(at) = mirror_at.as_deref() { |
| 171 | 173 | (mirror_before) rel_time(lang: lang, stamp: at) (mirror_after) |
| 172 | 174 | } else { |
| | @@ -176,48 +178,49 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> { |
| 176 | 178 | } |
| 177 | 179 | </div> |
| 178 | 180 | } |
| 179 | | - repo_tabs(owner: owner.clone(), repo: name.clone(), default_branch: default_branch.clone(), active: active.clone(), can_admin: can_admin, lang: lang, open_issues: Some(open_issues), open_pulls: Some(open_pulls), discussions: discussions, wiki: wiki, security: security) |
| 180 | | - <div class="header-actions"> |
| 181 | + <div class="acts"> |
| 181 | 182 | // A private repo says so beside the star; public needs no mark outside the menu. |
| 182 | 183 | if private { |
| 183 | 184 | <span class=(badge)>(vis)</span> |
| 184 | 185 | } |
| 185 | | - <div class="star-control"> |
| 186 | | - if let Some((action, label, csrf)) = star_control { |
| 187 | | - <form method="post" action=(action.as_str()) class="star-form"> |
| 188 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 189 | | - <button type="submit" class="star-button" data-palette-action="post">(label.as_str())</button> |
| 190 | | - </form> |
| 191 | | - } else { |
| 192 | | - <span class="muted" aria-label=(g::t(lang, K::StarsAria))>(anon_count.as_str())</span> |
| 193 | | - } |
| 194 | | - </div> |
| 186 | + if let Some((action, label, csrf)) = star_control { |
| 187 | + <form method="post" action=(action.as_str()) class="act-form"> |
| 188 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 189 | + <button type="submit" class="act" data-palette-action="post">(label.as_str())</button> |
| 190 | + </form> |
| 191 | + } else { |
| 192 | + <span class="hint" aria-label=(g::t(lang, K::StarsAria))>(anon_count.as_str())</span> |
| 193 | + } |
| 195 | 194 | <details class="menu head-more"> |
| 196 | | - <summary aria-label=(s(lang, "Repository actions", "Depo işlemleri"))> |
| 195 | + <summary class="act" aria-label=(s(lang, "Repository actions", "Depo işlemleri"))> |
| 197 | 196 | <span aria-hidden="true">"…"</span> |
| 198 | 197 | </summary> |
| 199 | 198 | <div class="menu-list head-more-list"> |
| 200 | 199 | <span class=(badge)>(vis)</span> |
| 201 | 200 | if let Some((action, csrf)) = fork_control { |
| 202 | | - <form method="post" action=(action.as_str()) class="fork-form"> |
| 201 | + <form method="post" action=(action.as_str()) class="act-form"> |
| 203 | 202 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 204 | | - <button type="submit" class="fork-button">(g::t(lang, K::ForkButton))</button> |
| 203 | + <button type="submit" class="act">(g::t(lang, K::ForkButton))</button> |
| 205 | 204 | </form> |
| 206 | 205 | } |
| 207 | 206 | if let Some((action, csrf, level)) = watch_control { |
| 208 | 207 | watch_form(lang: lang, action: action, csrf: csrf, level: level, watchers: watchers) |
| 209 | 208 | } else { |
| 210 | | - <span class="muted small">(watch_count.as_str())</span> |
| 209 | + <span class="hint">(watch_count.as_str())</span> |
| 211 | 210 | } |
| 212 | | - <span class="muted small">(fork_count.as_str())</span> |
| 211 | + <span class="hint">(fork_count.as_str())</span> |
| 213 | 212 | </div> |
| 214 | 213 | </details> |
| 215 | 214 | </div> |
| 215 | + repo_tabs(owner: owner.clone(), repo: name.clone(), default_branch: default_branch.clone(), active: active.clone(), can_admin: can_admin, lang: lang, open_issues: Some(open_issues), open_pulls: Some(open_pulls), discussions: discussions, wiki: wiki, security: security) |
| 216 | + if !hide_search && active == "code" { |
| 217 | + <form method="get" action=(search_action.as_str()) class="plain-search" role="search"> |
| 218 | + <input type="search" name="q" placeholder=(search_label) aria-label=(search_label) autocomplete="off"> |
| 219 | + </form> |
| 220 | + } |
| 216 | 221 | </section> |
| 217 | 222 | if archived { |
| 218 | | - <section class="card notice" role="status"> |
| 219 | | - (g::t(lang, K::ArchivedNotice)) |
| 220 | | - </section> |
| 223 | + <p class="state" role="status">(g::t(lang, K::ArchivedNotice))</p> |
| 221 | 224 | } |
| 222 | 225 | // The description belongs to the Code tab only; sub-pages keep the compact head. |
| 223 | 226 | if active == "code" && !description.is_empty() { |
| | @@ -237,20 +240,17 @@ async fn clone_popover( |
| 237 | 240 | ) -> Result<impl View> { |
| 238 | 241 | Ok(view! { |
| 239 | 242 | <details class="clone pop"> |
| 240 | | - <summary class="button primary"> |
| 241 | | - <svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M8 7l-5 5 5 5M16 7l5 5-5 5"/></svg> |
| 242 | | - (g::t(lang, K::CloneTitle)) |
| 243 | | - </summary> |
| 243 | + <summary class="act">(g::t(lang, K::CloneTitle))</summary> |
| 244 | 244 | <div class="pop-panel"> |
| 245 | 245 | <label for="clone-https">"HTTPS"</label> |
| 246 | 246 | <input id="clone-https" class="mono" type="text" readonly=(true) value=(https.as_str())> |
| 247 | 247 | <span id="clone-https-text" hidden=(true)>(https.as_str())</span> |
| 248 | | - <p><button type="button" class="button small" data-copy="clone-https-text" data-copied=(g::t(lang, K::CloneCopied)) data-failed=(g::t(lang, K::CloneCopyFailed)) data-palette-action="click">(g::t(lang, K::CopyCloneUrl))</button></p> |
| 248 | + <button type="button" class="act" data-copy="clone-https-text" data-copied=(g::t(lang, K::CloneCopied)) data-failed=(g::t(lang, K::CloneCopyFailed)) data-palette-action="click">(g::t(lang, K::CopyCloneUrl))</button> |
| 249 | 249 | <label for="clone-ssh">"SSH"</label> |
| 250 | 250 | <input id="clone-ssh" class="mono" type="text" readonly=(true) value=(ssh.as_str())> |
| 251 | | - <p class="muted small">(g::t(lang, K::SshRequiresKey))</p> |
| 251 | + <p class="hint">(g::t(lang, K::SshRequiresKey))</p> |
| 252 | 252 | if let Some((zip, tar)) = downloads { |
| 253 | | - <nav class="archive-links" aria-label=(g::t(lang, K::DownloadNav))> |
| 253 | + <nav class="sub" aria-label=(g::t(lang, K::DownloadNav))> |
| 254 | 254 | <a href=(zip)>(g::t(lang, K::DownloadZip))</a> |
| 255 | 255 | <a href=(tar)>(g::t(lang, K::DownloadTarGz))</a> |
| 256 | 256 | </nav> |
| | @@ -260,8 +260,8 @@ async fn clone_popover( |
| 260 | 260 | }) |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | | -/// Head of the README pane, shared by the repo home and the tree pages: the file name at the left, |
| 264 | | -/// then the repo facts (licence, size, top language) and the Clone popover at the right. |
| 263 | +/// Head of the README pane, shared by the repo home and the tree pages: the file name, then the repo |
| 264 | +/// facts (licence, size, top language) and the Clone popover as text links on the same line. |
| 265 | 265 | #[component] |
| 266 | 266 | pub(crate) async fn readme_head( |
| 267 | 267 | label: String, |
| | @@ -272,12 +272,10 @@ pub(crate) async fn readme_head( |
| 272 | 272 | lang: Lang, |
| 273 | 273 | ) -> Result<impl View> { |
| 274 | 274 | Ok(view! { |
| 275 | | - <div class="canvas-head canvas-readme-head"> |
| 276 | | - <span class="label">(label.as_str())</span> |
| 277 | | - <div class="canvas-facts"> |
| 278 | | - readme_meta(lang: lang, facts: facts) |
| 279 | | - clone_popover(https: https, ssh: ssh, downloads: downloads, lang: lang) |
| 280 | | - </div> |
| 275 | + <div class="acts"> |
| 276 | + <span class="name">(label.as_str())</span> |
| 277 | + readme_meta(lang: lang, facts: facts) |
| 278 | + clone_popover(https: https, ssh: ssh, downloads: downloads, lang: lang) |
| 281 | 279 | </div> |
| 282 | 280 | }) |
| 283 | 281 | } |
| | @@ -293,20 +291,20 @@ async fn branches_card( |
| 293 | 291 | ) -> Result<impl View> { |
| 294 | 292 | let empty = branches.is_empty(); |
| 295 | 293 | Ok(view! { |
| 296 | | - <section class="card"> |
| 294 | + <section class="sec"> |
| 297 | 295 | <h2>(g::t(lang, K::BranchesTitle))</h2> |
| 298 | 296 | if empty { |
| 299 | | - <p class="muted">(g::t(lang, K::EmptyRepoPush))</p> |
| 300 | | - <p class="muted small">(g::t(lang, K::OverHttps))</p> |
| 297 | + <p class="state">(g::t(lang, K::EmptyRepoPush))</p> |
| 298 | + <p class="hint">(g::t(lang, K::OverHttps))</p> |
| 301 | 299 | <pre class="code"><code>(push_https)</code></pre> |
| 302 | | - <p class="muted small">(g::t(lang, K::OverSsh))</p> |
| 300 | + <p class="hint">(g::t(lang, K::OverSsh))</p> |
| 303 | 301 | <pre class="code"><code>(push_ssh)</code></pre> |
| 304 | 302 | } else { |
| 305 | | - <ul class="branch-list"> |
| 303 | + <div> |
| 306 | 304 | for branch in branches.into_iter() { |
| 307 | | - <li><code>(branch)</code></li> |
| 305 | + <div class="line"><span class="name"><code>(branch)</code></span></div> |
| 308 | 306 | } |
| 309 | | - </ul> |
| 307 | + </div> |
| 310 | 308 | } |
| 311 | 309 | </section> |
| 312 | 310 | }) |
| | @@ -547,7 +545,7 @@ async fn repo_page(cx: &Cx) -> Result<impl View> { |
| 547 | 545 | // Two panes over the dock: the tree on the left, the README on the right. |
| 548 | 546 | <div class="repo-grid repo-home canvas-repo"> |
| 549 | 547 | <div class="repo-main canvas-files"> |
| 550 | | - <div class="browse-bar canvas-head" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> |
| 548 | + <div class="browse-bar" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> |
| 551 | 549 | ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags, |
| 552 | 550 | branches_href: branches_href, tags_href: tags_href) |
| 553 | 551 | file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), |
| | @@ -31,6 +31,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 31 | 31 | use crate::pages::repo_settings::settings_frame; |
| 32 | 32 | use crate::pages::repo_settings_live::settings_head; |
| 33 | 33 | use crate::state::AppState; |
| 34 | +use crate::views::parts::{confirm_act, reveal}; |
| 34 | 35 | use crate::views::{alert, avatar_url, display_name, shell}; |
| 35 | 36 | |
| 36 | 37 | path_param!(owner); |
| | @@ -156,7 +157,8 @@ fn collaborators_redirect(title: &str) -> SeeOther { |
| 156 | 157 | see_other(format!("/{title}/settings/collaborators")) |
| 157 | 158 | } |
| 158 | 159 | |
| 159 | | -/// The add row, then one row per collaborator. The role legend sits in the add panel. |
| 160 | +/// The collaborators topic: one row per collaborator (role and removal inside it), then the add form |
| 161 | +/// in place. The role legend sits in the add form. |
| 160 | 162 | #[component] |
| 161 | 163 | async fn collaborators_pane( |
| 162 | 164 | lang: Lang, |
| | @@ -168,91 +170,77 @@ async fn collaborators_pane( |
| 168 | 170 | add_open: bool, |
| 169 | 171 | ) -> Result<impl View> { |
| 170 | 172 | Ok(view! { |
| 171 | | - <section class="card rows-pane"> |
| 172 | | - <div class="row-line"> |
| 173 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 174 | | - <div class="row-main"> |
| 175 | | - <h2 class="row-title">(g::t(lang, K::AddCollaboratorHeading))</h2> |
| 176 | | - if rows.is_empty() { |
| 177 | | - <p class="row-status">(g::t(lang, K::NoCollaborators))</p> |
| 178 | | - } else { |
| 179 | | - <p class="row-status">(g::t(lang, K::CollaboratorsHelp))</p> |
| 180 | | - } |
| 181 | | - </div> |
| 182 | | - <details class="row-action" open=(add_open)> |
| 183 | | - <summary>(g::t(lang, K::AddCollaboratorButton))</summary> |
| 184 | | - <div class="row-panel"> |
| 185 | | - <h3>(g::t(lang, K::Roles))</h3> |
| 186 | | - <dl class="role-list"> |
| 187 | | - for entry in LEGEND.iter() { |
| 188 | | - <dt>(entry.0.as_str())</dt> |
| 189 | | - <dd>(g::t(lang, entry.1))</dd> |
| 173 | + <section class="sec"> |
| 174 | + <h2>(g::t(lang, K::Collaborators))</h2> |
| 175 | + if rows.is_empty() { |
| 176 | + <p class="state">(g::t(lang, K::NoCollaborators))</p> |
| 177 | + } else { |
| 178 | + <p class="hint">(g::t(lang, K::CollaboratorsHelp))</p> |
| 179 | + } |
| 180 | + <div> |
| 181 | + for row in rows.iter() { |
| 182 | + <details class="row-open"> |
| 183 | + <summary class="line"> |
| 184 | + <span class="name"> |
| 185 | + <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> |
| 186 | + " " (row.label.as_str()) |
| 187 | + </span> |
| 188 | + <span class="val">(crate::i18n::orgs::role_name(lang, row.role.as_str()))</span> |
| 189 | + </summary> |
| 190 | + <div class="opened"> |
| 191 | + if row.label == row.username { |
| 192 | + <p class="hint"><a href=(format!("/{}", row.username.as_str()))>(row.username.as_str())</a></p> |
| 190 | 193 | } |
| 191 | | - </dl> |
| 192 | | - <form method="post" action=(add_action.as_str()) class="stack" id="add-collaborator"> |
| 193 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 194 | | - <label> |
| 195 | | - <span>(g::t(lang, K::Username))</span> |
| 196 | | - <input type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 197 | | - </label> |
| 198 | | - <label> |
| 199 | | - <span>(g::t(lang, K::Role))</span> |
| 200 | | - <select name="role"> |
| 201 | | - for role in ROLES.iter() { |
| 202 | | - <option value=(role.as_str()) selected=(*role == Role::Read)>(role.as_str())</option> |
| 203 | | - } |
| 204 | | - </select> |
| 205 | | - </label> |
| 206 | | - <p class="muted small">(g::t(lang, K::AddCollaboratorHelp))</p> |
| 207 | | - <div> |
| 208 | | - <button type="submit" class="primary">(g::t(lang, K::AddCollaboratorButton))</button> |
| 194 | + <form method="post" action=(role_action.as_str()) class="fields"> |
| 195 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 196 | + <input type="hidden" name="user_id" value=(row.user_id.as_str())> |
| 197 | + <div class="field"> |
| 198 | + <label for=(format!("collab-role-{}", row.user_id.as_str()))>(g::t(lang, K::Role))</label> |
| 199 | + <select id=(format!("collab-role-{}", row.user_id.as_str())) name="role" aria-label=(g::role_for(lang, row.username.as_str()))> |
| 200 | + for role in ROLES.iter() { |
| 201 | + <option value=(role.as_str()) selected=(*role == row.role)>(crate::i18n::orgs::role_name(lang, role.as_str()))</option> |
| 202 | + } |
| 203 | + </select> |
| 204 | + </div> |
| 205 | + <button type="submit">(g::t(lang, K::SaveRole))</button> |
| 206 | + </form> |
| 207 | + <div class="acts"> |
| 208 | + confirm_act(lang: lang, label: g::t(lang, K::Remove), action: remove_action.as_str(), csrf: csrf.as_str(), |
| 209 | + fields: vec![("user_id".to_owned(), row.user_id.clone())], |
| 210 | + note: Some(passkeys::s(lang, "They lose access to this repo at once.", "Bu repoya erişimi hemen kaybeder.").to_owned())) |
| 209 | 211 | </div> |
| 210 | | - </form> |
| 211 | | - </div> |
| 212 | | - </details> |
| 212 | + </div> |
| 213 | + </details> |
| 214 | + } |
| 213 | 215 | </div> |
| 214 | | - for row in rows.iter() { |
| 215 | | - <div class="row-line"> |
| 216 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-6 8-6s8 2 8 6"/></svg> |
| 217 | | - <div class="row-main"> |
| 218 | | - <strong class="row-name"> |
| 219 | | - if row.label == row.username { |
| 220 | | - <a class="user-link" href=(format!("/{}", row.username.as_str()))> |
| 221 | | - <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> |
| 222 | | - <span>(row.label.as_str())</span> |
| 223 | | - </a> |
| 224 | | - } else { |
| 225 | | - <span class="user-link"> |
| 226 | | - <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> |
| 227 | | - <span>(row.label.as_str())</span> |
| 228 | | - </span> |
| 229 | | - } |
| 230 | | - </strong> |
| 231 | | - </div> |
| 232 | | - <div class="row-actions"> |
| 233 | | - <form method="post" action=(role_action.as_str()) class="inline-form"> |
| 234 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 235 | | - <input type="hidden" name="user_id" value=(row.user_id.as_str())> |
| 236 | | - <select name="role" aria-label=(g::role_for(lang, row.username.as_str()))> |
| 216 | + <div class="acts"> |
| 217 | + reveal(label: g::t(lang, K::AddCollaboratorButton), id: Some("collab-add"), open: add_open, |
| 218 | + <p class="state">(g::t(lang, K::Roles))</p> |
| 219 | + <dl class="role-list"> |
| 220 | + for entry in LEGEND.iter() { |
| 221 | + <dt>(crate::i18n::orgs::role_name(lang, entry.0.as_str()))</dt> |
| 222 | + <dd>(g::t(lang, entry.1))</dd> |
| 223 | + } |
| 224 | + </dl> |
| 225 | + <form method="post" action=(add_action.as_str()) class="fields" id="add-collaborator"> |
| 226 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 227 | + <div class="field"> |
| 228 | + <label for="collab-username">(g::t(lang, K::Username))</label> |
| 229 | + <input id="collab-username" type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 230 | + </div> |
| 231 | + <div class="field"> |
| 232 | + <label for="collab-role">(g::t(lang, K::Role))</label> |
| 233 | + <select id="collab-role" name="role"> |
| 237 | 234 | for role in ROLES.iter() { |
| 238 | | - <option value=(role.as_str()) selected=(*role == row.role)>(role.as_str())</option> |
| 235 | + <option value=(role.as_str()) selected=(*role == Role::Read)>(crate::i18n::orgs::role_name(lang, role.as_str()))</option> |
| 239 | 236 | } |
| 240 | 237 | </select> |
| 241 | | - <button type="submit">(g::t(lang, K::SaveRole))</button> |
| 242 | | - </form> |
| 243 | | - <details class="row-menu"> |
| 244 | | - <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> |
| 245 | | - <div class="row-menu-panel" role="menu"> |
| 246 | | - <form method="post" action=(remove_action.as_str()) class="inline-form"> |
| 247 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 248 | | - <input type="hidden" name="user_id" value=(row.user_id.as_str())> |
| 249 | | - <button type="submit" class="danger">(g::t(lang, K::Remove))</button> |
| 250 | | - </form> |
| 251 | | - </div> |
| 252 | | - </details> |
| 253 | | - </div> |
| 254 | | - </div> |
| 255 | | - } |
| 238 | + <p class="hint">(g::t(lang, K::AddCollaboratorHelp))</p> |
| 239 | + </div> |
| 240 | + <button type="submit" class="primary">(g::t(lang, K::AddCollaboratorButton))</button> |
| 241 | + </form> |
| 242 | + ) |
| 243 | + </div> |
| 256 | 244 | </section> |
| 257 | 245 | }) |
| 258 | 246 | } |
| | @@ -275,7 +263,7 @@ impl FrameData { |
| 275 | 263 | } |
| 276 | 264 | } |
| 277 | 265 | |
| 278 | | -/// The page body: repo header with Settings active, the notice, then the rows pane. |
| 266 | +/// The page body: repo header with Settings active, the notice, then the collaborators topic. |
| 279 | 267 | #[component] |
| 280 | 268 | async fn collaborators_body( |
| 281 | 269 | lang: Lang, |
| | @@ -300,7 +288,7 @@ async fn collaborators_body( |
| 300 | 288 | if is_error { |
| 301 | 289 | alert(message: text) |
| 302 | 290 | } else { |
| 303 | | - <section class="card notice" role="status">(text)</section> |
| 291 | + <p class="state" role="status">(text)</p> |
| 304 | 292 | } |
| 305 | 293 | } |
| 306 | 294 | collaborators_pane(lang: lang, rows: rows, role_action: role_action, |
| | @@ -36,6 +36,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 36 | 36 | use crate::pages::repo_settings::settings_frame; |
| 37 | 37 | use crate::pages::repo_settings_live::settings_head; |
| 38 | 38 | use crate::state::AppState; |
| 39 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 39 | 40 | use crate::views::{ |
| 40 | 41 | alert, enc, now_unix, rel_time_or_never, relative_time, shell, user_facing_message, |
| 41 | 42 | }; |
| | @@ -404,11 +405,11 @@ async fn frame_top( |
| 404 | 405 | if is_error { |
| 405 | 406 | alert(message: text) |
| 406 | 407 | } else { |
| 407 | | - <section class="card notice" role="status">(text)</section> |
| 408 | + <p class="state" role="status">(text)</p> |
| 408 | 409 | } |
| 409 | 410 | } |
| 410 | 411 | if archived { |
| 411 | | - <section class="card notice" role="status">(g::t(lang, K::ArchivedNotice))</section> |
| 412 | + <p class="state" role="status">(g::t(lang, K::ArchivedNotice))</p> |
| 412 | 413 | } |
| 413 | 414 | (child) |
| 414 | 415 | ) |
| | @@ -421,6 +422,7 @@ async fn frame_top( |
| 421 | 422 | async fn mirror_form( |
| 422 | 423 | action: String, |
| 423 | 424 | csrf: String, |
| 425 | + prefix: &'static str, |
| 424 | 426 | pull: bool, |
| 425 | 427 | current_url: String, |
| 426 | 428 | url: String, |
| | @@ -448,8 +450,12 @@ async fn mirror_form( |
| 448 | 450 | } else { |
| 449 | 451 | g::t(lang, K::SecretUnset) |
| 450 | 452 | }; |
| 453 | + let url_id = format!("{prefix}-url"); |
| 454 | + let username_id = format!("{prefix}-username"); |
| 455 | + let secret_id = format!("{prefix}-secret"); |
| 456 | + let interval_id = format!("{prefix}-interval"); |
| 451 | 457 | Ok(view! { |
| 452 | | - <form method="post" action=(action.as_str()) class="stack mirror-form"> |
| 458 | + <form method="post" action=(action.as_str()) class="fields mirror-form"> |
| 453 | 459 | if let Some(message) = error { |
| 454 | 460 | alert(message: message.as_str()) |
| 455 | 461 | } |
| | @@ -458,41 +464,39 @@ async fn mirror_form( |
| 458 | 464 | <input type="hidden" name="direction" value=(direction)> |
| 459 | 465 | } |
| 460 | 466 | if !current_url.is_empty() { |
| 461 | | - <p>(g::t(lang, K::CurrentUrl))" "<code>(current_url.as_str())</code></p> |
| 467 | + <p class="state">(g::t(lang, K::CurrentUrl))" "<code>(current_url.as_str())</code></p> |
| 462 | 468 | } |
| 463 | | - <label> |
| 464 | | - <span>(url_label)</span> |
| 465 | | - <input type="url" name="url" value=(url.as_str()) autocomplete="off" spellcheck="false" required=(current_url.is_empty())> |
| 466 | | - </label> |
| 467 | | - <p class="muted small">(url_hint)</p> |
| 468 | | - <label> |
| 469 | | - <span>(g::t(lang, K::UsernameOptional))</span> |
| 470 | | - <input type="text" name="username" value=(username.as_str()) autocomplete="off" maxlength="255"> |
| 471 | | - </label> |
| 472 | | - <label> |
| 473 | | - <span>(g::t(lang, K::SecretOptional))</span> |
| 474 | | - <input type="password" name="secret" autocomplete="new-password" maxlength="1024"> |
| 475 | | - </label> |
| 476 | | - <p class="muted small">(secret_hint)</p> |
| 469 | + <div class="field"> |
| 470 | + <label for=(url_id.as_str())>(url_label)</label> |
| 471 | + <input id=(url_id.as_str()) type="url" name="url" value=(url.as_str()) autocomplete="off" spellcheck="false" required=(current_url.is_empty())> |
| 472 | + <p class="hint">(url_hint)</p> |
| 473 | + </div> |
| 474 | + <div class="field"> |
| 475 | + <label for=(username_id.as_str())>(g::t(lang, K::UsernameOptional))</label> |
| 476 | + <input id=(username_id.as_str()) type="text" name="username" value=(username.as_str()) autocomplete="off" maxlength="255"> |
| 477 | + </div> |
| 478 | + <div class="field"> |
| 479 | + <label for=(secret_id.as_str())>(g::t(lang, K::SecretOptional))</label> |
| 480 | + <input id=(secret_id.as_str()) type="password" name="secret" autocomplete="new-password" maxlength="1024"> |
| 481 | + <p class="hint">(secret_hint)</p> |
| 482 | + </div> |
| 477 | 483 | if has_secret { |
| 478 | | - <label class="inline"> |
| 484 | + <label class="switch"> |
| 479 | 485 | <input type="checkbox" name="clear_secret" value="on"> |
| 480 | 486 | <span>(g::t(lang, K::ClearSecret))</span> |
| 481 | 487 | </label> |
| 482 | 488 | } |
| 483 | | - <label> |
| 484 | | - <span>(g::t(lang, K::IntervalField))</span> |
| 485 | | - <input type="number" name="interval" value=(interval.as_str()) min="0" max="525600" step="1"> |
| 486 | | - </label> |
| 489 | + <div class="field"> |
| 490 | + <label for=(interval_id.as_str())>(g::t(lang, K::IntervalField))</label> |
| 491 | + <input id=(interval_id.as_str()) type="number" name="interval" value=(interval.as_str()) min="0" max="525600" step="1"> |
| 492 | + </div> |
| 487 | 493 | if let Some(on) = enabled { |
| 488 | | - <label class="inline"> |
| 494 | + <label class="switch"> |
| 489 | 495 | <input type="checkbox" name="enabled" value="on" checked=(on)> |
| 490 | 496 | <span>(g::t(lang, K::EnabledField))</span> |
| 491 | 497 | </label> |
| 492 | 498 | } |
| 493 | | - <div> |
| 494 | | - <button type="submit" class="primary">(submit)</button> |
| 495 | | - </div> |
| 499 | + <button type="submit" class="primary">(submit)</button> |
| 496 | 500 | </form> |
| 497 | 501 | }) |
| 498 | 502 | } |
| | @@ -518,94 +522,76 @@ async fn mirrors_list_body( |
| 518 | 522 | let push_open = draft.error.is_some(); |
| 519 | 523 | Ok(view! { |
| 520 | 524 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, |
| 521 | | - <section class="card rows-pane"> |
| 522 | | - if !archived { |
| 523 | | - if let Some(pull) = pull_form { |
| 524 | | - <div class="row-line" id="add-pull-mirror"> |
| 525 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 526 | | - <div class="row-main"> |
| 527 | | - <h2 class="row-title">(g::t(lang, K::AddPullMirror))</h2> |
| 528 | | - <p class="row-status">(g::t(lang, K::MirrorsIntro))</p> |
| 529 | | - if empty { |
| 530 | | - <p class="row-status">(g::t(lang, K::NoMirrors))</p> |
| 531 | | - } else { |
| 532 | | - <p class="row-status">(g::t(lang, K::AddPullIntro))</p> |
| 533 | | - } |
| 534 | | - </div> |
| 535 | | - <details class="row-action" open=(pull_open)> |
| 536 | | - <summary>(g::t(lang, K::AddPullMirror))</summary> |
| 537 | | - <div class="row-panel"> |
| 538 | | - mirror_form(action: add_action.clone(), csrf: csrf.clone(), pull: true, current_url: String::new(), |
| 539 | | - url: pull.url, username: pull.username, has_secret: false, interval: pull.interval, |
| 540 | | - enabled: None, error: pull.error, submit: g::t(lang, K::AddPullMirror), direction: "pull", lang: lang) |
| 541 | | - </div> |
| 542 | | - </details> |
| 543 | | - </div> |
| 544 | | - } |
| 545 | | - <div class="row-line" id="add-push-mirror"> |
| 546 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 547 | | - <div class="row-main"> |
| 548 | | - <h2 class="row-title">(g::t(lang, K::AddPushMirror))</h2> |
| 549 | | - if empty && !can_pull { |
| 550 | | - <p class="row-status">(g::t(lang, K::NoMirrors))</p> |
| 551 | | - } else { |
| 552 | | - <p class="row-status">(g::t(lang, K::AddPushIntro))</p> |
| 553 | | - } |
| 554 | | - </div> |
| 555 | | - <details class="row-action" open=(push_open)> |
| 556 | | - <summary>(g::t(lang, K::AddPushMirror))</summary> |
| 557 | | - <div class="row-panel"> |
| 558 | | - mirror_form(action: add_action.clone(), csrf: csrf.clone(), pull: false, current_url: String::new(), |
| 559 | | - url: draft.url, username: draft.username, has_secret: false, interval: draft.interval, |
| 560 | | - enabled: None, error: draft.error, submit: g::t(lang, K::AddPushMirror), direction: "", lang: lang) |
| 561 | | - </div> |
| 562 | | - </details> |
| 563 | | - </div> |
| 564 | | - } |
| 525 | + <section class="sec"> |
| 526 | + <h2>(g::t(lang, K::Mirrors))</h2> |
| 565 | 527 | if archived && empty { |
| 566 | | - <div class="row-line"> |
| 567 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/><path d="M3 21v-5h5"/></svg> |
| 568 | | - <div class="row-main"> |
| 569 | | - <h2 class="row-title">(g::t(lang, K::NoMirrors))</h2> |
| 570 | | - </div> |
| 571 | | - </div> |
| 528 | + <p class="state">(g::t(lang, K::NoMirrors))</p> |
| 572 | 529 | } |
| 573 | 530 | for row in rows.iter() { |
| 574 | | - <div class="row-line"> |
| 575 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/><path d="M3 21v-5h5"/></svg> |
| 576 | | - <div class="row-main"> |
| 577 | | - <strong class="row-name"> |
| 578 | | - <span class=(row.dot_class) role="img" aria-label=(row.status_text) title=(row.status_text)></span> |
| 579 | | - <a class="mirror-url" href=(row.href.as_str())>(row.url.as_str())</a> |
| 580 | | - </strong> |
| 581 | | - <p class="row-status"> |
| 582 | | - (row.direction)" · "(row.interval.as_str()) |
| 583 | | - if !row.enabled { |
| 584 | | - " · "(adm::t(lang, adm::K::Disabled)) |
| 585 | | - } |
| 586 | | - " · " |
| 587 | | - if row.last_sync_at.is_empty() { |
| 588 | | - (g::t(lang, K::StatusNotRun)) |
| 589 | | - } else { |
| 590 | | - (row.sync_prefix)<time data-rel="true" datetime=(row.last_sync_at.as_str()) title=(row.last_sync.as_str())>(row.last_sync_rel.as_str())</time>(row.sync_suffix) |
| 591 | | - } |
| 592 | | - </p> |
| 531 | + <div class="line" data-kb-row=""> |
| 532 | + <span class="name"><span class=(row.dot_class) role="img" aria-label=(row.status_text) title=(row.status_text)></span> <a class="mirror-url" href=(row.href.as_str())>(row.url.as_str())</a></span> |
| 533 | + <span class="val"> |
| 534 | + (row.direction)" · "(row.interval.as_str()) |
| 535 | + if !row.enabled { |
| 536 | + " · "(adm::t(lang, adm::K::Disabled)) |
| 537 | + } |
| 538 | + " · " |
| 539 | + if row.last_sync_at.is_empty() { |
| 540 | + (g::t(lang, K::StatusNotRun)) |
| 541 | + } else { |
| 542 | + (row.sync_prefix)<time data-rel="true" datetime=(row.last_sync_at.as_str()) title=(row.last_sync.as_str())>(row.last_sync_rel.as_str())</time>(row.sync_suffix) |
| 543 | + } |
| 544 | + </span> |
| 545 | + </div> |
| 546 | + if !archived || !row.error.is_empty() { |
| 547 | + <div class="acts"> |
| 548 | + if !archived { |
| 549 | + post_act(label: g::t(lang, K::SyncNow), action: row.sync_action.as_str(), csrf: csrf.as_str()) |
| 550 | + } |
| 593 | 551 | if !row.error.is_empty() { |
| 594 | | - <details class="mirror-failure"> |
| 595 | | - <summary>(g::t(lang, K::ErrorLabel))</summary> |
| 552 | + reveal(label: g::t(lang, K::ErrorLabel), |
| 596 | 553 | <pre class="mirror-error">(row.error.as_str())</pre> |
| 597 | | - </details> |
| 554 | + ) |
| 598 | 555 | } |
| 599 | 556 | </div> |
| 600 | | - if !archived { |
| 601 | | - <form method="post" action=(row.sync_action.as_str()) class="row-form"> |
| 602 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 603 | | - <button type="submit" class="hook-sync">(g::t(lang, K::SyncNow))</button> |
| 604 | | - </form> |
| 605 | | - } |
| 606 | | - </div> |
| 557 | + } |
| 607 | 558 | } |
| 608 | 559 | </section> |
| 560 | + if !archived { |
| 561 | + if let Some(pull) = pull_form { |
| 562 | + <section class="sec" id="add-pull-mirror"> |
| 563 | + <h2>(g::t(lang, K::AddPullMirror))</h2> |
| 564 | + <p class="hint">(g::t(lang, K::MirrorsIntro))</p> |
| 565 | + if empty { |
| 566 | + <p class="state">(g::t(lang, K::NoMirrors))</p> |
| 567 | + } else { |
| 568 | + <p class="hint">(g::t(lang, K::AddPullIntro))</p> |
| 569 | + } |
| 570 | + <div class="acts"> |
| 571 | + reveal(label: g::t(lang, K::AddPullMirror), open: pull_open, |
| 572 | + mirror_form(action: add_action.clone(), csrf: csrf.clone(), prefix: "pull-mirror", pull: true, current_url: String::new(), |
| 573 | + url: pull.url, username: pull.username, has_secret: false, interval: pull.interval, |
| 574 | + enabled: None, error: pull.error, submit: g::t(lang, K::AddPullMirror), direction: "pull", lang: lang) |
| 575 | + ) |
| 576 | + </div> |
| 577 | + </section> |
| 578 | + } |
| 579 | + <section class="sec" id="add-push-mirror"> |
| 580 | + <h2>(g::t(lang, K::AddPushMirror))</h2> |
| 581 | + if empty && !can_pull { |
| 582 | + <p class="state">(g::t(lang, K::NoMirrors))</p> |
| 583 | + } else { |
| 584 | + <p class="hint">(g::t(lang, K::AddPushIntro))</p> |
| 585 | + } |
| 586 | + <div class="acts"> |
| 587 | + reveal(label: g::t(lang, K::AddPushMirror), open: push_open, |
| 588 | + mirror_form(action: add_action.clone(), csrf: csrf.clone(), prefix: "push-mirror", pull: false, current_url: String::new(), |
| 589 | + url: draft.url, username: draft.username, has_secret: false, interval: draft.interval, |
| 590 | + enabled: None, error: draft.error, submit: g::t(lang, K::AddPushMirror), direction: "", lang: lang) |
| 591 | + ) |
| 592 | + </div> |
| 593 | + </section> |
| 594 | + } |
| 609 | 595 | ) |
| 610 | 596 | }) |
| 611 | 597 | } |
| | @@ -828,46 +814,37 @@ async fn mirror_body( |
| 828 | 814 | let current_url = redacted_url(&mirror.url); |
| 829 | 815 | Ok(view! { |
| 830 | 816 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, |
| 831 | | - <section class="card"> |
| 832 | | - <h2>(mirror_kind(lang, mirror.direction))</h2> |
| 833 | | - if archived { |
| 834 | | - <p><code>(current_url.as_str())</code></p> |
| 835 | | - <p class="muted small">(g::t(lang, K::LastSync))" " rel_time_or_never(lang: lang, stamp: mirror.last_sync_at.as_deref())</p> |
| 817 | + if archived { |
| 818 | + <section class="sec"> |
| 819 | + <h2>(mirror_kind(lang, mirror.direction))</h2> |
| 820 | + <p class="state"><code>(current_url.as_str())</code></p> |
| 821 | + <p class="hint">(g::t(lang, K::LastSync))" " rel_time_or_never(lang: lang, stamp: mirror.last_sync_at.as_deref())</p> |
| 836 | 822 | if let Some(error) = mirror.last_error.clone() { |
| 837 | 823 | <pre class="mirror-error">(error.as_str())</pre> |
| 838 | 824 | } |
| 839 | | - } else { |
| 840 | | - mirror_form(action: edit_action.clone(), csrf: csrf.clone(), pull: pull, |
| 825 | + </section> |
| 826 | + } else { |
| 827 | + <section class="sec"> |
| 828 | + <h2>(mirror_kind(lang, mirror.direction))</h2> |
| 829 | + mirror_form(action: edit_action.clone(), csrf: csrf.clone(), prefix: "edit-mirror", pull: pull, |
| 841 | 830 | current_url: current_url.clone(), url: String::new(), username: draft.username, |
| 842 | 831 | has_secret: mirror.has_secret, interval: draft.interval, enabled: Some(draft.enabled), |
| 843 | 832 | error: draft.error, submit: g::t(lang, K::SaveMirror), direction: "", lang: lang) |
| 844 | | - } |
| 845 | | - </section> |
| 833 | + </section> |
| 834 | + } |
| 846 | 835 | if !archived { |
| 847 | | - <section class="card"> |
| 836 | + <section class="sec"> |
| 848 | 837 | <h2>(g::t(lang, K::SyncHeading))</h2> |
| 849 | | - <p class="muted small">(g::t(lang, K::SyncIntro))</p> |
| 850 | | - <form method="post" action=(sync_action.as_str()) class="inline-form"> |
| 851 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 852 | | - <button type="submit">(g::t(lang, K::SyncNow))</button> |
| 853 | | - </form> |
| 838 | + <p class="hint">(g::t(lang, K::SyncIntro))</p> |
| 839 | + <div class="acts"> |
| 840 | + post_act(label: g::t(lang, K::SyncNow), action: sync_action.as_str(), csrf: csrf.as_str()) |
| 841 | + </div> |
| 854 | 842 | </section> |
| 855 | | - <section class="card"> |
| 843 | + <section class="sec"> |
| 856 | 844 | <h2>(g::t(lang, K::DeleteMirror))</h2> |
| 857 | | - <p class="muted small">(delete_text)</p> |
| 858 | | - <div> |
| 859 | | - <details class="confirm-inline"> |
| 860 | | - <summary class="button danger">(g::t(lang, K::DeleteMirror))</summary> |
| 861 | | - <div class="confirm-pop"> |
| 862 | | - <p>(g::t(lang, K::DeleteConfirm))</p> |
| 863 | | - <form method="post" action=(delete_action.as_str())> |
| 864 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 865 | | - <input type="hidden" name="confirm" value="on"> |
| 866 | | - <button type="submit" class="danger">(g::t(lang, K::DeleteMirror))</button> |
| 867 | | - <button type="button" data-close-details="">(g::t(lang, K::Cancel))</button> |
| 868 | | - </form> |
| 869 | | - </div> |
| 870 | | - </details> |
| 845 | + <p class="hint">(delete_text)</p> |
| 846 | + <div class="acts"> |
| 847 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteMirror), action: delete_action.as_str(), csrf: csrf.as_str(), fields: vec![("confirm".to_owned(), "on".to_owned())], note: Some(g::t(lang, K::DeleteConfirm).to_owned())) |
| 871 | 848 | </div> |
| 872 | 849 | </section> |
| 873 | 850 | } |
| | @@ -25,6 +25,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 25 | 25 | use crate::pages::repo_settings::settings_frame; |
| 26 | 26 | use crate::pages::repo_settings_live::settings_head; |
| 27 | 27 | use crate::state::AppState; |
| 28 | +use crate::views::parts::reveal; |
| 28 | 29 | use crate::views::{alert, shell}; |
| 29 | 30 | |
| 30 | 31 | path_param!(owner); |
| | @@ -125,61 +126,49 @@ async fn rename_body( |
| 125 | 126 | repo_head(head: head) |
| 126 | 127 | settings_frame(lang: lang, title: nav_title, current: "rename", can_delete: can_delete, |
| 127 | 128 | if let Some(key) = notice { |
| 128 | | - <section class="card notice" role="status">(g::t(lang, key))</section> |
| 129 | + <p class="state" role="status">(g::t(lang, key))</p> |
| 129 | 130 | } |
| 130 | | - <section class="card rows-pane"> |
| 131 | | - <div class="row-line"> |
| 132 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 20h4L19 9l-4-4L4 16z"/><path d="M14 6l4 4"/></svg> |
| 133 | | - <div class="row-main"> |
| 134 | | - <h2 class="row-title">(g::t(lang, K::RenameRepo))</h2> |
| 135 | | - <p class="row-status">(g::t(lang, K::RenameHelp))</p> |
| 136 | | - </div> |
| 137 | | - <details class="row-action" open=(rename_open)> |
| 138 | | - <summary>(g::t(lang, K::RenameRepo))</summary> |
| 139 | | - <div class="row-panel"> |
| 140 | | - if let Some(message) = rename_error { |
| 131 | + <section class="sec"> |
| 132 | + <h2>(g::t(lang, K::RenameRepo))</h2> |
| 133 | + <p class="hint">(g::t(lang, K::RenameHelp))</p> |
| 134 | + <div class="acts"> |
| 135 | + reveal(label: g::t(lang, K::RenameRepo), open: rename_open, |
| 136 | + if let Some(message) = rename_error { |
| 137 | + alert(message: message.as_str()) |
| 138 | + } |
| 139 | + <form method="post" action=(rename_action.as_str()) class="fields"> |
| 140 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 141 | + <div class="field"> |
| 142 | + <label for="rename-name">(g::t(lang, K::NewName))</label> |
| 143 | + <input id="rename-name" type="text" name="name" value=(rename_name.as_str()) autocomplete="off" spellcheck="false" required=(true)> |
| 144 | + </div> |
| 145 | + <button type="submit" class="primary">(g::t(lang, K::RenameRepo))</button> |
| 146 | + </form> |
| 147 | + ) |
| 148 | + </div> |
| 149 | + </section> |
| 150 | + if can_delete { |
| 151 | + <section class="sec"> |
| 152 | + <h2>(g::t(lang, K::TransferRepo))</h2> |
| 153 | + <p class="hint">(g::t(lang, K::TransferHelp)) <a href=(status_href.as_str())>(g::t(lang, K::PendingTransfers))</a></p> |
| 154 | + <div class="acts"> |
| 155 | + reveal(label: g::t(lang, K::TransferRepo), open: transfer_open, |
| 156 | + if let Some(message) = transfer_error { |
| 141 | 157 | alert(message: message.as_str()) |
| 142 | 158 | } |
| 143 | | - <form method="post" action=(rename_action.as_str()) class="stack"> |
| 159 | + <form method="post" action=(transfer_action.as_str()) class="fields"> |
| 144 | 160 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 145 | | - <label> |
| 146 | | - <span>(g::t(lang, K::NewName))</span> |
| 147 | | - <input type="text" name="name" value=(rename_name.as_str()) autocomplete="off" spellcheck="false" required=(true)> |
| 148 | | - </label> |
| 149 | | - <button type="submit">(g::t(lang, K::RenameRepo))</button> |
| 161 | + <div class="field"> |
| 162 | + <label for="transfer-owner">(g::t(lang, K::NewOwnerLabel))</label> |
| 163 | + <input id="transfer-owner" type="text" name="new_owner" value=(transfer_owner.as_str()) autocomplete="off" spellcheck="false" required=(true)> |
| 164 | + </div> |
| 165 | + <div class="field"> |
| 166 | + <label for="transfer-confirm">(g::t(lang, K::TypeToConfirmBefore))<code>(title.clone())</code>(g::t(lang, K::TypeToConfirmAfter))</label> |
| 167 | + <input id="transfer-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 168 | + </div> |
| 169 | + <button type="submit" class="act danger">(g::t(lang, K::TransferRepo))</button> |
| 150 | 170 | </form> |
| 151 | | - </div> |
| 152 | | - </details> |
| 153 | | - </div> |
| 154 | | - </section> |
| 155 | | - if can_delete { |
| 156 | | - <section class="card rows-pane"> |
| 157 | | - <div class="row-line"> |
| 158 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M7 7h11l-3-3M17 17H6l3 3"/></svg> |
| 159 | | - <div class="row-main"> |
| 160 | | - <h2 class="row-title">(g::t(lang, K::TransferRepo))</h2> |
| 161 | | - <p class="row-status">(g::t(lang, K::TransferHelp))<a href=(status_href.as_str())>(g::t(lang, K::PendingTransfers))</a></p> |
| 162 | | - </div> |
| 163 | | - <details class="row-action danger" open=(transfer_open)> |
| 164 | | - <summary>(g::t(lang, K::TransferRepo))</summary> |
| 165 | | - <div class="row-panel"> |
| 166 | | - if let Some(message) = transfer_error { |
| 167 | | - alert(message: message.as_str()) |
| 168 | | - } |
| 169 | | - <form method="post" action=(transfer_action.as_str()) class="stack"> |
| 170 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 171 | | - <label> |
| 172 | | - <span>(g::t(lang, K::NewOwnerLabel))</span> |
| 173 | | - <input type="text" name="new_owner" value=(transfer_owner.as_str()) autocomplete="off" spellcheck="false" required=(true)> |
| 174 | | - </label> |
| 175 | | - <label> |
| 176 | | - <span>(g::t(lang, K::TypeToConfirmBefore))<code>(title.clone())</code>(g::t(lang, K::TypeToConfirmAfter))</span> |
| 177 | | - <input type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 178 | | - </label> |
| 179 | | - <button type="submit" class="danger">(g::t(lang, K::TransferRepo))</button> |
| 180 | | - </form> |
| 181 | | - </div> |
| 182 | | - </details> |
| 171 | + ) |
| 183 | 172 | </div> |
| 184 | 173 | </section> |
| 185 | 174 | } |
| | @@ -18,11 +18,13 @@ use crate::audit::{self, Actor, Target}; |
| 18 | 18 | use crate::auth::{require_csrf, require_user}; |
| 19 | 19 | use crate::i18n::repo_admin::{self as g, K}; |
| 20 | 20 | use crate::i18n::{self, Lang}; |
| 21 | +use crate::pages::passkeys; |
| 21 | 22 | use crate::pages::repo::repo_head; |
| 22 | 23 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 23 | 24 | use crate::pages::repo_settings::settings_frame; |
| 24 | 25 | use crate::pages::repo_settings_live::settings_head; |
| 25 | 26 | use crate::state::AppState; |
| 27 | +use crate::views::parts::{confirm_act, reveal}; |
| 26 | 28 | use crate::views::{alert, enc, rel_time, shell}; |
| 27 | 29 | |
| 28 | 30 | path_param!(owner); |
| | @@ -166,19 +168,20 @@ async fn frame_top( |
| 166 | 168 | if is_error { |
| 167 | 169 | alert(message: text) |
| 168 | 170 | } else { |
| 169 | | - <section class="card notice" role="status">(text)</section> |
| 171 | + <p class="state" role="status">(text)</p> |
| 170 | 172 | } |
| 171 | 173 | } |
| 172 | 174 | if archived { |
| 173 | | - <section class="card notice" role="status">(g::t(lang, K::ArchivedSecrets))</section> |
| 175 | + <p class="state" role="status">(g::t(lang, K::ArchivedSecrets))</p> |
| 174 | 176 | } |
| 175 | 177 | (child) |
| 176 | 178 | ) |
| 177 | 179 | }) |
| 178 | 180 | } |
| 179 | 181 | |
| 180 | | -/// The add row, then one row per secret with its delete button. Archived repos show no add row. |
| 181 | | -/// `draft_name` and `error` come from a refused add; the value is never passed back, so the textarea is always empty. |
| 182 | +/// The add topic (a form that opens in place, closed to archived repos), then the list of secret |
| 183 | +/// names: each row opens its delete action. `draft_name` and `error` come from a refused add; the |
| 184 | +/// value is never passed back, so the textarea is always empty. |
| 182 | 185 | #[component] |
| 183 | 186 | async fn secrets_body( |
| 184 | 187 | lang: Lang, |
| | @@ -196,69 +199,64 @@ async fn secrets_body( |
| 196 | 199 | let add_open = error.is_some(); |
| 197 | 200 | Ok(view! { |
| 198 | 201 | frame_top(lang: lang, head: head, title: title.clone(), notice: notice, archived: archived, |
| 199 | | - <section class="card rows-pane"> |
| 200 | | - if !archived { |
| 201 | | - <div class="row-line" id="add-secret"> |
| 202 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 203 | | - <div class="row-main"> |
| 204 | | - <h2 class="row-title">(g::t(lang, K::AddOrUpdate))</h2> |
| 205 | | - if rows.is_empty() { |
| 206 | | - <p class="row-status">(g::t(lang, K::NoSecrets))</p> |
| 207 | | - } else { |
| 208 | | - <p class="row-status">(g::t(lang, K::SecretsHelp))</p> |
| 202 | + if !archived { |
| 203 | + <section class="sec"> |
| 204 | + <h2>(g::t(lang, K::AddOrUpdate))</h2> |
| 205 | + <div class="acts"> |
| 206 | + reveal(label: g::t(lang, K::SaveSecret), id: Some("add-secret"), open: add_open, |
| 207 | + if let Some(message) = error { |
| 208 | + alert(message: message.as_str()) |
| 209 | 209 | } |
| 210 | | - </div> |
| 211 | | - <details class="row-action" open=(add_open)> |
| 212 | | - <summary>(g::t(lang, K::SaveSecret))</summary> |
| 213 | | - <div class="row-panel"> |
| 214 | | - if let Some(message) = error { |
| 215 | | - <p class="alert" role="alert">(message.as_str())</p> |
| 216 | | - } |
| 217 | | - <form method="post" action=(set_action.as_str()) class="stack"> |
| 218 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 219 | | - <label> |
| 220 | | - (g::t(lang, K::Name)) |
| 221 | | - <input type="text" name="name" value=(draft_name.as_str()) required=(true) maxlength="64" |
| 222 | | - pattern="[A-Z_][A-Z0-9_]{0,63}" autocomplete="off" spellcheck="false" |
| 223 | | - placeholder="DEPLOY_TOKEN"> |
| 224 | | - </label> |
| 225 | | - <label> |
| 226 | | - (g::t(lang, K::Value)) |
| 227 | | - <textarea name="value" required=(true) rows="6" autocomplete="off" spellcheck="false"></textarea> |
| 228 | | - </label> |
| 229 | | - <p class="muted small">(g::t(lang, K::SecretLimits))</p> |
| 230 | | - <div class="actions"> |
| 231 | | - <button type="submit" class="primary">(g::t(lang, K::SaveSecret))</button> |
| 232 | | - </div> |
| 233 | | - </form> |
| 234 | | - </div> |
| 235 | | - </details> |
| 236 | | - </div> |
| 237 | | - } |
| 238 | | - if archived && rows.is_empty() { |
| 239 | | - <div class="row-line"> |
| 240 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg> |
| 241 | | - <div class="row-main"> |
| 242 | | - <h2 class="row-title">(g::t(lang, K::NoSecrets))</h2> |
| 243 | | - </div> |
| 244 | | - </div> |
| 245 | | - } |
| 246 | | - for row in rows.iter() { |
| 247 | | - <div class="row-line"> |
| 248 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg> |
| 249 | | - <div class="row-main"> |
| 250 | | - <strong class="row-name"><code>(row.name.as_str())</code></strong> |
| 251 | | - <p class="row-status">rel_time(lang: lang, stamp: row.updated_at.as_str())</p> |
| 252 | | - </div> |
| 253 | | - if !archived { |
| 254 | | - <form method="post" action=(delete_action.as_str()) class="row-form"> |
| 210 | + <form method="post" action=(set_action.as_str()) class="fields"> |
| 255 | 211 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 256 | | - <input type="hidden" name="name" value=(row.name.as_str())> |
| 257 | | - <button type="submit" class="danger">(g::t(lang, K::Delete))</button> |
| 212 | + <div class="field"> |
| 213 | + <label for="secret-name">(g::t(lang, K::Name))</label> |
| 214 | + <input id="secret-name" type="text" name="name" value=(draft_name.as_str()) required=(true) maxlength="64" |
| 215 | + pattern="[A-Z_][A-Z0-9_]{0,63}" autocomplete="off" spellcheck="false" |
| 216 | + placeholder="DEPLOY_TOKEN"> |
| 217 | + </div> |
| 218 | + <div class="field"> |
| 219 | + <label for="secret-value">(g::t(lang, K::Value))</label> |
| 220 | + <textarea id="secret-value" name="value" required=(true) rows="6" autocomplete="off" spellcheck="false"></textarea> |
| 221 | + <p class="hint">(g::t(lang, K::SecretLimits))</p> |
| 222 | + </div> |
| 223 | + <button type="submit" class="primary">(g::t(lang, K::SaveSecret))</button> |
| 258 | 224 | </form> |
| 259 | | - } |
| 225 | + ) |
| 260 | 226 | </div> |
| 227 | + </section> |
| 228 | + } |
| 229 | + <section class="sec"> |
| 230 | + <h2>(g::t(lang, K::Secrets))</h2> |
| 231 | + if rows.is_empty() { |
| 232 | + <p class="state">(g::t(lang, K::NoSecrets))</p> |
| 233 | + } else { |
| 234 | + <p class="hint">(g::t(lang, K::SecretsHelp))</p> |
| 261 | 235 | } |
| 236 | + <div> |
| 237 | + for row in rows.iter() { |
| 238 | + if archived { |
| 239 | + <div class="line"> |
| 240 | + <span class="name"><code>(row.name.as_str())</code></span> |
| 241 | + <span class="val">rel_time(lang: lang, stamp: row.updated_at.as_str())</span> |
| 242 | + </div> |
| 243 | + } else { |
| 244 | + <details class="row-open"> |
| 245 | + <summary class="line"> |
| 246 | + <span class="name"><code>(row.name.as_str())</code></span> |
| 247 | + <span class="val">rel_time(lang: lang, stamp: row.updated_at.as_str())</span> |
| 248 | + </summary> |
| 249 | + <div class="opened"> |
| 250 | + <div class="acts"> |
| 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 | + } |
| 258 | + } |
| 259 | + </div> |
| 262 | 260 | </section> |
| 263 | 261 | ) |
| 264 | 262 | }) |
| | @@ -23,6 +23,7 @@ use crate::pages::repo::repo_head; |
| 23 | 23 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 24 | 24 | use crate::pages::repo_settings_live::security_live_url; |
| 25 | 25 | use crate::state::AppState; |
| 26 | +use crate::views::parts::post_act; |
| 26 | 27 | use crate::views::{rel_time, shell}; |
| 27 | 28 | |
| 28 | 29 | path_param!(owner); |
| | @@ -58,7 +59,7 @@ struct AlertRow { |
| 58 | 59 | dismissed: bool, |
| 59 | 60 | dismiss_action: String, |
| 60 | 61 | reopen_action: String, |
| 61 | | - fields: Vec<(&'static str, String)>, |
| 62 | + fields: Vec<(String, String)>, |
| 62 | 63 | } |
| 63 | 64 | |
| 64 | 65 | fn title_of(ctx: &RepoCtx) -> String { |
| | @@ -101,10 +102,10 @@ fn row_of(alert: &Alert, title: &str, lang: Lang) -> AlertRow { |
| 101 | 102 | dismiss_action: format!("{base}/dismiss"), |
| 102 | 103 | reopen_action: format!("{base}/reopen"), |
| 103 | 104 | fields: vec![ |
| 104 | | - ("advisory", key.advisory_id.clone()), |
| 105 | | - ("ecosystem", key.ecosystem.clone()), |
| 106 | | - ("package", key.package.clone()), |
| 107 | | - ("version", key.version.clone()), |
| 105 | + ("advisory".to_owned(), key.advisory_id.clone()), |
| 106 | + ("ecosystem".to_owned(), key.ecosystem.clone()), |
| 107 | + ("package".to_owned(), key.package.clone()), |
| 108 | + ("version".to_owned(), key.version.clone()), |
| 108 | 109 | ], |
| 109 | 110 | } |
| 110 | 111 | } |
| | @@ -121,54 +122,39 @@ async fn security_body( |
| 121 | 122 | let open_count = rows.iter().filter(|r| r.open).count(); |
| 122 | 123 | Ok(view! { |
| 123 | 124 | repo_head(head: head) |
| 124 | | - <section class="card rows-pane"> |
| 125 | | - <div class="row-line"> |
| 126 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l8 3v6c0 4.5-3.4 8.3-8 9-4.6-.7-8-4.5-8-9V6z"/><path d="M9 12l2 2 4-4"/></svg> |
| 127 | | - <div class="row-main"> |
| 128 | | - <h2 class="row-title">(i18n::t(lang, Key::Security))</h2> |
| 129 | | - if !enabled { |
| 130 | | - <p class="row-status">(g::t(lang, K::SecurityOff))</p> |
| 131 | | - } else { |
| 132 | | - <p class="row-status">(g::dependencies_summary(lang, dependencies, open_count))</p> |
| 133 | | - <p class="row-status">(g::t(lang, K::LockfilesRead))</p> |
| 134 | | - } |
| 135 | | - if rows.is_empty() { |
| 136 | | - <p class="row-status">(g::t(lang, K::NoAlerts))</p> |
| 137 | | - } |
| 138 | | - </div> |
| 139 | | - </div> |
| 140 | | - for row in rows.iter() { |
| 141 | | - <div class="row-line" data-kb-row=""> |
| 142 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4l9 16H3z"/><path d="M12 10v4M12 17v.5"/></svg> |
| 143 | | - <div class="row-main"> |
| 144 | | - <strong class="row-name"><a href=(row.osv_href.as_str()) rel="noopener noreferrer">(row.advisory.as_str())</a></strong> |
| 145 | | - <p class="row-status"> |
| 146 | | - <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()) |
| 147 | | - </p> |
| 148 | | - <p class="row-status">(row.summary.as_str())</p> |
| 149 | | - </div> |
| 150 | | - if row.open { |
| 151 | | - <form method="post" action=(row.dismiss_action.as_str()) class="row-form"> |
| 152 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 153 | | - <input type="hidden" name="advisory" value=(row.fields[0].1.as_str())> |
| 154 | | - <input type="hidden" name="ecosystem" value=(row.fields[1].1.as_str())> |
| 155 | | - <input type="hidden" name="package" value=(row.fields[2].1.as_str())> |
| 156 | | - <input type="hidden" name="version" value=(row.fields[3].1.as_str())> |
| 157 | | - <button type="submit">(g::t(lang, K::Dismiss))</button> |
| 158 | | - </form> |
| 159 | | - } |
| 160 | | - if row.dismissed { |
| 161 | | - <form method="post" action=(row.reopen_action.as_str()) class="row-form"> |
| 162 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 163 | | - <input type="hidden" name="advisory" value=(row.fields[0].1.as_str())> |
| 164 | | - <input type="hidden" name="ecosystem" value=(row.fields[1].1.as_str())> |
| 165 | | - <input type="hidden" name="package" value=(row.fields[2].1.as_str())> |
| 166 | | - <input type="hidden" name="version" value=(row.fields[3].1.as_str())> |
| 167 | | - <button type="submit">(g::t(lang, K::Reopen))</button> |
| 168 | | - </form> |
| 169 | | - } |
| 170 | | - </div> |
| 125 | + <section class="sec"> |
| 126 | + <h2>(i18n::t(lang, Key::Security))</h2> |
| 127 | + if !enabled { |
| 128 | + <p class="state">(g::t(lang, K::SecurityOff))</p> |
| 129 | + } else { |
| 130 | + <p class="state">(g::dependencies_summary(lang, dependencies, open_count))</p> |
| 131 | + <p class="hint">(g::t(lang, K::LockfilesRead))</p> |
| 132 | + } |
| 133 | + if rows.is_empty() { |
| 134 | + <p class="state">(g::t(lang, K::NoAlerts))</p> |
| 171 | 135 | } |
| 136 | + <div> |
| 137 | + for row in rows.iter() { |
| 138 | + <details class="row-open" data-kb-row=""> |
| 139 | + <summary class="line"> |
| 140 | + <span class="name">(row.advisory.as_str())</span> |
| 141 | + <span class="val"><code>(row.package.as_str())</code> " " <code>(row.version.as_str())</code> " · " (row.severity.as_str()) " · " <span class=(row.state_class)>(row.state_text)</span> " · " rel_time(lang: lang, stamp: row.created_at.as_str())</span> |
| 142 | + </summary> |
| 143 | + <div class="opened"> |
| 144 | + <p class="hint"><a href=(row.osv_href.as_str()) rel="noopener noreferrer">(crate::pages::passkeys::s(lang, "Details on osv.dev", "osv.dev'de ayrıntılar"))</a></p> |
| 145 | + <p class="hint">(row.summary.as_str())</p> |
| 146 | + <div class="acts"> |
| 147 | + if row.open { |
| 148 | + post_act(label: g::t(lang, K::Dismiss), action: row.dismiss_action.as_str(), csrf: csrf.as_str(), fields: row.fields.clone()) |
| 149 | + } |
| 150 | + if row.dismissed { |
| 151 | + post_act(label: g::t(lang, K::Reopen), action: row.reopen_action.as_str(), csrf: csrf.as_str(), fields: row.fields.clone()) |
| 152 | + } |
| 153 | + </div> |
| 154 | + </div> |
| 155 | + </details> |
| 156 | + } |
| 157 | + </div> |
| 172 | 158 | </section> |
| 173 | 159 | }) |
| 174 | 160 | } |
| | @@ -40,6 +40,7 @@ use crate::pages::repo::repo_head; |
| 40 | 40 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 41 | 41 | use crate::pages::repo_settings_live::settings_head; |
| 42 | 42 | use crate::state::AppState; |
| 43 | +use crate::views::parts::{confirm_act, post_act}; |
| 43 | 44 | use crate::views::{alert, enc, shell}; |
| 44 | 45 | |
| 45 | 46 | path_param!(owner); |
| | @@ -254,9 +255,9 @@ async fn load_branch_names(ctx: &RepoCtx) -> Result<Vec<String>> { |
| 254 | 255 | pub async fn notice_banner_for(lang: Lang, title: Option<String>) -> Result<impl View> { |
| 255 | 256 | Ok(view! { |
| 256 | 257 | if let Some(title) = title { |
| 257 | | - <section class="card notice" role="status"> |
| 258 | + <p class="state" role="status"> |
| 258 | 259 | (g::t(lang, K::RepoDeletedBefore))<code>(title)</code>(g::t(lang, K::RepoDeletedAfter)) |
| 259 | | - </section> |
| 260 | + </p> |
| 260 | 261 | } |
| 261 | 262 | }) |
| 262 | 263 | } |
| | @@ -272,28 +273,27 @@ async fn danger_zone( |
| 272 | 273 | let action = format!("/{title}/settings/delete"); |
| 273 | 274 | let open = error.is_some(); |
| 274 | 275 | Ok(view! { |
| 275 | | - <section class="card rows-pane security-danger"> |
| 276 | | - <p class="security-danger-label">(g::t(lang, K::DangerZone))</p> |
| 277 | | - <div class="row-line"> |
| 278 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4l9 16H3z"/><path d="M12 10v4M12 17v.5"/></svg> |
| 279 | | - <div class="row-main"> |
| 280 | | - <h2 class="row-title">(g::t(lang, K::DeleteRepo))</h2> |
| 281 | | - <p class="row-status">(g::t(lang, K::DeleteRepoHelp))</p> |
| 282 | | - <p class="row-status">(g::t(lang, K::DeleteTrashHelp))</p> |
| 283 | | - </div> |
| 284 | | - <details class="row-action danger" open=(open)> |
| 285 | | - <summary>(g::t(lang, K::DeleteRepo))</summary> |
| 286 | | - <div class="row-panel"> |
| 276 | + <section class="sec"> |
| 277 | + <h2>(g::t(lang, K::DangerZone))</h2> |
| 278 | + <p class="hint">(g::t(lang, K::DeleteRepoHelp))</p> |
| 279 | + <p class="hint">(g::t(lang, K::DeleteTrashHelp))</p> |
| 280 | + <div class="acts"> |
| 281 | + <details class="reveal" open=(open)> |
| 282 | + <summary class="act danger">(g::t(lang, K::DeleteRepo))</summary> |
| 283 | + <div class="opened"> |
| 287 | 284 | if let Some(message) = error { |
| 288 | 285 | alert(message: message.as_str()) |
| 289 | 286 | } |
| 290 | | - <form method="post" action=(action) class="stack"> |
| 287 | + <form method="post" action=(action) class="fields"> |
| 291 | 288 | <input type="hidden" name="csrf" value=(csrf)> |
| 292 | | - <label> |
| 293 | | - <span>(g::t(lang, K::TypeToConfirmBefore))<code>(title.clone())</code>(g::t(lang, K::TypeToConfirmAfter))</span> |
| 294 | | - <input type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 295 | | - </label> |
| 296 | | - <button type="submit" class="danger">(g::t(lang, K::DeleteRepo))</button> |
| 289 | + <div class="field"> |
| 290 | + <label for="delete-confirm">(g::t(lang, K::TypeToConfirmBefore))<code>(title.clone())</code>(g::t(lang, K::TypeToConfirmAfter))</label> |
| 291 | + <input id="delete-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 292 | + </div> |
| 293 | + <div class="acts"> |
| 294 | + <button type="submit" class="act danger">(g::t(lang, K::DeleteRepo))</button> |
| 295 | + <button type="button" class="act quiet" data-close-details="">(g::t(lang, K::Cancel))</button> |
| 296 | + </div> |
| 297 | 297 | </form> |
| 298 | 298 | </div> |
| 299 | 299 | </details> |
| | @@ -302,8 +302,7 @@ async fn danger_zone( |
| 302 | 302 | }) |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | | -/// The settings frame: the sections in a left pane and the page's own content (its children) in a |
| 306 | | -/// right pane. Both fill the window below the repo head (see `.settings-layout` in `_lang_browse.scss`). |
| 305 | +/// The settings frame: the second-level links (`.sub`) above the page's own content (its children). |
| 307 | 306 | /// `current` names the section shown (`general`, `branches`, `webhooks`, ...) and gets `aria-current`. |
| 308 | 307 | /// The General page's sections (`branches`, `discussions`, `danger`) are `?section=` links right after |
| 309 | 308 | /// General; the danger link is only for a viewer who may delete the repo (`can_delete`). |
| | @@ -337,8 +336,7 @@ pub async fn settings_frame( |
| 337 | 336 | let wiki = format!("/{title}/settings/wiki"); |
| 338 | 337 | let wiki_on = current == "wiki"; |
| 339 | 338 | Ok(view! { |
| 340 | | - <div class="settings-layout fit-pane"> |
| 341 | | - <nav class="settings-nav" aria-label=(g::t(lang, K::SettingsNavLabel))> |
| 339 | + <nav class="sub" aria-label=(g::t(lang, K::SettingsNavLabel))> |
| 342 | 340 | if general_on { |
| 343 | 341 | <a href=(general) aria-current="page">(g::t(lang, K::General))</a> |
| 344 | 342 | } else { |
| | @@ -392,10 +390,7 @@ pub async fn settings_frame( |
| 392 | 390 | <a href=(wiki)>(crate::i18n::code::t(lang, crate::i18n::code::K::TabWiki))</a> |
| 393 | 391 | } |
| 394 | 392 | </nav> |
| 395 | | - <div class="settings-main"> |
| 396 | | - (child) |
| 397 | | - </div> |
| 398 | | - </div> |
| 393 | + (child) |
| 399 | 394 | }) |
| 400 | 395 | } |
| 401 | 396 | |
| | @@ -440,95 +435,56 @@ async fn general_section( |
| 440 | 435 | }) |
| 441 | 436 | .collect(); |
| 442 | 437 | Ok(view! { |
| 443 | | - <form method="post" action=(general_action) class="card rows-pane"> |
| 444 | | - <label class="row-line row-field"> |
| 445 | | - <span class="row-main"> |
| 446 | | - <span class="row-title">(g::t(lang, K::Description))</span> |
| 447 | | - <span class="row-status">(g::t(lang, K::DescriptionHelp))</span> |
| 448 | | - </span> |
| 449 | | - <span class="row-control"> |
| 450 | | - <input type="text" name="description" value=(description) maxlength="350" autocomplete="off"> |
| 451 | | - </span> |
| 452 | | - </label> |
| 453 | | - if options.is_empty() { |
| 454 | | - <div class="row-line"> |
| 455 | | - <div class="row-main"> |
| 456 | | - <span class="row-title">(g::t(lang, K::DefaultBranch))</span> |
| 457 | | - <span class="row-status">(g::t(lang, K::NoBranchesYet))</span> |
| 458 | | - </div> |
| 438 | + <section class="sec"> |
| 439 | + <h2>(g::t(lang, K::General))</h2> |
| 440 | + <form method="post" action=(general_action) class="fields"> |
| 441 | + <div class="field"> |
| 442 | + <label for="repo-description">(g::t(lang, K::Description))</label> |
| 443 | + <input id="repo-description" type="text" name="description" value=(description) maxlength="350" autocomplete="off"> |
| 444 | + <p class="hint">(g::t(lang, K::DescriptionHelp))</p> |
| 459 | 445 | </div> |
| 460 | | - } else { |
| 461 | | - <label class="row-line row-field"> |
| 462 | | - <span class="row-main"> |
| 463 | | - <span class="row-title">(g::t(lang, K::DefaultBranch))</span> |
| 464 | | - </span> |
| 465 | | - <span class="row-control"> |
| 466 | | - <select name="default_branch"> |
| 446 | + if options.is_empty() { |
| 447 | + <p class="state">(g::t(lang, K::DefaultBranch)) ": " (g::t(lang, K::NoBranchesYet))</p> |
| 448 | + } else { |
| 449 | + <div class="field"> |
| 450 | + <label for="repo-default-branch">(g::t(lang, K::DefaultBranch))</label> |
| 451 | + <select id="repo-default-branch" name="default_branch"> |
| 467 | 452 | for option in options.iter() { |
| 468 | 453 | <option value=(option.0.as_str()) selected=(option.1)>(option.0.as_str())</option> |
| 469 | 454 | } |
| 470 | 455 | </select> |
| 471 | | - </span> |
| 472 | | - </label> |
| 473 | | - } |
| 474 | | - <div class="row-foot"> |
| 475 | | - <input type="hidden" name="csrf" value=(csrf.clone())> |
| 456 | + </div> |
| 457 | + } |
| 458 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 476 | 459 | <button type="submit" class="primary">(g::t(lang, K::SaveGeneral))</button> |
| 460 | + </form> |
| 461 | + </section> |
| 462 | + |
| 463 | + <section class="sec"> |
| 464 | + <h2>(g::t(lang, K::VisibilityHeading))</h2> |
| 465 | + <p class="state">(current_visibility)</p> |
| 466 | + <div class="acts"> |
| 467 | + confirm_act(lang: lang, label: flip_label, action: visibility_action.as_str(), csrf: csrf.as_str(), |
| 468 | + fields: vec![("visibility".to_owned(), flip_to.to_owned()), ("understand".to_owned(), "on".to_owned())], |
| 469 | + note: Some(flip_confirm.to_owned())) |
| 477 | 470 | </div> |
| 478 | | - </form> |
| 471 | + </section> |
| 479 | 472 | |
| 480 | | - <section class="card rows-pane"> |
| 481 | | - <div class="row-line"> |
| 482 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg> |
| 483 | | - <div class="row-main"> |
| 484 | | - <h2 class="row-title">(g::t(lang, K::VisibilityHeading))</h2> |
| 485 | | - <p class="row-status">(current_visibility)</p> |
| 473 | + <section class="sec"> |
| 474 | + <h2>(g::t(lang, K::ArchiveHeading))</h2> |
| 475 | + if archived { |
| 476 | + <p class="hint">(g::t(lang, K::ArchivedHelp))</p> |
| 477 | + <div class="acts"> |
| 478 | + post_act(label: g::t(lang, K::UnarchiveRepo), action: archive_action.as_str(), csrf: csrf.as_str(), |
| 479 | + fields: vec![("archived".to_owned(), "0".to_owned())]) |
| 486 | 480 | </div> |
| 487 | | - <details class="row-action"> |
| 488 | | - <summary>(flip_label)</summary> |
| 489 | | - <div class="row-panel"> |
| 490 | | - <p>(flip_confirm)</p> |
| 491 | | - <form method="post" action=(visibility_action) class="row-actions"> |
| 492 | | - <input type="hidden" name="csrf" value=(csrf.clone())> |
| 493 | | - <input type="hidden" name="visibility" value=(flip_to)> |
| 494 | | - <input type="hidden" name="understand" value="on"> |
| 495 | | - <button type="submit" class="danger">(flip_label)</button> |
| 496 | | - <button type="button" data-close-details="">(g::t(lang, K::Cancel))</button> |
| 497 | | - </form> |
| 498 | | - </div> |
| 499 | | - </details> |
| 500 | | - </div> |
| 501 | | - <div class="row-line"> |
| 502 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="5" rx="1"/><path d="M5 9v10h14V9M10 13h4"/></svg> |
| 503 | | - <div class="row-main"> |
| 504 | | - <h2 class="row-title">(g::t(lang, K::ArchiveHeading))</h2> |
| 505 | | - if archived { |
| 506 | | - <p class="row-status">(g::t(lang, K::ArchivedHelp))</p> |
| 507 | | - } else { |
| 508 | | - <p class="row-status">(g::t(lang, K::ArchiveHelp))</p> |
| 509 | | - } |
| 481 | + } else { |
| 482 | + <p class="hint">(g::t(lang, K::ArchiveHelp))</p> |
| 483 | + <div class="acts"> |
| 484 | + confirm_act(lang: lang, label: g::t(lang, K::ArchiveRepo), action: archive_action.as_str(), csrf: csrf.as_str(), |
| 485 | + fields: vec![("archived".to_owned(), "1".to_owned())], note: Some(g::t(lang, K::ArchiveConfirm).to_owned())) |
| 510 | 486 | </div> |
| 511 | | - if archived { |
| 512 | | - <form method="post" action=(archive_action.as_str()) class="row-form"> |
| 513 | | - <input type="hidden" name="csrf" value=(csrf.clone())> |
| 514 | | - <input type="hidden" name="archived" value="0"> |
| 515 | | - <button type="submit">(g::t(lang, K::UnarchiveRepo))</button> |
| 516 | | - </form> |
| 517 | | - } else { |
| 518 | | - <details class="row-action"> |
| 519 | | - <summary>(g::t(lang, K::ArchiveRepo))</summary> |
| 520 | | - <div class="row-panel"> |
| 521 | | - <p>(g::t(lang, K::ArchiveConfirm))</p> |
| 522 | | - <form method="post" action=(archive_action.as_str()) class="row-actions"> |
| 523 | | - <input type="hidden" name="csrf" value=(csrf.clone())> |
| 524 | | - <input type="hidden" name="archived" value="1"> |
| 525 | | - <button type="submit" class="danger">(g::t(lang, K::ArchiveRepo))</button> |
| 526 | | - <button type="button" data-close-details="">(g::t(lang, K::Cancel))</button> |
| 527 | | - </form> |
| 528 | | - </div> |
| 529 | | - </details> |
| 530 | | - } |
| 531 | | - </div> |
| 487 | + } |
| 532 | 488 | </section> |
| 533 | 489 | }) |
| 534 | 490 | } |
| | @@ -570,8 +526,8 @@ struct RulePill { |
| 570 | 526 | |
| 571 | 527 | /// The pills that describe a rule in its card summary. A rule that sets nothing gets one muted pill. |
| 572 | 528 | fn rule_pills(lang: Lang, rule: &BranchRule) -> Vec<RulePill> { |
| 573 | | - let warn = "rule-pill warn"; |
| 574 | | - let plain = "rule-pill"; |
| 529 | + let warn = "warn"; |
| 530 | + let plain = ""; |
| 575 | 531 | let mut pills = Vec::new(); |
| 576 | 532 | if rule.allow_force_push { |
| 577 | 533 | pills.push(pill(g::t(lang, K::ForcePushAllowed), warn)); |
| | @@ -598,10 +554,10 @@ fn rule_pills(lang: Lang, rule: &BranchRule) -> Vec<RulePill> { |
| 598 | 554 | pills.push(pill(g::t(lang, K::RuleChangesShort), plain)); |
| 599 | 555 | } |
| 600 | 556 | for check in &rule.required_checks { |
| 601 | | - pills.push(pill(&format!("\u{2713} {check}"), "rule-pill check")); |
| 557 | + pills.push(pill(&format!("\u{2713} {check}"), plain)); |
| 602 | 558 | } |
| 603 | 559 | if pills.is_empty() { |
| 604 | | - pills.push(pill(g::t(lang, K::RuleNoExtra), "rule-pill muted")); |
| 560 | + pills.push(pill(g::t(lang, K::RuleNoExtra), "muted")); |
| 605 | 561 | } |
| 606 | 562 | pills |
| 607 | 563 | } |
| | @@ -621,33 +577,10 @@ struct RuleCard { |
| 621 | 577 | draft: RuleDraft, |
| 622 | 578 | } |
| 623 | 579 | |
| 624 | | -/// One rule option as a row: a title with an optional muted line under it, and a toggle on the right. |
| 625 | | -#[component] |
| 626 | | -async fn switch_row( |
| 627 | | - name: String, |
| 628 | | - checked: bool, |
| 629 | | - title: String, |
| 630 | | - description: Option<String>, |
| 631 | | -) -> Result<impl View> { |
| 632 | | - Ok(view! { |
| 633 | | - <label class="row-line row-field"> |
| 634 | | - <span class="row-main"> |
| 635 | | - <span class="row-title">(title.as_str())</span> |
| 636 | | - if let Some(text) = description { |
| 637 | | - <span class="row-status">(text.as_str())</span> |
| 638 | | - } |
| 639 | | - </span> |
| 640 | | - <span class="row-control"> |
| 641 | | - <input type="checkbox" name=(name.as_str()) value="on" checked=(checked)> |
| 642 | | - </span> |
| 643 | | - </label> |
| 644 | | - }) |
| 645 | | -} |
| 646 | | - |
| 647 | | -/// The rule list: one bordered box with a row per rule, then a muted row for the default branch |
| 648 | | -/// when no rule covers it, then the New rule row last. A rule row opens with its rule's values, |
| 649 | | -/// and the row whose draft has an error opens with the draft instead. The New rule row opens with |
| 650 | | -/// the draft when no rule row takes it. The rows share one `name`, so opening one closes the rest. |
| 580 | +/// The rule list: a line per rule, then a muted line for the default branch when no rule covers it, |
| 581 | +/// then the New rule line last. A rule opens in place with its rule's values, and the rule whose |
| 582 | +/// draft has an error opens with the draft instead. The New rule line opens with the draft when no |
| 583 | +/// rule takes it. The rows share one `name`, so opening one closes the rest. |
| 651 | 584 | #[component] |
| 652 | 585 | async fn branch_rule_cards( |
| 653 | 586 | lang: Lang, |
| | @@ -662,47 +595,48 @@ async fn branch_rule_cards( |
| 662 | 595 | contexts: Vec<String>, |
| 663 | 596 | ) -> Result<impl View> { |
| 664 | 597 | Ok(view! { |
| 665 | | - <div class="rule-list"> |
| 598 | + <div> |
| 666 | 599 | for card in cards.iter() { |
| 667 | | - <details class="rule-row" name="branch-rule" open=(card.open)> |
| 668 | | - <summary> |
| 669 | | - <code class="rule-pattern">(card.draft.pattern.as_str())</code> |
| 670 | | - <span class="rule-pills"> |
| 600 | + <details class="row-open" name="branch-rule" open=(card.open)> |
| 601 | + <summary class="line"> |
| 602 | + <span class="name"><code>(card.draft.pattern.as_str())</code></span> |
| 603 | + <span class="val rule-pills"> |
| 671 | 604 | for pill in card.pills.iter() { |
| 672 | 605 | <span class=(pill.class)>(pill.text.as_str())</span> |
| 673 | 606 | } |
| 674 | 607 | </span> |
| 675 | | - <span class="rule-end"> |
| 676 | | - <span class="rule-edit">(g::t(lang, K::EditRule))</span> |
| 677 | | - <span class="rule-chevron" aria-hidden="true"></span> |
| 678 | | - </span> |
| 679 | 608 | </summary> |
| 680 | | - branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), |
| 681 | | - delete_action: delete_action.clone(), rule_id: Some(card.id.clone()), |
| 682 | | - draft: card.draft.clone(), contexts: contexts.clone()) |
| 609 | + <div class="opened"> |
| 610 | + branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), |
| 611 | + delete_action: delete_action.clone(), rule_id: Some(card.id.clone()), |
| 612 | + draft: card.draft.clone(), contexts: contexts.clone()) |
| 613 | + </div> |
| 683 | 614 | </details> |
| 684 | 615 | } |
| 685 | 616 | if builtin_row { |
| 686 | | - <div class="rule-builtin"> |
| 687 | | - <code class="rule-pattern">(default_branch.as_str())</code> |
| 688 | | - <span class="muted small">(g::t(lang, K::BuiltinRowText))</span> |
| 617 | + <div class="line"> |
| 618 | + <span class="name"><code>(default_branch.as_str())</code></span> |
| 619 | + <span class="val">(g::t(lang, K::BuiltinRowText))</span> |
| 689 | 620 | </div> |
| 690 | 621 | } |
| 691 | | - <details class="rule-row rule-new" name="branch-rule" open=(new_open)> |
| 692 | | - <summary>"+ "(g::t(lang, K::NewRule))</summary> |
| 693 | | - branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), |
| 694 | | - delete_action: delete_action.clone(), rule_id: None, |
| 695 | | - draft: new_draft, contexts: contexts.clone()) |
| 622 | + <details class="row-open" name="branch-rule" open=(new_open)> |
| 623 | + <summary class="line"> |
| 624 | + <span class="name">"+ "(g::t(lang, K::NewRule))</span> |
| 625 | + </summary> |
| 626 | + <div class="opened"> |
| 627 | + branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), |
| 628 | + delete_action: delete_action.clone(), rule_id: None, |
| 629 | + draft: new_draft, contexts: contexts.clone()) |
| 630 | + </div> |
| 696 | 631 | </details> |
| 697 | | - <p class="rule-pick muted">(passkeys::s(lang, "Pick a rule to edit it.", "Düzenlemek için bir kural seç."))</p> |
| 632 | + <p class="hint">(passkeys::s(lang, "Pick a rule to edit it.", "Düzenlemek için bir kural seç."))</p> |
| 698 | 633 | </div> |
| 699 | 634 | }) |
| 700 | 635 | } |
| 701 | 636 | |
| 702 | | -/// The rule form: the pattern, the pushes and merging switches side by side on wide screens, and |
| 703 | | -/// the checks. Saving an existing pattern updates its rule. An existing rule also gets a Remove |
| 704 | | -/// button. Its delete form is a sibling of the rule form, because forms cannot nest, and the button |
| 705 | | -/// submits it through its `form` attribute. |
| 637 | +/// The rule form: the pattern, the pushes and merging switches, and the checks, with the save action |
| 638 | +/// under them. Saving an existing pattern updates its rule. An existing rule also gets a Remove |
| 639 | +/// action, a confirm_act sibling of the rule form, because forms cannot nest. |
| 706 | 640 | #[component] |
| 707 | 641 | async fn branch_rule_form( |
| 708 | 642 | lang: Lang, |
| | @@ -725,87 +659,95 @@ async fn branch_rule_form( |
| 725 | 659 | required_checks, |
| 726 | 660 | error, |
| 727 | 661 | } = draft; |
| 728 | | - // The delete form's id and the rule id it posts, for an existing rule only. |
| 729 | | - let remove = rule_id.map(|id| (format!("remove-rule-{id}"), id)); |
| 662 | + // Field ids are per rule, so two open rule forms never share an id. |
| 663 | + let prefix = match &rule_id { |
| 664 | + Some(id) => format!("rule-{id}"), |
| 665 | + None => "rule-new".to_owned(), |
| 666 | + }; |
| 667 | + let pattern_id = format!("{prefix}-pattern"); |
| 668 | + let approvals_id = format!("{prefix}-approvals"); |
| 669 | + let checks_id = format!("{prefix}-checks"); |
| 730 | 670 | Ok(view! { |
| 731 | | - if let Some((remove_id, id)) = &remove { |
| 732 | | - <form method="post" action=(delete_action.as_str()) id=(remove_id.as_str())> |
| 733 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 734 | | - <input type="hidden" name="rule_id" value=(id.as_str())> |
| 735 | | - </form> |
| 736 | | - } |
| 737 | | - <form method="post" action=(save_action.as_str()) class="rule-form"> |
| 671 | + <form method="post" action=(save_action.as_str()) class="fields"> |
| 738 | 672 | if let Some(message) = error { |
| 739 | 673 | alert(message: message.as_str()) |
| 740 | 674 | } |
| 741 | 675 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 742 | | - <fieldset class="rule-section"> |
| 743 | | - <legend>(g::t(lang, K::SectionPattern))</legend> |
| 744 | | - <input type="text" name="pattern" value=(pattern.as_str()) aria-label=(g::t(lang, K::BranchPattern)) autocomplete="off" spellcheck="false" required=(true)> |
| 745 | | - <p class="muted small">(g::t(lang, K::PatternHelpA))<code>"*"</code>(g::t(lang, K::PatternHelpB))<code>"**"</code>(g::t(lang, K::PatternHelpC))<code>"/"</code>(g::t(lang, K::PatternHelpD))</p> |
| 676 | + <div class="field"> |
| 677 | + <label for=(pattern_id.as_str())>(g::t(lang, K::BranchPattern))</label> |
| 678 | + <input id=(pattern_id.as_str()) type="text" name="pattern" value=(pattern.as_str()) autocomplete="off" spellcheck="false" required=(true)> |
| 679 | + <p class="hint">(g::t(lang, K::PatternHelpA))<code>"*"</code>(g::t(lang, K::PatternHelpB))<code>"**"</code>(g::t(lang, K::PatternHelpC))<code>"/"</code>(g::t(lang, K::PatternHelpD))</p> |
| 680 | + </div> |
| 681 | + <fieldset class="rule-group"> |
| 682 | + <legend>(g::t(lang, K::SectionPushes))</legend> |
| 683 | + <label class="switch"> |
| 684 | + <input type="checkbox" name="allow_force_push" value="on" checked=(allow_force_push)> |
| 685 | + <span>(g::t(lang, K::AllowForcePush))</span> |
| 686 | + </label> |
| 687 | + <p class="hint">(g::t(lang, K::ForcePushDesc))</p> |
| 688 | + <label class="switch"> |
| 689 | + <input type="checkbox" name="allow_deletion" value="on" checked=(allow_deletion)> |
| 690 | + <span>(g::t(lang, K::AllowDeletion))</span> |
| 691 | + </label> |
| 692 | + <p class="hint">(g::t(lang, K::DeletionDesc))</p> |
| 693 | + <label class="switch"> |
| 694 | + <input type="checkbox" name="restrict_push" value="on" checked=(restrict_push)> |
| 695 | + <span>(g::t(lang, K::RestrictPushTitle))</span> |
| 696 | + </label> |
| 697 | + <p class="hint">(g::t(lang, K::RestrictPushDesc))</p> |
| 746 | 698 | </fieldset> |
| 747 | | - <div class="rule-pair"> |
| 748 | | - <fieldset class="rule-section"> |
| 749 | | - <legend>(g::t(lang, K::SectionPushes))</legend> |
| 750 | | - <div class="switch-list"> |
| 751 | | - switch_row(name: "allow_force_push".to_owned(), checked: allow_force_push, |
| 752 | | - title: g::t(lang, K::AllowForcePush).to_owned(), |
| 753 | | - description: Some(g::t(lang, K::ForcePushDesc).to_owned())) |
| 754 | | - switch_row(name: "allow_deletion".to_owned(), checked: allow_deletion, |
| 755 | | - title: g::t(lang, K::AllowDeletion).to_owned(), |
| 756 | | - description: Some(g::t(lang, K::DeletionDesc).to_owned())) |
| 757 | | - switch_row(name: "restrict_push".to_owned(), checked: restrict_push, |
| 758 | | - title: g::t(lang, K::RestrictPushTitle).to_owned(), |
| 759 | | - description: Some(g::t(lang, K::RestrictPushDesc).to_owned())) |
| 760 | | - </div> |
| 761 | | - </fieldset> |
| 762 | | - <fieldset class="rule-section"> |
| 763 | | - <legend>(g::t(lang, K::SectionMerging))</legend> |
| 764 | | - <div class="switch-list"> |
| 765 | | - <div class="row-line row-field stepper-row"> |
| 766 | | - <span class="row-main"> |
| 767 | | - <span class="row-title" id="required-approvals-label">(g::t(lang, K::RequiredApprovals))</span> |
| 768 | | - <span class="row-status">(g::t(lang, K::ApprovalsHelp))</span> |
| 769 | | - </span> |
| 770 | | - <div class="row-control"> |
| 771 | | - <div class="runner-pill"> |
| 772 | | - <button type="button" class="runner-step" data-step="-1" aria-label=(passkeys::s(lang, "Fewer", "Azalt"))>"−"</button> |
| 773 | | - <input type="number" name="required_approvals" min="0" max="20" step="1" inputmode="numeric" value=(required_approvals.as_str()) aria-labelledby="required-approvals-label"> |
| 774 | | - <button type="button" class="runner-step" data-step="1" aria-label=(passkeys::s(lang, "More", "Artır"))>"+"</button> |
| 775 | | - </div> |
| 776 | | - </div> |
| 777 | | - </div> |
| 778 | | - switch_row(name: "block_on_changes_requested".to_owned(), checked: block_on_changes_requested, |
| 779 | | - title: g::t(lang, K::BlockWhileChanges).to_owned(), description: None) |
| 780 | | - switch_row(name: "require_up_to_date".to_owned(), checked: require_up_to_date, |
| 781 | | - title: g::t(lang, K::RequireUpToDate).to_owned(), description: None) |
| 782 | | - switch_row(name: "require_merge_queue".to_owned(), checked: require_merge_queue, |
| 783 | | - title: mq::t(lang, mq::K::RequireMergeQueue).to_owned(), |
| 784 | | - description: Some(mq::t(lang, mq::K::RequireMergeQueueHint).to_owned())) |
| 699 | + <fieldset class="rule-group"> |
| 700 | + <legend>(g::t(lang, K::SectionMerging))</legend> |
| 701 | + <div class="field"> |
| 702 | + <label for=(approvals_id.as_str())>(g::t(lang, K::RequiredApprovals))</label> |
| 703 | + <div class="runner-pill"> |
| 704 | + <button type="button" class="runner-step" data-step="-1" aria-label=(passkeys::s(lang, "Fewer", "Azalt"))>"−"</button> |
| 705 | + <input id=(approvals_id.as_str()) type="number" name="required_approvals" min="0" max="20" step="1" inputmode="numeric" value=(required_approvals.as_str())> |
| 706 | + <button type="button" class="runner-step" data-step="1" aria-label=(passkeys::s(lang, "More", "Artır"))>"+"</button> |
| 785 | 707 | </div> |
| 786 | | - </fieldset> |
| 787 | | - </div> |
| 788 | | - <fieldset class="rule-section"> |
| 708 | + <p class="hint">(g::t(lang, K::ApprovalsHelp))</p> |
| 709 | + </div> |
| 710 | + <label class="switch"> |
| 711 | + <input type="checkbox" name="block_on_changes_requested" value="on" checked=(block_on_changes_requested)> |
| 712 | + <span>(g::t(lang, K::BlockWhileChanges))</span> |
| 713 | + </label> |
| 714 | + <label class="switch"> |
| 715 | + <input type="checkbox" name="require_up_to_date" value="on" checked=(require_up_to_date)> |
| 716 | + <span>(g::t(lang, K::RequireUpToDate))</span> |
| 717 | + </label> |
| 718 | + <label class="switch"> |
| 719 | + <input type="checkbox" name="require_merge_queue" value="on" checked=(require_merge_queue)> |
| 720 | + <span>(mq::t(lang, mq::K::RequireMergeQueue))</span> |
| 721 | + </label> |
| 722 | + <p class="hint">(mq::t(lang, mq::K::RequireMergeQueueHint))</p> |
| 723 | + </fieldset> |
| 724 | + <fieldset class="rule-group"> |
| 789 | 725 | <legend>(g::t(lang, K::SectionChecks))</legend> |
| 790 | | - <input type="text" name="required_checks" value=(required_checks.as_str()) aria-label=(g::t(lang, K::RequiredChecks)) autocomplete="off" spellcheck="false" placeholder="ci/test, ci/lint"> |
| 791 | | - <p class="muted small">(g::t(lang, K::RequiredChecksHelp))</p> |
| 726 | + <div class="field"> |
| 727 | + <label for=(checks_id.as_str())>(g::t(lang, K::RequiredChecks))</label> |
| 728 | + <input id=(checks_id.as_str()) type="text" name="required_checks" value=(required_checks.as_str()) autocomplete="off" spellcheck="false" placeholder="ci/test, ci/lint"> |
| 729 | + <p class="hint">(g::t(lang, K::RequiredChecksHelp))</p> |
| 730 | + </div> |
| 792 | 731 | if !contexts.is_empty() { |
| 793 | | - <div class="context-picker"> |
| 794 | | - <span class="muted small">(g::t(lang, K::RecentContexts))</span> |
| 732 | + <p class="hint">(g::t(lang, K::RecentContexts))</p> |
| 733 | + <div class="acts"> |
| 795 | 734 | for context in contexts.iter() { |
| 796 | | - <button type="button" class="context-chip" data-check-add=(context.as_str())>(context.as_str())</button> |
| 735 | + <button type="button" class="act" data-check-add=(context.as_str())>(context.as_str())</button> |
| 797 | 736 | } |
| 798 | 737 | </div> |
| 799 | 738 | } |
| 800 | 739 | </fieldset> |
| 801 | | - <div class="form-actions"> |
| 740 | + <div class="acts"> |
| 802 | 741 | <button type="submit" class="primary">(g::t(lang, K::SaveRule))</button> |
| 803 | | - <button type="button" data-close-details="">(g::t(lang, K::CancelRule))</button> |
| 804 | | - if let Some((remove_id, _)) = &remove { |
| 805 | | - <button type="submit" class="danger" form=(remove_id.as_str())>(g::t(lang, K::RemoveRule))</button> |
| 806 | | - } |
| 742 | + <button type="button" class="act quiet" data-close-details="">(g::t(lang, K::CancelRule))</button> |
| 807 | 743 | </div> |
| 808 | 744 | </form> |
| 745 | + if let Some(id) = &rule_id { |
| 746 | + <div class="acts"> |
| 747 | + confirm_act(lang: lang, label: g::t(lang, K::RemoveRule), action: delete_action.as_str(), csrf: csrf.as_str(), |
| 748 | + fields: vec![("rule_id".to_owned(), id.clone())]) |
| 749 | + </div> |
| 750 | + } |
| 809 | 751 | }) |
| 810 | 752 | } |
| 811 | 753 | |
| | @@ -938,7 +880,7 @@ async fn settings_body( |
| 938 | 880 | if is_error { |
| 939 | 881 | alert(message: text) |
| 940 | 882 | } else { |
| 941 | | - <section class="card notice" role="status">(text)</section> |
| 883 | + <p class="state" role="status">(text)</p> |
| 942 | 884 | } |
| 943 | 885 | } |
| 944 | 886 | if section == "general" { |
| | @@ -947,9 +889,9 @@ async fn settings_body( |
| 947 | 889 | visibility: visibility, archived: archived) |
| 948 | 890 | } |
| 949 | 891 | if section == "branches" { |
| 950 | | - <section class="settings-section settings-rules"> |
| 892 | + <section class="sec"> |
| 951 | 893 | <h2>(g::t(lang, K::BranchProtection))</h2> |
| 952 | | - <p class="muted small">(g::t(lang, K::BranchProtectionHelp))</p> |
| 894 | + <p class="hint">(g::t(lang, K::BranchProtectionHelp))</p> |
| 953 | 895 | branch_rule_cards(lang: lang, cards: cards, builtin_row: builtin_row, default_branch: default_branch.clone(), |
| 954 | 896 | new_draft: new_draft, new_open: new_open, csrf: csrf.clone(), save_action: rules_action, |
| 955 | 897 | delete_action: delete_action, contexts: contexts) |
| | @@ -452,8 +452,8 @@ pub async fn repo_strip( |
| 452 | 452 | }) |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | | -/// The README pane's header line: the license, the size and the top language, as text at the |
| 456 | | -/// right end. The full language split is the title. Nothing when the tree has no facts. |
| 455 | +/// The README pane's header line: the license, the size and the top language, as text beside the |
| 456 | +/// file name. The full language split is the title. Nothing when the tree has no facts. |
| 457 | 457 | #[component] |
| 458 | 458 | pub async fn readme_meta(lang: Lang, facts: Option<TreeFacts>) -> Result<impl View> { |
| 459 | 459 | let facts = facts.unwrap_or_default(); |
| | @@ -26,7 +26,8 @@ use crate::pages::repo::repo_head; |
| 26 | 26 | use crate::pages::repo_ctx::{RepoHead, load_repo}; |
| 27 | 27 | use crate::pages::repo_settings_live::{bump_settings, transfer_live_url}; |
| 28 | 28 | use crate::state::AppState; |
| 29 | | -use crate::views::{csrf_field, rel_time, shell}; |
| 29 | +use crate::views::parts::{confirm_act, post_act}; |
| 30 | +use crate::views::{rel_time, shell}; |
| 30 | 31 | |
| 31 | 32 | path_param!(owner); |
| 32 | 33 | path_param!(repo); |
| | @@ -74,40 +75,29 @@ async fn transfer_body( |
| 74 | 75 | ) -> Result<impl View> { |
| 75 | 76 | Ok(view! { |
| 76 | 77 | repo_head(head: head) |
| 77 | | - <section class="card"> |
| 78 | + <section class="sec"> |
| 78 | 79 | <h2>(g::t(lang, K::TransferTitle))</h2> |
| 79 | 80 | if let Some(summary) = summary.as_ref() { |
| 80 | | - <p>(summary.before.as_str()) rel_time(lang: lang, stamp: summary.expires_at.as_str()) (summary.after)</p> |
| 81 | | - if let Some(action) = accept { |
| 82 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 83 | | - csrf_field(token: csrf.as_str()) |
| 84 | | - <div> |
| 85 | | - <button type="submit">(g::t(lang, K::AcceptTransfer))</button> |
| 86 | | - </div> |
| 87 | | - </form> |
| 88 | | - } |
| 89 | | - if let Some(action) = decline { |
| 90 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 91 | | - csrf_field(token: csrf.as_str()) |
| 92 | | - <div> |
| 93 | | - <button type="submit" class="danger">(g::t(lang, K::DeclineTransfer))</button> |
| 94 | | - </div> |
| 95 | | - </form> |
| 96 | | - } |
| 97 | | - if let Some(action) = cancel { |
| 98 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 99 | | - csrf_field(token: csrf.as_str()) |
| 100 | | - <div> |
| 101 | | - <button type="submit" class="danger">(g::t(lang, K::CancelTransfer))</button> |
| 102 | | - </div> |
| 103 | | - </form> |
| 104 | | - } |
| 81 | + <p class="state">(summary.before.as_str()) rel_time(lang: lang, stamp: summary.expires_at.as_str()) (summary.after)</p> |
| 82 | + <div class="acts"> |
| 83 | + if let Some(action) = accept { |
| 84 | + post_act(label: g::t(lang, K::AcceptTransfer), action: action.as_str(), csrf: csrf.as_str()) |
| 85 | + } |
| 86 | + if let Some(action) = decline { |
| 87 | + confirm_act(lang: lang, label: g::t(lang, K::DeclineTransfer), action: action.as_str(), csrf: csrf.as_str()) |
| 88 | + } |
| 89 | + if let Some(action) = cancel { |
| 90 | + confirm_act(lang: lang, label: g::t(lang, K::CancelTransfer), action: action.as_str(), csrf: csrf.as_str()) |
| 91 | + } |
| 92 | + </div> |
| 105 | 93 | } |
| 106 | 94 | if summary.is_none() { |
| 107 | | - <p class="muted">(g::t(lang, K::NoPendingTransfer))</p> |
| 95 | + <p class="state">(g::t(lang, K::NoPendingTransfer))</p> |
| 108 | 96 | } |
| 109 | 97 | if let Some(href) = settings { |
| 110 | | - <p class="muted small"><a href=(href.as_str())>(g::t(lang, K::StartTransferLink))</a></p> |
| 98 | + <div class="acts"> |
| 99 | + <a class="act quiet" href=(href.as_str())>(g::t(lang, K::StartTransferLink))</a> |
| 100 | + </div> |
| 111 | 101 | } |
| 112 | 102 | </section> |
| 113 | 103 | }) |
| | @@ -297,25 +287,17 @@ pub(crate) async fn transfer_list_for( |
| 297 | 287 | .collect(); |
| 298 | 288 | Ok(view! { |
| 299 | 289 | if !rows.is_empty() { |
| 300 | | - <section class="card notif-group"> |
| 301 | | - <header class="notif-group-head"> |
| 302 | | - <h2>(g::t(lang, K::RepoTransfers))</h2> |
| 303 | | - </header> |
| 304 | | - <ul class="notif-list"> |
| 305 | | - for row in rows.into_iter() { |
| 306 | | - <li> |
| 307 | | - <span class="notif-title">(row.line.as_str())</span> |
| 308 | | - <form method="post" action=(row.accept.as_str()) class="notif-inline-form"> |
| 309 | | - csrf_field(token: csrf.as_str()) |
| 310 | | - <button type="submit">(g::t(lang, K::Accept))</button> |
| 311 | | - </form> |
| 312 | | - <form method="post" action=(row.decline.as_str()) class="notif-inline-form"> |
| 313 | | - csrf_field(token: csrf.as_str()) |
| 314 | | - <button type="submit" class="link-button">(g::t(lang, K::Decline))</button> |
| 315 | | - </form> |
| 316 | | - </li> |
| 317 | | - } |
| 318 | | - </ul> |
| 290 | + <section class="sec"> |
| 291 | + <h2>(g::t(lang, K::RepoTransfers))</h2> |
| 292 | + for row in rows.into_iter() { |
| 293 | + <div class="line" data-kb-row=""> |
| 294 | + <span class="name">(row.line.as_str())</span> |
| 295 | + </div> |
| 296 | + <div class="acts"> |
| 297 | + post_act(label: g::t(lang, K::Accept), action: row.accept.as_str(), csrf: csrf.as_str()) |
| 298 | + confirm_act(lang: lang, label: g::t(lang, K::Decline), action: row.decline.as_str(), csrf: csrf.as_str()) |
| 299 | + </div> |
| 300 | + } |
| 319 | 301 | </section> |
| 320 | 302 | } |
| 321 | 303 | }) |
| | @@ -31,6 +31,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 31 | 31 | use crate::pages::repo_settings::settings_frame; |
| 32 | 32 | use crate::pages::repo_settings_live::settings_head; |
| 33 | 33 | use crate::state::AppState; |
| 34 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 34 | 35 | use crate::views::{alert, enc, now_unix, relative_time, shell}; |
| 35 | 36 | use crate::webhooks::client::{WebhookPolicy, validate_url}; |
| 36 | 37 | use crate::webhooks::emit::emit_ping; |
| | @@ -503,11 +504,11 @@ async fn frame_top( |
| 503 | 504 | if is_error { |
| 504 | 505 | alert(message: text) |
| 505 | 506 | } else { |
| 506 | | - <section class="card notice" role="status">(text)</section> |
| 507 | + <p class="state" role="status">(text)</p> |
| 507 | 508 | } |
| 508 | 509 | } |
| 509 | 510 | if archived { |
| 510 | | - <section class="card notice" role="status">(g::t(lang, K::HookArchivedNotice))</section> |
| 511 | + <p class="state" role="status">(g::t(lang, K::HookArchivedNotice))</p> |
| 511 | 512 | } |
| 512 | 513 | (child) |
| 513 | 514 | ) |
| | @@ -528,55 +529,41 @@ async fn hook_form( |
| 528 | 529 | lang: Lang, |
| 529 | 530 | ) -> Result<impl View> { |
| 530 | 531 | Ok(view! { |
| 531 | | - <form method="post" action=(action.as_str()) class="card rows-pane webhook-form"> |
| 532 | + <form method="post" action=(action.as_str()) class="fields"> |
| 532 | 533 | if let Some(message) = error { |
| 533 | 534 | alert(message: message.as_str()) |
| 534 | 535 | } |
| 535 | 536 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 536 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Endpoint", "Uç nokta"))</h2> |
| 537 | | - <label class="row-line row-field"> |
| 538 | | - <span class="row-main"> |
| 539 | | - <span class="row-title">(g::t(lang, K::PayloadUrl))</span> |
| 540 | | - <span class="row-status">(g::t(lang, K::UrlHintNew))</span> |
| 541 | | - </span> |
| 542 | | - <span class="row-control"> |
| 543 | | - <input type="url" name="url" value=(url.as_str()) autocomplete="off" spellcheck="false" required=(true)> |
| 544 | | - </span> |
| 545 | | - </label> |
| 546 | | - <label class="row-line row-field"> |
| 547 | | - <span class="row-main"> |
| 548 | | - <span class="row-title">(g::t(lang, K::Secret))</span> |
| 549 | | - <span class="row-status">(secret_hint.as_str()) (g::t(lang, K::SignedWith))</span> |
| 550 | | - </span> |
| 551 | | - <span class="row-control"> |
| 552 | | - <input type="password" name="secret" autocomplete="new-password" maxlength="256"> |
| 553 | | - </span> |
| 554 | | - </label> |
| 555 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Delivery", "Teslimat"))</h2> |
| 556 | | - <div class="row-line row-field event-choices" role="group" aria-label=(g::t(lang, K::Events))> |
| 557 | | - <span class="row-main"> |
| 558 | | - <span class="row-title">(g::t(lang, K::Events))</span> |
| 559 | | - </span> |
| 560 | | - <span class="row-control"> |
| 537 | + <section class="sec"> |
| 538 | + <h2>(crate::pages::passkeys::s(lang, "Endpoint", "Uç nokta"))</h2> |
| 539 | + <div class="field"> |
| 540 | + <label for="hook-url">(g::t(lang, K::PayloadUrl))</label> |
| 541 | + <input id="hook-url" type="url" name="url" value=(url.as_str()) autocomplete="off" spellcheck="false" required=(true)> |
| 542 | + <p class="hint">(g::t(lang, K::UrlHintNew))</p> |
| 543 | + </div> |
| 544 | + <div class="field"> |
| 545 | + <label for="hook-secret">(g::t(lang, K::Secret))</label> |
| 546 | + <input id="hook-secret" type="password" name="secret" autocomplete="new-password" maxlength="256"> |
| 547 | + <p class="hint">(secret_hint.as_str()) " " (g::t(lang, K::SignedWith))</p> |
| 548 | + </div> |
| 549 | + </section> |
| 550 | + <section class="sec"> |
| 551 | + <h2>(crate::pages::passkeys::s(lang, "Delivery", "Teslimat"))</h2> |
| 552 | + <div class="field" role="group" aria-labelledby="hook-events-title"> |
| 553 | + <p class="field-title" id="hook-events-title">(g::t(lang, K::Events))</p> |
| 561 | 554 | for event in events.iter() { |
| 562 | | - <label class="inline"> |
| 555 | + <label class="switch"> |
| 563 | 556 | <input type="checkbox" name=(event.name.as_str()) value="on" checked=(event.checked)> |
| 564 | 557 | <span>(event.label)</span> |
| 565 | 558 | </label> |
| 566 | 559 | } |
| 567 | | - </span> |
| 568 | | - </div> |
| 569 | | - <label class="row-line row-field"> |
| 570 | | - <span class="row-main"> |
| 571 | | - <span class="row-title">(g::t(lang, K::ActiveField))</span> |
| 572 | | - </span> |
| 573 | | - <span class="row-control"> |
| 560 | + </div> |
| 561 | + <label class="switch"> |
| 574 | 562 | <input type="checkbox" name="active" value="on" checked=(active)> |
| 575 | | - </span> |
| 576 | | - </label> |
| 577 | | - <div class="row-foot"> |
| 578 | | - <button type="submit" class="primary">(submit)</button> |
| 579 | | - </div> |
| 563 | + <span>(g::t(lang, K::ActiveField))</span> |
| 564 | + </label> |
| 565 | + </section> |
| 566 | + <button type="submit" class="primary">(submit)</button> |
| 580 | 567 | </form> |
| 581 | 568 | }) |
| 582 | 569 | } |
| | @@ -587,50 +574,52 @@ async fn hooks_list_body( |
| 587 | 574 | title: String, |
| 588 | 575 | notice: Option<(&'static str, bool)>, |
| 589 | 576 | archived: bool, |
| 577 | + csrf: String, |
| 590 | 578 | rows: Vec<HookRow>, |
| 591 | 579 | lang: Lang, |
| 592 | 580 | ) -> Result<impl View> { |
| 593 | | - let new_href = format!("{}/new", hooks_href(&title)); |
| 581 | + let new_action = format!("{}/new", hooks_href(&title)); |
| 582 | + let blank = HookDraft::blank(); |
| 583 | + let events = event_boxes(lang, &blank.events); |
| 584 | + let empty = rows.is_empty(); |
| 594 | 585 | Ok(view! { |
| 595 | 586 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, |
| 596 | | - <section class="card rows-pane"> |
| 597 | | - <div class="row-line"> |
| 598 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 599 | | - <div class="row-main"> |
| 600 | | - <h2 class="row-title">(g::t(lang, K::Webhooks))</h2> |
| 601 | | - if rows.is_empty() { |
| 602 | | - <p class="row-status">(g::t(lang, K::NoWebhooks))</p> |
| 603 | | - } else { |
| 604 | | - <p class="row-status">(g::t(lang, K::WebhooksIntro))</p> |
| 605 | | - } |
| 587 | + <section class="sec"> |
| 588 | + <h2>(g::t(lang, K::Webhooks))</h2> |
| 589 | + if empty { |
| 590 | + <p class="state">(g::t(lang, K::NoWebhooks))</p> |
| 591 | + } else { |
| 592 | + <p class="hint">(g::t(lang, K::WebhooksIntro))</p> |
| 593 | + } |
| 594 | + if !archived { |
| 595 | + <div class="acts"> |
| 596 | + reveal(label: g::t(lang, K::AddWebhook), id: Some("add-webhook"), |
| 597 | + hook_form(action: new_action, csrf: csrf, url: String::new(), events: events, |
| 598 | + active: blank.active, secret_hint: g::t(lang, K::SecretHintNew).to_owned(), |
| 599 | + error: None, submit: g::t(lang, K::CreateWebhook), lang: lang) |
| 600 | + ) |
| 606 | 601 | </div> |
| 607 | | - if !archived { |
| 608 | | - <a href=(new_href.as_str()) class="button primary">(g::t(lang, K::AddWebhook))</a> |
| 609 | | - } |
| 610 | | - </div> |
| 602 | + } |
| 611 | 603 | for row in rows.iter() { |
| 612 | | - <div class="row-line"> |
| 613 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/></svg> |
| 614 | | - <div class="row-main"> |
| 615 | | - <strong class="row-name"><span class=(row.dot_class) role="img" aria-label=(row.dot_text) title=(row.dot_text)></span> <a href=(row.href.as_str())>(row.url.as_str())</a></strong> |
| 616 | | - <p class="row-status"> |
| 617 | | - if !row.events.is_empty() { |
| 618 | | - (row.events.as_str())" · " |
| 619 | | - } |
| 620 | | - if row.last_at.is_empty() { |
| 621 | | - (row.last_text) |
| 622 | | - } else { |
| 623 | | - (row.last_text)<time data-rel="true" datetime=(row.last_at.as_str()) title=(row.last_full.as_str())>(row.last_rel.as_str())</time> |
| 624 | | - } |
| 625 | | - if !row.problem.is_empty() { |
| 626 | | - " · "<span class="hook-problem">(row.problem)</span> |
| 627 | | - } |
| 628 | | - if !row.active { |
| 629 | | - " · "(row.inactive_text) |
| 630 | | - } |
| 631 | | - </p> |
| 632 | | - </div> |
| 633 | | - </div> |
| 604 | + <a class="line" href=(row.href.as_str()) data-kb-row=""> |
| 605 | + <span class="name"><span class=(row.dot_class) role="img" aria-label=(row.dot_text) title=(row.dot_text)></span> (row.url.as_str())</span> |
| 606 | + <span class="val"> |
| 607 | + if !row.events.is_empty() { |
| 608 | + (row.events.as_str())" · " |
| 609 | + } |
| 610 | + if row.last_at.is_empty() { |
| 611 | + (row.last_text) |
| 612 | + } else { |
| 613 | + (row.last_text)<time data-rel="true" datetime=(row.last_at.as_str()) title=(row.last_full.as_str())>(row.last_rel.as_str())</time> |
| 614 | + } |
| 615 | + if !row.problem.is_empty() { |
| 616 | + " · "<span class="hook-problem">(row.problem)</span> |
| 617 | + } |
| 618 | + if !row.active { |
| 619 | + " · "(row.inactive_text) |
| 620 | + } |
| 621 | + </span> |
| 622 | + </a> |
| 634 | 623 | } |
| 635 | 624 | </section> |
| 636 | 625 | ) |
| | @@ -646,41 +635,33 @@ async fn delivery_list( |
| 646 | 635 | ) -> Result<impl View> { |
| 647 | 636 | Ok(view! { |
| 648 | 637 | if deliveries.is_empty() { |
| 649 | | - <p class="muted">(g::t(lang, K::NoDeliveries))</p> |
| 638 | + <p class="state">(g::t(lang, K::NoDeliveries))</p> |
| 650 | 639 | } |
| 651 | 640 | for row in deliveries.iter() { |
| 652 | | - <details class="delivery"> |
| 653 | | - <summary> |
| 654 | | - <span class=(format!("hook-state {}", row.state_class))>(row.state_text)</span> |
| 655 | | - " " |
| 656 | | - <code>(row.event.as_str())</code> |
| 657 | | - " " |
| 658 | | - <time class="muted small" data-rel="true" datetime=(row.time_iso.as_str()) title=(row.time_full.as_str())>(row.time_rel.as_str())</time> |
| 659 | | - " " |
| 660 | | - <span class="muted small">(row.duration.as_str())</span> |
| 661 | | - " " |
| 662 | | - <span class="small">(g::t(lang, K::StatusLower))" " (row.status.as_str())</span> |
| 641 | + <details class="row-open"> |
| 642 | + <summary class="line" data-kb-row=""> |
| 643 | + <span class="name"><span class=(format!("hook-state {}", row.state_class))>(row.state_text)</span> <code>(row.event.as_str())</code></span> |
| 644 | + <span class="val"><time data-rel="true" datetime=(row.time_iso.as_str()) title=(row.time_full.as_str())>(row.time_rel.as_str())</time> " · " (row.duration.as_str()) " · " (g::t(lang, K::StatusLower)) " " (row.status.as_str())</span> |
| 663 | 645 | </summary> |
| 664 | | - <div class="delivery-body"> |
| 665 | | - <p class="muted small">"Guid " <code>(row.guid.as_str())</code></p> |
| 666 | | - <h4>(g::t(lang, K::RequestHeaders))</h4> |
| 667 | | - <pre class="code-block">(row.request_headers.as_str())</pre> |
| 668 | | - <h4>(g::t(lang, K::RequestBody))</h4> |
| 669 | | - <pre class="code-block">(row.request_body.as_str())</pre> |
| 670 | | - <h4>(g::t(lang, K::Response))</h4> |
| 646 | + <div class="opened"> |
| 647 | + <p class="hint">"Guid " <code>(row.guid.as_str())</code></p> |
| 648 | + <h3 class="part-title">(g::t(lang, K::RequestHeaders))</h3> |
| 649 | + <pre class="code">(row.request_headers.as_str())</pre> |
| 650 | + <h3 class="part-title">(g::t(lang, K::RequestBody))</h3> |
| 651 | + <pre class="code">(row.request_body.as_str())</pre> |
| 652 | + <h3 class="part-title">(g::t(lang, K::Response))</h3> |
| 671 | 653 | if !row.error.is_empty() { |
| 672 | | - <p class="alert" role="alert">(row.error.as_str())</p> |
| 654 | + alert(message: row.error.as_str()) |
| 673 | 655 | } |
| 674 | | - <p class="small">(g::t(lang, K::Status))" " (row.status.as_str())</p> |
| 675 | | - <h4>(g::t(lang, K::ResponseHeaders))</h4> |
| 676 | | - <pre class="code-block">(row.response_headers.as_str())</pre> |
| 677 | | - <h4>(g::t(lang, K::ResponseBody))</h4> |
| 678 | | - <pre class="code-block">(row.response_body.as_str())</pre> |
| 656 | + <p class="hint">(g::t(lang, K::Status))" " (row.status.as_str())</p> |
| 657 | + <h3 class="part-title">(g::t(lang, K::ResponseHeaders))</h3> |
| 658 | + <pre class="code">(row.response_headers.as_str())</pre> |
| 659 | + <h3 class="part-title">(g::t(lang, K::ResponseBody))</h3> |
| 660 | + <pre class="code">(row.response_body.as_str())</pre> |
| 679 | 661 | if !archived { |
| 680 | | - <form method="post" action=(row.redeliver_action.as_str()) class="inline-form"> |
| 681 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 682 | | - <button type="submit">(g::t(lang, K::Redeliver))</button> |
| 683 | | - </form> |
| 662 | + <div class="acts"> |
| 663 | + post_act(label: g::t(lang, K::Redeliver), action: row.redeliver_action.as_str(), csrf: csrf.as_str()) |
| 664 | + </div> |
| 684 | 665 | } |
| 685 | 666 | </div> |
| 686 | 667 | </details> |
| | @@ -708,14 +689,10 @@ async fn hook_body( |
| 708 | 689 | Ok(view! { |
| 709 | 690 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, |
| 710 | 691 | if archived { |
| 711 | | - <section class="card rows-pane"> |
| 712 | | - <div class="row-line"> |
| 713 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/></svg> |
| 714 | | - <div class="row-main"> |
| 715 | | - <strong class="row-name">(draft.url.as_str())</strong> |
| 716 | | - <p class="row-status">(g::t(lang, K::ArchivedHookNote))</p> |
| 717 | | - </div> |
| 718 | | - </div> |
| 692 | + <section class="sec"> |
| 693 | + <h2>(crate::pages::passkeys::s(lang, "Endpoint", "Uç nokta"))</h2> |
| 694 | + <p class="state">(draft.url.as_str())</p> |
| 695 | + <p class="hint">(g::t(lang, K::ArchivedHookNote))</p> |
| 719 | 696 | </section> |
| 720 | 697 | } else { |
| 721 | 698 | hook_form(action: edit_action.clone(), csrf: csrf.clone(), url: draft.url, |
| | @@ -723,45 +700,25 @@ async fn hook_body( |
| 723 | 700 | error: draft.error, submit: g::t(lang, K::SaveWebhook), lang: lang) |
| 724 | 701 | } |
| 725 | 702 | if !archived { |
| 726 | | - <section class="card rows-pane"> |
| 727 | | - <div class="row-line"> |
| 728 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M22 2 11 13"/><path d="M22 2 15 22l-4-9-9-4z"/></svg> |
| 729 | | - <div class="row-main"> |
| 730 | | - <h2 class="row-title">(g::t(lang, K::Test))</h2> |
| 731 | | - <p class="row-status">(g::t(lang, K::TestIntro))</p> |
| 732 | | - </div> |
| 733 | | - <form method="post" action=(test_action.as_str()) class="row-form"> |
| 734 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 735 | | - <button type="submit">(g::t(lang, K::SendTestPing))</button> |
| 736 | | - </form> |
| 703 | + <section class="sec"> |
| 704 | + <h2>(g::t(lang, K::Test))</h2> |
| 705 | + <p class="hint">(g::t(lang, K::TestIntro))</p> |
| 706 | + <div class="acts"> |
| 707 | + post_act(label: g::t(lang, K::SendTestPing), action: test_action.as_str(), csrf: csrf.as_str()) |
| 737 | 708 | </div> |
| 738 | 709 | </section> |
| 739 | 710 | } |
| 740 | | - <section class="card"> |
| 711 | + <section class="sec"> |
| 741 | 712 | <h2>(g::t(lang, K::RecentDeliveries))</h2> |
| 742 | | - <p class="muted small">(g::recent_deliveries(lang, DELIVERIES_SHOWN))</p> |
| 713 | + <p class="hint">(g::recent_deliveries(lang, DELIVERIES_SHOWN))</p> |
| 743 | 714 | delivery_list(deliveries: deliveries, csrf: csrf.clone(), archived: archived, lang: lang) |
| 744 | 715 | </section> |
| 745 | 716 | if !archived { |
| 746 | | - <section class="card rows-pane security-danger"> |
| 747 | | - <div class="row-line"> |
| 748 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4l9 16H3z"/><path d="M12 10v4M12 17v.5"/></svg> |
| 749 | | - <div class="row-main"> |
| 750 | | - <h2 class="row-title">(g::t(lang, K::DeleteWebhook))</h2> |
| 751 | | - <p class="row-status">(g::t(lang, K::DeleteIntro))</p> |
| 752 | | - </div> |
| 753 | | - <details class="row-action danger"> |
| 754 | | - <summary>(g::t(lang, K::DeleteWebhook))</summary> |
| 755 | | - <div class="row-panel"> |
| 756 | | - <p>(g::t(lang, K::DeleteConfirm))</p> |
| 757 | | - <form method="post" action=(delete_action.as_str()) class="row-actions"> |
| 758 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 759 | | - <input type="hidden" name="confirm" value="on"> |
| 760 | | - <button type="submit" class="danger">(g::t(lang, K::DeleteWebhook))</button> |
| 761 | | - <button type="button" data-close-details="">(g::t(lang, K::Cancel))</button> |
| 762 | | - </form> |
| 763 | | - </div> |
| 764 | | - </details> |
| 717 | + <section class="sec"> |
| 718 | + <h2>(g::t(lang, K::DeleteWebhook))</h2> |
| 719 | + <p class="hint">(g::t(lang, K::DeleteIntro))</p> |
| 720 | + <div class="acts"> |
| 721 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteWebhook), action: delete_action.as_str(), csrf: csrf.as_str(), fields: vec![("confirm".to_owned(), "on".to_owned())], note: Some(g::t(lang, K::DeleteConfirm).to_owned())) |
| 765 | 722 | </div> |
| 766 | 723 | </section> |
| 767 | 724 | } |
| | @@ -775,7 +732,7 @@ async fn hooks_list_page(cx: &Cx) -> Result<impl View> { |
| 775 | 732 | let owner = path_param::<Owner>(cx); |
| 776 | 733 | let name = path_param::<Repo>(cx); |
| 777 | 734 | let ctx = load_repo(cx, owner, name).await?; |
| 778 | | - require_user(cx).await?; |
| 735 | + let (_, session) = require_user(cx).await?; |
| 779 | 736 | if !ctx.can_admin() { |
| 780 | 737 | return Err(forbidden().into()); |
| 781 | 738 | } |
| | @@ -802,10 +759,11 @@ async fn hooks_list_page(cx: &Cx) -> Result<impl View> { |
| 802 | 759 | rows.push(hook_row(lang, tz, &frame.title, hook, last, &last_stamp)); |
| 803 | 760 | } |
| 804 | 761 | let notice = notice_from_query(cx, lang); |
| 762 | + let csrf = session.csrf_token.clone(); |
| 805 | 763 | Ok(view! { |
| 806 | 764 | shell(title: frame.page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 807 | 765 | hooks_list_body(head: frame.head, title: frame.title, notice: notice, |
| 808 | | - archived: frame.archived, rows: rows, lang: lang)) |
| 766 | + archived: frame.archived, csrf: csrf, rows: rows, lang: lang)) |
| 809 | 767 | }) |
| 810 | 768 | } |
| 811 | 769 | |
| | @@ -846,14 +804,11 @@ async fn hook_new_body( |
| 846 | 804 | let back = hooks_href(&title); |
| 847 | 805 | Ok(view! { |
| 848 | 806 | frame_top(head: head, title: title.clone(), notice: None, archived: archived, lang: lang, |
| 849 | | - <section class="card rows-pane"> |
| 850 | | - <div class="row-line"> |
| 851 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 852 | | - <div class="row-main"> |
| 853 | | - <h2 class="row-title">(g::t(lang, K::AddWebhook))</h2> |
| 854 | | - <p class="row-status">(g::t(lang, K::AddWebhookIntro))</p> |
| 855 | | - </div> |
| 856 | | - <a href=(back.as_str()) class="button">(g::t(lang, K::BackToWebhooks))</a> |
| 807 | + <section class="sec"> |
| 808 | + <h2>(g::t(lang, K::AddWebhook))</h2> |
| 809 | + <p class="hint">(g::t(lang, K::AddWebhookIntro))</p> |
| 810 | + <div class="acts"> |
| 811 | + <a class="act quiet" href=(back.as_str())>(g::t(lang, K::BackToWebhooks))</a> |
| 857 | 812 | </div> |
| 858 | 813 | </section> |
| 859 | 814 | hook_form(action: action, csrf: csrf, url: draft.url, events: events, |
| | @@ -1766,7 +1721,10 @@ mod tests { |
| 1766 | 1721 | assert!(body.contains(URL), "{body}"); |
| 1767 | 1722 | assert!(body.contains("Add webhook"), "{body}"); |
| 1768 | 1723 | assert!(body.contains("none yet"), "{body}"); |
| 1769 | | - assert!(body.contains("settings-nav"), "{body}"); |
| 1724 | + assert!( |
| 1725 | + body.contains("<nav class=\"sub\" aria-label=\"Settings\">"), |
| 1726 | + "{body}" |
| 1727 | + ); |
| 1770 | 1728 | let (status, _, body) = send( |
| 1771 | 1729 | &fx.app, |
| 1772 | 1730 | "GET", |
| | @@ -13,6 +13,7 @@ use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; |
| 13 | 13 | use topcoat::router::request::uri; |
| 14 | 14 | use topcoat::router::response::Response; |
| 15 | 15 | use topcoat::router::{Body, StatusCode, page, path_param, route}; |
| 16 | +use crate::views::parts::reveal; |
| 16 | 17 | use topcoat::view::{View, component, view}; |
| 17 | 18 | |
| 18 | 19 | use crate::auth::{current_user, require_user}; |
| | @@ -23,7 +24,7 @@ use crate::notify; |
| 23 | 24 | use crate::pages::issue_parts::{ItemKind, check_write, may_change, parse_number}; |
| 24 | 25 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 25 | 26 | use crate::state::AppState; |
| 26 | | -use crate::views::{empty_state, rel_time, repo_href, shell}; |
| 27 | +use crate::views::{rel_time, repo_href, shell}; |
| 27 | 28 | |
| 28 | 29 | path_param!(owner); |
| 29 | 30 | path_param!(repo); |
| | @@ -209,34 +210,41 @@ pub(crate) async fn reviewers_box(lang: Lang, reviewers: ReviewersView) -> Resul |
| 209 | 210 | } = reviewers; |
| 210 | 211 | let message = error.map(|code| error_text(lang, code)); |
| 211 | 212 | Ok(view! { |
| 212 | | - <section class="issue-side-section reviewers-box" id="reviewers"> |
| 213 | + <section class="sec reviewers-box" id="reviewers"> |
| 213 | 214 | <h2>(ga::t(lang, AK::Reviewers))</h2> |
| 214 | 215 | if let Some(message) = message { |
| 215 | | - <p class="alert small" role="alert">(message)</p> |
| 216 | + <p class="alert" role="alert">(message)</p> |
| 216 | 217 | } |
| 217 | 218 | if names.is_empty() { |
| 218 | | - <p class="muted small">(ga::t(lang, AK::NoReviewers))</p> |
| 219 | + <p class="state">(ga::t(lang, AK::NoReviewers))</p> |
| 219 | 220 | } |
| 220 | | - <ul class="issue-names reviewer-list"> |
| 221 | + <div class="plain-rows"> |
| 221 | 222 | for name in names.iter() { |
| 222 | | - <li> |
| 223 | | - <a href=(format!("/{name}"))>(name.as_str())</a> |
| 223 | + <div class="line"> |
| 224 | + <a class="name" href=(format!("/{name}"))>(name.as_str())</a> |
| 224 | 225 | if write { |
| 225 | | - <form method="post" action=(action.as_str()) class="notif-inline-form"> |
| 226 | + <form method="post" action=(action.as_str()) class="act-form"> |
| 226 | 227 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 227 | 228 | <input type="hidden" name="username" value=(name.as_str())> |
| 228 | | - <button type="submit" name="action" value="withdraw" class="link-button" title=(ga::t(lang, AK::WithdrawRequest)) aria-label=(ga::t(lang, AK::WithdrawRequest))>"×"</button> |
| 229 | + <button type="submit" name="action" value="withdraw" class="act quiet">(ga::t(lang, AK::WithdrawRequest))</button> |
| 229 | 230 | </form> |
| 230 | 231 | } |
| 231 | | - </li> |
| 232 | + </div> |
| 232 | 233 | } |
| 233 | | - </ul> |
| 234 | + </div> |
| 234 | 235 | if write { |
| 235 | | - <form method="post" action=(action.as_str()) class="stack"> |
| 236 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 237 | | - <input type="text" name="username" required=(true) autocomplete="off" spellcheck="false" data-suggest="user" placeholder=(ga::t(lang, AK::ReviewerName)) aria-label=(ga::t(lang, AK::ReviewerName))> |
| 238 | | - <div><button type="submit" name="action" value="request">(ga::t(lang, AK::RequestReview))</button></div> |
| 239 | | - </form> |
| 236 | + <div class="acts"> |
| 237 | + reveal(label: ga::t(lang, AK::RequestReview), id: Some("request-review"), |
| 238 | + <form method="post" action=(action.as_str()) class="fields"> |
| 239 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 240 | + <div class="field"> |
| 241 | + <label for="reviewer-name">(ga::t(lang, AK::ReviewerName))</label> |
| 242 | + <input id="reviewer-name" type="text" name="username" required=(true) autocomplete="off" spellcheck="false" data-suggest="user"> |
| 243 | + </div> |
| 244 | + <button type="submit" name="action" value="request" class="primary">(ga::t(lang, AK::RequestReview))</button> |
| 245 | + </form> |
| 246 | + ) |
| 247 | + </div> |
| 240 | 248 | } |
| 241 | 249 | </section> |
| 242 | 250 | }) |
| | @@ -285,27 +293,23 @@ async fn review_requests(cx: &Cx) -> Result<impl View> { |
| 285 | 293 | let empty = rows.is_empty(); |
| 286 | 294 | Ok(view! { |
| 287 | 295 | shell(title: heading, viewer: Some(&viewer), |
| 288 | | - <section class="page-head" data-live="/review-requests/events"> |
| 289 | | - <h1>(heading)</h1> |
| 296 | + <section data-live="/review-requests/events"> |
| 297 | + <h1 class="sr-only">(heading)</h1> |
| 290 | 298 | </section> |
| 291 | 299 | if empty { |
| 292 | | - <section class="card list-pane fit-pane"> |
| 293 | | - empty_state(title: ga::t(lang, AK::NoReviewRequests)) |
| 294 | | - </section> |
| 300 | + <p class="state">(ga::t(lang, AK::NoReviewRequests))</p> |
| 295 | 301 | } |
| 296 | 302 | if !empty { |
| 297 | | - <section class="card list-pane fit-pane"> |
| 298 | | - <ul class="notif-list review-request-list"> |
| 299 | | - for row in rows.iter() { |
| 300 | | - <li> |
| 301 | | - <span class="muted small">(row.0.as_str())</span> |
| 302 | | - <a class="notif-title" href=(row.1.as_str())>(row.2.as_str())</a> |
| 303 | | - <span class="muted small">(row.3.as_str())</span> |
| 304 | | - <span class="muted small">rel_time(lang: lang, stamp: row.4.as_str())</span> |
| 305 | | - </li> |
| 306 | | - } |
| 307 | | - </ul> |
| 308 | | - </section> |
| 303 | + <div class="plain-rows"> |
| 304 | + for row in rows.iter() { |
| 305 | + <a class="line" href=(row.1.as_str()) data-kb-row=""> |
| 306 | + <span class="name">(row.2.as_str())</span> |
| 307 | + <span class="val">(row.0.as_str())</span> |
| 308 | + <span class="val">(row.3.as_str())</span> |
| 309 | + <span class="val">rel_time(lang: lang, stamp: row.4.as_str())</span> |
| 310 | + </a> |
| 311 | + } |
| 312 | + </div> |
| 309 | 313 | } |
| 310 | 314 | ) |
| 311 | 315 | }) |
| | @@ -1,8 +1,7 @@ |
| 1 | | -//! Page: appearance (`/settings/appearance`). The colour theme, the language, and for each of the |
| 2 | | -//! light and dark themes a background and an accent colour, and the side of the shell sidebar, |
| 3 | | -//! all stored per user. Every change |
| 4 | | -//! saves at once, so the form has no Save button. Anonymous visitors set the theme from the footer |
| 5 | | -//! instead (see `pages/theme_cookie.rs`). Every POST checks the CSRF token first. |
| 1 | +//! Page: appearance (`/settings/appearance`). The colour theme, the language, the sound alerts, and |
| 2 | +//! for each of the light and dark themes a background and an accent colour, all stored per user. |
| 3 | +//! Every change saves at once, so the form has no Save button. Anonymous visitors set the theme from |
| 4 | +//! the footer instead (see `pages/theme_cookie.rs`). Every POST checks the CSRF token first. |
| 6 | 5 | |
| 7 | 6 | use std::collections::HashMap; |
| 8 | 7 | |
| | @@ -35,9 +34,6 @@ pub const LANGUAGE_CODES: &[&str] = &["auto", "en", "tr"]; |
| 35 | 34 | /// Theme codes, in display order. |
| 36 | 35 | const THEME_CODES: &[&str] = &["auto", "light", "dark"]; |
| 37 | 36 | |
| 38 | | -/// Sidebar sides, in display order. Must match `store::ui_prefs::SIDEBAR_SIDES`. |
| 39 | | -const SIDEBAR_CODES: &[&str] = &["left", "right"]; |
| 40 | | - |
| 41 | 37 | /// The colour tabs, in display order: the light theme's colours, then the dark theme's. |
| 42 | 38 | const TAB_CODES: &[&str] = &["light", "dark"]; |
| 43 | 39 | |
| | @@ -169,7 +165,6 @@ struct AppearancePage { |
| 169 | 165 | tabs: Vec<Choice>, |
| 170 | 166 | light: ColourGroup, |
| 171 | 167 | dark: ColourGroup, |
| 172 | | - sidebar: Vec<Choice>, |
| 173 | 168 | /// Whether the run-finished tone is on: the sound switch's checked state. |
| 174 | 169 | sound_on: bool, |
| 175 | 170 | } |
| | @@ -180,14 +175,6 @@ pub fn sound_attr(prefs: Option<&HashMap<String, String>>) -> Option<&'static st |
| 180 | 175 | (stored == "on").then_some("on") |
| 181 | 176 | } |
| 182 | 177 | |
| 183 | | -/// The label of a sidebar side. |
| 184 | | -fn sidebar_label(lang: Lang, code: &str) -> &'static str { |
| 185 | | - match code { |
| 186 | | - "right" => g::t(lang, K::SidebarRight), |
| 187 | | - _ => g::t(lang, K::SidebarLeft), |
| 188 | | - } |
| 189 | | -} |
| 190 | | - |
| 191 | 178 | /// The label of a language code. The two native names stay as they are in every language. |
| 192 | 179 | fn language_label(lang: Lang, code: &str) -> &'static str { |
| 193 | 180 | match code { |
| | @@ -329,7 +316,7 @@ async fn colour_row(row: ColourRow) -> Result<impl View> { |
| 329 | 316 | "accent-swatch hue-swatch" |
| 330 | 317 | }; |
| 331 | 318 | Ok(view! { |
| 332 | | - <div class="row-line row-field colour-line"> |
| 319 | + <div class="colour-line"> |
| 333 | 320 | <fieldset class="colour-picker" data-colour-row="true" data-kind=(kind) data-lightness=(lightness.as_str())> |
| 334 | 321 | <legend>(legend)</legend> |
| 335 | 322 | <div class="colour-choices"> |
| | @@ -439,107 +426,70 @@ async fn appearance_body(page: AppearancePage) -> Result<impl View> { |
| 439 | 426 | tabs, |
| 440 | 427 | light, |
| 441 | 428 | dark, |
| 442 | | - sidebar, |
| 443 | 429 | sound_on, |
| 444 | 430 | } = page; |
| 445 | 431 | Ok(view! { |
| 446 | | - <div class="settings-layout"> |
| 447 | | - <section class="page-head"> |
| 448 | | - <h1>(g::t(lang, K::Appearance))</h1> |
| 449 | | - </section> |
| 450 | | - <form id="appearance-form" method="post" action="/settings/appearance" class="card rows-pane appearance" data-appearance="true"> |
| 432 | + <form id="appearance-form" method="post" action="/settings/appearance" class="appearance" data-appearance="true"> |
| 433 | + <h1 class="sr-only">(g::t(lang, K::Appearance))</h1> |
| 451 | 434 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 452 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Theme and colours", "Tema ve renkler"))</h2> |
| 453 | | - <label class="row-line row-field"> |
| 454 | | - <span class="row-main"> |
| 455 | | - <span class="row-title">(g::t(lang, K::ThemeLabel))</span> |
| 456 | | - <span class="row-status">(g::t(lang, K::MatchSystemHelp))</span> |
| 457 | | - </span> |
| 458 | | - <span class="row-control"> |
| 459 | | - <select name="theme" data-autosubmit="true"> |
| 460 | | - for choice in theme.into_iter() { |
| 461 | | - <option value=(choice.value) selected=(choice.selected)>(choice.label)</option> |
| 462 | | - } |
| 463 | | - </select> |
| 464 | | - </span> |
| 465 | | - </label> |
| 466 | | - <fieldset class="row-field colour-group" data-colour-group="true" data-tab=(tab)> |
| 467 | | - <legend class="row-title">(colours)</legend> |
| 468 | | - <div class="segmented snippet-segmented colour-tabs" role="group"> |
| 469 | | - for choice in tabs.into_iter() { |
| 470 | | - <label class="segment"> |
| 471 | | - <input type="radio" name="colour_tab" value=(choice.value) checked=(choice.selected) data-colour-tab=(choice.value)> |
| 472 | | - <span>(choice.label)</span> |
| 473 | | - </label> |
| 474 | | - } |
| 435 | + <section class="sec"> |
| 436 | + <h2>(crate::pages::passkeys::s(lang, "Theme and language", "Tema ve dil"))</h2> |
| 437 | + <div class="field-pair"> |
| 438 | + <div class="field"> |
| 439 | + <label for="theme">(g::t(lang, K::ThemeLabel))</label> |
| 440 | + <select id="theme" name="theme" data-autosubmit="true"> |
| 441 | + for choice in theme.into_iter() { |
| 442 | + <option value=(choice.value) selected=(choice.selected)>(choice.label)</option> |
| 443 | + } |
| 444 | + </select> |
| 445 | + <p class="hint">(g::t(lang, K::MatchSystemHelp))</p> |
| 446 | + </div> |
| 447 | + <div class="field"> |
| 448 | + <label for="language">(g::t(lang, K::LanguageLabel))</label> |
| 449 | + <select id="language" name="language" data-autosubmit="true"> |
| 450 | + for choice in language.into_iter() { |
| 451 | + <option value=(choice.value) selected=(choice.selected)>(choice.label)</option> |
| 452 | + } |
| 453 | + </select> |
| 454 | + </div> |
| 475 | 455 | </div> |
| 476 | | - colour_panel(group: light) |
| 477 | | - colour_panel(group: dark) |
| 478 | | - </fieldset> |
| 479 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Layout and language", "Düzen ve dil"))</h2> |
| 480 | | - <label class="row-line row-field"> |
| 481 | | - <span class="row-main"> |
| 482 | | - <span class="row-title">(g::t(lang, K::LanguageLabel))</span> |
| 483 | | - </span> |
| 484 | | - <span class="row-control"> |
| 485 | | - <select name="language" data-autosubmit="true"> |
| 486 | | - for choice in language.into_iter() { |
| 487 | | - <option value=(choice.value) selected=(choice.selected)>(choice.label)</option> |
| 488 | | - } |
| 489 | | - </select> |
| 490 | | - </span> |
| 491 | | - </label> |
| 492 | | - <div class="row-line row-field side-picker" role="group" aria-labelledby="sidebar-side-title"> |
| 493 | | - <span class="row-main"> |
| 494 | | - <span class="row-title" id="sidebar-side-title">(g::t(lang, K::SidebarLabel))</span> |
| 495 | | - <span class="row-status">(crate::pages::passkeys::s(lang, "Moves the menu on settings and admin pages.", "Ayarlar ve yönetim sayfalarındaki menüyü taşır."))</span> |
| 496 | | - </span> |
| 497 | | - <span class="row-control"> |
| 498 | | - <div class="segmented snippet-segmented" role="group"> |
| 499 | | - for choice in sidebar.into_iter() { |
| 500 | | - <label class="segment"> |
| 501 | | - <input type="radio" name="sidebar_side" value=(choice.value) checked=(choice.selected) data-autosubmit="true"> |
| 456 | + </section> |
| 457 | + <section class="sec"> |
| 458 | + <h2>(colours)</h2> |
| 459 | + <fieldset class="colour-group" data-colour-group="true" data-tab=(tab)> |
| 460 | + <legend class="sr-only">(colours)</legend> |
| 461 | + <div class="tabs" role="group"> |
| 462 | + for choice in tabs.into_iter() { |
| 463 | + <label> |
| 464 | + <input type="radio" name="colour_tab" value=(choice.value) checked=(choice.selected) data-colour-tab=(choice.value)> |
| 502 | 465 | <span>(choice.label)</span> |
| 503 | 466 | </label> |
| 504 | 467 | } |
| 505 | 468 | </div> |
| 506 | | - </span> |
| 507 | | - </div> |
| 508 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Sound alerts", "Sesli uyarılar"))</h2> |
| 509 | | - <label class="row-line row-field sound-toggle"> |
| 510 | | - <span class="row-main"> |
| 511 | | - <span class="row-title">(g::t(lang, K::SoundLabel))</span> |
| 512 | | - <span class="row-status">(g::t(lang, K::SoundSwitch))</span> |
| 513 | | - </span> |
| 514 | | - <span class="row-control"> |
| 515 | | - <input type="hidden" name="sound_shown" value="1"> |
| 516 | | - <span class="sound-switch"> |
| 517 | | - <input type="checkbox" name="sound" value="on" checked=(sound_on) data-autosubmit="true" aria-label=(g::t(lang, K::SoundSwitch))> |
| 518 | | - <span class="sound-track"><span class="sound-knob"></span></span> |
| 519 | | - </span> |
| 520 | | - </span> |
| 521 | | - </label> |
| 522 | | - <div class="row-line row-field"> |
| 523 | | - <span class="row-main"> |
| 524 | | - <span class="row-title">(g::t(lang, K::SoundPassed))</span> |
| 525 | | - <span class="row-status">(g::t(lang, K::SoundPassedNote))</span> |
| 526 | | - </span> |
| 527 | | - <span class="row-control"> |
| 528 | | - <button type="button" class="btn" data-sound-play="passed">(g::t(lang, K::SoundPlay))</button> |
| 529 | | - </span> |
| 530 | | - </div> |
| 531 | | - <div class="row-line row-field"> |
| 532 | | - <span class="row-main"> |
| 533 | | - <span class="row-title">(g::t(lang, K::SoundFailed))</span> |
| 534 | | - <span class="row-status">(g::t(lang, K::SoundFailedNote))</span> |
| 535 | | - </span> |
| 536 | | - <span class="row-control"> |
| 537 | | - <button type="button" class="btn" data-sound-play="failed">(g::t(lang, K::SoundPlay))</button> |
| 538 | | - </span> |
| 539 | | - </div> |
| 540 | | - <p class="row-foot muted small">(g::t(lang, K::SoundOwnRuns)) " · " (g::t(lang, K::SoundFootOwn))</p> |
| 469 | + colour_panel(group: light) |
| 470 | + colour_panel(group: dark) |
| 471 | + </fieldset> |
| 472 | + </section> |
| 473 | + <section class="sec"> |
| 474 | + <h2>(g::t(lang, K::SoundLabel))</h2> |
| 475 | + <input type="hidden" name="sound_shown" value="1"> |
| 476 | + <label class="switch"> |
| 477 | + <input type="checkbox" name="sound" value="on" checked=(sound_on) data-autosubmit="true"> |
| 478 | + <span>(g::t(lang, K::SoundSwitch))</span> |
| 479 | + </label> |
| 480 | + <p class="hint">(g::t(lang, K::SoundOwnRuns)) " · " (g::t(lang, K::SoundFootOwn))</p> |
| 481 | + <div class="line"> |
| 482 | + <span class="name">(g::t(lang, K::SoundPassed))</span> |
| 483 | + <span class="val">(g::t(lang, K::SoundPassedNote))</span> |
| 484 | + <button type="button" class="act" data-sound-play="passed">(g::t(lang, K::SoundPlay))</button> |
| 485 | + </div> |
| 486 | + <div class="line"> |
| 487 | + <span class="name">(g::t(lang, K::SoundFailed))</span> |
| 488 | + <span class="val">(g::t(lang, K::SoundFailedNote))</span> |
| 489 | + <button type="button" class="act" data-sound-play="failed">(g::t(lang, K::SoundPlay))</button> |
| 490 | + </div> |
| 491 | + </section> |
| 541 | 492 | </form> |
| 542 | | - </div> |
| 543 | 493 | }) |
| 544 | 494 | } |
| 545 | 495 | |
| | @@ -586,6 +536,7 @@ fn sidebar_choice(lang: Lang, posted: Option<&str>, stored: &str) -> forge_core: |
| 586 | 536 | |
| 587 | 537 | /// The side a viewer's stored value stands for. Anything but `right` is `left`, the default, which |
| 588 | 538 | /// is also what the shell renders on `<html>` (see `views/mod.rs`). |
| 539 | +#[cfg(test)] |
| 589 | 540 | pub fn sidebar_stored(stored: &str) -> &'static str { |
| 590 | 541 | if stored == "right" { "right" } else { "left" } |
| 591 | 542 | } |
| | @@ -618,9 +569,6 @@ fn page_for( |
| 618 | 569 | tabs: choices(TAB_CODES, tab, |code| tab_label(lang, code)), |
| 619 | 570 | light: colour_group(lang, false, &user.base_light, &user.accent), |
| 620 | 571 | dark: colour_group(lang, true, &user.base_dark, &user.accent_dark), |
| 621 | | - sidebar: choices(SIDEBAR_CODES, sidebar_stored(&user.sidebar_side), |code| { |
| 622 | | - sidebar_label(lang, code) |
| 623 | | - }), |
| 624 | 572 | sound_on, |
| 625 | 573 | } |
| 626 | 574 | } |
| | @@ -970,6 +918,5 @@ mod tests { |
| 970 | 918 | assert_eq!(sidebar_stored("right"), "right"); |
| 971 | 919 | assert_eq!(sidebar_stored("left"), "left"); |
| 972 | 920 | assert_eq!(sidebar_stored("bogus"), "left"); |
| 973 | | - assert_eq!(sidebar_label(Lang::Tr, "right"), "Sa\u{11f}"); |
| 974 | 921 | } |
| 975 | 922 | } |
| | @@ -62,58 +62,55 @@ async fn export_view(lang: Lang, csrf: &str, exports: Vec<DataExport>) -> Result |
| 62 | 62 | let empty = exports.is_empty(); |
| 63 | 63 | let ttl_note = g::export_ttl_note(lang, exporter::EXPORT_TTL_DAYS); |
| 64 | 64 | Ok(view! { |
| 65 | | - <section class="page-head"> |
| 66 | | - <h1>(g::t(lang, K::ExportTitle))</h1> |
| 67 | | - </section> |
| 65 | + <h1 class="sr-only">(g::t(lang, K::ExportTitle))</h1> |
| 68 | 66 | <div class="export-page" data-live=(live.as_deref()) data-live-state=(if building { "building" } else { "idle" })> |
| 69 | | - <section class="card rows-pane"> |
| 70 | | - <div class="row-line"> |
| 71 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4v11M7 10l5 5 5-5"/><path d="M5 19h14"/></svg> |
| 72 | | - <div class="row-main"> |
| 73 | | - <h2 class="row-title">(crate::pages::passkeys::s(lang, "Archive", "Arşiv"))</h2> |
| 74 | | - <p class="row-status">(g::t(lang, K::ExportIntro))</p> |
| 75 | | - <p class="row-status">(g::t(lang, K::ExportContents))</p> |
| 76 | | - <p class="row-status">(g::t(lang, K::ExportEmailNote)) " " (ttl_note.as_str())</p> |
| 77 | | - </div> |
| 78 | | - <form method="post" action="/settings/export" class="row-form"> |
| 67 | + <section class="sec"> |
| 68 | + <h2>(crate::pages::passkeys::s(lang, "Archive", "Arşiv"))</h2> |
| 69 | + <p class="hint">(g::t(lang, K::ExportIntro))</p> |
| 70 | + <p class="hint">(g::t(lang, K::ExportContents))</p> |
| 71 | + <p class="hint">(g::t(lang, K::ExportEmailNote)) " " (ttl_note.as_str())</p> |
| 72 | + <div class="acts"> |
| 73 | + <form method="post" action="/settings/export" class="act-form"> |
| 79 | 74 | csrf_field(token: csrf) |
| 80 | | - <button type="submit" class="primary" disabled=(building)>(g::t(lang, K::ExportRequest))</button> |
| 75 | + <button type="submit" class="act" disabled=(building)>(g::t(lang, K::ExportRequest))</button> |
| 81 | 76 | </form> |
| 82 | 77 | </div> |
| 78 | + </section> |
| 79 | + <section class="sec"> |
| 80 | + <h2>(crate::pages::passkeys::s(lang, "Your archives", "Arşivleriniz"))</h2> |
| 83 | 81 | if empty { |
| 84 | | - <div class="row-line"> |
| 85 | | - <div class="row-main"> |
| 86 | | - <p class="row-status">(g::t(lang, K::ExportNone))</p> |
| 87 | | - </div> |
| 88 | | - </div> |
| 82 | + <p class="state">(g::t(lang, K::ExportNone))</p> |
| 89 | 83 | } |
| 90 | 84 | for export in exports.iter() { |
| 91 | | - <div class="row-line export-row"> |
| 92 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16v4H4zM6 11v8h12v-8"/><path d="M10 15h4"/></svg> |
| 93 | | - <div class="row-main"> |
| 94 | | - <strong class="row-name">(g::t(lang, K::ExportRequested)) " " rel_time(lang: lang, stamp: export.created_at.as_str())</strong> |
| 95 | | - if export.state == ExportState::Ready { |
| 96 | | - <p class="row-status"> |
| 97 | | - (g::t(lang, K::ExportSize)) ": " (human_size(lang, u64::try_from(export.size).unwrap_or(0))) |
| 98 | | - " · " (g::expires_label(lang)) " " rel_time(lang: lang, stamp: export.expires_at.as_str()) |
| 99 | | - </p> |
| 100 | | - } |
| 101 | | - if export.state == ExportState::Building { |
| 102 | | - <progress class="import-progress export-progress"></progress> |
| 103 | | - } |
| 104 | | - if let Some(message) = export.error.as_ref() { |
| 105 | | - alert(message: message.as_str()) |
| 106 | | - } |
| 85 | + <div class="export-row"> |
| 86 | + <div class="line"> |
| 87 | + <span class="name">(g::t(lang, K::ExportRequested)) " " rel_time(lang: lang, stamp: export.created_at.as_str())</span> |
| 88 | + <span class="val"> |
| 89 | + if export.state == ExportState::Ready { |
| 90 | + (g::t(lang, K::ExportReady)) |
| 91 | + } |
| 92 | + if export.state == ExportState::Building { |
| 93 | + (g::t(lang, K::ExportBuilding)) |
| 94 | + } |
| 95 | + if export.state == ExportState::Failed { |
| 96 | + (g::t(lang, K::ExportFailed)) |
| 97 | + } |
| 98 | + </span> |
| 107 | 99 | </div> |
| 108 | 100 | if export.state == ExportState::Ready { |
| 109 | | - <span class="badge public">(g::t(lang, K::ExportReady))</span> |
| 110 | | - <a class="button primary" href=(format!("/settings/export/{}/download", export.id))>(g::t(lang, K::ExportDownload))</a> |
| 101 | + <p class="hint"> |
| 102 | + (g::t(lang, K::ExportSize)) ": " (human_size(lang, u64::try_from(export.size).unwrap_or(0))) |
| 103 | + " · " (g::expires_label(lang)) " " rel_time(lang: lang, stamp: export.expires_at.as_str()) |
| 104 | + </p> |
| 105 | + <div class="acts"> |
| 106 | + <a class="act" href=(format!("/settings/export/{}/download", export.id))>(g::t(lang, K::ExportDownload))</a> |
| 107 | + </div> |
| 111 | 108 | } |
| 112 | 109 | if export.state == ExportState::Building { |
| 113 | | - <span class="badge import-running">(g::t(lang, K::ExportBuilding))</span> |
| 110 | + <progress class="import-progress export-progress"></progress> |
| 114 | 111 | } |
| 115 | | - if export.state == ExportState::Failed { |
| 116 | | - <span class="badge import-failed">(g::t(lang, K::ExportFailed))</span> |
| 112 | + if let Some(message) = export.error.as_ref() { |
| 113 | + alert(message: message.as_str()) |
| 117 | 114 | } |
| 118 | 115 | </div> |
| 119 | 116 | } |
| | @@ -1,4 +1,4 @@ |
| 1 | | -//! Page: GPG keys (`/settings/gpg`). Keys are imported into the forge-managed keyring and stored |
| 1 | +//! GPG keys, a section of `/settings/keys`. Keys are imported into the forge-managed keyring and stored |
| 2 | 2 | //! per user; a signed commit is badged Verified only when its signer's key is listed here. |
| 3 | 3 | |
| 4 | 4 | use forge_core::AuditAction; |
| | @@ -16,7 +16,9 @@ use crate::auth::{require_csrf, require_user}; |
| 16 | 16 | use crate::i18n::{self, Key, Lang, t}; |
| 17 | 17 | use crate::signatures; |
| 18 | 18 | use crate::state::AppState; |
| 19 | | -use crate::views::{added_status, alert, shell, user_facing_message}; |
| 19 | +use crate::pages::settings_keys::{KeysDraft, keys_page_view}; |
| 20 | +use crate::views::parts::{confirm_act, reveal}; |
| 21 | +use crate::views::{added_status, alert, user_facing_message}; |
| 20 | 22 | |
| 21 | 23 | #[derive(Deserialize)] |
| 22 | 24 | struct AddKeyForm { |
| | @@ -35,7 +37,7 @@ struct DeleteKeyForm { |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | #[component] |
| 38 | | -async fn gpg_view( |
| 40 | +pub(crate) async fn gpg_section( |
| 39 | 41 | lang: Lang, |
| 40 | 42 | csrf: &str, |
| 41 | 43 | keys: Vec<GpgKey>, |
| | @@ -43,69 +45,57 @@ async fn gpg_view( |
| 43 | 45 | error: Option<String>, |
| 44 | 46 | available: bool, |
| 45 | 47 | ) -> Result<impl View> { |
| 48 | + let empty = keys.is_empty(); |
| 49 | + let open = error.is_some(); |
| 46 | 50 | Ok(view! { |
| 47 | | - <section class="page-head"> |
| 48 | | - <h1>(t(lang, Key::GpgKeys))</h1> |
| 49 | | - </section> |
| 50 | | - if !available { |
| 51 | | - <p class="notice">(t(lang, Key::GpgUnavailable))</p> |
| 52 | | - } |
| 53 | | - <section class="card rows-pane"> |
| 54 | | - <div class="row-line"> |
| 55 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 56 | | - <div class="row-main"> |
| 57 | | - <h2 class="row-title">(t(lang, Key::AddGpgKeyTitle))</h2> |
| 58 | | - if keys.is_empty() { |
| 59 | | - <p class="row-status">(t(lang, Key::NoGpgKeys))</p> |
| 60 | | - } |
| 61 | | - </div> |
| 62 | | - <details class="row-action" id="add-gpg-key" open=(error.is_some())> |
| 63 | | - <summary>(t(lang, Key::AddKeyButton))</summary> |
| 64 | | - <div class="row-panel"> |
| 65 | | - if let Some(message) = error { |
| 66 | | - alert(message: message.as_str()) |
| 67 | | - } |
| 68 | | - <form method="post" action="/settings/gpg" class="stack"> |
| 69 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 70 | | - <label> |
| 71 | | - <span>(t(lang, Key::ArmoredPublicKeyLabel))</span> |
| 72 | | - <textarea name="armored" rows="10" spellcheck="false" required=(true)>(armored)</textarea> |
| 73 | | - <small class="muted">(t(lang, Key::ArmoredHint))</small> |
| 74 | | - </label> |
| 75 | | - <button type="submit" class="primary">(t(lang, Key::AddKeyButton))</button> |
| 76 | | - </form> |
| 77 | | - </div> |
| 78 | | - </details> |
| 51 | + <section class="sec" id="gpg"> |
| 52 | + <h2>(t(lang, Key::GpgKeys))</h2> |
| 53 | + if !available { |
| 54 | + <p class="hint">(t(lang, Key::GpgUnavailable))</p> |
| 55 | + } |
| 56 | + if empty { |
| 57 | + <p class="state">(t(lang, Key::NoGpgKeys))</p> |
| 58 | + } |
| 59 | + <div> |
| 60 | + for key in keys.into_iter() { |
| 61 | + <details class="row-open"> |
| 62 | + <summary class="line"> |
| 63 | + <span class="name">(key.emails.join(", "))</span> |
| 64 | + <span class="val">added_status(lang: lang, added: Some(key.created_at.as_str()), used: None)</span> |
| 65 | + </summary> |
| 66 | + <div class="opened"> |
| 67 | + <code class="hint">(key.fingerprint.clone())</code> |
| 68 | + <div class="acts"> |
| 69 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/gpg/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) |
| 70 | + </div> |
| 71 | + </div> |
| 72 | + </details> |
| 73 | + } |
| 79 | 74 | </div> |
| 80 | | - for key in keys.into_iter() { |
| 81 | | - <div class="row-line"> |
| 82 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 20l4-1 10-10-3-3L5 16z"/><path d="M14 6l3 3"/></svg> |
| 83 | | - <div class="row-main"> |
| 84 | | - <strong class="row-name"><code>(key.fingerprint.clone())</code></strong> |
| 85 | | - <p class="row-status">(key.emails.join(", ")) " · " added_status(lang: lang, added: Some(key.created_at.as_str()), used: None)</p> |
| 86 | | - </div> |
| 87 | | - <form method="post" action="/settings/gpg/delete" class="row-form"> |
| 75 | + <div class="acts"> |
| 76 | + reveal(label: t(lang, Key::AddKeyButton), id: Some("add-gpg-key"), open: open, |
| 77 | + if let Some(message) = error { |
| 78 | + alert(message: message.as_str()) |
| 79 | + } |
| 80 | + <form method="post" action="/settings/gpg" class="fields"> |
| 88 | 81 | <input type="hidden" name="csrf" value=(csrf)> |
| 89 | | - <input type="hidden" name="id" value=(key.id.clone())> |
| 90 | | - <button type="submit" class="danger">(t(lang, Key::Delete))</button> |
| 82 | + <div class="field"> |
| 83 | + <label for="gpg-key">(t(lang, Key::ArmoredPublicKeyLabel))</label> |
| 84 | + <textarea id="gpg-key" name="armored" rows="8" spellcheck="false" required=(true)>(armored)</textarea> |
| 85 | + <p class="hint">(t(lang, Key::ArmoredHint))</p> |
| 86 | + </div> |
| 87 | + <button type="submit" class="primary">(t(lang, Key::AddKeyButton))</button> |
| 91 | 88 | </form> |
| 92 | | - </div> |
| 93 | | - } |
| 89 | + ) |
| 90 | + </div> |
| 94 | 91 | </section> |
| 95 | 92 | }) |
| 96 | 93 | } |
| 97 | 94 | |
| 98 | | -#[page("/settings/gpg")] |
| 99 | | -async fn gpg_page(cx: &Cx) -> Result<impl View> { |
| 100 | | - let viewer = require_user(cx).await?; |
| 101 | | - let lang = i18n::lang(cx, Some(&viewer.0)); |
| 102 | | - let state = app_context::<AppState>(cx); |
| 103 | | - let keys = state.store.list_gpg_keys(&viewer.0.id).await?; |
| 104 | | - let available = signatures::gpg_available(state).await; |
| 105 | | - let csrf = viewer.1.csrf_token.clone(); |
| 106 | | - Ok(view! { |
| 107 | | - shell(title: t(lang, Key::GpgKeys), viewer: Some(&viewer), gpg_view(lang: lang, csrf: csrf.as_str(), keys: keys, armored: "", error: None, available: available)) |
| 108 | | - }) |
| 95 | +#[route(GET "/settings/gpg")] |
| 96 | +async fn gpg_page(cx: &Cx) -> Result<SeeOther> { |
| 97 | + require_user(cx).await?; |
| 98 | + Ok(see_other("/settings/keys#gpg")) |
| 109 | 99 | } |
| 110 | 100 | |
| 111 | 101 | #[page(POST "/settings/gpg")] |
| | @@ -137,7 +127,7 @@ async fn gpg_add(cx: &Cx, Form(form): Form<AddKeyForm>) -> Result<impl View> { |
| 137 | 127 | serde_json::Value::Null, |
| 138 | 128 | ) |
| 139 | 129 | .await; |
| 140 | | - return Err(see_other("/settings/gpg").into()); |
| 130 | + return Err(see_other("/settings/keys").into()); |
| 141 | 131 | } |
| 142 | 132 | Err(e) => match user_facing_message(&e) { |
| 143 | 133 | Some(message) => message, |
| | @@ -147,11 +137,13 @@ async fn gpg_add(cx: &Cx, Form(form): Form<AddKeyForm>) -> Result<impl View> { |
| 147 | 137 | } |
| 148 | 138 | }; |
| 149 | 139 | |
| 150 | | - let keys = state.store.list_gpg_keys(&viewer.0.id).await?; |
| 151 | | - let available = signatures::gpg_available(state).await; |
| 152 | | - let csrf = viewer.1.csrf_token.clone(); |
| 140 | + let draft = KeysDraft { |
| 141 | + armored: form.armored.clone(), |
| 142 | + gpg_error: Some(message), |
| 143 | + ..KeysDraft::default() |
| 144 | + }; |
| 153 | 145 | Ok(view! { |
| 154 | | - shell(title: t(lang, Key::GpgKeys), viewer: Some(&viewer), gpg_view(lang: lang, csrf: csrf.as_str(), keys: keys, armored: form.armored.as_str(), error: Some(message), available: available)) |
| 146 | + keys_page_view(lang: lang, state: state, viewer: &viewer, draft: draft) |
| 155 | 147 | }) |
| 156 | 148 | } |
| 157 | 149 | |
| | @@ -178,5 +170,5 @@ async fn gpg_delete(cx: &Cx, Form(form): Form<DeleteKeyForm>) -> Result<SeeOther |
| 178 | 170 | serde_json::Value::Null, |
| 179 | 171 | ) |
| 180 | 172 | .await; |
| 181 | | - Ok(see_other("/settings/gpg")) |
| 173 | + Ok(see_other("/settings/keys")) |
| 182 | 174 | } |
| | @@ -157,8 +157,17 @@ async fn gpg_refusals_and_the_listing_share_one_site() { |
| 157 | 157 | "the key survives refused deletes" |
| 158 | 158 | ); |
| 159 | 159 | |
| 160 | | - // The page lists the key. The notice shows only when GPG is missing on this server. |
| 161 | | - let reply = call(&site, "GET", "/settings/gpg", Some(&cookie), None).await; |
| 160 | + // The GPG page now redirects to the keys page, which lists the key. |
| 161 | + let redirect = call(&site, "GET", "/settings/gpg", Some(&cookie), None).await; |
| 162 | + assert_eq!(redirect.status, 303, "gpg page redirects"); |
| 163 | + assert_eq!( |
| 164 | + redirect.location.as_deref(), |
| 165 | + Some("/settings/keys#gpg"), |
| 166 | + "gpg page redirects to the keys page" |
| 167 | + ); |
| 168 | + |
| 169 | + // The listing is read from the keys page. The notice shows only when GPG is missing on this server. |
| 170 | + let reply = call(&site, "GET", "/settings/keys", Some(&cookie), None).await; |
| 162 | 171 | assert_eq!(reply.status, 200, "listing page"); |
| 163 | 172 | assert!( |
| 164 | 173 | reply.body.contains(FINGERPRINT), |
| | @@ -1,7 +1,8 @@ |
| 1 | | -//! Page: SSH keys (`/settings/keys`). Only ed25519 and ECDSA keys are accepted. |
| 1 | +//! Page: keys (`/settings/keys`): SSH keys, GPG keys and access tokens on one page. Only ed25519 |
| 2 | +//! and ECDSA SSH keys are accepted. |
| 2 | 3 | |
| 3 | 4 | use base64::prelude::{BASE64_STANDARD, BASE64_STANDARD_NO_PAD, Engine as _}; |
| 4 | | -use forge_core::{AuditAction, SshKey}; |
| 5 | +use forge_core::{AuditAction, Session, SshKey, User}; |
| 5 | 6 | use serde::Deserialize; |
| 6 | 7 | use sha2::{Digest, Sha256}; |
| 7 | 8 | use topcoat::Result; |
| | @@ -15,6 +16,9 @@ use crate::audit::{self, Actor, Target}; |
| 15 | 16 | use crate::auth::{require_csrf, require_user}; |
| 16 | 17 | use crate::i18n::{self, Key, Lang, t, unsupported_key_type}; |
| 17 | 18 | use crate::state::AppState; |
| 19 | +use crate::pages::settings_gpg::gpg_section; |
| 20 | +use crate::pages::settings_tokens::tokens_section; |
| 21 | +use crate::views::parts::{confirm_act, reveal}; |
| 18 | 22 | use crate::views::{added_status, alert, shell, user_facing_message}; |
| 19 | 23 | |
| 20 | 24 | /// Algorithms accepted for web-registered keys. `ssh-rsa` is rejected with its own message. |
| | @@ -135,65 +139,95 @@ struct DeleteKeyForm { |
| 135 | 139 | id: String, |
| 136 | 140 | } |
| 137 | 141 | |
| 142 | +/// What a form sent back to the keys page: its draft and its error, or the token made just now. |
| 143 | +#[derive(Default)] |
| 144 | +pub(crate) struct KeysDraft { |
| 145 | + pub public_key: String, |
| 146 | + pub ssh_error: Option<String>, |
| 147 | + pub armored: String, |
| 148 | + pub gpg_error: Option<String>, |
| 149 | + pub token: Option<String>, |
| 150 | + pub token_error: Option<String>, |
| 151 | +} |
| 152 | + |
| 153 | +/// The keys page for the viewer, with what a form sent back. |
| 154 | +#[component] |
| 155 | +pub(crate) async fn keys_page_view( |
| 156 | + lang: Lang, |
| 157 | + state: &AppState, |
| 158 | + viewer: &(User, Session), |
| 159 | + draft: KeysDraft, |
| 160 | +) -> Result<impl View> { |
| 161 | + let keys = state.store.list_ssh_keys(&viewer.0.id).await?; |
| 162 | + let gpg_keys = state.store.list_gpg_keys(&viewer.0.id).await?; |
| 163 | + let tokens = state.store.list_tokens(&viewer.0.id).await?; |
| 164 | + let available = crate::signatures::gpg_available(state).await; |
| 165 | + let csrf = viewer.1.csrf_token.as_str(); |
| 166 | + Ok(view! { |
| 167 | + shell(title: pk_title(lang), viewer: Some(viewer), |
| 168 | + ssh_section(lang: lang, csrf: csrf, keys: keys, public_key: draft.public_key.as_str(), error: draft.ssh_error) |
| 169 | + gpg_section(lang: lang, csrf: csrf, keys: gpg_keys, armored: draft.armored.as_str(), error: draft.gpg_error, available: available) |
| 170 | + tokens_section(lang: lang, csrf: csrf, tokens: tokens, created: draft.token, error: draft.token_error) |
| 171 | + ) |
| 172 | + }) |
| 173 | +} |
| 174 | + |
| 175 | +fn pk_title(lang: Lang) -> &'static str { |
| 176 | + crate::pages::passkeys::s(lang, "Keys", "Anahtarlar") |
| 177 | +} |
| 178 | + |
| 138 | 179 | #[component] |
| 139 | | -async fn keys_view( |
| 180 | +async fn ssh_section( |
| 140 | 181 | lang: Lang, |
| 141 | 182 | csrf: &str, |
| 142 | 183 | keys: Vec<SshKey>, |
| 143 | 184 | public_key: &str, |
| 144 | 185 | error: Option<String>, |
| 145 | 186 | ) -> Result<impl View> { |
| 187 | + let empty = keys.is_empty(); |
| 188 | + let open = error.is_some(); |
| 146 | 189 | Ok(view! { |
| 147 | | - <section class="page-head"> |
| 148 | | - <h1>(t(lang, Key::SshKeys))</h1> |
| 149 | | - </section> |
| 150 | | - <section class="card rows-pane"> |
| 151 | | - <div class="row-line"> |
| 152 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 153 | | - <div class="row-main"> |
| 154 | | - <h2 class="row-title">(t(lang, Key::AddSshKeyTitle))</h2> |
| 155 | | - if keys.is_empty() { |
| 156 | | - <p class="row-status">(t(lang, Key::NoSshKeys))</p> |
| 157 | | - } else { |
| 158 | | - <p class="row-status">(t(lang, Key::PublicKeyHint))</p> |
| 159 | | - } |
| 160 | | - </div> |
| 161 | | - <details class="row-action" id="add-key" open=(error.is_some())> |
| 162 | | - <summary>(t(lang, Key::AddKeyButton))</summary> |
| 163 | | - <div class="row-panel"> |
| 164 | | - if let Some(message) = error { |
| 165 | | - alert(message: message.as_str()) |
| 166 | | - } |
| 167 | | - <form data-hard="true" method="post" action="/settings/keys" class="stack"> |
| 168 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 169 | | - <label> |
| 170 | | - <span>(t(lang, Key::TitleOptional))</span> |
| 171 | | - <input type="text" name="title" maxlength="100" autocomplete="off"> |
| 172 | | - </label> |
| 173 | | - <label> |
| 174 | | - <span>(t(lang, Key::PublicKeyLabel))</span> |
| 175 | | - <textarea name="public_key" rows="4" spellcheck="false" required=(true)>(public_key)</textarea> |
| 176 | | - <small class="muted">(t(lang, Key::PublicKeyHint))</small> |
| 177 | | - </label> |
| 178 | | - <button type="submit" class="primary">(t(lang, Key::AddKeyButton))</button> |
| 179 | | - </form> |
| 180 | | - </div> |
| 181 | | - </details> |
| 190 | + <section class="sec" id="ssh"> |
| 191 | + <h2>(t(lang, Key::SshKeys))</h2> |
| 192 | + if empty { |
| 193 | + <p class="state">(t(lang, Key::NoSshKeys))</p> |
| 194 | + } |
| 195 | + <div> |
| 196 | + for key in keys.into_iter() { |
| 197 | + <details class="row-open"> |
| 198 | + <summary class="line"> |
| 199 | + <span class="name">(key.title.clone())</span> |
| 200 | + <span class="val">(key.algorithm.clone()) " · " added_status(lang: lang, added: Some(key.created_at.as_str()), used: key.last_used_at.as_deref())</span> |
| 201 | + </summary> |
| 202 | + <div class="opened"> |
| 203 | + <code class="hint">(key.fingerprint.clone())</code> |
| 204 | + <div class="acts"> |
| 205 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/keys/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) |
| 206 | + </div> |
| 207 | + </div> |
| 208 | + </details> |
| 209 | + } |
| 182 | 210 | </div> |
| 183 | | - for key in keys.into_iter() { |
| 184 | | - <div class="row-line"> |
| 185 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="8" cy="15" r="4"/><path d="m11 12 9-9M16 7l3 3"/></svg> |
| 186 | | - <div class="row-main"> |
| 187 | | - <strong class="row-name">(key.title.clone())</strong> |
| 188 | | - <p class="row-status"><code>(key.fingerprint.clone())</code> " · " (key.algorithm.clone()) " · " added_status(lang: lang, added: Some(key.created_at.as_str()), used: key.last_used_at.as_deref())</p> |
| 189 | | - </div> |
| 190 | | - <form method="post" action="/settings/keys/delete" class="row-form"> |
| 211 | + <div class="acts"> |
| 212 | + reveal(label: t(lang, Key::AddKeyButton), id: Some("add-key"), open: open, |
| 213 | + if let Some(message) = error { |
| 214 | + alert(message: message.as_str()) |
| 215 | + } |
| 216 | + <form data-hard="true" method="post" action="/settings/keys" class="fields"> |
| 191 | 217 | <input type="hidden" name="csrf" value=(csrf)> |
| 192 | | - <input type="hidden" name="id" value=(key.id.clone())> |
| 193 | | - <button type="submit" class="danger">(t(lang, Key::Delete))</button> |
| 218 | + <div class="field"> |
| 219 | + <label for="ssh-title">(t(lang, Key::TitleOptional))</label> |
| 220 | + <input id="ssh-title" type="text" name="title" maxlength="100" autocomplete="off"> |
| 221 | + </div> |
| 222 | + <div class="field"> |
| 223 | + <label for="ssh-key">(t(lang, Key::PublicKeyLabel))</label> |
| 224 | + <textarea id="ssh-key" name="public_key" rows="4" spellcheck="false" required=(true)>(public_key)</textarea> |
| 225 | + <p class="hint">(t(lang, Key::PublicKeyHint))</p> |
| 226 | + </div> |
| 227 | + <button type="submit" class="primary">(t(lang, Key::AddKeyButton))</button> |
| 194 | 228 | </form> |
| 195 | | - </div> |
| 196 | | - } |
| 229 | + ) |
| 230 | + </div> |
| 197 | 231 | </section> |
| 198 | 232 | }) |
| 199 | 233 | } |
| | @@ -202,13 +236,9 @@ async fn keys_view( |
| 202 | 236 | async fn keys_page(cx: &Cx) -> Result<impl View> { |
| 203 | 237 | let viewer = require_user(cx).await?; |
| 204 | 238 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 205 | | - let keys = app_context::<AppState>(cx) |
| 206 | | - .store |
| 207 | | - .list_ssh_keys(&viewer.0.id) |
| 208 | | - .await?; |
| 209 | | - let csrf = viewer.1.csrf_token.clone(); |
| 239 | + let state = app_context::<AppState>(cx); |
| 210 | 240 | Ok(view! { |
| 211 | | - shell(title: t(lang, Key::SshKeys), viewer: Some(&viewer), keys_view(lang: lang, csrf: csrf.as_str(), keys: keys, public_key: "", error: None)) |
| 241 | + keys_page_view(lang: lang, state: state, viewer: &viewer, draft: KeysDraft::default()) |
| 212 | 242 | }) |
| 213 | 243 | } |
| 214 | 244 | |
| | @@ -261,12 +291,13 @@ async fn keys_add(cx: &Cx, Form(form): Form<AddKeyForm>) -> Result<impl View> { |
| 261 | 291 | } |
| 262 | 292 | } |
| 263 | 293 | }; |
| 264 | | - let message = outcome.err().unwrap_or_default(); |
| 265 | | - |
| 266 | | - let keys = store.list_ssh_keys(&viewer.0.id).await?; |
| 267 | | - let csrf = viewer.1.csrf_token.clone(); |
| 294 | + let draft = KeysDraft { |
| 295 | + public_key: form.public_key.clone(), |
| 296 | + ssh_error: outcome.err(), |
| 297 | + ..KeysDraft::default() |
| 298 | + }; |
| 268 | 299 | Ok(view! { |
| 269 | | - shell(title: t(lang, Key::SshKeys), viewer: Some(&viewer), keys_view(lang: lang, csrf: csrf.as_str(), keys: keys, public_key: form.public_key.as_str(), error: Some(message))) |
| 300 | + keys_page_view(lang: lang, state: state, viewer: &viewer, draft: draft) |
| 270 | 301 | }) |
| 271 | 302 | } |
| 272 | 303 | |
| | @@ -18,6 +18,7 @@ use crate::auth::{require_csrf, require_user}; |
| 18 | 18 | use crate::i18n::push as push_text; |
| 19 | 19 | use crate::i18n::{self, Key, Lang, t}; |
| 20 | 20 | use crate::state::AppState; |
| 21 | +use crate::views::parts::confirm_act; |
| 21 | 22 | use crate::views::{csrf_field, rel_time, shell}; |
| 22 | 23 | |
| 23 | 24 | #[query_params(error = bad_request)] |
| | @@ -69,108 +70,80 @@ async fn notifications_body(page: NotificationsPage) -> Result<impl View> { |
| 69 | 70 | // locked and the notes below say why. |
| 70 | 71 | let blocked = unverified_note.is_some() || server_note.is_some(); |
| 71 | 72 | Ok(view! { |
| 72 | | - <div class="settings-layout"> |
| 73 | | - <section class="page-head"> |
| 74 | | - <h1>(t(lang, Key::Notifications))</h1> |
| 75 | | - </section> |
| 73 | + <h1 class="sr-only">(t(lang, Key::Notifications))</h1> |
| 76 | 74 | if let Some(message) = notice { |
| 77 | | - <section class="card notice" role="status"> |
| 78 | | - <p>(message.as_str())</p> |
| 79 | | - </section> |
| 75 | + <p class="state" role="status">(message.as_str())</p> |
| 80 | 76 | } |
| 81 | | - <section class="card rows-pane"> |
| 82 | | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Email", "E-posta"))</h2> |
| 77 | + <section class="sec" id="email"> |
| 78 | + <h2>(crate::pages::passkeys::s(lang, "Email", "E-posta"))</h2> |
| 83 | 79 | <form id="notify-form" method="post" action="/settings/notifications" class="notify-form"> |
| 84 | 80 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 85 | 81 | </form> |
| 86 | | - <label class="row-line row-field"> |
| 87 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/></svg> |
| 88 | | - <span class="row-main"> |
| 89 | | - <span class="row-title">(t(lang, Key::EmailNotifyLabel))</span> |
| 90 | | - <span class="row-status">(t(lang, Key::EmailNotifyHelp))</span> |
| 91 | | - if let Some(message) = server_note { |
| 92 | | - <span class="row-status warn" role="note">(message)</span> |
| 93 | | - } |
| 94 | | - if let Some(message) = unverified_note { |
| 95 | | - <span class="row-status" role="note">(message)</span> |
| 96 | | - } |
| 97 | | - </span> |
| 98 | | - <span class="row-control"> |
| 99 | | - <input type="checkbox" form="notify-form" name="email_notifications" value="1" checked=(on) disabled=(blocked) data-autosubmit="true"> |
| 100 | | - </span> |
| 82 | + <label class="switch"> |
| 83 | + <input type="checkbox" form="notify-form" name="email_notifications" value="1" checked=(on) disabled=(blocked) data-autosubmit="true"> |
| 84 | + <span>(t(lang, Key::EmailNotifyLabel))</span> |
| 101 | 85 | </label> |
| 86 | + <p class="hint">(t(lang, Key::EmailNotifyHelp))</p> |
| 87 | + if let Some(message) = server_note { |
| 88 | + <p class="hint warn" role="note">(message)</p> |
| 89 | + } |
| 90 | + if let Some(message) = unverified_note { |
| 91 | + <p class="hint" role="note">(message)</p> |
| 92 | + } |
| 102 | 93 | <noscript> |
| 103 | | - <div class="row-foot"> |
| 94 | + <div class="acts"> |
| 104 | 95 | <button type="submit" form="notify-form" class="primary" disabled=(blocked)>(t(lang, Key::Save))</button> |
| 105 | 96 | </div> |
| 106 | 97 | </noscript> |
| 107 | 98 | </section> |
| 108 | | - <section class="card rows-pane push-card" data-push="true" data-live="/settings/notifications/push/events"> |
| 109 | | - <div class="row-line"> |
| 110 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 8 3 8H3s3-1 3-8"/><path d="M10 20a2 2 0 0 0 4 0"/></svg> |
| 111 | | - <div class="row-main"> |
| 112 | | - <h2 class="row-title">(push_text::t(lang, push_text::K::DeviceHeading))</h2> |
| 113 | | - <p class="row-status">(push_text::t(lang, push_text::K::DeviceHelp))</p> |
| 114 | | - <p class="row-status" data-push-state="on" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOn))</p> |
| 115 | | - <p class="row-status" data-push-state="off" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOff))</p> |
| 116 | | - </div> |
| 117 | | - <div class="row-actions"> |
| 118 | | - <button type="button" class="primary" data-push-action="enable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOn))</button> |
| 119 | | - <button type="button" data-push-action="disable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOff))</button> |
| 120 | | - </div> |
| 99 | + <section class="sec" id="device" data-push="true" data-live="/settings/notifications/push/events"> |
| 100 | + <h2>(push_text::t(lang, push_text::K::DeviceHeading))</h2> |
| 101 | + <p class="state" data-push-state="on" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOn))</p> |
| 102 | + <p class="state" data-push-state="off" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOff))</p> |
| 103 | + <p class="hint">(push_text::t(lang, push_text::K::DeviceHelp))</p> |
| 104 | + <p class="hint" role="note" data-push-state="unsupported" hidden=(true)>(push_text::t(lang, push_text::K::DeviceUnsupported))</p> |
| 105 | + <p class="hint" role="note" data-push-state="https" hidden=(true)>(push_text::t(lang, push_text::K::DeviceNeedsHttps))</p> |
| 106 | + <p class="hint" role="note" data-push-state="ios" hidden=(true)>(push_text::t(lang, push_text::K::DeviceIosHint))</p> |
| 107 | + <p class="hint" role="note" data-push-state="denied" hidden=(true)>(push_text::t(lang, push_text::K::DeviceDenied))</p> |
| 108 | + <p class="hint warn" role="alert" data-push-state="error" hidden=(true)>(push_text::t(lang, push_text::K::DeviceError))</p> |
| 109 | + <div class="acts"> |
| 110 | + <button type="button" class="act" data-push-action="enable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOn))</button> |
| 111 | + <button type="button" class="act quiet" data-push-action="disable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOff))</button> |
| 112 | + <form method="post" action="/settings/notifications/push/test" class="act-form"> |
| 113 | + csrf_field(token: csrf.as_str()) |
| 114 | + <button type="submit" class="act" data-push-test="true" disabled=(!can_test)>(push_text::t(lang, push_text::K::SendTest))</button> |
| 115 | + </form> |
| 121 | 116 | </div> |
| 122 | | - <p class="notice" role="note" data-push-state="unsupported" hidden=(true)>(push_text::t(lang, push_text::K::DeviceUnsupported))</p> |
| 123 | | - <p class="notice" role="note" data-push-state="https" hidden=(true)>(push_text::t(lang, push_text::K::DeviceNeedsHttps))</p> |
| 124 | | - <p class="notice" role="note" data-push-state="ios" hidden=(true)>(push_text::t(lang, push_text::K::DeviceIosHint))</p> |
| 125 | | - <p class="notice" role="note" data-push-state="denied" hidden=(true)>(push_text::t(lang, push_text::K::DeviceDenied))</p> |
| 126 | | - <p class="notice" role="alert" data-push-state="error" hidden=(true)>(push_text::t(lang, push_text::K::DeviceError))</p> |
| 127 | | - <form method="post" action="/settings/notifications/push/test" class="row-line row-form-line"> |
| 128 | | - csrf_field(token: csrf.as_str()) |
| 129 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M22 2L11 13"/><path d="M22 2l-7 20-4-9-9-4z"/></svg> |
| 130 | | - <div class="row-main"> |
| 131 | | - <h2 class="row-title">(push_text::t(lang, push_text::K::SendTest))</h2> |
| 132 | | - if !can_test { |
| 133 | | - <p class="row-status">(push_text::t(lang, push_text::K::TestNoDevices))</p> |
| 134 | | - } |
| 135 | | - </div> |
| 136 | | - <div class="row-actions"> |
| 137 | | - <button type="submit" data-push-test="true" disabled=(!can_test)>(crate::pages::passkeys::s(lang, "Send", "Gönder"))</button> |
| 138 | | - </div> |
| 139 | | - </form> |
| 117 | + if !can_test { |
| 118 | + <p class="hint">(push_text::t(lang, push_text::K::TestNoDevices))</p> |
| 119 | + } |
| 140 | 120 | </section> |
| 141 | | - <section class="card rows-pane"> |
| 142 | | - <div class="row-line"> |
| 143 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="7" y="3" width="10" height="18" rx="2"/><path d="M11 18h2"/></svg> |
| 144 | | - <div class="row-main"> |
| 145 | | - <h2 class="row-title">(push_text::t(lang, push_text::K::DevicesHeading))</h2> |
| 146 | | - if devices.is_empty() { |
| 147 | | - <p class="row-status">(push_text::t(lang, push_text::K::DevicesEmpty))</p> |
| 148 | | - } |
| 149 | | - </div> |
| 150 | | - </div> |
| 121 | + <section class="sec" id="devices"> |
| 122 | + <h2>(push_text::t(lang, push_text::K::DevicesHeading))</h2> |
| 123 | + if devices.is_empty() { |
| 124 | + <p class="state">(push_text::t(lang, push_text::K::DevicesEmpty))</p> |
| 125 | + } |
| 151 | 126 | for device in devices.into_iter() { |
| 152 | | - <div class="row-line"> |
| 153 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="7" y="3" width="10" height="18" rx="2"/><path d="M11 18h2"/></svg> |
| 154 | | - <div class="row-main"> |
| 155 | | - <strong class="row-name">(device.agent_label.as_str())</strong> |
| 156 | | - <p class="row-status">(push_text::added_label(lang)) " " rel_time(lang: lang, stamp: device.created_at.as_str())</p> |
| 157 | | - <p class="row-status"> |
| 127 | + <details class="row-open"> |
| 128 | + <summary class="line"> |
| 129 | + <span class="name">(device.agent_label.as_str())</span> |
| 130 | + <span class="val">(push_text::added_label(lang)) " " rel_time(lang: lang, stamp: device.created_at.as_str())</span> |
| 131 | + </summary> |
| 132 | + <div class="opened"> |
| 133 | + <p class="hint"> |
| 158 | 134 | if let Some(stamp) = device.last_success_at.as_deref() { |
| 159 | 135 | (push_text::last_delivered_label(lang)) " " rel_time(lang: lang, stamp: stamp) |
| 160 | 136 | } else { |
| 161 | 137 | (push_text::t(lang, push_text::K::NeverDelivered)) |
| 162 | 138 | } |
| 163 | 139 | </p> |
| 140 | + <div class="acts"> |
| 141 | + confirm_act(lang: lang, label: push_text::t(lang, push_text::K::RemoveDevice), action: "/settings/notifications/push/remove", csrf: csrf.as_str(), fields: vec![("id".to_owned(), device.id.clone())]) |
| 142 | + </div> |
| 164 | 143 | </div> |
| 165 | | - <form method="post" action="/settings/notifications/push/remove" class="row-form"> |
| 166 | | - csrf_field(token: csrf.as_str()) |
| 167 | | - <input type="hidden" name="id" value=(device.id.as_str())> |
| 168 | | - <button type="submit" class="danger">(push_text::t(lang, push_text::K::RemoveDevice))</button> |
| 169 | | - </form> |
| 170 | | - </div> |
| 144 | + </details> |
| 171 | 145 | } |
| 172 | 146 | </section> |
| 173 | | - </div> |
| 174 | 147 | }) |
| 175 | 148 | } |
| 176 | 149 | |
| | @@ -1,5 +1,5 @@ |
| 1 | 1 | //! Page: public profile (`/settings/profile`). One form saves the display name, the username |
| 2 | | -//! capitalization, the "about" text and the timezone. The avatar menu beside it posts to its own upload and removal |
| 2 | +//! capitalization, the "about" text and the timezone. The avatar topic posts to its own upload and removal |
| 3 | 3 | //! routes. Every POST checks the CSRF token first. |
| 4 | 4 | |
| 5 | 5 | use std::sync::{Arc, OnceLock}; |
| | @@ -24,6 +24,7 @@ use crate::auth::{require_csrf, require_user}; |
| 24 | 24 | use crate::i18n::{self, Key, Lang, about_too_long, display_name_too_long, t}; |
| 25 | 25 | use crate::live::Topic; |
| 26 | 26 | use crate::state::AppState; |
| 27 | +use crate::views::parts::{confirm_act, reveal}; |
| 27 | 28 | use crate::views::{alert, avatar_url, shell, user_facing_message}; |
| 28 | 29 | |
| 29 | 30 | /// Longest "about" text, in characters. |
| | @@ -137,100 +138,84 @@ async fn profile_body(page: ProfilePage) -> Result<impl View> { |
| 137 | 138 | has_avatar, |
| 138 | 139 | zones, |
| 139 | 140 | } = page; |
| 141 | + let avatar_open = errors.avatar.is_some(); |
| 140 | 142 | Ok(view! { |
| 141 | | - <div class="settings-layout"> |
| 142 | | - <section class="page-head"> |
| 143 | | - <h1>(t(lang, Key::Profile))</h1> |
| 144 | | - </section> |
| 143 | + <h1 class="sr-only">(t(lang, Key::Profile))</h1> |
| 145 | 144 | if let Some(message) = notice { |
| 146 | | - <section class="card notice" role="status"> |
| 147 | | - <p>(message)</p> |
| 148 | | - </section> |
| 145 | + <p class="state" role="status">(message)</p> |
| 149 | 146 | } |
| 150 | | - <section class="card rows-pane"> |
| 151 | | - <div class="row-line row-field profile-settings-avatar"> |
| 152 | | - <img class="avatar profile-settings-avatar-img" src=(avatar_src.as_str()) alt=(t(lang, Key::AvatarAlt)) width="40" height="40"> |
| 153 | | - <div class="row-main"> |
| 154 | | - <h2 class="row-title">(t(lang, Key::Avatar))</h2> |
| 155 | | - <p class="row-status">(t(lang, Key::AvatarHint))</p> |
| 147 | + <section class="sec"> |
| 148 | + <h2>(t(lang, Key::Avatar))</h2> |
| 149 | + <img class="avatar" src=(avatar_src.as_str()) alt=(t(lang, Key::AvatarAlt)) width="48" height="48"> |
| 150 | + <p class="hint">(t(lang, Key::AvatarHint))</p> |
| 151 | + <div class="acts"> |
| 152 | + reveal(label: t(lang, Key::UploadPhoto), open: avatar_open, |
| 156 | 153 | if let Some(message) = errors.avatar { |
| 157 | 154 | alert(message: message.as_str()) |
| 158 | 155 | } |
| 159 | | - </div> |
| 160 | | - <div class="row-actions row-control"> |
| 161 | | - <form method="post" action="/settings/profile/avatar" enctype="multipart/form-data" class="row-form profile-settings-avatar-upload"> |
| 156 | + <form method="post" action="/settings/profile/avatar" enctype="multipart/form-data" class="fields"> |
| 162 | 157 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 163 | | - <input class="profile-settings-avatar-file" type="file" id="profile-settings-avatar-file" name="avatar" aria-label=(t(lang, Key::Image)) accept="image/png,image/jpeg,image/webp,image/gif" required=(true)> |
| 164 | | - <label class="profile-settings-avatar-item" for="profile-settings-avatar-file">(t(lang, Key::UploadPhoto))</label> |
| 158 | + <div class="field"> |
| 159 | + <label for="profile-settings-avatar-file">(t(lang, Key::Image))</label> |
| 160 | + <input type="file" id="profile-settings-avatar-file" name="avatar" accept="image/png,image/jpeg,image/webp,image/gif" required=(true)> |
| 161 | + </div> |
| 165 | 162 | <button type="submit" class="primary">(t(lang, Key::Upload))</button> |
| 166 | 163 | </form> |
| 167 | | - if has_avatar { |
| 168 | | - <form method="post" action="/settings/profile/avatar/delete" class="row-form profile-settings-avatar-remove"> |
| 169 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 170 | | - <button type="submit" class="link-button">(t(lang, Key::RemovePhoto))</button> |
| 171 | | - </form> |
| 172 | | - } |
| 173 | | - </div> |
| 164 | + ) |
| 165 | + if has_avatar { |
| 166 | + confirm_act(lang: lang, label: t(lang, Key::RemovePhoto), action: "/settings/profile/avatar/delete", csrf: csrf.as_str()) |
| 167 | + } |
| 174 | 168 | </div> |
| 175 | | - <form id="profile-form" method="post" action="/settings/profile" class="profile-form"> |
| 176 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 177 | | - </form> |
| 178 | | - <label class="row-line row-field"> |
| 179 | | - <span class="row-main"> |
| 180 | | - <span class="row-title">(t(lang, Key::DisplayName))</span> |
| 181 | | - <span class="row-status" id="profile-display-name-hint">(t(lang, Key::DisplayNameHint))</span> |
| 182 | | - </span> |
| 183 | | - <span class="row-control"> |
| 184 | | - <input id="profile-display-name" form="profile-form" type="text" name="display_name" maxlength="80" autocomplete="name" value=(draft.display_name.as_str()) aria-describedby="profile-display-name-hint"> |
| 185 | | - </span> |
| 186 | | - </label> |
| 187 | | - if let Some(message) = errors.display_name { |
| 188 | | - alert(message: message.as_str()) |
| 189 | | - } |
| 190 | | - <label class="row-line row-field"> |
| 191 | | - <span class="row-main"> |
| 192 | | - <span class="row-title">(t(lang, Key::Username))</span> |
| 193 | | - <span class="row-status" id="profile-username-hint">(t(lang, Key::UsernameHint))</span> |
| 194 | | - </span> |
| 195 | | - <span class="row-control"> |
| 196 | | - <input id="profile-username" form="profile-form" type="text" name="username" maxlength="64" required=(true) autocomplete="username" value=(draft.username.as_str()) aria-describedby="profile-username-hint"> |
| 197 | | - </span> |
| 198 | | - </label> |
| 199 | | - if let Some(message) = errors.username { |
| 200 | | - alert(message: message.as_str()) |
| 201 | | - } |
| 202 | | - <label class="row-line row-field"> |
| 203 | | - <span class="row-main"> |
| 204 | | - <span class="row-title">(t(lang, Key::About))</span> |
| 205 | | - <span class="row-status" id="profile-about-hint">(t(lang, Key::AboutHint))</span> |
| 206 | | - </span> |
| 207 | | - <span class="row-control"> |
| 208 | | - <textarea id="profile-about" form="profile-form" name="about" rows="6" maxlength="2000" aria-describedby="profile-about-hint">(draft.about.as_str())</textarea> |
| 209 | | - </span> |
| 210 | | - </label> |
| 211 | | - if let Some(message) = errors.about { |
| 212 | | - alert(message: message.as_str()) |
| 213 | | - } |
| 214 | | - <label class="row-line row-field"> |
| 215 | | - <span class="row-main"> |
| 216 | | - <span class="row-title">(t(lang, Key::Timezone))</span> |
| 217 | | - </span> |
| 218 | | - <span class="row-control"> |
| 219 | | - <select id="profile-timezone" form="profile-form" name="timezone"> |
| 169 | + </section> |
| 170 | + <form id="profile-form" method="post" action="/settings/profile"> |
| 171 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 172 | + <section class="sec"> |
| 173 | + <div class="field"> |
| 174 | + <label for="profile-display-name">(t(lang, Key::DisplayName))</label> |
| 175 | + <input id="profile-display-name" type="text" name="display_name" maxlength="80" autocomplete="name" value=(draft.display_name.as_str()) aria-describedby="profile-display-name-hint"> |
| 176 | + <p class="hint" id="profile-display-name-hint">(t(lang, Key::DisplayNameHint))</p> |
| 177 | + </div> |
| 178 | + if let Some(message) = errors.display_name { |
| 179 | + alert(message: message.as_str()) |
| 180 | + } |
| 181 | + </section> |
| 182 | + <section class="sec"> |
| 183 | + <div class="field"> |
| 184 | + <label for="profile-username">(t(lang, Key::Username))</label> |
| 185 | + <input id="profile-username" type="text" name="username" maxlength="64" required=(true) autocomplete="username" value=(draft.username.as_str()) aria-describedby="profile-username-hint"> |
| 186 | + <p class="hint" id="profile-username-hint">(t(lang, Key::UsernameHint))</p> |
| 187 | + </div> |
| 188 | + if let Some(message) = errors.username { |
| 189 | + alert(message: message.as_str()) |
| 190 | + } |
| 191 | + </section> |
| 192 | + <section class="sec"> |
| 193 | + <div class="field"> |
| 194 | + <label for="profile-about">(t(lang, Key::About))</label> |
| 195 | + <textarea id="profile-about" name="about" rows="6" maxlength="2000" aria-describedby="profile-about-hint">(draft.about.as_str())</textarea> |
| 196 | + <p class="hint" id="profile-about-hint">(t(lang, Key::AboutHint))</p> |
| 197 | + </div> |
| 198 | + if let Some(message) = errors.about { |
| 199 | + alert(message: message.as_str()) |
| 200 | + } |
| 201 | + </section> |
| 202 | + <section class="sec"> |
| 203 | + <div class="field"> |
| 204 | + <label for="profile-timezone">(t(lang, Key::Timezone))</label> |
| 205 | + <select id="profile-timezone" name="timezone"> |
| 220 | 206 | for zone in zones.into_iter() { |
| 221 | 207 | <option value=(zone.name.clone()) selected=(zone.selected)>(zone.name)</option> |
| 222 | 208 | } |
| 223 | 209 | </select> |
| 224 | | - </span> |
| 225 | | - </label> |
| 226 | | - if let Some(message) = errors.timezone { |
| 227 | | - alert(message: message.as_str()) |
| 228 | | - } |
| 229 | | - <div class="row-foot"> |
| 230 | | - <button type="submit" class="primary" form="profile-form">(t(lang, Key::Save))</button> |
| 231 | | - </div> |
| 232 | | - </section> |
| 233 | | - </div> |
| 210 | + </div> |
| 211 | + if let Some(message) = errors.timezone { |
| 212 | + alert(message: message.as_str()) |
| 213 | + } |
| 214 | + <div class="acts"> |
| 215 | + <button type="submit" class="primary">(t(lang, Key::Save))</button> |
| 216 | + </div> |
| 217 | + </section> |
| 218 | + </form> |
| 234 | 219 | }) |
| 235 | 220 | } |
| 236 | 221 | |
| | @@ -358,7 +343,7 @@ async fn profile_page(cx: &Cx) -> Result<impl View> { |
| 358 | 343 | ) |
| 359 | 344 | .await?; |
| 360 | 345 | Ok(view! { |
| 361 | | - shell(title: "Profile", viewer: Some(&viewer), profile_body(page: page)) |
| 346 | + shell(title: t(lang, Key::Profile), viewer: Some(&viewer), profile_body(page: page)) |
| 362 | 347 | }) |
| 363 | 348 | } |
| 364 | 349 | |
| | @@ -401,7 +386,7 @@ async fn profile_save(cx: &Cx, Form(form): Form<ProfileForm>) -> Result<impl Vie |
| 401 | 386 | }; |
| 402 | 387 | let page = page_data(&viewer, lang, draft, errors, None).await?; |
| 403 | 388 | return Ok(view! { |
| 404 | | - shell(title: "Profile", viewer: Some(&viewer), profile_body(page: page)) |
| 389 | + shell(title: t(lang, Key::Profile), viewer: Some(&viewer), profile_body(page: page)) |
| 405 | 390 | }); |
| 406 | 391 | } |
| 407 | 392 | }; |
| | @@ -471,7 +456,7 @@ async fn avatar_upload(cx: &Cx, mut multipart: Multipart) -> Result<impl View> { |
| 471 | 456 | }; |
| 472 | 457 | let page = page_data(&viewer, lang, Draft::from_user(&viewer.0), errors, None).await?; |
| 473 | 458 | Ok(view! { |
| 474 | | - shell(title: "Profile", viewer: Some(&viewer), profile_body(page: page)) |
| 459 | + shell(title: t(lang, Key::Profile), viewer: Some(&viewer), profile_body(page: page)) |
| 475 | 460 | }) |
| 476 | 461 | } |
| 477 | 462 | |
| | @@ -28,6 +28,7 @@ use crate::i18n::{self, Key, Lang, password_too_long, password_too_short, t}; |
| 28 | 28 | use crate::pages::passkeys::{PasskeyPanel, build_panel, passkeys_panel, s}; |
| 29 | 29 | use crate::state::AppState; |
| 30 | 30 | use crate::throttle::{self, LOGIN_USER_LIMIT, TWO_FACTOR_USER_LIMIT}; |
| 31 | +use crate::views::parts::{post_act, reveal}; |
| 31 | 32 | use crate::views::{added_status, alert, rel_time, shell, user_facing_message}; |
| 32 | 33 | |
| 33 | 34 | /// Shortest and longest new passwords, in characters. |
| | @@ -156,7 +157,6 @@ struct DeviceView { |
| 156 | 157 | /// What the page needs to draw itself. |
| 157 | 158 | struct SecurityPage { |
| 158 | 159 | lang: Lang, |
| 159 | | - csrf: String, |
| 160 | 160 | email: String, |
| 161 | 161 | /// Whether the stored address has been verified. |
| 162 | 162 | email_verified: bool, |
| | @@ -182,13 +182,14 @@ struct SecurityPage { |
| 182 | 182 | passkeys: PasskeyPanel, |
| 183 | 183 | /// Repositories still owned by the user. Deletion is refused while there are any. |
| 184 | 184 | owned_repos: Vec<String>, |
| 185 | + /// Web sessions open on the account, the count the Sessions topic shows. |
| 186 | + session_count: usize, |
| 185 | 187 | } |
| 186 | 188 | |
| 187 | 189 | #[component] |
| 188 | | -async fn security_body(page: SecurityPage) -> Result<impl View> { |
| 190 | +async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> { |
| 189 | 191 | let SecurityPage { |
| 190 | 192 | lang, |
| 191 | | - csrf, |
| 192 | 193 | email, |
| 193 | 194 | email_verified, |
| 194 | 195 | stored_email, |
| | @@ -206,26 +207,14 @@ async fn security_body(page: SecurityPage) -> Result<impl View> { |
| 206 | 207 | delete_error, |
| 207 | 208 | passkeys, |
| 208 | 209 | owned_repos, |
| 210 | + session_count, |
| 209 | 211 | } = page; |
| 210 | 212 | let two_factor_on = two_factor.is_some(); |
| 211 | | - let codes_class = match &two_factor { |
| 212 | | - Some(device) if device.codes_low => "row-status warn", |
| 213 | | - _ => "row-status", |
| 214 | | - }; |
| 213 | + let pending_set = pending.is_some(); |
| 215 | 214 | let password_open = password_error.is_some(); |
| 216 | 215 | let email_open = email_error.is_some(); |
| 217 | 216 | let email_set = !email.is_empty(); |
| 218 | 217 | let show_resend = email_set && !email_verified; |
| 219 | | - let two_factor_pill_class = if two_factor_on { |
| 220 | | - "security-pill on" |
| 221 | | - } else { |
| 222 | | - "security-pill off" |
| 223 | | - }; |
| 224 | | - let two_factor_pill_text = if two_factor_on { |
| 225 | | - t(lang, Key::PillOn) |
| 226 | | - } else { |
| 227 | | - t(lang, Key::PillOff) |
| 228 | | - }; |
| 229 | 218 | let regenerate_error = two_factor_error |
| 230 | 219 | .clone() |
| 231 | 220 | .filter(|_| two_factor_panel == TwoFactorPanel::Regenerate); |
| | @@ -237,258 +226,216 @@ async fn security_body(page: SecurityPage) -> Result<impl View> { |
| 237 | 226 | let disable_open = disable_error.is_some(); |
| 238 | 227 | let delete_open = delete_error.is_some(); |
| 239 | 228 | let delete_blocked = !owned_repos.is_empty(); |
| 229 | + let sessions_line = format!("{session_count} {}", s(lang, "active", "etkin")); |
| 240 | 230 | Ok(view! { |
| 241 | | - <div class="settings-layout"> |
| 242 | | - <section class="page-head"> |
| 243 | | - <h1>(t(lang, Key::Security))</h1> |
| 244 | | - <p class="muted page-action"><a href="/settings/security/log">(t(lang, Key::SecurityLog))</a>(t(lang, Key::SecurityLogRest))</p> |
| 245 | | - </section> |
| 231 | + <h1 class="sr-only">(t(lang, Key::Security))</h1> |
| 246 | 232 | if let Some(message) = notice { |
| 247 | | - <section class="card notice" role="status"> |
| 248 | | - <p>(message)</p> |
| 249 | | - </section> |
| 250 | | - } |
| 251 | | - if let Some(list) = codes { |
| 252 | | - <section class="card" data-once=""> |
| 253 | | - <h2>(t(lang, Key::RecoveryCodes))</h2> |
| 254 | | - <p>(t(lang, Key::RecoveryCodesSave))</p> |
| 255 | | - <ul class="item-list" id="recovery-codes"> |
| 256 | | - for code in list.into_iter() { |
| 257 | | - <li><code>(code)</code></li> |
| 258 | | - } |
| 259 | | - </ul> |
| 260 | | - <p><button type="button" data-copy="recovery-codes" data-lines="" data-copied=(rc::t(lang, RC::CopyDone)) data-failed=(rc::t(lang, RC::CopyFailed))>(pk::t(lang, PK::CopyCommand))</button></p> |
| 261 | | - </section> |
| 233 | + <p class="state" role="status">(message)</p> |
| 262 | 234 | } |
| 263 | | - <section class="card rows-pane"> |
| 264 | | - <div class="row-line"> |
| 265 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></svg> |
| 266 | | - <div class="row-main"> |
| 267 | | - <h2 class="row-title">(t(lang, Key::Password))</h2> |
| 268 | | - if let Some(stamp) = password_changed { |
| 269 | | - <p class="row-status">(i18n::last_changed_label(lang)) " " rel_time(lang: lang, stamp: stamp.as_str())</p> |
| 235 | + <section class="sec" id="password"> |
| 236 | + <h2>(t(lang, Key::Password))</h2> |
| 237 | + if let Some(stamp) = password_changed { |
| 238 | + <p class="state">(i18n::last_changed_label(lang)) " " rel_time(lang: lang, stamp: stamp.as_str())</p> |
| 239 | + } |
| 240 | + <div class="acts"> |
| 241 | + reveal(label: t(lang, Key::ChangeAction), open: password_open, |
| 242 | + if let Some(message) = password_error { |
| 243 | + alert(message: message.as_str()) |
| 270 | 244 | } |
| 271 | | - </div> |
| 272 | | - <details class="row-action" open=(password_open)> |
| 273 | | - <summary>(t(lang, Key::ChangeAction))</summary> |
| 274 | | - <div class="row-panel"> |
| 275 | | - if let Some(message) = password_error { |
| 276 | | - alert(message: message.as_str()) |
| 277 | | - } |
| 278 | | - <form data-hard="true" method="post" action="/settings/security/password" class="stack"> |
| 279 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 280 | | - <label> |
| 281 | | - <span>(t(lang, Key::CurrentPassword))</span> |
| 282 | | - <input type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 283 | | - </label> |
| 284 | | - <label> |
| 285 | | - <span>(t(lang, Key::NewPassword))</span> |
| 286 | | - <input type="password" name="new_password" autocomplete="new-password" minlength="10" maxlength="1024" required=(true)> |
| 287 | | - <small class="muted">(t(lang, Key::NewPasswordHint))</small> |
| 288 | | - </label> |
| 289 | | - <label> |
| 290 | | - <span>(t(lang, Key::ConfirmNewPassword))</span> |
| 291 | | - <input type="password" name="confirm_password" autocomplete="new-password" required=(true)> |
| 292 | | - </label> |
| 293 | | - <button type="submit" class="primary">(t(lang, Key::ChangePassword))</button> |
| 294 | | - </form> |
| 295 | | - </div> |
| 296 | | - </details> |
| 245 | + <form data-hard="true" method="post" action="/settings/security/password" class="fields"> |
| 246 | + <input type="hidden" name="csrf" value=(csrf)> |
| 247 | + <div class="field"> |
| 248 | + <label for="current-password">(t(lang, Key::CurrentPassword))</label> |
| 249 | + <input id="current-password" type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 250 | + </div> |
| 251 | + <div class="field"> |
| 252 | + <label for="new-password">(t(lang, Key::NewPassword))</label> |
| 253 | + <input id="new-password" type="password" name="new_password" autocomplete="new-password" minlength="10" maxlength="1024" required=(true)> |
| 254 | + <p class="hint">(t(lang, Key::NewPasswordHint))</p> |
| 255 | + </div> |
| 256 | + <div class="field"> |
| 257 | + <label for="confirm-password">(t(lang, Key::ConfirmNewPassword))</label> |
| 258 | + <input id="confirm-password" type="password" name="confirm_password" autocomplete="new-password" required=(true)> |
| 259 | + </div> |
| 260 | + <button type="submit" class="primary">(t(lang, Key::ChangePassword))</button> |
| 261 | + </form> |
| 262 | + ) |
| 297 | 263 | </div> |
| 298 | | - <div class="row-line"> |
| 299 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/></svg> |
| 300 | | - <div class="row-main"> |
| 301 | | - <h2 class="row-title">(t(lang, Key::Email))</h2> |
| 302 | | - if stored_email.is_empty() { |
| 303 | | - <p class="row-status">(t(lang, Key::EmailNoAddress))</p> |
| 304 | | - } else { |
| 305 | | - <p class="row-status"><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> |
| 264 | + </section> |
| 265 | + <section class="sec" id="email"> |
| 266 | + <h2>(t(lang, Key::Email))</h2> |
| 267 | + if stored_email.is_empty() { |
| 268 | + <p class="state">(t(lang, Key::EmailNoAddress))</p> |
| 269 | + } else { |
| 270 | + <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> |
| 271 | + } |
| 272 | + <div class="acts"> |
| 273 | + reveal(label: t(lang, Key::ChangeAction), open: email_open, |
| 274 | + if let Some(message) = email_error { |
| 275 | + alert(message: message.as_str()) |
| 306 | 276 | } |
| 307 | | - </div> |
| 308 | | - if show_resend { |
| 309 | | - <form method="post" action="/settings/security/email/resend" class="row-form"> |
| 310 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 311 | | - <button type="submit">(t(lang, Key::VerifyResend))</button> |
| 277 | + <form method="post" action="/settings/security/email" class="fields"> |
| 278 | + <input type="hidden" name="csrf" value=(csrf)> |
| 279 | + <div class="field"> |
| 280 | + <label for="email-address">(t(lang, Key::Email))</label> |
| 281 | + <input id="email-address" type="email" name="email" autocomplete="email" maxlength="254" required=(true) value=(email.as_str())> |
| 282 | + </div> |
| 283 | + <div class="field"> |
| 284 | + <label for="email-current-password">(t(lang, Key::CurrentPassword))</label> |
| 285 | + <input id="email-current-password" type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 286 | + </div> |
| 287 | + <button type="submit" class="primary">(t(lang, Key::SaveEmail))</button> |
| 312 | 288 | </form> |
| 289 | + ) |
| 290 | + if show_resend { |
| 291 | + post_act(label: t(lang, Key::VerifyResend), action: "/settings/security/email/resend", csrf: csrf) |
| 313 | 292 | } |
| 314 | | - <details class="row-action" open=(email_open)> |
| 315 | | - <summary>(t(lang, Key::ChangeAction))</summary> |
| 316 | | - <div class="row-panel"> |
| 317 | | - if let Some(message) = email_error { |
| 318 | | - alert(message: message.as_str()) |
| 319 | | - } |
| 320 | | - <form method="post" action="/settings/security/email" class="stack"> |
| 321 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 322 | | - <label> |
| 323 | | - <span>(t(lang, Key::Email))</span> |
| 324 | | - <input type="email" name="email" autocomplete="email" maxlength="254" required=(true) value=(email.as_str())> |
| 325 | | - </label> |
| 326 | | - <label> |
| 327 | | - <span>(t(lang, Key::CurrentPassword))</span> |
| 328 | | - <input type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 329 | | - </label> |
| 330 | | - <button type="submit" class="primary">(t(lang, Key::SaveEmail))</button> |
| 331 | | - </form> |
| 332 | | - </div> |
| 333 | | - </details> |
| 334 | 293 | </div> |
| 335 | | - <div class="rows-block"> |
| 336 | | - <div class="row-line"> |
| 337 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l8 3v6c0 4.5-3.4 8.3-8 9-4.6-.7-8-4.5-8-9V6z"/><path d="M9 12l2 2 4-4"/></svg> |
| 338 | | - <div class="row-main"> |
| 339 | | - <h2 class="row-title"> |
| 340 | | - <span>(t(lang, Key::TwoFactorAuth))</span> |
| 341 | | - <span class=(two_factor_pill_class)>(two_factor_pill_text)</span> |
| 342 | | - </h2> |
| 343 | | - if !two_factor_on && pending.is_none() { |
| 344 | | - <p class="row-status">(t(lang, Key::TwoFactorOffIntro))</p> |
| 345 | | - } |
| 346 | | - if pending.is_some() { |
| 347 | | - <p class="row-status">(t(lang, Key::SetupInProgress))</p> |
| 294 | + </section> |
| 295 | + <section class="sec" id="two-factor"> |
| 296 | + <h2>(t(lang, Key::TwoFactorAuth))</h2> |
| 297 | + if let Some(list) = codes { |
| 298 | + <div class="opened" data-once=""> |
| 299 | + <p class="state">(t(lang, Key::RecoveryCodes))</p> |
| 300 | + <p class="hint">(t(lang, Key::RecoveryCodesSave))</p> |
| 301 | + <ul class="topic-list" id="recovery-codes"> |
| 302 | + for code in list.into_iter() { |
| 303 | + <li><code>(code)</code></li> |
| 348 | 304 | } |
| 305 | + </ul> |
| 306 | + <div class="acts"> |
| 307 | + <button type="button" class="act" data-copy="recovery-codes" data-lines="" data-copied=(rc::t(lang, RC::CopyDone)) data-failed=(rc::t(lang, RC::CopyFailed))>(pk::t(lang, PK::CopyCommand))</button> |
| 349 | 308 | </div> |
| 350 | | - if two_factor_on { |
| 351 | | - <details class="row-action danger" open=(disable_open)> |
| 352 | | - <summary>(t(lang, Key::TurnOffTwoFactorButton))</summary> |
| 353 | | - <div class="row-panel"> |
| 354 | | - if let Some(message) = disable_error { |
| 355 | | - alert(message: message.as_str()) |
| 356 | | - } |
| 357 | | - <form data-hard="true" method="post" action="/settings/security/2fa/disable" class="stack"> |
| 358 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 359 | | - <label> |
| 360 | | - <span>(t(lang, Key::CurrentPassword))</span> |
| 361 | | - <input type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 362 | | - </label> |
| 363 | | - <label> |
| 364 | | - <span>(t(lang, Key::Code))</span> |
| 365 | | - <input type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 366 | | - </label> |
| 367 | | - <button type="submit" class="danger">(t(lang, Key::TurnOffTwoFactorButton))</button> |
| 368 | | - </form> |
| 369 | | - </div> |
| 370 | | - </details> |
| 371 | | - } else if pending.is_none() { |
| 372 | | - <form data-hard="true" method="post" action="/settings/security/2fa/enable" class="row-form"> |
| 373 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 374 | | - <button type="submit" class="primary">(t(lang, Key::SetUpAction))</button> |
| 375 | | - </form> |
| 376 | | - } |
| 377 | 309 | </div> |
| 378 | | - if let Some(device) = two_factor { |
| 379 | | - <ul class="security-devices"> |
| 380 | | - <li class="row-line security-device"> |
| 381 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="7" y="3" width="10" height="18" rx="2"/><path d="M11 18h2"/></svg> |
| 382 | | - <div class="row-main"> |
| 383 | | - <p class="row-title">(device.name.as_str())</p> |
| 384 | | - <p class="row-status">added_status(lang: lang, added: device.added.as_deref(), used: device.used.as_deref())</p> |
| 385 | | - </div> |
| 386 | | - </li> |
| 387 | | - <li class="row-line security-device"> |
| 388 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="8" cy="15" r="4"/><path d="M11 12l9-9M17 6l3 3M14 9l3 3"/></svg> |
| 389 | | - <div class="row-main"> |
| 390 | | - <p class="row-title">(t(lang, Key::RecoveryCodes))</p> |
| 391 | | - <p class=(codes_class)>(device.codes_line.as_str())</p> |
| 392 | | - if device.codes_low { |
| 393 | | - <p class="row-status warn">(t(lang, Key::CodesRunningLow))</p> |
| 394 | | - } |
| 395 | | - </div> |
| 396 | | - <details class="row-action" open=(regenerate_open)> |
| 397 | | - <summary>(t(lang, Key::RegenerateCodes))</summary> |
| 398 | | - <div class="row-panel"> |
| 399 | | - if let Some(message) = regenerate_error { |
| 400 | | - alert(message: message.as_str()) |
| 401 | | - } |
| 402 | | - <form data-hard="true" method="post" action="/settings/security/2fa/recovery" class="stack"> |
| 403 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 404 | | - <p class="muted">(t(lang, Key::RegenerateCodesHint))</p> |
| 405 | | - <label> |
| 406 | | - <span>(t(lang, Key::Code))</span> |
| 407 | | - <input type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 408 | | - </label> |
| 409 | | - <button type="submit" class="primary">(t(lang, Key::RegenerateCodes))</button> |
| 410 | | - </form> |
| 411 | | - </div> |
| 412 | | - </details> |
| 413 | | - </li> |
| 414 | | - </ul> |
| 310 | + } |
| 311 | + if let Some(device) = two_factor { |
| 312 | + <p class="state">(t(lang, Key::PillOn)) " · " (device.name.as_str())</p> |
| 313 | + <p class="hint">added_status(lang: lang, added: device.added.as_deref(), used: device.used.as_deref())</p> |
| 314 | + <p class="hint">(device.codes_line.as_str())</p> |
| 315 | + if device.codes_low { |
| 316 | + <p class="hint topic-warn">(t(lang, Key::CodesRunningLow))</p> |
| 415 | 317 | } |
| 416 | | - if let Some((secret, uri)) = pending { |
| 417 | | - <div class="row-panel security-setup"> |
| 418 | | - <p>(t(lang, Key::TwoFactorPendingIntro))</p> |
| 419 | | - <p>(t(lang, Key::SecretPrefix)) <code>(secret)</code></p> |
| 420 | | - <p>(t(lang, Key::LinkPrefix)) <code>(uri)</code></p> |
| 421 | | - if let Some(message) = setup_error { |
| 318 | + <div class="acts"> |
| 319 | + reveal(label: t(lang, Key::RegenerateCodes), open: regenerate_open, |
| 320 | + if let Some(message) = regenerate_error { |
| 422 | 321 | alert(message: message.as_str()) |
| 423 | 322 | } |
| 424 | | - <form data-hard="true" method="post" action="/settings/security/2fa/confirm" class="stack"> |
| 425 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 426 | | - <label> |
| 427 | | - <span>(t(lang, Key::CodeFromApp))</span> |
| 428 | | - <input type="text" name="code" inputmode="numeric" autocomplete="one-time-code" maxlength="6" required=(true)> |
| 429 | | - </label> |
| 430 | | - <label> |
| 431 | | - <span>(t(lang, Key::DeviceName))</span> |
| 432 | | - <input type="text" name="name" autocomplete="off" maxlength="40" placeholder=(t(lang, Key::AuthenticatorApp))> |
| 433 | | - <small class="muted">(t(lang, Key::DeviceNameHint))</small> |
| 434 | | - </label> |
| 435 | | - <button type="submit" class="primary">(t(lang, Key::ConfirmAndTurnOn))</button> |
| 323 | + <form data-hard="true" method="post" action="/settings/security/2fa/recovery" class="fields"> |
| 324 | + <input type="hidden" name="csrf" value=(csrf)> |
| 325 | + <p class="hint">(t(lang, Key::RegenerateCodesHint))</p> |
| 326 | + <div class="field"> |
| 327 | + <label for="regenerate-code">(t(lang, Key::Code))</label> |
| 328 | + <input id="regenerate-code" type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 329 | + </div> |
| 330 | + <button type="submit" class="primary">(t(lang, Key::RegenerateCodes))</button> |
| 436 | 331 | </form> |
| 437 | | - </div> |
| 332 | + ) |
| 333 | + <details class="reveal" open=(disable_open)> |
| 334 | + <summary class="act danger">(t(lang, Key::TurnOffTwoFactorButton))</summary> |
| 335 | + <div class="opened"> |
| 336 | + if let Some(message) = disable_error { |
| 337 | + alert(message: message.as_str()) |
| 338 | + } |
| 339 | + <form data-hard="true" method="post" action="/settings/security/2fa/disable" class="fields"> |
| 340 | + <input type="hidden" name="csrf" value=(csrf)> |
| 341 | + <div class="field"> |
| 342 | + <label for="disable-password">(t(lang, Key::CurrentPassword))</label> |
| 343 | + <input id="disable-password" type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 344 | + </div> |
| 345 | + <div class="field"> |
| 346 | + <label for="disable-code">(t(lang, Key::Code))</label> |
| 347 | + <input id="disable-code" type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 348 | + </div> |
| 349 | + <button type="submit" class="act danger">(t(lang, Key::TurnOffTwoFactorButton))</button> |
| 350 | + </form> |
| 351 | + </div> |
| 352 | + </details> |
| 353 | + </div> |
| 354 | + } else if pending_set { |
| 355 | + <p class="state">(t(lang, Key::SetupInProgress))</p> |
| 356 | + } else { |
| 357 | + <p class="state">(t(lang, Key::PillOff))</p> |
| 358 | + <p class="hint">(t(lang, Key::TwoFactorOffIntro))</p> |
| 359 | + <div class="acts"> |
| 360 | + <form data-hard="true" method="post" action="/settings/security/2fa/enable" class="act-form"> |
| 361 | + <input type="hidden" name="csrf" value=(csrf)> |
| 362 | + <button type="submit" class="act">(t(lang, Key::SetUpAction))</button> |
| 363 | + </form> |
| 364 | + </div> |
| 365 | + } |
| 366 | + if let Some((secret, uri)) = pending { |
| 367 | + <p class="hint">(t(lang, Key::TwoFactorPendingIntro))</p> |
| 368 | + <p class="hint">(t(lang, Key::SecretPrefix)) <code>(secret)</code></p> |
| 369 | + <p class="hint">(t(lang, Key::LinkPrefix)) <code>(uri)</code></p> |
| 370 | + if let Some(message) = setup_error { |
| 371 | + alert(message: message.as_str()) |
| 438 | 372 | } |
| 373 | + <form data-hard="true" method="post" action="/settings/security/2fa/confirm" class="fields"> |
| 374 | + <input type="hidden" name="csrf" value=(csrf)> |
| 375 | + <div class="field"> |
| 376 | + <label for="enrol-code">(t(lang, Key::CodeFromApp))</label> |
| 377 | + <input id="enrol-code" type="text" name="code" inputmode="numeric" autocomplete="one-time-code" maxlength="6" required=(true)> |
| 378 | + </div> |
| 379 | + <div class="field"> |
| 380 | + <label for="enrol-name">(t(lang, Key::DeviceName))</label> |
| 381 | + <input id="enrol-name" type="text" name="name" autocomplete="off" maxlength="40" placeholder=(t(lang, Key::AuthenticatorApp))> |
| 382 | + <p class="hint">(t(lang, Key::DeviceNameHint))</p> |
| 383 | + </div> |
| 384 | + <button type="submit" class="primary">(t(lang, Key::ConfirmAndTurnOn))</button> |
| 385 | + </form> |
| 386 | + } |
| 387 | + </section> |
| 388 | + passkeys_panel(lang: lang, csrf: csrf, panel: passkeys) |
| 389 | + <section class="sec" id="sessions"> |
| 390 | + <h2>(t(lang, Key::Sessions))</h2> |
| 391 | + <p class="state">(sessions_line.as_str())</p> |
| 392 | + <p class="hint">(t(lang, Key::SecurityLog))(t(lang, Key::SecurityLogRest))</p> |
| 393 | + <div class="acts"> |
| 394 | + <a class="act" href="/settings/sessions">(s(lang, "Review", "Gözden geçir"))</a> |
| 395 | + <a class="act" href="/settings/security/log">(t(lang, Key::SecurityLog))</a> |
| 439 | 396 | </div> |
| 440 | | - passkeys_panel(lang: lang, csrf: csrf.as_str(), panel: passkeys) |
| 441 | 397 | </section> |
| 442 | | - <section class="card rows-pane security-danger"> |
| 443 | | - <p class="security-danger-label">(t(lang, Key::DangerZone))</p> |
| 444 | | - <div class="row-line"> |
| 445 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4l9 16H3z"/><path d="M12 10v4M12 17v.5"/></svg> |
| 446 | | - <div class="row-main"> |
| 447 | | - <h2 class="row-title">(t(lang, Key::DeleteAccount))</h2> |
| 448 | | - if delete_blocked { |
| 449 | | - <p class="row-status">(t(lang, Key::TransferOrDeleteRepos))</p> |
| 450 | | - } else { |
| 451 | | - <p class="row-status">(t(lang, Key::DeleteAccountIntro))</p> |
| 398 | + <section class="sec" id="danger"> |
| 399 | + <h2>(t(lang, Key::DangerZone))</h2> |
| 400 | + if delete_blocked { |
| 401 | + <p class="state">(t(lang, Key::TransferOrDeleteRepos))</p> |
| 402 | + <ul class="topic-list"> |
| 403 | + for name in owned_repos.into_iter() { |
| 404 | + <li class="line"><span class="name">(name)</span></li> |
| 452 | 405 | } |
| 453 | | - </div> |
| 454 | | - if !delete_blocked { |
| 455 | | - <details class="row-action danger" open=(delete_open)> |
| 456 | | - <summary>(t(lang, Key::DeleteAccount))</summary> |
| 457 | | - <div class="row-panel"> |
| 406 | + </ul> |
| 407 | + } else { |
| 408 | + <p class="state">(t(lang, Key::DeleteAccountIntro))</p> |
| 409 | + <div class="acts"> |
| 410 | + <details class="reveal" open=(delete_open)> |
| 411 | + <summary class="act danger">(t(lang, Key::DeleteAccount))</summary> |
| 412 | + <div class="opened"> |
| 458 | 413 | if let Some(message) = delete_error { |
| 459 | 414 | alert(message: message.as_str()) |
| 460 | 415 | } |
| 461 | | - <form data-hard="true" method="post" action="/settings/security/delete" class="stack"> |
| 462 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 463 | | - <label> |
| 464 | | - <span>(t(lang, Key::CurrentPassword))</span> |
| 465 | | - <input type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 466 | | - </label> |
| 416 | + <form data-hard="true" method="post" action="/settings/security/delete" class="fields"> |
| 417 | + <input type="hidden" name="csrf" value=(csrf)> |
| 418 | + <div class="field"> |
| 419 | + <label for="delete-password">(t(lang, Key::CurrentPassword))</label> |
| 420 | + <input id="delete-password" type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 421 | + </div> |
| 467 | 422 | if two_factor_on { |
| 468 | | - <label> |
| 469 | | - <span>(t(lang, Key::Code))</span> |
| 470 | | - <input type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 471 | | - </label> |
| 423 | + <div class="field"> |
| 424 | + <label for="delete-code">(t(lang, Key::Code))</label> |
| 425 | + <input id="delete-code" type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 426 | + </div> |
| 472 | 427 | } |
| 473 | | - <label> |
| 474 | | - <span>(t(lang, Key::TypeUsernameToConfirm))</span> |
| 475 | | - <input type="text" name="confirm_username" autocomplete="off" required=(true)> |
| 476 | | - </label> |
| 477 | | - <button type="submit" class="danger">(t(lang, Key::DeleteAccount))</button> |
| 428 | + <div class="field"> |
| 429 | + <label for="delete-username">(t(lang, Key::TypeUsernameToConfirm))</label> |
| 430 | + <input id="delete-username" type="text" name="confirm_username" autocomplete="off" required=(true)> |
| 431 | + </div> |
| 432 | + <button type="submit" class="act danger">(t(lang, Key::DeleteAccount))</button> |
| 478 | 433 | </form> |
| 479 | 434 | </div> |
| 480 | 435 | </details> |
| 481 | | - } |
| 482 | | - if delete_blocked { |
| 483 | | - <ul class="item-list security-repos"> |
| 484 | | - for name in owned_repos.into_iter() { |
| 485 | | - <li>(name)</li> |
| 486 | | - } |
| 487 | | - </ul> |
| 488 | | - } |
| 489 | | - </div> |
| 436 | + </div> |
| 437 | + } |
| 490 | 438 | </section> |
| 491 | | - </div> |
| 492 | 439 | }) |
| 493 | 440 | } |
| 494 | 441 | |
| | @@ -587,7 +534,6 @@ async fn build_page( |
| 587 | 534 | }; |
| 588 | 535 | Ok(SecurityPage { |
| 589 | 536 | lang, |
| 590 | | - csrf: viewer.1.csrf_token.clone(), |
| 591 | 537 | delete_error: shown.delete_error, |
| 592 | 538 | passkeys: build_panel(state, &viewer.0.id).await?, |
| 593 | 539 | owned_repos, |
| | @@ -607,6 +553,7 @@ async fn build_page( |
| 607 | 553 | pending, |
| 608 | 554 | password_changed, |
| 609 | 555 | two_factor, |
| 556 | + session_count: state.store.list_sessions(&viewer.0.id).await?.len(), |
| 610 | 557 | }) |
| 611 | 558 | } |
| 612 | 559 | |
| | @@ -626,10 +573,11 @@ async fn respond(cx: &Cx, viewer: (User, Session), shown: Shown) -> Result<impl |
| 626 | 573 | }; |
| 627 | 574 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 628 | 575 | let page = build_page(state, lang, &viewer, shown).await?; |
| 576 | + let csrf = viewer.1.csrf_token.clone(); |
| 629 | 577 | Ok(view! { |
| 630 | 578 | (status) |
| 631 | 579 | (headers) |
| 632 | | - shell(title: t(lang, Key::Security), viewer: Some(&viewer), security_body(page: page)) |
| 580 | + shell(title: t(lang, Key::Security), viewer: Some(&viewer), security_body(page: page, csrf: csrf.as_str())) |
| 633 | 581 | }) |
| 634 | 582 | } |
| 635 | 583 | |
| | @@ -1673,7 +1621,7 @@ mod tests { |
| 1673 | 1621 | assert!(page.body.contains("Added "), "{}", page.body); |
| 1674 | 1622 | assert!(page.body.contains("1 of 10 recovery codes unused")); |
| 1675 | 1623 | assert!(page.body.contains("Running low")); |
| 1676 | | - assert!(page.body.contains("security-pill on")); |
| 1624 | + assert!(page.body.contains("<p class=\"state\">On · "), "{}", page.body); |
| 1677 | 1625 | |
| 1678 | 1626 | let bad = format!( |
| 1679 | 1627 | "csrf={CSRF}¤t_password=nope&code={}", |
| | @@ -1688,13 +1636,18 @@ mod tests { |
| 1688 | 1636 | ) |
| 1689 | 1637 | .await; |
| 1690 | 1638 | assert!(reply.body.contains("Current password is incorrect.")); |
| 1639 | + let (_, opened) = reply |
| 1640 | + .body |
| 1641 | + .split_once("<details class=\"reveal\" open") |
| 1642 | + .expect("turn-off panel should stay open"); |
| 1691 | 1643 | assert!( |
| 1692 | | - reply.body.contains("row-action danger\" open"), |
| 1693 | | - "turn-off panel should stay open: {}", |
| 1694 | | - reply.body |
| 1644 | + opened.contains("Turn off") |
| 1645 | + && opened.split("<details").next().is_some_and(|panel| panel |
| 1646 | + .contains("action=\"/settings/security/2fa/disable\"")), |
| 1647 | + "the open panel should be the turn-off form: {opened}" |
| 1695 | 1648 | ); |
| 1696 | 1649 | assert!( |
| 1697 | | - !reply.body.contains("row-action\" open"), |
| 1650 | + !opened.contains("<details class=\"reveal\" open"), |
| 1698 | 1651 | "only the turn-off panel should be open" |
| 1699 | 1652 | ); |
| 1700 | 1653 | |
| | @@ -13,7 +13,9 @@ use topcoat::view::{View, component, view}; |
| 13 | 13 | use crate::audit::{self, Actor, Target}; |
| 14 | 14 | use crate::auth::{logout, require_csrf, require_user}; |
| 15 | 15 | use crate::i18n::{self, Key, Lang, t}; |
| 16 | +use crate::pages::passkeys::s; |
| 16 | 17 | use crate::state::AppState; |
| 18 | +use crate::views::parts::confirm_act; |
| 17 | 19 | use crate::views::{rel_time, shell}; |
| 18 | 20 | use crate::web_push::agent_label; |
| 19 | 21 | |
| | @@ -39,15 +41,6 @@ fn session_label(lang: Lang, session: &Session) -> String { |
| 39 | 41 | .map_or_else(|| t(lang, Key::UnknownBrowser).to_owned(), agent_label) |
| 40 | 42 | } |
| 41 | 43 | |
| 42 | | -/// " · " and the address the session was last seen at (or signed in from), for the list's meta |
| 43 | | -/// line. Empty when no address was recorded. |
| 44 | | -fn address_text(session: &Session) -> String { |
| 45 | | - match session.last_ip.as_deref().or(session.ip.as_deref()) { |
| 46 | | - Some(ip) => format!(" · {ip}"), |
| 47 | | - None => String::new(), |
| 48 | | - } |
| 49 | | -} |
| 50 | | - |
| 51 | 44 | #[component] |
| 52 | 45 | async fn sessions_view( |
| 53 | 46 | lang: Lang, |
| | @@ -57,50 +50,36 @@ async fn sessions_view( |
| 57 | 50 | ) -> Result<impl View> { |
| 58 | 51 | let others = sessions.iter().filter(|s| s.id != current_id).count(); |
| 59 | 52 | Ok(view! { |
| 60 | | - <section class="page-head"> |
| 61 | | - <h1>(t(lang, Key::Sessions))</h1> |
| 62 | | - if others > 0 { |
| 63 | | - <form method="post" action="/settings/sessions/revoke-others" class="inline-form"> |
| 64 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 65 | | - <button type="submit" class="danger">(t(lang, Key::RevokeAllOthers))</button> |
| 66 | | - </form> |
| 67 | | - } |
| 68 | | - </section> |
| 69 | | - <section class="card rows-pane session-pane"> |
| 53 | + <h1 class="sr-only">(t(lang, Key::Sessions))</h1> |
| 54 | + if others > 0 { |
| 55 | + <div class="acts"> |
| 56 | + confirm_act(lang: lang, label: t(lang, Key::RevokeAllOthers), action: "/settings/sessions/revoke-others", csrf: csrf, note: Some(s(lang, "Every other browser is signed out at once. This one stays signed in.", "Diğer tüm tarayıcılarda oturum hemen kapanır. Bu tarayıcıda oturum açık kalır.").to_owned())) |
| 57 | + </div> |
| 58 | + } |
| 59 | + <div> |
| 70 | 60 | for session in sessions.into_iter() { |
| 71 | | - <div class="row-line"> |
| 72 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg> |
| 73 | | - <div class="row-main"> |
| 74 | | - <strong class="row-name"><a href=(format!("/settings/sessions/{}", session.id)) data-dialog=(format!("session-{}", session.id))>(session_label(lang, &session))</a></strong> |
| 75 | | - if session.id == current_id { |
| 76 | | - <span class="badge public">(t(lang, Key::ThisSession))</span> |
| 77 | | - } |
| 78 | | - <p class="row-status"><span class="muted small">(i18n::dated_label(lang, Key::SignedIn)) " " rel_time(lang: lang, stamp: session.created_at.as_str()) " · " (i18n::dated_label(lang, Key::LastSeen)) " " rel_time(lang: lang, stamp: session.last_seen.as_str()) " · " (i18n::dated_label(lang, Key::ExpiresLabel)) " " rel_time(lang: lang, stamp: session.expires_at.as_str()) (address_text(&session))</span></p> |
| 79 | | - <dialog class="session-dialog" id=(format!("session-{}", session.id)) aria-labelledby=(format!("session-{}-title", session.id))> |
| 80 | | - <div class="session-dialog-head"> |
| 81 | | - <h2 id=(format!("session-{}-title", session.id))>(session_label(lang, &session))</h2> |
| 82 | | - <form method="dialog"> |
| 83 | | - <button type="submit">(t(lang, Key::Close))</button> |
| 84 | | - </form> |
| 85 | | - </div> |
| 86 | | - session_details(lang: lang, csrf: csrf, session: session.clone(), current: session.id == current_id) |
| 87 | | - </dialog> |
| 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 | + <p class="back-act"><a class="act" href=(format!("/settings/sessions/{}", session.id))>(s(lang, "Open page", "Sayfayı aç"))</a></p> |
| 88 | 74 | </div> |
| 89 | | - if session.id != current_id { |
| 90 | | - <form method="post" action="/settings/sessions/revoke" class="row-form"> |
| 91 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 92 | | - <input type="hidden" name="id" value=(session.id.clone())> |
| 93 | | - <button type="submit" class="danger">(t(lang, Key::Revoke))</button> |
| 94 | | - </form> |
| 95 | | - } |
| 96 | | - </div> |
| 75 | + </details> |
| 97 | 76 | } |
| 98 | | - </section> |
| 77 | + </div> |
| 99 | 78 | }) |
| 100 | 79 | } |
| 101 | 80 | |
| 102 | | -/// The facts about one session, shared by its dialog on the list and its detail page: the badge |
| 103 | | -/// when it is the current session, the key/value grid, and the revoke button for any other one. |
| 81 | +/// The facts about one session, shared by its row on the list and its detail page: the badge |
| 82 | +/// when it is the current session, the key/value grid, and the revoke action for any other one. |
| 104 | 83 | #[component] |
| 105 | 84 | async fn session_details( |
| 106 | 85 | lang: Lang, |
| | @@ -124,7 +103,7 @@ async fn session_details( |
| 124 | 103 | let id = session.id.clone(); |
| 125 | 104 | Ok(view! { |
| 126 | 105 | if current { |
| 127 | | - <p><span class="badge public">(t(lang, Key::ThisSession))</span></p> |
| 106 | + <p class="state">(t(lang, Key::ThisSession))</p> |
| 128 | 107 | } |
| 129 | 108 | <dl class="kv-grid"> |
| 130 | 109 | <div><dt>(t(lang, Key::UserAgent))</dt><dd>(user_agent.as_str())</dd></div> |
| | @@ -135,11 +114,9 @@ async fn session_details( |
| 135 | 114 | <div><dt>(t(lang, Key::ExpiresAt))</dt><dd>rel_time(lang: lang, stamp: session.expires_at.as_str())</dd></div> |
| 136 | 115 | </dl> |
| 137 | 116 | if !current { |
| 138 | | - <form method="post" action="/settings/sessions/revoke"> |
| 139 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 140 | | - <input type="hidden" name="id" value=(id.as_str())> |
| 141 | | - <button type="submit" class="danger">(t(lang, Key::Revoke))</button> |
| 142 | | - </form> |
| 117 | + <div class="acts"> |
| 118 | + 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())) |
| 119 | + </div> |
| 143 | 120 | } |
| 144 | 121 | }) |
| 145 | 122 | } |
| | @@ -152,13 +129,10 @@ async fn session_detail_view( |
| 152 | 129 | current: bool, |
| 153 | 130 | ) -> Result<impl View> { |
| 154 | 131 | Ok(view! { |
| 155 | | - <section class="page-head"> |
| 156 | | - <h1>(session_label(lang, &session))</h1> |
| 157 | | - </section> |
| 158 | | - <section class="card"> |
| 159 | | - session_details(lang: lang, csrf: csrf, session: session, current: current) |
| 160 | | - <p><a href="/settings/sessions">(t(lang, Key::BackToSessions))</a></p> |
| 161 | | - </section> |
| 132 | + <h1 class="h1">(session_label(lang, &session))</h1> |
| 133 | + <p class="hint">(i18n::dated_label(lang, Key::LastSeen)) " " rel_time(lang: lang, stamp: session.last_seen.as_str())</p> |
| 134 | + session_details(lang: lang, csrf: csrf, session: session.clone(), current: current) |
| 135 | + <p class="back-act"><a class="act" href="/settings/sessions">(t(lang, Key::BackToSessions))</a></p> |
| 162 | 136 | }) |
| 163 | 137 | } |
| 164 | 138 | |
| | @@ -280,7 +254,7 @@ mod tests { |
| 280 | 254 | const CSRF: &str = "sessions-test-csrf"; |
| 281 | 255 | |
| 282 | 256 | #[tokio::test] |
| 283 | | - async fn sessions_list_renders_a_dialog_per_session() { |
| 257 | + async fn sessions_list_renders_a_row_open_per_session() { |
| 284 | 258 | let dir = tempfile::tempdir().expect("tempdir"); |
| 285 | 259 | let state = crate::test_support::test_state(dir.path()).await; |
| 286 | 260 | let store = state.store.clone(); |
| | @@ -307,9 +281,10 @@ mod tests { |
| 307 | 281 | assert_eq!(res.status().as_u16(), 200); |
| 308 | 282 | let body = to_bytes(res.into_body(), usize::MAX).await.expect("body"); |
| 309 | 283 | let html = String::from_utf8_lossy(&body); |
| 310 | | - let id = format!("session-{}", current.id); |
| 311 | | - assert!(html.contains(&format!("<dialog class=\"session-dialog\" id=\"{id}\""))); |
| 312 | | - assert!(html.contains(&format!("data-dialog=\"{id}\""))); |
| 284 | + assert!(html.contains("<details class=\"row-open\">")); |
| 285 | + assert!(html.contains("<div class=\"opened\">")); |
| 286 | + assert!(html.contains("<dl class=\"kv-grid\">")); |
| 287 | + assert!(html.contains(&format!("href=\"/settings/sessions/{}\"", current.id))); |
| 313 | 288 | } |
| 314 | 289 | |
| 315 | 290 | #[tokio::test] |
| | @@ -1,4 +1,4 @@ |
| 1 | | -//! Page: access tokens (`/settings/tokens`). Tokens are shown once, at creation. |
| 1 | +//! Access tokens, a section of `/settings/keys`. Tokens are shown once, at creation. |
| 2 | 2 | |
| 3 | 3 | use std::time::Duration; |
| 4 | 4 | |
| | @@ -22,9 +22,10 @@ use crate::auth::{require_csrf, require_user}; |
| 22 | 22 | use crate::i18n::packages::{self as pk, K as PK}; |
| 23 | 23 | use crate::i18n::releases_ci::{self as rc, K as RC}; |
| 24 | 24 | use crate::i18n::{self, Key, Lang, t, token_name_length}; |
| 25 | | -use crate::pages::admin_runners::confirm_post; |
| 25 | +use crate::pages::settings_keys::{KeysDraft, keys_page_view}; |
| 26 | 26 | use crate::state::AppState; |
| 27 | | -use crate::views::{alert, rel_time, rel_time_or_never, shell}; |
| 27 | +use crate::views::parts::{confirm_act, reveal}; |
| 28 | +use crate::views::{alert, rel_time, rel_time_or_never}; |
| 28 | 29 | |
| 29 | 30 | /// Scopes are fixed to `repo` for M1. |
| 30 | 31 | const SCOPES: &[&str] = &["repo"]; |
| | @@ -51,18 +52,11 @@ struct DeleteTokenForm { |
| 51 | 52 | id: String, |
| 52 | 53 | } |
| 53 | 54 | |
| 54 | | -/// The question the delete popover asks before a token is revoked. |
| 55 | | -fn delete_message(lang: Lang, name: &str) -> String { |
| 55 | +/// What deleting a token costs. |
| 56 | +fn delete_message(lang: Lang) -> &'static str { |
| 56 | 57 | match lang { |
| 57 | | - Lang::Tr => format!("{name} silinsin mi? Bu token ile çalışan her şey hemen durur."), |
| 58 | | - _ => format!("Delete token {name}? Anything using it stops working at once."), |
| 59 | | - } |
| 60 | | -} |
| 61 | | - |
| 62 | | -fn delete_confirm(lang: Lang) -> &'static str { |
| 63 | | - match lang { |
| 64 | | - Lang::Tr => "Evet, sil", |
| 65 | | - _ => "Yes, delete", |
| 58 | + Lang::Tr => "Bu token ile çalışan her şey hemen durur.", |
| 59 | + _ => "Anything using it stops working at once.", |
| 66 | 60 | } |
| 67 | 61 | } |
| 68 | 62 | |
| | @@ -78,102 +72,93 @@ fn expiry_days(choice: &str) -> Option<u64> { |
| 78 | 72 | } |
| 79 | 73 | |
| 80 | 74 | #[component] |
| 81 | | -async fn tokens_view( |
| 75 | +pub(crate) async fn tokens_section( |
| 82 | 76 | lang: Lang, |
| 83 | 77 | csrf: &str, |
| 84 | 78 | tokens: Vec<AccessToken>, |
| 85 | 79 | created: Option<String>, |
| 86 | 80 | error: Option<String>, |
| 87 | 81 | ) -> Result<impl View> { |
| 82 | + let empty = tokens.is_empty(); |
| 83 | + let open = error.is_some(); |
| 88 | 84 | Ok(view! { |
| 89 | | - <section class="page-head"> |
| 90 | | - <h1>(t(lang, Key::AccessTokens))</h1> |
| 91 | | - </section> |
| 92 | | - if let Some(token) = created { |
| 93 | | - <section class="card notice" role="status" data-once=""> |
| 94 | | - <h2>(t(lang, Key::YourNewToken))</h2> |
| 95 | | - <p>(t(lang, Key::CopyNow))</p> |
| 96 | | - <div class="copy-box"> |
| 97 | | - <pre class="code"><code id="new-token">(token)</code></pre> |
| 98 | | - <button type="button" data-copy="new-token" data-copied=(rc::t(lang, RC::CopyDone)) data-failed=(rc::t(lang, RC::CopyFailed))>(pk::t(lang, PK::CopyCommand))</button> |
| 99 | | - </div> |
| 100 | | - <p class="muted small">(t(lang, Key::UseAsPassword))</p> |
| 101 | | - </section> |
| 102 | | - } |
| 103 | | - <section class="card rows-pane"> |
| 104 | | - <div class="row-line"> |
| 105 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 106 | | - <div class="row-main"> |
| 107 | | - <h2 class="row-title">(t(lang, Key::NewToken))</h2> |
| 108 | | - if tokens.is_empty() { |
| 109 | | - <p class="row-status">(t(lang, Key::NoAccessTokens))</p> |
| 110 | | - } |
| 111 | | - </div> |
| 112 | | - <details class="row-action" id="add-token" open=(error.is_some())> |
| 113 | | - <summary>(t(lang, Key::CreateToken))</summary> |
| 114 | | - <div class="row-panel"> |
| 115 | | - if let Some(message) = error { |
| 116 | | - alert(message: message.as_str()) |
| 117 | | - } |
| 118 | | - <form method="post" action="/settings/tokens" class="stack"> |
| 119 | | - <input type="hidden" name="csrf" value=(csrf)> |
| 120 | | - <label> |
| 121 | | - <span>(t(lang, Key::Name))</span> |
| 122 | | - <input type="text" name="name" maxlength="64" required=(true) autocomplete="off"> |
| 123 | | - </label> |
| 124 | | - <label> |
| 125 | | - <span>(t(lang, Key::Expires))</span> |
| 126 | | - <select name="expires"> |
| 127 | | - <option value="30">(t(lang, Key::ExpiresIn30))</option> |
| 128 | | - <option value="90" selected=(true)>(t(lang, Key::ExpiresIn90))</option> |
| 129 | | - <option value="365">(t(lang, Key::ExpiresIn365))</option> |
| 130 | | - <option value="never">(t(lang, Key::ExpiresNever))</option> |
| 131 | | - </select> |
| 132 | | - </label> |
| 133 | | - <label class="checkbox"> |
| 134 | | - <input type="checkbox" name="packages" value="on"> |
| 135 | | - <span>(pk::t(lang, PK::ScopePackages))</span> |
| 136 | | - </label> |
| 137 | | - <p class="muted small">(pk::t(lang, PK::ScopePackagesHelp))</p> |
| 138 | | - <p class="muted small">(t(lang, Key::ScopeNote))</p> |
| 139 | | - <button type="submit" class="primary">(t(lang, Key::CreateToken))</button> |
| 140 | | - </form> |
| 141 | | - </div> |
| 142 | | - </details> |
| 143 | | - </div> |
| 144 | | - for token in tokens.into_iter() { |
| 145 | | - <div class="row-line"> |
| 146 | | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="7" width="18" height="10" rx="2"/><path d="M8 12h.01M12 12h.01M16 12h.01"/></svg> |
| 147 | | - <div class="row-main"> |
| 148 | | - <strong class="row-name">(token.name.clone())</strong> |
| 149 | | - <p class="row-status">(i18n::dated_label(lang, Key::Created)) " " rel_time(lang: lang, stamp: token.created_at.as_str()) " · " (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())</p> |
| 85 | + <section class="sec" id="tokens"> |
| 86 | + <h2>(t(lang, Key::AccessTokens))</h2> |
| 87 | + if let Some(token) = created { |
| 88 | + <div class="opened" role="status" data-once=""> |
| 89 | + <p class="state">(t(lang, Key::YourNewToken))</p> |
| 90 | + <p class="hint">(t(lang, Key::CopyNow))</p> |
| 91 | + <div class="copy-box"> |
| 92 | + <pre class="code"><code id="new-token">(token)</code></pre> |
| 93 | + <button type="button" data-copy="new-token" data-copied=(rc::t(lang, RC::CopyDone)) data-failed=(rc::t(lang, RC::CopyFailed))>(pk::t(lang, PK::CopyCommand))</button> |
| 150 | 94 | </div> |
| 151 | | - confirm_post(lang: lang, csrf: csrf, action: "/settings/tokens/delete", label: t(lang, Key::Delete), message: delete_message(lang, token.name.as_str()), confirm: delete_confirm(lang), danger: true, fields: vec![("id", token.id.clone())]) |
| 95 | + <p class="hint">(t(lang, Key::UseAsPassword))</p> |
| 152 | 96 | </div> |
| 153 | 97 | } |
| 98 | + if empty { |
| 99 | + <p class="state">(t(lang, Key::NoAccessTokens))</p> |
| 100 | + } |
| 101 | + <div> |
| 102 | + for token in tokens.into_iter() { |
| 103 | + <details class="row-open"> |
| 104 | + <summary class="line"> |
| 105 | + <span class="name">(token.name.clone())</span> |
| 106 | + <span class="val">(i18n::dated_label(lang, Key::LastUsed)) " " rel_time_or_never(lang: lang, stamp: token.last_used_at.as_deref()) ", " (i18n::dated_label(lang, Key::ExpiresLabel)) " " rel_time_or_never(lang: lang, stamp: token.expires_at.as_deref())</span> |
| 107 | + </summary> |
| 108 | + <div class="opened"> |
| 109 | + <p class="hint">(i18n::dated_label(lang, Key::Created)) " " rel_time(lang: lang, stamp: token.created_at.as_str())</p> |
| 110 | + <div class="acts"> |
| 111 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/tokens/delete", csrf: csrf, fields: vec![("id".to_owned(), token.id.clone())], note: Some(delete_message(lang).to_owned())) |
| 112 | + </div> |
| 113 | + </div> |
| 114 | + </details> |
| 115 | + } |
| 116 | + </div> |
| 117 | + <div class="acts"> |
| 118 | + reveal(label: t(lang, Key::NewToken), id: Some("add-token"), open: open, |
| 119 | + if let Some(message) = error { |
| 120 | + alert(message: message.as_str()) |
| 121 | + } |
| 122 | + <form method="post" action="/settings/tokens" class="fields"> |
| 123 | + <input type="hidden" name="csrf" value=(csrf)> |
| 124 | + <div class="field"> |
| 125 | + <label for="token-name">(t(lang, Key::Name))</label> |
| 126 | + <input id="token-name" type="text" name="name" maxlength="64" required=(true) autocomplete="off"> |
| 127 | + </div> |
| 128 | + <div class="field"> |
| 129 | + <label for="token-expires">(t(lang, Key::Expires))</label> |
| 130 | + <select id="token-expires" name="expires"> |
| 131 | + <option value="30">(t(lang, Key::ExpiresIn30))</option> |
| 132 | + <option value="90" selected=(true)>(t(lang, Key::ExpiresIn90))</option> |
| 133 | + <option value="365">(t(lang, Key::ExpiresIn365))</option> |
| 134 | + <option value="never">(t(lang, Key::ExpiresNever))</option> |
| 135 | + </select> |
| 136 | + </div> |
| 137 | + <label class="switch"> |
| 138 | + <input type="checkbox" name="packages" value="on"> |
| 139 | + <span>(pk::t(lang, PK::ScopePackages))</span> |
| 140 | + </label> |
| 141 | + <p class="hint">(pk::t(lang, PK::ScopePackagesHelp)) " " (t(lang, Key::ScopeNote))</p> |
| 142 | + <button type="submit" class="primary">(t(lang, Key::CreateToken))</button> |
| 143 | + </form> |
| 144 | + ) |
| 145 | + </div> |
| 154 | 146 | </section> |
| 155 | 147 | }) |
| 156 | 148 | } |
| 157 | 149 | |
| 158 | | -#[page("/settings/tokens")] |
| 159 | | -async fn tokens_page(cx: &Cx) -> Result<impl View> { |
| 160 | | - let viewer = require_user(cx).await?; |
| 161 | | - let lang = i18n::lang(cx, Some(&viewer.0)); |
| 162 | | - let tokens = app_context::<AppState>(cx) |
| 163 | | - .store |
| 164 | | - .list_tokens(&viewer.0.id) |
| 165 | | - .await?; |
| 166 | | - let csrf = viewer.1.csrf_token.clone(); |
| 167 | | - Ok(view! { |
| 168 | | - shell(title: t(lang, Key::AccessTokens), viewer: Some(&viewer), tokens_view(lang: lang, csrf: csrf.as_str(), tokens: tokens, created: None, error: None)) |
| 169 | | - }) |
| 150 | +#[route(GET "/settings/tokens")] |
| 151 | +async fn tokens_page(cx: &Cx) -> Result<SeeOther> { |
| 152 | + require_user(cx).await?; |
| 153 | + Ok(see_other("/settings/keys#tokens")) |
| 170 | 154 | } |
| 171 | 155 | |
| 172 | 156 | #[page(POST "/settings/tokens")] |
| 173 | 157 | async fn tokens_create(cx: &Cx, Form(form): Form<CreateTokenForm>) -> Result<impl View> { |
| 174 | 158 | let viewer = require_csrf(cx, &form.csrf).await?; |
| 175 | 159 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 176 | | - let store = &app_context::<AppState>(cx).store; |
| 160 | + let state = app_context::<AppState>(cx); |
| 161 | + let store = &state.store; |
| 177 | 162 | let name = form.name.trim(); |
| 178 | 163 | |
| 179 | 164 | // Some(message) on invalid input; otherwise the new token to show once. |
| | @@ -223,10 +208,13 @@ async fn tokens_create(cx: &Cx, Form(form): Form<CreateTokenForm>) -> Result<imp |
| 223 | 208 | |
| 224 | 209 | // The response may carry the plaintext token, so keep it out of caches. |
| 225 | 210 | response_headers(cx).append(CACHE_CONTROL, HeaderValue::from_static("no-store")); |
| 226 | | - let tokens = store.list_tokens(&viewer.0.id).await?; |
| 227 | | - let csrf = viewer.1.csrf_token.clone(); |
| 211 | + let draft = KeysDraft { |
| 212 | + token: created, |
| 213 | + token_error: error, |
| 214 | + ..KeysDraft::default() |
| 215 | + }; |
| 228 | 216 | Ok(view! { |
| 229 | | - shell(title: t(lang, Key::AccessTokens), viewer: Some(&viewer), tokens_view(lang: lang, csrf: csrf.as_str(), tokens: tokens, created: created, error: error)) |
| 217 | + keys_page_view(lang: lang, state: state, viewer: &viewer, draft: draft) |
| 230 | 218 | }) |
| 231 | 219 | } |
| 232 | 220 | |
| | @@ -249,7 +237,7 @@ async fn tokens_delete(cx: &Cx, Form(form): Form<DeleteTokenForm>) -> Result<See |
| 249 | 237 | ) |
| 250 | 238 | .await; |
| 251 | 239 | } |
| 252 | | - Ok(see_other("/settings/tokens")) |
| 240 | + Ok(see_other("/settings/keys")) |
| 253 | 241 | } |
| 254 | 242 | |
| 255 | 243 | #[cfg(test)] |
| | @@ -42,31 +42,31 @@ async fn setup_form( |
| 42 | 42 | error: Option<String>, |
| 43 | 43 | ) -> Result<impl View> { |
| 44 | 44 | Ok(view! { |
| 45 | | - <section class="card narrow"> |
| 45 | + <section> |
| 46 | 46 | <h1>(t(lang, Key::WelcomeToForge))</h1> |
| 47 | | - <p class="muted">(t(lang, Key::SetupSub))</p> |
| 48 | | - if let Some(message) = error { |
| 49 | | - alert(message: message.as_str()) |
| 50 | | - } |
| 51 | | - <form data-hard="true" method="post" action="/setup" class="stack"> |
| 47 | + <p class="hint">(t(lang, Key::SetupSub))</p> |
| 48 | + <form data-hard="true" method="post" action="/setup" class="fields"> |
| 49 | + if let Some(message) = error { |
| 50 | + alert(message: message.as_str()) |
| 51 | + } |
| 52 | 52 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 53 | | - <label> |
| 54 | | - <span>(t(lang, Key::Username))</span> |
| 55 | | - <input type="text" name="username" value=(username) autocomplete="username" required=(true)> |
| 56 | | - </label> |
| 57 | | - <label> |
| 58 | | - <span>(t(lang, Key::EmailOptional))</span> |
| 59 | | - <input type="email" name="email" value=(email) autocomplete="email"> |
| 60 | | - </label> |
| 61 | | - <label> |
| 62 | | - <span>(t(lang, Key::Password))</span> |
| 63 | | - <input type="password" name="password" autocomplete="new-password" required=(true)> |
| 64 | | - <small class="muted">(t(lang, Key::AtLeast12Chars))</small> |
| 65 | | - </label> |
| 66 | | - <label> |
| 67 | | - <span>(t(lang, Key::ConfirmPassword))</span> |
| 68 | | - <input type="password" name="confirm" autocomplete="new-password" required=(true)> |
| 69 | | - </label> |
| 53 | + <div class="field"> |
| 54 | + <label for="setup-username">(t(lang, Key::Username))</label> |
| 55 | + <input id="setup-username" type="text" name="username" value=(username) autocomplete="username" required=(true)> |
| 56 | + </div> |
| 57 | + <div class="field"> |
| 58 | + <label for="setup-email">(t(lang, Key::EmailOptional))</label> |
| 59 | + <input id="setup-email" type="email" name="email" value=(email) autocomplete="email"> |
| 60 | + </div> |
| 61 | + <div class="field"> |
| 62 | + <label for="setup-password">(t(lang, Key::Password))</label> |
| 63 | + <input id="setup-password" type="password" name="password" autocomplete="new-password" required=(true)> |
| 64 | + <p class="hint">(t(lang, Key::AtLeast12Chars))</p> |
| 65 | + </div> |
| 66 | + <div class="field"> |
| 67 | + <label for="setup-confirm">(t(lang, Key::ConfirmPassword))</label> |
| 68 | + <input id="setup-confirm" type="password" name="confirm" autocomplete="new-password" required=(true)> |
| 69 | + </div> |
| 70 | 70 | <button type="submit" class="primary">(t(lang, Key::CreateAdmin))</button> |
| 71 | 71 | </form> |
| 72 | 72 | </section> |
| | @@ -27,6 +27,7 @@ use crate::pages::snippets_live::{bump_snippet, item_live_url, list_live_url}; |
| 27 | 27 | use crate::render::highlight::highlight_lines; |
| 28 | 28 | use crate::render::markdown::render_markdown; |
| 29 | 29 | use crate::state::AppState; |
| 30 | +use crate::views::parts::confirm_act; |
| 30 | 31 | use crate::views::{alert, empty_state, rel_time, shell, user_facing_message}; |
| 31 | 32 | |
| 32 | 33 | path_param!(id); |
| | @@ -276,18 +277,14 @@ async fn owned(cx: &Cx, user: &User, snippet_id: &str) -> Result<Snippet> { |
| 276 | 277 | #[component] |
| 277 | 278 | pub(crate) async fn snippet_rows(lang: Lang, rows: Vec<ListRow>) -> Result<impl View> { |
| 278 | 279 | Ok(view! { |
| 279 | | - <ul class="item-list snippet-list"> |
| 280 | + <div class="snippet-list"> |
| 280 | 281 | for row in rows.into_iter() { |
| 281 | | - <li class="item"> |
| 282 | | - <div class="item-main"> |
| 283 | | - <a href=(format!("/snippets/{}", row.id))><strong>(row.title)</strong></a> |
| 284 | | - <span class="muted small"> |
| 285 | | - (row.owner) " · " (row.visibility) " · " (row.files) " · " (g::updated_before(lang)) rel_time(lang: lang, stamp: row.updated_at.as_str()) (g::updated_after(lang)) |
| 286 | | - </span> |
| 287 | | - </div> |
| 288 | | - </li> |
| 282 | + <a class="line" href=(format!("/snippets/{}", row.id)) data-kb-row=""> |
| 283 | + <span class="name">(row.title)</span> |
| 284 | + <span class="val">(row.owner) " · " (row.visibility) " · " (row.files) " · " (g::updated_before(lang)) rel_time(lang: lang, stamp: row.updated_at.as_str()) (g::updated_after(lang))</span> |
| 285 | + </a> |
| 289 | 286 | } |
| 290 | | - </ul> |
| 287 | + </div> |
| 291 | 288 | }) |
| 292 | 289 | } |
| 293 | 290 | |
| | @@ -299,19 +296,19 @@ async fn snippet_list_body( |
| 299 | 296 | live: Option<String>, |
| 300 | 297 | ) -> Result<impl View> { |
| 301 | 298 | Ok(view! { |
| 302 | | - <section class="page-head" data-live=(live.as_deref())> |
| 303 | | - <h1>(g::t(lang, K::Snippets))</h1> |
| 299 | + <div data-live=(live.as_deref())> |
| 300 | + <h1 class="sr-only">(g::t(lang, K::Snippets))</h1> |
| 304 | 301 | if signed_in { |
| 305 | | - <a class="button primary" href="/snippets/new">(g::t(lang, K::NewSnippet))</a> |
| 302 | + <div class="acts"> |
| 303 | + <a class="act" href="/snippets/new">(g::t(lang, K::NewSnippet))</a> |
| 304 | + </div> |
| 306 | 305 | } |
| 307 | | - </section> |
| 308 | | - <section class="card list-pane fit-pane"> |
| 309 | 306 | if rows.is_empty() { |
| 310 | 307 | empty_state(title: g::t(lang, K::NoSnippets)) |
| 311 | 308 | } else { |
| 312 | 309 | snippet_rows(lang: lang, rows: rows) |
| 313 | 310 | } |
| 314 | | - </section> |
| 311 | + </div> |
| 315 | 312 | }) |
| 316 | 313 | } |
| 317 | 314 | |
| | @@ -355,31 +352,33 @@ async fn snippet_files( |
| 355 | 352 | name="tab" value=(number.to_string()) checked=(checked)> |
| 356 | 353 | <label class="snippet-tab" for=(format!("snippet-tab-{number}"))>(label)</label> |
| 357 | 354 | } |
| 358 | | - if can_add { |
| 359 | | - <button type="submit" class="ghost snippet-tab-add" name="op" value="add" formnovalidate=(true) |
| 360 | | - title=(g::t(lang, K::AddFile)) aria-label=(g::t(lang, K::AddFile))> |
| 361 | | - <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> |
| 362 | | - </button> |
| 363 | | - } |
| 364 | 355 | </div> |
| 365 | | - <span class="snippet-count muted small">(counter)</span> |
| 356 | + <p class="hint snippet-count">(counter)</p> |
| 366 | 357 | </div> |
| 358 | + if can_add { |
| 359 | + <div class="acts"> |
| 360 | + <button type="submit" class="act snippet-tab-add" name="op" value="add" formnovalidate=(true)>(g::t(lang, K::AddFile))</button> |
| 361 | + </div> |
| 362 | + } |
| 367 | 363 | for (index, slot) in slots.into_iter().enumerate() { |
| 368 | 364 | <fieldset class=(format!("snippet-panel snippet-panel-{}", slot.number))> |
| 369 | 365 | <legend class="sr-only">(g::t(lang, K::FileLabel))(index + 1)</legend> |
| 370 | | - <div class="snippet-slot-head"> |
| 371 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg> |
| 372 | | - <input type="text" class="snippet-name" name=(format!("name_{}", slot.number)) value=(slot.name) |
| 373 | | - maxlength="100" placeholder=(g::t(lang, K::FileNamePlaceholder)) aria-label=(g::t(lang, K::FileName))> |
| 374 | | - if removable { |
| 375 | | - <button type="submit" class="ghost snippet-remove" name="remove" value=(slot.number.to_string()) |
| 376 | | - formnovalidate=(true) title=(g::t(lang, K::RemoveFile)) aria-label=(g::t(lang, K::RemoveFile))> |
| 377 | | - <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"/></svg> |
| 378 | | - </button> |
| 379 | | - } |
| 366 | + <div class="field"> |
| 367 | + <label for=(format!("snippet-name-{}", slot.number))>(g::t(lang, K::FileName))</label> |
| 368 | + <input type="text" id=(format!("snippet-name-{}", slot.number)) class="snippet-name" name=(format!("name_{}", slot.number)) value=(slot.name) |
| 369 | + maxlength="100" placeholder=(g::t(lang, K::FileNamePlaceholder))> |
| 380 | 370 | </div> |
| 381 | | - <textarea class="code snippet-content" name=(format!("content_{}", slot.number)) |
| 382 | | - spellcheck="false" aria-label=(g::t(lang, K::FileContents))>(slot.content)</textarea> |
| 371 | + <div class="field"> |
| 372 | + <label for=(format!("snippet-content-{}", slot.number))>(g::t(lang, K::FileContents))</label> |
| 373 | + <textarea id=(format!("snippet-content-{}", slot.number)) class="code snippet-content" name=(format!("content_{}", slot.number)) |
| 374 | + spellcheck="false">(slot.content)</textarea> |
| 375 | + </div> |
| 376 | + if removable { |
| 377 | + <div class="acts"> |
| 378 | + <button type="submit" class="act quiet snippet-remove" name="remove" value=(slot.number.to_string()) |
| 379 | + formnovalidate=(true)>(g::t(lang, K::RemoveFile))</button> |
| 380 | + </div> |
| 381 | + } |
| 383 | 382 | </fieldset> |
| 384 | 383 | } |
| 385 | 384 | </div> |
| | @@ -416,44 +415,37 @@ async fn snippet_form( |
| 416 | 415 | if let Some(message) = error { |
| 417 | 416 | alert(message: message.as_str()) |
| 418 | 417 | } |
| 419 | | - <form method="post" action=(action) class="snippet-form fit-pane"> |
| 418 | + <h1 class="sr-only">(heading)</h1> |
| 419 | + <form method="post" action=(action) class="fields snippet-form"> |
| 420 | 420 | <input type="hidden" name="csrf" value=(csrf)> |
| 421 | | - <header class="snippet-head page-head"> |
| 422 | | - <h1>(heading)</h1> |
| 423 | | - <div class="snippet-head-actions"> |
| 424 | | - <fieldset class="snippet-visibility"> |
| 425 | | - <legend class="sr-only">(g::t(lang, K::Visibility))</legend> |
| 426 | | - <div class="segmented snippet-segmented"> |
| 427 | | - <label class="segment" title=(g::t(lang, K::PublicOption))> |
| 428 | | - <input type="radio" name="visibility" value="public" checked=(public)> |
| 429 | | - <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"/></svg> |
| 430 | | - <span>(g::t(lang, K::VisibilityPublic))</span> |
| 431 | | - </label> |
| 432 | | - <label class="segment" title=(g::t(lang, K::UnlistedOption))> |
| 433 | | - <input type="radio" name="visibility" value="unlisted" checked=(unlisted)> |
| 434 | | - <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7"/><path d="M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7"/></svg> |
| 435 | | - <span>(g::t(lang, K::VisibilityUnlisted))</span> |
| 436 | | - </label> |
| 437 | | - <label class="segment" title=(g::t(lang, K::PrivateOption))> |
| 438 | | - <input type="radio" name="visibility" value="private" checked=(private)> |
| 439 | | - <svg viewBox="0 0 24 24" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg> |
| 440 | | - <span>(g::t(lang, K::VisibilityPrivate))</span> |
| 441 | | - </label> |
| 442 | | - </div> |
| 443 | | - </fieldset> |
| 444 | | - <button type="submit" class="primary">(g::t(lang, K::SaveSnippet))</button> |
| 445 | | - </div> |
| 446 | | - </header> |
| 447 | | - <div class="snippet-doc"> |
| 448 | | - <div class="snippet-meta"> |
| 449 | | - <input type="text" class="snippet-title" name="title" value=(title) maxlength="120" required=(true) |
| 450 | | - placeholder=(g::t(lang, K::SnippetTitlePlaceholder)) aria-label=(g::t(lang, K::Title))> |
| 451 | | - <input type="text" class="snippet-desc" name="description" value=(description) maxlength="1000" |
| 452 | | - placeholder=(g::t(lang, K::DescriptionOptional)) aria-label=(g::t(lang, K::Description))> |
| 453 | | - </div> |
| 454 | | - snippet_files(lang: lang, slots: slots, active: active, removable: removable, can_add: can_add, |
| 455 | | - counter: counter) |
| 421 | + <div class="field"> |
| 422 | + <label for="snippet-title">(g::t(lang, K::Title))</label> |
| 423 | + <input id="snippet-title" type="text" class="snippet-title" name="title" value=(title) maxlength="120" required=(true) |
| 424 | + placeholder=(g::t(lang, K::SnippetTitlePlaceholder))> |
| 425 | + </div> |
| 426 | + <div class="field"> |
| 427 | + <label for="snippet-description">(g::t(lang, K::Description))</label> |
| 428 | + <input id="snippet-description" type="text" class="snippet-desc" name="description" value=(description) maxlength="1000" |
| 429 | + placeholder=(g::t(lang, K::DescriptionOptional))> |
| 456 | 430 | </div> |
| 431 | + <div class="field" role="radiogroup" aria-labelledby="snippet-visibility"> |
| 432 | + <p class="state" id="snippet-visibility">(g::t(lang, K::Visibility))</p> |
| 433 | + <label class="switch" title=(g::t(lang, K::PublicOption))> |
| 434 | + <input type="radio" name="visibility" value="public" checked=(public)> |
| 435 | + <span>(g::t(lang, K::VisibilityPublic))</span> |
| 436 | + </label> |
| 437 | + <label class="switch" title=(g::t(lang, K::UnlistedOption))> |
| 438 | + <input type="radio" name="visibility" value="unlisted" checked=(unlisted)> |
| 439 | + <span>(g::t(lang, K::VisibilityUnlisted))</span> |
| 440 | + </label> |
| 441 | + <label class="switch" title=(g::t(lang, K::PrivateOption))> |
| 442 | + <input type="radio" name="visibility" value="private" checked=(private)> |
| 443 | + <span>(g::t(lang, K::VisibilityPrivate))</span> |
| 444 | + </label> |
| 445 | + </div> |
| 446 | + <button type="submit" class="primary">(g::t(lang, K::SaveSnippet))</button> |
| 447 | + snippet_files(lang: lang, slots: slots, active: active, removable: removable, can_add: can_add, |
| 448 | + counter: counter) |
| 457 | 449 | </form> |
| 458 | 450 | }) |
| 459 | 451 | } |
| | @@ -476,31 +468,28 @@ async fn snippet_body( |
| 476 | 468 | let history_href = format!("/snippets/{snippet_id}/revisions"); |
| 477 | 469 | let delete_action = format!("/snippets/{snippet_id}/delete"); |
| 478 | 470 | Ok(view! { |
| 479 | | - <section class="page-head snippet-view-head" data-live=(live.as_deref())> |
| 480 | | - <h1>(title)</h1> |
| 481 | | - <span class="muted small">(owner) " · " (visibility) " · " (g::updated_before(lang)) rel_time(lang: lang, stamp: updated_at) (g::updated_after(lang))</span> |
| 482 | | - </section> |
| 471 | + <div data-live=(live.as_deref())> |
| 472 | + <h1 class="h1">(title)</h1> |
| 473 | + <p class="hint">(owner) " · " (visibility) " · " (g::updated_before(lang)) rel_time(lang: lang, stamp: updated_at) (g::updated_after(lang))</p> |
| 474 | + </div> |
| 483 | 475 | if !description.is_empty() { |
| 484 | | - <p class="snippet-description">(description)</p> |
| 476 | + <p class="state">(description)</p> |
| 485 | 477 | } |
| 486 | | - <nav class="snippet-actions" aria-label=(g::t(lang, K::SnippetNav))> |
| 487 | | - <a class="button" href=(history_href)>(g::t(lang, K::Revisions))</a> |
| 488 | | - if let Some(token) = owner_csrf { |
| 489 | | - <a class="button" href=(edit_href)>(g::t(lang, K::Edit))</a> |
| 490 | | - <form method="post" action=(delete_action) class="inline-form"> |
| 491 | | - <input type="hidden" name="csrf" value=(token.as_str())> |
| 492 | | - <button type="submit" class="danger">(g::t(lang, K::Delete))</button> |
| 493 | | - </form> |
| 494 | | - } |
| 478 | + <nav class="sub" aria-label=(g::t(lang, K::SnippetNav))> |
| 479 | + <a href=(history_href)>(g::t(lang, K::Revisions))</a> |
| 495 | 480 | </nav> |
| 481 | + if let Some(token) = owner_csrf { |
| 482 | + <div class="acts"> |
| 483 | + <a class="act" href=(edit_href)>(g::t(lang, K::Edit))</a> |
| 484 | + confirm_act(lang: lang, label: g::t(lang, K::Delete), action: delete_action.as_str(), csrf: token.as_str()) |
| 485 | + </div> |
| 486 | + } |
| 496 | 487 | for file in files.into_iter() { |
| 497 | | - <section class="file snippet-file"> |
| 498 | | - <header class="file-head"> |
| 499 | | - <strong>(file.name.clone())</strong> |
| 500 | | - <nav class="file-actions" aria-label=(g::t(lang, K::FileNav))> |
| 501 | | - <a href=(file.raw.clone())>(g::t(lang, K::Raw))</a> |
| 502 | | - </nav> |
| 503 | | - </header> |
| 488 | + <section class="sec snippet-file"> |
| 489 | + <h2>(file.name.clone())</h2> |
| 490 | + <nav class="sub" aria-label=(g::t(lang, K::FileNav))> |
| 491 | + <a href=(file.raw.clone())>(g::t(lang, K::Raw))</a> |
| 492 | + </nav> |
| 504 | 493 | if file.markdown { |
| 505 | 494 | <div class="markdown-body">(Unescaped::new_unchecked(file.body.clone()))</div> |
| 506 | 495 | } else if file.highlighted { |
| | @@ -511,7 +500,7 @@ async fn snippet_body( |
| 511 | 500 | </section> |
| 512 | 501 | } |
| 513 | 502 | if !is_owner { |
| 514 | | - <p class="muted small">(g::t(lang, K::OnlyOwnerEdits))</p> |
| 503 | + <p class="hint">(g::t(lang, K::OnlyOwnerEdits))</p> |
| 515 | 504 | } |
| 516 | 505 | }) |
| 517 | 506 | } |
| | @@ -527,28 +516,24 @@ async fn revisions_body( |
| 527 | 516 | let back = format!("/snippets/{snippet_id}"); |
| 528 | 517 | let heading = g::revisions_of(lang, title); |
| 529 | 518 | Ok(view! { |
| 530 | | - <section class="page-head" data-live=(live.as_deref())> |
| 531 | | - <h1>(heading.as_str())</h1> |
| 532 | | - <a href=(back)>(g::t(lang, K::BackToSnippet))</a> |
| 533 | | - </section> |
| 534 | | - <section class="card list-pane fit-pane"> |
| 535 | | - if revisions.is_empty() { |
| 536 | | - <p class="muted">(g::t(lang, K::NoRevisions))</p> |
| 537 | | - } else { |
| 538 | | - <ul class="item-list"> |
| 539 | | - for rev in revisions.into_iter() { |
| 540 | | - <li class="item"> |
| 541 | | - <div class="item-main"> |
| 542 | | - <strong>(g::t(lang, K::RevisionLabel))(rev.number)</strong> |
| 543 | | - <span class="muted small"> |
| 544 | | - (rev.author) " · " rel_time(lang: lang, stamp: rev.at.as_str()) " · " (rev.file_names) |
| 545 | | - </span> |
| 546 | | - </div> |
| 547 | | - </li> |
| 548 | | - } |
| 549 | | - </ul> |
| 550 | | - } |
| 551 | | - </section> |
| 519 | + <div data-live=(live.as_deref())> |
| 520 | + <h1 class="h1">(heading.as_str())</h1> |
| 521 | + <nav class="sub"> |
| 522 | + <a href=(back)>(g::t(lang, K::BackToSnippet))</a> |
| 523 | + </nav> |
| 524 | + </div> |
| 525 | + if revisions.is_empty() { |
| 526 | + <p class="state">(g::t(lang, K::NoRevisions))</p> |
| 527 | + } else { |
| 528 | + <div> |
| 529 | + for rev in revisions.into_iter() { |
| 530 | + <div class="line" data-kb-row=""> |
| 531 | + <span class="name">(g::t(lang, K::RevisionLabel))(rev.number)</span> |
| 532 | + <span class="val">(rev.author) " · " rel_time(lang: lang, stamp: rev.at.as_str()) " · " (rev.file_names)</span> |
| 533 | + </div> |
| 534 | + } |
| 535 | + </div> |
| 536 | + } |
| 552 | 537 | }) |
| 553 | 538 | } |
| 554 | 539 | |
| | @@ -383,13 +383,13 @@ pub async fn load_readme( |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /// One row of a listing: a stretched link to the entry (the whole row is the target), its icon, |
| 386 | | -/// its name and its age at the right end. Submodules have no page, so their row shows the short sha. |
| 386 | +/// its name and its age right after the name. Submodules have no page, so their row shows the short sha. |
| 387 | 387 | #[component] |
| 388 | 388 | pub async fn tree_table(rows: Vec<EntryRow>, lang: Lang) -> Result<impl View> { |
| 389 | 389 | Ok(view! { |
| 390 | | - <div class="table-wrap tree-list"> |
| 390 | + <div class="tree-list"> |
| 391 | 391 | for row in rows.into_iter() { |
| 392 | | - <div class="tree-entry" data-kb-row=""> |
| 392 | + <div class="line tree-entry" data-kb-row=""> |
| 393 | 393 | <span class="tree-kind"> |
| 394 | 394 | if row.kind == "dir" { |
| 395 | 395 | <svg class="kind-icon is-dir" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg> |
| | @@ -526,7 +526,7 @@ async fn tree_page(cx: &Cx) -> Result<impl View> { |
| 526 | 526 | repo_head(head: header) |
| 527 | 527 | <div class="repo-grid repo-home canvas-repo tree-browse"> |
| 528 | 528 | <div class="repo-main canvas-files"> |
| 529 | | - <div class="browse-bar canvas-head" data-live=(live.as_deref()) data-live-code=(live.is_some().then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> |
| 529 | + <div class="browse-bar" data-live=(live.as_deref()) data-live-code=(live.is_some().then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))> |
| 530 | 530 | ref_selector(lang: lang, label: mi::t(lang, MK::RefLabel), current: ref_name.clone(), branches: branches, tags: tags, |
| 531 | 531 | branches_href: branches_href, tags_href: tags_href) |
| 532 | 532 | file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) |
| | @@ -147,9 +147,9 @@ fn revision_rows(ctx: &RepoCtx, revs: &[PageRevision]) -> Vec<RevisionRow> { |
| 147 | 147 | .collect() |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | | -/// The header every wiki screen shares: the page title on the left, then the wiki's own |
| 151 | | -/// navigation as a button row (Home, All pages, any page-specific `extra` links such as Edit |
| 152 | | -/// or History) with "New page" as the primary action on the far right for writers. |
| 150 | +/// The header every wiki screen shares: the page name as its heading when the screen has links |
| 151 | +/// of its own (a page, its history, an edit), then the wiki's navigation as second-level text |
| 152 | +/// links (Home, All pages, any page-specific `extra` links) with "New page" as an action. |
| 153 | 153 | #[component] |
| 154 | 154 | async fn wiki_head( |
| 155 | 155 | lang: Lang, |
| | @@ -163,20 +163,25 @@ async fn wiki_head( |
| 163 | 163 | let home = repo_href(&owner, &repo, "wiki", ""); |
| 164 | 164 | let pages = repo_href(&owner, &repo, "wiki", "-/pages"); |
| 165 | 165 | let new = repo_href(&owner, &repo, "wiki", "-/new"); |
| 166 | + let heading_shown = !extra.is_empty(); |
| 166 | 167 | Ok(view! { |
| 167 | | - <section class="page-head wiki-head" data-live=(live.as_deref())> |
| 168 | | - <h1>(title.as_str())</h1> |
| 169 | | - <nav class="wiki-actions" aria-label=(g::t(lang, K::PageNav))> |
| 170 | | - <a class="button" href=(home)>(g::t(lang, K::Home))</a> |
| 171 | | - <a class="button" href=(pages)>(g::t(lang, K::AllPages))</a> |
| 168 | + <div data-live=(live.as_deref())> |
| 169 | + if heading_shown { |
| 170 | + <h1 class="h1">(title.as_str())</h1> |
| 171 | + } else { |
| 172 | + <h1 class="sr-only">(title.as_str())</h1> |
| 173 | + } |
| 174 | + <nav class="sub" aria-label=(g::t(lang, K::PageNav))> |
| 175 | + <a href=(home)>(g::t(lang, K::Home))</a> |
| 176 | + <a href=(pages)>(g::t(lang, K::AllPages))</a> |
| 172 | 177 | for (label, href) in extra.into_iter() { |
| 173 | | - <a class="button" href=(href)>(label)</a> |
| 178 | + <a href=(href)>(label)</a> |
| 174 | 179 | } |
| 175 | 180 | if can_write { |
| 176 | | - <a class="button primary" href=(new)>(g::t(lang, K::NewPage))</a> |
| 181 | + <a class="act" href=(new)>(g::t(lang, K::NewPage))</a> |
| 177 | 182 | } |
| 178 | 183 | </nav> |
| 179 | | - </section> |
| 184 | + </div> |
| 180 | 185 | }) |
| 181 | 186 | } |
| 182 | 187 | |
| | @@ -205,7 +210,7 @@ fn page_links( |
| 205 | 210 | #[component] |
| 206 | 211 | async fn wiki_view_body(html: String) -> Result<impl View> { |
| 207 | 212 | Ok(view! { |
| 208 | | - <section class="card wiki-page fit-pane"> |
| 213 | + <section class="sec wiki-page"> |
| 209 | 214 | <div class="markdown-body">(Unescaped::new_unchecked(html))</div> |
| 210 | 215 | </section> |
| 211 | 216 | }) |
| | @@ -220,13 +225,11 @@ async fn wiki_empty_body( |
| 220 | 225 | ) -> Result<impl View> { |
| 221 | 226 | let new = repo_href(&owner, &repo, "wiki", "-/new"); |
| 222 | 227 | Ok(view! { |
| 223 | | - <section class="card wiki-page fit-pane"> |
| 224 | | - empty_state(title: g::t(lang, K::WikiNoPages), |
| 225 | | - if can_write { |
| 226 | | - <a class="button primary" href=(new.as_str())>(g::t(lang, K::CreateFirstPage))</a> |
| 227 | | - } |
| 228 | | - ) |
| 229 | | - </section> |
| 228 | + empty_state(title: g::t(lang, K::WikiNoPages), |
| 229 | + if can_write { |
| 230 | + <a class="act" href=(new.as_str())>(g::t(lang, K::CreateFirstPage))</a> |
| 231 | + } |
| 232 | + ) |
| 230 | 233 | }) |
| 231 | 234 | } |
| 232 | 235 | |
| | @@ -245,43 +248,35 @@ async fn wiki_list_body( |
| 245 | 248 | }) |
| 246 | 249 | .collect(); |
| 247 | 250 | Ok(view! { |
| 248 | | - <section class="card wiki-page fit-pane"> |
| 249 | | - if rows.is_empty() { |
| 250 | | - empty_state(title: g::t(lang, K::NoPagesYet)) |
| 251 | | - } else { |
| 252 | | - <ul class="item-list wiki-pages"> |
| 253 | | - for (title, href) in rows.into_iter() { |
| 254 | | - <li class="item"><a href=(href)>(title.as_str())</a></li> |
| 255 | | - } |
| 256 | | - </ul> |
| 257 | | - } |
| 258 | | - </section> |
| 251 | + if rows.is_empty() { |
| 252 | + empty_state(title: g::t(lang, K::NoPagesYet)) |
| 253 | + } else { |
| 254 | + <div class="wiki-pages"> |
| 255 | + for (title, href) in rows.into_iter() { |
| 256 | + <a class="line" href=(href) data-kb-row=""> |
| 257 | + <span class="name">(title.as_str())</span> |
| 258 | + </a> |
| 259 | + } |
| 260 | + </div> |
| 261 | + } |
| 259 | 262 | }) |
| 260 | 263 | } |
| 261 | 264 | |
| 262 | 265 | #[component] |
| 263 | 266 | async fn wiki_history_body(lang: Lang, rows: Vec<RevisionRow>) -> Result<impl View> { |
| 264 | 267 | Ok(view! { |
| 265 | | - <section class="card wiki-page fit-pane"> |
| 266 | | - if rows.is_empty() { |
| 267 | | - empty_state(title: g::t(lang, K::NoChangesYet)) |
| 268 | | - } else { |
| 269 | | - <div class="table-wrap"> |
| 270 | | - <table class="table wiki-history"> |
| 271 | | - <tbody> |
| 272 | | - for row in rows.into_iter() { |
| 273 | | - <tr> |
| 274 | | - <td class="nowrap"><a href=(row.href)><code>(row.short.as_str())</code></a></td> |
| 275 | | - <td>(row.subject.as_str())</td> |
| 276 | | - <td class="muted small nowrap">(row.author.as_str())</td> |
| 277 | | - <td class="muted small nowrap">rel_time(lang: lang, stamp: row.when.as_str())</td> |
| 278 | | - </tr> |
| 279 | | - } |
| 280 | | - </tbody> |
| 281 | | - </table> |
| 282 | | - </div> |
| 283 | | - } |
| 284 | | - </section> |
| 268 | + if rows.is_empty() { |
| 269 | + empty_state(title: g::t(lang, K::NoChangesYet)) |
| 270 | + } else { |
| 271 | + <div class="wiki-history"> |
| 272 | + for row in rows.into_iter() { |
| 273 | + <a class="line" href=(row.href) data-kb-row=""> |
| 274 | + <span class="name">(row.subject.as_str())</span> |
| 275 | + <span class="val"><code>(row.short.as_str())</code> " · " (row.author.as_str()) " · " rel_time(lang: lang, stamp: row.when.as_str())</span> |
| 276 | + </a> |
| 277 | + } |
| 278 | + </div> |
| 279 | + } |
| 285 | 280 | }) |
| 286 | 281 | } |
| 287 | 282 | |
| | @@ -297,29 +292,29 @@ async fn wiki_edit_body( |
| 297 | 292 | error: Option<String>, |
| 298 | 293 | ) -> Result<impl View> { |
| 299 | 294 | Ok(view! { |
| 300 | | - <section class="card wiki-page fit-pane"> |
| 301 | | - <form method="post" action=(action.as_str()) class="stack wiki-form"> |
| 295 | + <section class="sec wiki-page"> |
| 296 | + <form method="post" action=(action.as_str()) class="fields wiki-form"> |
| 302 | 297 | if let Some(message) = error { |
| 303 | 298 | alert(message: message.as_str()) |
| 304 | 299 | } |
| 305 | 300 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 306 | 301 | <input type="hidden" name="base" value=(base.as_str())> |
| 307 | 302 | if is_new { |
| 308 | | - <label> |
| 309 | | - <span>(g::t(lang, K::PageName))</span> |
| 310 | | - <input type="text" name="name" value=(name.as_str()) maxlength="100" required=(true) pattern="[A-Za-z0-9_-]+"> |
| 311 | | - <small class="muted">(g::t(lang, K::PageNameHint))</small> |
| 312 | | - </label> |
| 303 | + <div class="field"> |
| 304 | + <label for="wiki-name">(g::t(lang, K::PageName))</label> |
| 305 | + <input id="wiki-name" type="text" name="name" value=(name.as_str()) maxlength="100" required=(true) pattern="[A-Za-z0-9_-]+"> |
| 306 | + <p class="hint">(g::t(lang, K::PageNameHint))</p> |
| 307 | + </div> |
| 313 | 308 | } |
| 314 | | - <label> |
| 315 | | - <span>(g::t(lang, K::ContentMarkdown))</span> |
| 316 | | - <textarea name="content" rows="24" spellcheck="false">(content.as_str())</textarea> |
| 317 | | - <small class="muted">(g::t(lang, K::WikiLinkHint))</small> |
| 318 | | - </label> |
| 319 | | - <label> |
| 320 | | - <span>(g::t(lang, K::Summary))</span> |
| 321 | | - <input type="text" name="message" maxlength="200" autocomplete="off"> |
| 322 | | - </label> |
| 309 | + <div class="field"> |
| 310 | + <label for="wiki-content">(g::t(lang, K::ContentMarkdown))</label> |
| 311 | + <textarea id="wiki-content" name="content" rows="24" spellcheck="false">(content.as_str())</textarea> |
| 312 | + <p class="hint">(g::t(lang, K::WikiLinkHint))</p> |
| 313 | + </div> |
| 314 | + <div class="field"> |
| 315 | + <label for="wiki-message">(g::t(lang, K::Summary))</label> |
| 316 | + <input id="wiki-message" type="text" name="message" maxlength="200" autocomplete="off"> |
| 317 | + </div> |
| 323 | 318 | <button type="submit" class="primary">(g::t(lang, K::SavePage))</button> |
| 324 | 319 | </form> |
| 325 | 320 | </section> |
| | @@ -519,10 +514,18 @@ async fn edit_screen( |
| 519 | 514 | } else { |
| 520 | 515 | name.replace('-', " ") |
| 521 | 516 | }; |
| 517 | + let back_links = if is_new { |
| 518 | + Vec::new() |
| 519 | + } else { |
| 520 | + vec![( |
| 521 | + g::t(lang, K::BackToPage).to_owned(), |
| 522 | + repo_href(&owner_name, &repo_name, "wiki", &name), |
| 523 | + )] |
| 524 | + }; |
| 522 | 525 | Ok(view! { cx => |
| 523 | 526 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 524 | 527 | repo_head(head: header) |
| 525 | | - wiki_head(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: !is_new, title: head_title.clone(), extra: Vec::new(), live: None) |
| 528 | + wiki_head(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: !is_new, title: head_title.clone(), extra: back_links.clone(), live: None) |
| 526 | 529 | wiki_edit_body(lang: lang, action: action, csrf: csrf, base: base, name: name.clone(), is_new: is_new, content: content, error: error) |
| 527 | 530 | ) |
| 528 | 531 | }) |
| | @@ -685,21 +688,18 @@ async fn wiki_settings_body( |
| 685 | 688 | enabled: bool, |
| 686 | 689 | ) -> Result<impl View> { |
| 687 | 690 | Ok(view! { |
| 688 | | - <form method="post" action=(action.as_str()) class="card rows-pane wiki-form"> |
| 689 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 690 | | - <label class="row-line row-field"> |
| 691 | | - <span class="row-main"> |
| 692 | | - <span class="row-title">(g::t(lang, K::EnableWiki))</span> |
| 693 | | - <span class="row-status">(g::t(lang, K::WikiDisabledHint))</span> |
| 694 | | - </span> |
| 695 | | - <span class="row-control"> |
| 691 | + <section class="sec"> |
| 692 | + <h2>(g::t(lang, K::WikiSettings))</h2> |
| 693 | + <form method="post" action=(action.as_str()) class="fields wiki-form"> |
| 694 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 695 | + <label class="switch"> |
| 696 | 696 | <input type="checkbox" name="enabled" value="1" checked=(enabled)> |
| 697 | | - </span> |
| 698 | | - </label> |
| 699 | | - <div class="row-foot"> |
| 697 | + <span>(g::t(lang, K::EnableWiki))</span> |
| 698 | + </label> |
| 699 | + <p class="hint">(g::t(lang, K::WikiDisabledHint))</p> |
| 700 | 700 | <button type="submit" class="primary">(g::t(lang, K::Save))</button> |
| 701 | | - </div> |
| 702 | | - </form> |
| 701 | + </form> |
| 702 | + </section> |
| 703 | 703 | }) |
| 704 | 704 | } |
| 705 | 705 | |
| | @@ -148,6 +148,23 @@ pub async fn checks_summary( |
| 148 | 148 | }) |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | +/// A status description in the viewer's language. CI's own descriptions are stored in English; |
| 152 | +/// what an outside tool reports stays as it sent it. |
| 153 | +fn description_text(lang: Lang, text: &str) -> &str { |
| 154 | + use crate::pages::passkeys::s; |
| 155 | + match text { |
| 156 | + "Waiting for approval" => s(lang, "Waiting for approval", "Onay bekliyor"), |
| 157 | + "Waiting for other jobs" => s(lang, "Waiting for other jobs", "Diğer işleri bekliyor"), |
| 158 | + "Queued" => s(lang, "Queued", "Sırada"), |
| 159 | + "Running" => s(lang, "Running", "Çalışıyor"), |
| 160 | + "Succeeded" => s(lang, "Succeeded", "Başarılı"), |
| 161 | + "Failed" => s(lang, "Failed", "Başarısız"), |
| 162 | + "Cancelled" => s(lang, "Cancelled", "İptal edildi"), |
| 163 | + "Errored" => s(lang, "Errored", "Hata verdi"), |
| 164 | + other => other, |
| 165 | + } |
| 166 | +} |
| 167 | + |
| 151 | 168 | /// The contexts of one commit: icon, context name, description and a details link. |
| 152 | 169 | #[component] |
| 153 | 170 | pub async fn status_list(items: Vec<StatusItem>, lang: Lang) -> Result<impl View> { |
| | @@ -158,7 +175,7 @@ pub async fn status_list(items: Vec<StatusItem>, lang: Lang) -> Result<impl View |
| 158 | 175 | <span class=(item.icon_class.as_str())>(item.icon)</span> |
| 159 | 176 | <code>(item.context.as_str())</code> |
| 160 | 177 | if item.has_description { |
| 161 | | - <span class="muted small">(item.description.as_str())</span> |
| 178 | + <span class="muted small">(description_text(lang, item.description.as_str()))</span> |
| 162 | 179 | } |
| 163 | 180 | if item.has_link { |
| 164 | 181 | <a class="small" href=(item.link.as_str()) rel="nofollow noopener noreferrer">(g::t(lang, K::DetailsLink))</a> |
| | @@ -567,10 +567,10 @@ pub async fn diff_section( |
| 567 | 567 | diff_toolbar(bar: bar, lang: lang) |
| 568 | 568 | } |
| 569 | 569 | if truncated_files { |
| 570 | | - <p class="muted">(truncated_note.as_str())</p> |
| 570 | + <p class="state">(truncated_note.as_str())</p> |
| 571 | 571 | } |
| 572 | 572 | if no_files { |
| 573 | | - <p class="muted">(g::t(lang, K::NoFileChanges))</p> |
| 573 | + <p class="state">(g::t(lang, K::NoFileChanges))</p> |
| 574 | 574 | } else { |
| 575 | 575 | <ul class="diff-index"> |
| 576 | 576 | for item in nav.iter() { |
| | @@ -596,19 +596,15 @@ async fn diff_toolbar(bar: Toolbar, lang: Lang) -> Result<impl View> { |
| 596 | 596 | let split_on = if bar.split { "true" } else { "false" }; |
| 597 | 597 | let ws_on = if bar.ignore_ws { "true" } else { "false" }; |
| 598 | 598 | Ok(view! { |
| 599 | | - <div class="diff-toolbar"> |
| 600 | | - <div class="seg" role="group" aria-label=(b::t(lang, b::K::DiffView))> |
| 601 | | - <a class="seg-item" href=(bar.unified_href.as_str()) aria-pressed=(unified_on)>(b::t(lang, b::K::Unified))</a> |
| 602 | | - <a class="seg-item" href=(bar.split_href.as_str()) aria-pressed=(split_on)>(b::t(lang, b::K::Split))</a> |
| 603 | | - </div> |
| 604 | | - <a class="seg-item toggle" href=(bar.ws_href.as_str()) aria-pressed=(ws_on)>(b::t(lang, b::K::IgnoreWhitespace))</a> |
| 599 | + <nav class="sub diff-toolbar" aria-label=(b::t(lang, b::K::DiffView))> |
| 600 | + <a href=(bar.unified_href.as_str()) aria-pressed=(unified_on)>(b::t(lang, b::K::Unified))</a> |
| 601 | + <a href=(bar.split_href.as_str()) aria-pressed=(split_on)>(b::t(lang, b::K::Split))</a> |
| 602 | + <a href=(bar.ws_href.as_str()) aria-pressed=(ws_on)>(b::t(lang, b::K::IgnoreWhitespace))</a> |
| 605 | 603 | if let Some((patch, diff)) = bar.downloads { |
| 606 | | - <span class="diff-downloads"> |
| 607 | | - <a href=(patch.as_str()) title=(b::t(lang, b::K::PatchTitle))>(b::t(lang, b::K::PatchLink))</a> |
| 608 | | - <a href=(diff.as_str()) title=(b::t(lang, b::K::DiffTitle))>(b::t(lang, b::K::DiffLink))</a> |
| 609 | | - </span> |
| 604 | + <a class="act quiet" href=(patch.as_str()) title=(b::t(lang, b::K::PatchTitle))>(b::t(lang, b::K::PatchLink))</a> |
| 605 | + <a class="act quiet" href=(diff.as_str()) title=(b::t(lang, b::K::DiffTitle))>(b::t(lang, b::K::DiffLink))</a> |
| 610 | 606 | } |
| 611 | | - </div> |
| 607 | + </nav> |
| 612 | 608 | }) |
| 613 | 609 | } |
| 614 | 610 | |
| | @@ -629,18 +625,18 @@ async fn diff_file(file: FileView, lang: Lang, split: bool, anchored: bool) -> R |
| 629 | 625 | <header class="diff-file-header"> |
| 630 | 626 | <code class="diff-path">(file.label.as_str())</code> |
| 631 | 627 | <span class="diff-file-meta"> |
| 632 | | - <span class="muted small">(file.status)</span> |
| 628 | + <span class="hint">(file.status)</span> |
| 633 | 629 | <span class="diff-stats"><span class="add">(add_label.as_str())</span> " " <span class="del">(del_label.as_str())</span></span> |
| 634 | 630 | </span> |
| 635 | 631 | </header> |
| 636 | 632 | if file.binary { |
| 637 | | - <p class="muted diff-collapsed">(g::t(lang, K::BinaryFileChanged))</p> |
| 633 | + <p class="state diff-collapsed">(g::t(lang, K::BinaryFileChanged))</p> |
| 638 | 634 | } else { |
| 639 | 635 | if file.truncated { |
| 640 | 636 | if file.has_blob { |
| 641 | | - <p class="muted diff-collapsed">(g::t(lang, K::DiffTooLargePrefix)) <a href=(file.blob_href.as_str())>(g::t(lang, K::ViewFile))</a></p> |
| 637 | + <p class="state diff-collapsed">(g::t(lang, K::DiffTooLargePrefix)) <a class="act" href=(file.blob_href.as_str())>(g::t(lang, K::ViewFile))</a></p> |
| 642 | 638 | } else { |
| 643 | | - <p class="muted diff-collapsed">(g::t(lang, K::DiffTooLarge))</p> |
| 639 | + <p class="state diff-collapsed">(g::t(lang, K::DiffTooLarge))</p> |
| 644 | 640 | } |
| 645 | 641 | } |
| 646 | 642 | if has_rows { |
| | @@ -803,25 +799,25 @@ async fn inline_comment_form(form: InlineForm, lang: Lang) -> Result<impl View> |
| 803 | 799 | }; |
| 804 | 800 | let suggest_label = pr_g::t(lang, PrK::SuggestChange); |
| 805 | 801 | Ok(view! { |
| 806 | | - <form method="post" action=(action.as_str()) class="review-inline-form stack"> |
| 802 | + <form method="post" action=(action.as_str()) class="review-inline-form fields"> |
| 807 | 803 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 808 | 804 | <input type="hidden" name="file_index" value=(file_index.as_str())> |
| 809 | 805 | <input type="hidden" name="side" value=(side)> |
| 810 | 806 | <input type="hidden" name="line" value=(line.as_str())> |
| 811 | 807 | <input type="hidden" name="head_oid" value=(head_oid.as_str())> |
| 812 | | - <label> |
| 813 | | - <span>(g::t(lang, K::CommentLabel))</span> |
| 814 | | - <textarea name="body" rows="4"></textarea> |
| 815 | | - </label> |
| 816 | | - <div class="issue-actions"> |
| 817 | | - <button type="submit" name="action" value="single">(g::t(lang, K::AddSingleComment))</button> |
| 808 | + <div class="field"> |
| 809 | + <label for="inline-comment-body">(g::t(lang, K::CommentLabel))</label> |
| 810 | + <textarea id="inline-comment-body" name="body" rows="4"></textarea> |
| 811 | + </div> |
| 812 | + <div class="acts"> |
| 813 | + <button type="submit" class="primary" name="action" value="single">(g::t(lang, K::AddSingleComment))</button> |
| 818 | 814 | if can_review { |
| 819 | | - <button type="submit" name="action" value="review">(review_label)</button> |
| 815 | + <button type="submit" class="act" name="action" value="review">(review_label)</button> |
| 820 | 816 | } |
| 821 | 817 | if let Some(text) = suggest_line { |
| 822 | | - <button type="button" class="link-button" data-suggest=(text.as_str())>(suggest_label)</button> |
| 818 | + <button type="button" class="act" data-suggest=(text.as_str())>(suggest_label)</button> |
| 823 | 819 | } |
| 824 | | - <a href=(cancel_href.as_str())>(g::t(lang, K::CancelLink))</a> |
| 820 | + <a class="act quiet" href=(cancel_href.as_str())>(g::t(lang, K::CancelLink))</a> |
| 825 | 821 | </div> |
| 826 | 822 | </form> |
| 827 | 823 | }) |
| | @@ -5,6 +5,7 @@ pub mod commit_line; |
| 5 | 5 | pub mod commit_status; |
| 6 | 6 | pub mod diff; |
| 7 | 7 | pub mod heatmap; |
| 8 | +pub mod parts; |
| 8 | 9 | pub mod repo_list; |
| 9 | 10 | pub mod review_thread; |
| 10 | 11 | pub mod timeline; |
| | @@ -392,7 +393,6 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> |
| 392 | 393 | let admin_label = ad::t(lang, AK::AdminArea); |
| 393 | 394 | let logout_label = t(lang, Key::LogOut); |
| 394 | 395 | let bell_title = i18n::t(lang, Key::Notifications); |
| 395 | | - let explore_label = t(lang, Key::Explore); |
| 396 | 396 | let open_label = mi::t(lang, MK::OpenNotifications); |
| 397 | 397 | let clear_label = mi::t(lang, MK::ClearNotifications); |
| 398 | 398 | let clear_title = mi::t(lang, MK::MarkAllRead); |
| | @@ -443,7 +443,6 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> |
| 443 | 443 | </form> |
| 444 | 444 | </div> |
| 445 | 445 | </details> |
| 446 | | - <a class="corner-bell corner-explore" href="/explore" title=(explore_label) aria-label=(explore_label)><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5z"/></svg></a> |
| 447 | 446 | <a class="corner-bell" href="/notifications" title=(bell_label) aria-label=(bell_label) aria-expanded="false"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg> |
| 448 | 447 | if corner.unread > 0 { |
| 449 | 448 | <span class="bell-count">(corner.unread.to_string())</span> |
| | @@ -524,8 +523,7 @@ pub async fn shell( |
| 524 | 523 | } else { |
| 525 | 524 | None |
| 526 | 525 | }; |
| 527 | | - let section_menu = section.clone(); |
| 528 | | - let site_shell = section.as_ref().is_some_and(|s| s.site); |
| 526 | + let width = page_width(uri(__cx).path()); |
| 529 | 527 | let theme_attr = crate::theme::data_theme(__cx, viewer.map(|(user, _)| user)); |
| 530 | 528 | // The relative-time wording and the server's clock, for nav.js to keep `<time data-rel>` labels current. |
| 531 | 529 | let rel_words_attr = rel_words(lang); |
| | @@ -588,7 +586,7 @@ pub async fn shell( |
| 588 | 586 | let anonymous = viewer.is_none(); |
| 589 | 587 | let search_label = o::t(lang, OK::SearchPublicRepos); |
| 590 | 588 | let palette_label = br::t(lang, br::K::PaletteOpen).to_owned(); |
| 591 | | - let menu_label = t(lang, Key::SiteMenu); |
| 589 | + let explore_label = t(lang, Key::Explore); |
| 592 | 590 | // The path bar: one segment per part of the request path, the last one unlinked. |
| 593 | 591 | let segments = path_segments(uri(__cx).path(), title); |
| 594 | 592 | let path_attr = segments |
| | @@ -694,20 +692,14 @@ pub async fn shell( |
| 694 | 692 | </head> |
| 695 | 693 | <body data-link-restarting=(lk::t(lang, LinkKey::Restarting)) data-link-back=(lk::t(lang, LinkKey::BackSubmit)) data-done-saved=(lk::t(lang, LinkKey::Saved)) data-done-ok=(lk::t(lang, LinkKey::Done)) data-draft-restored=(lk::t(lang, LinkKey::DraftRestored)) data-draft-discard=(lk::t(lang, LinkKey::DraftDiscard)) data-select-filter=(lk::t(lang, LinkKey::SelectFilter)) data-select-none=(lk::t(lang, LinkKey::SelectNone)) data-signed-in=(signed_in.then(|| "true".to_owned())) data-tree-w=(tree_w) data-corner-pos=(corner_pos)> |
| 696 | 694 | <header class="topbar"> |
| 697 | | - if let Some(section) = section_menu { |
| 698 | | - <details class="nav-toggle"> |
| 699 | | - <summary class="icon-btn" aria-label=(menu_label) title=(menu_label)> |
| 700 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg> |
| 701 | | - </summary> |
| 702 | | - <div class="nav-panel"> |
| 703 | | - section_nav(title: section.title.as_str(), back: section.back, back_href: section.back_href.as_str(), items: section.items, current: section.current, live: section.live) |
| 704 | | - </div> |
| 705 | | - </details> |
| 706 | | - } |
| 707 | 695 | <a class="wordmark" href="/"> |
| 708 | 696 | <svg class="ico wordmark-mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 19c0-7 5-12 14-13-1 9-6 14-13 14"/><path d="M5 19l6-6"/></svg> |
| 709 | 697 | "forge" |
| 710 | 698 | </a> |
| 699 | + <a class="top-explore" href="/explore" title=(explore_label) aria-label=(explore_label)> |
| 700 | + <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5z"/></svg> |
| 701 | + <span>(explore_label)</span> |
| 702 | + </a> |
| 711 | 703 | <nav class="pathbar" aria-label=(mi::t(lang, MK::BreadcrumbNav))> |
| 712 | 704 | if signed_in { |
| 713 | 705 | <svg class="ico pathbar-ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> |
| | @@ -740,9 +732,6 @@ pub async fn shell( |
| 740 | 732 | } |
| 741 | 733 | </nav> |
| 742 | 734 | if signed_in { |
| 743 | | - <a class="icon-btn top-search-link" href="/explore" aria-label=(search_label) title=(search_label)> |
| 744 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> |
| 745 | | - </a> |
| 746 | 735 | <div class="live-strip" data-activity="/-/activity" data-passed=(mi::t(lang, MK::Passed)) data-failed=(mi::t(lang, MK::Failed)) data-cancelled=(mi::t(lang, MK::Cancelled)) |
| 747 | 736 | data-count-running=(running_tpl.as_str()) data-count-failed=(failed_tpl.as_str()) data-count-passed=(passed_tpl.as_str()) data-count-cancelled=(cancelled_tpl.as_str()) |
| 748 | 737 | data-runs-label=(runs_label) aria-live="polite"> |
| | @@ -767,9 +756,6 @@ pub async fn shell( |
| 767 | 756 | <svg class="ico top-search-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> |
| 768 | 757 | <input type="search" name="q" placeholder=(search_label) aria-label=(search_label)> |
| 769 | 758 | </form> |
| 770 | | - <a class="icon-btn top-search-link" href="/explore" aria-label=(search_label) title=(search_label)> |
| 771 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> |
| 772 | | - </a> |
| 773 | 759 | <form class="theme-form" method="post" action="/-/theme"> |
| 774 | 760 | if let Some(csrf) = theme_csrf { |
| 775 | 761 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| | @@ -788,7 +774,6 @@ pub async fn shell( |
| 788 | 774 | } |
| 789 | 775 | </button> |
| 790 | 776 | </form> |
| 791 | | - <a class="topbar-link" href="/explore">(t(lang, Key::Explore))</a> |
| 792 | 777 | <a class="button primary" href="/login">(t(lang, Key::LogIn))</a> |
| 793 | 778 | } |
| 794 | 779 | </header> |
| | @@ -804,14 +789,12 @@ pub async fn shell( |
| 804 | 789 | </form> |
| 805 | 790 | </div> |
| 806 | 791 | } |
| 807 | | - <div class=(if site_shell { "shell shell-site" } else { "shell" })> |
| 808 | | - if let Some(section) = section { |
| 809 | | - <aside class="shell-sidebar"> |
| 810 | | - section_nav(title: section.title.as_str(), back: section.back, back_href: section.back_href.as_str(), items: section.items, current: section.current, live: section.live) |
| 811 | | - </aside> |
| 812 | | - } |
| 792 | + <div class="shell"> |
| 813 | 793 | <div class="shell-body"> |
| 814 | | - <main tabindex="-1"> |
| 794 | + <main tabindex="-1" data-width=(width)> |
| 795 | + if let Some(section) = section { |
| 796 | + section_tabs(label: section.title.as_str(), items: section.items, current: section.current, live: section.live) |
| 797 | + } |
| 815 | 798 | (child) |
| 816 | 799 | </main> |
| 817 | 800 | <footer class="site-footer"> |
| | @@ -851,86 +834,67 @@ pub struct NavItem { |
| 851 | 834 | pub key: &'static str, |
| 852 | 835 | pub href: String, |
| 853 | 836 | pub label: &'static str, |
| 854 | | - pub icon: &'static str, |
| 855 | 837 | } |
| 856 | 838 | |
| 857 | | -/// A section sidebar: the admin area or user settings, shown in place of the global links. |
| 839 | +/// A section's tabs: the admin area or the user's settings, one row of text links above the page. |
| 858 | 840 | #[derive(Clone)] |
| 859 | 841 | pub struct Section { |
| 860 | 842 | pub title: String, |
| 861 | | - pub back: &'static str, |
| 862 | | - /// Where the back link goes: the site for admin and settings, an organization's profile for its settings. |
| 863 | | - pub back_href: String, |
| 864 | 843 | pub items: Vec<NavItem>, |
| 865 | 844 | pub current: &'static str, |
| 866 | 845 | /// The stream the section's pages follow, or empty when they follow none. |
| 867 | 846 | pub live: &'static str, |
| 868 | | - /// True for the site-wide sections (admin and the user's settings), which lay their pages out |
| 869 | | - /// as panes across the window. An organization's settings keep their own layout. |
| 870 | | - pub site: bool, |
| 847 | +} |
| 848 | + |
| 849 | +/// How wide a page's column is, from its path alone, so that every page of a kind has the same |
| 850 | +/// edge. `col` is for settings and forms, `read` for lists and threads, `wide` for code, diffs and |
| 851 | +/// CI, whose lines need the room. All three start at the path bar's left edge. |
| 852 | +pub fn page_width(path: &str) -> &'static str { |
| 853 | + let parts: Vec<&str> = path.trim_matches('/').split('/').collect(); |
| 854 | + match parts.as_slice() { |
| 855 | + ["settings" | "admin", ..] | ["new", ..] | ["org", "new"] | ["org", _, "settings", ..] => { |
| 856 | + "col" |
| 857 | + } |
| 858 | + ["login" | "register" | "forgot" | "reset" | "setup" | "invite", ..] => "col", |
| 859 | + [_, _, section, ..] => match *section { |
| 860 | + "settings" | "new" | "edit" | "fork" | "transfer" | "rename" => "col", |
| 861 | + "tree" | "blob" | "blame" | "commit" | "compare" | "ci" | "raw" | "edit-file" |
| 862 | + | "scrub" => "wide", |
| 863 | + "pulls" if parts.len() > 4 => "wide", |
| 864 | + _ => "read", |
| 865 | + }, |
| 866 | + [_, _] => "wide", |
| 867 | + _ => "read", |
| 868 | + } |
| 871 | 869 | } |
| 872 | 870 | |
| 873 | 871 | pub fn admin_items(lang: Lang) -> Vec<NavItem> { |
| 874 | | - let item = |key, href: &'static str, label, icon| NavItem { |
| 872 | + let item = |key, href: &'static str, label| NavItem { |
| 875 | 873 | key, |
| 876 | 874 | href: href.to_owned(), |
| 877 | 875 | label, |
| 878 | | - icon, |
| 879 | 876 | }; |
| 880 | 877 | vec![ |
| 881 | | - item("users", "/admin/users", ad::t(lang, AK::Users), "users"), |
| 882 | | - item( |
| 883 | | - "health", |
| 884 | | - "/admin/health", |
| 885 | | - crate::i18n::accounts::t(lang, crate::i18n::accounts::A::Health), |
| 886 | | - "health", |
| 887 | | - ), |
| 888 | | - item( |
| 889 | | - "invites", |
| 890 | | - "/admin/invites", |
| 891 | | - ad::t(lang, AK::Invites), |
| 892 | | - "invites", |
| 893 | | - ), |
| 894 | | - item("audit", "/admin/audit", ad::t(lang, AK::AuditLog), "audit"), |
| 895 | | - item( |
| 896 | | - "runners", |
| 897 | | - "/admin/runners", |
| 898 | | - ad::t(lang, AK::Runners), |
| 899 | | - "runners", |
| 900 | | - ), |
| 901 | | - item("mail", "/admin/mail", ad::t(lang, AK::Mail), "mail"), |
| 902 | | - item( |
| 903 | | - "server", |
| 904 | | - "/admin/server", |
| 905 | | - ad::t(lang, AK::ServerSettings), |
| 906 | | - "server", |
| 907 | | - ), |
| 908 | | - item( |
| 909 | | - "backups", |
| 910 | | - "/admin/backups", |
| 911 | | - ad::t(lang, AK::Backups), |
| 912 | | - "backups", |
| 913 | | - ), |
| 878 | + item("users", "/admin/users", ad::t(lang, AK::Users)), |
| 879 | + item("invites", "/admin/invites", ad::t(lang, AK::Invites)), |
| 880 | + item("runners", "/admin/runners", ad::t(lang, AK::Runners)), |
| 881 | + item("server", "/admin/server", ad::t(lang, AK::ServerSettings)), |
| 882 | + item("mail", "/admin/mail", ad::t(lang, AK::Mail)), |
| 883 | + item("backups", "/admin/backups", ad::t(lang, AK::Backups)), |
| 914 | 884 | item( |
| 915 | 885 | "replication", |
| 916 | 886 | "/admin/replication", |
| 917 | 887 | ad::t(lang, AK::Replication), |
| 918 | | - "replication", |
| 919 | 888 | ), |
| 889 | + item( |
| 890 | + "health", |
| 891 | + "/admin/health", |
| 892 | + crate::i18n::accounts::t(lang, crate::i18n::accounts::A::Health), |
| 893 | + ), |
| 894 | + item("audit", "/admin/audit", ad::t(lang, AK::AuditLog)), |
| 920 | 895 | ] |
| 921 | 896 | } |
| 922 | 897 | |
| 923 | | -/// The organization's settings sidebar. Its profile, repositories, |
| 924 | | -/// members and teams are reached from the profile tab bar, so they are not listed here. |
| 925 | | -fn org_items(lang: Lang, org: &str) -> Vec<NavItem> { |
| 926 | | - vec![NavItem { |
| 927 | | - key: "settings", |
| 928 | | - href: format!("/org/{org}/settings"), |
| 929 | | - label: o::t(lang, OK::General), |
| 930 | | - icon: "appearance", |
| 931 | | - }] |
| 932 | | -} |
| 933 | | - |
| 934 | 898 | /// The profile tab bar in its order, for a person's or an organization's profile: overview, |
| 935 | 899 | /// repositories, snippets and stars (people only), packages, organizations (the viewer's own |
| 936 | 900 | /// profile only) and, for an organization the viewer belongs to, members and teams. The hrefs are |
| | @@ -943,23 +907,22 @@ pub fn profile_items( |
| 943 | 907 | org_member: bool, |
| 944 | 908 | ) -> Vec<NavItem> { |
| 945 | 909 | let profile = format!("/{}", enc(username)); |
| 946 | | - let tab = |key: &'static str, label: &'static str, icon: &'static str| NavItem { |
| 910 | + let tab = |key: &'static str, label: &'static str| NavItem { |
| 947 | 911 | key, |
| 948 | 912 | href: format!("{profile}?tab={key}"), |
| 949 | 913 | label, |
| 950 | | - icon, |
| 951 | 914 | }; |
| 952 | 915 | let mut items = vec![ |
| 953 | | - tab("overview", o::t(lang, OK::TabOverview), "profile"), |
| 954 | | - tab("repositories", o::t(lang, OK::Repositories), ""), |
| 916 | + tab("overview", o::t(lang, OK::TabOverview)), |
| 917 | + tab("repositories", o::t(lang, OK::Repositories)), |
| 955 | 918 | ]; |
| 956 | 919 | if !is_org { |
| 957 | | - items.push(tab("snippets", cm::t(lang, CK::Snippets), "")); |
| 958 | | - items.push(tab("stars", o::t(lang, OK::TabStars), "")); |
| 920 | + items.push(tab("snippets", cm::t(lang, CK::Snippets))); |
| 921 | + items.push(tab("stars", o::t(lang, OK::TabStars))); |
| 959 | 922 | } |
| 960 | | - items.push(tab("packages", pk::t(lang, PK::TabPackages), "")); |
| 923 | + items.push(tab("packages", pk::t(lang, PK::TabPackages))); |
| 961 | 924 | if own_profile { |
| 962 | | - items.push(tab("organizations", o::t(lang, OK::Organizations), "")); |
| 925 | + items.push(tab("organizations", o::t(lang, OK::Organizations))); |
| 963 | 926 | } |
| 964 | 927 | if is_org && org_member { |
| 965 | 928 | let org = format!("/org/{}", enc(username)); |
| | @@ -967,13 +930,11 @@ pub fn profile_items( |
| 967 | 930 | key: "members", |
| 968 | 931 | href: format!("{org}/members"), |
| 969 | 932 | label: o::t(lang, OK::Members), |
| 970 | | - icon: "users", |
| 971 | 933 | }); |
| 972 | 934 | items.push(NavItem { |
| 973 | 935 | key: "teams", |
| 974 | 936 | href: format!("{org}/teams"), |
| 975 | 937 | label: o::t(lang, OK::Teams), |
| 976 | | - icon: "teams", |
| 977 | 938 | }); |
| 978 | 939 | } |
| 979 | 940 | items |
| | @@ -986,7 +947,6 @@ pub fn global_items(lang: Lang, can_create_org: bool) -> Vec<NavItem> { |
| 986 | 947 | key, |
| 987 | 948 | href: href.to_owned(), |
| 988 | 949 | label, |
| 989 | | - icon: "", |
| 990 | 950 | }; |
| 991 | 951 | let mut items = vec![ |
| 992 | 952 | item("explore", "/explore", t(lang, Key::Explore)), |
| | @@ -1015,63 +975,33 @@ pub fn global_items(lang: Lang, can_create_org: bool) -> Vec<NavItem> { |
| 1015 | 975 | } |
| 1016 | 976 | |
| 1017 | 977 | pub fn settings_items(lang: Lang) -> Vec<NavItem> { |
| 1018 | | - let item = |key, href: &'static str, label, icon| NavItem { |
| 978 | + let pk = crate::pages::passkeys::s; |
| 979 | + let item = |key, href: &'static str, label| NavItem { |
| 1019 | 980 | key, |
| 1020 | 981 | href: href.to_owned(), |
| 1021 | 982 | label, |
| 1022 | | - icon, |
| 1023 | 983 | }; |
| 1024 | 984 | vec![ |
| 1025 | | - item( |
| 1026 | | - "profile", |
| 1027 | | - "/settings/profile", |
| 1028 | | - t(lang, Key::Profile), |
| 1029 | | - "profile", |
| 1030 | | - ), |
| 1031 | | - item("keys", "/settings/keys", t(lang, Key::SshKeys), "keys"), |
| 1032 | | - item("gpg", "/settings/gpg", t(lang, Key::GpgKeys), "gpg"), |
| 1033 | | - item( |
| 1034 | | - "tokens", |
| 1035 | | - "/settings/tokens", |
| 1036 | | - t(lang, Key::AccessTokens), |
| 1037 | | - "tokens", |
| 1038 | | - ), |
| 1039 | | - item( |
| 1040 | | - "sessions", |
| 1041 | | - "/settings/sessions", |
| 1042 | | - t(lang, Key::Sessions), |
| 1043 | | - "sessions", |
| 1044 | | - ), |
| 1045 | | - item( |
| 1046 | | - "security", |
| 1047 | | - "/settings/security", |
| 1048 | | - t(lang, Key::Security), |
| 1049 | | - "security", |
| 1050 | | - ), |
| 1051 | | - item( |
| 1052 | | - "notifications", |
| 1053 | | - "/settings/notifications", |
| 1054 | | - t(lang, Key::MenuNotificationEmails), |
| 1055 | | - "notifications", |
| 1056 | | - ), |
| 985 | + item("profile", "/settings/profile", t(lang, Key::Profile)), |
| 1057 | 986 | item( |
| 1058 | 987 | "appearance", |
| 1059 | 988 | "/settings/appearance", |
| 1060 | 989 | mi::t(lang, MK::Appearance), |
| 1061 | | - "appearance", |
| 1062 | 990 | ), |
| 1063 | 991 | item( |
| 1064 | | - "export", |
| 1065 | | - "/settings/export", |
| 1066 | | - mg::t(lang, MGK::SettingsExport), |
| 1067 | | - "export", |
| 992 | + "notifications", |
| 993 | + "/settings/notifications", |
| 994 | + t(lang, Key::Notifications), |
| 1068 | 995 | ), |
| 996 | + item("security", "/settings/security", t(lang, Key::Security)), |
| 997 | + item("keys", "/settings/keys", pk(lang, "Keys", "Anahtarlar")), |
| 998 | + item("export", "/settings/export", pk(lang, "Data", "Veri")), |
| 1069 | 999 | ] |
| 1070 | 1000 | } |
| 1071 | 1001 | |
| 1072 | | -/// The section sidebar for a path under `/admin` or `/settings`, or `None` elsewhere. Picked from |
| 1073 | | -/// the path alone, so every page under those prefixes gets it. `/settings/security/log` is |
| 1074 | | -/// Security's page, so it highlights Security. |
| 1002 | +/// The tabs for a path under `/admin` or `/settings`, or `None` elsewhere. Picked from the path |
| 1003 | +/// alone, so every page under those prefixes gets them. A page folded into another tab marks that |
| 1004 | +/// tab: sessions are part of Security, and GPG keys and tokens part of Keys. |
| 1075 | 1005 | pub fn section_for(lang: Lang, path: &str) -> Option<Section> { |
| 1076 | 1006 | let mut parts = path.trim_matches('/').split('/'); |
| 1077 | 1007 | let first = parts.next()?; |
| | @@ -1079,30 +1009,13 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { |
| 1079 | 1009 | let (title, items) = match first { |
| 1080 | 1010 | "admin" => (ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), |
| 1081 | 1011 | "settings" => (o::t(lang, OK::Settings).to_owned(), settings_items(lang)), |
| 1082 | | - // An organization's settings pages (`/org/{name}/settings`) keep a |
| 1083 | | - // sidebar. Its profile, members and teams pages have none: the tab bar leads to them. `/org/new` |
| 1084 | | - // is the create form and keeps the global links. |
| 1085 | | - "org" if !second.is_empty() && second != "new" => { |
| 1086 | | - if parts.next() != Some("settings") { |
| 1087 | | - return None; |
| 1088 | | - } |
| 1089 | | - let current = if parts.next() == Some("pins") { |
| 1090 | | - "pins" |
| 1091 | | - } else { |
| 1092 | | - "settings" |
| 1093 | | - }; |
| 1094 | | - return Some(Section { |
| 1095 | | - title: second.to_owned(), |
| 1096 | | - back: o::t(lang, OK::BackToOrganization), |
| 1097 | | - back_href: user_href(second), |
| 1098 | | - items: org_items(lang, second), |
| 1099 | | - current, |
| 1100 | | - live: "", |
| 1101 | | - site: false, |
| 1102 | | - }); |
| 1103 | | - } |
| 1104 | 1012 | _ => return None, |
| 1105 | 1013 | }; |
| 1014 | + let second = match second { |
| 1015 | + "sessions" => "security", |
| 1016 | + "gpg" | "tokens" => "keys", |
| 1017 | + other => other, |
| 1018 | + }; |
| 1106 | 1019 | let current = items |
| 1107 | 1020 | .iter() |
| 1108 | 1021 | .find(|item| item.key == second) |
| | @@ -1115,123 +1028,34 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { |
| 1115 | 1028 | }; |
| 1116 | 1029 | Some(Section { |
| 1117 | 1030 | title, |
| 1118 | | - back: t(lang, Key::BackToSite), |
| 1119 | | - back_href: "/".to_owned(), |
| 1120 | 1031 | items, |
| 1121 | 1032 | current, |
| 1122 | 1033 | live, |
| 1123 | | - site: true, |
| 1124 | 1034 | }) |
| 1125 | 1035 | } |
| 1126 | 1036 | |
| 1127 | | -/// The section sidebar: a link back to the site, then the section's own links with |
| 1128 | | -/// `aria-current="page"` on the current one. |
| 1037 | +/// One row of text tabs, with `aria-current="page"` on the current one. |
| 1129 | 1038 | #[component] |
| 1130 | | -async fn section_nav( |
| 1131 | | - title: &str, |
| 1132 | | - back: &str, |
| 1133 | | - back_href: &str, |
| 1039 | +async fn section_tabs( |
| 1040 | + label: &str, |
| 1134 | 1041 | items: Vec<NavItem>, |
| 1135 | 1042 | current: &str, |
| 1136 | 1043 | live: &str, |
| 1137 | 1044 | ) -> Result<impl View> { |
| 1138 | 1045 | let live = (!live.is_empty()).then_some(live); |
| 1139 | | - let links: Vec<(NavItem, bool, &'static str)> = items |
| 1046 | + let links: Vec<(NavItem, bool)> = items |
| 1140 | 1047 | .into_iter() |
| 1141 | 1048 | .map(|item| { |
| 1142 | 1049 | let on = item.key == current; |
| 1143 | | - let class = if on { "side-link on" } else { "side-link" }; |
| 1144 | | - (item, on, class) |
| 1050 | + (item, on) |
| 1145 | 1051 | }) |
| 1146 | 1052 | .collect(); |
| 1147 | 1053 | Ok(view! { |
| 1148 | | - <nav class="side-links" aria-label=(back)> |
| 1149 | | - <a class="side-link" href=(back_href)> |
| 1150 | | - nav_icon(name: "back") |
| 1151 | | - (back) |
| 1152 | | - </a> |
| 1054 | + <nav class="tabs" aria-label=(label) data-live=(live)> |
| 1055 | + for (item, on) in links.into_iter() { |
| 1056 | + <a href=(item.href) aria-current=(on.then_some("page"))>(item.label)</a> |
| 1057 | + } |
| 1153 | 1058 | </nav> |
| 1154 | | - <div class="side-group"> |
| 1155 | | - <h2 class="side-h">(title)</h2> |
| 1156 | | - <nav class="side-links" aria-label=(title) data-live=(live)> |
| 1157 | | - for (item, on, class) in links.into_iter() { |
| 1158 | | - <a class=(class) href=(item.href) aria-current=(on.then_some("page"))> |
| 1159 | | - nav_icon(name: item.icon) |
| 1160 | | - (item.label) |
| 1161 | | - </a> |
| 1162 | | - } |
| 1163 | | - </nav> |
| 1164 | | - </div> |
| 1165 | | - }) |
| 1166 | | -} |
| 1167 | | - |
| 1168 | | -/// The inline icon of a section link, by name. Unknown names draw nothing. |
| 1169 | | -#[component] |
| 1170 | | -async fn nav_icon(name: &str) -> Result<impl View> { |
| 1171 | | - Ok(view! { |
| 1172 | | - if name == "back" { |
| 1173 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M19 12H5M11 6l-6 6 6 6"/></svg> |
| 1174 | | - } |
| 1175 | | - if name == "teams" { |
| 1176 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="7" r="3"/><circle cx="5" cy="17" r="3"/><circle cx="19" cy="17" r="3"/><path d="M10 9.5 6.5 14.5M14 9.5l3.5 5M8 17h8"/></svg> |
| 1177 | | - } |
| 1178 | | - if name == "health" { |
| 1179 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12h4l2.5-6 4 12 2.5-6H21"/></svg> |
| 1180 | | - } |
| 1181 | | - if name == "users" { |
| 1182 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="9" cy="8" r="4"/><path d="M2 21c0-4 3-6 7-6s7 2 7 6"/><path d="M16 4a4 4 0 0 1 0 8M22 21c0-3-2-5-4-5.5"/></svg> |
| 1183 | | - } |
| 1184 | | - if name == "invites" { |
| 1185 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg> |
| 1186 | | - } |
| 1187 | | - if name == "audit" { |
| 1188 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4h6v3H9z"/><path d="M7 5H5v16h14V5h-2"/><path d="M9 12h6M9 16h6"/></svg> |
| 1189 | | - } |
| 1190 | | - if name == "runners" { |
| 1191 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="6" rx="1.5"/><rect x="3" y="14" width="18" height="6" rx="1.5"/><path d="M7 7h.01M7 17h.01"/></svg> |
| 1192 | | - } |
| 1193 | | - if name == "mail" { |
| 1194 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M22 2 11 13"/><path d="M22 2 15 22l-4-9-9-4z"/></svg> |
| 1195 | | - } |
| 1196 | | - if name == "server" { |
| 1197 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h10M18 6h2M4 12h2M10 12h10M4 18h12M20 18h0"/><circle cx="16" cy="6" r="2"/><circle cx="8" cy="12" r="2"/><circle cx="18" cy="18" r="2"/></svg> |
| 1198 | | - } |
| 1199 | | - if name == "backups" { |
| 1200 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><ellipse cx="12" cy="5" rx="8" ry="3"/><path d="M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5"/><path d="M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6"/></svg> |
| 1201 | | - } |
| 1202 | | - if name == "replication" { |
| 1203 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 11a8 8 0 0 0-14.5-4.5L3 9"/><path d="M3 4v5h5"/><path d="M4 13a8 8 0 0 0 14.5 4.5L21 15"/><path d="M21 20v-5h-5"/></svg> |
| 1204 | | - } |
| 1205 | | - if name == "profile" { |
| 1206 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg> |
| 1207 | | - } |
| 1208 | | - if name == "keys" { |
| 1209 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="8" cy="15" r="4"/><path d="M11 12l9-9M17 6l3 3M14 9l2 2"/></svg> |
| 1210 | | - } |
| 1211 | | - if name == "gpg" { |
| 1212 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="9" r="6"/><path d="m9 14-2 7 5-3 5 3-2-7"/></svg> |
| 1213 | | - } |
| 1214 | | - if name == "tokens" { |
| 1215 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9h16M4 15h16M10 3l-2 18M16 3l-2 18"/></svg> |
| 1216 | | - } |
| 1217 | | - if name == "sessions" { |
| 1218 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg> |
| 1219 | | - } |
| 1220 | | - if name == "security" { |
| 1221 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6z"/></svg> |
| 1222 | | - } |
| 1223 | | - if name == "notifications" { |
| 1224 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 7 3 9H3c0-2 3-2 3-9"/><path d="M10.3 21a1.9 1.9 0 0 0 3.4 0"/></svg> |
| 1225 | | - } |
| 1226 | | - if name == "appearance" { |
| 1227 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg> |
| 1228 | | - } |
| 1229 | | - if name == "export" { |
| 1230 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v12"/><path d="m7 10 5 5 5-5"/><path d="M5 21h14"/></svg> |
| 1231 | | - } |
| 1232 | | - if name == "pins" { |
| 1233 | | - <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17v5"/><path d="M9 3h6l-1 6 3 3v2H7v-2l3-3z"/></svg> |
| 1234 | | - } |
| 1235 | 1059 | }) |
| 1236 | 1060 | } |
| 1237 | 1061 | |
| | @@ -1295,12 +1119,12 @@ pub async fn empty_state( |
| 1295 | 1119 | #[default] child: Child<'_>, |
| 1296 | 1120 | ) -> Result<impl View> { |
| 1297 | 1121 | Ok(view! { |
| 1298 | | - <div class="empty-state"> |
| 1299 | | - <p class="empty-state-title">(title)</p> |
| 1122 | + <div class="sec empty-state"> |
| 1123 | + <p class="state">(title)</p> |
| 1300 | 1124 | if let Some(hint) = hint { |
| 1301 | | - <p class="empty-state-hint">(hint)</p> |
| 1125 | + <p class="hint">(hint)</p> |
| 1302 | 1126 | } |
| 1303 | | - <div class="empty-state-action">(child)</div> |
| 1127 | + <div class="acts">(child)</div> |
| 1304 | 1128 | </div> |
| 1305 | 1129 | }) |
| 1306 | 1130 | } |
| | @@ -2070,7 +1894,7 @@ mod shell_tests { |
| 2070 | 1894 | assert!(tag.contains("defer"), "{tag}"); |
| 2071 | 1895 | assert_no_inline_scripts(&html); |
| 2072 | 1896 | |
| 2073 | | - assert!(html.contains("<main tabindex=\"-1\">")); |
| 1897 | + assert!(html.contains("<main tabindex=\"-1\" data-width=\"col\">")); |
| 2074 | 1898 | assert!(html.contains("data-hard=\"true\" method=\"post\" action=\"/login\"")); |
| 2075 | 1899 | |
| 2076 | 1900 | // An anonymous page renders the default colours. |
| | @@ -0,0 +1,75 @@ |
| 1 | +//! The parts every page acts through: the two ways an action opens in place. See the page language |
| 2 | +//! in `style/_min.scss`. An action sits right under what it acts on, as a text link. |
| 3 | + |
| 4 | +use topcoat::Result; |
| 5 | +use topcoat::view::{Child, View, component, view}; |
| 6 | + |
| 7 | +use crate::i18n::Lang; |
| 8 | +use crate::pages::passkeys::s; |
| 9 | + |
| 10 | +/// A text link that opens its form in place, on its own line under the links beside it. `open` |
| 11 | +/// starts it open, as a form sent back with an error must. |
| 12 | +#[component] |
| 13 | +pub async fn reveal( |
| 14 | + label: &str, |
| 15 | + #[default] id: Option<&str>, |
| 16 | + #[default] open: bool, |
| 17 | + #[default] child: Child<'_>, |
| 18 | +) -> Result<impl View> { |
| 19 | + Ok(view! { |
| 20 | + <details class="reveal" id=(id) open=(open)> |
| 21 | + <summary class="act">(label)</summary> |
| 22 | + <div class="opened">(child)</div> |
| 23 | + </details> |
| 24 | + }) |
| 25 | +} |
| 26 | + |
| 27 | +/// A destructive text link that asks first, in place. The POST goes only from the second button. |
| 28 | +/// `fields` are the form's hidden fields besides the CSRF token, `note` says what will be lost. |
| 29 | +#[component] |
| 30 | +pub async fn confirm_act( |
| 31 | + lang: Lang, |
| 32 | + label: &str, |
| 33 | + action: &str, |
| 34 | + csrf: &str, |
| 35 | + #[default] fields: Vec<(String, String)>, |
| 36 | + #[default] note: Option<String>, |
| 37 | +) -> Result<impl View> { |
| 38 | + Ok(view! { |
| 39 | + <details class="reveal"> |
| 40 | + <summary class="act danger">(label)</summary> |
| 41 | + <form class="opened" method="post" action=(action)> |
| 42 | + <input type="hidden" name="csrf" value=(csrf)> |
| 43 | + for (name, value) in fields.into_iter() { |
| 44 | + <input type="hidden" name=(name) value=(value)> |
| 45 | + } |
| 46 | + if let Some(note) = note { |
| 47 | + <p class="hint">(note)</p> |
| 48 | + } |
| 49 | + <div class="acts"> |
| 50 | + <button type="submit" class="act danger">(label)</button> |
| 51 | + <button type="button" class="act quiet" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> |
| 52 | + </div> |
| 53 | + </form> |
| 54 | + </details> |
| 55 | + }) |
| 56 | +} |
| 57 | + |
| 58 | +/// One text link that posts at once, for actions that lose nothing. |
| 59 | +#[component] |
| 60 | +pub async fn post_act( |
| 61 | + label: &str, |
| 62 | + action: &str, |
| 63 | + csrf: &str, |
| 64 | + #[default] fields: Vec<(String, String)>, |
| 65 | +) -> Result<impl View> { |
| 66 | + Ok(view! { |
| 67 | + <form class="act-form" method="post" action=(action)> |
| 68 | + <input type="hidden" name="csrf" value=(csrf)> |
| 69 | + for (name, value) in fields.into_iter() { |
| 70 | + <input type="hidden" name=(name) value=(value)> |
| 71 | + } |
| 72 | + <button type="submit" class="act">(label)</button> |
| 73 | + </form> |
| 74 | + }) |
| 75 | +} |
| | @@ -52,13 +52,13 @@ pub async fn repo_rows(rows: Vec<RepoRow>, lang: Lang) -> Result<impl View> { |
| 52 | 52 | Ok(view! { |
| 53 | 53 | <ul class="repo-list"> |
| 54 | 54 | for row in rows.into_iter() { |
| 55 | | - <li class="repo-item" data-kb-row=""> |
| 56 | | - <a class="repo-name" href=(row.href.as_str())>(row.title.as_str())</a> |
| 55 | + <li class="line repo-item" data-kb-row=""> |
| 56 | + <a class="name repo-name" href=(row.href.as_str())>(row.title.as_str())</a> |
| 57 | 57 | <span class=(badge_class(row.visibility))>(i18n::visibility_label(lang, row.visibility))</span> |
| 58 | 58 | if !row.description.is_empty() { |
| 59 | | - <span class="repo-desc" title=(row.description.as_str())>(row.description.as_str())</span> |
| 59 | + <span class="val repo-desc" title=(row.description.as_str())>(row.description.as_str())</span> |
| 60 | 60 | } |
| 61 | | - <span class="muted small repo-stats"> |
| 61 | + <span class="val repo-stats"> |
| 62 | 62 | "\u{2605} " (row.stars.to_string()) |
| 63 | 63 | (before) |
| 64 | 64 | <time data-rel="true" datetime=(row.when.iso.as_str()) title=(row.when.absolute.as_str())>(row.when.relative.as_str())</time> |
| | @@ -81,8 +81,8 @@ pub struct SortLink { |
| 81 | 81 | #[component] |
| 82 | 82 | pub async fn sort_chips(links: Vec<SortLink>, lang: Lang) -> Result<impl View> { |
| 83 | 83 | Ok(view! { |
| 84 | | - <nav class="explore-sort" aria-label=(g::t(lang, K::SortNav))> |
| 85 | | - <span class="muted small">(g::t(lang, K::SortBy))</span> |
| 84 | + <nav class="sub" aria-label=(g::t(lang, K::SortNav))> |
| 85 | + <span>(g::t(lang, K::SortBy))</span> |
| 86 | 86 | for link in links.into_iter() { |
| 87 | 87 | if link.current { |
| 88 | 88 | <span class="current" aria-current="true">(link.label)</span> |
| | @@ -15,6 +15,7 @@ use crate::i18n::Lang; |
| 15 | 15 | use crate::i18n::pulls_review::{self as g, K}; |
| 16 | 16 | use crate::pages::issue_parts::When; |
| 17 | 17 | use crate::render::markdown::{LinkContext, render_markdown}; |
| 18 | +use crate::views::parts::{confirm_act, post_act}; |
| 18 | 19 | use crate::views::{avatar_url, display_name, now_unix, user_href, user_link}; |
| 19 | 20 | |
| 20 | 21 | /// What the Apply control of a suggestion shows. A root without a state shows the diff only. |
| | @@ -350,14 +351,10 @@ async fn thread_actions( |
| 350 | 351 | return_to: String, |
| 351 | 352 | ) -> Result<impl View> { |
| 352 | 353 | Ok(view! { |
| 353 | | - <div class="review-thread-actions"> |
| 354 | + <div class="acts review-thread-actions"> |
| 354 | 355 | if let Some(action) = resolve_action { |
| 355 | | - <form method="post" action=(action.as_str()) class="review-inline"> |
| 356 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 357 | | - <input type="hidden" name="resolved" value=(resolve_value.as_str())> |
| 358 | | - <input type="hidden" name="return" value=(return_to.as_str())> |
| 359 | | - <button type="submit" class="link-button">(resolve_label.as_str())</button> |
| 360 | | - </form> |
| 356 | + post_act(label: resolve_label.as_str(), action: action.as_str(), csrf: csrf.as_str(), |
| 357 | + fields: vec![("resolved".to_owned(), resolve_value.clone()), ("return".to_owned(), return_to.clone())]) |
| 361 | 358 | } |
| 362 | 359 | </div> |
| 363 | 360 | }) |
| | @@ -373,16 +370,14 @@ async fn reply_form( |
| 373 | 370 | let label = g::t(lang, K::ReplyLabel); |
| 374 | 371 | let button = g::t(lang, K::ReplyButton); |
| 375 | 372 | Ok(view! { |
| 376 | | - <form method="post" action=(action.as_str()) class="review-reply stack"> |
| 373 | + <form method="post" action=(action.as_str()) class="review-reply fields"> |
| 377 | 374 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 378 | 375 | <input type="hidden" name="return" value=(return_to.as_str())> |
| 379 | | - <label> |
| 376 | + <label class="field"> |
| 380 | 377 | <span>(label)</span> |
| 381 | 378 | <textarea name="body" rows="3"></textarea> |
| 382 | 379 | </label> |
| 383 | | - <div class="issue-actions"> |
| 384 | | - <button type="submit">(button)</button> |
| 385 | | - </div> |
| 380 | + <button type="submit" class="primary">(button)</button> |
| 386 | 381 | </form> |
| 387 | 382 | }) |
| 388 | 383 | } |
| | @@ -408,6 +403,7 @@ async fn thread_comment( |
| 408 | 403 | let edited = g::t(lang, K::Edited); |
| 409 | 404 | let edit = g::t(lang, K::EditLink); |
| 410 | 405 | let delete = g::t(lang, K::DeleteButton); |
| 406 | + let has_acts = edit_href.is_some() || delete_href.is_some(); |
| 411 | 407 | Ok(view! { |
| 412 | 408 | <article class="review-comment"> |
| 413 | 409 | <header class="review-comment-head"> |
| | @@ -417,23 +413,22 @@ async fn thread_comment( |
| 417 | 413 | if let Some(href) = history_href { |
| 418 | 414 | <a class="issue-edited" href=(href.as_str())>(edited)</a> |
| 419 | 415 | } |
| 420 | | - <span class="review-comment-actions"> |
| 421 | | - if let Some(href) = edit_href { |
| 422 | | - <a href=(href.as_str())>(edit)</a> |
| 423 | | - } |
| 424 | | - if let Some(action) = delete_href { |
| 425 | | - <form method="post" action=(action.as_str()) class="review-inline"> |
| 426 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 427 | | - <input type="hidden" name="return" value=(return_to.as_str())> |
| 428 | | - <button type="submit" class="link-button">(delete)</button> |
| 429 | | - </form> |
| 430 | | - } |
| 431 | | - </span> |
| 432 | 416 | </header> |
| 433 | 417 | for part in parts.into_iter() { |
| 434 | 418 | comment_part(part: part, csrf: csrf.clone(), return_to: return_to.clone(), |
| 435 | 419 | lang: lang) |
| 436 | 420 | } |
| 421 | + if has_acts { |
| 422 | + <div class="acts"> |
| 423 | + if let Some(href) = edit_href { |
| 424 | + <a class="act" href=(href.as_str())>(edit)</a> |
| 425 | + } |
| 426 | + if let Some(action) = delete_href { |
| 427 | + confirm_act(lang: lang, label: delete, action: action.as_str(), csrf: csrf.as_str(), |
| 428 | + fields: vec![("return".to_owned(), return_to.clone())]) |
| 429 | + } |
| 430 | + </div> |
| 431 | + } |
| 437 | 432 | </article> |
| 438 | 433 | }) |
| 439 | 434 | } |
| | @@ -475,12 +470,10 @@ async fn comment_part( |
| 475 | 470 | <div class="review-suggestion-line add"><span class="review-suggestion-sign">(added_sign)</span><code>(line.as_str())</code></div> |
| 476 | 471 | } |
| 477 | 472 | if let Some(action) = apply_action { |
| 478 | | - <form method="post" action=(action.as_str()) class="review-suggestion-apply"> |
| 479 | | - <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 480 | | - <input type="hidden" name="return" value=(return_to.as_str())> |
| 481 | | - <input type="hidden" name="block" value=(block.as_str())> |
| 482 | | - <button type="submit">(apply_label)</button> |
| 483 | | - </form> |
| 473 | + <div class="acts review-suggestion-apply"> |
| 474 | + post_act(label: apply_label, action: action.as_str(), csrf: csrf.as_str(), |
| 475 | + fields: vec![("block".to_owned(), block.clone()), ("return".to_owned(), return_to.clone())]) |
| 476 | + </div> |
| 484 | 477 | } |
| 485 | 478 | if outdated { |
| 486 | 479 | <p class="review-suggestion-outdated">(outdated_text)</p> |
| | @@ -0,0 +1,226 @@ |
| 1 | +#!/usr/bin/env bun |
| 2 | +// Measures pages against the page language in a real headless browser. For every path and window it |
| 3 | +// checks the left edge, sideways overflow, controls past the column and old layout classes, then |
| 4 | +// opens each menu and disclosure on the page and checks the panel stays in the window. |
| 5 | +// |
| 6 | +// Usage: bun scripts/audit/measure.ts BASE SESSION_COOKIE PATHS_FILE OUT_DIR [--shots] [--menus] |
| 7 | +// PATHS_FILE has one path a line. Results go to OUT_DIR/measure.json; shots to OUT_DIR/shots. |
| 8 | + |
| 9 | +import { mkdirSync, readFileSync, writeFileSync, readdirSync, existsSync } from "fs"; |
| 10 | +import { homedir } from "os"; |
| 11 | + |
| 12 | +const [forge, cookie, pathsFile, out] = process.argv.slice(2); |
| 13 | +const shots = process.argv.includes("--shots"); |
| 14 | +const menus = process.argv.includes("--menus"); |
| 15 | +const FLOATING = "details.menu, details.pins-menu, details.ref-select, details.clone, details.corner, details.strip-runs, details.row-menu, details.commit-status, details.reaction-picker"; |
| 16 | +const paths = readFileSync(pathsFile, "utf8").split("\n").map((l) => l.trim()).filter(Boolean); |
| 17 | +const windows = [ |
| 18 | + [1920, 1080], |
| 19 | + [2560, 1440], |
| 20 | + [390, 844], |
| 21 | +]; |
| 22 | +const PORT = 9333; |
| 23 | + |
| 24 | +// A __Host- cookie cannot live on plain http, so a small proxy adds it. Streams never end and would |
| 25 | +// starve the browser's connections, so they answer at once. |
| 26 | +const proxy = Bun.serve({ |
| 27 | + port: 0, |
| 28 | + idleTimeout: 60, |
| 29 | + async fetch(req) { |
| 30 | + const url = new URL(req.url); |
| 31 | + if (/\/(stream|events)$/.test(url.pathname)) return new Response(null, { status: 204 }); |
| 32 | + // AUDIT_CSS=file serves that stylesheet, to compare two stylesheets on the same data. |
| 33 | + if (process.env.AUDIT_CSS && url.pathname === "/assets/main.css") { |
| 34 | + return new Response(Bun.file(process.env.AUDIT_CSS), { headers: { "content-type": "text/css" } }); |
| 35 | + } |
| 36 | + const headers = new Headers(req.headers); |
| 37 | + headers.delete("host"); |
| 38 | + if (cookie !== "-") headers.set("cookie", cookie); |
| 39 | + const r = await fetch(forge + url.pathname + url.search, { method: req.method, headers, body: req.body, redirect: "manual" }); |
| 40 | + const back = new Headers(r.headers); |
| 41 | + back.delete("content-encoding"); |
| 42 | + back.delete("content-length"); |
| 43 | + const location = back.get("location"); |
| 44 | + if (location?.startsWith(forge)) back.set("location", location.slice(forge.length)); |
| 45 | + return new Response(r.body, { status: r.status, headers: back }); |
| 46 | + }, |
| 47 | +}); |
| 48 | +const base = `http://127.0.0.1:${proxy.port}`; |
| 49 | + |
| 50 | +function chrome(): string { |
| 51 | + const root = `${homedir()}/.cache/ms-playwright`; |
| 52 | + const dir = readdirSync(root).find((d) => d.startsWith("chromium_headless_shell")); |
| 53 | + if (!dir) throw new Error("no headless shell"); |
| 54 | + const sub = readdirSync(`${root}/${dir}`).find((d) => existsSync(`${root}/${dir}/${d}/chrome-headless-shell`)); |
| 55 | + return `${root}/${dir}/${sub}/chrome-headless-shell`; |
| 56 | +} |
| 57 | + |
| 58 | +const proc = Bun.spawn( |
| 59 | + [chrome(), `--remote-debugging-port=${PORT}`, "--no-sandbox", "--disable-gpu", "--hide-scrollbars", `--user-data-dir=${out}/profile`, "about:blank"], |
| 60 | + { stdout: "ignore", stderr: "ignore" }, |
| 61 | +); |
| 62 | + |
| 63 | +let target = ""; |
| 64 | +for (let i = 0; i < 100 && !target; i++) { |
| 65 | + await Bun.sleep(100); |
| 66 | + try { |
| 67 | + const list = (await (await fetch(`http://127.0.0.1:${PORT}/json`)).json()) as { type: string; webSocketDebuggerUrl: string }[]; |
| 68 | + target = list.find((t) => t.type === "page")?.webSocketDebuggerUrl ?? ""; |
| 69 | + } catch {} |
| 70 | +} |
| 71 | +if (!target) throw new Error("browser did not start"); |
| 72 | + |
| 73 | +const ws = new WebSocket(target); |
| 74 | +await new Promise((r) => (ws.onopen = r)); |
| 75 | +let id = 0; |
| 76 | +const waiting = new Map<number, (v: any) => void>(); |
| 77 | +const events = new Map<string, () => void>(); |
| 78 | +ws.onmessage = (e) => { |
| 79 | + const m = JSON.parse(e.data as string); |
| 80 | + if (m.id) { |
| 81 | + waiting.get(m.id)?.(m.result ?? m.error); |
| 82 | + waiting.delete(m.id); |
| 83 | + } else if (m.method) { |
| 84 | + events.get(m.method)?.(); |
| 85 | + } |
| 86 | +}; |
| 87 | +function send(method: string, params: object = {}): Promise<any> { |
| 88 | + return new Promise((r) => { |
| 89 | + waiting.set(++id, r); |
| 90 | + ws.send(JSON.stringify({ id, method, params })); |
| 91 | + }); |
| 92 | +} |
| 93 | +async function js(expression: string): Promise<any> { |
| 94 | + const r = await send("Runtime.evaluate", { expression, returnByValue: true, awaitPromise: true }); |
| 95 | + return r?.result?.value; |
| 96 | +} |
| 97 | + |
| 98 | +async function go(url: string) { |
| 99 | + const loaded = new Promise<void>((r) => events.set("Page.loadEventFired", r)); |
| 100 | + await send("Page.navigate", { url }); |
| 101 | + await Promise.race([loaded, Bun.sleep(8000)]); |
| 102 | + await Bun.sleep(150); |
| 103 | +} |
| 104 | + |
| 105 | +async function shot(name: string) { |
| 106 | + const r = await send("Page.captureScreenshot", { format: "png" }); |
| 107 | + if (r?.data) await Bun.write(`${out}/shots/${name}.png`, Buffer.from(r.data, "base64")); |
| 108 | +} |
| 109 | + |
| 110 | +// Runs in the page. Everything it reports is a broken rule. |
| 111 | +const CHECK = `(() => { |
| 112 | + const bad = []; |
| 113 | + const main = document.querySelector('main'); |
| 114 | + if (!main) return ['no main']; |
| 115 | + const w = innerWidth; |
| 116 | + if (document.documentElement.scrollWidth > w + 1) { |
| 117 | + const over = [...main.querySelectorAll('*')].find((e) => e.getBoundingClientRect().right > w + 1 && !e.closest('pre, .diff, .table-scroll, [data-scroll-x]')); |
| 118 | + bad.push('sideways overflow ' + document.documentElement.scrollWidth + ' at ' + (over ? over.tagName + '.' + over.className : '?')); |
| 119 | + } |
| 120 | + const cs = getComputedStyle(main); |
| 121 | + const left = main.getBoundingClientRect().left + parseFloat(cs.paddingLeft); |
| 122 | + const right = main.getBoundingClientRect().right - parseFloat(cs.paddingRight); |
| 123 | + const bar = document.querySelector('.pathbar'); |
| 124 | + if (w >= 900 && bar && Math.abs(bar.getBoundingClientRect().left - left) > 1) bad.push('edge: path bar ' + bar.getBoundingClientRect().left + ' main ' + left); |
| 125 | + for (const e of main.querySelectorAll('a, button, input, select, textarea, summary')) { |
| 126 | + const r = e.getBoundingClientRect(); |
| 127 | + if (!r.width || e.closest('pre, [popover], .menu-list, .pop-panel, .corner-menu, .tabs, .sub, .repo-tabs, .profile-tabs, .heat-grid, details:not([open]) > :not(summary)')) continue; |
| 128 | + const where = ' in ' + (e.parentElement.className || e.parentElement.tagName) + ' < ' + (e.parentElement.parentElement.className || e.parentElement.parentElement.tagName); |
| 129 | + if (r.right > right + 1) bad.push('past the column: ' + e.tagName + ' "' + (e.textContent || e.name || '').trim().slice(0, 30) + '" right ' + Math.round(r.right) + ' > ' + Math.round(right) + where); |
| 130 | + if (r.left < left - 1) bad.push('left of the edge: ' + e.tagName + '.' + e.className + ' "' + (e.textContent || '').trim().slice(0, 30) + '"' + where); |
| 131 | + } |
| 132 | + const width = main.dataset.width; |
| 133 | + if (width !== 'wide') { |
| 134 | + for (const c of ['card', 'rows-pane', 'row-line', 'fit-pane', 'page-head', 'row-field', 'side-link', 'settings-layout']) { |
| 135 | + const n = main.querySelectorAll('.' + c).length; |
| 136 | + if (n) bad.push('old layout .' + c + ' x' + n); |
| 137 | + } |
| 138 | + } |
| 139 | + if (width !== 'wide') { |
| 140 | + for (const e of main.querySelectorAll('div, section, article, ul, ol, form, aside, nav')) { |
| 141 | + const c = getComputedStyle(e); |
| 142 | + const r = e.getBoundingClientRect(); |
| 143 | + if (r.height < 64 || r.width < 200 || e.closest('pre, table, .copy-box, .heatmap, [popover], .menu-list, .pop-panel, .corner-menu, .diff-file, .snippet-files, details > .status-list')) continue; |
| 144 | + const filled = c.backgroundColor !== 'rgba(0, 0, 0, 0)'; |
| 145 | + const boxed = parseFloat(c.borderTopWidth) > 0 && parseFloat(c.borderLeftWidth) > 0 && parseFloat(c.borderRightWidth) > 0; |
| 146 | + if (filled || boxed) bad.push('box: ' + e.tagName + '.' + String(e.className).slice(0, 40)); |
| 147 | + } |
| 148 | + for (const e of main.querySelectorAll('select')) { |
| 149 | + if (!e.closest('.field') && e.getBoundingClientRect().width > 320) bad.push('stretched select ' + (e.name || '')); |
| 150 | + } |
| 151 | + for (const e of main.querySelectorAll('label:not(.colour-choice):has(> input[type=checkbox], > input[type=radio])')) { |
| 152 | + const i = e.querySelector('input').getBoundingClientRect(); |
| 153 | + const t = e.querySelector('span, small'); |
| 154 | + if (t && t.getBoundingClientRect().top >= i.bottom - 1) bad.push('tick above its label: ' + t.textContent.trim().slice(0, 30)); |
| 155 | + } |
| 156 | + } |
| 157 | + for (const b of main.querySelectorAll('.acts > button:not(.act, .primary), .sec button.danger:not(.act)')) bad.push('button where a text link belongs: ' + b.textContent.trim().slice(0, 30)); |
| 158 | + return [...new Set(bad)]; |
| 159 | +})()`; |
| 160 | + |
| 161 | +// Opens each closed disclosure and popover in turn, checks its panel, shuts it. |
| 162 | +const OPEN = `(async () => { |
| 163 | + const bad = []; |
| 164 | + let opened = 0; |
| 165 | + const wait = () => new Promise((r) => setTimeout(r, 30)); |
| 166 | + const all = [...document.querySelectorAll('details:not([open]), [popovertarget]')].filter((e) => e.getClientRects().length || e.tagName === 'DETAILS'); |
| 167 | + for (const e of all.slice(0, 60)) { |
| 168 | + const summary = e.tagName === 'DETAILS' ? e.querySelector(':scope > summary') : e; |
| 169 | + if (!summary || !summary.getClientRects().length || e.parentElement.closest('details:not([open])')) continue; |
| 170 | + summary.click(); |
| 171 | + await wait(); |
| 172 | + opened++; |
| 173 | + const root = e.tagName === 'DETAILS' ? e : document.querySelector(':popover-open'); |
| 174 | + if (root) { |
| 175 | + for (const k of root.querySelectorAll('*')) { |
| 176 | + const r = k.getBoundingClientRect(); |
| 177 | + if (!r.width || !r.height || k.closest('pre')) continue; |
| 178 | + if (r.right > innerWidth + 1 || r.left < -1) { bad.push('open panel leaves the window: ' + (summary.textContent || '').trim().slice(0, 30) + ' at ' + k.tagName + '.' + k.className + ' ' + Math.round(r.left) + '-' + Math.round(r.right)); break; } |
| 179 | + } |
| 180 | + if (document.documentElement.scrollWidth > innerWidth + 1) bad.push('opening makes the page wide: ' + (summary.textContent || '').trim().slice(0, 30)); |
| 181 | + } |
| 182 | + if (e.tagName === 'DETAILS') { e.open = false; } else { document.querySelector(':popover-open')?.hidePopover(); } |
| 183 | + await wait(); |
| 184 | + } |
| 185 | + return { opened, bad: [...new Set(bad)] }; |
| 186 | +})()`; |
| 187 | + |
| 188 | +await send("Page.enable"); |
| 189 | +await send("Runtime.enable"); |
| 190 | +await send("Network.enable"); |
| 191 | +mkdirSync(`${out}/shots`, { recursive: true }); |
| 192 | +const report: Record<string, string[]> = {}; |
| 193 | +let openedTotal = 0; |
| 194 | +for (const path of paths) { |
| 195 | + for (const [width, height] of windows) { |
| 196 | + await send("Emulation.setDeviceMetricsOverride", { width, height, deviceScaleFactor: 1, mobile: false }); |
| 197 | + await go(base + path); |
| 198 | + const bad: string[] = (await js(CHECK)) ?? ["page did not answer"]; |
| 199 | + const code = await js("document.title"); |
| 200 | + if (/not found|error/i.test(code ?? "")) bad.push("title: " + code); |
| 201 | + const name = path.replace(/[^a-z0-9]+/gi, "_") + "_" + width; |
| 202 | + if (shots) await shot(name); |
| 203 | + // --menus: one shot per floating panel, open, for review by eye. |
| 204 | + if (menus) { |
| 205 | + const count = (await js(`document.querySelectorAll(${JSON.stringify(FLOATING)}).length`)) ?? 0; |
| 206 | + for (let i = 0; i < Math.min(count, 12); i++) { |
| 207 | + const ok = await js(`(() => { const d = document.querySelectorAll(${JSON.stringify(FLOATING)})[${i}]; const s = d?.querySelector(':scope > summary'); if (!s || !s.getClientRects().length) return false; s.click(); return true; })()`); |
| 208 | + if (!ok) continue; |
| 209 | + await Bun.sleep(80); |
| 210 | + await shot(`${name}_menu${i}`); |
| 211 | + await js(`document.querySelectorAll(${JSON.stringify(FLOATING)})[${i}].open = false`); |
| 212 | + } |
| 213 | + } |
| 214 | + const open = await js(OPEN); |
| 215 | + if (open) { |
| 216 | + openedTotal += open.opened; |
| 217 | + bad.push(...open.bad); |
| 218 | + } |
| 219 | + if (bad.length) report[`${path} @${width}`] = bad; |
| 220 | + } |
| 221 | +} |
| 222 | + |
| 223 | +proc.kill(); |
| 224 | +writeFileSync(`${out}/measure.json`, JSON.stringify(report, null, 1)); |
| 225 | +console.log(`${paths.length} paths, ${paths.length * windows.length} views, ${openedTotal} panels opened, ${Object.keys(report).length} views with problems`); |
| 226 | +process.exit(0); |
| | @@ -89,6 +89,13 @@ if [[ $KEEP == 0 ]]; then |
| 89 | 89 | python3 "$ROOT/scripts/audit/seed.py" "http://127.0.0.1:$PORT" "$OUT" 2>&1 | tee "$OUT/seed.log" |
| 90 | 90 | fi |
| 91 | 91 | |
| 92 | +# AUDIT_SERVE=1 stops here and keeps the seeded server up, for scripts/audit/measure.ts. |
| 93 | +if [[ -n "${AUDIT_SERVE:-}" ]]; then |
| 94 | + echo "[run] serving on http://127.0.0.1:$PORT" |
| 95 | + wait "$FORGE_PID" |
| 96 | + exit 0 |
| 97 | +fi |
| 98 | + |
| 92 | 99 | echo "[run] screenshots" |
| 93 | 100 | AUDIT_PROXY_PORT="${AUDIT_PROXY_PORT:-$((PORT + 10))}" \ |
| 94 | 101 | python3 "$ROOT/scripts/audit/shoot.py" "http://127.0.0.1:$PORT" "$OUT" "$ROOT/crates/forge-web/src" 2>&1 | tee "$OUT/shoot.log" |
| | @@ -528,6 +528,14 @@ def status_of(url): |
| 528 | 528 | |
| 529 | 529 | |
| 530 | 530 | def main(): |
| 531 | + # AUDIT_LIST=file writes the concrete paths and the session cookie, for measure.ts, and stops. |
| 532 | + if os.environ.get("AUDIT_LIST"): |
| 533 | + with open(os.environ["AUDIT_LIST"], "w") as f: |
| 534 | + for pat in discover(): |
| 535 | + for url, _ in concrete(pat): |
| 536 | + f.write(url + "\n") |
| 537 | + print(cookie_for("user", "dark")) |
| 538 | + return |
| 531 | 539 | os.makedirs(SHOTS, exist_ok=True) |
| 532 | 540 | os.makedirs(os.path.join(OUT, "tmp"), exist_ok=True) |
| 533 | 541 | try: |
| | @@ -52,289 +52,8 @@ color: var(--text); |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | | -// A session's details over /settings/sessions, opened from its title. The body is the kv-grid in two |
| 56 | | -// columns; the close button sits at the top right, and the revoke button under the grid. |
| 57 | | -dialog.session-dialog { |
| 58 | | - width: min(640px, calc(100% - 32px)); |
| 59 | | - max-height: min(80vh, 640px); |
| 60 | | - margin: 10vh auto 0; |
| 61 | | - padding: 20px 24px; |
| 62 | | - overflow: auto; |
| 63 | | - color: var(--text); |
| 64 | | - background: var(--surface); |
| 65 | | - border: 1px solid var(--border); |
| 66 | | - border-radius: var(--radius-md); |
| 67 | | - box-shadow: var(--shadow); |
| 68 | | - |
| 69 | | - &::backdrop { |
| 70 | | - background: rgba(0, 0, 0, 0.45); |
| 71 | | - } |
| 72 | | - |
| 73 | | - .session-dialog-head { |
| 74 | | - display: flex; |
| 75 | | - align-items: center; |
| 76 | | - justify-content: space-between; |
| 77 | | - gap: 12px; |
| 78 | | - margin-bottom: 16px; |
| 79 | | - |
| 80 | | - h2 { |
| 81 | | - margin: 0; |
| 82 | | - min-width: 0; |
| 83 | | - font-size: 1.125rem; |
| 84 | | - overflow-wrap: anywhere; |
| 85 | | - } |
| 86 | | - |
| 87 | | - form { |
| 88 | | - margin: 0; |
| 89 | | - flex: none; |
| 90 | | - } |
| 91 | | - } |
| 92 | | - |
| 93 | | - .kv-grid { |
| 94 | | - grid-template-columns: repeat(2, minmax(0, 1fr)); |
| 95 | | - |
| 96 | | - @media (max-width: 520px) { |
| 97 | | - grid-template-columns: minmax(0, 1fr); |
| 98 | | - } |
| 99 | | - } |
| 100 | | - |
| 101 | | - > form { |
| 102 | | - margin-top: 16px; |
| 103 | | - } |
| 104 | | -} |
| 105 | | - |
| 106 | | -// Admin user detail. The header: a back link, the avatar, the name with a status dot and a role |
| 107 | | -// badge, one muted meta line, then one row of small facts. Under it the actions are hairline rows |
| 108 | | -// (title and one line of help on the left, the button on the right); the destructive ones sit in |
| 109 | | -// their own danger card at the bottom. |
| 110 | | -.user-head { |
| 111 | | - margin-bottom: 16px; |
| 112 | | -} |
| 113 | | - |
| 114 | | -.user-back { |
| 115 | | - display: inline-block; |
| 116 | | - margin-bottom: 12px; |
| 117 | | - color: var(--muted); |
| 118 | | - text-decoration: none; |
| 119 | | - |
| 120 | | - &:hover { |
| 121 | | - color: var(--text); |
| 122 | | - text-decoration: underline; |
| 123 | | - } |
| 124 | | -} |
| 125 | | - |
| 126 | | -.user-id { |
| 127 | | - display: flex; |
| 128 | | - align-items: center; |
| 129 | | - gap: 16px; |
| 130 | | - min-width: 0; |
| 131 | | -} |
| 132 | | - |
| 133 | | -.user-avatar { |
| 134 | | - flex: none; |
| 135 | | - width: 56px; |
| 136 | | - height: 56px; |
| 137 | | - border: 1px solid var(--border); |
| 138 | | -} |
| 139 | | - |
| 140 | | -.user-id-text { |
| 141 | | - min-width: 0; |
| 142 | | -} |
| 143 | | - |
| 144 | | -.user-name { |
| 145 | | - display: flex; |
| 146 | | - flex-wrap: wrap; |
| 147 | | - align-items: center; |
| 148 | | - gap: 4px 10px; |
| 149 | | - margin: 0; |
| 150 | | - overflow-wrap: anywhere; |
| 151 | | -} |
| 152 | | - |
| 153 | | -// The status dot: green when active, red when suspended. |
| 154 | | -.user-dot { |
| 155 | | - flex: none; |
| 156 | | - width: 8px; |
| 157 | | - height: 8px; |
| 158 | | - border-radius: 50%; |
| 159 | | - background: var(--muted); |
| 160 | | - |
| 161 | | - &.is-active { |
| 162 | | - background: var(--ok); |
| 163 | | - } |
| 164 | | - |
| 165 | | - &.is-suspended { |
| 166 | | - background: var(--danger); |
| 167 | | - } |
| 168 | | -} |
| 169 | | - |
| 170 | | -.user-off { |
| 171 | | - color: var(--danger); |
| 172 | | - font-size: 0.75rem; |
| 173 | | - font-weight: 500; |
| 174 | | -} |
| 175 | | - |
| 176 | | -.user-role { |
| 177 | | - margin-left: 0; |
| 178 | | - border-color: transparent; |
| 179 | | - background: var(--surface-2); |
| 180 | | - color: var(--text); |
| 181 | | -} |
| 182 | | - |
| 183 | | -.user-meta { |
| 184 | | - margin: 4px 0 0; |
| 185 | | - overflow-wrap: anywhere; |
| 186 | | -} |
| 187 | | - |
| 188 | | -// The facts: one row of small stat items between two hairlines. |
| 189 | | -.user-stats { |
| 190 | | - display: flex; |
| 191 | | - flex-wrap: wrap; |
| 192 | | - gap: 8px 28px; |
| 193 | | - margin: 16px 0 0; |
| 194 | | - padding: 12px 0; |
| 195 | | - border-top: 1px solid var(--border); |
| 196 | | - border-bottom: 1px solid var(--border); |
| 197 | | - |
| 198 | | - > div { |
| 199 | | - display: flex; |
| 200 | | - align-items: baseline; |
| 201 | | - gap: 8px; |
| 202 | | - min-width: 0; |
| 203 | | - } |
| 204 | | - |
| 205 | | - dt { |
| 206 | | - color: var(--muted); |
| 207 | | - font-size: 0.8125rem; |
| 208 | | - } |
| 209 | | - |
| 210 | | - dd { |
| 211 | | - margin: 0; |
| 212 | | - font-weight: 600; |
| 213 | | - font-variant-numeric: tabular-nums; |
| 214 | | - } |
| 215 | | -} |
| 216 | | - |
| 217 | | -.action-row { |
| 218 | | - display: grid; |
| 219 | | - grid-template-columns: minmax(0, 1fr) auto; |
| 220 | | - align-items: center; |
| 221 | | - gap: 8px 24px; |
| 222 | | - padding: 14px 0; |
| 223 | | - |
| 224 | | - h3 { |
| 225 | | - margin: 0; |
| 226 | | - font-size: 0.9375rem; |
| 227 | | - font-weight: 600; |
| 228 | | - } |
| 229 | | - |
| 230 | | - p { |
| 231 | | - margin: 2px 0 0; |
| 232 | | - } |
| 233 | | -} |
| 234 | | - |
| 235 | | -.action-text { |
| 236 | | - min-width: 0; |
| 237 | | -} |
| 238 | | - |
| 239 | | -.action-control { |
| 240 | | - display: flex; |
| 241 | | - align-items: center; |
| 242 | | - justify-content: flex-end; |
| 243 | | - min-width: 0; |
| 244 | | - |
| 245 | | - form { |
| 246 | | - margin: 0; |
| 247 | | - } |
| 248 | | - |
| 249 | | - // The passkey confirm opens under its button, right-aligned, as in the row menus. |
| 250 | | - > .confirm-inline { |
| 251 | | - position: relative; |
| 252 | | - } |
| 253 | | - |
| 254 | | - .confirm-pop { |
| 255 | | - position: absolute; |
| 256 | | - right: 0; |
| 257 | | - top: calc(100% + 6px); |
| 258 | | - z-index: 10; |
| 259 | | - width: min(300px, calc(100vw - 32px)); |
| 260 | | - // The general rule caps the pop at its summary's width; here it hangs out to the left. |
| 261 | | - max-width: none; |
| 262 | | - padding: 12px 14px; |
| 263 | | - border: 1px solid var(--border); |
| 264 | | - border-radius: var(--radius-lg); |
| 265 | | - background: var(--surface); |
| 266 | | - box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); |
| 267 | | - text-align: left; |
| 268 | | - |
| 269 | | - p { |
| 270 | | - margin: 0 0 10px; |
| 271 | | - } |
| 272 | | - |
| 273 | | - form { |
| 274 | | - display: flex; |
| 275 | | - flex-wrap: wrap; |
| 276 | | - gap: 8px; |
| 277 | | - } |
| 278 | | - } |
| 279 | | -} |
| 280 | | - |
| 281 | | -.action-note { |
| 282 | | - margin: 0; |
| 283 | | - text-align: right; |
| 284 | | -} |
| 285 | | - |
| 286 | | -// The suspend reason: a small caption over its input, then the button, bottom-aligned. |
| 287 | | -.action-form { |
| 288 | | - display: flex; |
| 289 | | - flex-wrap: wrap; |
| 290 | | - align-items: flex-end; |
| 291 | | - justify-content: flex-end; |
| 292 | | - gap: 8px; |
| 293 | | -} |
| 294 | | - |
| 295 | | -.action-field { |
| 296 | | - display: flex; |
| 297 | | - flex-direction: column; |
| 298 | | - gap: 2px; |
| 299 | | - min-width: 0; |
| 300 | | - |
| 301 | | - span { |
| 302 | | - color: var(--muted); |
| 303 | | - font-size: 0.8125rem; |
| 304 | | - } |
| 305 | | - |
| 306 | | - input[type="text"] { |
| 307 | | - width: 220px; |
| 308 | | - max-width: 100%; |
| 309 | | - } |
| 310 | | -} |
| 311 | | - |
| 312 | 55 | @media (max-width: 600px) { |
| 313 | | - .action-row { |
| 314 | | - grid-template-columns: minmax(0, 1fr); |
| 315 | | - } |
| 316 | | - |
| 317 | | - .action-control { |
| 318 | | - justify-content: flex-start; |
| 319 | | - } |
| 320 | | - |
| 321 | | - .action-note { |
| 322 | | - text-align: left; |
| 323 | | - } |
| 324 | | - |
| 325 | | - .action-form { |
| 326 | | - justify-content: flex-start; |
| 327 | | - } |
| 328 | 56 | |
| 329 | | - .action-field input[type="text"] { |
| 330 | | - width: 100%; |
| 331 | | - } |
| 332 | | - |
| 333 | | - .action-control .confirm-pop { |
| 334 | | - position: static; |
| 335 | | - width: 100%; |
| 336 | | - margin-top: 8px; |
| 337 | | - } |
| 338 | 57 | } |
| 339 | 58 | |
| 340 | 59 | .reset-link { |
| | @@ -349,14 +68,6 @@ dialog.session-dialog { |
| 349 | 68 | user-select: all; |
| 350 | 69 | } |
| 351 | 70 | |
| 352 | | -.health-summary { |
| 353 | | - display: flex; |
| 354 | | - align-items: center; |
| 355 | | - gap: 8px; |
| 356 | | - margin: 0 0 4px; |
| 357 | | - font-weight: 500; |
| 358 | | -} |
| 359 | | - |
| 360 | 71 | // A status dot: the summary's, and each service row's. |
| 361 | 72 | .health-dot { |
| 362 | 73 | display: inline-block; |
| | @@ -381,62 +92,9 @@ dialog.session-dialog { |
| 381 | 92 | } |
| 382 | 93 | } |
| 383 | 94 | |
| 384 | | -.health-usage-head { |
| 385 | | - display: flex; |
| 386 | | - flex-wrap: wrap; |
| 387 | | - justify-content: space-between; |
| 388 | | - align-items: baseline; |
| 389 | | - gap: 4px 16px; |
| 390 | | - margin-bottom: 8px; |
| 391 | | -} |
| 392 | | - |
| 393 | 95 | // The data directory's usage bar: 8px tall, the fill turns red at 90%. |
| 394 | 96 | .health-path { |
| 395 | 97 | margin-top: 4px; |
| 396 | 98 | overflow-wrap: anywhere; |
| 397 | 99 | } |
| 398 | 100 | |
| 399 | | -.health-meta { |
| 400 | | - margin: 0 0 16px; |
| 401 | | -} |
| 402 | | - |
| 403 | | -.link-row { |
| 404 | | - display: flex; |
| 405 | | - flex-wrap: wrap; |
| 406 | | - gap: 8px 20px; |
| 407 | | - margin: 16px 0 0; |
| 408 | | -} |
| 409 | | - |
| 410 | | -// Active admin alerts, above the health cards. |
| 411 | | -.admin-alerts { |
| 412 | | - background: var(--danger-bg); |
| 413 | | - border: 1px solid var(--danger); |
| 414 | | - border-radius: var(--radius-lg); |
| 415 | | - padding: 12px 16px; |
| 416 | | - margin-bottom: 16px; |
| 417 | | - |
| 418 | | - h2 { |
| 419 | | - margin: 0 0 8px; |
| 420 | | - font-size: 0.9375rem; |
| 421 | | - color: var(--danger); |
| 422 | | - } |
| 423 | | - |
| 424 | | - ul { |
| 425 | | - list-style: none; |
| 426 | | - margin: 0 0 8px; |
| 427 | | - padding: 0; |
| 428 | | - } |
| 429 | | - |
| 430 | | - li { |
| 431 | | - padding: 6px 0; |
| 432 | | - overflow-wrap: anywhere; |
| 433 | | - |
| 434 | | - & + li { |
| 435 | | - border-top: 1px solid var(--border); |
| 436 | | - } |
| 437 | | - |
| 438 | | - .muted { |
| 439 | | - margin-left: 8px; |
| 440 | | - } |
| 441 | | - } |
| 442 | | -} |
| | @@ -8,78 +8,9 @@ |
| 8 | 8 | background: var(--warn); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | | -.admin-rows { |
| 12 | | - margin: 0; |
| 13 | | - padding: 0; |
| 14 | | - list-style: none; |
| 15 | | -} |
| 16 | | - |
| 17 | | -.admin-row { |
| 18 | | - display: grid; |
| 19 | | - grid-template-columns: minmax(0, 1fr) auto; |
| 20 | | - align-items: center; |
| 21 | | - column-gap: 28px; |
| 22 | | - padding: 12px 0; |
| 23 | | - |
| 24 | | - & + .admin-row { |
| 25 | | - border-top: 1px solid var(--border); |
| 26 | | - } |
| 27 | | -} |
| 28 | | - |
| 29 | | -.admin-row-main { |
| 30 | | - min-width: 0; |
| 31 | | -} |
| 32 | | - |
| 33 | | -.admin-row-name { |
| 34 | | - min-width: 0; |
| 35 | | - overflow: hidden; |
| 36 | | - color: var(--text); |
| 37 | | - font-size: 0.9375rem; |
| 38 | | - font-weight: 600; |
| 39 | | - text-overflow: ellipsis; |
| 40 | | - white-space: nowrap; |
| 41 | | -} |
| 42 | | - |
| 43 | | -// The status word on the right: muted, with the warning or danger colour when the copy is lagging or failing. |
| 44 | | -.admin-row-state { |
| 45 | | - color: var(--muted); |
| 46 | | - font-size: 0.8125rem; |
| 47 | | - white-space: nowrap; |
| 48 | | - |
| 49 | | - &.warn { |
| 50 | | - color: var(--warn); |
| 51 | | - } |
| 52 | | - |
| 53 | | - &.bad { |
| 54 | | - color: var(--bad); |
| 55 | | - } |
| 56 | | -} |
| 57 | | - |
| 58 | | -// The last error, under the meta line. It lines up under the name, like the meta. |
| 59 | | -.admin-row-error { |
| 60 | | - margin: 4px 0 0 16px; |
| 61 | | - color: var(--bad); |
| 62 | | - font-size: 0.75rem; |
| 63 | | - overflow-wrap: anywhere; |
| 64 | | -} |
| 65 | | - |
| 66 | | -// A status fact: the dot, then its word, on one line. |
| 67 | | -.admin-status { |
| 68 | | - display: inline-flex; |
| 69 | | - align-items: center; |
| 70 | | - gap: 6px; |
| 71 | | -} |
| 72 | | - |
| 73 | 11 | // Phone: the status word goes under the name, indented to line up with it. |
| 74 | 12 | @media (max-width: 600px) { |
| 75 | | - .admin-row { |
| 76 | | - grid-template-columns: minmax(0, 1fr); |
| 77 | | - row-gap: 6px; |
| 78 | | - } |
| 79 | 13 | |
| 80 | | - .admin-row-state { |
| 81 | | - padding-left: 16px; |
| 82 | | - } |
| 83 | 14 | } |
| 84 | 15 | |
| 85 | 16 | // A small-range number on the server settings page steps like the runner's Max: the pill keeps its |
| | @@ -71,22 +71,6 @@ |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | | -// Actions menu: a 28px "…" beside the star, holding the badge, watch, fork and their counts. |
| 75 | | -.header-actions .head-more > summary { |
| 76 | | - display: inline-flex; |
| 77 | | - align-items: center; |
| 78 | | - justify-content: center; |
| 79 | | - width: 28px; |
| 80 | | - height: 28px; |
| 81 | | - padding: 0; |
| 82 | | - font-size: 16px; |
| 83 | | - line-height: 1; |
| 84 | | - color: var(--text); |
| 85 | | - background: var(--surface); |
| 86 | | - border: 1px solid var(--border-strong); |
| 87 | | - border-radius: var(--radius-md); |
| 88 | | -} |
| 89 | | - |
| 90 | 74 | .head-more-list { |
| 91 | 75 | right: 0; |
| 92 | 76 | display: flex; |
| | @@ -5,8 +5,6 @@ |
| 5 | 5 | // is the colour fade on the name. The hover colour of a tree name is restored at the end. |
| 6 | 6 | |
| 7 | 7 | // The base state, for every row in these lists: the name is --text-2. |
| 8 | | -.tree-table tbody tr .tree-label > a, |
| 9 | | -.tree-table tbody tr .tree-label > span, |
| 10 | 8 | [data-kb-row] .commit-summary, |
| 11 | 9 | .repo-item .repo-name, |
| 12 | 10 | .pin-card .repo-name { |
| | @@ -14,8 +12,6 @@ |
| 14 | 12 | } |
| 15 | 13 | |
| 16 | 14 | @media (prefers-reduced-motion: no-preference) { |
| 17 | | - .tree-table tbody tr .tree-label > a, |
| 18 | | - .tree-table tbody tr .tree-label > span, |
| 19 | 15 | [data-kb-row] .commit-summary, |
| 20 | 16 | .repo-item .repo-name, |
| 21 | 17 | .pin-card .repo-name { |
| | @@ -24,8 +20,6 @@ |
| 24 | 20 | } |
| 25 | 21 | |
| 26 | 22 | // Level 1: slightly brighter than the base. |
| 27 | | -.tree-table tbody tr[data-heat="1"] .tree-label > a, |
| 28 | | -.tree-table tbody tr[data-heat="1"] .tree-label > span, |
| 29 | 23 | [data-kb-row][data-heat="1"] .commit-summary, |
| 30 | 24 | .repo-item[data-heat="1"] .repo-name, |
| 31 | 25 | .pin-card[data-heat="1"] .repo-name { |
| | @@ -33,8 +27,6 @@ |
| 33 | 27 | } |
| 34 | 28 | |
| 35 | 29 | // Level 2: brighter. |
| 36 | | -.tree-table tbody tr[data-heat="2"] .tree-label > a, |
| 37 | | -.tree-table tbody tr[data-heat="2"] .tree-label > span, |
| 38 | 30 | [data-kb-row][data-heat="2"] .commit-summary, |
| 39 | 31 | .repo-item[data-heat="2"] .repo-name, |
| 40 | 32 | .pin-card[data-heat="2"] .repo-name { |
| | @@ -42,8 +34,6 @@ |
| 42 | 34 | } |
| 43 | 35 | |
| 44 | 36 | // Level 3: the newest rows. The name is --text and bold, and the time is --text. |
| 45 | | -.tree-table tbody tr[data-heat="3"] .tree-label > a, |
| 46 | | -.tree-table tbody tr[data-heat="3"] .tree-label > span, |
| 47 | 37 | [data-kb-row][data-heat="3"] .commit-summary, |
| 48 | 38 | .repo-item[data-heat="3"] .repo-name, |
| 49 | 39 | .pin-card[data-heat="3"] .repo-name { |
| | @@ -55,7 +45,3 @@ |
| 55 | 45 | color: var(--text); |
| 56 | 46 | } |
| 57 | 47 | |
| 58 | | -// The tree name's hover colour is unchanged: it stays --text on every row. |
| 59 | | -.tree-table tbody tr .tree-label > a:hover { |
| 60 | | - color: var(--text); |
| 61 | | -} |
| | @@ -1,63 +1,4 @@ |
| 1 | | -// alive_lists: see memory design/ALIVE.md. |
| 2 | 1 | |
| 3 | | -// Issues and pulls toolbar: Labels and Milestones sit in one "…" menu beside New issue. The |
| 4 | | -// summary is drawn like a .button so the row keeps one height. |
| 5 | | -.list-more { |
| 6 | | - position: relative; |
| 7 | | - |
| 8 | | - > summary { |
| 9 | | - display: inline-flex; |
| 10 | | - align-items: center; |
| 11 | | - justify-content: center; |
| 12 | | - height: var(--control-h); |
| 13 | | - min-width: var(--control-h); |
| 14 | | - padding: 0 10px; |
| 15 | | - box-sizing: border-box; |
| 16 | | - border: 1px solid var(--border-strong); |
| 17 | | - border-radius: var(--radius-md); |
| 18 | | - background: var(--surface); |
| 19 | | - color: var(--text); |
| 20 | | - font-size: 1rem; |
| 21 | | - line-height: 1; |
| 22 | | - cursor: pointer; |
| 23 | | - list-style: none; |
| 24 | | - user-select: none; |
| 25 | | - |
| 26 | | - &::-webkit-details-marker { |
| 27 | | - display: none; |
| 28 | | - } |
| 29 | | - } |
| 30 | | - |
| 31 | | - &[open] > summary { |
| 32 | | - background: var(--surface-2); |
| 33 | | - } |
| 34 | | - |
| 35 | | - > .list-more-menu { |
| 36 | | - position: absolute; |
| 37 | | - top: calc(100% + 4px); |
| 38 | | - right: 0; |
| 39 | | - z-index: 20; |
| 40 | | - display: flex; |
| 41 | | - flex-direction: column; |
| 42 | | - min-width: 160px; |
| 43 | | - padding: 4px; |
| 44 | | - border: 1px solid var(--border); |
| 45 | | - border-radius: var(--radius-md); |
| 46 | | - background: var(--surface); |
| 47 | | - |
| 48 | | - > a { |
| 49 | | - padding: 7px 10px; |
| 50 | | - border-radius: var(--radius-sm); |
| 51 | | - color: var(--text); |
| 52 | | - text-decoration: none; |
| 53 | | - white-space: nowrap; |
| 54 | | - |
| 55 | | - &:hover { |
| 56 | | - background: var(--surface-2); |
| 57 | | - } |
| 58 | | - } |
| 59 | | - } |
| 60 | | -} |
| 61 | 2 | |
| 62 | 3 | // Commit page: one line under the title holds the hash, signature, author, time, parents, checks |
| 63 | 4 | // and the Browse files link. It wraps on a narrow window and never becomes a card. |
| | @@ -82,7 +23,4 @@ |
| 82 | 23 | flex: 0 0 auto; |
| 83 | 24 | } |
| 84 | 25 | |
| 85 | | - > .commit-browse { |
| 86 | | - margin-left: auto; |
| 87 | | - } |
| 88 | 26 | } |
| | @@ -1,31 +1,9 @@ |
| 1 | | -// alive_settings: see memory design/ALIVE.md. |
| 2 | | - |
| 3 | | -// The repo General page shows one section at a time. A section is plain content on the page background, |
| 4 | | -// one left aligned column at 720px, under a mono label. Nothing in it is a card. |
| 5 | | -.settings-main > .settings-section { |
| 6 | | - display: flex; |
| 7 | | - flex-direction: column; |
| 8 | | - gap: 16px; |
| 9 | | - box-sizing: border-box; |
| 10 | | - max-width: 720px; |
| 11 | | - min-width: 0; |
| 12 | | - |
| 13 | | - > h2 { |
| 14 | | - @extend %mono-label; |
| 15 | | - margin: 0; |
| 16 | | - } |
| 17 | | -} |
| 1 | + |
| 18 | 2 | |
| 19 | 3 | // Branch protection: the rules are a list pane, the rule being edited fills the pane beside it. The |
| 20 | 4 | // rows stay one `details` group, so the panes are drawn by the list and the open row's form is laid |
| 21 | 5 | // over the right one: opening a row needs no script and closes the row that was open. |
| 22 | 6 | @media (min-width: 900px) { |
| 23 | | - .settings-main > .settings-rules { |
| 24 | | - flex: 1 1 auto; |
| 25 | | - gap: 8px; |
| 26 | | - max-width: none; |
| 27 | | - min-height: 0; |
| 28 | | - } |
| 29 | 7 | |
| 30 | 8 | .rule-list { |
| 31 | 9 | position: relative; |
| | @@ -161,9 +139,6 @@ |
| 161 | 139 | } |
| 162 | 140 | } |
| 163 | 141 | |
| 164 | | - > .form-actions { |
| 165 | | - order: 3; |
| 166 | | - } |
| 167 | 142 | } |
| 168 | 143 | |
| 169 | 144 | .rule-section { |
| | @@ -180,25 +155,11 @@ |
| 180 | 155 | } |
| 181 | 156 | } |
| 182 | 157 | |
| 183 | | - .rule-form .switch-list { |
| 184 | | - padding: 0; |
| 185 | | - border: 0; |
| 186 | | - border-top: 1px solid var(--border); |
| 187 | | - border-radius: 0; |
| 188 | | - } |
| 189 | | - |
| 190 | 158 | .rule-form .switch-row:first-child { |
| 191 | 159 | border-top: 0; |
| 192 | 160 | } |
| 193 | 161 | } |
| 194 | 162 | |
| 195 | | -// The danger zone's intro: the same 14px text-2 as the other section intros. |
| 196 | | -.settings-intro { |
| 197 | | - margin: 0; |
| 198 | | - font-size: 14px; |
| 199 | | - color: var(--text-2); |
| 200 | | -} |
| 201 | | - |
| 202 | 163 | // Branch protection rows: the open row differs from a closed one only in its background. Both keep |
| 203 | 164 | // the Edit text and a right chevron, so nothing swaps when a row opens. |
| 204 | 165 | .rule-row > summary .rule-chevron, |
| | @@ -223,17 +184,6 @@ |
| 223 | 184 | |
| 224 | 185 | // The sound row spans the left column, so its label stays on one line beside the switch. |
| 225 | 186 | @media (min-width: 1100px) { |
| 226 | | - .appearance-page { |
| 227 | | - align-items: stretch; |
| 228 | | - } |
| 229 | | - |
| 230 | | - .appearance-top > .sound-toggle { |
| 231 | | - grid-column: 1 / -1; |
| 232 | | - } |
| 233 | | -} |
| 234 | 187 | |
| 235 | | -.sound-toggle .sound-row > span:first-child { |
| 236 | | - min-width: 0; |
| 237 | | - white-space: nowrap; |
| 238 | 188 | } |
| 239 | 189 | |
| | @@ -3,100 +3,9 @@ |
| 3 | 3 | // so the page fits one screen. The form is `display: contents` so its two blocks join this grid. |
| 4 | 4 | // The sound card sits outside the form: its Play buttons must not be inside it. |
| 5 | 5 | @media (min-width: 1100px) { |
| 6 | | - .appearance-page { |
| 7 | | - display: grid; |
| 8 | | - grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); |
| 9 | | - align-items: start; |
| 10 | | - gap: 16px 24px; |
| 11 | 6 | |
| 12 | | - .appearance-top { |
| 13 | | - grid-column: 1; |
| 14 | | - grid-row: 1; |
| 15 | | - grid-template-columns: repeat(2, minmax(0, 1fr)); |
| 16 | | - } |
| 17 | | - |
| 18 | | - .sound-card { |
| 19 | | - grid-column: 1; |
| 20 | | - grid-row: 2; |
| 21 | | - } |
| 22 | | - |
| 23 | | - .colour-group { |
| 24 | | - grid-column: 2; |
| 25 | | - grid-row: 1 / span 2; |
| 26 | | - } |
| 27 | | - } |
| 28 | | -} |
| 29 | | - |
| 30 | | -// Settings: the sound card. The density radios use the sidebar side's segmented pill. |
| 31 | | -// A sound-row's name and its quiet note sit on one line, with a gap rather than a typed space. |
| 32 | | -.sound-name { |
| 33 | | - display: flex; |
| 34 | | - flex-wrap: wrap; |
| 35 | | - gap: 6px; |
| 36 | | -} |
| 37 | | - |
| 38 | | -.sound-toggle .sound-row { |
| 39 | | - height: var(--control-h); |
| 40 | | - min-height: 0; |
| 41 | | -} |
| 42 | | - |
| 43 | | -.sound-row { |
| 44 | | - display: flex; |
| 45 | | - align-items: center; |
| 46 | | - justify-content: space-between; |
| 47 | | - gap: 16px; |
| 48 | | - min-height: 36px; |
| 49 | | -} |
| 50 | | - |
| 51 | | -// The switch is a checkbox, visually hidden, with its track and knob drawn beside it. |
| 52 | | -.sound-switch { |
| 53 | | - position: relative; |
| 54 | | - flex: none; |
| 55 | | - display: block; |
| 56 | | - width: 36px; |
| 57 | | - height: 20px; |
| 58 | | - |
| 59 | | - input[type="checkbox"] { |
| 60 | | - position: absolute; |
| 61 | | - width: 1px; |
| 62 | | - height: 1px; |
| 63 | | - margin: 0; |
| 64 | | - opacity: 0; |
| 65 | | - } |
| 66 | | -} |
| 67 | | - |
| 68 | | -.sound-track { |
| 69 | | - position: absolute; |
| 70 | | - inset: 0; |
| 71 | | - border-radius: 10px; |
| 72 | | - background: var(--border); |
| 73 | | - cursor: pointer; |
| 74 | | -} |
| 75 | | - |
| 76 | | -.sound-switch input:checked + .sound-track { |
| 77 | | - background: var(--accent); |
| 78 | | -} |
| 79 | | - |
| 80 | | -.sound-knob { |
| 81 | | - position: absolute; |
| 82 | | - top: 2px; |
| 83 | | - left: 2px; |
| 84 | | - width: 16px; |
| 85 | | - height: 16px; |
| 86 | | - border-radius: 50%; |
| 87 | | - background: var(--surface); |
| 88 | | -} |
| 89 | | - |
| 90 | | -.sound-switch input:checked + .sound-track > .sound-knob { |
| 91 | | - transform: translateX(16px); |
| 92 | | -} |
| 93 | | - |
| 94 | | -.sound-switch input:focus-visible + .sound-track { |
| 95 | | - outline: 2px solid var(--accent); |
| 96 | | - outline-offset: 2px; |
| 97 | 7 | } |
| 98 | 8 | |
| 99 | 9 | @media (prefers-reduced-motion: reduce) { |
| 100 | | - .sound-knob { |
| 101 | | - } |
| 10 | + |
| 102 | 11 | } |
| | @@ -106,14 +106,6 @@ textarea.md-drop { |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | | -.reviewer-list li { |
| 110 | | - display: flex; |
| 111 | | - align-items: center; |
| 112 | | - justify-content: space-between; |
| 113 | | - gap: 0.5rem; |
| 114 | | - padding: 0.1rem 0; |
| 115 | | -} |
| 116 | | - |
| 117 | 109 | .review-request-list li { |
| 118 | 110 | display: flex; |
| 119 | 111 | flex-wrap: wrap; |
| | @@ -17,51 +17,6 @@ |
| 17 | 17 | overflow: hidden; |
| 18 | 18 | background: var(--surface); |
| 19 | 19 | |
| 20 | | - .seg-item { |
| 21 | | - border: 0; |
| 22 | | - border-radius: 0; |
| 23 | | - border-right: 1px solid var(--border-strong); |
| 24 | | - |
| 25 | | - &:last-child { |
| 26 | | - border-right: 0; |
| 27 | | - } |
| 28 | | - } |
| 29 | | -} |
| 30 | | - |
| 31 | | -.seg-item { |
| 32 | | - display: inline-flex; |
| 33 | | - align-items: center; |
| 34 | | - height: calc(var(--control-h) - 4px); |
| 35 | | - padding: 0 12px; |
| 36 | | - font-size: 0.8125rem; |
| 37 | | - font-weight: 500; |
| 38 | | - color: var(--text-2); |
| 39 | | - text-decoration: none; |
| 40 | | - background: var(--surface); |
| 41 | | - |
| 42 | | - &:hover { |
| 43 | | - text-decoration: none; |
| 44 | | - background: var(--surface-2); |
| 45 | | - color: var(--text); |
| 46 | | - } |
| 47 | | - |
| 48 | | - &[aria-pressed="true"] { |
| 49 | | - background: var(--accent-soft); |
| 50 | | - color: var(--text); |
| 51 | | - } |
| 52 | | - |
| 53 | | - &.toggle { |
| 54 | | - border: 1px solid var(--border-strong); |
| 55 | | - border-radius: var(--radius-md); |
| 56 | | - } |
| 57 | | -} |
| 58 | | - |
| 59 | | -.diff-downloads { |
| 60 | | - display: inline-flex; |
| 61 | | - gap: 12px; |
| 62 | | - margin-left: auto; |
| 63 | | - font-family: var(--mono); |
| 64 | | - font-size: 0.8125rem; |
| 65 | 20 | } |
| 66 | 21 | |
| 67 | 22 | // Split view: two sides per row, code wraps instead of scrolling sideways. |
| | @@ -376,60 +331,12 @@ dialog.finder { |
| 376 | 331 | } |
| 377 | 332 | } |
| 378 | 333 | |
| 379 | | -.new-branch-form { |
| 380 | | - display: flex; |
| 381 | | - flex-wrap: wrap; |
| 382 | | - align-items: flex-end; |
| 383 | | - gap: 10px 12px; |
| 384 | | - margin-top: 10px; |
| 385 | | - padding: 12px; |
| 386 | | - background: var(--surface); |
| 387 | | - border: 1px solid var(--border); |
| 388 | | - border-radius: var(--radius-lg); |
| 389 | | - |
| 390 | | - label { |
| 391 | | - display: flex; |
| 392 | | - flex-direction: column; |
| 393 | | - gap: 4px; |
| 394 | | - font-size: 0.8125rem; |
| 395 | | - color: var(--text-2); |
| 396 | | - } |
| 397 | | - |
| 398 | | - input[type="text"] { |
| 399 | | - min-width: 14rem; |
| 400 | | - } |
| 401 | | -} |
| 402 | | - |
| 403 | 334 | .button.small { |
| 404 | 335 | height: 28px; |
| 405 | 336 | padding: 0 10px; |
| 406 | 337 | font-size: 0.8125rem; |
| 407 | 338 | } |
| 408 | 339 | |
| 409 | | -.branch-table { |
| 410 | | - .branch-author { |
| 411 | | - white-space: nowrap; |
| 412 | | - |
| 413 | | - > span + span { |
| 414 | | - margin-left: 8px; |
| 415 | | - } |
| 416 | | - } |
| 417 | | - |
| 418 | | - .branch-counts { |
| 419 | | - white-space: nowrap; |
| 420 | | - } |
| 421 | | - |
| 422 | | - .branch-actions { |
| 423 | | - white-space: nowrap; |
| 424 | | - text-align: right; |
| 425 | | - |
| 426 | | - > * { |
| 427 | | - margin-left: 6px; |
| 428 | | - vertical-align: middle; |
| 429 | | - } |
| 430 | | - } |
| 431 | | -} |
| 432 | | - |
| 433 | 340 | .confirm-inline { |
| 434 | 341 | display: inline-block; |
| 435 | 342 | max-width: 100%; |
| | @@ -444,35 +351,8 @@ dialog.finder { |
| 444 | 351 | } |
| 445 | 352 | } |
| 446 | 353 | |
| 447 | | - .confirm-pop { |
| 448 | | - // In the flow under the summary: it pushes the rows below it down instead of covering them. |
| 449 | | - display: block; |
| 450 | | - width: 22rem; |
| 451 | | - max-width: 100%; |
| 452 | | - margin-top: 8px; |
| 453 | | - padding: 12px; |
| 454 | | - text-align: left; |
| 455 | | - white-space: normal; |
| 456 | | - background: var(--surface); |
| 457 | | - border: 1px solid var(--border-strong); |
| 458 | | - border-radius: var(--radius-lg); |
| 459 | | - box-shadow: var(--shadow); |
| 460 | | - |
| 461 | | - p { |
| 462 | | - margin: 0 0 10px; |
| 463 | | - font-size: 0.875rem; |
| 464 | | - } |
| 465 | | - |
| 466 | | - form { |
| 467 | | - display: flex; |
| 468 | | - gap: 8px; |
| 469 | | - flex-wrap: wrap; |
| 470 | | - } |
| 471 | | - } |
| 472 | 354 | } |
| 473 | 355 | |
| 474 | 356 | @media (max-width: 720px) { |
| 475 | | - .branch-table .branch-actions { |
| 476 | | - text-align: left; |
| 477 | | - } |
| 357 | + |
| 478 | 358 | } |
| | @@ -39,11 +39,6 @@ |
| 39 | 39 | padding-bottom: 20px; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | | - .settings-layout.fit-pane { |
| 43 | | - grid-template-rows: minmax(0, 1fr); |
| 44 | | - overflow: hidden; |
| 45 | | - } |
| 46 | | - |
| 47 | 42 | // The accent wash shows through on signed-in pages: the shell itself paints nothing. |
| 48 | 43 | .shell, |
| 49 | 44 | .shell-body { |
| | @@ -74,8 +69,7 @@ |
| 74 | 69 | } |
| 75 | 70 | |
| 76 | 71 | // The tab row: 36px, one hairline, the active tab a 2px accent rule on it. |
| 77 | | - .repo-tabs, |
| 78 | | - .page-head { |
| 72 | + .repo-tabs { |
| 79 | 73 | min-height: 36px; |
| 80 | 74 | } |
| 81 | 75 | |
| | @@ -4,92 +4,7 @@ |
| 4 | 4 | // Page heads: one 40px row, the right action centred in it at 32px, so at least 4px of the |
| 5 | 5 | // row sits under the button before the rule. |
| 6 | 6 | @media (min-width: 900px) { |
| 7 | | - .page-head { |
| 8 | | - min-height: 40px; |
| 9 | | - box-sizing: border-box; |
| 10 | | - align-items: center; |
| 11 | | - } |
| 12 | | -} |
| 13 | | - |
| 14 | | -.page-head .inline-form { |
| 15 | | - margin: 0; |
| 16 | | -} |
| 17 | | - |
| 18 | | -.page-head .button, |
| 19 | | -.page-head button { |
| 20 | | - height: 32px; |
| 21 | | - box-sizing: border-box; |
| 22 | | - display: inline-flex; |
| 23 | | - align-items: center; |
| 24 | | - margin: 0; |
| 25 | | - padding-top: 0; |
| 26 | | - padding-bottom: 0; |
| 27 | | -} |
| 28 | 7 | |
| 29 | | -// Explore: the search and its button sit on one 32px line in the 44px toolbar, sort after them. |
| 30 | | -.explore > .explore-toolbar > .explore-search { |
| 31 | | - flex: 0 1 20rem; |
| 32 | | - display: flex; |
| 33 | | - flex-wrap: nowrap; |
| 34 | | - align-items: center; |
| 35 | | - gap: 8px; |
| 36 | | - width: auto; |
| 37 | | - height: 32px; |
| 38 | | - min-width: 0; |
| 39 | | - margin: 0; |
| 40 | | - |
| 41 | | - input[type="search"] { |
| 42 | | - flex: 1 1 0; |
| 43 | | - width: auto; |
| 44 | | - min-width: 0; |
| 45 | | - height: 32px; |
| 46 | | - box-sizing: border-box; |
| 47 | | - margin: 0; |
| 48 | | - padding-top: 0; |
| 49 | | - padding-bottom: 0; |
| 50 | | - } |
| 51 | | - |
| 52 | | - button { |
| 53 | | - flex: none; |
| 54 | | - height: 32px; |
| 55 | | - box-sizing: border-box; |
| 56 | | - margin: 0; |
| 57 | | - padding-top: 0; |
| 58 | | - padding-bottom: 0; |
| 59 | | - } |
| 60 | | - |
| 61 | | - @media (max-width: 479px) { |
| 62 | | - input[type="search"] { |
| 63 | | - flex: 1 1 0; |
| 64 | | - } |
| 65 | | - } |
| 66 | | -} |
| 67 | | - |
| 68 | | -.explore > .explore-toolbar .explore-sort { |
| 69 | | - margin: 0; |
| 70 | | -} |
| 71 | | - |
| 72 | | -// Sessions: names are plain text; only the "This session" badge takes the accent. The pane |
| 73 | | -// scrolls inside itself, so the last Revoke is reachable. |
| 74 | | -.card.fit-pane.session-pane { |
| 75 | | - overflow-y: auto; |
| 76 | | - overflow-x: hidden; |
| 77 | | - overscroll-behavior: contain; |
| 78 | | - min-height: 0; |
| 79 | | - |
| 80 | | - .item-main > a, |
| 81 | | - .item-main > a strong { |
| 82 | | - color: var(--text); |
| 83 | | - } |
| 84 | | - |
| 85 | | - > .item-list { |
| 86 | | - padding-bottom: 8px; |
| 87 | | - } |
| 88 | | -} |
| 89 | | - |
| 90 | | -// Snippet head: the visibility control and Save are both 32px. |
| 91 | | -.snippet-head .snippet-segmented.segmented { |
| 92 | | - height: 32px; |
| 93 | 8 | } |
| 94 | 9 | |
| 95 | 10 | // Heatmap: the last column's month label ends at the grid's edge and runs back over the |
| | @@ -98,38 +13,11 @@ |
| 98 | 13 | justify-self: end; |
| 99 | 14 | } |
| 100 | 15 | |
| 101 | | -// Audit log: WHEN 140px, ACTOR 160px (only on the admin table, which has six columns), ACTION |
| 102 | | -// and TARGET and DETAILS take the rest, 14px cell padding. |
| 103 | | -.table.audit-table { |
| 104 | | - th, |
| 105 | | - td { |
| 106 | | - padding: 6px 14px; |
| 107 | | - } |
| 108 | | - |
| 109 | | - th:first-child, |
| 110 | | - td:first-child { |
| 111 | | - width: 140px; |
| 112 | | - } |
| 113 | | -} |
| 114 | | - |
| 115 | | -.table.audit-table:has(> thead > tr > th:nth-child(6)) { |
| 116 | | - th:nth-child(2), |
| 117 | | - td:nth-child(2) { |
| 118 | | - width: 160px; |
| 119 | | - } |
| 120 | | -} |
| 121 | | - |
| 122 | | -// Security danger zone: the repo names line up with the body text beside the icon. |
| 123 | | -.card.security-danger .row-line > .security-repos { |
| 124 | | - padding-left: 36px; |
| 125 | | -} |
| 126 | | - |
| 127 | 16 | // Explore: one pane with the shared 14px inset, nothing more. |
| 128 | 17 | .explore { |
| 129 | 18 | padding: 0; |
| 130 | 19 | } |
| 131 | 20 | |
| 132 | | -.explore > .explore-toolbar, |
| 133 | 21 | .explore > ul, |
| 134 | 22 | .explore > .repo-list { |
| 135 | 23 | margin: 0; |
| | @@ -1,235 +1,4 @@ |
| 1 | | -// canvas_commits: the commits list, matched to project/Commits.dc.html in the One Lit Thing |
| 2 | | -// artifact (see memory design/ALIVE.md). A head line, then one pane of day groups. Each row is one |
| 3 | | -// 36px line; a row with more than one clause or a body is a <details> whose message opens below it. |
| 4 | | -// Everything is scoped to .commits-fit so no other page changes. |
| 5 | 1 | |
| 6 | | -.commits-fit { |
| 7 | | - // Head line: "Commits on", the branch tag and, when a path filter is set, its note. 36px high. |
| 8 | | - > .commits-head { |
| 9 | | - display: flex; |
| 10 | | - align-items: center; |
| 11 | | - flex-wrap: wrap; |
| 12 | | - gap: 10px; |
| 13 | | - min-height: 36px; |
| 14 | | - box-sizing: border-box; |
| 15 | | - } |
| 16 | | - |
| 17 | | - .commits-head .label, |
| 18 | | - .commits-g .label { |
| 19 | | - font-family: var(--mono); |
| 20 | | - font-size: 11px; |
| 21 | | - font-weight: 500; |
| 22 | | - letter-spacing: 0.12em; |
| 23 | | - text-transform: uppercase; |
| 24 | | - color: var(--muted); |
| 25 | | - } |
| 26 | | - |
| 27 | | - .commits-head .tag { |
| 28 | | - font-family: var(--mono); |
| 29 | | - font-size: 11px; |
| 30 | | - padding: 1px 7px; |
| 31 | | - border-radius: 5px; |
| 32 | | - background: var(--surface-2); |
| 33 | | - color: var(--text-2); |
| 34 | | - } |
| 35 | | - |
| 36 | | - .commits-filter { |
| 37 | | - display: inline-flex; |
| 38 | | - flex-wrap: wrap; |
| 39 | | - gap: 6px; |
| 40 | | - } |
| 41 | | - |
| 42 | | - // The one pane. It fills what is left under the head line and scrolls inside itself; the pager |
| 43 | | - // sits below it. |
| 44 | | - > .commits-pane { |
| 45 | | - display: flex; |
| 46 | | - flex-direction: column; |
| 47 | | - flex: 1 1 auto; |
| 48 | | - min-height: 0; |
| 49 | | - margin-top: 12px; |
| 50 | | - box-sizing: border-box; |
| 51 | | - overflow-y: auto; |
| 52 | | - overscroll-behavior: contain; |
| 53 | | - background: var(--surface); |
| 54 | | - border: 1px solid var(--border); |
| 55 | | - border-radius: 10px; |
| 56 | | - } |
| 57 | | - |
| 58 | | - // Day group header: 28px, a hairline under it. |
| 59 | | - .commits-g { |
| 60 | | - flex: none; |
| 61 | | - display: flex; |
| 62 | | - align-items: center; |
| 63 | | - height: 28px; |
| 64 | | - box-sizing: border-box; |
| 65 | | - padding: 0 14px; |
| 66 | | - box-shadow: inset 0 -1px var(--border); |
| 67 | | - } |
| 68 | | - |
| 69 | | - .commits-list { |
| 70 | | - list-style: none; |
| 71 | | - margin: 0; |
| 72 | | - padding: 0; |
| 73 | | - } |
| 74 | | - |
| 75 | | - // One row per commit, with its hairline. A disclosure's body sits inside the same item, so the |
| 76 | | - // hairline falls under the message too. |
| 77 | | - .commits-item { |
| 78 | | - box-shadow: inset 0 -1px var(--border); |
| 79 | | - } |
| 80 | | - |
| 81 | | - .commits-d { |
| 82 | | - margin: 0; |
| 83 | | - |
| 84 | | - > summary { |
| 85 | | - list-style: none; |
| 86 | | - cursor: pointer; |
| 87 | | - |
| 88 | | - &::-webkit-details-marker { |
| 89 | | - display: none; |
| 90 | | - } |
| 91 | | - } |
| 92 | | - } |
| 93 | | - |
| 94 | | - // The row line: 36px, one line, 14px side padding. The subject, the author and the sha are |
| 95 | | - // clipped in place; nothing wraps. |
| 96 | | - .commits-r { |
| 97 | | - display: flex; |
| 98 | | - align-items: center; |
| 99 | | - gap: 12px; |
| 100 | | - height: 36px; |
| 101 | | - box-sizing: border-box; |
| 102 | | - padding: 0 14px; |
| 103 | | - min-width: 0; |
| 104 | | - white-space: nowrap; |
| 105 | | - } |
| 106 | | - |
| 107 | | - .commits-slot { |
| 108 | | - flex: none; |
| 109 | | - width: 14px; |
| 110 | | - display: flex; |
| 111 | | - align-items: center; |
| 112 | | - justify-content: center; |
| 113 | | - color: var(--muted); |
| 114 | | - |
| 115 | | - svg { |
| 116 | | - display: block; |
| 117 | | - width: 14px; |
| 118 | | - height: 14px; |
| 119 | | - } |
| 120 | | - } |
| 121 | | - |
| 122 | | - .commits-d[open] .commits-chev svg { |
| 123 | | - transform: rotate(180deg); |
| 124 | | - } |
| 125 | | - |
| 126 | | - // CI dot: none, ok, bad, or live while a status is pending. Live follows the accent. |
| 127 | | - .commits-dot { |
| 128 | | - flex: none; |
| 129 | | - width: 8px; |
| 130 | | - height: 8px; |
| 131 | | - border-radius: 50%; |
| 132 | | - background: var(--muted); |
| 133 | | - |
| 134 | | - &.ok { |
| 135 | | - background: var(--ok); |
| 136 | | - } |
| 137 | | - |
| 138 | | - &.bad { |
| 139 | | - background: var(--bad); |
| 140 | | - } |
| 141 | | - |
| 142 | | - &.live { |
| 143 | | - background: var(--accent); |
| 144 | | - animation: commits-beat 1.6s ease-in-out infinite; |
| 145 | | - } |
| 146 | | - } |
| 147 | | - |
| 148 | | - // The subject takes the free width and clips. The heat rule in _alive_heat.scss sets its colour. |
| 149 | | - .commits-sub { |
| 150 | | - flex: 1 1 auto; |
| 151 | | - display: flex; |
| 152 | | - min-width: 0; |
| 153 | | - overflow: hidden; |
| 154 | | - font-size: 14px; |
| 155 | | - font-weight: 400; |
| 156 | | - overflow-wrap: normal; |
| 157 | | - |
| 158 | | - .commit-line { |
| 159 | | - flex: 1 1 auto; |
| 160 | | - min-width: 0; |
| 161 | | - max-width: 100%; |
| 162 | | - } |
| 163 | | - |
| 164 | | - .commit-line-text { |
| 165 | | - font-size: 14px; |
| 166 | | - } |
| 167 | | - } |
| 168 | | - |
| 169 | | - .commits-au { |
| 170 | | - flex: none; |
| 171 | | - font-size: 13px; |
| 172 | | - color: var(--text-2); |
| 173 | | - white-space: nowrap; |
| 174 | | - } |
| 175 | | - |
| 176 | | - .commits-age { |
| 177 | | - flex: none; |
| 178 | | - width: 92px; |
| 179 | | - font-size: 13px; |
| 180 | | - color: var(--muted); |
| 181 | | - white-space: nowrap; |
| 182 | | - } |
| 183 | | - |
| 184 | | - .commits-sha { |
| 185 | | - flex: none; |
| 186 | | - font-family: var(--mono); |
| 187 | | - font-size: 12px; |
| 188 | | - color: var(--text-2); |
| 189 | | - text-decoration: none; |
| 190 | | - |
| 191 | | - &:hover { |
| 192 | | - color: var(--text); |
| 193 | | - } |
| 194 | | - } |
| 195 | | - |
| 196 | | - .commits-ic { |
| 197 | | - flex: none; |
| 198 | | - display: flex; |
| 199 | | - color: var(--muted); |
| 200 | | - |
| 201 | | - svg { |
| 202 | | - display: block; |
| 203 | | - width: 16px; |
| 204 | | - height: 16px; |
| 205 | | - } |
| 206 | | - |
| 207 | | - &:hover { |
| 208 | | - color: var(--text); |
| 209 | | - } |
| 210 | | - } |
| 211 | | - |
| 212 | | - // The message under an expandable row: 13px, indented to 136px, every line kept. |
| 213 | | - .commits-x { |
| 214 | | - margin: 0; |
| 215 | | - padding: 2px 14px 10px 136px; |
| 216 | | - font-family: var(--font); |
| 217 | | - font-size: 13px; |
| 218 | | - line-height: 1.5; |
| 219 | | - color: var(--text-2); |
| 220 | | - white-space: pre-wrap; |
| 221 | | - overflow-wrap: anywhere; |
| 222 | | - } |
| 223 | | - |
| 224 | | - // The checks of an expanded row list under its message, at the same indent. |
| 225 | | - .commits-d > .commit-status { |
| 226 | | - margin: 0 14px 10px 136px; |
| 227 | | - } |
| 228 | | - |
| 229 | | - > .pager { |
| 230 | | - flex: none; |
| 231 | | - } |
| 232 | | -} |
| 233 | 2 | |
| 234 | 3 | @keyframes commits-beat { |
| 235 | 4 | 50% { |
| | @@ -238,35 +7,11 @@ |
| 238 | 7 | } |
| 239 | 8 | |
| 240 | 9 | @media (prefers-reduced-motion: reduce) { |
| 241 | | - .commits-fit .commits-dot.live { |
| 242 | | - animation: none; |
| 243 | | - } |
| 10 | + |
| 244 | 11 | } |
| 245 | 12 | |
| 246 | 13 | // Below 900px the page stacks and the pane is as tall as its rows. |
| 247 | 14 | @media (max-width: 899px) { |
| 248 | | - .commits-fit > .commits-pane { |
| 249 | | - flex: none; |
| 250 | | - overflow: visible; |
| 251 | | - } |
| 252 | | -} |
| 253 | | - |
| 254 | | -// One pane: the outer list is only the frame, and the head sits inside it on the same 14px margin. |
| 255 | | -.commits-fit.lang-list { |
| 256 | | - background: transparent; |
| 257 | | - border: 0; |
| 258 | | - border-radius: 0; |
| 259 | | - box-shadow: none; |
| 260 | | -} |
| 261 | 15 | |
| 262 | | -.commits-fit > .commits-head { |
| 263 | | - padding: 0; |
| 264 | 16 | } |
| 265 | 17 | |
| 266 | | -.commits-fit > .commits-head .label { |
| 267 | | - margin: 0; |
| 268 | | -} |
| 269 | | - |
| 270 | | -.commits-fit > .pager { |
| 271 | | - border-top: 0; |
| 272 | | -} |
| | @@ -52,18 +52,11 @@ |
| 52 | 52 | padding: 0 14px; |
| 53 | 53 | overflow-y: auto; |
| 54 | 54 | |
| 55 | | - > .issue-side-section, |
| 56 | | - > .notif-box { |
| 55 | + > .issue-side-section { |
| 57 | 56 | margin: 0; |
| 58 | 57 | padding: 14px 0; |
| 59 | 58 | } |
| 60 | 59 | |
| 61 | | - > .notif-box { |
| 62 | | - border: 0; |
| 63 | | - border-radius: 0; |
| 64 | | - background: none; |
| 65 | | - box-shadow: none; |
| 66 | | - } |
| 67 | 60 | } |
| 68 | 61 | } |
| 69 | 62 | |
| | @@ -87,9 +80,6 @@ |
| 87 | 80 | gap: 12px; |
| 88 | 81 | padding: 4px 0 14px; |
| 89 | 82 | |
| 90 | | - .remove-form { |
| 91 | | - margin: 0 0 0 auto; |
| 92 | | - } |
| 93 | 83 | } |
| 94 | 84 | |
| 95 | 85 | .label-edit-form { |
| | @@ -184,25 +174,9 @@ |
| 184 | 174 | } |
| 185 | 175 | } |
| 186 | 176 | |
| 187 | | -// New repository: the page head runs the full width like every page, the fields stay form wide, and |
| 188 | | -// the head's controls share one height. |
| 189 | | -.newrepo-form { |
| 190 | | - max-width: none; |
| 191 | | -} |
| 192 | | - |
| 193 | | -.newrepo-form > :not(.page-head) { |
| 194 | | - max-width: 720px; |
| 195 | | -} |
| 196 | | - |
| 197 | | -.newrepo-head-actions { |
| 198 | | - --control-h: 32px; |
| 199 | | -} |
| 200 | | - |
| 201 | 177 | // A side pane matches the pane beside it. |
| 202 | 178 | @media (min-width: 900px) { |
| 203 | | - .fit-split > .fit-side { |
| 204 | | - align-self: stretch; |
| 205 | | - } |
| 179 | + |
| 206 | 180 | } |
| 207 | 181 | |
| 208 | 182 | // Blame: a commit takes two lines; going further back is a small mark on the first. |
| | @@ -102,7 +102,6 @@ |
| 102 | 102 | |
| 103 | 103 | // Panes: the list sits in one pane with a 1px border, 10px radius and no shadow. |
| 104 | 104 | .lang-list, |
| 105 | | -.list-pane, |
| 106 | 105 | .explore { |
| 107 | 106 | box-shadow: none; |
| 108 | 107 | border: 1px solid var(--border); |
| | @@ -111,162 +110,6 @@ |
| 111 | 110 | overflow: hidden; |
| 112 | 111 | } |
| 113 | 112 | |
| 114 | | -// Toolbars: one 44px row at the top of the pane (branches, tags and releases). |
| 115 | | -.lang-list > .list-bar { |
| 116 | | - height: 44px; |
| 117 | | - min-height: 0; |
| 118 | | - flex-wrap: nowrap; |
| 119 | | - gap: 10px; |
| 120 | | - padding: 0 14px; |
| 121 | | - box-sizing: border-box; |
| 122 | | - overflow: hidden; |
| 123 | | -} |
| 124 | | - |
| 125 | | -// Explore: the search and the sort bar share one 44px toolbar. |
| 126 | | -.explore > .explore-toolbar { |
| 127 | | - display: flex; |
| 128 | | - align-items: center; |
| 129 | | - gap: 10px; |
| 130 | | - height: 44px; |
| 131 | | - padding: 0 14px; |
| 132 | | - box-sizing: border-box; |
| 133 | | - border-bottom: 1px solid var(--border); |
| 134 | | - min-width: 0; |
| 135 | | - |
| 136 | | - > .explore-search { |
| 137 | | - flex: 0 1 20rem; |
| 138 | | - min-width: 0; |
| 139 | | - margin: 0; |
| 140 | | - } |
| 141 | | - |
| 142 | | - > .repo-subbar { |
| 143 | | - flex: 1 1 auto; |
| 144 | | - min-width: 0; |
| 145 | | - margin: 0; |
| 146 | | - flex-wrap: nowrap; |
| 147 | | - overflow: hidden; |
| 148 | | - } |
| 149 | | -} |
| 150 | | - |
| 151 | | -// Table rows (branches and tags): 36px, one line, a hairline under each row. |
| 152 | | -.refs-table { |
| 153 | | - tbody > tr { |
| 154 | | - height: 36px; |
| 155 | | - } |
| 156 | | - |
| 157 | | - th, |
| 158 | | - td { |
| 159 | | - height: 36px; |
| 160 | | - padding: 0 14px; |
| 161 | | - vertical-align: middle; |
| 162 | | - white-space: nowrap; |
| 163 | | - border-bottom: 1px solid var(--border); |
| 164 | | - } |
| 165 | | - |
| 166 | | - // Cells shrink to the table width so the commit subject clips instead of widening the row. |
| 167 | | - td.tree-commit { |
| 168 | | - width: 100%; |
| 169 | | - max-width: 0; |
| 170 | | - overflow: hidden; |
| 171 | | - } |
| 172 | | - |
| 173 | | - .tree-commit .commit-line { |
| 174 | | - display: block; |
| 175 | | - overflow: hidden; |
| 176 | | - text-overflow: ellipsis; |
| 177 | | - white-space: nowrap; |
| 178 | | - } |
| 179 | | - |
| 180 | | - .tree-name { |
| 181 | | - font-family: var(--mono); |
| 182 | | - font-size: 13px; |
| 183 | | - } |
| 184 | | - |
| 185 | | - .tree-label { |
| 186 | | - display: inline-flex; |
| 187 | | - align-items: center; |
| 188 | | - gap: 8px; |
| 189 | | - max-width: 100%; |
| 190 | | - overflow: hidden; |
| 191 | | - } |
| 192 | | - |
| 193 | | - .tree-label > a { |
| 194 | | - overflow: hidden; |
| 195 | | - text-overflow: ellipsis; |
| 196 | | - } |
| 197 | | -} |
| 198 | | - |
| 199 | | -// Releases: one row per release, the tag in mono, the title clipped, age and author, the asset |
| 200 | | -// list in a popover and Edit at the end. |
| 201 | | -.lang-list .release-card { |
| 202 | | - display: flex; |
| 203 | | - flex-wrap: nowrap; |
| 204 | | - align-items: center; |
| 205 | | - gap: 12px; |
| 206 | | - height: 36px; |
| 207 | | - min-width: 0; |
| 208 | | - margin: 0; |
| 209 | | - padding: 0 14px; |
| 210 | | - overflow: hidden; |
| 211 | | - border-bottom: 1px solid var(--border); |
| 212 | | - |
| 213 | | - &:hover { |
| 214 | | - background: var(--surface-2); |
| 215 | | - } |
| 216 | | - |
| 217 | | - > h3 { |
| 218 | | - flex: 0 1 auto; |
| 219 | | - min-width: 0; |
| 220 | | - margin: 0; |
| 221 | | - overflow: hidden; |
| 222 | | - font-size: 14px; |
| 223 | | - font-weight: 500; |
| 224 | | - white-space: nowrap; |
| 225 | | - text-overflow: ellipsis; |
| 226 | | - } |
| 227 | | - |
| 228 | | - > .release-tag { |
| 229 | | - flex: none; |
| 230 | | - font-family: var(--mono); |
| 231 | | - font-size: 12px; |
| 232 | | - color: var(--text-2); |
| 233 | | - } |
| 234 | | - |
| 235 | | - > .release-meta { |
| 236 | | - flex: none; |
| 237 | | - margin-left: auto; |
| 238 | | - white-space: nowrap; |
| 239 | | - } |
| 240 | | - |
| 241 | | - > .release-edit { |
| 242 | | - flex: none; |
| 243 | | - } |
| 244 | | - |
| 245 | | - > .release-assets-pop { |
| 246 | | - position: relative; |
| 247 | | - flex: none; |
| 248 | | - |
| 249 | | - > summary { |
| 250 | | - cursor: pointer; |
| 251 | | - white-space: nowrap; |
| 252 | | - } |
| 253 | | - |
| 254 | | - &[open] > .release-asset-list { |
| 255 | | - position: absolute; |
| 256 | | - right: 0; |
| 257 | | - top: 100%; |
| 258 | | - z-index: 5; |
| 259 | | - min-width: 18rem; |
| 260 | | - margin: 4px 0 0; |
| 261 | | - padding: 8px 12px; |
| 262 | | - list-style: none; |
| 263 | | - background: var(--surface); |
| 264 | | - border: 1px solid var(--border); |
| 265 | | - border-radius: 8px; |
| 266 | | - } |
| 267 | | - } |
| 268 | | -} |
| 269 | | - |
| 270 | 113 | // Repo rows (Explore and the profile tabs): mono name, visibility, the description clipped in |
| 271 | 114 | // --text-2, then stars and the update age on the right. |
| 272 | 115 | .repo-list > .repo-item { |
| | @@ -315,8 +158,6 @@ |
| 315 | 158 | |
| 316 | 159 | // Notification, Needs you and review request rows: reason as a small mono tag, the title, the |
| 317 | 160 | // repo or detail, the age and the row's own actions. |
| 318 | | -.notif-group .notif-list > li, |
| 319 | | -.needs-section .notif-list > li.notif-row, |
| 320 | 161 | .review-request-list > li { |
| 321 | 162 | display: flex; |
| 322 | 163 | flex-wrap: nowrap; |
| | @@ -328,16 +169,6 @@ |
| 328 | 169 | overflow: hidden; |
| 329 | 170 | border-bottom: 1px solid var(--border); |
| 330 | 171 | |
| 331 | | - > .notif-title { |
| 332 | | - flex: 0 1 auto; |
| 333 | | - min-width: 0; |
| 334 | | - overflow: hidden; |
| 335 | | - font-size: 14px; |
| 336 | | - text-overflow: ellipsis; |
| 337 | | - white-space: nowrap; |
| 338 | | - overflow-wrap: normal; |
| 339 | | - } |
| 340 | | - |
| 341 | 172 | > .badge { |
| 342 | 173 | flex: none; |
| 343 | 174 | font-family: var(--mono); |
| | @@ -345,28 +176,11 @@ |
| 345 | 176 | } |
| 346 | 177 | |
| 347 | 178 | > .muted, |
| 348 | | - > time, |
| 349 | | - > .notif-inline-form { |
| 179 | + > time { |
| 350 | 180 | flex: none; |
| 351 | 181 | white-space: nowrap; |
| 352 | 182 | } |
| 353 | 183 | |
| 354 | | - > .notif-inline-form { |
| 355 | | - display: inline-flex; |
| 356 | | - } |
| 357 | | -} |
| 358 | | - |
| 359 | | -.notif-group .notif-list > li > .notif-title { |
| 360 | | - flex: 1 1 auto; |
| 361 | | -} |
| 362 | | - |
| 363 | | -.notif-group-head { |
| 364 | | - display: flex; |
| 365 | | - align-items: center; |
| 366 | | - gap: 12px; |
| 367 | | - height: 36px; |
| 368 | | - padding: 0 14px; |
| 369 | | - border-bottom: 1px solid var(--border); |
| 370 | 184 | } |
| 371 | 185 | |
| 372 | 186 | // Issue rows: the assignee sits in a fixed 24px slot at the right, so the columns line up whether |
| | @@ -412,55 +226,10 @@ |
| 412 | 226 | } |
| 413 | 227 | } |
| 414 | 228 | |
| 415 | | -// Milestones: the Open and Closed filter sits at the right of the pane's toolbar, apart from the |
| 416 | | -// Issues, Labels and Milestones tabs. |
| 417 | | -.lang-list > .list-bar > .subnav + .subnav { |
| 418 | | - margin-left: auto; |
| 419 | | -} |
| 420 | | - |
| 421 | | -// Releases: the New release button is centred in the 44px band. |
| 422 | | -.lang-list > .release-list-head { |
| 423 | | - height: 44px; |
| 424 | | - align-items: center; |
| 425 | | - |
| 426 | | - > .button { |
| 427 | | - height: 32px; |
| 428 | | - display: inline-flex; |
| 429 | | - align-items: center; |
| 430 | | - align-self: center; |
| 431 | | - } |
| 432 | | -} |
| 433 | | - |
| 434 | | -// Lists share a 14px inset. Empty states sit on that inset, not inside a second one. |
| 435 | | -.lang-list > .list-scroll, |
| 436 | | -.lang-list > .fit-scroll { |
| 437 | | - padding: 0 14px; |
| 438 | | -} |
| 439 | | - |
| 440 | 229 | .lang-list > .empty-state { |
| 441 | 230 | padding: 16px 14px; |
| 442 | 231 | } |
| 443 | 232 | |
| 444 | | -.lang-list > .list-scroll > .empty-state, |
| 445 | | -.lang-list > .fit-scroll > .empty-state { |
| 446 | | - padding: 16px 0; |
| 447 | | -} |
| 448 | | - |
| 449 | | -// Table rows (tags and branches) start and end on the 14px inset. |
| 450 | | -.lang-list .refs-table th:first-child, |
| 451 | | -.lang-list .refs-table td:first-child, |
| 452 | | -.lang-list .branch-table th:first-child, |
| 453 | | -.lang-list .branch-table td:first-child { |
| 454 | | - padding-left: 0; |
| 455 | | -} |
| 456 | | - |
| 457 | | -.lang-list .refs-table th:last-child, |
| 458 | | -.lang-list .refs-table td:last-child, |
| 459 | | -.lang-list .branch-table th:last-child, |
| 460 | | -.lang-list .branch-table td:last-child { |
| 461 | | - padding-right: 0; |
| 462 | | -} |
| 463 | | - |
| 464 | 233 | // Labels: the colour is a 32px swatch with its label to the left and a border, like the inputs. |
| 465 | 234 | label:has(> input[type="color"]) { |
| 466 | 235 | display: flex; |
| | @@ -494,16 +263,6 @@ input[type="color"] { |
| 494 | 263 | } |
| 495 | 264 | } |
| 496 | 265 | |
| 497 | | -// Pull Commits: rows keep a 14px side padding and Browse files stays inside the pane. |
| 498 | | -.issue-pane > .commit-list > .commit-row { |
| 499 | | - flex-wrap: nowrap; |
| 500 | | - padding: 12px 14px; |
| 501 | | - |
| 502 | | - > .commit-actions { |
| 503 | | - flex: none; |
| 504 | | - } |
| 505 | | -} |
| 506 | | - |
| 507 | 266 | // Pull Files: long diff lines scroll inside their file's body; the file header stays put. |
| 508 | 267 | .pull-diff-scroll { |
| 509 | 268 | min-width: 0; |
| | @@ -37,27 +37,8 @@ |
| 37 | 37 | border-radius: 10px; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | | - // Head row: 36px, one hairline under it, 14px side padding. Also the toolbar of the tree pane. |
| 41 | | - .canvas-head { |
| 42 | | - display: flex; |
| 43 | | - align-items: center; |
| 44 | | - gap: 12px; |
| 45 | | - flex: none; |
| 46 | | - height: 36px; |
| 47 | | - min-width: 0; |
| 48 | | - margin: 0; |
| 49 | | - padding: 0 14px; |
| 50 | | - border: 0; |
| 51 | | - border-bottom: 1px solid var(--border); |
| 52 | | - font-size: 13px; |
| 53 | | - color: var(--text-2); |
| 54 | | - } |
| 55 | | - |
| 56 | 40 | // Tree pane: the branch selector and the go-to-file tag share the head; the rows scroll below. |
| 57 | 41 | .canvas-files { |
| 58 | | - .canvas-head { |
| 59 | | - padding-right: 10px; |
| 60 | | - } |
| 61 | 42 | |
| 62 | 43 | .ref-select { |
| 63 | 44 | position: relative; |
| | @@ -229,21 +210,6 @@ |
| 229 | 210 | |
| 230 | 211 | // README pane: the file name at the left, the facts and Clone at the right. |
| 231 | 212 | .canvas-readme { |
| 232 | | - .canvas-head { |
| 233 | | - justify-content: space-between; |
| 234 | | - } |
| 235 | | - |
| 236 | | - .canvas-facts { |
| 237 | | - display: flex; |
| 238 | | - align-items: center; |
| 239 | | - gap: 14px; |
| 240 | | - min-width: 0; |
| 241 | | - margin-left: auto; |
| 242 | | - font-family: var(--mono); |
| 243 | | - font-size: 12px; |
| 244 | | - color: var(--muted); |
| 245 | | - white-space: nowrap; |
| 246 | | - } |
| 247 | 213 | |
| 248 | 214 | .readme-meta { |
| 249 | 215 | overflow: hidden; |
| | @@ -604,18 +570,6 @@ |
| 604 | 570 | stroke-linejoin: round; |
| 605 | 571 | } |
| 606 | 572 | |
| 607 | | -// Code tab menu: its left edge sits on the Code tab's left edge, 4px under the 36px tab row. The |
| 608 | | -// head is the containing block, outside the tab bar's scroll clip. |
| 609 | | -.page-head.repo-head-code { |
| 610 | | - position: relative; |
| 611 | | -} |
| 612 | | - |
| 613 | | -.page-head.repo-head-code .tab-more-list { |
| 614 | | - top: 40px; |
| 615 | | - left: 0; |
| 616 | | - margin-top: 0; |
| 617 | | -} |
| 618 | | - |
| 619 | 573 | // Tree pane with no README: the message sits on the pane head's 14px inset, not the body's 24px. |
| 620 | 574 | .repo-home.canvas-repo .canvas-readme .canvas-body:has(> .empty-state) { |
| 621 | 575 | padding: 14px; |
| | @@ -652,7 +606,3 @@ dialog.finder .finder-input { |
| 652 | 606 | padding-right: 9px; |
| 653 | 607 | } |
| 654 | 608 | |
| 655 | | -.repo-home.canvas-repo .canvas-readme .canvas-head .label { |
| 656 | | - margin: 0; |
| 657 | | - align-self: center; |
| 658 | | -} |
| | @@ -1,63 +1,4 @@ |
| 1 | | -// Shared list and page styles that were in the dashboard file until c812504: the explore search and |
| 2 | | -// sort chips, the repo listing on profile tabs, repo rows, the numbered pager and the org page head. |
| 3 | 1 | |
| 4 | | -// Explore: one-row search (input, then its button) and a sort control of pill links. |
| 5 | | -.explore-search { |
| 6 | | - display: flex; |
| 7 | | - flex-wrap: wrap; |
| 8 | | - gap: 8px; |
| 9 | | - align-items: center; |
| 10 | | - margin: 18px 0 0; |
| 11 | | - |
| 12 | | - input[type="search"] { |
| 13 | | - flex: 1 1 240px; |
| 14 | | - width: auto; |
| 15 | | - min-width: 0; |
| 16 | | - } |
| 17 | | - |
| 18 | | - button { |
| 19 | | - flex: 0 0 auto; |
| 20 | | - } |
| 21 | | - |
| 22 | | - @media (max-width: 479px) { |
| 23 | | - input[type="search"] { |
| 24 | | - flex: 1 1 100%; |
| 25 | | - } |
| 26 | | - } |
| 27 | | -} |
| 28 | | - |
| 29 | | -.explore-sort { |
| 30 | | - display: flex; |
| 31 | | - flex-wrap: wrap; |
| 32 | | - gap: 6px 8px; |
| 33 | | - align-items: center; |
| 34 | | - margin: 14px 0 0; |
| 35 | | - font-size: 13px; |
| 36 | | - |
| 37 | | - a, |
| 38 | | - .current { |
| 39 | | - display: inline-flex; |
| 40 | | - align-items: center; |
| 41 | | - height: 28px; |
| 42 | | - padding: 0 12px; |
| 43 | | - border: 1px solid var(--border); |
| 44 | | - border-radius: var(--radius-full); |
| 45 | | - color: var(--text-2); |
| 46 | | - text-decoration: none; |
| 47 | | - } |
| 48 | | - |
| 49 | | - a:hover { |
| 50 | | - background: var(--surface-2); |
| 51 | | - text-decoration: none; |
| 52 | | - } |
| 53 | | - |
| 54 | | - .current { |
| 55 | | - border-color: transparent; |
| 56 | | - background: var(--accent-soft); |
| 57 | | - color: var(--accent-ink); |
| 58 | | - font-weight: 600; |
| 59 | | - } |
| 60 | | -} |
| 61 | 2 | |
| 62 | 3 | // Repo listing toolbar: the search takes the free width, and the New repository button sits beside it. |
| 63 | 4 | .repo-tools { |
| | @@ -66,11 +7,6 @@ |
| 66 | 7 | gap: 8px; |
| 67 | 8 | align-items: center; |
| 68 | 9 | |
| 69 | | - .explore-search { |
| 70 | | - flex: 1 1 320px; |
| 71 | | - margin: 0; |
| 72 | | - } |
| 73 | | - |
| 74 | 10 | .button { |
| 75 | 11 | flex: none; |
| 76 | 12 | } |
| | @@ -84,7 +20,6 @@ |
| 84 | 20 | justify-content: space-between; |
| 85 | 21 | gap: 8px 16px; |
| 86 | 22 | |
| 87 | | - .explore-sort, |
| 88 | 23 | p { |
| 89 | 24 | margin: 0; |
| 90 | 25 | } |
| | @@ -97,8 +32,6 @@ |
| 97 | 32 | flex-direction: column; |
| 98 | 33 | gap: 10px; |
| 99 | 34 | |
| 100 | | - > .explore-search, |
| 101 | | - > .explore-sort, |
| 102 | 35 | > p { |
| 103 | 36 | margin: 0; |
| 104 | 37 | } |
| | @@ -164,20 +97,6 @@ |
| 164 | 97 | } |
| 165 | 98 | } |
| 166 | 99 | |
| 167 | | -// Organization pages: the name and description stack; the section links are in the shell sidebar. |
| 168 | | -.org-head { |
| 169 | | - .org-head-text { |
| 170 | | - display: grid; |
| 171 | | - gap: 4px; |
| 172 | | - min-width: 0; |
| 173 | | - } |
| 174 | | - |
| 175 | | - h1, |
| 176 | | - p { |
| 177 | | - margin: 0; |
| 178 | | - } |
| 179 | | -} |
| 180 | | - |
| 181 | 100 | // Organization header: the avatar is 96px (the person's is larger), and the Edit organization and |
| 182 | 101 | // New repository buttons sit in one row under the description line. |
| 183 | 102 | .profile-avatar.org-avatar { |
| | @@ -185,32 +104,8 @@ |
| 185 | 104 | height: 96px; |
| 186 | 105 | } |
| 187 | 106 | |
| 188 | | -.profile-org-actions .profile-edit { |
| 189 | | - margin-top: 0; |
| 190 | | -} |
| 191 | | - |
| 192 | | -// Overview of an organization: the pinned repos fill the left column, two to a row, and the members |
| 193 | | -// card sits at the right, 320px wide. Below 900px the two stack, the repos first. A person's |
| 194 | | -// overview wrapper adds no box of its own. |
| 195 | | -.profile-overview { |
| 196 | | - display: contents; |
| 197 | | -} |
| 198 | | - |
| 199 | | -.org-overview { |
| 200 | | - display: grid; |
| 201 | | - grid-template-columns: minmax(0, 1fr); |
| 202 | | - gap: 16px; |
| 203 | | - align-items: start; |
| 204 | | - |
| 205 | | - .pin-grid { |
| 206 | | - grid-template-columns: repeat(2, minmax(0, 1fr)); |
| 207 | | - } |
| 208 | | -} |
| 209 | | - |
| 210 | 107 | @media (min-width: 900px) { |
| 211 | | - .org-overview { |
| 212 | | - grid-template-columns: minmax(0, 1fr) 320px; |
| 213 | | - } |
| 108 | + |
| 214 | 109 | } |
| 215 | 110 | |
| 216 | 111 | .profile-org { |
| | @@ -8,37 +8,4 @@ |
| 8 | 8 | text-align: left; |
| 9 | 9 | color: var(--muted); |
| 10 | 10 | |
| 11 | | - .empty-state-title { |
| 12 | | - margin: 0; |
| 13 | | - color: var(--text-2); |
| 14 | | - font-weight: 600; |
| 15 | | - } |
| 16 | | - |
| 17 | | - .empty-state-hint { |
| 18 | | - max-width: 52ch; |
| 19 | | - margin: 0; |
| 20 | | - font-size: 0.875rem; |
| 21 | | - } |
| 22 | | - |
| 23 | | - .empty-state-action { |
| 24 | | - display: flex; |
| 25 | | - flex-wrap: wrap; |
| 26 | | - justify-content: flex-start; |
| 27 | | - gap: 8px; |
| 28 | | - margin-top: 8px; |
| 29 | | - |
| 30 | | - &:empty { |
| 31 | | - display: none; |
| 32 | | - } |
| 33 | | - |
| 34 | | - > button, |
| 35 | | - > .button { |
| 36 | | - align-self: center; |
| 37 | | - } |
| 38 | | - |
| 39 | | - pre, |
| 40 | | - code { |
| 41 | | - text-align: left; |
| 42 | | - } |
| 43 | | - } |
| 44 | 11 | } |
| | @@ -8,12 +8,6 @@ |
| 8 | 8 | margin-bottom: 0; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | | -// Instance health (/admin/health): the alerts card pages four alerts at a time, so its pager sits |
| 12 | | -// close under the list. |
| 13 | | -.admin-alerts .pager { |
| 14 | | - margin: 0 0 8px; |
| 15 | | -} |
| 16 | | - |
| 17 | 11 | // Instance health (/admin/health): the storage and services cards sit side by side, under the |
| 18 | 12 | // summary. The alerts and the footnote span both columns. |
| 19 | 13 | @media (min-width: 900px) { |
| | @@ -22,33 +16,12 @@ |
| 22 | 16 | grid-template-columns: repeat(2, minmax(0, 1fr)); |
| 23 | 17 | column-gap: 16px; |
| 24 | 18 | |
| 25 | | - > .page-head, |
| 26 | | - > .admin-alerts, |
| 27 | | - > .health-meta { |
| 28 | | - grid-column: 1 / -1; |
| 29 | | - } |
| 30 | | - |
| 31 | | - .health-row { |
| 32 | | - padding: 8px 0; |
| 33 | | - } |
| 34 | 19 | } |
| 35 | 20 | } |
| 36 | 21 | |
| 37 | 22 | // User detail (/admin/users/{id}): the actions and the danger zone side by side, under the header. |
| 38 | 23 | @media (min-width: 900px) { |
| 39 | | - .user-page { |
| 40 | | - display: grid; |
| 41 | | - grid-template-columns: repeat(2, minmax(0, 1fr)); |
| 42 | | - column-gap: 16px; |
| 43 | 24 | |
| 44 | | - > .user-head { |
| 45 | | - grid-column: 1 / -1; |
| 46 | | - } |
| 47 | | - |
| 48 | | - .action-row { |
| 49 | | - padding: 10px 0; |
| 50 | | - } |
| 51 | | - } |
| 52 | 25 | } |
| 53 | 26 | |
| 54 | 27 | // Mail settings (/admin/mail): the SMTP form runs three fields across, the actions span the row. |
| | @@ -1,24 +1,4 @@ |
| 1 | | -// One-screen layout of editor forms. See _fit.scss. An editor form sits in a .fit-pane: its editor |
| 2 | | -// takes the rest of the height, so the buttons stay under it without a page scroll. |
| 3 | 1 | |
| 4 | | -// Short fields of the new-release form share a row; the hint goes under them. |
| 5 | | -.release-pair { |
| 6 | | - display: flex; |
| 7 | | - flex-wrap: wrap; |
| 8 | | - align-items: flex-end; |
| 9 | | - gap: 14px 16px; |
| 10 | | - |
| 11 | | - > label { |
| 12 | | - flex: 1 1 12rem; |
| 13 | | - min-width: 0; |
| 14 | | - } |
| 15 | | - |
| 16 | | - > p { |
| 17 | | - order: 1; |
| 18 | | - flex: 1 0 100%; |
| 19 | | - margin: 0; |
| 20 | | - } |
| 21 | | -} |
| 22 | 2 | |
| 23 | 3 | @media (min-width: 900px) { |
| 24 | 4 | // A card that is a pane with a form in it: no bottom margin (the pane fills the window), and the |
| | @@ -54,7 +34,6 @@ |
| 54 | 34 | // The pane clips its overflow, so the focus ring of the card edges gets a little room. |
| 55 | 35 | padding: 4px; |
| 56 | 36 | |
| 57 | | - .snippet-doc, |
| 58 | 37 | .snippet-files { |
| 59 | 38 | flex: 1 1 auto; |
| 60 | 39 | min-height: 0; |
| | @@ -78,35 +57,8 @@ |
| 78 | 57 | } |
| 79 | 58 | } |
| 80 | 59 | |
| 81 | | - // The import page (pages/import.rs, import_home): the form and the recent imports side by side on |
| 82 | | - // wide windows, each a pane that scrolls inside. |
| 83 | | - .import-home { |
| 84 | | - display: grid; |
| 85 | | - grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem); |
| 86 | | - align-items: start; |
| 87 | | - gap: 16px; |
| 88 | | - |
| 89 | | - > .newrepo-form.fit-pane { |
| 90 | | - max-width: none; |
| 91 | | - } |
| 92 | | - |
| 93 | | - > .import-recent { |
| 94 | | - max-width: none; |
| 95 | | - margin: 0; |
| 96 | | - } |
| 97 | | - } |
| 98 | | - |
| 99 | 60 | // The form's two cards share a row on the widest windows; the header and the notes span both. |
| 100 | 61 | @media (min-width: 1200px) { |
| 101 | | - .import-home > .newrepo-form { |
| 102 | | - display: grid; |
| 103 | | - grid-template-columns: repeat(2, minmax(0, 720px)); |
| 104 | | - justify-content: start; |
| 105 | | - align-items: start; |
| 106 | 62 | |
| 107 | | - > :not(.newrepo-card) { |
| 108 | | - grid-column: 1 / -1; |
| 109 | | - } |
| 110 | | - } |
| 111 | 63 | } |
| 112 | 64 | } |
| | @@ -1,27 +1,4 @@ |
| 1 | 1 | // One-screen layout of notifications, security log and audit log. See _fit.scss. |
| 2 | 2 | @media (min-width: 900px) { |
| 3 | | - // The notifications pane holds the groups and the older link: it scrolls only in a page of many |
| 4 | | - // small groups. Its bottom margin would add to the page's height, so it has none. |
| 5 | | - .notif-pane.fit-pane { |
| 6 | | - margin-bottom: 0; |
| 7 | | - } |
| 8 | 3 | |
| 9 | | - // A table card (audit log, security log): the table scrolls inside the card and the pager stays |
| 10 | | - // at its bottom, in the same column, so the paging is always in view. |
| 11 | | - .fit-pane.fit-list { |
| 12 | | - display: flex; |
| 13 | | - flex-direction: column; |
| 14 | | - overflow: hidden; |
| 15 | | - margin-bottom: 0; |
| 16 | | - |
| 17 | | - > .table-wrap { |
| 18 | | - flex: 1 1 auto; |
| 19 | | - min-height: 0; |
| 20 | | - overflow: auto; |
| 21 | | - } |
| 22 | | - |
| 23 | | - > .pager { |
| 24 | | - flex: none; |
| 25 | | - } |
| 26 | | - } |
| 27 | 4 | } |
| | @@ -1,38 +1,10 @@ |
| 1 | | -// One-screen layout of repo and org settings. See _fit.scss. |
| 2 | 1 | |
| 3 | | -// A settings page that puts its cards side by side: the list and its add forms, or the general cards |
| 4 | | -// in columns. Below 900px the cards stack. From 900px the cards share the row, and a card that does |
| 5 | | -// not fit the pane's height scrolls inside it. |
| 6 | | -.settings-split { |
| 7 | | - display: grid; |
| 8 | | - grid-template-columns: minmax(0, 1fr); |
| 9 | | - align-items: start; |
| 10 | | - align-content: start; |
| 11 | | - gap: 16px; |
| 12 | | - |
| 13 | | - > .card { |
| 14 | | - margin-bottom: 0; |
| 15 | | - } |
| 16 | | -} |
| 17 | 2 | |
| 18 | 3 | @media (min-width: 900px) { |
| 19 | | - .settings-split { |
| 20 | | - grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); |
| 21 | | - } |
| 4 | + |
| 22 | 5 | } |
| 23 | 6 | |
| 24 | 7 | // The new webhook form: the fields in the left column, the event list in the right one. |
| 25 | 8 | @media (min-width: 900px) { |
| 26 | | - .settings-split .webhook-form { |
| 27 | | - display: grid; |
| 28 | | - grid-template-columns: repeat(2, minmax(0, 1fr)); |
| 29 | | - align-items: start; |
| 30 | | - gap: 14px 32px; |
| 31 | | - max-width: none; |
| 32 | 9 | |
| 33 | | - > .event-choices { |
| 34 | | - grid-column: 2; |
| 35 | | - grid-row: 1 / span 6; |
| 36 | | - } |
| 37 | | - } |
| 38 | 10 | } |
| | @@ -1,58 +1,5 @@ |
| 1 | | -// One-screen layout of runners, labels, milestones and releases. See _fit.scss. |
| 2 | | -// |
| 3 | | -// A list card fills the pane (`.fit-pane`): its header stays put, its rows scroll inside `.fit-scroll`, |
| 4 | | -// and the pager sits under them in the same column (`.fit-card`). Beside it, a narrow card (`.fit-side`) |
| 5 | | -// holds the create form, so the form is in reach without scrolling. Below 900px the row stacks and |
| 6 | | -// nothing has a fixed height. |
| 7 | 1 | |
| 8 | | -.fit-split { |
| 9 | | - display: flex; |
| 10 | | - align-items: stretch; |
| 11 | | - gap: 20px; |
| 12 | | - |
| 13 | | - > .fit-main { |
| 14 | | - flex: 1 1 auto; |
| 15 | | - min-width: 0; |
| 16 | | - } |
| 17 | | - |
| 18 | | - > .fit-side { |
| 19 | | - flex: 0 0 300px; |
| 20 | | - min-width: 0; |
| 21 | | - } |
| 22 | | -} |
| 23 | | - |
| 24 | | -.fit-card { |
| 25 | | - display: flex; |
| 26 | | - flex-direction: column; |
| 27 | | - min-height: 0; |
| 28 | | - |
| 29 | | - > .fit-scroll { |
| 30 | | - flex: 1 1 auto; |
| 31 | | - min-height: 0; |
| 32 | | - overflow: auto; |
| 33 | | - overscroll-behavior: contain; |
| 34 | | - } |
| 35 | | - |
| 36 | | - > .pager { |
| 37 | | - flex: none; |
| 38 | | - margin-top: 8px; |
| 39 | | - } |
| 40 | | -} |
| 41 | | - |
| 42 | | -// Runner rows reach 12px past the list on each side (see `.runner-row.is-linked`); the scroll box |
| 43 | | -// takes that room so the hover background is not cut off. |
| 44 | | -.fit-bleed { |
| 45 | | - margin: 0 -12px; |
| 46 | | - padding: 0 12px; |
| 47 | | -} |
| 48 | 2 | |
| 49 | 3 | @media (max-width: 899px) { |
| 50 | | - .fit-split { |
| 51 | | - flex-direction: column; |
| 52 | 4 | |
| 53 | | - > .fit-side { |
| 54 | | - flex: none; |
| 55 | | - width: 100%; |
| 56 | | - } |
| 57 | | - } |
| 58 | 5 | } |
| | @@ -6,52 +6,6 @@ |
| 6 | 6 | background: var(--danger); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | | -// The URL is the row's name: a monospace identifier that truncates with an ellipsis. |
| 10 | | -.runner-name.mirror-url, |
| 11 | | -.runner-name.hook-url { |
| 12 | | - font-family: var(--mono); |
| 13 | | - font-size: 0.875rem; |
| 14 | | - font-weight: 500; |
| 15 | | -} |
| 16 | | - |
| 17 | | -// Mirrors: the name column, then the Sync now button. |
| 18 | | -.mirror-list .runner-row { |
| 19 | | - grid-template-columns: minmax(0, 1fr) auto; |
| 20 | | -} |
| 21 | | - |
| 22 | | -// Webhooks: the name column alone; the row links to the hook's page. |
| 23 | | -.hook-list .runner-row { |
| 24 | | - grid-template-columns: minmax(0, 1fr); |
| 25 | | -} |
| 26 | | - |
| 27 | | -// Sync now: a compact button that sits level with the name. |
| 28 | | -.hook-sync { |
| 29 | | - box-sizing: border-box; |
| 30 | | - height: 28px; |
| 31 | | - padding: 0 10px; |
| 32 | | - font-size: 0.8125rem; |
| 33 | | -} |
| 34 | | - |
| 35 | | -// The failure disclosure sits under the meta line, indented to line up with the name. |
| 36 | | -.mirror-failure { |
| 37 | | - margin: 4px 0 0 16px; |
| 38 | | - font-size: 0.75rem; |
| 39 | | - |
| 40 | | - summary { |
| 41 | | - color: var(--danger); |
| 42 | | - cursor: pointer; |
| 43 | | - width: fit-content; |
| 44 | | - } |
| 45 | | - |
| 46 | | - .mirror-error { |
| 47 | | - margin: 6px 0 0; |
| 48 | | - font-family: var(--mono); |
| 49 | | - font-size: 0.8125rem; |
| 50 | | - overflow-wrap: anywhere; |
| 51 | | - white-space: pre-wrap; |
| 52 | | - } |
| 53 | | -} |
| 54 | | - |
| 55 | 9 | // The last delivery's state when it was not ok. |
| 56 | 10 | .hook-problem { |
| 57 | 11 | color: var(--danger); |
| | @@ -59,12 +13,5 @@ |
| 59 | 13 | |
| 60 | 14 | // Phone: the sync button goes under the name, the rows stack. |
| 61 | 15 | @media (max-width: 600px) { |
| 62 | | - .mirror-list .runner-row { |
| 63 | | - grid-template-columns: minmax(0, 1fr); |
| 64 | | - row-gap: 10px; |
| 65 | 16 | |
| 66 | | - > form { |
| 67 | | - justify-self: start; |
| 68 | | - } |
| 69 | | - } |
| 70 | 17 | } |
| | @@ -1,128 +1,4 @@ |
| 1 | | -// Import and export (pages/import.rs, pages/settings_export.rs). Tokens only, so both themes follow |
| 2 | | -// main.scss. The forms reuse the .newrepo-* cards. |
| 3 | 1 | |
| 4 | | -.import-tabs { |
| 5 | | - display: flex; |
| 6 | | - flex-wrap: wrap; |
| 7 | | - align-items: center; |
| 8 | | - gap: 4px; |
| 9 | | - max-width: 960px; |
| 10 | | - margin: 0 0 16px; |
| 11 | | - border-bottom: 1px solid var(--border); |
| 12 | | -} |
| 13 | | - |
| 14 | | -.import-tabs + .alert { |
| 15 | | - max-width: 960px; |
| 16 | | -} |
| 17 | | - |
| 18 | | -.import-tab { |
| 19 | | - margin-bottom: -1px; |
| 20 | | - padding: 8px 14px; |
| 21 | | - border-bottom: 2px solid transparent; |
| 22 | | - font-size: 0.875rem; |
| 23 | | - font-weight: 500; |
| 24 | | - color: var(--muted); |
| 25 | | - text-decoration: none; |
| 26 | | - |
| 27 | | - &:hover { |
| 28 | | - color: var(--text); |
| 29 | | - } |
| 30 | | - |
| 31 | | - &[aria-current="page"] { |
| 32 | | - color: var(--accent-ink); |
| 33 | | - border-bottom-color: var(--accent); |
| 34 | | - } |
| 35 | | -} |
| 36 | | - |
| 37 | | -.import-sources { |
| 38 | | - display: inline-flex; |
| 39 | | - align-items: center; |
| 40 | | - align-self: flex-start; |
| 41 | | - gap: 2px; |
| 42 | | - max-width: 100%; |
| 43 | | - padding: 2px; |
| 44 | | - border: 1px solid var(--border); |
| 45 | | - border-radius: var(--radius-full); |
| 46 | | - background: var(--surface-2); |
| 47 | | -} |
| 48 | | - |
| 49 | | -.import-source { |
| 50 | | - display: inline-flex; |
| 51 | | - align-items: center; |
| 52 | | - height: 26px; |
| 53 | | - padding: 0 14px; |
| 54 | | - border-radius: var(--radius-full); |
| 55 | | - font-size: 0.8125rem; |
| 56 | | - font-weight: 500; |
| 57 | | - color: var(--muted); |
| 58 | | - text-decoration: none; |
| 59 | | - white-space: nowrap; |
| 60 | | - |
| 61 | | - &:hover { |
| 62 | | - color: var(--text); |
| 63 | | - } |
| 64 | | - |
| 65 | | - &[aria-current="page"] { |
| 66 | | - background: var(--surface); |
| 67 | | - color: var(--accent-ink); |
| 68 | | - box-shadow: 0 1px 2px rgba(30, 36, 32, .12); |
| 69 | | - } |
| 70 | | -} |
| 71 | | - |
| 72 | | -.import-opts { |
| 73 | | - display: flex; |
| 74 | | - flex-direction: column; |
| 75 | | - gap: 8px; |
| 76 | | - min-width: 0; |
| 77 | | - margin: 0; |
| 78 | | - padding: 0; |
| 79 | | - border: 0; |
| 80 | | - |
| 81 | | - legend { |
| 82 | | - padding: 0; |
| 83 | | - margin-bottom: 6px; |
| 84 | | - font-size: 0.875rem; |
| 85 | | - font-weight: 500; |
| 86 | | - color: var(--text-2); |
| 87 | | - } |
| 88 | | - |
| 89 | | - p { |
| 90 | | - margin: 4px 0 0; |
| 91 | | - } |
| 92 | | -} |
| 93 | | - |
| 94 | | -// Where the picked repositories go: the owner as a settings row, what comes along under it. |
| 95 | | -.import-into { |
| 96 | | - gap: 0; |
| 97 | | - padding: 4px 22px 16px; |
| 98 | | - |
| 99 | | - .action-control select { |
| 100 | | - min-width: 180px; |
| 101 | | - } |
| 102 | | -} |
| 103 | | - |
| 104 | | -.import-into-opts { |
| 105 | | - padding-top: 14px; |
| 106 | | - border-top: 1px solid var(--border); |
| 107 | | - |
| 108 | | - // Four short choices fit on one line here; the single-import form keeps them stacked. |
| 109 | | - .import-opts { |
| 110 | | - flex-direction: row; |
| 111 | | - flex-wrap: wrap; |
| 112 | | - gap: 8px 22px; |
| 113 | | - } |
| 114 | | - |
| 115 | | - .import-opts > p { |
| 116 | | - flex-basis: 100%; |
| 117 | | - } |
| 118 | | -} |
| 119 | | - |
| 120 | | -// The repositories as rows: the whole row is the checkbox's label, a ticked row is tinted. |
| 121 | | -.import-pick { |
| 122 | | - gap: 0; |
| 123 | | - padding: 0; |
| 124 | | - overflow: hidden; |
| 125 | | -} |
| 126 | 2 | |
| 127 | 3 | .import-pick-list { |
| 128 | 4 | max-height: 60vh; |
| | @@ -131,80 +7,6 @@ |
| 131 | 7 | overflow-y: auto; |
| 132 | 8 | list-style: none; |
| 133 | 9 | |
| 134 | | - li + li .import-pick-row { |
| 135 | | - border-top: 1px solid var(--border); |
| 136 | | - } |
| 137 | | -} |
| 138 | | - |
| 139 | | -.import-pick-row { |
| 140 | | - display: grid; |
| 141 | | - grid-template-columns: auto minmax(0, 1fr) auto; |
| 142 | | - align-items: start; |
| 143 | | - gap: 12px; |
| 144 | | - margin: 0; |
| 145 | | - padding: 11px 22px; |
| 146 | | - cursor: pointer; |
| 147 | | - |
| 148 | | - > input { |
| 149 | | - margin: 2px 0 0; |
| 150 | | - } |
| 151 | | - |
| 152 | | - &:hover { |
| 153 | | - background: var(--surface-2); |
| 154 | | - } |
| 155 | | - |
| 156 | | - &:has(input:checked) { |
| 157 | | - background: var(--accent-soft); |
| 158 | | - } |
| 159 | | -} |
| 160 | | - |
| 161 | | -.import-pick-all { |
| 162 | | - align-items: center; |
| 163 | | - border-bottom: 1px solid var(--border-strong); |
| 164 | | - font-weight: 600; |
| 165 | | - |
| 166 | | - > input { |
| 167 | | - margin: 0; |
| 168 | | - } |
| 169 | | - |
| 170 | | - &:has(input:checked) { |
| 171 | | - background: none; |
| 172 | | - } |
| 173 | | -} |
| 174 | | - |
| 175 | | -.import-pick-main { |
| 176 | | - display: flex; |
| 177 | | - flex-direction: column; |
| 178 | | - gap: 2px; |
| 179 | | - min-width: 0; |
| 180 | | -} |
| 181 | | - |
| 182 | | -.import-pick-title { |
| 183 | | - display: flex; |
| 184 | | - flex-wrap: wrap; |
| 185 | | - align-items: center; |
| 186 | | - gap: 4px 8px; |
| 187 | | - min-width: 0; |
| 188 | | -} |
| 189 | | - |
| 190 | | -.import-pick-name { |
| 191 | | - font-family: var(--mono); |
| 192 | | - font-size: 0.875rem; |
| 193 | | - font-weight: 500; |
| 194 | | -} |
| 195 | | - |
| 196 | | -.import-pick-desc { |
| 197 | | - min-width: 0; |
| 198 | | - overflow: hidden; |
| 199 | | - text-overflow: ellipsis; |
| 200 | | - white-space: nowrap; |
| 201 | | - max-width: 100%; |
| 202 | | -} |
| 203 | | - |
| 204 | | -// The recent imports card under the import form (pages/import.rs, recent_imports): as wide as the form. |
| 205 | | -.import-recent { |
| 206 | | - max-width: 960px; |
| 207 | | - margin-top: 16px; |
| 208 | 10 | } |
| 209 | 11 | |
| 210 | 12 | .import-job { |
| | @@ -215,38 +17,6 @@ |
| 215 | 17 | min-width: 0; |
| 216 | 18 | } |
| 217 | 19 | |
| 218 | | -.import-job-title { |
| 219 | | - margin: 0; |
| 220 | | - min-width: 0; |
| 221 | | - font-size: 1.25rem; |
| 222 | | - font-family: var(--mono); |
| 223 | | - overflow-wrap: anywhere; |
| 224 | | -} |
| 225 | | - |
| 226 | | -.import-job-name { |
| 227 | | - font-family: var(--mono); |
| 228 | | - font-size: 0.875rem; |
| 229 | | - overflow-wrap: anywhere; |
| 230 | | -} |
| 231 | | - |
| 232 | | -.import-job-row { |
| 233 | | - display: flex; |
| 234 | | - flex-wrap: wrap; |
| 235 | | - align-items: center; |
| 236 | | - gap: 8px 14px; |
| 237 | | - |
| 238 | | - .item-main { |
| 239 | | - flex: 1 1 260px; |
| 240 | | - min-width: 0; |
| 241 | | - } |
| 242 | | -} |
| 243 | | - |
| 244 | | -.import-stage { |
| 245 | | - display: flex; |
| 246 | | - align-items: baseline; |
| 247 | | - gap: 10px; |
| 248 | | -} |
| 249 | | - |
| 250 | 20 | .import-progress { |
| 251 | 21 | width: 100%; |
| 252 | 22 | height: 8px; |
| | @@ -264,17 +34,6 @@ |
| 264 | 34 | color: var(--alert-text); |
| 265 | 35 | } |
| 266 | 36 | |
| 267 | | -.import-retry { |
| 268 | | - display: flex; |
| 269 | | - flex-direction: column; |
| 270 | | - gap: 10px; |
| 271 | | - max-width: 420px; |
| 272 | | - |
| 273 | | - p { |
| 274 | | - margin: 0; |
| 275 | | - } |
| 276 | | -} |
| 277 | | - |
| 278 | 37 | .import-log-title { |
| 279 | 38 | margin: 0; |
| 280 | 39 | font-size: 0.9375rem; |
| | @@ -313,44 +72,18 @@ |
| 313 | 72 | max-width: 960px; |
| 314 | 73 | } |
| 315 | 74 | |
| 316 | | -.export-intro { |
| 317 | | - display: flex; |
| 318 | | - flex-direction: column; |
| 319 | | - gap: 8px; |
| 320 | | - |
| 321 | | - p { |
| 322 | | - margin: 0; |
| 323 | | - } |
| 324 | | -} |
| 325 | | - |
| 326 | 75 | .export-row { |
| 327 | 76 | display: flex; |
| 328 | 77 | flex-wrap: wrap; |
| 329 | 78 | align-items: center; |
| 330 | 79 | gap: 8px 14px; |
| 331 | 80 | |
| 332 | | - .item-main { |
| 333 | | - flex: 1 1 240px; |
| 334 | | - min-width: 0; |
| 335 | | - } |
| 336 | 81 | } |
| 337 | 82 | |
| 338 | 83 | .export-progress { |
| 339 | 84 | width: 120px; |
| 340 | 85 | } |
| 341 | 86 | |
| 342 | | -.export-error { |
| 343 | | - list-style: none; |
| 344 | | - |
| 345 | | - .alert { |
| 346 | | - margin: 0; |
| 347 | | - } |
| 348 | | -} |
| 349 | | - |
| 350 | 87 | @media (max-width: 560px) { |
| 351 | | - .import-pick-row, |
| 352 | | - .import-into { |
| 353 | | - padding-left: 14px; |
| 354 | | - padding-right: 14px; |
| 355 | | - } |
| 88 | + |
| 356 | 89 | } |