| @@ -138,8 +138,8 @@ fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) { |
| 138 | } | 138 | } |
| 139 | | 139 | |
| 140 | async fn create_token(http: &Http, session: &str) -> String { | 140 | async fn create_token(http: &Http, session: &str) -> String { |
| 141 | - let page = http.get_cookie("/settings/tokens", session).await; | 141 | + let page = http.get_cookie("/settings/keys", session).await; |
| 142 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 142 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 143 | let csrf = input_value(&page.body, "csrf"); | 143 | let csrf = input_value(&page.body, "csrf"); |
| 144 | let res = http | 144 | let res = http |
| 145 | .post_form( | 145 | .post_form( |
| @@ -99,8 +99,8 @@ fn remote_sha(repo: &Path, reference: &str) -> String { |
| 99 | | 99 | |
| 100 | /// Creates an access token through `/settings/tokens` and returns the token shown once. | 100 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 101 | async fn create_token(http: &Http, session: &str, name: &str) -> String { | 101 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 102 | - let page = http.get_cookie("/settings/tokens", session).await; | 102 | + let page = http.get_cookie("/settings/keys", session).await; |
| 103 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 103 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 104 | let csrf = input_value(&page.body, "csrf"); | 104 | let csrf = input_value(&page.body, "csrf"); |
| 105 | let res = http | 105 | let res = http |
| 106 | .post_form( | 106 | .post_form( |
| @@ -272,8 +272,8 @@ async fn login(http: &Http, username: &str, password: &str) -> String { |
| 272 | | 272 | |
| 273 | /// Creates an access token through `/settings/tokens` and returns the token shown once. | 273 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 274 | async fn create_token(http: &Http, session: &str, name: &str) -> String { | 274 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 275 | - let page = http.get("/settings/tokens", Some(session)).await; | 275 | + let page = http.get("/settings/keys", Some(session)).await; |
| 276 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 276 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 277 | let csrf = input_value(&page.body(), "csrf"); | 277 | let csrf = input_value(&page.body(), "csrf"); |
| 278 | let res = http | 278 | let res = http |
| 279 | .post_form( | 279 | .post_form( |
| @@ -199,7 +199,7 @@ async fn csrf_from(http: &Http, path: &str, session: &str) -> String { |
| 199 | | 199 | |
| 200 | /// Creates an access token through `/settings/tokens` and returns the token shown once. | 200 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 201 | async fn create_token(http: &Http, session: &str, name: &str) -> String { | 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 | let res = http | 203 | let res = http |
| 204 | .post_form( | 204 | .post_form( |
| 205 | "/settings/tokens", | 205 | "/settings/tokens", |
| @@ -622,7 +622,7 @@ async fn fork_pull_waits_for_approval_and_runs_without_secrets() { |
| 622 | // Bob forks and changes the workflow on a branch. | 622 | // Bob forks and changes the workflow on a branch. |
| 623 | let bob = login(&b.http, "bob", BOB_PW).await; | 623 | let bob = login(&b.http, "bob", BOB_PW).await; |
| 624 | let bob_token = create_token(&b.http, &bob, "bob-token").await; | 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 | let fork = b | 626 | let fork = b |
| 627 | .http | 627 | .http |
| 628 | .post_form(&format!("{REPO_PATH}/fork"), &[("csrf", &csrf)], Some(&bob)) | 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 | .await; | 657 | .await; |
| 658 | assert_eq!(compare.status, 200, "GET compare"); | 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 | let open = b | 660 | let open = b |
| 661 | .http | 661 | .http |
| 662 | .post_form( | 662 | .post_form( |
| @@ -50,7 +50,10 @@ async fn snippets_page_follows_the_browser_language() { |
| 50 | assert_eq!(turkish.status().as_u16(), 200); | 50 | assert_eq!(turkish.status().as_u16(), 200); |
| 51 | let body = turkish.text().await.expect("read body"); | 51 | let body = turkish.text().await.expect("read body"); |
| 52 | assert!(body.contains("<html lang=\"tr\""), "html lang is tr"); | 52 | assert!(body.contains("<html lang=\"tr\""), "html lang is tr"); |
| 53 | - assert!(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 | assert!( | 57 | assert!( |
| 55 | body.contains("Gösterilecek parçacık yok."), | 58 | body.contains("Gösterilecek parçacık yok."), |
| 56 | "Turkish empty state" | 59 | "Turkish empty state" |
| @@ -64,6 +67,9 @@ async fn snippets_page_follows_the_browser_language() { |
| 64 | .await | 67 | .await |
| 65 | .expect("GET /snippets (en)"); | 68 | .expect("GET /snippets (en)"); |
| 66 | let body = english.text().await.expect("read body"); | 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 | assert!(body.contains("No snippets to show."), "English empty state"); | 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 | /// Creates an access token through `/settings/tokens` and returns the token shown once. | 143 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 144 | async fn create_token(http: &Http, session: &str, name: &str) -> String { | 144 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 145 | - let page = http.get_cookie("/settings/tokens", session).await; | 145 | + let page = http.get_cookie("/settings/keys", session).await; |
| 146 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 146 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 147 | let csrf = input_value(&page.body, "csrf"); | 147 | let csrf = input_value(&page.body, "csrf"); |
| 148 | let res = http | 148 | let res = http |
| 149 | .post_form( | 149 | .post_form( |
| @@ -546,9 +546,14 @@ async fn suspended_user_token_is_refused_over_http_git() { |
| 546 | assert_eq!(list.status, 200, "GET /admin/users"); | 546 | assert_eq!(list.status, 200, "GET /admin/users"); |
| 547 | let doc = scraper::Html::parse_document(&list.body); | 547 | let doc = scraper::Html::parse_document(&list.body); |
| 548 | let link = scraper::Selector::parse("a[href^=\"/admin/users/\"]").expect("selector"); | 548 | let link = scraper::Selector::parse("a[href^=\"/admin/users/\"]").expect("selector"); |
| | 549 | + let name = scraper::Selector::parse(".name").expect("selector"); |
| 549 | let bob_href = doc | 550 | let bob_href = doc |
| 550 | .select(&link) | 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 | .and_then(|a| a.value().attr("href")) | 557 | .and_then(|a| a.value().attr("href")) |
| 553 | .expect("bob's admin link") | 558 | .expect("bob's admin link") |
| 554 | .to_owned(); | 559 | .to_owned(); |
| @@ -80,8 +80,8 @@ fn commit_file(repo: &Path, name: &str, message: &str) -> String { |
| 80 | | 80 | |
| 81 | /// Creates an access token through `/settings/tokens` and returns the token shown once. | 81 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 82 | async fn create_token(http: &Http, session: &str, name: &str) -> String { | 82 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 83 | - let page = http.get_cookie("/settings/tokens", session).await; | 83 | + let page = http.get_cookie("/settings/keys", session).await; |
| 84 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 84 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 85 | let csrf = input_value(&page.body, "csrf"); | 85 | let csrf = input_value(&page.body, "csrf"); |
| 86 | let res = http | 86 | let res = http |
| 87 | .post_form( | 87 | .post_form( |
| @@ -62,8 +62,8 @@ fn payload() -> Vec<u8> { |
| 62 | | 62 | |
| 63 | /// Creates an access token through `/settings/tokens` and returns the token shown once. | 63 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 64 | async fn create_token(http: &Http, session: &str, name: &str) -> String { | 64 | async fn create_token(http: &Http, session: &str, name: &str) -> String { |
| 65 | - let page = http.get("/settings/tokens", Some(session)).await; | 65 | + let page = http.get("/settings/keys", Some(session)).await; |
| 66 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 66 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 67 | let csrf = input_value(&page.body, "csrf"); | 67 | let csrf = input_value(&page.body, "csrf"); |
| 68 | let res = http | 68 | let res = http |
| 69 | .post_form( | 69 | .post_form( |
| @@ -141,7 +141,7 @@ async fn csrf_from(http: &Http, path: &str, session: &str) -> String { |
| 141 | | 141 | |
| 142 | /// Creates an access token through `/settings/tokens` and returns the token shown once. | 142 | /// Creates an access token through `/settings/tokens` and returns the token shown once. |
| 143 | async fn create_token(http: &Http, session: &str, name: &str) -> String { | 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 | let res = http | 145 | let res = http |
| 146 | .post_form( | 146 | .post_form( |
| 147 | "/settings/tokens", | 147 | "/settings/tokens", |
| @@ -169,8 +169,8 @@ async fn wait_for(what: &str, check: impl Fn() -> bool) { |
| 169 | | 169 | |
| 170 | /// The session's CSRF token, scraped from the token settings page. | 170 | /// The session's CSRF token, scraped from the token settings page. |
| 171 | async fn csrf_token(http: &Http, session: &str) -> String { | 171 | async fn csrf_token(http: &Http, session: &str) -> String { |
| 172 | - let page = http.get_cookie("/settings/tokens", session).await; | 172 | + let page = http.get_cookie("/settings/keys", session).await; |
| 173 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 173 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 174 | input_value(&page.body, "csrf") | 174 | input_value(&page.body, "csrf") |
| 175 | } | 175 | } |
| 176 | | 176 | |
| @@ -48,8 +48,8 @@ fn admin(config: &Path, args: &[&str]) -> Output { |
| 48 | | 48 | |
| 49 | /// The session's CSRF token, read from a page every signed-in user can open. | 49 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 50 | async fn csrf_for(http: &Http, session: &str) -> String { | 50 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 51 | - let page = http.get("/settings/tokens", Some(session)).await; | 51 | + let page = http.get("/settings/keys", Some(session)).await; |
| 52 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 52 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 53 | input_value(&page.body, "csrf") | 53 | input_value(&page.body, "csrf") |
| 54 | } | 54 | } |
| 55 | | 55 | |
| @@ -61,8 +61,8 @@ fn admin(config: &Path, args: &[&str]) -> Output { |
| 61 | | 61 | |
| 62 | /// The session's CSRF token, read from a page every signed-in user can open. | 62 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 63 | async fn csrf_for(http: &Http, session: &str) -> String { | 63 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 64 | - let page = http.get("/settings/tokens", Some(session)).await; | 64 | + let page = http.get("/settings/keys", Some(session)).await; |
| 65 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 65 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 66 | input_value(&page.body, "csrf") | 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 | /// The session's CSRF token, scraped from the token settings page. | 127 | /// The session's CSRF token, scraped from the token settings page. |
| 128 | async fn csrf_token(http: &Http, session: &str) -> String { | 128 | async fn csrf_token(http: &Http, session: &str) -> String { |
| 129 | - let page = http.get_cookie("/settings/tokens", session).await; | 129 | + let page = http.get_cookie("/settings/keys", session).await; |
| 130 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 130 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 131 | input_value(&page.body, "csrf") | 131 | input_value(&page.body, "csrf") |
| 132 | } | 132 | } |
| 133 | | 133 | |
| @@ -35,8 +35,8 @@ fn admin(config: &Path, args: &[&str]) -> Output { |
| 35 | | 35 | |
| 36 | /// The session's CSRF token, read from a page every signed-in user can open. | 36 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 37 | async fn csrf_for(http: &Http, session: &str) -> String { | 37 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 38 | - let page = http.get("/settings/tokens", Some(session)).await; | 38 | + let page = http.get("/settings/keys", Some(session)).await; |
| 39 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 39 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 40 | input_value(&page.body, "csrf") | 40 | input_value(&page.body, "csrf") |
| 41 | } | 41 | } |
| 42 | | 42 | |
| @@ -47,8 +47,8 @@ fn admin(config: &Path, args: &[&str]) { |
| 47 | | 47 | |
| 48 | /// The session's CSRF token, read from a page every signed-in user can open. | 48 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 49 | async fn csrf_for(http: &Http, session: &str) -> String { | 49 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 50 | - let page = http.get("/settings/tokens", Some(session)).await; | 50 | + let page = http.get("/settings/keys", Some(session)).await; |
| 51 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 51 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 52 | input_value(&page.body, "csrf") | 52 | input_value(&page.body, "csrf") |
| 53 | } | 53 | } |
| 54 | | 54 | |
| @@ -37,8 +37,8 @@ fn admin(config: &Path, args: &[&str]) -> Output { |
| 37 | | 37 | |
| 38 | /// The session's CSRF token, read from a page every signed-in user can open. | 38 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 39 | async fn csrf_for(http: &Http, session: &str) -> String { | 39 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 40 | - let page = http.get("/settings/tokens", Some(session)).await; | 40 | + let page = http.get("/settings/keys", Some(session)).await; |
| 41 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 41 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 42 | input_value(&page.body, "csrf") | 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 | /// of its summary pills. The built-in default-branch row has no rule behind it, so it is skipped. | 379 | /// of its summary pills. The built-in default-branch row has no rule behind it, so it is skipped. |
| 380 | fn branch_rows(body: &str) -> Vec<Vec<String>> { | 380 | fn branch_rows(body: &str) -> Vec<Vec<String>> { |
| 381 | let doc = scraper::Html::parse_document(body); | 381 | let doc = scraper::Html::parse_document(body); |
| 382 | - let cards = scraper::Selector::parse("details.rule-row:not(.rule-new)").expect("selector"); | 382 | + // Every rule row is a `details` with the pattern in its summary's name; the "+ New rule" row |
| 383 | - let pattern = scraper::Selector::parse("summary code.rule-pattern").expect("selector"); | 383 | + // has no pattern there, so it drops out. |
| 384 | - let pills = scraper::Selector::parse("summary .rule-pill").expect("selector"); | 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 | let text = |el: scraper::ElementRef| el.text().collect::<String>().trim().to_owned(); | 387 | let text = |el: scraper::ElementRef| el.text().collect::<String>().trim().to_owned(); |
| 386 | doc.select(&cards) | 388 | doc.select(&cards) |
| 387 | - .map(|card| { | 389 | + .filter_map(|card| { |
| 388 | - let mut cells: Vec<String> = | 390 | + let name = card.select(&pattern).next().map(text)?; |
| 389 | - card.select(&pattern).next().map(text).into_iter().collect(); | 391 | + let mut cells = vec![name]; |
| 390 | cells.extend(card.select(&pills).map(text)); | 392 | cells.extend(card.select(&pills).map(text)); |
| 391 | - cells | 393 | + Some(cells) |
| 392 | }) | 394 | }) |
| 393 | .collect() | 395 | .collect() |
| 394 | } | 396 | } |
| @@ -47,8 +47,8 @@ fn admin(config: &std::path::Path, args: &[&str]) { |
| 47 | | 47 | |
| 48 | /// The session's CSRF token, read from a page every signed-in user can open. | 48 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 49 | async fn csrf_for(http: &Http, session: &str) -> String { | 49 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 50 | - let page = http.get("/settings/tokens", Some(session)).await; | 50 | + let page = http.get("/settings/keys", Some(session)).await; |
| 51 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 51 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 52 | input_value(&page.body, "csrf") | 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 | 1 | +//! Black-box tests for the admin and settings section tabs: every page under `/admin` and |
| 2 | -//! `/settings` swaps the global links for the section's own list, marks the current entry with | 2 | +//! `/settings` shows the section's own tab row above the page, marks the current tab with |
| 3 | //! `aria-current="page"`, and has no " · "-joined link row. | 3 | //! `aria-current="page"`, and has no " · "-joined link row. |
| 4 | | 4 | |
| 5 | #![allow(dead_code)] | 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. | 133 | +/// The section's tab row as (href, aria-current) pairs. The row is the first `nav.tabs` in `main`, |
| 134 | -fn sidebar(body: &str) -> Vec<(String, Option<String>)> { | 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 | let doc = scraper::Html::parse_document(body); | 136 | let doc = scraper::Html::parse_document(body); |
| 136 | - let sel = scraper::Selector::parse("aside.shell-sidebar a.side-link").expect("selector"); | 137 | + let row = scraper::Selector::parse("main nav.tabs").expect("selector"); |
| 137 | - doc.select(&sel) | 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 | .map(|a| { | 141 | .map(|a| { |
| 139 | ( | 142 | ( |
| 140 | a.value().attr("href").unwrap_or("").to_owned(), | 143 | a.value().attr("href").unwrap_or("").to_owned(), |
| @@ -144,9 +147,11 @@ fn sidebar(body: &str) -> Vec<(String, Option<String>)> { |
| 144 | .collect() | 147 | .collect() |
| 145 | } | 148 | } |
| 146 | | 149 | |
| 147 | -fn assert_section(body: &str, current: &str, hrefs: &[&str]) { | 150 | +/// Checks the section's tab row: its first tab is the section's first, every tab in `hrefs` is |
| 148 | - let links = sidebar(body); | 151 | +/// there, and exactly one tab, the one at `current`, is marked. |
| 149 | - assert_eq!(links[0].0, "/", "first entry is the way back"); | 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 | for href in hrefs { | 155 | for href in hrefs { |
| 151 | assert!(links.iter().any(|(h, _)| h == href), "missing {href}"); | 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 | .iter() | 159 | .iter() |
| 155 | .filter(|(_, c)| c.as_deref() == Some("page")) | 160 | .filter(|(_, c)| c.as_deref() == Some("page")) |
| 156 | .collect(); | 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 | assert_eq!(marked[0].0, current); | 163 | assert_eq!(marked[0].0, current); |
| 159 | assert!(!body.contains("</a> · <a"), "no dot-separated link row"); | 164 | assert!(!body.contains("</a> · <a"), "no dot-separated link row"); |
| 160 | } | 165 | } |
| 161 | | 166 | |
| 162 | #[tokio::test] | 167 | #[tokio::test] |
| 163 | -async fn admin_pages_get_the_admin_sidebar() { | 168 | +async fn admin_pages_get_the_admin_tabs() { |
| 164 | let env = start().await; | 169 | let env = start().await; |
| 165 | let session = login(&env.http, "tahinli", PW).await; | 170 | let session = login(&env.http, "tahinli", PW).await; |
| 166 | let want = [ | 171 | let want = [ |
| @@ -176,31 +181,44 @@ async fn admin_pages_get_the_admin_sidebar() { |
| 176 | for path in want { | 181 | for path in want { |
| 177 | let page = env.http.get(path, Some(&session)).await; | 182 | let page = env.http.get(path, Some(&session)).await; |
| 178 | assert_eq!(page.status, 200, "GET {path}"); | 183 | assert_eq!(page.status, 200, "GET {path}"); |
| 179 | - assert_section(&page.body, path, &want); | 184 | + assert_tabs(&page.body, path, &want); |
| 180 | assert!( | 185 | assert!( |
| 181 | - !sidebar(&page.body).iter().any(|(h, _)| h == "/explore"), | 186 | + !tab_links(&page.body).iter().any(|(h, _)| h == "/explore"), |
| 182 | "global links are swapped out" | 187 | "global links are swapped out" |
| 183 | ); | 188 | ); |
| 184 | } | 189 | } |
| 185 | } | 190 | } |
| 186 | | 191 | |
| 187 | #[tokio::test] | 192 | #[tokio::test] |
| 188 | -async fn settings_pages_get_the_settings_sidebar() { | 193 | +async fn settings_pages_get_the_settings_tabs() { |
| 189 | let env = start().await; | 194 | let env = start().await; |
| 190 | let session = login(&env.http, "tahinli", PW).await; | 195 | let session = login(&env.http, "tahinli", PW).await; |
| 191 | - let want = [ | 196 | + let tabs = [ |
| 192 | "/settings/profile", | 197 | "/settings/profile", |
| 193 | - "/settings/keys", | | |
| 194 | - "/settings/gpg", | | |
| 195 | - "/settings/tokens", | | |
| 196 | - "/settings/sessions", | | |
| 197 | - "/settings/security", | | |
| 198 | - "/settings/notifications", | | |
| 199 | "/settings/appearance", | 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 | let page = env.http.get(path, Some(&session)).await; | 215 | let page = env.http.get(path, Some(&session)).await; |
| 203 | assert_eq!(page.status, 200, "GET {path}"); | 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 | html_attr(&page.body, "data-sidebar").as_deref(), | 727 | html_attr(&page.body, "data-sidebar").as_deref(), |
| 728 | Some("left") | 728 | Some("left") |
| 729 | ); | 729 | ); |
| 730 | - assert_eq!( | | |
| 731 | - checked_radio(&page.body, "sidebar_side").as_deref(), | | |
| 732 | - Some("left") | | |
| 733 | - ); | | |
| 734 | let csrf = input_value(&page.body, "csrf"); | 730 | let csrf = input_value(&page.body, "csrf"); |
| 735 | | 731 | |
| 736 | let saved = env | 732 | let saved = env |
| @@ -753,10 +749,6 @@ async fn appearance_sidebar_side_saves_and_renders_on_html() { |
| 753 | html_attr(&page.body, "data-sidebar").as_deref(), | 749 | html_attr(&page.body, "data-sidebar").as_deref(), |
| 754 | Some("right") | 750 | Some("right") |
| 755 | ); | 751 | ); |
| 756 | - assert_eq!( | | |
| 757 | - checked_radio(&page.body, "sidebar_side").as_deref(), | | |
| 758 | - Some("right") | | |
| 759 | - ); | | |
| 760 | | 752 | |
| 761 | // A save without the field keeps the side; a malformed side changes nothing. | 753 | // A save without the field keeps the side; a malformed side changes nothing. |
| 762 | let saved = env | 754 | let saved = env |
| @@ -37,8 +37,8 @@ fn admin(config: &Path, args: &[&str]) { |
| 37 | | 37 | |
| 38 | /// The session's CSRF token, read from a page every signed-in user can open. | 38 | /// The session's CSRF token, read from a page every signed-in user can open. |
| 39 | async fn csrf_for(http: &Http, session: &str) -> String { | 39 | async fn csrf_for(http: &Http, session: &str) -> String { |
| 40 | - let page = http.get("/settings/tokens", Some(session)).await; | 40 | + let page = http.get("/settings/keys", Some(session)).await; |
| 41 | - assert_eq!(page.status, 200, "GET /settings/tokens"); | 41 | + assert_eq!(page.status, 200, "GET /settings/keys"); |
| 42 | input_value(&page.body, "csrf") | 42 | input_value(&page.body, "csrf") |
| 43 | } | 43 | } |
| 44 | | 44 | |
| @@ -4090,7 +4090,12 @@ |
| 4090 | function paletteMeta(item) { | 4090 | function paletteMeta(item) { |
| 4091 | if (!item.meta || item.metaGen !== pal.scanGen) { | 4091 | if (!item.meta || item.metaGen !== pal.scanGen) { |
| 4092 | var read = (item.scan && pal.scan.texts[item.scan]) || []; | 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 | item.metaGen = pal.scanGen; | 4099 | item.metaGen = pal.scanGen; |
| 4095 | } | 4100 | } |
| 4096 | return item.meta; | 4101 | return item.meta; |
| @@ -4304,7 +4309,8 @@ |
| 4304 | m.terms.forEach(function (term) { | 4309 | m.terms.forEach(function (term) { |
| 4305 | var raw = paletteField(t, term); | 4310 | var raw = paletteField(t, term); |
| 4306 | if (raw >= PALETTE_EXACT) { exact = true; } | 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 | if (!best && paletteInOrder(t, m.label.s)) { best = 1; } | 4315 | if (!best && paletteInOrder(t, m.label.s)) { best = 1; } |
| 4310 | if (why) { item.why = why; } | 4316 | if (why) { item.why = why; } |
| @@ -4338,7 +4344,7 @@ |
| 4338 | best = Math.max(best, paletteField(fq, m.label)); | 4344 | best = Math.max(best, paletteField(fq, m.label)); |
| 4339 | // The words side by side in one sentence say more than the same words all over the page. | 4345 | // The words side by side in one sentence say more than the same words all over the page. |
| 4340 | m.terms.some(function (term) { | 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 | best += 1; | 4348 | best += 1; |
| 4343 | item.why = term.text; | 4349 | item.why = term.text; |
| 4344 | item.near = false; | 4350 | item.near = false; |
| @@ -4358,7 +4364,7 @@ |
| 4358 | var href = base + '/' + p.path; | 4364 | var href = base + '/' + p.path; |
| 4359 | if ((p.admin && !admin) || seen[href]) { return; } | 4365 | if ((p.admin && !admin) || seen[href]) { return; } |
| 4360 | seen[href] = true; | 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 | if (current) { add(current.name, current.href, current.admin); } | 4370 | if (current) { add(current.name, current.href, current.admin); } |
| @@ -4507,7 +4513,7 @@ |
| 4507 | if (!Object.prototype.hasOwnProperty.call(pal.str.heads, item.kind)) { return; } | 4513 | if (!Object.prototype.hasOwnProperty.call(pal.str.heads, item.kind)) { return; } |
| 4508 | var s; | 4514 | var s; |
| 4509 | if (!pathMode) { s = paletteScore(q, item); } | 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 | else { s = words && item.kind !== 'file' && item.kind !== 'action' ? Math.min(2.9, paletteScore(words, item)) : 0; } | 4517 | else { s = words && item.kind !== 'file' && item.kind !== 'action' ? Math.min(2.9, paletteScore(words, item)) : 0; } |
| 4512 | // Above a path match (3), which would otherwise fill the list and cut the actions off. Text typed | 4518 | // Above a path match (3), which would otherwise fill the list and cut the actions off. Text typed |
| 4513 | // after the opening path searches the page's actions by name. | 4519 | // after the opening path searches the page's actions by name. |
| @@ -24,6 +24,7 @@ use crate::live::{Topic, stream_changes}; |
| 24 | use crate::pages::admin_users::admin_only; | 24 | use crate::pages::admin_users::admin_only; |
| 25 | use crate::pages::issues_list::stamp_unix; | 25 | use crate::pages::issues_list::stamp_unix; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| | 27 | +use crate::views::parts::post_act; |
| 27 | use crate::views::{enc, rel_time, shell}; | 28 | use crate::views::{enc, rel_time, shell}; |
| 28 | | 29 | |
| 29 | /// Runs shown on the page. | 30 | /// Runs shown on the page. |
| @@ -143,136 +144,78 @@ async fn backups_view( |
| 143 | matches!(running, Some(RunKind::Fsck)).then(|| g::running_line(lang, RunKind::Fsck)); | 144 | matches!(running, Some(RunKind::Fsck)).then(|| g::running_line(lang, RunKind::Fsck)); |
| 144 | Ok(view! { | 145 | Ok(view! { |
| 145 | <div data-live="/admin/backups/events"> | 146 | <div data-live="/admin/backups/events"> |
| 146 | - <section class="page-head"> | 147 | + <h1 class="sr-only">(g::t(lang, K::Backups))</h1> |
| 147 | - <h1>(g::t(lang, K::Backups))</h1> | 148 | + <p class="hint">(g::t(lang, K::BackupsIntro))</p> |
| 148 | - </section> | | |
| 149 | - <p class="muted page-lede">(g::t(lang, K::BackupsIntro))</p> | | |
| 150 | if let Some(message) = notice { | 149 | if let Some(message) = notice { |
| 151 | - <section class="card notice" role="status"> | 150 | + <p class="state" role="status">(message.as_str())</p> |
| 152 | - <p>(message.as_str())</p> | | |
| 153 | - </section> | | |
| 154 | } | 151 | } |
| 155 | - <section class="card rows-pane" aria-label=(g::t(lang, K::Settings))> | 152 | + <section class="sec"> |
| 156 | if settings.enabled { | 153 | if settings.enabled { |
| 157 | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Configuration", "Yapılandırma"))</h2> | 154 | + <h2>(crate::pages::passkeys::s(lang, "Configuration", "Yapılandırma"))</h2> |
| 158 | - <div class="row-line"> | 155 | + <div class="line" data-kb-row=""> |
| 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> | 156 | + <span class="name">(g::t(lang, K::Directory))</span> |
| 160 | - <div class="row-main"> | 157 | + <span class="val"><code>(settings.dir.as_str())</code></span> |
| 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> | | |
| 164 | </div> | 158 | </div> |
| 165 | - <div class="row-line"> | 159 | + <div class="line" data-kb-row=""> |
| 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> | 160 | + <span class="name">(g::t(lang, K::BackupInterval))</span> |
| 167 | - <div class="row-main"> | 161 | + <span class="val">(settings.interval.as_str())</span> |
| 168 | - <h2 class="row-title">(g::t(lang, K::BackupInterval))</h2> | | |
| 169 | - <p class="row-status">(settings.interval.as_str())</p> | | |
| 170 | - </div> | | |
| 171 | </div> | 162 | </div> |
| 172 | - <div class="row-line"> | 163 | + <div class="line" data-kb-row=""> |
| 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> | 164 | + <span class="name">(g::t(lang, K::Retention))</span> |
| 174 | - <div class="row-main"> | 165 | + <span class="val">(settings.keep.as_str())</span> |
| 175 | - <h2 class="row-title">(g::t(lang, K::Retention))</h2> | | |
| 176 | - <p class="row-status">(settings.keep.as_str())</p> | | |
| 177 | - </div> | | |
| 178 | </div> | 166 | </div> |
| 179 | - <div class="row-line"> | 167 | + <div class="line" data-kb-row=""> |
| 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> | 168 | + <span class="name">(g::t(lang, K::Fsck))</span> |
| 181 | - <div class="row-main"> | 169 | + <span class="val">(settings.fsck_interval.as_str())</span> |
| 182 | - <h2 class="row-title">(g::t(lang, K::Fsck))</h2> | | |
| 183 | - <p class="row-status">(settings.fsck_interval.as_str())</p> | | |
| 184 | - </div> | | |
| 185 | </div> | 170 | </div> |
| 186 | - <div class="row-line"> | 171 | + <div class="line" data-kb-row=""> |
| 187 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12h4l2-5 4 10 2-5h6"/></svg> | 172 | + <span class="name">(g::t(lang, K::Healthcheck))</span> |
| 188 | - <div class="row-main"> | 173 | + <span class="val">(settings.healthcheck.as_str())</span> |
| 189 | - <h2 class="row-title">(g::t(lang, K::Healthcheck))</h2> | | |
| 190 | - <p class="row-status">(settings.healthcheck.as_str())</p> | | |
| 191 | - </div> | | |
| 192 | </div> | 174 | </div> |
| 193 | } else { | 175 | } else { |
| 194 | - <div class="row-line"> | 176 | + <h2>(g::t(lang, K::Settings))</h2> |
| 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> | 177 | + <p class="state">(g::t(lang, K::ScheduledBackupsOff))</p> |
| 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> | | |
| 201 | } | 178 | } |
| 202 | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Run now", "Şimdi çalıştır"))</h2> | 179 | + </section> |
| 203 | - <div class="row-line"> | 180 | + <section class="sec"> |
| 204 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4l13 8-13 8z"/></svg> | 181 | + <h2>(crate::pages::passkeys::s(lang, "Run now", "Şimdi çalıştır"))</h2> |
| 205 | - <div class="row-main"> | 182 | + if let Some(line) = backup_running { |
| 206 | - <h2 class="row-title">(g::kind_name(lang, RunKind::Backup))</h2> | 183 | + <p class="state">(line)</p> |
| 207 | - if let Some(line) = backup_running { | 184 | + } |
| 208 | - <p class="row-status">(line)</p> | 185 | + if let Some(line) = fsck_running { |
| 209 | - } | 186 | + <p class="state">(line)</p> |
| 210 | - </div> | 187 | + } |
| 211 | - <form id="run-backup" method="post" action="/admin/backups/run" class="row-form"> | 188 | + <div class="acts"> |
| 212 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 189 | + <form id="run-backup" method="post" action="/admin/backups/run" class="act-form"> |
| 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"> | | |
| 225 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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 | </form> | 192 | </form> |
| | 193 | + post_act(label: g::t(lang, K::RunFsckNow), action: "/admin/backups/fsck", csrf: csrf.as_str()) |
| 228 | </div> | 194 | </div> |
| 229 | </section> | 195 | </section> |
| 230 | - if rows.is_empty() { | 196 | + <section class="sec"> |
| 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"> | | |
| 242 | <h2>(g::t(lang, K::RecentRuns))</h2> | 197 | <h2>(g::t(lang, K::RecentRuns))</h2> |
| 243 | - <div class="table-wrap"> | 198 | + if rows.is_empty() { |
| 244 | - <table class="table queue-table"> | 199 | + <p class="state">(g::t(lang, K::NoRunsYet))</p> |
| 245 | - <thead> | 200 | + <p class="hint">(g::t(lang, K::BackupsEmptyHint))</p> |
| 246 | - <tr> | 201 | + } else { |
| 247 | - <th>(g::t(lang, K::TableKind))</th> | 202 | + for row in rows.into_iter() { |
| 248 | - <th>(g::t(lang, K::TableTrigger))</th> | 203 | + <div class="line" data-kb-row=""> |
| 249 | - <th>(g::t(lang, K::TableStarted))</th> | 204 | + <span class="name">(row.kind.as_str()) " · " (row.trigger.as_str())</span> |
| 250 | - <th>(g::t(lang, K::TableDuration))</th> | 205 | + <span class="val">(row.status.as_str()) " · " rel_time(lang: lang, stamp: row.started.as_str())</span> |
| 251 | - <th>(g::t(lang, K::TableSize))</th> | 206 | + </div> |
| 252 | - <th>(g::t(lang, K::TableResult))</th> | 207 | + <p class="hint"> |
| 253 | - </tr> | 208 | + (row.duration.as_str()) |
| 254 | - </thead> | 209 | + if !row.size.is_empty() { |
| 255 | - <tbody> | 210 | + " · " (row.size.as_str()) |
| 256 | - for row in rows.into_iter() { | 211 | + } |
| 257 | - <tr> | 212 | + </p> |
| 258 | - <td data-label=(g::t(lang, K::TableKind))>(row.kind.as_str())</td> | 213 | + if !row.detail.is_empty() { |
| 259 | - <td data-label=(g::t(lang, K::TableTrigger))>(row.trigger.as_str())</td> | 214 | + <p class="hint bad">(row.detail.as_str())</p> |
| 260 | - <td class="small" data-label=(g::t(lang, K::TableStarted))>rel_time(lang: lang, stamp: row.started.as_str())</td> | 215 | + } |
| 261 | - <td class="small" data-label=(g::t(lang, K::TableDuration))>(row.duration.as_str())</td> | 216 | + } |
| 262 | - <td class="small" data-label=(g::t(lang, K::TableSize))>(row.size.as_str())</td> | 217 | + } |
| 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> | | |
| 274 | </section> | 218 | </section> |
| 275 | - } | | |
| 276 | </div> | 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 | 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 card. Every number is a cheap query or a short external probe | 2 | +//! disk's usage bar, and a services topic. Every number is a cheap query or a short external probe |
| 3 | //! (`df`), so there is no polling; reloading the page, or opening it again, reads fresh values. The | 3 | //! (`df`), so there is no polling; reloading the page, or opening it again, reads fresh values. The |
| 4 | //! tree size of the repos (`du`) walks every repo, so a background task caches it (see | 4 | //! tree size of the repos (`du`) walks every repo, so a background task caches it (see |
| 5 | //! [`spawn_repo_size`]) and the page only reads the cache. Non-admins get 404. | 5 | //! [`spawn_repo_size`]) and the page only reads the cache. Non-admins get 404. |
| @@ -84,7 +84,6 @@ struct Usage { |
| 84 | /// The icon a status row shows. | 84 | /// The icon a status row shows. |
| 85 | #[derive(Clone, Copy)] | 85 | #[derive(Clone, Copy)] |
| 86 | enum Glyph { | 86 | enum Glyph { |
| 87 | - Disk, | | |
| 88 | Database, | 87 | Database, |
| 89 | Folder, | 88 | Folder, |
| 90 | Archive, | 89 | Archive, |
| @@ -98,9 +97,6 @@ enum Glyph { |
| 98 | #[component] | 97 | #[component] |
| 99 | async fn glyph(kind: Glyph) -> Result<impl View> { | 98 | async fn glyph(kind: Glyph) -> Result<impl View> { |
| 100 | Ok(view! { | 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 | if matches!(kind, Glyph::Database) { | 100 | if matches!(kind, Glyph::Database) { |
| 105 | <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> | 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 | Ok(view! { | 554 | Ok(view! { |
| 559 | <div data-live="/admin/health/events" class="health-page"> | 555 | <div data-live="/admin/health/events" class="health-page"> |
| 560 | - <section class="page-head"> | 556 | + <h1 class="sr-only">(at(lang, A::Health))</h1> |
| 561 | - <h1>(at(lang, A::Health))</h1> | 557 | + <p class="state"> |
| 562 | - </section> | | |
| 563 | - <p class="health-summary page-lede"> | | |
| 564 | <span class=(format!("health-dot {}", summary_dot.class()))></span> | 558 | <span class=(format!("health-dot {}", summary_dot.class()))></span> |
| 565 | - (summary) | 559 | + " " (summary) |
| 566 | </p> | 560 | </p> |
| 567 | - <p class="muted small page-lede">(at(lang, A::HealthIntro))</p> | 561 | + <p class="hint">(at(lang, A::HealthIntro))</p> |
| 568 | if count > 0 { | 562 | if count > 0 { |
| 569 | - <section class="admin-alerts" role="alert"> | 563 | + <section class="sec" role="alert"> |
| 570 | <h2>(alert_text::banner_heading(lang, count))</h2> | 564 | <h2>(alert_text::banner_heading(lang, count))</h2> |
| 571 | - <ul> | 565 | + for a in alerts.into_iter() { |
| 572 | - for a in alerts.into_iter() { | 566 | + <div class="line" data-kb-row=""> |
| 573 | - <li> | 567 | + <span class="name">(a.title.as_str())</span> |
| 574 | - <strong>(a.title.as_str())</strong> | 568 | + <span class="val">since_line(lang: lang, stamp: a.stamp.as_str())</span> |
| 575 | - <span class="muted small">since_line(lang: lang, stamp: a.stamp.as_str())</span> | 569 | + </div> |
| 576 | - if !a.body.is_empty() { | 570 | + if !a.body.is_empty() { |
| 577 | - <div class="small">(a.body.as_str())</div> | 571 | + <p class="hint">(a.body.as_str())</p> |
| 578 | - } | | |
| 579 | - </li> | | |
| 580 | } | 572 | } |
| 581 | - </ul> | 573 | + } |
| 582 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | 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 | </section> | 578 | </section> |
| 585 | } | 579 | } |
| 586 | - <section class="card rows-pane" aria-label=(at(lang, A::Storage))> | 580 | + <section class="sec"> |
| 587 | - <div class="row-line"> | 581 | + <h2>(at(lang, A::Storage))</h2> |
| 588 | - glyph(kind: Glyph::Disk) | 582 | + if let Some(u) = usage { |
| 589 | - <div class="row-main"> | 583 | + <p class="state"><strong>(u.used.as_str())</strong> " " (at(lang, A::DiskUsed)) " · " (u.free_of_total.as_str())</p> |
| 590 | - <h2 class="row-title">(at(lang, A::Storage))</h2> | 584 | + <progress class=(if u.bad { "meter bad" } else { "meter" }) max="100" value=(u.pct.to_string())></progress> |
| 591 | - if let Some(u) = usage { | 585 | + <p class="hint health-path">(u.path.as_str())</p> |
| 592 | - <p class="row-status"><strong>(u.used.as_str())</strong> " " (at(lang, A::DiskUsed)) " · " (u.free_of_total.as_str())</p> | 586 | + } else { |
| 593 | - <progress class=(if u.bad { "meter bad" } else { "meter" }) max="100" value=(u.pct.to_string())></progress> | 587 | + <p class="state">(at(lang, A::Unavailable))</p> |
| 594 | - <p class="row-status muted small health-path">(u.path.as_str())</p> | 588 | + } |
| 595 | - } else { | | |
| 596 | - <p class="row-status">(at(lang, A::Unavailable))</p> | | |
| 597 | - } | | |
| 598 | - </div> | | |
| 599 | - </div> | | |
| 600 | for f in facts.into_iter() { | 589 | for f in facts.into_iter() { |
| 601 | - <div class="row-line"> | 590 | + <div class="line" data-kb-row=""> |
| 602 | - glyph(kind: f.glyph) | 591 | + <span class="name">glyph(kind: f.glyph) (f.label)</span> |
| 603 | - <div class="row-main"> | 592 | + <span class=(format!("val {}", f.dot.value_class()))>(f.value.as_str())</span> |
| 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> | | |
| 610 | </div> | 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 | </section> | 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 | for s in services.into_iter() { | 602 | for s in services.into_iter() { |
| 615 | - <div class="row-line"> | 603 | + <div class="line" data-kb-row=""> |
| 616 | - glyph(kind: s.glyph) | 604 | + <span class="name">glyph(kind: s.glyph) (s.label)</span> |
| 617 | - <div class="row-main"> | 605 | + <span class="val"> |
| 618 | - <h2 class="row-title">(s.label)</h2> | 606 | + <span class=(format!("health-dot {}", s.dot.class()))></span> <span class=(s.dot.value_class())>(s.value.as_str())</span> |
| 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> | 607 | + if !s.detail.is_empty() { |
| 620 | - if !s.detail.is_empty() { | 608 | + " · " (s.detail.as_str()) |
| 621 | - " · " (s.detail.as_str()) | 609 | + } |
| 622 | - } | 610 | + if let Some(stamp) = s.stamp.as_deref() { |
| 623 | - if let Some(stamp) = s.stamp.as_deref() { | 611 | + " · " rel_time(lang: lang, stamp: stamp) |
| 624 | - " · " rel_time(lang: lang, stamp: stamp) | 612 | + } |
| 625 | - } | 613 | + </span> |
| 626 | - </p> | | |
| 627 | - </div> | | |
| 628 | </div> | 614 | </div> |
| 629 | } | 615 | } |
| 630 | </section> | 616 | </section> |
| 631 | - <p class="muted small health-meta">(meta.as_str())</p> | | |
| 632 | </div> | 617 | </div> |
| 633 | }) | 618 | }) |
| 634 | } | 619 | } |
| @@ -33,7 +33,8 @@ use crate::mail::{enqueue, live, templates}; |
| 33 | use crate::pages::admin_users::admin_only; | 33 | use crate::pages::admin_users::admin_only; |
| 34 | use crate::pages::ci_runs::{changed_event, events_response}; | 34 | use crate::pages::ci_runs::{changed_event, events_response}; |
| 35 | use crate::state::AppState; | 35 | use crate::state::AppState; |
| 36 | -use crate::views::{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 | /// Rows shown in the queue at most. | 39 | /// Rows shown in the queue at most. |
| 39 | const LIST_LIMIT: u32 = 100; | 40 | const LIST_LIMIT: u32 = 100; |
| @@ -72,7 +73,7 @@ struct FilterChip { |
| 72 | href: String, | 73 | href: String, |
| 73 | label: &'static str, | 74 | label: &'static str, |
| 74 | count: u32, | 75 | count: u32, |
| 75 | - class: &'static str, | 76 | + current: bool, |
| 76 | } | 77 | } |
| 77 | | 78 | |
| 78 | /// The queue tab: the filter chips, the rows and the state the filter is on, for the forms. | 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 | fn row_view(entry: &OutboxEntry, now: &str, lang: Lang) -> QueueRow { | 120 | fn row_view(entry: &OutboxEntry, now: &str, lang: Lang) -> QueueRow { |
| 128 | let state = entry.state_at(now); | 121 | let state = entry.state_at(now); |
| 129 | QueueRow { | 122 | QueueRow { |
| @@ -154,14 +147,14 @@ async fn queue_data( |
| 154 | href: "/admin/mail?tab=queue".to_owned(), | 147 | href: "/admin/mail?tab=queue".to_owned(), |
| 155 | label: g::t(lang, K::MailFilterAll), | 148 | label: g::t(lang, K::MailFilterAll), |
| 156 | count: total, | 149 | count: total, |
| 157 | - class: tab_class(filter.is_none()), | 150 | + current: filter.is_none(), |
| 158 | }]; | 151 | }]; |
| 159 | for (kind, count) in counts { | 152 | for (kind, count) in counts { |
| 160 | chips.push(FilterChip { | 153 | chips.push(FilterChip { |
| 161 | href: format!("/admin/mail?tab=queue&state={}", kind.as_str()), | 154 | href: format!("/admin/mail?tab=queue&state={}", kind.as_str()), |
| 162 | label: g::mail_state(lang, kind), | 155 | label: g::mail_state(lang, kind), |
| 163 | count, | 156 | count, |
| 164 | - class: tab_class(filter == Some(kind)), | 157 | + current: filter == Some(kind), |
| 165 | }); | 158 | }); |
| 166 | } | 159 | } |
| 167 | let rows = state | 160 | let rows = state |
| @@ -220,165 +213,128 @@ async fn mail_view( |
| 220 | g::t(lang, K::NoPasswordStored) | 213 | g::t(lang, K::NoPasswordStored) |
| 221 | }; | 214 | }; |
| 222 | let settings_on = data.tab == Tab::Settings; | 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 | let filter_param = data | 216 | let filter_param = data |
| 226 | .queue | 217 | .queue |
| 227 | .as_ref() | 218 | .as_ref() |
| 228 | .map(|q| q.filter_param.clone()) | 219 | .map(|q| q.filter_param.clone()) |
| 229 | .unwrap_or_default(); | 220 | .unwrap_or_default(); |
| 230 | Ok(view! { | 221 | Ok(view! { |
| 231 | - <section class="page-head"> | 222 | + <h1 class="sr-only">(g::t(lang, K::Mail))</h1> |
| 232 | - <h1>(g::t(lang, K::Mail))</h1> | 223 | + <nav class="sub" aria-label=(g::t(lang, K::Mail))> |
| 233 | - </section> | 224 | + <a href="/admin/mail" aria-current=(settings_on.then_some("page"))>(g::t(lang, K::MailTabSettings))</a> |
| 234 | - <p class="muted page-lede">(g::t(lang, K::MailIntro))</p> | 225 | + <a href="/admin/mail?tab=queue" aria-current=((!settings_on).then_some("page"))>(g::t(lang, K::MailTabQueue))</a> |
| 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> | | |
| 238 | </nav> | 226 | </nav> |
| | 227 | + <p class="hint">(g::t(lang, K::MailIntro))</p> |
| 239 | if let Some(message) = notice { | 228 | if let Some(message) = notice { |
| 240 | - <section class="card notice" role="status"> | 229 | + <p class="state" role="status">(message.as_str())</p> |
| 241 | - <p>(message.as_str())</p> | | |
| 242 | - </section> | | |
| 243 | } | 230 | } |
| 244 | if settings_on { | 231 | if settings_on { |
| 245 | // Saved by any admin session: the stream re-renders the settings with the same signal | 232 | // Saved by any admin session: the stream re-renders the settings with the same signal |
| 246 | // as the queue (the save bumps it too), and the form keeps what was typed. | 233 | // as the queue (the save bumps it too), and the form keeps what was typed. |
| 247 | <div data-live="/admin/mail/events"> | 234 | <div data-live="/admin/mail/events"> |
| 248 | - <section class="card rows-pane"> | 235 | + <form method="post" action="/admin/mail"> |
| 249 | - <div class="row-line"> | 236 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 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> | 237 | + <section class="sec" id="smtp"> |
| 251 | - <div class="row-main"> | 238 | + <h2>(g::t(lang, K::SmtpServer))</h2> |
| 252 | - <h2 class="row-title">(g::t(lang, K::SmtpServer))</h2> | 239 | + <p class="hint">(g::t(lang, K::MailTransportNote))</p> |
| 253 | - <p class="row-status">(g::t(lang, K::MailTransportNote))</p> | 240 | + <p class="hint">(g::t(lang, K::MailTransportInUse)) " " <code>(data.transport)</code></p> |
| 254 | - <p class="row-status">(g::t(lang, K::MailTransportInUse)) " " <code>(data.transport)</code></p> | 241 | + <div class="fields"> |
| 255 | - </div> | 242 | + <div class="field"> |
| 256 | - </div> | 243 | + <label for="mail-host">(g::t(lang, K::MailHost))</label> |
| 257 | - <form method="post" action="/admin/mail"> | 244 | + <input id="mail-host" type="text" name="host" value=(data.host.as_str()) maxlength="253" autocomplete="off"> |
| 258 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 245 | + </div> |
| 259 | - <label class="row-line row-field"> | 246 | + <div class="field"> |
| 260 | - <span class="row-main"><span class="row-title">(g::t(lang, K::MailHost))</span></span> | 247 | + <label for="mail-port">(g::t(lang, K::MailPort))</label> |
| 261 | - <span class="row-control"><input type="text" name="host" value=(data.host.as_str()) maxlength="253" autocomplete="off"></span> | 248 | + <input id="mail-port" type="number" name="port" value=(data.port.as_str()) min="1" max="65535"> |
| 262 | - </label> | 249 | + </div> |
| 263 | - <label class="row-line row-field"> | 250 | + <div class="field"> |
| 264 | - <span class="row-main"><span class="row-title">(g::t(lang, K::MailPort))</span></span> | 251 | + <label for="mail-security">(i18n::t(lang, Key::Security))</label> |
| 265 | - <span class="row-control"><input type="number" name="port" value=(data.port.as_str()) min="1" max="65535"></span> | 252 | + <select id="mail-security" name="security"> |
| 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"> | | |
| 271 | <option value="starttls" selected=(starttls)>"STARTTLS"</option> | 253 | <option value="starttls" selected=(starttls)>"STARTTLS"</option> |
| 272 | <option value="tls" selected=(tls)>"TLS"</option> | 254 | <option value="tls" selected=(tls)>"TLS"</option> |
| 273 | <option value="none" selected=(plain)>(g::t(lang, K::SecurityNone))</option> | 255 | <option value="none" selected=(plain)>(g::t(lang, K::SecurityNone))</option> |
| 274 | </select> | 256 | </select> |
| 275 | - </span> | 257 | + </div> |
| 276 | - </label> | 258 | + <div class="field"> |
| 277 | - <label class="row-line row-field"> | 259 | + <label for="mail-username">(i18n::t(lang, Key::Username))</label> |
| 278 | - <span class="row-main"><span class="row-title">(i18n::t(lang, Key::Username))</span></span> | 260 | + <input id="mail-username" type="text" name="username" value=(data.username.as_str()) maxlength="256" autocomplete="off"> |
| 279 | - <span class="row-control"><input type="text" name="username" value=(data.username.as_str()) maxlength="256" autocomplete="off"></span> | 261 | + </div> |
| 280 | - </label> | 262 | + <div class="field"> |
| 281 | - <label class="row-line row-field"> | 263 | + <label for="mail-password">(i18n::t(lang, Key::Password))</label> |
| 282 | - <span class="row-main"> | 264 | + <input id="mail-password" type="password" name="password" autocomplete="new-password" maxlength="1024"> |
| 283 | - <span class="row-title">(i18n::t(lang, Key::Password))</span> | 265 | + <p class="hint">(password_hint)</p> |
| 284 | - <span class="row-status">(password_hint)</span> | 266 | + </div> |
| 285 | - </span> | 267 | + </div> |
| 286 | - <span class="row-control"><input type="password" name="password" autocomplete="new-password" maxlength="1024"></span> | 268 | + </section> |
| 287 | - </label> | 269 | + <section class="sec"> |
| 288 | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Sending", "Gönderim"))</h2> | 270 | + <h2>(crate::pages::passkeys::s(lang, "Sending", "Gönderim"))</h2> |
| 289 | - <label class="row-line row-field"> | 271 | + <div class="fields"> |
| 290 | - <span class="row-main"><span class="row-title">(g::t(lang, K::FromAddress))</span></span> | 272 | + <div class="field"> |
| 291 | - <span class="row-control"><input type="email" name="from_addr" value=(data.from_addr.as_str()) maxlength="254"></span> | 273 | + <label for="mail-from-addr">(g::t(lang, K::FromAddress))</label> |
| 292 | - </label> | 274 | + <input id="mail-from-addr" type="email" name="from_addr" value=(data.from_addr.as_str()) maxlength="254"> |
| 293 | - <label class="row-line row-field"> | 275 | + </div> |
| 294 | - <span class="row-main"><span class="row-title">(g::t(lang, K::FromName))</span></span> | 276 | + <div class="field"> |
| 295 | - <span class="row-control"><input type="text" name="from_name" value=(data.from_name.as_str()) maxlength="100"></span> | 277 | + <label for="mail-from-name">(g::t(lang, K::FromName))</label> |
| 296 | - </label> | 278 | + <input id="mail-from-name" type="text" name="from_name" value=(data.from_name.as_str()) maxlength="100"> |
| 297 | - <label class="row-line row-field"> | 279 | + </div> |
| 298 | - <span class="row-main"><span class="row-title">(g::t(lang, K::SendMailCheckbox))</span></span> | 280 | + <label class="switch"> |
| 299 | - <span class="row-control"><input type="checkbox" name="enabled" value="on" checked=(data.enabled)></span> | 281 | + <input type="checkbox" name="enabled" value="on" checked=(data.enabled)> |
| 300 | - </label> | 282 | + <span>(g::t(lang, K::SendMailCheckbox))</span> |
| 301 | - <div class="row-foot"> | 283 | + </label> |
| 302 | <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> | 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 | </div> | 285 | </div> |
| 305 | - </form> | 286 | + <div class="acts"> |
| 306 | - <form id="mail-test" method="post" action="/admin/mail/test"> | 287 | + <button type="submit" form="mail-test" class="act">(g::t(lang, K::SendTestMailToMe))</button> |
| 307 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 288 | + </div> |
| 308 | - </form> | 289 | + </section> |
| 309 | - </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 | </div> | 294 | </div> |
| 311 | } else if let Some(queue) = data.queue { | 295 | } else if let Some(queue) = data.queue { |
| 312 | - <section class="card fit-pane"> | 296 | + <nav class="sub" aria-label=(g::t(lang, K::MailTabQueue))> |
| 313 | - <p class="muted small">(g::t(lang, K::MailQueueIntro))</p> | 297 | + for chip in queue.chips.into_iter() { |
| 314 | - <div class="mail-filters"> | 298 | + <a href=(chip.href.as_str()) aria-current=(chip.current.then_some("page"))>(chip.label) " (" (chip.count) ")"</a> |
| 315 | - for chip in queue.chips.into_iter() { | 299 | + } |
| 316 | - <a class=(chip.class) href=(chip.href.as_str())>(chip.label) " " <span class="tab-count">(chip.count)</span></a> | 300 | + </nav> |
| 317 | - } | 301 | + <p class="hint">(g::t(lang, K::MailQueueIntro))</p> |
| 318 | - </div> | 302 | + <div data-live="/admin/mail/events"> |
| 319 | - <div data-live="/admin/mail/events"> | 303 | + if queue.rows.is_empty() { |
| 320 | - if queue.rows.is_empty() { | 304 | + if queue.filter_param.is_empty() { |
| 321 | - if queue.filter_param.is_empty() { | 305 | + <p class="state">(g::t(lang, K::MailQueueEmpty))</p> |
| 322 | - empty_state(title: g::t(lang, K::MailQueueEmpty)) | | |
| 323 | - } else { | | |
| 324 | - empty_state(title: g::t(lang, K::MailNothingMatches)) | | |
| 325 | - } | | |
| 326 | } else { | 306 | } else { |
| 327 | - <div class="table-wrap"> | 307 | + <p class="state">(g::t(lang, K::MailNothingMatches))</p> |
| 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> | | |
| 379 | } | 308 | } |
| 380 | - </div> | 309 | + } else { |
| 381 | - </section> | 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 | use crate::live::{Topic, stream_changes}; | 27 | use crate::live::{Topic, stream_changes}; |
| 28 | use crate::pages::admin_users::admin_only; | 28 | use crate::pages::admin_users::admin_only; |
| 29 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| | 30 | +use crate::views::parts::post_act; |
| 30 | use crate::views::{enc, rel_time_or_never, shell}; | 31 | use crate::views::{enc, rel_time_or_never, shell}; |
| 31 | | 32 | |
| 32 | #[query_params(error = bad_request)] | 33 | #[query_params(error = bad_request)] |
| @@ -189,106 +190,72 @@ async fn replication_view( |
| 189 | ) -> Result<impl View> { | 190 | ) -> Result<impl View> { |
| 190 | Ok(view! { | 191 | Ok(view! { |
| 191 | <div data-live="/admin/replication/events"> | 192 | <div data-live="/admin/replication/events"> |
| 192 | - <section class="page-head"> | 193 | + <h1 class="sr-only">(g::t(lang, K::Replication))</h1> |
| 193 | - <h1>(g::t(lang, K::Replication))</h1> | 194 | + <p class="hint">(g::t(lang, K::ReplicationIntro))</p> |
| 194 | - </section> | | |
| 195 | - <p class="muted page-lede">(g::t(lang, K::ReplicationIntro))</p> | | |
| 196 | if let Some(message) = notice { | 195 | if let Some(message) = notice { |
| 197 | - <section class="card notice" role="status"> | 196 | + <p class="state" role="status">(message.as_str())</p> |
| 198 | - <p>(message.as_str())</p> | | |
| 199 | - </section> | | |
| 200 | } | 197 | } |
| 201 | - <section class="card rows-pane" aria-label=(g::t(lang, K::Standby))> | 198 | + if data.enabled { |
| 202 | - if data.enabled { | 199 | + <section class="sec"> |
| 203 | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Target and schedule", "Hedef ve zamanlama"))</h2> | 200 | + <h2>(crate::pages::passkeys::s(lang, "Target and schedule", "Hedef ve zamanlama"))</h2> |
| 204 | - <div class="row-line"> | 201 | + <div class="line" data-kb-row=""> |
| 205 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h13l-3-3M20 17H7l3 3"/></svg> | 202 | + <span class="name">(g::t(lang, K::ReplicationTarget))</span> |
| 206 | - <div class="row-main"> | 203 | + <span class="val"><code>(data.target.as_str())</code></span> |
| 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> | | |
| 210 | </div> | 204 | </div> |
| 211 | - <div class="row-line"> | 205 | + <div class="line" data-kb-row=""> |
| 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> | 206 | + <span class="name">(g::t(lang, K::Interval))</span> |
| 213 | - <div class="row-main"> | 207 | + <span class="val">(data.interval.as_str())</span> |
| 214 | - <h2 class="row-title">(g::t(lang, K::Interval))</h2> | | |
| 215 | - <p class="row-status">(data.interval.as_str())</p> | | |
| 216 | - </div> | | |
| 217 | </div> | 208 | </div> |
| 218 | - <div class="row-line"> | 209 | + <div class="line" data-kb-row=""> |
| 219 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12h4l2-5 4 10 2-5h6"/></svg> | 210 | + <span class="name">(g::t(lang, K::Healthcheck))</span> |
| 220 | - <div class="row-main"> | 211 | + <span class="val">(data.healthcheck)</span> |
| 221 | - <h2 class="row-title">(g::t(lang, K::Healthcheck))</h2> | | |
| 222 | - <p class="row-status">(data.healthcheck)</p> | | |
| 223 | - </div> | | |
| 224 | </div> | 212 | </div> |
| 225 | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Status", "Durum"))</h2> | 213 | + </section> |
| 226 | - <div class="row-line"> | 214 | + <section class="sec"> |
| 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> | 215 | + <h2>(crate::pages::passkeys::s(lang, "Status", "Durum"))</h2> |
| 228 | - <div class="row-main"> | 216 | + <div class="line" data-kb-row=""> |
| 229 | - <h2 class="row-title">(g::t(lang, K::Database))</h2> | 217 | + <span class="name">(g::t(lang, K::Database))</span> |
| 230 | - <p class="row-status"><span class=(data.db_dot) aria-hidden="true"></span> (data.db_health)</p> | 218 | + <span class="val"><span class=(data.db_dot) aria-hidden="true"></span> (data.db_health)</span> |
| 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> | | |
| 249 | </div> | 219 | </div> |
| 250 | - } else { | 220 | + if !data.db_error.is_empty() { |
| 251 | - <div class="row-line"> | 221 | + <p class="hint bad">(g::t(lang, K::DatabaseErrorPrefix))(data.db_error.as_str())</p> |
| 252 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h13l-3-3M20 17H7l3 3"/></svg> | 222 | + } |
| 253 | - <div class="row-main"> | 223 | + <div class="line" data-kb-row=""> |
| 254 | - <h2 class="row-title">(g::t(lang, K::Replication))</h2> | 224 | + <span class="name">(g::t(lang, K::LastDbSnapshotShipped))</span> |
| 255 | - <p class="row-status">(g::t(lang, K::ReplicationOff))</p> | 225 | + <span class="val">rel_time_or_never(lang: lang, stamp: data.db_last_ok.as_deref())</span> |
| 256 | - </div> | | |
| 257 | </div> | 226 | </div> |
| 258 | - } | 227 | + <div class="line" data-kb-row=""> |
| 259 | - <div class="row-line"> | 228 | + <span class="name">(g::t(lang, K::LastDbAttempt))</span> |
| 260 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h13l-3-3M20 17H7l3 3"/></svg> | 229 | + <span class="val">rel_time_or_never(lang: lang, stamp: data.db_last_attempt.as_deref())</span> |
| 261 | - <div class="row-main"> | | |
| 262 | - <h2 class="row-title">(g::t(lang, K::Standby))</h2> | | |
| 263 | </div> | 230 | </div> |
| 264 | - <form method="post" action="/admin/replication/reconcile" class="row-form"> | 231 | + </section> |
| 265 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 232 | + } else { |
| 266 | - <button type="submit" class="primary">(g::t(lang, K::ReconcileNow))</button> | 233 | + <section class="sec"> |
| 267 | - </form> | 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 | </div> | 242 | </div> |
| 269 | </section> | 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 | if data.repos.is_empty() { | 246 | if data.repos.is_empty() { |
| 272 | - <div class="row-line"> | 247 | + <p class="state">(g::t(lang, K::NoReposYet))</p> |
| 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> | 248 | + <p class="hint">(g::t(lang, K::ReposEmptyHint))</p> |
| 274 | - <div class="row-main"> | 249 | + <p class="hint">(g::t(lang, K::ReplicationConfigHint))</p> |
| 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> | | |
| 280 | } else { | 250 | } else { |
| 281 | for row in data.repos.into_iter() { | 251 | for row in data.repos.into_iter() { |
| 282 | - <div class="row-line"> | 252 | + <div class="line" data-kb-row=""> |
| 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> | 253 | + <span class="name">(row.name.as_str())</span> |
| 284 | - <div class="row-main"> | 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> |
| 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> | | |
| 291 | </div> | 255 | </div> |
| | 256 | + if !row.error.is_empty() { |
| | 257 | + <p class="hint bad">(row.error.as_str())</p> |
| | 258 | + } |
| 292 | } | 259 | } |
| 293 | } | 260 | } |
| 294 | </section> | 261 | </section> |
| @@ -36,8 +36,9 @@ use crate::pages::admin_users::admin_only; |
| 36 | use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; | 36 | use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; |
| 37 | use crate::pages::repo_mirrors::stamp_in_tz; | 37 | use crate::pages::repo_mirrors::stamp_in_tz; |
| 38 | use crate::state::AppState; | 38 | use crate::state::AppState; |
| | 39 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 39 | use crate::views::repo_list::{PageLink, pager, pager_links}; | 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 | path_param!(runner_id); | 43 | path_param!(runner_id); |
| 43 | | 44 | |
| @@ -196,6 +197,10 @@ struct RunnerRow { |
| 196 | /// The concurrency the admin set or the runner reported, for the load meter's maximum. | 197 | /// The concurrency the admin set or the runner reported, for the load meter's maximum. |
| 197 | /// Empty when the runner has not reported one. | 198 | /// Empty when the runner has not reported one. |
| 198 | concurrency_max: u32, | 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 | /// How the runner's reported build compares with this server's: the label, the `.ci-state` class | 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 | let (build_label, build_class, build_tone) = build_badge(lang, runner); | 264 | let (build_label, build_class, build_tone) = build_badge(lang, runner); |
| 260 | let (dot_class, state_text) = dot_of(lang, runner, now); | 265 | let (dot_class, state_text) = dot_of(lang, runner, now); |
| 261 | let concurrency_max = concurrency.parse().unwrap_or(0); | 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 | RunnerRow { | 283 | RunnerRow { |
| 263 | name: runner.name.clone(), | 284 | name: runner.name.clone(), |
| 264 | labels: runner.labels.join(" · "), | 285 | labels: runner.labels.join(" · "), |
| @@ -290,6 +311,8 @@ fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { |
| 290 | build_class, | 311 | build_class, |
| 291 | build_tone, | 312 | build_tone, |
| 292 | concurrency_max, | 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 | let (links, prev, next) = nav; | 358 | let (links, prev, next) = nav; |
| 336 | Ok(view! { | 359 | Ok(view! { |
| 337 | <div data-live="/admin/runners/events"> | 360 | <div data-live="/admin/runners/events"> |
| 338 | - <section class="page-head"> | 361 | + <h1 class="sr-only">(g::t(lang, K::CiRunners))</h1> |
| 339 | - <h1>(g::t(lang, K::CiRunners))</h1> | | |
| 340 | - </section> | | |
| 341 | if let Some((text, is_error)) = notice { | 362 | if let Some((text, is_error)) = notice { |
| 342 | if is_error { | 363 | if is_error { |
| 343 | - <section class="card notice alert" role="alert">(text)</section> | 364 | + alert(message: text) |
| 344 | } else { | 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"> | 369 | + <section class="sec"> |
| 349 | - <div class="row-line"> | 370 | + <h2>(g::t(lang, K::AddARunner))</h2> |
| 350 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 371 | + if rows.is_empty() { |
| 351 | - <div class="row-main"> | 372 | + <p class="state">(g::t(lang, K::NoRunnersYet))</p> |
| 352 | - <h2 class="row-title">(g::t(lang, K::AddARunner))</h2> | 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 | if rows.is_empty() { | 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> | 381 | + <form method="post" action="/admin/runners/tokens" class="fields"> |
| 357 | - <details class="row-action" id="add-runner"> | 382 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 358 | - <summary>(g::t(lang, K::CreateRegistrationToken))</summary> | 383 | + <button type="submit" class="primary">(g::t(lang, K::CreateRegistrationToken))</button> |
| 359 | - <div class="row-panel"> | 384 | + </form> |
| 360 | - <p class="muted small">(note.as_str())</p> | 385 | + ) |
| 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> | | |
| 371 | </div> | 386 | </div> |
| | 387 | + </section> |
| | 388 | + <section class="sec"> |
| 372 | for row in rows.iter() { | 389 | for row in rows.iter() { |
| 373 | - <div class="row-line runner-row is-linked"> | 390 | + <details class="row-open"> |
| 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> | 391 | + <summary class="line" data-kb-row=""> |
| 375 | - <div class="runner-id"> | 392 | + <span class=(row.dot_class) role="img" aria-label=(row.state_text) title=(row.state_text)></span> |
| 376 | - <div class="runner-title"> | 393 | + <span class="name">(row.name.as_str())</span> |
| 377 | - <span class=(row.dot_class) role="img" aria-label=(row.state_text) title=(row.state_text)></span> | 394 | + <span class="val">(row.status.as_str())</span> |
| 378 | - <a class="runner-name" href=(row.detail_href.as_str())>(row.name.as_str())</a> | 395 | + </summary> |
| 379 | - if row.disabled { | 396 | + <div class="opened"> |
| 380 | - <span class="runner-off">(g::t(lang, K::Disabled))</span> | 397 | + <p class="hint"> |
| 381 | - } | 398 | + if !row.labels.is_empty() { |
| 382 | - </div> | 399 | + <span class="runner-labels">(row.labels.as_str())</span> |
| 383 | - <p class="runner-meta muted"> | 400 | + " · " |
| 384 | - if !row.labels.is_empty() { | 401 | + } |
| 385 | - <span class="runner-labels">(row.labels.as_str())</span> | 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> |
| 386 | - " · " | 403 | + </p> |
| 387 | - } | 404 | + <div class="runner-version" title=(row.build.as_str())> |
| 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> | 405 | + if !row.build_short.is_empty() { |
| 389 | - if row.restart_pending.is_some() { | 406 | + <code class="runner-hash">(row.build_short.as_str())</code> |
| 390 | - " · " | 407 | + } |
| 391 | - <span class="runner-off">(s(lang, "restart pending", "yeniden başlatma bekliyor"))</span> | 408 | + if row.build_tone == "ok" { |
| 392 | - } | 409 | + <span class="runner-status"><span class="runner-tick" aria-hidden="true">"✓"</span>" "(row.build_label)</span> |
| 393 | - </p> | 410 | + } else { |
| 394 | - </div> | 411 | + <span class=(format!("runner-status {}", row.build_tone))>(row.build_label)</span> |
| 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) | 412 | + } |
| 396 | - <div class="runner-version" title=(row.build.as_str())> | 413 | + </div> |
| 397 | - if !row.build_short.is_empty() { | 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) |
| 398 | - <code class="runner-hash">(row.build_short.as_str())</code> | 415 | + <div class="acts"> |
| 399 | - } | 416 | + <a class="act" href=(row.detail_href.as_str())>(s(lang, "Open", "Aç"))</a> |
| 400 | - if row.build_tone == "ok" { | 417 | + if row.disabled { |
| 401 | - <span class="runner-status"><span class="runner-tick" aria-hidden="true">"✓"</span>" "(row.build_label)</span> | 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())]) |
| 402 | - } else { | 419 | + } else { |
| 403 | - <span class=(format!("runner-status {}", row.build_tone))>(row.build_label)</span> | 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())]) |
| 404 | - } | 421 | + } |
| 405 | - </div> | 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) |
| 406 | - <details class="row-menu"> | 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![]) |
| 407 | - <summary class="button row-menu-btn" aria-label=(s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> | 424 | + </div> |
| 408 | - <div class="row-menu-panel" role="menu"> | 425 | + </div> |
| 409 | - if row.disabled { | 426 | + </details> |
| 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> | | |
| 423 | } | 427 | } |
| 424 | if !rows.is_empty() { | 428 | if !rows.is_empty() { |
| 425 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | 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 | 446 | +/// A text link that asks first, in place; the POST only fires from the confirm button. |
| 443 | -/// confirm button inside it, and Cancel closes the popover. | | |
| 444 | #[component] | 447 | #[component] |
| 445 | pub(crate) async fn confirm_post( | 448 | pub(crate) async fn confirm_post( |
| 446 | lang: Lang, | 449 | lang: Lang, |
| @@ -453,19 +456,19 @@ pub(crate) async fn confirm_post( |
| 453 | fields: Vec<(&'static str, String)>, | 456 | fields: Vec<(&'static str, String)>, |
| 454 | ) -> Result<impl View> { | 457 | ) -> Result<impl View> { |
| 455 | Ok(view! { | 458 | Ok(view! { |
| 456 | - <details class="confirm-inline"> | 459 | + <details class="reveal"> |
| 457 | - <summary class=(if danger { "button danger" } else { "button" })>(label)</summary> | 460 | + <summary class=(if danger { "act danger" } else { "act" })>(label)</summary> |
| 458 | - <div class="confirm-pop"> | 461 | + <form class="opened" method="post" action=(action)> |
| 459 | - <p>(message)</p> | 462 | + <input type="hidden" name="csrf" value=(csrf)> |
| 460 | - <form method="post" action=(action)> | 463 | + for (name, value) in fields.iter() { |
| 461 | - <input type="hidden" name="csrf" value=(csrf)> | 464 | + <input type="hidden" name=(*name) value=(value.as_str())> |
| 462 | - for (name, value) in fields.iter() { | 465 | + } |
| 463 | - <input type="hidden" name=(*name) value=(value.as_str())> | 466 | + <p class="hint">(message)</p> |
| 464 | - } | 467 | + <div class="acts"> |
| 465 | - <button type="submit" class=(if danger { "danger" } else { "primary" })>(confirm)</button> | 468 | + <button type="submit" class=(if danger { "act danger" } else { "act" })>(confirm)</button> |
| 466 | - <button type="button" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> | 469 | + <button type="button" class="act quiet" data-close-details="">(s(lang, "Cancel", "Vazgeç"))</button> |
| 467 | - </form> | 470 | + </div> |
| 468 | - </div> | 471 | + </form> |
| 469 | </details> | 472 | </details> |
| 470 | }) | 473 | }) |
| 471 | } | 474 | } |
| @@ -509,29 +512,21 @@ async fn restart_control( |
| 509 | ) -> Result<impl View> { | 512 | ) -> Result<impl View> { |
| 510 | Ok(view! { | 513 | Ok(view! { |
| 511 | if pending.is_some() { | 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 | } else if can_restart { | 516 | } else if can_restart { |
| 514 | - <details class="confirm-inline"> | 517 | + <details class="reveal"> |
| 515 | - <summary class="button">(s(lang, "Restart", "Yeniden başlat"))</summary> | 518 | + <summary class="act">(s(lang, "Restart", "Yeniden başlat"))</summary> |
| 516 | - <div class="confirm-pop"> | 519 | + <div class="opened"> |
| 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> | 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> |
| 518 | - <form method="post" action=(action) class="restart-choices"> | 521 | + <p class="hint">(s(lang, "The running jobs finish, then it restarts.", "Çalışan işler biter, sonra yeniden başlar."))</p> |
| 519 | - <input type="hidden" name="csrf" value=(csrf)> | 522 | + <div class="acts"> |
| 520 | - <input type="hidden" name="back" value=(back)> | 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())]) |
| 521 | - <button type="submit" name="mode" value="drain" class="restart-choice"> | 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())) |
| 522 | - <strong>(s(lang, "Restart after current jobs", "Mevcut işlerden sonra yeniden başlat"))</strong> | 525 | + </div> |
| 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> | | |
| 531 | </div> | 526 | </div> |
| 532 | </details> | 527 | </details> |
| 533 | } else { | 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 | lang: Lang, | 543 | lang: Lang, |
| 549 | csrf: &str, | 544 | csrf: &str, |
| 550 | action: &str, | 545 | action: &str, |
| | 546 | + id: &str, |
| 551 | key: &str, | 547 | key: &str, |
| 552 | value: &str, | 548 | value: &str, |
| 553 | source: &'static str, | 549 | source: &'static str, |
| @@ -573,34 +569,34 @@ async fn concurrency_form( |
| 573 | Lang::Tr => format!("{running}/{max} iş çalışıyor"), | 569 | Lang::Tr => format!("{running}/{max} iş çalışıyor"), |
| 574 | }; | 570 | }; |
| 575 | Ok(view! { | 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 | <input type="hidden" name="csrf" value=(csrf)> | 573 | <input type="hidden" name="csrf" value=(csrf)> |
| 578 | <input type="hidden" name="key" value=(key)> | 574 | <input type="hidden" name="key" value=(key)> |
| 579 | <input type="hidden" name="back" value=(back)> | 575 | <input type="hidden" name="back" value=(back)> |
| 580 | - <div class="runner-running"> | 576 | + <div class="field"> |
| 581 | - <span class="runner-count"><span class="runner-n">(running_text.as_str())</span>" "<span class="muted">(s(lang, "running", "çalışıyor"))</span></span> | 577 | + <label for=(id)>(s(lang, "Concurrency", "Eşzamanlılık"))</label> |
| 582 | - if use_pips { | 578 | + <div class="runner-stepper"> |
| 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"> | | |
| 595 | <button type="button" class="runner-step" data-step="-1" aria-label=(s(lang, "Fewer", "Azalt"))>"−"</button> | 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 | <button type="button" class="runner-step" data-step="1" aria-label=(s(lang, "More", "Artır"))>"+"</button> | 581 | <button type="button" class="runner-step" data-step="1" aria-label=(s(lang, "More", "Artır"))>"+"</button> |
| 598 | </div> | 582 | </div> |
| 599 | - <button type="submit" class="primary runner-save">(s(lang, "Save", "Kaydet"))</button> | 583 | + <div class="runner-running"> |
| 600 | - if has_override { | 584 | + <span class="runner-count"><span class="runner-n">(running_text.as_str())</span>" "<span class="muted">(s(lang, "running", "çalışıyor"))</span></span> |
| 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> | 585 | + if use_pips { |
| 602 | - } | 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 | </div> | 595 | </div> |
| | 596 | + <button type="submit" class="primary runner-save">(s(lang, "Save", "Kaydet"))</button> |
| | 597 | + if has_override { |
| | 598 | + <button type="submit" name="reset" value="1" class="act" formnovalidate="formnovalidate" title=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan"))>(s(lang, "Use the runner.toml value", "runner.toml değerini kullan"))</button> |
| | 599 | + } |
| 604 | </form> | 600 | </form> |
| 605 | }) | 601 | }) |
| 606 | } | 602 | } |
| @@ -613,26 +609,22 @@ async fn token_view( |
| 613 | expiry: String, | 609 | expiry: String, |
| 614 | ) -> Result<impl View> { | 610 | ) -> Result<impl View> { |
| 615 | Ok(view! { | 611 | Ok(view! { |
| 616 | - <section class="page-head"> | 612 | + <h1 class="sr-only">(g::t(lang, K::RegistrationToken))</h1> |
| 617 | - <h1>(g::t(lang, K::RegistrationToken))</h1> | 613 | + <p class="state" role="status"><strong>(g::t(lang, K::CopyTokenNow))</strong></p> |
| 618 | - </section> | 614 | + <p class="hint">(expiry.as_str())</p> |
| 619 | - <section class="card notice" role="status"> | 615 | + <section class="sec" data-once=""> |
| 620 | - <p><strong>(g::t(lang, K::CopyTokenNow))</strong></p> | | |
| 621 | - <p>(expiry.as_str())</p> | | |
| 622 | - </section> | | |
| 623 | - <section class="card" data-once=""> | | |
| 624 | <h2>(g::t(lang, K::Token))</h2> | 616 | <h2>(g::t(lang, K::Token))</h2> |
| 625 | <div class="copy-box"> | 617 | <div class="copy-box"> |
| 626 | <code id="reg-token">(token.as_str())</code> | 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 | </div> | 620 | </div> |
| 629 | <h2>(g::t(lang, K::RegisterARunner))</h2> | 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 | <div class="copy-box"> | 623 | <div class="copy-box"> |
| 632 | <code id="reg-command">(command.as_str())</code> | 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 | </div> | 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 | </section> | 628 | </section> |
| 637 | }) | 629 | }) |
| 638 | } | 630 | } |
| @@ -1084,7 +1076,6 @@ struct DetailField { |
| 1084 | hint: &'static str, | 1076 | hint: &'static str, |
| 1085 | value: String, | 1077 | value: String, |
| 1086 | kind_label: &'static str, | 1078 | kind_label: &'static str, |
| 1087 | - kind_class: &'static str, | | |
| 1088 | source_label: &'static str, | 1079 | source_label: &'static str, |
| 1089 | pending_label: &'static str, | 1080 | pending_label: &'static str, |
| 1090 | has_override: bool, | 1081 | has_override: bool, |
| @@ -1101,10 +1092,10 @@ fn detail_fields(lang: Lang, tab: &str, fields: &[FieldRow]) -> Vec<DetailField> |
| 1101 | .filter_map(|key| fields.iter().find(|f| f.key == key)) | 1092 | .filter_map(|key| fields.iter().find(|f| f.key == key)) |
| 1102 | .map(|f| { | 1093 | .map(|f| { |
| 1103 | let (label, hint) = field_text(lang, f.key); | 1094 | let (label, hint) = field_text(lang, f.key); |
| 1104 | - let (kind_label, kind_class) = if f.kind == FieldKind::Live { | 1095 | + let kind_label = if f.kind == FieldKind::Live { |
| 1105 | - (g::t(lang, K::SrvKindLive), "badge srv-live") | 1096 | + g::t(lang, K::SrvKindLive) |
| 1106 | } else { | 1097 | } else { |
| 1107 | - (g::t(lang, K::SrvKindRestart), "badge srv-restart") | 1098 | + g::t(lang, K::SrvKindRestart) |
| 1108 | }; | 1099 | }; |
| 1109 | let choices: Vec<(&'static str, &'static str)> = match f.key { | 1100 | let choices: Vec<(&'static str, &'static str)> = match f.key { |
| 1110 | "auto_update" => vec![ | 1101 | "auto_update" => vec![ |
| @@ -1132,7 +1123,6 @@ fn detail_fields(lang: Lang, tab: &str, fields: &[FieldRow]) -> Vec<DetailField> |
| 1132 | hint, | 1123 | hint, |
| 1133 | value: f.value.clone(), | 1124 | value: f.value.clone(), |
| 1134 | kind_label, | 1125 | kind_label, |
| 1135 | - kind_class, | | |
| 1136 | source_label: source_text(lang, f.source), | 1126 | source_label: source_text(lang, f.source), |
| 1137 | pending_label: if !f.pending { | 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 { | 1589 | +/// `aria-current` for the open tab of the detail page's tab row. |
| 1600 | - if on { | 1590 | +fn current(on: bool) -> Option<&'static str> { |
| 1601 | - "subnav-link current" | 1591 | + on.then_some("page") |
| 1602 | - } else { | | |
| 1603 | - "subnav-link" | | |
| 1604 | - } | | |
| 1605 | } | 1592 | } |
| 1606 | | 1593 | |
| 1607 | #[component] | 1594 | #[component] |
| @@ -1672,33 +1659,39 @@ async fn runner_detail_view( |
| 1672 | let has_host = !metrics.empty || runner.reported.cpus.is_some(); | 1659 | let has_host = !metrics.empty || runner.reported.cpus.is_some(); |
| 1673 | Ok(view! { | 1660 | Ok(view! { |
| 1674 | <div data-live="/admin/runners/events" class="runner-detail"> | 1661 | <div data-live="/admin/runners/events" class="runner-detail"> |
| 1675 | - <section class="page-head"> | 1662 | + <h1 class="h1">(runner.name.as_str())</h1> |
| 1676 | - <div class="runner-head"> | 1663 | + <p class="hint runner-state"><span class=(row.dot_class)></span>(row.state_text) |
| 1677 | - <h1>(runner.name.as_str())</h1> | 1664 | + if row.restart_pending.is_some() { |
| 1678 | - <span class="runner-state"><span class=(row.dot_class)></span>(row.state_text)</span> | 1665 | + " · " |
| 1679 | - if row.restart_pending.is_some() { | 1666 | + <span class="runner-off">(s(lang, "restart pending", "yeniden başlatma bekliyor"))</span> |
| 1680 | - <span class="ci-state runner-disabled">(s(lang, "restart pending", "yeniden başlatma bekliyor"))</span> | 1667 | + } |
| 1681 | - } | 1668 | + </p> |
| 1682 | - </div> | 1669 | + <p class="sub"><a href="/admin/runners">(g::t(lang, K::BackToRunners))</a></p> |
| 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> | | |
| 1688 | if let Some((text, is_error)) = notice { | 1670 | if let Some((text, is_error)) = notice { |
| 1689 | if is_error { | 1671 | if is_error { |
| 1690 | - <section class="card notice alert" role="alert">(text)</section> | 1672 | + alert(message: text) |
| 1691 | } else { | 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"> | 1677 | + <section class="sec"> |
| 1696 | - <div class="srv-grid srv-stats"> | 1678 | + <h2>(s(lang, "Status", "Durum"))</h2> |
| 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> | 1679 | + <p class="state">(s(lang, "Running jobs", "Çalışan işler")) " " <a href=(jobs_href.as_str())>(in_use.as_str())</a></p> |
| 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> | 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> |
| 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> | 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> |
| 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> | 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 | </div> | 1691 | </div> |
| | 1692 | + </section> |
| | 1693 | + <section class="sec"> |
| | 1694 | + <h2>(s(lang, "Last hour", "Son bir saat"))</h2> |
| 1702 | if has_host { | 1695 | if has_host { |
| 1703 | <div class="mx-panels"> | 1696 | <div class="mx-panels"> |
| 1704 | for (c, fact) in metrics.charts.iter().zip(facts.iter()) { | 1697 | for (c, fact) in metrics.charts.iter().zip(facts.iter()) { |
| @@ -1706,7 +1699,7 @@ async fn runner_detail_view( |
| 1706 | <div class="mx-head"> | 1699 | <div class="mx-head"> |
| 1707 | <p class="mx-caption">(c.caption.as_str())</p> | 1700 | <p class="mx-caption">(c.caption.as_str())</p> |
| 1708 | if !fact.is_empty() { | 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 | if !c.legend.is_empty() { | 1704 | if !c.legend.is_empty() { |
| 1712 | <ul class="mx-legend"> | 1705 | <ul class="mx-legend"> |
| @@ -1753,7 +1746,7 @@ async fn runner_detail_view( |
| 1753 | </div> | 1746 | </div> |
| 1754 | } | 1747 | } |
| 1755 | if metrics.empty { | 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 | } else { | 1750 | } else { |
| 1758 | <details class="mx-table"> | 1751 | <details class="mx-table"> |
| 1759 | <summary>(s(lang, "Show as table", "Tablo olarak göster"))</summary> | 1752 | <summary>(s(lang, "Show as table", "Tablo olarak göster"))</summary> |
| @@ -1776,61 +1769,54 @@ async fn runner_detail_view( |
| 1776 | </details> | 1769 | </details> |
| 1777 | } | 1770 | } |
| 1778 | </section> | 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 | for (slug, _) in TABS.iter() { | 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 | </nav> | 1776 | </nav> |
| 1784 | if editing { | 1777 | if editing { |
| 1785 | - <section class="card rows-pane"> | 1778 | + <section class="sec"> |
| 1786 | - <form method="post" action=(save_action.as_str())> | 1779 | + <form method="post" action=(save_action.as_str()) class="fields"> |
| 1787 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 1780 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 1788 | <input type="hidden" name="tab" value=(tab)> | 1781 | <input type="hidden" name="tab" value=(tab)> |
| 1789 | for f in shown.iter() { | 1782 | for f in shown.iter() { |
| 1790 | - <div class="row-line row-field"> | 1783 | + <div class="field"> |
| 1791 | - <div class="row-main"> | 1784 | + <label for=(format!("rf-{}", f.key))>(f.label)</label> |
| 1792 | - <label class="row-title" for=(format!("rf-{}", f.key))>(f.label) | 1785 | + if f.input == "select" { |
| 1793 | - <span class=(f.kind_class)>(f.kind_label)</span> | 1786 | + <select id=(format!("rf-{}", f.key)) name=(f.key)> |
| 1794 | - <span class="badge srv-source">(f.source_label)</span> | 1787 | + for (value, text, on) in f.options.iter() { |
| 1795 | - if !f.pending_label.is_empty() { | 1788 | + <option value=(*value) selected=(sel(*on))>(*text)</option> |
| 1796 | - <span class="badge srv-pending">(f.pending_label)</span> | | |
| 1797 | } | 1789 | } |
| 1798 | - </label> | 1790 | + </select> |
| 1799 | - <p class="row-status">(f.hint)</p> | 1791 | + } else if f.input == "number" { |
| 1800 | - </div> | 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)"))> |
| 1801 | - <div class="row-control"> | 1793 | + } else { |
| 1802 | - if f.input == "select" { | 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"> |
| 1803 | - <select id=(format!("rf-{}", f.key)) name=(f.key)> | 1795 | + } |
| 1804 | - for (value, text, on) in f.options.iter() { | 1796 | + <p class="hint">(f.hint)</p> |
| 1805 | - <option value=(*value) selected=(sel(*on))>(*text)</option> | 1797 | + <p class="hint">(f.kind_label) " · " (f.source_label) |
| 1806 | - } | 1798 | + if !f.pending_label.is_empty() { |
| 1807 | - </select> | 1799 | + " · " (f.pending_label) |
| 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> | | |
| 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 | </div> | 1807 | </div> |
| 1818 | } | 1808 | } |
| 1819 | for (i, (label, value)) in identity.iter().enumerate().filter(|_| tab == "identity") { | 1809 | for (i, (label, value)) in identity.iter().enumerate().filter(|_| tab == "identity") { |
| 1820 | - <div class="row-line row-field"> | 1810 | + <div class="field"> |
| 1821 | - <div class="row-main"> | 1811 | + <p class="state">(*label) " " <code class="srv-fixed">(value.as_str())</code></p> |
| 1822 | - <span class="row-title">(*label)<span class="badge srv-ro">(g::t(lang, K::SrvKindReadOnly))</span></span> | 1812 | + <p class="hint">(g::t(lang, K::SrvKindReadOnly))</p> |
| 1823 | - if i == 0 { | 1813 | + 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> | 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> |
| 1825 | - } | 1815 | + } |
| 1826 | - </div> | | |
| 1827 | - <div class="row-control"><code class="srv-fixed">(value.as_str())</code></div> | | |
| 1828 | </div> | 1816 | </div> |
| 1829 | } | 1817 | } |
| 1830 | if tab != "identity" { | 1818 | if tab != "identity" { |
| 1831 | - <div class="row-foot"> | 1819 | + <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> |
| 1832 | - <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> | | |
| 1833 | - </div> | | |
| 1834 | } | 1820 | } |
| 1835 | </form> | 1821 | </form> |
| 1836 | <form id="rn-reset" method="post" action=(reset_action.as_str())> | 1822 | <form id="rn-reset" method="post" action=(reset_action.as_str())> |
| @@ -1841,13 +1827,13 @@ async fn runner_detail_view( |
| 1841 | </form> | 1827 | </form> |
| 1842 | </section> | 1828 | </section> |
| 1843 | } else { | 1829 | } else { |
| 1844 | - <section class="card"> | 1830 | + <section class="sec"> |
| 1845 | if tab == "logs" { | 1831 | if tab == "logs" { |
| 1846 | if log.is_empty() { | 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 | } else { | 1834 | } else { |
| 1849 | <div class="runner-log-bar"> | 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 | </div> | 1837 | </div> |
| 1852 | <pre id="runner-log" class="ci-log runner-log" role="log" aria-label=(s(lang, "Runner log", "Çalıştırıcı günlüğü"))> | 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 | for row in log.iter() { | 1839 | for row in log.iter() { |
| @@ -1858,7 +1844,7 @@ async fn runner_detail_view( |
| 1858 | } else if tab == "jobs" { | 1844 | } else if tab == "jobs" { |
| 1859 | <h2>(s(lang, "Running now", "Şu an çalışan"))</h2> | 1845 | <h2>(s(lang, "Running now", "Şu an çalışan"))</h2> |
| 1860 | if running_jobs.is_empty() { | 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 | } else { | 1848 | } else { |
| 1863 | <div class="table-wrap"> | 1849 | <div class="table-wrap"> |
| 1864 | <table class="table queue-table"> | 1850 | <table class="table queue-table"> |
| @@ -1879,7 +1865,7 @@ async fn runner_detail_view( |
| 1879 | } | 1865 | } |
| 1880 | <h2>(s(lang, "Recent", "Son"))</h2> | 1866 | <h2>(s(lang, "Recent", "Son"))</h2> |
| 1881 | if recent_jobs.is_empty() { | 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 | } else { | 1869 | } else { |
| 1884 | <div class="table-wrap"> | 1870 | <div class="table-wrap"> |
| 1885 | <table class="table queue-table"> | 1871 | <table class="table queue-table"> |
| @@ -2356,7 +2342,7 @@ mod tests { |
| 2356 | assert!(!page.contains("linux, x86_64"), "labels are not joined"); | 2342 | assert!(!page.contains("linux, x86_64"), "labels are not joined"); |
| 2357 | // Never seen, so offline; not disabled, so no disabled word. | 2343 | // Never seen, so offline; not disabled, so no disabled word. |
| 2358 | assert!(page.contains(r#"class="runner-dot is-offline""#)); | 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 | let runner = store.list_runners().await.expect("list").remove(0); | 2347 | let runner = store.list_runners().await.expect("list").remove(0); |
| 2362 | store | 2348 | store |
| @@ -2365,7 +2351,7 @@ mod tests { |
| 2365 | .expect("disable"); | 2351 | .expect("disable"); |
| 2366 | let (_, page) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; | 2352 | let (_, page) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; |
| 2367 | assert!(page.contains(r#"class="runner-dot is-disabled""#)); | 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 | // Scenario: restart is capability-gated and audited, then the runner is disabled, enabled and deleted. | 2357 | // Scenario: restart is capability-gated and audited, then the runner is disabled, enabled and deleted. |
| @@ -1,6 +1,6 @@ |
| 1 | //! Page: the forge's own settings (`/admin/server`). Instance admins only; anyone else gets 404. | 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 | //! from (default, config file, or a UI override) and how a change reaches the process: live | 4 | //! from (default, config file, or a UI override) and how a change reaches the process: live |
| 5 | //! (applied at once), restart (saved, applied at the next start) or read-only. Saving a tab stores | 5 | //! (applied at once), restart (saved, applied at the next start) or read-only. Saving a tab stores |
| 6 | //! the changed fields as database overrides on top of the config file, which is never rewritten. | 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 | use crate::live::Topic; | 35 | use crate::live::Topic; |
| 36 | use crate::pages::admin_users::admin_only; | 36 | use crate::pages::admin_users::admin_only; |
| 37 | use crate::pages::ci_runs::{changed_event, events_response}; | 37 | use crate::pages::ci_runs::{changed_event, events_response}; |
| | 38 | +use crate::pages::passkeys::s; |
| 38 | use crate::self_update; | 39 | use crate::self_update; |
| 39 | use crate::state::AppState; | 40 | use crate::state::AppState; |
| | 41 | +use crate::views::parts::{confirm_act, reveal}; |
| 40 | use crate::views::{enc, shell}; | 42 | use crate::views::{enc, shell}; |
| 41 | | 43 | |
| 42 | #[query_params(error = bad_request)] | 44 | #[query_params(error = bad_request)] |
| 43 | pub(crate) struct ServerQuery { | 45 | pub(crate) struct ServerQuery { |
| 44 | notice: Option<String>, | 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 | tab: Option<String>, | 52 | tab: Option<String>, |
| 46 | /// The boot id of the server that was asked to restart. | 53 | /// The boot id of the server that was asked to restart. |
| 47 | restarting: Option<String>, | 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 | /// How long the restart waits after the request is answered, so the redirect that follows is | 57 | /// How long the restart waits after the request is answered, so the redirect that follows is |
| 59 | /// served by the old process. | 58 | /// served by the old process. |
| 60 | const RESTART_GRACE: std::time::Duration = std::time::Duration::from_millis(750); | 59 | const RESTART_GRACE: std::time::Duration = std::time::Duration::from_millis(750); |
| @@ -87,11 +86,13 @@ struct OptionRow { |
| 87 | /// One field, already formatted for the template. A secret's value is never in here. | 86 | /// One field, already formatted for the template. A secret's value is never in here. |
| 88 | struct Row { | 87 | struct Row { |
| 89 | key: &'static str, | 88 | key: &'static str, |
| | 89 | + /// The category the setting belongs to, for a search result's link. |
| | 90 | + group: Group, |
| 90 | label: &'static str, | 91 | label: &'static str, |
| 91 | help: &'static str, | 92 | help: &'static str, |
| 92 | kind_label: &'static str, | 93 | kind_label: &'static str, |
| 93 | - kind_class: &'static str, | 94 | + /// What a line shows for the value: the text, the chosen option, On or Off, or the secret state. |
| 94 | - source_label: &'static str, | 95 | + value_text: String, |
| 95 | value: String, | 96 | value: String, |
| 96 | file_value: String, | 97 | file_value: String, |
| 97 | show_file_value: bool, | 98 | show_file_value: bool, |
| @@ -107,6 +108,10 @@ struct Row { |
| 107 | is_select: bool, | 108 | is_select: bool, |
| 108 | is_secret: bool, | 109 | is_secret: bool, |
| 109 | fixed: bool, | 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 | pub(crate) fn tab_label(lang: Lang, group: Group) -> &'static str { | 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 | fn row(lang: Lang, view: &FieldView) -> Row { | 131 | fn row(lang: Lang, view: &FieldView) -> Row { |
| 135 | let field: &Field = view.field; | 132 | let field: &Field = view.field; |
| 136 | - let (kind_label, kind_class) = match field.kind { | 133 | + let kind_label = match field.kind { |
| 137 | - Kind::Live => (g::t(lang, K::SrvKindLive), "badge srv-live"), | 134 | + // A live field needs no word: applying at once is what a field is expected to do. |
| 138 | - Kind::Restart => (g::t(lang, K::SrvKindRestart), "badge srv-restart"), | 135 | + Kind::Live => "", |
| 139 | - Kind::ReadOnly => (g::t(lang, K::SrvKindReadOnly), "badge srv-ro"), | 136 | + Kind::Restart => g::t(lang, K::SrvKindRestart), |
| 140 | - }; | 137 | + Kind::ReadOnly => g::t(lang, K::SrvKindReadOnly), |
| 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), | | |
| 145 | }; | 138 | }; |
| 146 | let (min, max) = match field.ty { | 139 | let (min, max) = match field.ty { |
| 147 | Ty::Uint(min, max) => (min.to_string(), max.to_string()), | 140 | Ty::Uint(min, max) => (min.to_string(), max.to_string()), |
| @@ -163,41 +156,81 @@ fn row(lang: Lang, view: &FieldView) -> Row { |
| 163 | _ => Vec::new(), | 156 | _ => Vec::new(), |
| 164 | }; | 157 | }; |
| 165 | let editable = field.kind != Kind::ReadOnly; | 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 | let (label, help) = match (lang, i18n::server_settings::field_tr(field.key)) { | 185 | let (label, help) = match (lang, i18n::server_settings::field_tr(field.key)) { |
| 167 | (Lang::Tr, Some(tr)) => tr, | 186 | (Lang::Tr, Some(tr)) => tr, |
| 168 | _ => (field.label, field.help), | 187 | _ => (field.label, field.help), |
| 169 | }; | 188 | }; |
| 170 | Row { | 189 | Row { |
| 171 | key: field.key, | 190 | key: field.key, |
| | 191 | + group: field.group, |
| 172 | label, | 192 | label, |
| 173 | help, | 193 | help, |
| 174 | kind_label, | 194 | kind_label, |
| 175 | - kind_class, | 195 | + value_text, |
| 176 | - source_label, | | |
| 177 | value: view.value.clone(), | 196 | value: view.value.clone(), |
| 178 | file_value: if view.file_value.is_empty() { | 197 | file_value: if view.file_value.is_empty() { |
| 179 | g::t(lang, K::SrvEmpty).to_owned() | 198 | g::t(lang, K::SrvEmpty).to_owned() |
| 180 | } else { | 199 | } else { |
| 181 | view.file_value.clone() | 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 | has_override: editable && view.source == Source::Ui, | 203 | has_override: editable && view.source == Source::Ui, |
| 185 | pending: view.restart_pending, | 204 | pending: view.restart_pending, |
| 186 | checked: view.value == "true", | 205 | checked: view.value == "true", |
| 187 | min, | 206 | min, |
| 188 | max, | 207 | max, |
| 189 | options, | 208 | options, |
| 190 | - secret_state: if view.secret_set { | 209 | + secret_state, |
| 191 | - g::t(lang, K::SrvSecretSet) | 210 | + is_bool, |
| 192 | - } else { | 211 | + is_number, |
| 193 | - g::t(lang, K::SrvSecretNotSet) | 212 | + is_select, |
| 194 | - }, | 213 | + is_secret, |
| 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(), | | |
| 199 | fixed: !editable, | 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 | async fn rows_for(state: &AppState, lang: Lang, group: Group) -> forge_core::Result<Vec<Row>> { | 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 | .collect()) | 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 | #[component] | 364 | #[component] |
| 215 | async fn server_view( | 365 | async fn server_view( |
| 216 | lang: Lang, | 366 | lang: Lang, |
| 217 | csrf: String, | 367 | csrf: String, |
| 218 | group: Group, | 368 | group: Group, |
| 219 | rows: Vec<Row>, | 369 | rows: Vec<Row>, |
| | 370 | + q: String, |
| | 371 | + search: Option<Vec<Row>>, |
| 220 | notice: Option<String>, | 372 | notice: Option<String>, |
| 221 | restart: Restart, | 373 | restart: Restart, |
| 222 | ) -> Result<impl View> { | 374 | ) -> Result<impl View> { |
| 223 | let tab = group.slug(); | 375 | let tab = group.slug(); |
| 224 | let any_editable = rows.iter().any(|r| !r.fixed); | 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 | // A pending restart names the boot id it waits for: the stream then sends at once when a new | 379 | // A pending restart names the boot id it waits for: the stream then sends at once when a new |
| 226 | // process answers, and the page re-renders. | 380 | // process answers, and the page re-renders. |
| 227 | let live = match restart { | 381 | let live = match restart { |
| @@ -232,124 +386,86 @@ async fn server_view( |
| 232 | _ => "/admin/server/events".to_owned(), | 386 | _ => "/admin/server/events".to_owned(), |
| 233 | }; | 387 | }; |
| 234 | Ok(view! { | 388 | Ok(view! { |
| 235 | - <div data-live=(live.as_str()) class="srv-page"> | 389 | + <div data-live=(live.as_str())> |
| 236 | - <section class="page-head"> | 390 | + <h1 class="sr-only">(g::t(lang, K::ServerSettings))</h1> |
| 237 | - <h1>(g::t(lang, K::ServerSettings))</h1> | 391 | + <form class="plain-search" method="get" action="/admin/server" role="search"> |
| 238 | - </section> | 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> |
| 239 | - <p class="muted page-lede">(g::t(lang, K::ServerSettingsIntro))</p> | 393 | + <label class="sr-only" for="server-search">(search_label)</label> |
| 240 | - <p class="muted small page-lede">(match lang { Lang::Tr => "Sürüm", _ => "Version" }) " " (forge_ci::build::display())</p> | 394 | + <input id="server-search" type="search" name="q" value=(q.as_str()) placeholder=(search_label) data-live-search="" autocomplete="off"> |
| 241 | - if restart == Restart::Pending { | 395 | + </form> |
| 242 | - <section class="card notice srv-restarting" role="status" aria-live="polite"> | 396 | + <nav class="sub" aria-label=(g::t(lang, K::ServerSettings))> |
| 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> | 397 | + for g_tab in Group::ALL.into_iter() { |
| 244 | - </section> | 398 | + if g_tab == group { |
| 245 | - } else if restart == Restart::Done { | 399 | + <a aria-current="page" href=(format!("/admin/server?cat={}", g_tab.slug()))>(tab_label(lang, g_tab))</a> |
| 246 | - <section class="card notice" role="status"> | 400 | + } else { |
| 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> | 401 | + <a href=(format!("/admin/server?cat={}", g_tab.slug()))>(tab_label(lang, g_tab))</a> |
| 248 | - </section> | 402 | + } |
| 249 | - } | 403 | + } |
| 250 | - <nav class="subnav" aria-label=(g::t(lang, K::ServerSettings))> | 404 | + </nav> |
| 251 | - for g_tab in Group::ALL.into_iter() { | 405 | + <p class="hint">(g::t(lang, K::ServerSettingsIntro))</p> |
| 252 | - <a class=(tab_class(g_tab == group)) href=(format!("/admin/server?tab={}", g_tab.slug()))>(tab_label(lang, g_tab))</a> | 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> | 412 | + if let Some(message) = notice { |
| 255 | - if let Some(message) = notice { | 413 | + <p class="state" role="status">(message.as_str())</p> |
| 256 | - <section class="card notice" role="status"> | 414 | + } |
| 257 | - <p>(message.as_str())</p> | 415 | + if let Some(hits) = search { |
| 258 | - </section> | 416 | + <section class="sec"> |
| 259 | - } | 417 | + <h2>(s(lang, "Results", "Sonuçlar"))</h2> |
| 260 | - <section class="card rows-pane"> | 418 | + if hits.is_empty() { |
| 261 | - <form method="post" action="/admin/server" class="srv-form"> | 419 | + <p class="state">(s(lang, "No setting matches.", "Eşleşen ayar yok."))</p> |
| 262 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 420 | + } |
| 263 | - <input type="hidden" name="tab" value=(tab)> | 421 | + for hit in hits.iter() { |
| 264 | - for r in rows.iter() { | 422 | + <a class="line" href=(format!("/admin/server?cat={}#srv-{}", hit.group.slug(), hit.key))> |
| 265 | - <div class="row-line row-field srv-field" id=(format!("srv-{}", r.key))> | 423 | + <span class="name">(hit.label)</span> |
| 266 | - <div class="row-main"> | 424 | + <span class="val">(tab_label(lang, hit.group))</span> |
| 267 | - <span class="row-title"> | 425 | + </a> |
| 268 | - <span class="srv-label" title=(r.label)>(r.label)</span> | 426 | + } |
| 269 | - <span class=(r.kind_class)>(r.kind_label)</span> | 427 | + </section> |
| 270 | - <span class="badge srv-source">(r.source_label)</span> | 428 | + } else { |
| 271 | - if r.pending { | 429 | + <section class="sec"> |
| 272 | - <span class="badge srv-pending">(g::t(lang, K::SrvRestartNeeded))</span> | 430 | + <h2>(tab_label(lang, group))</h2> |
| 273 | - } | 431 | + <form method="post" action="/admin/server" class="fields"> |
| 274 | - </span> | 432 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 275 | - if !r.help.is_empty() { | 433 | + <input type="hidden" name="tab" value=(tab)> |
| 276 | - <p class="row-status">(r.help)</p> | 434 | + for block in blocks.iter() { |
| 277 | - } | 435 | + if block.len() > 1 { |
| 278 | - if r.is_secret { | 436 | + <div class="field-pair"> |
| 279 | - <p class="row-status"><strong>(r.secret_state)</strong> ". " (g::t(lang, K::SrvSecretHint))</p> | 437 | + for r in block.iter() { |
| 280 | - } | 438 | + srv_row(lang: lang, row: r) |
| 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> | | |
| 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 | </div> | 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 | } else { | 441 | } else { |
| 308 | - <input type="text" name=(r.key) value=(r.value.as_str()) maxlength="1024" autocomplete="off" aria-label=(r.label)> | 442 | + for r in block.iter() { |
| 309 | - } | 443 | + srv_row(lang: lang, row: r) |
| 310 | - if r.has_override { | 444 | + } |
| 311 | - <button type="submit" form="srv-reset" name="key" value=(r.key)>(g::t(lang, K::SrvResetToFile))</button> | | |
| 312 | } | 445 | } |
| 313 | - </div> | 446 | + } |
| 314 | - </div> | 447 | + if any_editable { |
| 315 | - } | 448 | + <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> |
| 316 | - if any_editable { | 449 | + } |
| 317 | - <div class="row-foot"> | 450 | + </form> |
| 318 | - <button type="submit" class="primary">(i18n::t(lang, Key::Save))</button> | 451 | + </section> |
| 319 | - </div> | 452 | + } |
| 320 | - } | | |
| 321 | - </form> | | |
| 322 | <form id="srv-reset" method="post" action="/admin/server/reset"> | 453 | <form id="srv-reset" method="post" action="/admin/server/reset"> |
| 323 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 454 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 324 | <input type="hidden" name="tab" value=(tab)> | 455 | <input type="hidden" name="tab" value=(tab)> |
| 325 | </form> | 456 | </form> |
| 326 | - </section> | 457 | + <section class="sec"> |
| 327 | - <section class="card rows-pane"> | 458 | + <h2>(s(lang, "Restart server", "Sunucuyu yeniden başlat"))</h2> |
| 328 | - <div class="row-line"> | 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> |
| 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> | 460 | + if restart == Restart::Pending { |
| 330 | - <div class="row-main"> | 461 | + <p class="state">(s(lang, "A restart is in progress.", "Yeniden başlatma sürüyor."))</p> |
| 331 | - <h2 class="row-title">(s(lang, "Restart server", "Sunucuyu yeniden başlat"))</h2> | 462 | + } |
| 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> | | |
| 337 | if restart != Restart::Pending { | 463 | if restart != Restart::Pending { |
| 338 | - <details class="row-action danger"> | 464 | + <div class="acts"> |
| 339 | - <summary>(s(lang, "Restart server", "Sunucuyu yeniden başlat"))</summary> | 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())) |
| 340 | - <div class="row-panel"> | 466 | + </div> |
| 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> | | |
| 350 | } | 467 | } |
| 351 | - </div> | 468 | + </section> |
| 352 | - </section> | | |
| 353 | </div> | 469 | </div> |
| 354 | }) | 470 | }) |
| 355 | } | 471 | } |
| @@ -361,15 +477,22 @@ async fn server_page(cx: &Cx) -> Result<impl View> { |
| 361 | let state = app_context::<AppState>(cx); | 477 | let state = app_context::<AppState>(cx); |
| 362 | let lang = i18n::lang(cx, Some(&viewer.0)); | 478 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 363 | let group = query | 479 | let group = query |
| 364 | - .tab | 480 | + .cat |
| 365 | .as_deref() | 481 | .as_deref() |
| | 482 | + .or(query.tab.as_deref()) |
| 366 | .and_then(Group::parse) | 483 | .and_then(Group::parse) |
| 367 | .unwrap_or(Group::General); | 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 | let csrf = viewer.1.csrf_token.clone(); | 492 | let csrf = viewer.1.csrf_token.clone(); |
| 370 | let title = g::t(lang, K::ServerSettings); | 493 | let title = g::t(lang, K::ServerSettings); |
| 371 | Ok(view! { | 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 | Err(other) => other.to_string(), | 525 | Err(other) => other.to_string(), |
| 403 | }; | 526 | }; |
| 404 | Err(see_other(format!( | 527 | Err(see_other(format!( |
| 405 | - "/admin/server?tab={}¬ice={}", | 528 | + "/admin/server?cat={}¬ice={}", |
| 406 | group.slug(), | 529 | group.slug(), |
| 407 | enc(¬ice) | 530 | enc(¬ice) |
| 408 | )) | 531 | )) |
| @@ -485,7 +608,7 @@ async fn server_restart(cx: &Cx, Form(form): Form<RestartForm>) -> Result<Respon |
| 485 | self_update::request_restart(); | 608 | self_update::request_restart(); |
| 486 | }); | 609 | }); |
| 487 | Err(see_other(format!( | 610 | Err(see_other(format!( |
| 488 | - "/admin/server?tab={}&restarting={}", | 611 | + "/admin/server?cat={}&restarting={}", |
| 489 | group.slug(), | 612 | group.slug(), |
| 490 | enc(self_update::boot_id()) | 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 | Err(other) => other.to_string(), | 663 | Err(other) => other.to_string(), |
| 541 | }; | 664 | }; |
| 542 | Err(see_other(format!( | 665 | Err(see_other(format!( |
| 543 | - "/admin/server?tab={}¬ice={}", | 666 | + "/admin/server?cat={}¬ice={}", |
| 544 | group.slug(), | 667 | group.slug(), |
| 545 | enc(¬ice) | 668 | enc(¬ice) |
| 546 | )) | 669 | )) |
| @@ -1,6 +1,7 @@ |
| 1 | //! Page: one account for admins (`/admin/users/{id}`). Facts, suspend or lift, admin flag, a | 1 | //! Page: one account for admins (`/admin/users/{id}`). Facts, suspend or lift, admin flag, a |
| 2 | //! one-time password reset link and disabling two-factor for a locked-out user. Every action is | 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 | use forge_core::names::normalize_name; | 6 | use forge_core::names::normalize_name; |
| 6 | use forge_core::store::suspension::{AccountFacts, Suspension}; | 7 | use forge_core::store::suspension::{AccountFacts, Suspension}; |
| @@ -19,14 +20,14 @@ use crate::audit::{self, Actor, Target}; |
| 19 | use crate::auth::{check_csrf, two_factor_enabled}; | 20 | use crate::auth::{check_csrf, two_factor_enabled}; |
| 20 | use crate::i18n::accounts::{A, t as at}; | 21 | use crate::i18n::accounts::{A, t as at}; |
| 21 | use crate::i18n::admin::{self as g, K}; | 22 | use crate::i18n::admin::{self as g, K}; |
| | 23 | +use crate::i18n::orgs::{self as og, K as OG}; |
| 22 | use crate::i18n::{self, Key, Lang}; | 24 | use crate::i18n::{self, Key, Lang}; |
| 23 | use crate::live::{Topic, stream_changes}; | 25 | use crate::live::{Topic, stream_changes}; |
| 24 | use crate::pages::admin_users::admin_only; | 26 | use crate::pages::admin_users::admin_only; |
| 25 | use crate::pages::passkeys::s; | 27 | use crate::pages::passkeys::s; |
| 26 | use crate::state::AppState; | 28 | use crate::state::AppState; |
| 27 | -use crate::views::{ | 29 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 28 | - alert, avatar_url, enc, rel_time, rel_time_or_never, shell, user_facing_message, | 30 | +use crate::views::{alert, enc, rel_time, rel_time_or_never, shell, user_facing_message}; |
| 29 | -}; | | |
| 30 | | 31 | |
| 31 | #[query_params(error = bad_request)] | 32 | #[query_params(error = bad_request)] |
| 32 | pub(crate) struct DoneQuery { | 33 | pub(crate) struct DoneQuery { |
| @@ -134,11 +135,6 @@ async fn detail_body( |
| 134 | } else { | 135 | } else { |
| 135 | at(lang, A::Active) | 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 | let tfa_on = facts.two_factor; | 138 | let tfa_on = facts.two_factor; |
| 143 | let tfa = if tfa_on { | 139 | let tfa = if tfa_on { |
| 144 | at(lang, A::On) | 140 | at(lang, A::On) |
| @@ -146,12 +142,16 @@ async fn detail_body( |
| 146 | at(lang, A::Off) | 142 | at(lang, A::Off) |
| 147 | }; | 143 | }; |
| 148 | let is_admin = target.is_admin; | 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 | let suspended_note = match suspension.as_ref().map(|s| s.reason.clone()) { | 150 | let suspended_note = match suspension.as_ref().map(|s| s.reason.clone()) { |
| 150 | Some(reason) if !reason.is_empty() => reason, | 151 | Some(reason) if !reason.is_empty() => reason, |
| 151 | _ => at(lang, A::AccountSuspended).to_owned(), | 152 | _ => at(lang, A::AccountSuspended).to_owned(), |
| 152 | }; | 153 | }; |
| 153 | let email = target.email.clone().unwrap_or_default(); | 154 | let email = target.email.clone().unwrap_or_default(); |
| 154 | - let avatar = avatar_url(&target.username, target.avatar_hash.as_deref()); | | |
| 155 | let suspend_action = format!("{base}/suspend"); | 155 | let suspend_action = format!("{base}/suspend"); |
| 156 | let unsuspend_action = format!("{base}/unsuspend"); | 156 | let unsuspend_action = format!("{base}/unsuspend"); |
| 157 | let admin_action = format!("{base}/admin"); | 157 | let admin_action = format!("{base}/admin"); |
| @@ -161,176 +161,176 @@ async fn detail_body( |
| 161 | let passkey_count = passkeys.to_string(); | 161 | let passkey_count = passkeys.to_string(); |
| 162 | let delete_href = format!("{base}/delete"); | 162 | let delete_href = format!("{base}/delete"); |
| 163 | let live = format!("{base}/events"); | 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 | let Notice { done, error, link } = notice; | 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 | Ok(view! { | 200 | Ok(view! { |
| 166 | - <div data-live=(live.as_str()) class="user-page"> | 201 | + <div data-live=(live.as_str())> |
| 167 | - <section class="user-head"> | 202 | + <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 168 | - <a class="user-back small" href="/admin/users">"← "(g::t(lang, K::Users))</a> | 203 | + <h1 class="h1">(target.username.as_str())</h1> |
| 169 | - <div class="user-id"> | 204 | + <p class="hint"> |
| 170 | - <img class="avatar user-avatar" src=(avatar.as_str()) alt="" width="56" height="56"> | 205 | + if !email.is_empty() { |
| 171 | - <div class="user-id-text"> | 206 | + (email.as_str()) " · " |
| 172 | - <h1 class="user-name"> | 207 | + } |
| 173 | - <span class=(dot_class) role="img" aria-label=(status) title=(status)></span> | 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()) |
| 174 | - (target.username.as_str()) | 209 | + </p> |
| 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> | | |
| 196 | if let Some(message) = done { | 210 | if let Some(message) = done { |
| 197 | - <section class="card notice" role="status"> | 211 | + <p class="state" role="status">(message)</p> |
| 198 | - <p>(message)</p> | | |
| 199 | - </section> | | |
| 200 | } | 212 | } |
| 201 | if let Some(message) = error { | 213 | if let Some(message) = error { |
| 202 | alert(message: message.as_str()) | 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 | if suspended { | 222 | if suspended { |
| 206 | - <div class="row-line"> | 223 | + <p class="hint">(suspended_note.as_str())</p> |
| 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> | 224 | + <div class="acts"> |
| 208 | - <div class="row-main"> | 225 | + post_act(label: at(lang, A::Unsuspend), action: unsuspend_action.as_str(), csrf: csrf) |
| 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 | - } | | |
| 226 | </div> | 226 | </div> |
| 227 | - if !last_admin { | 227 | + } else { |
| 228 | - <form method="post" action=(admin_action.as_str()) class="row-form"> | 228 | + <p class="hint">(at(lang, A::SuspendHelp))</p> |
| 229 | - <input type="hidden" name="csrf" value=(csrf)> | 229 | + if own { |
| 230 | - <input type="hidden" name="admin" value=(if is_admin { "0" } else { "1" })> | 230 | + <p class="hint">(at(lang, A::ErrSelf))</p> |
| 231 | - <button type="submit">(if is_admin { at(lang, A::RevokeAdmin) } else { at(lang, A::GrantAdmin) })</button> | | |
| 232 | - </form> | | |
| 233 | } | 231 | } |
| 234 | - </div> | 232 | + if !own { |
| 235 | - <div class="row-line"> | 233 | + <div class="acts"> |
| 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> | 234 | + reveal(label: suspend_title, id: Some("suspend"), open: false, |
| 237 | - <div class="row-main"> | 235 | + <form method="post" action=(suspend_action.as_str()) class="fields"> |
| 238 | - <h2 class="row-title">(at(lang, A::ResetPassword))</h2> | 236 | + <input type="hidden" name="csrf" value=(csrf)> |
| 239 | - <p class="row-status">(at(lang, A::ResetHelp))</p> | 237 | + <div class="field"> |
| 240 | - if let Some(link) = link { | 238 | + <label for="suspend-reason">(at(lang, A::SuspendReason))</label> |
| 241 | - <p class="row-status">(at(lang, A::ResetLinkReady))</p> | 239 | + <input id="suspend-reason" type="text" name="reason" maxlength="300" autocomplete="off"> |
| 242 | - <code class="reset-link">(link.as_str())</code> | 240 | + </div> |
| 243 | - } | 241 | + <div class="acts"> |
| 244 | - </div> | 242 | + <button type="submit" class="act danger">(suspend_title)</button> |
| 245 | - <form method="post" action=(reset_action.as_str()) class="row-form"> | 243 | + </div> |
| 246 | - <input type="hidden" name="csrf" value=(csrf)> | 244 | + </form> |
| 247 | - <button type="submit">(at(lang, A::GenerateLink))</button> | 245 | + ) |
| 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 | - } | | |
| 262 | </div> | 246 | </div> |
| 263 | - if !own { | 247 | + } |
| 264 | - <details class="row-action danger"> | 248 | + } |
| 265 | - <summary>(at(lang, A::Suspend))</summary> | 249 | + <p class="hint">(admin_help)</p> |
| 266 | - <div class="row-panel"> | 250 | + if last_admin { |
| 267 | - <form method="post" action=(suspend_action.as_str()) class="stack"> | 251 | + <p class="hint">(at(lang, A::AdminHelp))</p> |
| 268 | - <input type="hidden" name="csrf" value=(csrf)> | 252 | + } |
| 269 | - <label> | 253 | + if !last_admin && is_admin { |
| 270 | - <span>(at(lang, A::SuspendReason))</span> | 254 | + <div class="acts"> |
| 271 | - <input type="text" name="reason" maxlength="300" autocomplete="off"> | 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())]) |
| 272 | - </label> | | |
| 273 | - <button type="submit" class="danger">(at(lang, A::Suspend))</button> | | |
| 274 | - </form> | | |
| 275 | - </div> | | |
| 276 | - </details> | | |
| 277 | - } | | |
| 278 | </div> | 256 | </div> |
| 279 | } | 257 | } |
| 280 | - <div class="row-line"> | 258 | + if !last_admin && !is_admin { |
| 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> | 259 | + <div class="acts"> |
| 282 | - <div class="row-main"> | 260 | + post_act(label: at(lang, A::GrantAdmin), action: admin_action.as_str(), csrf: csrf, fields: vec![("admin".to_owned(), "1".to_owned())]) |
| 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 | - } | | |
| 288 | </div> | 261 | </div> |
| 289 | - if tfa_on { | 262 | + } |
| 290 | - <form method="post" action=(tfa_action.as_str()) class="row-form"> | 263 | + </section> |
| 291 | - <input type="hidden" name="csrf" value=(csrf)> | 264 | + <section class="sec"> |
| 292 | - <button type="submit" class="danger">(g::t(lang, K::Disable))</button> | 265 | + <h2>(recovery_title)</h2> |
| 293 | - </form> | 266 | + <p class="state">(recovery_state.as_str())</p> |
| 294 | - } | 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 | </div> | 274 | </div> |
| 296 | - <div class="row-line"> | 275 | + if tfa_on { |
| 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> | 276 | + <p class="hint">(at(lang, A::Disable2faHelp))</p> |
| 298 | - <div class="row-main"> | 277 | + <div class="acts"> |
| 299 | - <h2 class="row-title">(s(lang, "Remove all passkeys", "Tüm geçiş anahtarlarını kaldır"))</h2> | 278 | + confirm_act(lang: lang, label: g::t(lang, K::Disable), action: tfa_action.as_str(), csrf: csrf) |
| 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 | - } | | |
| 304 | </div> | 279 | </div> |
| 305 | - if passkeys > 0 { | 280 | + } else { |
| 306 | - <details class="row-action danger"> | 281 | + <p class="hint">(at(lang, A::TwoFactorNotOn))</p> |
| 307 | - <summary>(s(lang, "Remove", "Kaldır"))</summary> | 282 | + } |
| 308 | - <div class="row-panel"> | 283 | + if passkeys > 0 { |
| 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> | 284 | + <p class="hint">(passkeys_help)</p> |
| 310 | - <form method="post" action=(passkeys_action.as_str()) class="row-form"> | 285 | + <div class="acts"> |
| 311 | - <input type="hidden" name="csrf" value=(csrf)> | 286 | + confirm_act(lang: lang, label: remove_label, action: passkeys_action.as_str(), csrf: csrf, note: Some(passkeys_question.to_owned())) |
| 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> | | |
| 327 | </div> | 287 | </div> |
| | 288 | + } else { |
| | 289 | + <p class="hint">(at(lang, A::NoPasskeysToRemove))</p> |
| 328 | } | 290 | } |
| 329 | </section> | 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 | </div> | 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 | /// What the page shows of one account, as one string. A missing or hidden account is a 404. | 334 | /// What the page shows of one account, as one string. A missing or hidden account is a 404. |
| 335 | async fn account_fingerprint(store: &Store, user_id: &str) -> Result<String> { | 335 | async fn account_fingerprint(store: &Store, user_id: &str) -> Result<String> { |
| 336 | let Some(target) = store.user_by_id(user_id).await? else { | 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 | let viewer = admin_only(cx).await?; | 377 | let viewer = admin_only(cx).await?; |
| 378 | let lang = i18n::lang(cx, Some(&viewer.0)); | 378 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 379 | let query = query_params::<DoneQuery>(cx)?; | 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 | let notice = Notice { | 399 | let notice = Notice { |
| 382 | done: query.done.as_deref().and_then(|d| done_text(lang, d)), | 400 | done: query.done.as_deref().and_then(|d| done_text(lang, d)), |
| 383 | ..Notice::default() | 401 | ..Notice::default() |
| 384 | }; | 402 | }; |
| 385 | let csrf = viewer.1.csrf_token.clone(); | 403 | let csrf = viewer.1.csrf_token.clone(); |
| 386 | - let title = detail.target.username.clone(); | | |
| 387 | Ok(view! { | 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 | use forge_core::names::{normalize_name, validate_username}; | 4 | use forge_core::names::{normalize_name, validate_username}; |
| 4 | use forge_core::store::orgs::OrgMemberRole; | 5 | use forge_core::store::orgs::OrgMemberRole; |
| @@ -10,19 +11,27 @@ use topcoat::context::{Cx, app_context}; |
| 10 | use topcoat::router::content::Form; | 11 | use topcoat::router::content::Form; |
| 11 | use topcoat::router::error::{forbidden, not_found, see_other}; | 12 | use topcoat::router::error::{forbidden, not_found, see_other}; |
| 12 | use topcoat::router::response::Response; | 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 | use topcoat::view::{View, component, view}; | 15 | use topcoat::view::{View, component, view}; |
| 15 | | 16 | |
| 16 | use crate::audit::{self, Actor, Target}; | 17 | use crate::audit::{self, Actor, Target}; |
| 17 | use crate::auth::{check_csrf, current_user, hash_password_async}; | 18 | use crate::auth::{check_csrf, current_user, hash_password_async}; |
| 18 | use crate::i18n::admin::{self as g, K}; | 19 | use crate::i18n::admin::{self as g, K}; |
| | 20 | +use crate::i18n::orgs::{self as og, K as OG}; |
| 19 | use crate::i18n::{self, Key, Lang}; | 21 | use crate::i18n::{self, Key, Lang}; |
| 20 | use crate::live::{Topic, stream_changes}; | 22 | use crate::live::{Topic, stream_changes}; |
| | 23 | +use crate::pages::passkeys::s; |
| 21 | use crate::state::AppState; | 24 | use crate::state::AppState; |
| | 25 | +use crate::views::parts::reveal; |
| | 26 | +use crate::views::repo_list::{pager, pager_links}; |
| 22 | use crate::views::{alert, enc, rel_time, shell, user_facing_message}; | 27 | use crate::views::{alert, enc, rel_time, shell, user_facing_message}; |
| 23 | | 28 | |
| 24 | const MIN_PASSWORD_CHARS: usize = 12; | 29 | const MIN_PASSWORD_CHARS: usize = 12; |
| 25 | const MAX_PASSWORD_BYTES: usize = 1024; | 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 | #[derive(Deserialize)] | 36 | #[derive(Deserialize)] |
| 28 | struct CreateUserForm { | 37 | struct CreateUserForm { |
| @@ -47,6 +56,92 @@ struct DeleteForm { |
| 47 | confirm_username: String, | 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 | /// The ghost account is reserved and never shown as a deletable user. | 145 | /// The ghost account is reserved and never shown as a deletable user. |
| 51 | fn is_ghost(user: &User) -> bool { | 146 | fn is_ghost(user: &User) -> bool { |
| 52 | normalize_name(&user.username) == GHOST_USERNAME | 147 | normalize_name(&user.username) == GHOST_USERNAME |
| @@ -55,33 +150,20 @@ fn is_ghost(user: &User) -> bool { |
| 55 | /// One account row of the list, with the text and links it shows already decided. | 150 | /// One account row of the list, with the text and links it shows already decided. |
| 56 | struct UserRow { | 151 | struct UserRow { |
| 57 | href: String, | 152 | href: String, |
| 58 | - delete_href: String, | | |
| 59 | username: String, | 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 | linkable: bool, | 155 | linkable: bool, |
| 62 | - /// Nobody deletes their own account here, and the ghost account is never deleted. | | |
| 63 | - deletable: bool, | | |
| 64 | email: String, | 156 | email: String, |
| 65 | role: String, | 157 | role: String, |
| 66 | created_at: String, | 158 | created_at: String, |
| 67 | } | 159 | } |
| 68 | | 160 | |
| 69 | -#[component] | 161 | +impl UserRow { |
| 70 | -async fn users_view( | 162 | + fn new(lang: Lang, user: &User) -> UserRow { |
| 71 | - lang: Lang, | 163 | + UserRow { |
| 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 { | | |
| 80 | href: format!("/admin/users/{}", enc(&user.id)), | 164 | href: format!("/admin/users/{}", enc(&user.id)), |
| 81 | - delete_href: format!("/admin/users/{}/delete", enc(&user.id)), | | |
| 82 | username: user.username.clone(), | 165 | username: user.username.clone(), |
| 83 | - linkable: !(user.is_org() || is_ghost(user)), | 166 | + linkable: !is_ghost(user), |
| 84 | - deletable: user.id != viewer_id && !is_ghost(user), | | |
| 85 | email: user.email.clone().unwrap_or_default(), | 167 | email: user.email.clone().unwrap_or_default(), |
| 86 | role: if user.is_org() { | 168 | role: if user.is_org() { |
| 87 | g::t(lang, K::RoleOrganization).to_owned() | 169 | g::t(lang, K::RoleOrganization).to_owned() |
| @@ -91,73 +173,120 @@ async fn users_view( |
| 91 | g::t(lang, K::RoleUser).to_owned() | 173 | g::t(lang, K::RoleUser).to_owned() |
| 92 | }, | 174 | }, |
| 93 | created_at: user.created_at.clone(), | 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 | .collect(); | 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 | Ok(view! { | 223 | Ok(view! { |
| 97 | <div data-live="/admin/users/events"> | 224 | <div data-live="/admin/users/events"> |
| 98 | - <section class="page-head"> | 225 | + <h1 class="sr-only">(g::t(lang, K::Users))</h1> |
| 99 | - <h1>(g::t(lang, K::Users))</h1> | 226 | + <form class="plain-search" method="get" action="/admin/users" role="search"> |
| 100 | - </section> | 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> |
| 101 | - <section class="card rows-pane"> | 228 | + <label class="sr-only" for="user-search">(search_label)</label> |
| 102 | - <div class="row-line"> | 229 | + <input id="user-search" type="search" name="q" value=(q.as_str()) placeholder=(search_label) data-live-search="" autocomplete="off"> |
| 103 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 230 | + <input type="hidden" name="kind" value=(kind.key())> |
| 104 | - <div class="row-main"> | 231 | + </form> |
| 105 | - <h2 class="row-title">(g::t(lang, K::CreateAUser))</h2> | 232 | + <nav class="sub" aria-label=(filter_label)> |
| 106 | - </div> | 233 | + <a href=(all_href.as_str()) aria-current=((kind == Kind::All).then_some("page"))>(all_label.as_str())</a> |
| 107 | - <details class="row-action" open=(error.is_some())> | 234 | + <a href=(people_href.as_str()) aria-current=((kind == Kind::People).then_some("page"))>(people_label.as_str())</a> |
| 108 | - <summary>(g::t(lang, K::CreateUser))</summary> | 235 | + <a href=(orgs_href.as_str()) aria-current=((kind == Kind::Organizations).then_some("page"))>(orgs_label.as_str())</a> |
| 109 | - <div class="row-panel"> | 236 | + reveal(label: g::t(lang, K::CreateUser), id: Some("create-user"), open: open, |
| 110 | - if let Some(message) = error { | 237 | + if let Some(message) = error { |
| 111 | - alert(message: message.as_str()) | 238 | + alert(message: message.as_str()) |
| 112 | - } | 239 | + } |
| 113 | - <form method="post" action="/admin/users" class="stack"> | 240 | + <form method="post" action="/admin/users" class="fields"> |
| 114 | - <input type="hidden" name="csrf" value=(csrf)> | 241 | + <input type="hidden" name="csrf" value=(csrf)> |
| 115 | - <label> | 242 | + <div class="field"> |
| 116 | - <span>(i18n::t(lang, Key::Username))</span> | 243 | + <label for="new-username">(i18n::t(lang, Key::Username))</label> |
| 117 | - <input type="text" name="username" required=(true) autocomplete="off"> | 244 | + <input id="new-username" 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> | | |
| 134 | </div> | 245 | </div> |
| 135 | - </details> | 246 | + <div class="field"> |
| 136 | - </div> | 247 | + <label for="new-email">(i18n::t(lang, Key::EmailOptional))</label> |
| 137 | - for row in rows.into_iter() { | 248 | + <input id="new-email" type="email" name="email" autocomplete="off"> |
| 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> | | |
| 154 | </div> | 249 | </div> |
| 155 | - if row.deletable { | 250 | + <div class="field"> |
| 156 | - <a class="button danger" href=(row.delete_href.as_str())>(i18n::t(lang, Key::Delete))</a> | 251 | + <label for="new-password">(i18n::t(lang, Key::Password))</label> |
| 157 | - } | 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 | </div> | 286 | </div> |
| 159 | } | 287 | } |
| 160 | - </section> | 288 | + } |
| | 289 | + pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 161 | </div> | 290 | </div> |
| 162 | }) | 291 | }) |
| 163 | } | 292 | } |
| @@ -198,11 +327,12 @@ async fn users_events(cx: &Cx) -> Result<Response> { |
| 198 | async fn users_page(cx: &Cx) -> Result<impl View> { | 327 | async fn users_page(cx: &Cx) -> Result<impl View> { |
| 199 | let viewer = admin_only(cx).await?; | 328 | let viewer = admin_only(cx).await?; |
| 200 | let lang = i18n::lang(cx, Some(&viewer.0)); | 329 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| | 330 | + let (q, kind, page) = listing_args(query_params::<UsersQuery>(cx)?); |
| 201 | let users = app_context::<AppState>(cx).store.list_users().await?; | 331 | let users = app_context::<AppState>(cx).store.list_users().await?; |
| 202 | let csrf = viewer.1.csrf_token.clone(); | 332 | let csrf = viewer.1.csrf_token.clone(); |
| 203 | let title = g::t(lang, K::Users); | 333 | let title = g::t(lang, K::Users); |
| 204 | Ok(view! { | 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 | let csrf = viewer.1.csrf_token.clone(); | 369 | let csrf = viewer.1.csrf_token.clone(); |
| 240 | let title = g::t(lang, K::Users); | 370 | let title = g::t(lang, K::Users); |
| 241 | Ok(view! { | 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 | let action = format!("/admin/users/{}/delete", enc(&target.id)); | 481 | let action = format!("/admin/users/{}/delete", enc(&target.id)); |
| 352 | let prompt = g::type_to_confirm(lang, &target.username); | 482 | let prompt = g::type_to_confirm(lang, &target.username); |
| 353 | Ok(view! { | 483 | Ok(view! { |
| 354 | - <section class="page-head"> | 484 | + <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 355 | - <h1>(g::t(lang, K::DeleteUser))</h1> | 485 | + <h1 class="sr-only">(g::t(lang, K::DeleteUser))</h1> |
| 356 | - </section> | 486 | + if let Some(message) = error { |
| 357 | - <section class="card"> | 487 | + alert(message: message.as_str()) |
| 358 | - if let Some(message) = error { | 488 | + } |
| 359 | - alert(message: message.as_str()) | 489 | + if let Some(message) = refusal { |
| 360 | - } | 490 | + alert(message: message.as_str()) |
| 361 | - if let Some(message) = refusal { | 491 | + } |
| 362 | - alert(message: message.as_str()) | 492 | + <p class="state">(g::t(lang, K::DeletesAccount))<strong>(target.username.as_str())</strong>(g::t(lang, K::DeleteAccountRest))</p> |
| 363 | - } | 493 | + if has_repos { |
| 364 | - <p>(g::t(lang, K::DeletesAccount))<strong>(target.username.as_str())</strong>(g::t(lang, K::DeleteAccountRest))</p> | 494 | + <p class="hint">(g::t(lang, K::TransferOrDeleteFirst))</p> |
| 365 | - if has_repos { | 495 | + <ul class="item-list"> |
| 366 | - <p>(g::t(lang, K::TransferOrDeleteFirst))</p> | 496 | + for name in repos.into_iter() { |
| 367 | - <ul class="item-list"> | 497 | + <li>(name)</li> |
| 368 | - for name in repos.into_iter() { | 498 | + } |
| 369 | - <li>(name)</li> | 499 | + </ul> |
| 370 | - } | 500 | + } |
| 371 | - </ul> | 501 | + if let Some(impact) = impact { |
| 372 | - } | 502 | + <section class="sec"> |
| 373 | - if let Some(impact) = impact { | | |
| 374 | <h2>(g::t(lang, K::WhatHappens))</h2> | 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 | <ul class="item-list"> | 505 | <ul class="item-list"> |
| 377 | for line in impact.moved.into_iter() { | 506 | for line in impact.moved.into_iter() { |
| 378 | <li>(line)</li> | 507 | <li>(line)</li> |
| 379 | } | 508 | } |
| 380 | </ul> | 509 | </ul> |
| 381 | - <p>(g::t(lang, K::RemovedWithAccount))</p> | 510 | + <p class="hint">(g::t(lang, K::RemovedWithAccount))</p> |
| 382 | <ul class="item-list"> | 511 | <ul class="item-list"> |
| 383 | for line in impact.removed.into_iter() { | 512 | for line in impact.removed.into_iter() { |
| 384 | <li>(line)</li> | 513 | <li>(line)</li> |
| 385 | } | 514 | } |
| 386 | </ul> | 515 | </ul> |
| 387 | - <form method="post" action=(action.as_str()) class="stack"> | 516 | + </section> |
| 388 | - <input type="hidden" name="csrf" value=(csrf)> | 517 | + <form method="post" action=(action.as_str()) class="fields"> |
| 389 | - <label> | 518 | + <input type="hidden" name="csrf" value=(csrf)> |
| 390 | - <span>(prompt.as_str())</span> | 519 | + <div class="field"> |
| 391 | - <input type="text" name="confirm_username" autocomplete="off" required=(true)> | 520 | + <label for="confirm-username">(prompt.as_str())</label> |
| 392 | - </label> | 521 | + <input id="confirm-username" type="text" name="confirm_username" autocomplete="off" required=(true)> |
| 393 | - <button type="submit" class="danger">(g::t(lang, K::DeleteUser))</button> | 522 | + </div> |
| 394 | - </form> | 523 | + <div class="acts"> |
| 395 | - } | 524 | + <button type="submit" class="act danger">(g::t(lang, K::DeleteUser))</button> |
| 396 | - <p><a href="/admin/users">(g::t(lang, K::BackToUsers))</a></p> | 525 | + </div> |
| 397 | - </section> | 526 | + </form> |
| | 527 | + } |
| 398 | }) | 528 | }) |
| 399 | } | 529 | } |
| 400 | | 530 | |
| @@ -410,29 +540,24 @@ async fn org_delete_note( |
| 410 | let settings = format!("/org/{}/settings", enc(&target.username)); | 540 | let settings = format!("/org/{}/settings", enc(&target.username)); |
| 411 | let profile = format!("/{}", enc(&target.username)); | 541 | let profile = format!("/{}", enc(&target.username)); |
| 412 | Ok(view! { | 542 | Ok(view! { |
| 413 | - <section class="page-head"> | 543 | + <a class="act back-act" href="/admin/users">(g::t(lang, K::BackToUsers))</a> |
| 414 | - <h1>(g::t(lang, K::DeleteOrgTitle))</h1> | 544 | + <h1 class="sr-only">(g::t(lang, K::DeleteOrgTitle))</h1> |
| 415 | - </section> | 545 | + <p class="state"><strong>(target.username.as_str())</strong>(g::t(lang, K::OrgNotAUser))</p> |
| 416 | - <section class="card"> | 546 | + if has_repos { |
| 417 | - <p><strong>(target.username.as_str())</strong>(g::t(lang, K::OrgNotAUser))</p> | 547 | + <p class="hint">(g::t(lang, K::OrgReposFirst))</p> |
| 418 | - if has_repos { | 548 | + <ul class="item-list"> |
| 419 | - <p>(g::t(lang, K::OrgReposFirst))</p> | 549 | + for name in repos.into_iter() { |
| 420 | - <ul class="item-list"> | 550 | + <li>(name)</li> |
| 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> | | |
| 431 | } | 551 | } |
| 432 | - " · " | 552 | + </ul> |
| 433 | - <a href="/admin/users">(g::t(lang, K::BackToUsers))</a> | 553 | + } |
| 434 | - </p> | 554 | + <div class="acts"> |
| 435 | - </section> | 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 | use crate::pages::admin_users::admin_only; | 17 | use crate::pages::admin_users::admin_only; |
| 18 | use crate::pages::issues_list::list_href; | 18 | use crate::pages::issues_list::list_href; |
| 19 | use crate::state::AppState; | 19 | use crate::state::AppState; |
| 20 | -use crate::views::{empty_state, rel_time, shell}; | 20 | +use crate::views::{rel_time, shell}; |
| 21 | | 21 | |
| 22 | /// Entries per page of the admin audit log, under its filter bar. | 22 | /// Entries per page of the admin audit log, under its filter bar. |
| 23 | const ADMIN_PAGE_SIZE: usize = 8; | 23 | const ADMIN_PAGE_SIZE: usize = 8; |
| @@ -98,38 +98,26 @@ async fn fetch_page( |
| 98 | async fn audit_table(lang: Lang, rows: Vec<RowView>, show_actor: bool) -> Result<impl View> { | 98 | async fn audit_table(lang: Lang, rows: Vec<RowView>, show_actor: bool) -> Result<impl View> { |
| 99 | Ok(view! { | 99 | Ok(view! { |
| 100 | if rows.is_empty() { | 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 | } else { | 102 | } else { |
| 103 | - <div class="table-wrap"> | 103 | + for row in rows.into_iter() { |
| 104 | - <table class="table audit-table queue-table"> | 104 | + <div class="line" data-kb-row=""> |
| 105 | - <thead> | 105 | + <span class="name"><code>(row.action.as_str())</code></span> |
| 106 | - <tr> | 106 | + <span class="val"> |
| 107 | - <th>(g::t(lang, K::TableWhen))</th> | 107 | + rel_time(lang: lang, stamp: row.when.as_str()) |
| 108 | - if show_actor { | 108 | + if show_actor { |
| 109 | - <th>(g::t(lang, K::TableActor))</th> | 109 | + " · " (row.actor.as_str()) |
| 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> | | |
| 129 | } | 110 | } |
| 130 | - </tbody> | 111 | + " · " (row.target.as_str()) |
| 131 | - </table> | 112 | + </span> |
| 132 | - </div> | 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 | ) -> Result<impl View> { | 134 | ) -> Result<impl View> { |
| 147 | Ok(view! { | 135 | Ok(view! { |
| 148 | <div data-live=(live.as_str())> | 136 | <div data-live=(live.as_str())> |
| 149 | - <section class="page-head"> | 137 | + <h1 class="sr-only">(g::t(lang, K::AuditLog))</h1> |
| 150 | - <h1>(g::t(lang, K::AuditLog))</h1> | 138 | + <p class="hint">(g::t(lang, K::AuditIntro))</p> |
| 151 | - </section> | 139 | + <form method="get" action="/admin/audit"> |
| 152 | - <p class="muted page-lede">(g::t(lang, K::AuditIntro))</p> | 140 | + <div class="plain-search"> |
| 153 | - <section class="card"> | 141 | + <label class="sr-only" for="audit-actor">(g::t(lang, K::ActorUsername))</label> |
| 154 | - <form method="get" action="/admin/audit" class="filter-bar"> | 142 | + <input id="audit-actor" type="text" name="actor" value=(actor.as_str()) autocomplete="off"> |
| 155 | - <label class="filter-action"> | 143 | + <button type="submit" class="act">(g::t(lang, K::Filter))</button> |
| 156 | - <span>(g::t(lang, K::ActionLabel))</span> | 144 | + </div> |
| | 145 | + <div class="sub"> |
| | 146 | + <label> |
| | 147 | + (g::t(lang, K::ActionLabel)) " " |
| 157 | <select name="action" data-autosubmit="true"> | 148 | <select name="action" data-autosubmit="true"> |
| 158 | <option value="" selected=(action.is_empty())>(g::t(lang, K::AllActions))</option> | 149 | <option value="" selected=(action.is_empty())>(g::t(lang, K::AllActions))</option> |
| 159 | for known in AuditAction::ALL.iter().copied() { | 150 | for known in AuditAction::ALL.iter().copied() { |
| @@ -161,26 +152,17 @@ async fn admin_audit_view( |
| 161 | } | 152 | } |
| 162 | </select> | 153 | </select> |
| 163 | </label> | 154 | </label> |
| 164 | - <label class="filter-actor"> | 155 | + </div> |
| 165 | - <span>(g::t(lang, K::ActorUsername))</span> | 156 | + </form> |
| 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> | | |
| 171 | if let Some(message) = notice { | 157 | if let Some(message) = notice { |
| 172 | - <section class="card notice" role="status"> | 158 | + <p class="state" role="status">(message.as_str())</p> |
| 173 | - <p>(message.as_str())</p> | 159 | + } |
| 174 | - </section> | 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 | </div> | 166 | </div> |
| 185 | }) | 167 | }) |
| 186 | } | 168 | } |
| @@ -192,18 +174,14 @@ async fn own_log_view( |
| 192 | older_href: Option<String>, | 174 | older_href: Option<String>, |
| 193 | ) -> Result<impl View> { | 175 | ) -> Result<impl View> { |
| 194 | Ok(view! { | 176 | Ok(view! { |
| 195 | - <section class="page-head"> | 177 | + <h1 class="sr-only">(g::t(lang, K::SecurityLogTitle))</h1> |
| 196 | - <h1>(g::t(lang, K::SecurityLogTitle))</h1> | 178 | + <p class="hint">(g::t(lang, K::OwnLogIntro))</p> |
| 197 | - </section> | 179 | + audit_table(lang: lang, rows: rows, show_actor: false) |
| 198 | - <p class="muted page-lede">(g::t(lang, K::OwnLogIntro))</p> | 180 | + if let Some(href) = older_href { |
| 199 | - <section class="card fit-pane fit-list"> | 181 | + <nav class="sub"> |
| 200 | - audit_table(lang: lang, rows: rows, show_actor: false) | 182 | + <a href=(href.as_str())>(g::t(lang, K::Older))</a> |
| 201 | - if let Some(href) = older_href { | 183 | + </nav> |
| 202 | - <nav class="pager"> | 184 | + } |
| 203 | - <a href=(href.as_str())>(g::t(lang, K::Older))</a> | | |
| 204 | - </nav> | | |
| 205 | - } | | |
| 206 | - </section> | | |
| 207 | }) | 185 | }) |
| 208 | } | 186 | } |
| 209 | | 187 | |
| @@ -228,16 +228,16 @@ async fn blame_page(cx: &Cx) -> Result<impl View> { |
| 228 | <div class="browse-bar"> | 228 | <div class="browse-bar"> |
| 229 | breadcrumb(lang: lang, crumbs: crumbs) | 229 | breadcrumb(lang: lang, crumbs: crumbs) |
| 230 | </div> | 230 | </div> |
| 231 | - <section class="file fit-pane" data-lines=""> | 231 | + <section class="file" data-lines=""> |
| 232 | <header class="file-head"> | 232 | <header class="file-head"> |
| 233 | - <span class="muted small">(b::t(lang, b::K::BlameTitle)) " \u{b7} " (size)</span> | 233 | + <span class="hint">(b::t(lang, b::K::BlameTitle)) " \u{b7} " (size)</span> |
| 234 | - <nav class="file-actions" aria-label=(g::t(lang, K::FileNav))> | 234 | + <nav class="acts file-actions" aria-label=(g::t(lang, K::FileNav))> |
| 235 | - <a href=(blob_href.as_str())>(b::t(lang, b::K::BlameBackToFile))</a> | 235 | + <a class="act" href=(blob_href.as_str())>(b::t(lang, b::K::BlameBackToFile))</a> |
| 236 | - <a href=(history.as_str())>(g::t(lang, K::HistoryLink))</a> | 236 | + <a class="act" href=(history.as_str())>(g::t(lang, K::HistoryLink))</a> |
| 237 | </nav> | 237 | </nav> |
| 238 | </header> | 238 | </header> |
| 239 | if let Some(text) = message { | 239 | if let Some(text) = message { |
| 240 | - <p class="notice">(text)</p> | 240 | + <p class="state">(text)</p> |
| 241 | } | 241 | } |
| 242 | if has_rows { | 242 | if has_rows { |
| 243 | blame_table(rows: rows, lang: lang) | 243 | blame_table(rows: rows, lang: lang) |
| @@ -280,21 +280,21 @@ async fn blob_page(cx: &Cx) -> Result<impl View> { |
| 280 | breadcrumb(lang: lang, crumbs: crumbs) | 280 | breadcrumb(lang: lang, crumbs: crumbs) |
| 281 | file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) | 281 | file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) |
| 282 | </div> | 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 | <header class="file-head"> | 284 | <header class="file-head"> |
| 285 | - <span class="muted small">(size)</span> | 285 | + <span class="hint">(size)</span> |
| 286 | - <nav class="file-actions" aria-label=(g::t(lang, K::FileNav))> | 286 | + <nav class="acts file-actions" aria-label=(g::t(lang, K::FileNav))> |
| 287 | if let Some((label, href)) = toggle { | 287 | if let Some((label, href)) = toggle { |
| 288 | - <a href=(href)>(label)</a> | 288 | + <a class="act" href=(href)>(label)</a> |
| 289 | } | 289 | } |
| 290 | if is_text { | 290 | if is_text { |
| 291 | - <a href=(blame.as_str())>(b::t(lang, b::K::BlameLink))</a> | 291 | + <a class="act" 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)) | 292 | + <button type="button" class="act" data-copy-permalink="" title=(b::t(lang, b::K::PermalinkHint)) |
| 293 | data-copied=(b::t(lang, b::K::PermalinkCopied))>(b::t(lang, b::K::CopyPermalink))</button> | 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> | 295 | + <a class="act" href=(history)>(g::t(lang, K::HistoryLink))</a> |
| 296 | - <a href=(raw.clone())>(g::t(lang, K::RawLink))</a> | 296 | + <a class="act" href=(raw.clone())>(g::t(lang, K::RawLink))</a> |
| 297 | - <a href=(download_href) download=(download_name)>(g::t(lang, K::DownloadLink))</a> | 297 | + <a class="act" href=(download_href) download=(download_name)>(g::t(lang, K::DownloadLink))</a> |
| 298 | </nav> | 298 | </nav> |
| 299 | </header> | 299 | </header> |
| 300 | if kind == "image" { | 300 | if kind == "image" { |
| @@ -309,19 +309,19 @@ async fn blob_page(cx: &Cx) -> Result<impl View> { |
| 309 | file_table(lines: lines) | 309 | file_table(lines: lines) |
| 310 | } | 310 | } |
| 311 | if kind == "lfs" { | 311 | if kind == "lfs" { |
| 312 | - <p class="notice">(note.clone())</p> | 312 | + <p class="state">(note.clone())</p> |
| 313 | } | 313 | } |
| 314 | if kind == "binary" { | 314 | if kind == "binary" { |
| 315 | - <p class="notice">(note.clone())</p> | 315 | + <p class="state">(note.clone())</p> |
| 316 | } | 316 | } |
| 317 | if kind == "symlink" { | 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 | if kind == "submodule" { | 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 | if truncated { | 323 | if truncated { |
| 324 | - <p class="notice">(g::t(lang, K::TruncatedPrefix)) | 324 | + <p class="hint">(g::t(lang, K::TruncatedPrefix)) |
| 325 | <a href=(raw)>(g::t(lang, K::ViewFullRaw))</a> "."</p> | 325 | <a href=(raw)>(g::t(lang, K::ViewFullRaw))</a> "."</p> |
| 326 | } | 326 | } |
| 327 | </section> | 327 | </section> |
| @@ -30,7 +30,8 @@ use crate::pages::tree::{LastCommit, last_commit_view}; |
| 30 | use crate::post_update::after_ref_update; | 30 | use crate::post_update::after_ref_update; |
| 31 | use crate::state::AppState; | 31 | use crate::state::AppState; |
| 32 | use crate::views::commit_line::commit_line; | 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 | path_param!(owner); | 36 | path_param!(owner); |
| 36 | path_param!(repo); | 37 | path_param!(repo); |
| @@ -97,7 +98,6 @@ struct BranchRow { |
| 97 | counts: Option<String>, | 98 | counts: Option<String>, |
| 98 | up_to_date: bool, | 99 | up_to_date: bool, |
| 99 | pr_href: Option<String>, | 100 | pr_href: Option<String>, |
| 100 | - delete_label: String, | | |
| 101 | } | 101 | } |
| 102 | | 102 | |
| 103 | #[component] | 103 | #[component] |
| @@ -109,19 +109,18 @@ async fn new_branch_form( |
| 109 | options: Vec<String>, | 109 | options: Vec<String>, |
| 110 | ) -> Result<impl View> { | 110 | ) -> Result<impl View> { |
| 111 | Ok(view! { | 111 | Ok(view! { |
| 112 | - <details class="new-branch"> | 112 | + reveal(label: b::t(lang, b::K::NewBranchTitle), id: Some("new-branch"), |
| 113 | - <summary class="button">(b::t(lang, b::K::NewBranchTitle))</summary> | 113 | + <form method="post" action=(action.as_str()) class="fields"> |
| 114 | - <form method="post" action=(action.as_str()) class="new-branch-form"> | | |
| 115 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 114 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 116 | - <label> | 115 | + <div class="field"> |
| 117 | - <span>(b::t(lang, b::K::BranchNameLabel))</span> | 116 | + <label for="branch-name">(b::t(lang, b::K::BranchNameLabel))</label> |
| 118 | - <input type="text" name="name" required=(true) autocomplete="off" spellcheck="false" maxlength="200"> | 117 | + <input id="branch-name" type="text" name="name" required=(true) autocomplete="off" spellcheck="false" maxlength="200"> |
| 119 | - </label> | 118 | + </div> |
| 120 | - <label> | 119 | + <div class="field"> |
| 121 | - <span>(b::t(lang, b::K::BranchFromLabel))</span> | 120 | + <label for="branch-from">(b::t(lang, b::K::BranchFromLabel))</label> |
| 122 | - <input type="text" name="from" list="branch-sources" value=(default_branch.as_str()) | 121 | + <input id="branch-from" type="text" name="from" list="branch-sources" value=(default_branch.as_str()) |
| 123 | placeholder=(b::t(lang, b::K::BranchFromPlaceholder)) autocomplete="off" spellcheck="false"> | 122 | placeholder=(b::t(lang, b::K::BranchFromPlaceholder)) autocomplete="off" spellcheck="false"> |
| 124 | - </label> | 123 | + </div> |
| 125 | <datalist id="branch-sources"> | 124 | <datalist id="branch-sources"> |
| 126 | for option in options.iter() { | 125 | for option in options.iter() { |
| 127 | <option value=(option.as_str())></option> | 126 | <option value=(option.as_str())></option> |
| @@ -129,7 +128,7 @@ async fn new_branch_form( |
| 129 | </datalist> | 128 | </datalist> |
| 130 | <button type="submit" class="primary">(b::t(lang, b::K::CreateBranch))</button> | 129 | <button type="submit" class="primary">(b::t(lang, b::K::CreateBranch))</button> |
| 131 | </form> | 130 | </form> |
| 132 | - </details> | 131 | + ) |
| 133 | }) | 132 | }) |
| 134 | } | 133 | } |
| 135 | | 134 | |
| @@ -142,68 +141,39 @@ async fn branch_table( |
| 142 | can_delete: bool, | 141 | can_delete: bool, |
| 143 | ) -> Result<impl View> { | 142 | ) -> Result<impl View> { |
| 144 | Ok(view! { | 143 | Ok(view! { |
| 145 | - <div class="table-wrap"> | 144 | + <div> |
| 146 | - <table class="table refs-table branch-table"> | 145 | + for row in rows.into_iter() { |
| 147 | - <thead> | 146 | + <details class="row-open" data-kb-row=""> |
| 148 | - <tr> | 147 | + <summary class="line"> |
| 149 | - <th>(g::t(lang, K::BranchLabel))</th> | 148 | + <a class="name" href=(row.href.as_str())>(row.name.as_str())</a> |
| 150 | - <th>(g::t(lang, K::LastCommitHeader))</th> | 149 | + if row.is_default { |
| 151 | - <th>(b::t(lang, b::K::BranchAuthorHeader))</th> | 150 | + <span class="badge public">(g::t(lang, K::DefaultBadge))</span> |
| 152 | - <th>(b::t(lang, b::K::BranchAheadBehindHeader))</th> | 151 | + } |
| 153 | - <th class="branch-actions-col">(b::t(lang, b::K::BranchActionsHeader))</th> | 152 | + <span class="val">(row.author.as_str()) " · " <time data-rel="true" datetime=(row.iso.as_str())>(row.age.as_str())</time> |
| 154 | - </tr> | 153 | + if let Some(counts) = row.counts { |
| 155 | - </thead> | 154 | + " · " (counts.as_str()) |
| 156 | - <tbody> | 155 | + } else if row.up_to_date { |
| 157 | - for row in rows.into_iter() { | 156 | + " · " (b::t(lang, b::K::UpToDate)) |
| 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> | | |
| 171 | } | 157 | } |
| 172 | - <td class="branch-author"> | 158 | + </span> |
| 173 | - <span>(row.author.as_str())</span> | 159 | + </summary> |
| 174 | - <span class="muted small"><time data-rel="true" datetime=(row.iso.as_str())>(row.age.as_str())</time></span> | 160 | + <div class="opened"> |
| 175 | - </td> | 161 | + if let Some(last) = row.last { |
| 176 | - <td class="branch-counts"> | 162 | + <p class="state"><a href=(last.href.as_str())>commit_line(subject: last.summary.clone())</a></p> |
| 177 | - if let Some(counts) = row.counts { | 163 | + } |
| 178 | - <span class="small">(counts.as_str())</span> | 164 | + <div class="acts"> |
| 179 | - } else if row.up_to_date { | 165 | + if let Some(pr) = row.pr_href { |
| 180 | - <span class="muted small">(b::t(lang, b::K::UpToDate))</span> | 166 | + <a class="act" href=(pr.as_str())>(b::t(lang, b::K::NewPr))</a> |
| 181 | - } | 167 | + } |
| 182 | - </td> | 168 | + if can_delete && !row.is_default { |
| 183 | - <td class="branch-actions"> | 169 | + confirm_act(lang: lang, label: b::t(lang, b::K::DeleteBranch), action: delete_action.as_str(), csrf: csrf.as_str(), |
| 184 | - if let Some(pr) = row.pr_href { | 170 | + fields: vec![("name".to_owned(), row.name.clone()), ("oid".to_owned(), row.oid.clone())], |
| 185 | - <a class="button small" href=(pr.as_str())>(b::t(lang, b::K::NewPr))</a> | 171 | + note: Some(b::t(lang, b::K::DeleteConfirm).to_owned())) |
| 186 | - } | 172 | + } |
| 187 | - if can_delete && !row.is_default { | 173 | + </div> |
| 188 | - <details class="confirm-inline"> | 174 | + </div> |
| 189 | - <summary class="button small danger" aria-label=(row.delete_label.as_str())>(b::t(lang, b::K::DeleteBranch))</summary> | 175 | + </details> |
| 190 | - <div class="confirm-pop"> | 176 | + } |
| 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> | | |
| 207 | </div> | 177 | </div> |
| 208 | }) | 178 | }) |
| 209 | } | 179 | } |
| @@ -280,7 +250,6 @@ async fn branches_page(cx: &Cx) -> Result<impl View> { |
| 280 | counts, | 250 | counts, |
| 281 | up_to_date, | 251 | up_to_date, |
| 282 | pr_href, | 252 | pr_href, |
| 283 | - delete_label: b::delete_aria(lang, &info.name), | | |
| 284 | name: info.name, | 253 | name: info.name, |
| 285 | }); | 254 | }); |
| 286 | } | 255 | } |
| @@ -310,24 +279,20 @@ async fn branches_page(cx: &Cx) -> Result<impl View> { |
| 310 | if is_error { | 279 | if is_error { |
| 311 | alert(message: b::t(lang, key)) | 280 | alert(message: b::t(lang, key)) |
| 312 | } else { | 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"> | 285 | + if can_write { |
| 317 | - <div class="list-bar"> | 286 | + <div class="acts"> |
| 318 | - if can_write { | 287 | + new_branch_form(lang: lang, action: action.clone(), csrf: csrf.clone(), |
| 319 | - new_branch_form(lang: lang, action: action.clone(), csrf: csrf.clone(), | 288 | + default_branch: default_branch, options: options) |
| 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 | - } | | |
| 329 | </div> | 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 | assert!(html.contains("1 ahead, 54 behind"), "{html}"); | 281 | assert!(html.contains("1 ahead, 54 behind"), "{html}"); |
| 282 | assert!(html.contains(&format!("/{OWNER}/{REPO}/compare/main...feature"))); | 282 | assert!(html.contains(&format!("/{OWNER}/{REPO}/compare/main...feature"))); |
| 283 | assert!(html.contains("tahinli")); | 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 | // Anonymous viewers get no create or delete controls. | 286 | // Anonymous viewers get no create or delete controls. |
| 286 | let (_, _, anon) = send(&fx.router, "GET", &page, None, &[]).await; | 287 | let (_, _, anon) = send(&fx.router, "GET", &page, None, &[]).await; |
| 287 | - assert!(!anon.contains("confirm-inline")); | 288 | + assert!(!anon.contains(&delete_form)); |
| 288 | assert!(!anon.contains("new-branch")); | 289 | assert!(!anon.contains("new-branch")); |
| 289 | | 290 | |
| 290 | // Create from a ref. | 291 | // Create from a ref. |
| @@ -435,12 +435,20 @@ async fn job_body( |
| 435 | ) -> Result<impl View> { | 435 | ) -> Result<impl View> { |
| 436 | Ok(view! { | 436 | Ok(view! { |
| 437 | repo_head(head: RepoHead { live: String::new(), ..head }) | 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 | <header class="ci-tl-head"> | 439 | <header class="ci-tl-head"> |
| 440 | <div class="ci-tl-headmain"> | 440 | <div class="ci-tl-headmain"> |
| 441 | <div class="ci-tl-line"> | 441 | <div class="ci-tl-line"> |
| 442 | <span class="ci-tl-no"><a href=(job.run_href.as_str())>(g::t(lang, K::RunNumber)) (job.run_number)</a></span> | 442 | <span class="ci-tl-no"><a href=(job.run_href.as_str())>(g::t(lang, K::RunNumber)) (job.run_number)</a></span> |
| 443 | <h2 class="ci-tl-title ci-job-title">(job.name.as_str())</h2> | 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 | </div> | 452 | </div> |
| 445 | <div class="ci-tl-meta"> | 453 | <div class="ci-tl-meta"> |
| 446 | <span class=(job.state_class.as_str())>(job.state.as_str())</span> | 454 | <span class=(job.state_class.as_str())>(job.state.as_str())</span> |
| @@ -455,14 +463,6 @@ async fn job_body( |
| 455 | } | 463 | } |
| 456 | </div> | 464 | </div> |
| 457 | </div> | 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 | </header> | 466 | </header> |
| 467 | <div class="ci-tl-main"> | 467 | <div class="ci-tl-main"> |
| 468 | <section class="ci-pane ci-tl-jobs"> | 468 | <section class="ci-pane ci-tl-jobs"> |
| @@ -498,13 +498,13 @@ async fn job_body( |
| 498 | <div class="ci-tl-tools"> | 498 | <div class="ci-tl-tools"> |
| 499 | <input type="search" class="ci-logsearch" data-log-q="true" placeholder=(g::t(lang, K::LogSearch)) aria-label=(g::t(lang, K::LogSearch)) autocomplete="off" spellcheck="false"> | 499 | <input type="search" class="ci-logsearch" data-log-q="true" placeholder=(g::t(lang, K::LogSearch)) aria-label=(g::t(lang, K::LogSearch)) autocomplete="off" spellcheck="false"> |
| 500 | <span class="ci-logcount" data-log-count="true" data-none=(g::t(lang, K::LogNoMatches)) aria-live="polite"></span> | 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> | 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="ci-mini" data-log-next="true" aria-label=(g::t(lang, K::LogNext)) title=(g::t(lang, K::LogNext))>"\u{2193}"</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="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> | 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="ci-mini" href=(job.log_href.as_str())>(g::t(lang, K::FullLog))</a> | 504 | + <a class="act" href=(job.log_href.as_str())>(g::t(lang, K::FullLog))</a> |
| 505 | <span class="ci-logfold" data-log-fold-box="true" hidden="hidden"> | 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> | 506 | + <button type="button" class="act" 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> | 507 | + <button type="button" class="act" data-log-fold="open">(g::t(lang, K::LogExpandAll))</button> |
| 508 | </span> | 508 | </span> |
| 509 | </div> | 509 | </div> |
| 510 | </div> | 510 | </div> |
| @@ -39,6 +39,7 @@ use crate::i18n::{ |
| 39 | self, Lang, | 39 | self, Lang, |
| 40 | releases_ci::{self as g, K}, | 40 | releases_ci::{self as g, K}, |
| 41 | }; | 41 | }; |
| | 42 | +use crate::pages::admin_runners::confirm_post; |
| 42 | use crate::pages::ci_estimate::{self, Est, Step}; | 43 | use crate::pages::ci_estimate::{self, Est, Step}; |
| 43 | use crate::pages::ci_fail::{self, FailFirst, fail_first_block}; | 44 | use crate::pages::ci_fail::{self, FailFirst, fail_first_block}; |
| 44 | use crate::pages::ci_job::{Tail, log_from, log_tail_of}; | 45 | use crate::pages::ci_job::{Tail, log_from, log_tail_of}; |
| @@ -1576,9 +1577,9 @@ async fn usernames( |
| 1576 | #[component] | 1577 | #[component] |
| 1577 | async fn action_button(action: String, csrf: String, label: &'static str) -> Result<impl View> { | 1578 | async fn action_button(action: String, csrf: String, label: &'static str) -> Result<impl View> { |
| 1578 | Ok(view! { | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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 | </form> | 1583 | </form> |
| 1583 | }) | 1584 | }) |
| 1584 | } | 1585 | } |
| @@ -2139,7 +2140,7 @@ async fn run_side(lang: Lang, list: ListView) -> Result<impl View> { |
| 2139 | next_scheduled, | 2140 | next_scheduled, |
| 2140 | } = list; | 2141 | } = list; |
| 2141 | Ok(view! { | 2142 | Ok(view! { |
| 2142 | - <section class="card ci-side"> | 2143 | + <section class="ci-side"> |
| 2143 | <div class="ci-side-head"> | 2144 | <div class="ci-side-head"> |
| 2144 | <h2 class="ci-side-title">(g::t(lang, K::Runs)) <span class="ci-count">(total)</span></h2> | 2145 | <h2 class="ci-side-title">(g::t(lang, K::Runs)) <span class="ci-count">(total)</span></h2> |
| 2145 | <div class="ci-tools"> | 2146 | <div class="ci-tools"> |
| @@ -2206,7 +2207,7 @@ async fn run_side(lang: Lang, list: ListView) -> Result<impl View> { |
| 2206 | if let Some((action, token)) = row.rerun.as_ref() { | 2207 | if let Some((action, token)) = row.rerun.as_ref() { |
| 2207 | <form method="post" action=(action.as_str()) class="ci-row-rerun-form" data-kb-rerun=""> | 2208 | <form method="post" action=(action.as_str()) class="ci-row-rerun-form" data-kb-rerun=""> |
| 2208 | <input type="hidden" name="csrf" value=(token.as_str())> | 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 | </form> | 2211 | </form> |
| 2211 | } | 2212 | } |
| 2212 | </li> | 2213 | </li> |
| @@ -2246,10 +2247,10 @@ async fn runs_body( |
| 2246 | if is_error { | 2247 | if is_error { |
| 2247 | alert(message: text) | 2248 | alert(message: text) |
| 2248 | } else { | 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 | <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true"> | 2254 | <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true"> |
| 2254 | <defs> | 2255 | <defs> |
| 2255 | <pattern id="ci-hatch" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"> | 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 | <span class="ci-chev" aria-hidden="true"></span> | 2344 | <span class="ci-chev" aria-hidden="true"></span> |
| 2344 | </a> | 2345 | </a> |
| 2345 | if let (Some(action), Some(csrf)) = (job.rerun.as_ref(), run.writer_csrf.as_ref()) { | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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 | </form> | 2350 | </form> |
| 2350 | } | 2351 | } |
| 2351 | </div> | 2352 | </div> |
| @@ -2358,7 +2359,7 @@ async fn run_timeline(lang: Lang, run: &RunDetail) -> Result<impl View> { |
| 2358 | <pre class="ci-logpre">(job.tail.as_str())</pre> | 2359 | <pre class="ci-logpre">(job.tail.as_str())</pre> |
| 2359 | <a class="ci-job-full" href=(job.href.as_str())>(g::t(lang, K::FullLog))</a> | 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 | </div> | 2363 | </div> |
| 2363 | } else if !job.preview.is_empty() { | 2364 | } else if !job.preview.is_empty() { |
| 2364 | <p class="ci-job-last" title=(job.preview.as_str())> | 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 head of a run: `Run #N` and the commit's first clause, the full message on demand, the run's |
| 2376 | -/// (the state in accent while it is live) and at most two actions at the right. `all_href` adds the All | 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 | /// runs link, which the run page needs; the list page has the runs beside it. | 2379 | /// runs link, which the run page needs; the list page has the runs beside it. |
| 2378 | #[component] | 2380 | #[component] |
| 2379 | async fn run_head(lang: Lang, run: &RunDetail, all_href: Option<String>) -> Result<impl View> { | 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 | Ok(view! { | 2383 | Ok(view! { |
| 2381 | <header class="ci-tl-head" data-run=(run.number)> | 2384 | <header class="ci-tl-head" data-run=(run.number)> |
| 2382 | <div class="ci-tl-headmain"> | 2385 | <div class="ci-tl-headmain"> |
| @@ -2387,6 +2390,24 @@ async fn run_head(lang: Lang, run: &RunDetail, all_href: Option<String>) -> Resu |
| 2387 | <summary>(crate::i18n::code::t(lang, crate::i18n::code::K::ShowFullMessage))</summary> | 2390 | <summary>(crate::i18n::code::t(lang, crate::i18n::code::K::ShowFullMessage))</summary> |
| 2388 | <p class="small">(run.title.as_str())</p> | 2391 | <p class="small">(run.title.as_str())</p> |
| 2389 | </details> | 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 | </div> | 2411 | </div> |
| 2391 | <div class="ci-tl-meta"> | 2412 | <div class="ci-tl-meta"> |
| 2392 | <span class=(run.state_class.as_str())>(run.state.as_str())</span> | 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 | <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> | 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 | </div> | 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 | </header> | 2439 | </header> |
| 2437 | }) | 2440 | }) |
| 2438 | } | 2441 | } |
| @@ -2536,7 +2539,7 @@ async fn run_jobs(lang: Lang, run: &RunDetail) -> Result<impl View> { |
| 2536 | <div class="ci-tl-artline"> | 2539 | <div class="ci-tl-artline"> |
| 2537 | <h3 class="ci-tl-label">(g::t(lang, K::Artifacts))</h3> | 2540 | <h3 class="ci-tl-label">(g::t(lang, K::Artifacts))</h3> |
| 2538 | if let Some(href) = run.zip_href.as_ref() { | 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 | </div> | 2544 | </div> |
| 2542 | <ul class="ci-art-list"> | 2545 | <ul class="ci-art-list"> |
| @@ -2562,7 +2565,7 @@ async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result<impl Vie |
| 2562 | <input type="radio" name="ci-view" id="ci-view-log" class="ci-tl-radio" checked=(if timeline { None } else { Some("checked") })> | 2565 | <input type="radio" name="ci-view" id="ci-view-log" class="ci-tl-radio" checked=(if timeline { None } else { Some("checked") })> |
| 2563 | <input type="radio" name="ci-view" id="ci-view-timeline" class="ci-tl-radio" checked=(if timeline { Some("checked") } else { None })> | 2566 | <input type="radio" name="ci-view" id="ci-view-timeline" class="ci-tl-radio" checked=(if timeline { Some("checked") } else { None })> |
| 2564 | <div class="ci-logbar ci-tl-logbar"> | 2567 | <div class="ci-logbar ci-tl-logbar"> |
| 2565 | - <div class="ci-tl-tabs"> | 2568 | + <div class="tabs ci-tl-tabs"> |
| 2566 | <label for="ci-view-log" class="ci-tl-tab ci-tl-tab-log">(g::t(lang, K::Log))</label> | 2569 | <label for="ci-view-log" class="ci-tl-tab ci-tl-tab-log">(g::t(lang, K::Log))</label> |
| 2567 | <label for="ci-view-timeline" class="ci-tl-tab ci-tl-tab-timeline">(g::t(lang, K::Timeline))</label> | 2570 | <label for="ci-view-timeline" class="ci-tl-tab ci-tl-tab-timeline">(g::t(lang, K::Timeline))</label> |
| 2568 | </div> | 2571 | </div> |
| @@ -2570,19 +2573,19 @@ async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result<impl Vie |
| 2570 | <div class="ci-tl-tools"> | 2573 | <div class="ci-tl-tools"> |
| 2571 | <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"> | 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 | <span class="ci-logcount" data-log-count="true" data-none=(g::t(lang, K::LogNoMatches)) aria-live="polite"></span> | 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> | 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> |
| 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> | 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> |
| 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> | 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> |
| 2576 | - <a class="ci-mini" href=(log.href.as_str())>(g::t(lang, K::FullLog))</a> | 2579 | + <a class="act" href=(log.href.as_str())>(g::t(lang, K::FullLog))</a> |
| 2577 | if let (Some(action), Some(csrf)) = (log.rerun.as_ref(), run.writer_csrf.as_ref()) { | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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 | </form> | 2584 | </form> |
| 2582 | } | 2585 | } |
| 2583 | <span class="ci-logfold" data-log-fold-box="true" hidden="hidden"> | 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> | 2587 | + <button type="button" class="act" 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> | 2588 | + <button type="button" class="act" data-log-fold="open">(g::t(lang, K::LogExpandAll))</button> |
| 2586 | </span> | 2589 | </span> |
| 2587 | </div> | 2590 | </div> |
| 2588 | } | 2591 | } |
| @@ -2648,10 +2651,10 @@ async fn run_body( |
| 2648 | if is_error { | 2651 | if is_error { |
| 2649 | alert(message: text) | 2652 | alert(message: text) |
| 2650 | } else { | 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 | <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true"> | 2658 | <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true"> |
| 2656 | <defs> | 2659 | <defs> |
| 2657 | <pattern id="ci-hatch" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"> | 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 | Ok(view! { | 209 | Ok(view! { |
| 210 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 210 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 211 | repo_head(head: header) | 211 | repo_head(head: header) |
| 212 | - <div class="search-page fit-pane"> | 212 | + <div class="search-page"> |
| 213 | <form method="get" action=(action.as_str()) class="search-form" role="search"> | 213 | <form method="get" action=(action.as_str()) class="search-form" role="search"> |
| 214 | - <div class="search-row"> | 214 | + <div class="plain-search"> |
| 215 | <input type="search" name="q" value=(q.as_str()) placeholder=(g::t(lang, K::SearchCodePlaceholder)) aria-label=(g::t(lang, K::SearchCodePlaceholder))> | 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 | </div> | 216 | </div> |
| 218 | - <div class="search-row search-options"> | 217 | + <div class="field-pair"> |
| 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> | 218 | + <div class="field"> |
| 220 | - <label>(g::t(lang, K::PathField)) <input type="text" name="path" value=(path_value.as_str()) placeholder="src/**/*.rs"></label> | 219 | + <label for="search-ref">(g::t(lang, K::RefField))</label> |
| 221 | - <label><input type="checkbox" name="case" value="1" checked=(match_case)> (g::t(lang, K::MatchCase))</label> | 220 | + <input id="search-ref" type="text" name="ref" value=(ref_value.as_str()) placeholder=(ctx.repo.default_branch.as_str())> |
| 222 | - <label><input type="checkbox" name="regex" value="1" checked=(regex)> (g::t(lang, K::RegexOption))</label> | 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 | </div> | 237 | </div> |
| 224 | </form> | 238 | </form> |
| 225 | if empty_repo { | 239 | if empty_repo { |
| 226 | - <p class="notice">(empty_message.as_str())</p> | 240 | + <p class="state">(empty_message.as_str())</p> |
| 227 | } else if no_query { | 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 | if let Some(msg) = notice { | 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 | if !no_query && !empty_repo { | 247 | if !no_query && !empty_repo { |
| 234 | if has_results { | 248 | if has_results { |
| 235 | - <p class="muted small">(summary.as_str()) | 249 | + <p class="hint">(summary.as_str()) |
| 236 | if truncated { | 250 | if truncated { |
| 237 | (g::t(lang, K::ShowingFirst)) (shown.as_str()) (g::t(lang, K::ShowingFirstEnd)) | 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 | Ok(view! { | 258 | Ok(view! { |
| 259 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 259 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 260 | repo_head(head: header) | 260 | repo_head(head: header) |
| 261 | - <h2 class="commit-summary-title">(heading.as_str())</h2> | 261 | + <h1 class="h1 commit-summary-title">(heading.as_str())</h1> |
| 262 | - <div class="commit-facts muted"> | 262 | + <div class="hint commit-facts"> |
| 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> | 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 | <code id="commit-oid" class="sr-only">(full_oid.as_str())</code> | 264 | <code id="commit-oid" class="sr-only">(full_oid.as_str())</code> |
| 265 | if let Some(badge) = sig { | 265 | if let Some(badge) = sig { |
| 266 | <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> | 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 | if folded { | 285 | if folded { |
| 286 | ", " | 286 | ", " |
| 287 | <details class="coauthors-more"> | 287 | <details class="coauthors-more"> |
| 288 | - <summary>(others.as_str())</summary> | 288 | + <summary class="act">(others.as_str())</summary> |
| 289 | <ul class="coauthors-list" aria-label=(coauthors_label)> | 289 | <ul class="coauthors-list" aria-label=(coauthors_label)> |
| 290 | for c in rest.iter() { | 290 | for c in rest.iter() { |
| 291 | <li> | 291 | <li> |
| @@ -319,7 +319,9 @@ async fn commit_page(cx: &Cx) -> Result<impl View> { |
| 319 | if let Some(summary) = checks { | 319 | if let Some(summary) = checks { |
| 320 | checks_summary(summary: summary, lang: StatusLang(lang)) | 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 | </div> | 325 | </div> |
| 324 | if let Some(msg) = parsed.as_ref() { | 326 | if let Some(msg) = parsed.as_ref() { |
| 325 | <ul class="commit-groups" aria-label=(changes_label)> | 327 | <ul class="commit-groups" aria-label=(changes_label)> |
| @@ -334,15 +336,17 @@ async fn commit_page(cx: &Cx) -> Result<impl View> { |
| 334 | </li> | 336 | </li> |
| 335 | } | 337 | } |
| 336 | </ul> | 338 | </ul> |
| 337 | - <details class="commit-full-message"> | 339 | + <details class="reveal commit-full-message"> |
| 338 | - <summary>(show_full)</summary> | 340 | + <summary class="act">(show_full)</summary> |
| 339 | - <pre class="code commit-message"><code>(message.as_str())</code></pre> | 341 | + <div class="opened"> |
| | 342 | + <pre class="code commit-message"><code>(message.as_str())</code></pre> |
| | 343 | + </div> |
| 340 | </details> | 344 | </details> |
| 341 | } | 345 | } |
| 342 | if parsed.is_none() && has_body { | 346 | if parsed.is_none() && has_body { |
| 343 | <pre class="code commit-message"><code>(message.as_str())</code></pre> | 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 | 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) | 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 | </div> | 351 | </div> |
| 348 | ) | 352 | ) |
| @@ -28,7 +28,7 @@ use crate::signatures::{self, SigBadge}; |
| 28 | use crate::state::AppState; | 28 | use crate::state::AppState; |
| 29 | use crate::views::commit_line::commit_line; | 29 | use crate::views::commit_line::commit_line; |
| 30 | use crate::views::commit_status::{StatusLang, StatusSummary, commit_status, status_list}; | 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 | path_param!(owner); | 33 | path_param!(owner); |
| 34 | path_param!(repo); | 34 | path_param!(repo); |
| @@ -355,81 +355,74 @@ async fn commits_page(cx: &Cx) -> Result<impl View> { |
| 355 | Ok(view! { | 355 | Ok(view! { |
| 356 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 356 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 357 | repo_head(head: header) | 357 | repo_head(head: header) |
| 358 | - <div class="commits-fit fit-pane lang-list"> | 358 | + <p class="hint">(g::t(lang, K::CommitsOn)) <code>(ref_name.as_str())</code></p> |
| 359 | - <div class="commits-head"> | 359 | + if has_filter { |
| 360 | - <span class="label">(g::t(lang, K::CommitsOn))</span> | 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 | - <span class="tag">(ref_name.as_str())</span> | 361 | + } |
| | 362 | + if empty { |
| | 363 | + <p class="state">(g::t(lang, K::NoCommits))</p> |
| 362 | if has_filter { | 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 | } else { | 367 | } else { |
| 373 | - <div class="commits-pane"> | 368 | + for group in groups.iter() { |
| 374 | - for group in groups.iter() { | 369 | + <section class="sec"> |
| 375 | - <div class="commits-g"><span class="label">(group.label.as_str())</span></div> | 370 | + <h2>(group.label.as_str())</h2> |
| 376 | - <ul class="commits-list"> | 371 | + <div class="commits-list"> |
| 377 | for row in group.rows.iter() { | 372 | for row in group.rows.iter() { |
| 378 | - <li class="commits-item" data-kb-row="" data-arrive=(row.oid.as_str())> | 373 | + if let Some(body) = row.body.clone() { |
| 379 | - if let Some(body) = row.body.clone() { | 374 | + <details class="row-open commits-d" data-kb-row="" data-arrive=(row.oid.as_str())> |
| 380 | - <details class="commits-d"> | 375 | + <summary class="line commits-r"> |
| 381 | - <summary class="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> |
| 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> | | |
| 403 | <span class=(row.dot())></span> | 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> | 378 | + <a class="name 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> | 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 | if let Some(badge) = row.sig.clone() { | 380 | if let Some(badge) = row.sig.clone() { |
| 407 | <span class=(badge.class) title=(badge.title.as_str())>(badge.label)</span> | 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 | <a class="sha commits-sha" href=(row.commit_href.as_str())>(row.short.as_str())</a> | 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)) | 384 | + </summary> |
| 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> | 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 | </div> | 395 | </div> |
| 414 | - } | 396 | + </details> |
| 415 | - </li> | 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> | 411 | + </div> |
| 418 | - } | 412 | + </section> |
| 419 | - </div> | 413 | + } |
| 420 | } | 414 | } |
| 421 | if has_newer || has_older { | 415 | if has_newer || has_older { |
| 422 | - <nav class="pager"> | 416 | + <nav class="sub"> |
| 423 | if has_newer { | 417 | if has_newer { |
| 424 | <a href=(newer_href.as_str())>(g::t(lang, K::NewerLink))</a> | 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 | if has_older { | 421 | if has_older { |
| 428 | <a href=(older_href.as_str())>(g::t(lang, K::OlderLink))</a> | 422 | <a href=(older_href.as_str())>(g::t(lang, K::OlderLink))</a> |
| 429 | } | 423 | } |
| 430 | </nav> | 424 | </nav> |
| 431 | } | 425 | } |
| 432 | - </div> | | |
| 433 | ) | 426 | ) |
| 434 | }) | 427 | }) |
| 435 | } | 428 | } |
| @@ -639,7 +632,7 @@ mod tests { |
| 639 | let (status, _, body) = get(&fx.router, &base).await; | 632 | let (status, _, body) = get(&fx.router, &base).await; |
| 640 | assert_eq!(status, 200); | 633 | assert_eq!(status, 200); |
| 641 | let html = String::from_utf8(body).unwrap(); | 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 | assert!(html.contains("filler 53")); | 636 | assert!(html.contains("filler 53")); |
| 644 | assert!(!html.contains("root commit")); | 637 | assert!(!html.contains("root commit")); |
| 645 | assert!(html.contains(">Older<")); | 638 | assert!(html.contains(">Older<")); |
| @@ -652,7 +645,7 @@ mod tests { |
| 652 | let (status, _, body) = get(&fx.router, &format!("{base}?page=2")).await; | 645 | let (status, _, body) = get(&fx.router, &format!("{base}?page=2")).await; |
| 653 | assert_eq!(status, 200); | 646 | assert_eq!(status, 200); |
| 654 | let html = String::from_utf8(body).unwrap(); | 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 | assert!(html.contains("root commit")); | 649 | assert!(html.contains("root commit")); |
| 657 | assert!(html.contains(">Newer<")); | 650 | assert!(html.contains(">Newer<")); |
| 658 | assert!(!html.contains(">Older<")); | 651 | assert!(!html.contains(">Older<")); |
| @@ -671,9 +664,9 @@ mod tests { |
| 671 | get(&fx.router, &format!("/{OWNER}/{REPO}/commits/main/a.txt")).await; | 664 | get(&fx.router, &format!("/{OWNER}/{REPO}/commits/main/a.txt")).await; |
| 672 | assert_eq!(status, 200); | 665 | assert_eq!(status, 200); |
| 673 | let html = String::from_utf8(body).unwrap(); | 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 | // Only the modified commit has a body, so only its row has a disclosure. | 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 | assert!(html.contains("Body line one.")); | 670 | assert!(html.contains("Body line one.")); |
| 678 | assert!(html.contains("Modify a.txt and add new.txt")); | 671 | assert!(html.contains("Modify a.txt and add new.txt")); |
| 679 | assert!(html.contains("root commit")); | 672 | assert!(html.contains("root commit")); |
| @@ -38,7 +38,8 @@ use crate::state::AppState; |
| 38 | use crate::templates; | 38 | use crate::templates; |
| 39 | use crate::views::commit_line::commit_line; | 39 | use crate::views::commit_line::commit_line; |
| 40 | use crate::views::diff::{DiffLang, DiffOpts, LIMITS, diff_section}; | 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 | use crate::webhooks::emit::{Sender, emit_pull}; | 43 | use crate::webhooks::emit::{Sender, emit_pull}; |
| 43 | | 44 | |
| 44 | path_param!(owner); | 45 | path_param!(owner); |
| @@ -332,82 +333,77 @@ async fn compare_view( |
| 332 | Ok(view! { | 333 | Ok(view! { |
| 333 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 334 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 334 | repo_head(head: header) | 335 | repo_head(head: header) |
| 335 | - <div class="lang-split is-list"> | | |
| 336 | if has_commits { | 336 | if has_commits { |
| 337 | - <div class="lang-list fit-pane"> | 337 | + <section class="sec"> |
| 338 | - <div class="list-bar"> | 338 | + <h2>(commits_label.as_str())</h2> |
| 339 | - <h2>(commits_label.as_str())</h2> | 339 | + <div> |
| 340 | - </div> | 340 | + for row in rows.iter() { |
| 341 | - <div class="list-scroll"> | 341 | + <div class="line" data-kb-row=""> |
| 342 | - <ul class="commit-list compare-commits"> | 342 | + <a class="name commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> |
| 343 | - for row in rows.iter() { | 343 | + <span class="val"> |
| 344 | - <li class="commit-row" data-kb-row=""> | 344 | + (row.author.as_str()) |
| 345 | - <div class="commit-main"> | 345 | + if !row.email.is_empty() { |
| 346 | - <a class="commit-summary" href=(row.commit_href.as_str())>commit_line(subject: row.summary.clone())</a> | 346 | + " · " (row.email.as_str()) |
| 347 | - <div class="commit-meta muted small"> | 347 | + } |
| 348 | - <span class="commit-author">(row.author.as_str())</span> | 348 | + if lang == i18n::Lang::Tr { |
| 349 | - if !row.email.is_empty() { | 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 | - <span class="commit-email">(row.email.as_str())</span> | 350 | + } else { |
| 351 | - } | 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 | - if lang == i18n::Lang::Tr { | 352 | + } |
| 353 | - <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | 353 | + </span> |
| 354 | - <span>(g::t(lang, K::Committed))</span> | 354 | + <a class="sha commit-oid" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 355 | - } else { | 355 | + <a class="act quiet" href=(row.tree_href.as_str())>(g::t(lang, K::BrowseFiles))</a> |
| 356 | - <span>(g::t(lang, K::Committed))</span> | 356 | + </div> |
| 357 | - <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | 357 | + } |
| 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> | | |
| 368 | </div> | 358 | </div> |
| 369 | - </div> | 359 | + </section> |
| 370 | } | 360 | } |
| 371 | - <div class="lang-pane fit-pane compare-detail"> | 361 | + <section class="sec"> |
| 372 | <h2>(g::t(lang, K::ComparingPrefix)) <code>(heading_base.as_str())</code> "..." <code>(heading_head.as_str())</code></h2> | 362 | <h2>(g::t(lang, K::ComparingPrefix)) <code>(heading_base.as_str())</code> "..." <code>(heading_head.as_str())</code></h2> |
| 373 | if unrelated { | 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 | if nothing { | 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 | if show_form { | 369 | if show_form { |
| 380 | - <section class="compare-open"> | 370 | + <div class="acts"> |
| 381 | - <h2>(g::t(lang, K::OpenPullRequest))</h2> | 371 | + reveal(label: g::t(lang, K::OpenPullRequest), id: Some("open-pull"), open: has_error, |
| 382 | if has_error { | 372 | if has_error { |
| 383 | alert(message: error_text.as_str()) | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 376 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 387 | <input type="hidden" name="base" value=(base.as_str())> | 377 | <input type="hidden" name="base" value=(base.as_str())> |
| 388 | <input type="hidden" name="head" value=(head_for_form.as_str())> | 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> | 379 | + <div class="field"> |
| 390 | - <p><label>(g::t(lang, K::DescriptionLabel)) <textarea name="body" rows="8">(form_body.as_str())</textarea></label></p> | 380 | + <label for="pull-title">(g::t(lang, K::TitleLabel))</label> |
| 391 | - <p class="form-actions"> | 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 | <button type="submit" class="primary">(g::t(lang, K::CreatePullRequest))</button> | 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> | 389 | + <button type="submit" class="act" name="draft" value="1">(g::t(lang, K::CreateDraftPullRequest))</button> |
| 394 | - </p> | 390 | + </div> |
| 395 | </form> | 391 | </form> |
| 396 | - </section> | 392 | + ) |
| | 393 | + </div> |
| 397 | } | 394 | } |
| 398 | if has_existing { | 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 | if archived_note { | 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 | if show_diff { | 402 | if show_diff { |
| 405 | for d in diff.iter() { | 403 | for d in diff.iter() { |
| 406 | diff_section(diff: d, owner: owner.as_str(), repo: name.as_str(), oid: cmp.head_oid.as_str(), parent: parent.as_deref(), subject: g::t(lang, K::ThisComparison), lang: DiffLang(lang), opts: opts.clone()) | 404 | diff_section(diff: d, owner: owner.as_str(), repo: name.as_str(), oid: cmp.head_oid.as_str(), parent: parent.as_deref(), subject: g::t(lang, K::ThisComparison), lang: DiffLang(lang), opts: opts.clone()) |
| 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 | Ok(view! { | 427 | Ok(view! { |
| 432 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 428 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 433 | repo_head(head: header) | 429 | repo_head(head: header) |
| 434 | - <section class="lang-form compare-pick"> | 430 | + <section class="sec"> |
| 435 | <h2>(g::t(lang, K::CompareBranches))</h2> | 431 | <h2>(g::t(lang, K::CompareBranches))</h2> |
| 436 | - <form method="get" action=(action.as_str()) class="filter-bar"> | 432 | + <form method="get" action=(action.as_str()) class="fields"> |
| 437 | - <label>(g::t(lang, K::BasePrefix)) <input type="text" name="base" list="compare-branches" value=(base.as_str())></label> | 433 | + <div class="field"> |
| 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> | 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 | <datalist id="compare-branches"> | 441 | <datalist id="compare-branches"> |
| 440 | for name in branches.iter() { | 442 | for name in branches.iter() { |
| 441 | <option value=(name.as_str())></option> | 443 | <option value=(name.as_str())></option> |
| @@ -23,8 +23,8 @@ use crate::views::repo_href; |
| 23 | path_param!(owner); | 23 | path_param!(owner); |
| 24 | path_param!(repo); | 24 | path_param!(repo); |
| 25 | | 25 | |
| 26 | -/// The settings card: one switch row. `enabled` is the current state. The switch submits the form | 26 | +/// The Discussions topic: a hint, then one switch. `enabled` is the current state. The switch submits |
| 27 | -/// on change (`data-autosubmit`); an unchecked box sends no `enabled`, which the handler reads as off. | 27 | +/// the form on change (`data-autosubmit`); an unchecked box sends no `enabled`, which the handler reads as off. |
| 28 | #[component] | 28 | #[component] |
| 29 | pub(crate) async fn discussions_card( | 29 | pub(crate) async fn discussions_card( |
| 30 | lang: Lang, | 30 | lang: Lang, |
| @@ -32,17 +32,21 @@ pub(crate) async fn discussions_card( |
| 32 | csrf: String, | 32 | csrf: String, |
| 33 | enabled: bool, | 33 | enabled: bool, |
| 34 | ) -> Result<impl View> { | 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 | Ok(view! { | 40 | Ok(view! { |
| 36 | - <section class="card rows-pane" id="discussions"> | 41 | + <section class="sec" id="discussions"> |
| 37 | - <form method="post" action=(action.as_str()) class="row-line row-field"> | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 45 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 39 | - <span class="row-main"> | 46 | + <label class="switch"> |
| 40 | - <span class="row-title" id="discussions-switch-label">(g::t(lang, K::Discussions))</span> | 47 | + <input type="checkbox" name="enabled" value="1" checked=(enabled) data-autosubmit="true"> |
| 41 | - <span class="row-status">(g::t(lang, K::DiscussionsDescription))</span> | 48 | + <span>(switch_label)</span> |
| 42 | - </span> | 49 | + </label> |
| 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 | </form> | 50 | </form> |
| 47 | </section> | 51 | </section> |
| 48 | }) | 52 | }) |
| @@ -25,12 +25,22 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 25 | use crate::pages::tree::link_context; | 25 | use crate::pages::tree::link_context; |
| 26 | use crate::render::markdown::{LinkContext, render_markdown}; | 26 | use crate::render::markdown::{LinkContext, render_markdown}; |
| 27 | use crate::state::AppState; | 27 | use crate::state::AppState; |
| | 28 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 28 | use crate::views::{avatar_url, display_name, now_unix, shell, user_href, user_link}; | 29 | use crate::views::{avatar_url, display_name, now_unix, shell, user_href, user_link}; |
| 29 | | 30 | |
| 30 | path_param!(owner); | 31 | path_param!(owner); |
| 31 | path_param!(repo); | 32 | path_param!(repo); |
| 32 | path_param!(number); | 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 | /// One comment, with every string the template shows already built. | 44 | /// One comment, with every string the template shows already built. |
| 35 | pub(crate) struct CommentView { | 45 | pub(crate) struct CommentView { |
| 36 | lang: Lang, | 46 | lang: Lang, |
| @@ -174,64 +184,68 @@ async fn comment_article(item: CommentView) -> Result<impl View> { |
| 174 | } = item; | 184 | } = item; |
| 175 | let profile = user_href(&login); | 185 | let profile = user_href(&login); |
| 176 | let class = if accepted { | 186 | let class = if accepted { |
| 177 | - "issue-item discussion-accepted" | 187 | + "sec discussion-accepted" |
| 178 | } else { | 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 | Ok(view! { | 199 | Ok(view! { |
| 182 | <article class=(class) id=(anchor.as_str())> | 200 | <article class=(class) id=(anchor.as_str())> |
| 183 | - <header class="issue-item-head"> | 201 | + <p class="state"> |
| 184 | if deleted { | 202 | if deleted { |
| 185 | - <span class="muted">(g::t(lang, K::CommentDeleted))</span> | 203 | + (g::t(lang, K::CommentDeleted)) |
| 186 | } else { | 204 | } else { |
| 187 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> | 205 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> |
| 188 | - <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> | 206 | + " " user_link(shown: author.as_str(), login: login.as_str()) |
| 189 | - <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> | 207 | + " " <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> |
| 190 | } | 208 | } |
| 191 | if accepted { | 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 | if !deleted { | 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 | if let Some(bar) = reactions { | 215 | if let Some(bar) = reactions { |
| 198 | reaction_row(lang: lang, bar: bar) | 216 | reaction_row(lang: lang, bar: bar) |
| 199 | } | 217 | } |
| 200 | - <div class="discussion-actions"> | 218 | + <div class="acts"> |
| 201 | if let Some(action) = answer_action { | 219 | if let Some(action) = answer_action { |
| 202 | - <form method="post" action=(action.as_str())> | 220 | + post_act(label: answer_label, action: action.as_str(), csrf: csrf.as_str(), fields: answer_fields) |
| 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> | | |
| 208 | } | 221 | } |
| 209 | if let Some(action) = reply_action { | 222 | if let Some(action) = reply_action { |
| 210 | - <details class="discussion-reply"> | 223 | + reveal(label: g::t(lang, K::Reply), id: Some(reply_open.as_str()), |
| 211 | - <summary>(g::t(lang, K::Reply))</summary> | 224 | + <form method="post" action=(action.as_str()) class="fields"> |
| 212 | - <form method="post" action=(action.as_str()) class="stack"> | | |
| 213 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 225 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 214 | <input type="hidden" name="parent" value=(id.as_str())> | 226 | <input type="hidden" name="parent" value=(id.as_str())> |
| 215 | - <textarea name="body" rows="4" aria-label=(g::t(lang, K::Reply))></textarea> | 227 | + <div class="field"> |
| 216 | - <div><button type="submit">(g::t(lang, K::Reply))</button></div> | 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 | </form> | 232 | </form> |
| 218 | - </details> | 233 | + ) |
| 219 | } | 234 | } |
| 220 | if let Some(action) = edit_action { | 235 | if let Some(action) = edit_action { |
| 221 | - <details class="discussion-reply"> | 236 | + reveal(label: g::t(lang, K::Edit), id: Some(edit_open.as_str()), |
| 222 | - <summary>(g::t(lang, K::Edit))</summary> | 237 | + <form method="post" action=(action.as_str()) class="fields"> |
| 223 | - <form method="post" action=(action.as_str()) class="stack"> | | |
| 224 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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> | 239 | + <div class="field"> |
| 226 | - <div><button type="submit">(g::t(lang, K::Save))</button></div> | 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 | </form> | 244 | </form> |
| 228 | - </details> | 245 | + ) |
| 229 | } | 246 | } |
| 230 | if let Some(action) = delete_action { | 247 | if let Some(action) = delete_action { |
| 231 | - <form method="post" action=(action.as_str())> | 248 | + confirm_act(lang: lang, label: g::t(lang, K::Delete), action: action.as_str(), csrf: csrf.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> | | |
| 235 | } | 249 | } |
| 236 | </div> | 250 | </div> |
| 237 | } | 251 | } |
| @@ -403,93 +417,83 @@ async fn discussion_page( |
| 403 | Ok(view! { cx => | 417 | Ok(view! { cx => |
| 404 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 418 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 405 | repo_head(head: header) | 419 | repo_head(head: header) |
| 406 | - <section class="issue-head" data-live=(live_href.as_str()) data-live-now=""> | 420 | + <section class="sec" 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> | 421 | + <h1 class="h1">(discussion.title.as_str()) " " <span class="hint">(number_label.as_str())</span></h1> |
| 408 | - <p class="issue-byline"> | 422 | + <p class="hint"> |
| 409 | - <span class="discussion-category">(category)</span> | 423 | + (category) |
| 410 | if answered { | 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 | if locked { | 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> | 430 | + " " user_link(shown: author.as_str(), login: author_login.as_str()) |
| 417 | - (g::t(lang, K::OpenedThis)) | 431 | + " " (g::t(lang, K::OpenedThis)) " " |
| 418 | <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> | 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 | (comments_label.as_str()) | 434 | (comments_label.as_str()) |
| 421 | </p> | 435 | </p> |
| 422 | </section> | 436 | </section> |
| 423 | - <div class="issue-layout"> | 437 | + <article class="sec" id="discussion-body"> |
| 424 | - <div class="issue-column fit-pane"> | 438 | + <p class="state"> |
| 425 | - <article class="issue-item" id="discussion-body"> | 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> |
| 426 | - <header class="issue-item-head"> | 440 | + " " user_link(shown: author.as_str(), login: author_login.as_str()) |
| 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> | 441 | + </p> |
| 428 | - <strong>user_link(shown: author.as_str(), login: author_login.as_str())</strong> | 442 | + <div class="markdown-body">(Unescaped::new_unchecked(body_html))</div> |
| 429 | - </header> | 443 | + if let Some(bar) = body_bar { |
| 430 | - <div class="issue-item-body markdown-body">(Unescaped::new_unchecked(body_html))</div> | 444 | + reaction_row(lang: lang, bar: bar) |
| 431 | - if let Some(bar) = body_bar { | 445 | + } |
| 432 | - reaction_row(lang: lang, bar: bar) | 446 | + if body_mine_actions { |
| 433 | - } | 447 | + <div class="acts"> |
| 434 | - if body_mine_actions { | 448 | + reveal(label: g::t(lang, K::Edit), id: Some("edit-open"), |
| 435 | - <div class="discussion-actions"> | 449 | + <form method="post" action=(edit_action.as_str()) class="fields"> |
| 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"> | | |
| 485 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 450 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 486 | - <input type="hidden" name="locked" value=(lock_value)> | 451 | + <div class="field"> |
| 487 | - <button type="submit">(lock_label)</button> | 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 | </form> | 460 | </form> |
| 489 | - </section> | 461 | + ) |
| 490 | - } | 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())) |
| 491 | - </aside> | 463 | + </div> |
| 492 | - </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 | use crate::pages::discussion_live::list_live_url; | 22 | use crate::pages::discussion_live::list_live_url; |
| 23 | use crate::pages::issue_meta::{can_triage, form_field, form_pairs, refusal_message}; | 23 | use crate::pages::issue_meta::{can_triage, form_field, form_pairs, refusal_message}; |
| 24 | use crate::pages::issue_parts::When; | 24 | use crate::pages::issue_parts::When; |
| 25 | -use crate::pages::issues_list::{list_href, state_tab_class}; | 25 | +use crate::pages::issues_list::{list_href, state_tab}; |
| 26 | use crate::pages::repo::repo_head; | 26 | use crate::pages::repo::repo_head; |
| 27 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | 27 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 28 | use crate::render::markdown::mentioned_usernames; | 28 | use crate::render::markdown::mentioned_usernames; |
| 29 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| 30 | -use crate::views::{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 | path_param!(owner); | 32 | path_param!(owner); |
| 33 | path_param!(repo); | 33 | path_param!(repo); |
| @@ -260,17 +260,17 @@ async fn discussions_list_page(cx: &Cx) -> Result<impl View> { |
| 260 | | 260 | |
| 261 | let base = discussions_href(&owner_name, &repo_name, ""); | 261 | let base = discussions_href(&owner_name, &repo_name, ""); |
| 262 | let selected = category.map_or("", |c| c.as_str()); | 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 | let all_href = list_href(&base, &[]); | 264 | let all_href = list_href(&base, &[]); |
| 265 | let all_label = g::t(lang, K::AllCategories); | 265 | let all_label = g::t(lang, K::AllCategories); |
| 266 | let nav_label = g::t(lang, K::CategoriesNav); | 266 | let nav_label = g::t(lang, K::CategoriesNav); |
| 267 | - let tabs: Vec<(&'static str, String, &'static str)> = DISCUSSION_CATEGORIES | 267 | + let tabs: Vec<(&'static str, String, bool)> = DISCUSSION_CATEGORIES |
| 268 | .iter() | 268 | .iter() |
| 269 | .map(|c| { | 269 | .map(|c| { |
| 270 | ( | 270 | ( |
| 271 | g::category_label(lang, *c), | 271 | g::category_label(lang, *c), |
| 272 | list_href(&base, &[("category", c.as_str())]), | 272 | list_href(&base, &[("category", c.as_str())]), |
| 273 | - state_tab_class(category == Some(*c)), | 273 | + category == Some(*c), |
| 274 | ) | 274 | ) |
| 275 | }) | 275 | }) |
| 276 | .collect(); | 276 | .collect(); |
| @@ -303,30 +303,30 @@ async fn discussions_list_page(cx: &Cx) -> Result<impl View> { |
| 303 | Ok(view! { | 303 | Ok(view! { |
| 304 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 304 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 305 | repo_head(head: header) | 305 | repo_head(head: header) |
| 306 | - <section class="issue-pane fit-pane"> | 306 | + <div data-live=(live_href.as_str()) data-live-now=""> |
| 307 | - <div class="issue-toolbar" data-live=(live_href.as_str()) data-live-now=""> | 307 | + <h1 class="sr-only">(title.as_str())</h1> |
| 308 | - <nav class="issue-tabs" aria-label=(nav_label)> | 308 | + <nav class="tabs" aria-label=(nav_label)> |
| 309 | - <a class=(all_class) href=(all_href.as_str())>(all_label)</a> | 309 | + state_tab(href: all_href.as_str(), text: all_label, current: all_on) |
| 310 | - for tab in tabs.iter() { | 310 | + for tab in tabs.iter() { |
| 311 | - <a class=(tab.2) href=(tab.1.as_str())>(tab.0)</a> | 311 | + state_tab(href: tab.1.as_str(), text: tab.0, current: tab.2) |
| 312 | - } | 312 | + } |
| 313 | - </nav> | 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 | if can_start { | 321 | if can_start { |
| 315 | - <div class="issue-tools"> | 322 | + <div class="acts"> |
| 316 | - <a class="button" href=(new_href.as_str())>(new_label)</a> | 323 | + <a class="act" href=(new_href.as_str())>(new_label)</a> |
| 317 | </div> | 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 | } else { | 326 | } else { |
| 327 | - <ul class="issue-list"> | 327 | + <div> |
| 328 | for row in rows.iter() { | 328 | for row in rows.iter() { |
| 329 | - <li class="issue-row"> | 329 | + <div class="line issue-row" data-kb-row=""> |
| 330 | <div class="issue-main"> | 330 | <div class="issue-main"> |
| 331 | <div class="issue-title-line"> | 331 | <div class="issue-title-line"> |
| 332 | <a class="issue-title" href=(row.href.as_str())>(row.title.as_str())</a> | 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 | if !by_after.is_empty() { | 340 | if !by_after.is_empty() { |
| 341 | <span>(by_after)</span> | 341 | <span>(by_after)</span> |
| 342 | } | 342 | } |
| | 343 | + <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> |
| 343 | </div> | 344 | </div> |
| 344 | </div> | 345 | </div> |
| 345 | - <div class="issue-aside"> | 346 | + </div> |
| 346 | - <a class="small muted" href=(row.href.as_str())>(row.comments_text.as_str())</a> | | |
| 347 | - </div> | | |
| 348 | - </li> | | |
| 349 | } | 347 | } |
| 350 | - </ul> | 348 | + </div> |
| 351 | } | 349 | } |
| 352 | if has_newer || has_older { | 350 | if has_newer || has_older { |
| 353 | - <nav class="pager"> | 351 | + <nav class="sub"> |
| 354 | if has_newer { | 352 | if has_newer { |
| 355 | <a href=(newer_href.as_str())>(newer_label)</a> | 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 | if has_older { | 356 | if has_older { |
| 359 | <a href=(older_href.as_str())>(older_label)</a> | 357 | <a href=(older_href.as_str())>(older_label)</a> |
| 360 | } | 358 | } |
| 361 | </nav> | 359 | </nav> |
| 362 | } | 360 | } |
| 363 | - </section> | 361 | + </div> |
| 364 | ) | 362 | ) |
| 365 | }) | 363 | }) |
| 366 | } | 364 | } |
| @@ -385,36 +383,34 @@ async fn new_discussion_body( |
| 385 | let cancel = discussions_href(&head.owner, &head.name, ""); | 383 | let cancel = discussions_href(&head.owner, &head.name, ""); |
| 386 | Ok(view! { | 384 | Ok(view! { |
| 387 | repo_head(head: head) | 385 | repo_head(head: head) |
| 388 | - <section class="card issue-new"> | 386 | + <h1 class="sr-only">(g::t(lang, K::NewDiscussion))</h1> |
| 389 | - <h2>(g::t(lang, K::NewDiscussion))</h2> | 387 | + if let Some(message) = draft.error { |
| 390 | - if let Some(message) = draft.error { | 388 | + alert(message: message.as_str()) |
| 391 | - alert(message: message.as_str()) | 389 | + } |
| 392 | - } | 390 | + <form method="post" action=(action.as_str()) class="fields"> |
| 393 | - <form method="post" action=(action.as_str()) class="stack"> | 391 | + csrf_field(token: csrf.as_str()) |
| 394 | - csrf_field(token: csrf.as_str()) | 392 | + <div class="field"> |
| 395 | - <label> | 393 | + <label for="discussion-category">(g::t(lang, K::Category))</label> |
| 396 | - <span>(g::t(lang, K::Category))</span> | 394 | + <select id="discussion-category" name="category"> |
| 397 | - <select name="category"> | 395 | + for option in options.iter() { |
| 398 | - for option in options.iter() { | 396 | + <option value=(option.value) selected=(option.selected)>(option.label)</option> |
| 399 | - <option value=(option.value) selected=(option.selected)>(option.label)</option> | 397 | + } |
| 400 | - } | 398 | + </select> |
| 401 | - </select> | 399 | + </div> |
| 402 | - </label> | 400 | + <div class="field"> |
| 403 | - <label> | 401 | + <label for="discussion-title">(g::t(lang, K::Title))</label> |
| 404 | - <span>(g::t(lang, K::Title))</span> | 402 | + <input id="discussion-title" type="text" name="title" value=(draft.title.as_str()) required=(true) autocomplete="off"> |
| 405 | - <input type="text" name="title" value=(draft.title.as_str()) required=(true) autocomplete="off"> | 403 | + </div> |
| 406 | - </label> | 404 | + <div class="field"> |
| 407 | - <label> | 405 | + <label for="discussion-body">(g::t(lang, K::Description))</label> |
| 408 | - <span>(g::t(lang, K::Description))</span> | 406 | + <textarea id="discussion-body" name="body" rows="12">(draft.body.as_str())</textarea> |
| 409 | - <textarea name="body" rows="12">(draft.body.as_str())</textarea> | 407 | + <p class="hint">(g::t(lang, K::MarkdownSupported))</p> |
| 410 | - <span class="muted small">(g::t(lang, K::MarkdownSupported))</span> | 408 | + </div> |
| 411 | - </label> | 409 | + <div class="acts"> |
| 412 | - <div class="issue-actions"> | 410 | + <button type="submit" class="primary">(g::t(lang, K::StartDiscussion))</button> |
| 413 | - <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> |
| 414 | - <a href=(cancel.as_str())>(g::t(lang, K::Cancel))</a> | 412 | + </div> |
| 415 | - </div> | 413 | + </form> |
| 416 | - </form> | | |
| 417 | - </section> | | |
| 418 | }) | 414 | }) |
| 419 | } | 415 | } |
| 420 | | 416 | |
| @@ -237,17 +237,17 @@ async fn history_page( |
| 237 | Ok(view! { cx => | 237 | Ok(view! { cx => |
| 238 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 238 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 239 | repo_head(head: header) | 239 | repo_head(head: header) |
| 240 | - <section class="issue-head" data-live=(live.as_str()) data-live-now=""> | 240 | + <section class="sec" data-live=(live.as_str()) data-live-now=""> |
| 241 | - <h1 class="issue-heading">(heading.as_str())</h1> | 241 | + <h1 class="h1">(heading.as_str())</h1> |
| 242 | - <p class="issue-byline"> | 242 | + <p class="hint"> |
| 243 | <a href=(back.as_str())>(back_label.as_str())</a> | 243 | <a href=(back.as_str())>(back_label.as_str())</a> |
| 244 | " · " | 244 | " · " |
| 245 | (count_label.as_str()) | 245 | (count_label.as_str()) |
| 246 | </p> | 246 | </p> |
| 247 | </section> | 247 | </section> |
| 248 | - <div class="issue-timeline fit-pane"> | 248 | + <div class="issue-timeline"> |
| 249 | if entries.is_empty() { | 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 | for entry in entries.into_iter() { | 252 | for entry in entries.into_iter() { |
| 253 | history_entry(lang: lang, entry: entry) | 253 | history_entry(lang: lang, entry: entry) |
| @@ -270,8 +270,8 @@ async fn history_entry(lang: Lang, entry: HistoryEntry) -> Result<impl View> { |
| 270 | } = entry; | 270 | } = entry; |
| 271 | let title_text = title_change.map(|(from, to)| g::title_change(lang, &from, &to)); | 271 | let title_text = title_change.map(|(from, to)| g::title_change(lang, &from, &to)); |
| 272 | Ok(view! { | 272 | Ok(view! { |
| 273 | - <article class="issue-item"> | 273 | + <article class="thread-entry"> |
| 274 | - <header class="issue-item-head"> | 274 | + <header class="thread-head"> |
| 275 | <strong>(editor.as_str())</strong> | 275 | <strong>(editor.as_str())</strong> |
| 276 | (g::t(lang, K::EditedBy)) | 276 | (g::t(lang, K::EditedBy)) |
| 277 | <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> | 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 | <p class="mono">(text.as_str())</p> | 281 | <p class="mono">(text.as_str())</p> |
| 282 | } | 282 | } |
| 283 | if body_unchanged { | 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 | } else { | 285 | } else { |
| 286 | <div class="diff-file"> | 286 | <div class="diff-file"> |
| 287 | <div class="diff-file-body"> | 287 | <div class="diff-file-body"> |
| @@ -297,9 +297,11 @@ async fn history_entry(lang: Lang, entry: HistoryEntry) -> Result<impl View> { |
| 297 | </div> | 297 | </div> |
| 298 | </div> | 298 | </div> |
| 299 | } | 299 | } |
| 300 | - <details> | 300 | + <details class="reveal"> |
| 301 | - <summary>(g::t(lang, K::Raw))</summary> | 301 | + <summary class="act">(g::t(lang, K::Raw))</summary> |
| 302 | - <pre class="review-hunk"><code>(raw.as_str())</code></pre> | 302 | + <div class="opened"> |
| | 303 | + <pre class="review-hunk"><code>(raw.as_str())</code></pre> |
| | 304 | + </div> |
| 303 | </details> | 305 | </details> |
| 304 | </article> | 306 | </article> |
| 305 | }) | 307 | }) |
| @@ -18,7 +18,7 @@ use crate::state::AppState; |
| 18 | use crate::views::repo_list::{ | 18 | use crate::views::repo_list::{ |
| 19 | PageLink, RepoRow, SortLink, pager, pager_links, repo_rows, sort_chips, | 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 | const PER_PAGE: u64 = 30; | 23 | const PER_PAGE: u64 = 30; |
| 24 | /// Longest search text kept, in characters. | 24 | /// Longest search text kept, in characters. |
| @@ -199,42 +199,40 @@ async fn explore_body( |
| 199 | let (links, prev, next) = nav; | 199 | let (links, prev, next) = nav; |
| 200 | let clear_href = explore_href("", sort, 1); | 200 | let clear_href = explore_href("", sort, 1); |
| 201 | Ok(view! { | 201 | Ok(view! { |
| 202 | - <section class="page-head"> | 202 | + <h1 class="sr-only">(g::t(lang, K::Explore))</h1> |
| 203 | - <h1>(g::t(lang, K::Explore))</h1> | 203 | + <section class="explore" data-live=(live.as_str())> |
| 204 | - <p class="muted small page-note">(g::t(lang, K::PublicReposIntro))</p> | 204 | + <p class="hint">(g::t(lang, K::PublicReposIntro))</p> |
| 205 | - </section> | 205 | + <form method="get" action="/explore" class="plain-search" role="search"> |
| 206 | - <section class="explore list-pane fit-pane" data-live=(live.as_str())> | 206 | + <input type="search" name="q" value=(q.as_str()) data-live-search="" |
| 207 | - if has_orgs { | 207 | + placeholder=(g::t(lang, K::SearchPublicRepos)) aria-label=(g::t(lang, K::SearchPublicRepos))> |
| 208 | - <section class="explore-orgs"> | 208 | + <input type="hidden" name="sort" value=(sort)> |
| 209 | - <h2>(g::t(lang, K::Organizations))</h2> | 209 | + <button type="submit" class="act">(g::t(lang, K::Search))</button> |
| 210 | - <ul class="item-list"> | 210 | + </form> |
| 211 | - for org in orgs.iter() { | 211 | + <div class="sub"> |
| 212 | - <li><a href=(format!("/{}", org.as_str()))>(org.as_str())</a></li> | 212 | + sort_chips(links: sort_links, lang: lang) |
| 213 | - } | 213 | + <span>(g::repo_count(lang, total))</span> |
| 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> | | |
| 228 | </div> | 214 | </div> |
| 229 | if empty { | 215 | if empty { |
| 230 | - empty_state(title: g::t(lang, K::NoPublicReposMatch), | 216 | + <p class="state">(g::t(lang, K::NoPublicReposMatch))</p> |
| 231 | - if has_search { | 217 | + if has_search { |
| 232 | - <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearSearch))</a> | 218 | + <div class="acts"> |
| 233 | - }) | 219 | + <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearSearch))</a> |
| | 220 | + </div> |
| | 221 | + } |
| 234 | } else { | 222 | } else { |
| 235 | repo_rows(rows: rows, lang: lang) | 223 | repo_rows(rows: rows, lang: lang) |
| 236 | } | 224 | } |
| 237 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | 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 | </section> | 236 | </section> |
| 239 | }) | 237 | }) |
| 240 | } | 238 | } |
| @@ -36,7 +36,7 @@ pub async fn file_finder( |
| 36 | let src = repo_href(&owner, &repo, "paths", &ref_name); | 36 | let src = repo_href(&owner, &repo, "paths", &ref_name); |
| 37 | let base = format!("{}/", repo_href(&owner, &repo, "blob", &ref_name)); | 37 | let base = format!("{}/", repo_href(&owner, &repo, "blob", &ref_name)); |
| 38 | Ok(view! { | 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 | <span class="finder-label">(b::t(lang, b::K::GoToFile))</span> | 40 | <span class="finder-label">(b::t(lang, b::K::GoToFile))</span> |
| 41 | <kbd>"t"</kbd> | 41 | <kbd>"t"</kbd> |
| 42 | </button> | 42 | </button> |
| @@ -49,7 +49,7 @@ pub async fn file_finder( |
| 49 | placeholder=(b::t(lang, b::K::FinderPlaceholder)) aria-label=(b::t(lang, b::K::FinderPlaceholder)) | 49 | placeholder=(b::t(lang, b::K::FinderPlaceholder)) aria-label=(b::t(lang, b::K::FinderPlaceholder)) |
| 50 | role="combobox" aria-expanded="true" aria-controls="finder-list" aria-autocomplete="list"> | 50 | role="combobox" aria-expanded="true" aria-controls="finder-list" aria-autocomplete="list"> |
| 51 | <ul id="finder-list" class="finder-list" role="listbox" data-finder-list=""></ul> | 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 | </div> | 53 | </div> |
| 54 | </dialog> | 54 | </dialog> |
| 55 | }) | 55 | }) |
| @@ -58,15 +58,15 @@ enum ResetMode { |
| 58 | #[component] | 58 | #[component] |
| 59 | async fn forgot_form(lang: Lang, precsrf: &str) -> Result<impl View> { | 59 | async fn forgot_form(lang: Lang, precsrf: &str) -> Result<impl View> { |
| 60 | Ok(view! { | 60 | Ok(view! { |
| 61 | - <section class="card narrow"> | 61 | + <section> |
| 62 | <h1>(t(lang, Key::ForgotTitle))</h1> | 62 | <h1>(t(lang, Key::ForgotTitle))</h1> |
| 63 | - <p class="muted">(t(lang, Key::ForgotSub))</p> | 63 | + <p class="hint">(t(lang, Key::ForgotSub))</p> |
| 64 | - <form data-hard="true" method="post" action="/forgot" class="stack"> | 64 | + <form data-hard="true" method="post" action="/forgot" class="fields"> |
| 65 | <input type="hidden" name="precsrf" value=(precsrf)> | 65 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 66 | - <label> | 66 | + <div class="field"> |
| 67 | - <span>(t(lang, Key::Email))</span> | 67 | + <label for="forgot-email">(t(lang, Key::Email))</label> |
| 68 | - <input type="email" name="email" autocomplete="email" maxlength="254" required=(true)> | 68 | + <input id="forgot-email" type="email" name="email" autocomplete="email" maxlength="254" required=(true)> |
| 69 | - </label> | 69 | + </div> |
| 70 | <button type="submit" class="primary">(t(lang, Key::ForgotSubmit))</button> | 70 | <button type="submit" class="primary">(t(lang, Key::ForgotSubmit))</button> |
| 71 | </form> | 71 | </form> |
| 72 | </section> | 72 | </section> |
| @@ -76,11 +76,9 @@ async fn forgot_form(lang: Lang, precsrf: &str) -> Result<impl View> { |
| 76 | #[component] | 76 | #[component] |
| 77 | async fn forgot_sent(lang: Lang) -> Result<impl View> { | 77 | async fn forgot_sent(lang: Lang) -> Result<impl View> { |
| 78 | Ok(view! { | 78 | Ok(view! { |
| 79 | - <section class="card narrow"> | 79 | + <section> |
| 80 | <h1>(t(lang, Key::ForgotTitle))</h1> | 80 | <h1>(t(lang, Key::ForgotTitle))</h1> |
| 81 | - <section class="card notice" role="status"> | 81 | + <p class="state" role="status">(t(lang, Key::ForgotSent))</p> |
| 82 | - <p>(t(lang, Key::ForgotSent))</p> | | |
| 83 | - </section> | | |
| 84 | </section> | 82 | </section> |
| 85 | }) | 83 | }) |
| 86 | } | 84 | } |
| @@ -152,34 +150,38 @@ async fn reset_body( |
| 152 | error: Option<String>, | 150 | error: Option<String>, |
| 153 | ) -> Result<impl View> { | 151 | ) -> Result<impl View> { |
| 154 | Ok(view! { | 152 | Ok(view! { |
| 155 | - <section class="card narrow"> | 153 | + <section> |
| 156 | <h1>(t(lang, Key::ResetTitle))</h1> | 154 | <h1>(t(lang, Key::ResetTitle))</h1> |
| 157 | if mode == ResetMode::Form { | 155 | if mode == ResetMode::Form { |
| 158 | - <p class="muted">(t(lang, Key::ResetSub))</p> | 156 | + <p class="hint">(t(lang, Key::ResetSub))</p> |
| 159 | - if let Some(message) = error { | 157 | + <form data-hard="true" method="post" action=(format!("/reset/{token}")) class="fields"> |
| 160 | - alert(message: message.as_str()) | 158 | + if let Some(message) = error { |
| 161 | - } | 159 | + alert(message: message.as_str()) |
| 162 | - <form data-hard="true" method="post" action=(format!("/reset/{token}")) class="stack"> | 160 | + } |
| 163 | <input type="hidden" name="precsrf" value=(precsrf)> | 161 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 164 | - <label> | 162 | + <div class="field"> |
| 165 | - <span>(t(lang, Key::NewPassword))</span> | 163 | + <label for="reset-password">(t(lang, Key::NewPassword))</label> |
| 166 | - <input type="password" name="password" autocomplete="new-password" required=(true)> | 164 | + <input id="reset-password" type="password" name="password" autocomplete="new-password" required=(true)> |
| 167 | - <small class="muted">(t(lang, Key::AtLeast12Chars))</small> | 165 | + <p class="hint">(t(lang, Key::AtLeast12Chars))</p> |
| 168 | - </label> | 166 | + </div> |
| 169 | - <label> | 167 | + <div class="field"> |
| 170 | - <span>(t(lang, Key::ConfirmNewPassword))</span> | 168 | + <label for="reset-confirm">(t(lang, Key::ConfirmNewPassword))</label> |
| 171 | - <input type="password" name="confirm" autocomplete="new-password" required=(true)> | 169 | + <input id="reset-confirm" type="password" name="confirm" autocomplete="new-password" required=(true)> |
| 172 | - </label> | 170 | + </div> |
| 173 | <button type="submit" class="primary">(t(lang, Key::ResetSubmit))</button> | 171 | <button type="submit" class="primary">(t(lang, Key::ResetSubmit))</button> |
| 174 | </form> | 172 | </form> |
| 175 | } | 173 | } |
| 176 | if mode == ResetMode::Invalid { | 174 | if mode == ResetMode::Invalid { |
| 177 | - <p class="muted">(t(lang, Key::ResetInvalid))</p> | 175 | + <p class="state">(t(lang, Key::ResetInvalid))</p> |
| 178 | - <p><a href="/forgot">(t(lang, Key::ForgotTitle))</a></p> | 176 | + <div class="acts"> |
| | 177 | + <a class="act" href="/forgot">(t(lang, Key::ForgotTitle))</a> |
| | 178 | + </div> |
| 179 | } | 179 | } |
| 180 | if mode == ResetMode::Done { | 180 | if mode == ResetMode::Done { |
| 181 | - <p>(t(lang, Key::ResetDone))</p> | 181 | + <p class="state">(t(lang, Key::ResetDone))</p> |
| 182 | - <p><a href="/login">(t(lang, Key::LogIn))</a></p> | 182 | + <div class="acts"> |
| | 183 | + <a class="act" href="/login">(t(lang, Key::LogIn))</a> |
| | 184 | + </div> |
| 183 | } | 185 | } |
| 184 | </section> | 186 | </section> |
| 185 | }) | 187 | }) |
| @@ -33,13 +33,13 @@ async fn home(cx: &Cx) -> Result<impl View> { |
| 33 | #[component] | 33 | #[component] |
| 34 | async fn landing(has_users: bool, lang: Lang) -> Result<impl View> { | 34 | async fn landing(has_users: bool, lang: Lang) -> Result<impl View> { |
| 35 | Ok(view! { | 35 | Ok(view! { |
| 36 | - <section class="page-head home-head"> | 36 | + <section class="sec"> |
| 37 | - <h1>"forge"</h1> | 37 | + <h1 class="sr-only">"forge"</h1> |
| 38 | - <p class="muted small page-note">(g::t(lang, K::LandingTagline))</p> | 38 | + <p class="state">(g::t(lang, K::LandingTagline))</p> |
| 39 | - <div class="actions"> | 39 | + <div class="acts"> |
| 40 | - <a class="button primary" href="/login">(g::t(lang, K::LogIn))</a> | 40 | + <a class="act" href="/login">(g::t(lang, K::LogIn))</a> |
| 41 | if !has_users { | 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 | </div> | 44 | </div> |
| 45 | </section> | 45 | </section> |
| @@ -20,7 +20,7 @@ use topcoat::view::{View, component, view}; |
| 20 | use crate::audit::{self, Actor, Target}; | 20 | use crate::audit::{self, Actor, Target}; |
| 21 | use crate::auth::{require_csrf, require_user}; | 21 | use crate::auth::{require_csrf, require_user}; |
| 22 | use crate::i18n::migrate::{self as g, K}; | 22 | use crate::i18n::migrate::{self as g, K}; |
| 23 | -use crate::i18n::{self, Key, Lang}; | 23 | +use crate::i18n::{self, Lang}; |
| 24 | use crate::importer::api::{ApiError, RemoteApi}; | 24 | use crate::importer::api::{ApiError, RemoteApi}; |
| 25 | use crate::importer::{ | 25 | use crate::importer::{ |
| 26 | self, ImportOptions, JobSpec, Source, default_name, make_forgejo, make_github, make_gitlab, | 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 | use crate::pages::new_repo::{owner_choices, repo_owner}; | 31 | use crate::pages::new_repo::{owner_choices, repo_owner}; |
| 32 | use crate::pages::repo_ctx::still_readable; | 32 | use crate::pages::repo_ctx::still_readable; |
| 33 | use crate::state::AppState; | 33 | use crate::state::AppState; |
| 34 | -use crate::views::{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 | path_param!(job_id); | 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 | let create = active == "create"; | 165 | let create = active == "create"; |
| 166 | let import = active == "import"; | 166 | let import = active == "import"; |
| 167 | Ok(view! { | 167 | Ok(view! { |
| 168 | - <nav class="import-tabs" aria-label=(g::t(lang, K::ImportTitle))> | 168 | + <nav class="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> | 169 | + <a href="/new" 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> | 170 | + <a href="/new/import" aria-current=(import.then_some("page"))>(g::t(lang, K::TabImport))</a> |
| 171 | </nav> | 171 | </nav> |
| 172 | }) | 172 | }) |
| 173 | } | 173 | } |
| @@ -179,32 +179,31 @@ async fn source_tabs(lang: Lang, base: &str, active: Source) -> Result<impl View |
| 179 | let gitlab = format!("{base}?source=gitlab"); | 179 | let gitlab = format!("{base}?source=gitlab"); |
| 180 | let forgejo = format!("{base}?source=forgejo"); | 180 | let forgejo = format!("{base}?source=forgejo"); |
| 181 | Ok(view! { | 181 | Ok(view! { |
| 182 | - <nav class="import-sources" aria-label=(g::t(lang, K::TabImport))> | 182 | + <nav class="sub" 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> | 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()) class="import-source" aria-current=((active == Source::GitHub).then_some("page"))>(g::t(lang, K::SrcGitHub))</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()) class="import-source" aria-current=((active == Source::GitLab).then_some("page"))>(g::t(lang, K::SrcGitLab))</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()) class="import-source" aria-current=((active == Source::Forgejo).then_some("page"))>(g::t(lang, K::SrcForgejo))</a> | 186 | + <a href=(forgejo.as_str()) aria-current=((active == Source::Forgejo).then_some("page"))>(g::t(lang, K::SrcForgejo))</a> |
| 187 | </nav> | 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 | #[component] | 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 | Ok(view! { | 194 | Ok(view! { |
| 194 | - <fieldset class="newrepo-visibility"> | 195 | + <fieldset class="rule-group"> |
| 195 | - <legend class="sr-only">(i18n::t(lang, Key::NewRepository))</legend> | 196 | + <legend>(crate::i18n::misc::t(lang, crate::i18n::misc::K::VisibilityLegend))</legend> |
| 196 | - <div class="segmented snippet-segmented"> | 197 | + <label class="switch"> |
| 197 | - <label class="segment"> | 198 | + <input type="radio" name="visibility" value="private" checked=(private)> |
| 198 | - <input type="radio" name="visibility" value="private" checked=(private)> | 199 | + <span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPrivate))</span> |
| 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 | + </label> |
| 200 | - <span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPrivate))</span> | 201 | + <p class="hint">(crate::i18n::misc::t(lang, crate::i18n::misc::K::PrivateHelp))</p> |
| 201 | - </label> | 202 | + <label class="switch"> |
| 202 | - <label class="segment"> | 203 | + <input type="radio" name="visibility" value="public" checked=(!private)> |
| 203 | - <input type="radio" name="visibility" value="public" checked=(!private)> | 204 | + <span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPublic))</span> |
| 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 | + </label> |
| 205 | - <span>(crate::i18n::community::t(lang, crate::i18n::community::K::VisibilityPublic))</span> | 206 | + <p class="hint">(crate::i18n::misc::t(lang, crate::i18n::misc::K::PublicHelp))</p> |
| 206 | - </label> | | |
| 207 | - </div> | | |
| 208 | </fieldset> | 207 | </fieldset> |
| 209 | }) | 208 | }) |
| 210 | } | 209 | } |
| @@ -212,13 +211,13 @@ async fn visibility_pick(lang: Lang, private: bool) -> Result<impl View> { |
| 212 | #[component] | 211 | #[component] |
| 213 | async fn option_boxes(lang: Lang, opts: ImportOptions) -> Result<impl View> { | 212 | async fn option_boxes(lang: Lang, opts: ImportOptions) -> Result<impl View> { |
| 214 | Ok(view! { | 213 | Ok(view! { |
| 215 | - <fieldset class="import-opts"> | 214 | + <fieldset class="rule-group"> |
| 216 | <legend>(g::t(lang, K::WhatToImport))</legend> | 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> | 216 | + <label class="switch"><input type="checkbox" name="opt_labels" value="on" checked=(opts.labels)><span>(g::t(lang, K::OptLabels))</span></label> |
| 218 | - <label class="inline"><input type="checkbox" name="opt_issues" value="on" checked=(opts.issues)><span>(g::t(lang, K::OptIssues))</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> |
| 219 | - <label class="inline"><input type="checkbox" name="opt_pulls" value="on" checked=(opts.pulls)><span>(g::t(lang, K::OptPulls))</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> |
| 220 | - <label class="inline"><input type="checkbox" name="opt_releases" value="on" checked=(opts.releases)><span>(g::t(lang, K::OptReleases))</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> |
| 221 | - <p class="muted small">(g::t(lang, K::OptionsNote))</p> | 220 | + <p class="hint">(g::t(lang, K::OptionsNote))</p> |
| 222 | </fieldset> | 221 | </fieldset> |
| 223 | }) | 222 | }) |
| 224 | } | 223 | } |
| @@ -319,81 +318,68 @@ async fn import_form( |
| 319 | let private = draft.private; | 318 | let private = draft.private; |
| 320 | let opts = draft.opts; | 319 | let opts = draft.opts; |
| 321 | Ok(view! { | 320 | Ok(view! { |
| 322 | - if let Some(message) = error { | 321 | + <h1 class="sr-only">(g::t(lang, K::ImportTitle))</h1> |
| 323 | - alert(message: message.as_str()) | 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 | csrf_field(token: csrf) | 337 | csrf_field(token: csrf) |
| 327 | <input type="hidden" name="source" value=(source_value)> | 338 | <input type="hidden" name="source" value=(source_value)> |
| 328 | - <header class="newrepo-head page-head"> | 339 | + <p class="hint">(g::t(lang, K::ImportIntro))</p> |
| 329 | - <h1>(g::t(lang, K::ImportTitle))</h1> | 340 | + if has_instance { |
| 330 | - newrepo_tabs(lang: lang, active: "import") | 341 | + <div class="field"> |
| 331 | - <div class="newrepo-head-actions"> | 342 | + <label for="import-instance">(instance_label)</label> |
| 332 | - visibility_pick(lang: lang, private: private) | 343 | + <input id="import-instance" type="url" name="instance" value=(draft.instance.as_str()) autocomplete="off" spellcheck="false" maxlength="2048"> |
| 333 | - <button type="submit" class="primary">(g::t(lang, K::StartImport))</button> | | |
| 334 | </div> | 344 | </div> |
| 335 | - </header> | 345 | + } |
| 336 | - source_tabs(lang: lang, base: "/new/import", active: source) | 346 | + <div class="field"> |
| 337 | - if !is_git { | 347 | + <label for="import-remote">(remote_label)</label> |
| 338 | - <div class="newrepo-card import-bulk"> | 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"> |
| 339 | - <div class="import-bulk-text"> | 349 | + </div> |
| 340 | - <strong>(g::t(lang, K::BulkLink))</strong> | 350 | + if is_git { |
| 341 | - <span class="muted small">(g::t(lang, K::BulkIntro))</span> | 351 | + <div class="field"> |
| 342 | - </div> | 352 | + <label for="import-git-user">(g::t(lang, K::GitUser))</label> |
| 343 | - <a class="button" href=(bulk_href.as_str())>(g::t(lang, K::BulkLinkButton))</a> | 353 | + <input id="import-git-user" type="text" name="git_user" value=(draft.git_user.as_str()) autocomplete="off" maxlength="255"> |
| 344 | </div> | 354 | </div> |
| 345 | } | 355 | } |
| 346 | - <p class="muted small">(g::t(lang, K::ImportIntro))</p> | 356 | + <div class="field"> |
| 347 | - <div class="newrepo-card"> | 357 | + <label for="import-token">(token_label)</label> |
| 348 | - if has_instance { | 358 | + <input id="import-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 349 | - <label> | 359 | + <p class="hint">(g::t(lang, K::TokenHelp))</p> |
| 350 | - <span>(instance_label)</span> | 360 | + </div> |
| 351 | - <input type="url" name="instance" value=(draft.instance.as_str()) autocomplete="off" spellcheck="false" maxlength="2048" class="newrepo-mono"> | 361 | + if !is_git { |
| 352 | - </label> | 362 | + option_boxes(lang: lang, opts: opts) |
| 353 | - } | 363 | + } |
| 354 | - <label> | 364 | + <div class="field"> |
| 355 | - <span>(remote_label)</span> | 365 | + <label for="import-owner">(g::t(lang, K::TargetOwner))</label> |
| 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"> | 366 | + <select id="import-owner" name="owner"> |
| 357 | - </label> | 367 | + for name in owners.iter() { |
| 358 | - <div class="newrepo-row"> | 368 | + <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> |
| 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> | | |
| 364 | } | 369 | } |
| 365 | - <label class="newrepo-half"> | 370 | + </select> |
| 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 | - } | | |
| 374 | </div> | 371 | </div> |
| 375 | - <div class="newrepo-card"> | 372 | + <div class="field"> |
| 376 | - <div class="newrepo-row newrepo-slug"> | 373 | + <label for="import-name">(g::t(lang, K::TargetName))</label> |
| 377 | - <label class="newrepo-owner"> | 374 | + <input id="import-name" type="text" name="name" value=(draft.name.as_str()) maxlength="64" autocomplete="off"> |
| 378 | - <span>(g::t(lang, K::TargetOwner))</span> | 375 | + <p class="hint">(g::t(lang, K::TargetNameHelp))</p> |
| 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> | | |
| 396 | </div> | 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 | </form> | 383 | </form> |
| 398 | }) | 384 | }) |
| 399 | } | 385 | } |
| @@ -401,7 +387,7 @@ async fn import_form( |
| 401 | /// How many imports the Import tab lists under the form. | 387 | /// How many imports the Import tab lists under the form. |
| 402 | const RECENT_IMPORTS: usize = 5; | 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 | #[component] | 391 | #[component] |
| 406 | async fn import_home( | 392 | async fn import_home( |
| 407 | lang: Lang, | 393 | lang: Lang, |
| @@ -412,10 +398,8 @@ async fn import_home( |
| 412 | more: bool, | 398 | more: bool, |
| 413 | ) -> Result<impl View> { | 399 | ) -> Result<impl View> { |
| 414 | Ok(view! { | 400 | Ok(view! { |
| 415 | - <div class="import-home"> | 401 | + import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners) |
| 416 | - import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners) | 402 | + recent_imports(lang: lang, jobs: jobs, more: more) |
| 417 | - recent_imports(lang: lang, jobs: jobs, more: more) | | |
| 418 | - </div> | | |
| 419 | }) | 403 | }) |
| 420 | } | 404 | } |
| 421 | | 405 | |
| @@ -429,9 +413,7 @@ async fn import_error_body( |
| 429 | owners: Vec<String>, | 413 | owners: Vec<String>, |
| 430 | ) -> Result<impl View> { | 414 | ) -> Result<impl View> { |
| 431 | Ok(view! { | 415 | Ok(view! { |
| 432 | - <div class="import-home"> | 416 | + import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(error), owners: owners) |
| 433 | - import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(error), owners: owners) | | |
| 434 | - </div> | | |
| 435 | }) | 417 | }) |
| 436 | } | 418 | } |
| 437 | | 419 | |
| @@ -629,40 +611,34 @@ async fn bulk_form( |
| 629 | // A Forgejo token can list its own repositories, so the owner may stay empty. | 611 | // A Forgejo token can list its own repositories, so the owner may stay empty. |
| 630 | let owner_required = source != Source::Forgejo; | 612 | let owner_required = source != Source::Forgejo; |
| 631 | Ok(view! { | 613 | Ok(view! { |
| 632 | - if let Some(message) = error { | 614 | + <h1 class="sr-only">(g::t(lang, K::BulkTitle))</h1> |
| 633 | - alert(message: message.as_str()) | 615 | + newrepo_tabs(lang: lang, active: "import") |
| 634 | - } | 616 | + source_tabs(lang: lang, base: "/new/import/bulk", active: source) |
| 635 | - <form method="post" action="/new/import/bulk" class="newrepo-form"> | 617 | + <form method="post" action="/new/import/bulk" class="fields"> |
| | 618 | + if let Some(message) = error { |
| | 619 | + alert(message: message.as_str()) |
| | 620 | + } |
| 636 | csrf_field(token: csrf) | 621 | csrf_field(token: csrf) |
| 637 | <input type="hidden" name="source" value=(source_value)> | 622 | <input type="hidden" name="source" value=(source_value)> |
| 638 | <input type="hidden" name="stage" value="list"> | 623 | <input type="hidden" name="stage" value="list"> |
| 639 | - <header class="newrepo-head page-head"> | 624 | + <p class="hint">(g::t(lang, K::BulkIntro))</p> |
| 640 | - <h1>(g::t(lang, K::BulkTitle))</h1> | 625 | + if has_instance { |
| 641 | - newrepo_tabs(lang: lang, active: "import") | 626 | + <div class="field"> |
| 642 | - <div class="newrepo-head-actions"> | 627 | + <label for="bulk-instance">(instance_label)</label> |
| 643 | - <button type="submit" class="primary">(g::t(lang, K::BulkListButton))</button> | 628 | + <input id="bulk-instance" type="url" name="instance" value=(instance) autocomplete="off" spellcheck="false" maxlength="2048"> |
| 644 | </div> | 629 | </div> |
| 645 | - </header> | 630 | + } |
| 646 | - source_tabs(lang: lang, base: "/new/import/bulk", active: source) | 631 | + <div class="field"> |
| 647 | - <p class="muted small">(g::t(lang, K::BulkIntro))</p> | 632 | + <label for="bulk-from">(owner_label)</label> |
| 648 | - <div class="newrepo-card"> | 633 | + <input id="bulk-from" type="text" name="from" required=(owner_required) autocomplete="off" spellcheck="false" maxlength="100"> |
| 649 | - if has_instance { | 634 | + </div> |
| 650 | - <label> | 635 | + <div class="field"> |
| 651 | - <span>(instance_label)</span> | 636 | + <label for="bulk-token">(g::t(lang, K::TokenOptional))</label> |
| 652 | - <input type="url" name="instance" value=(instance) autocomplete="off" spellcheck="false" maxlength="2048" class="newrepo-mono"> | 637 | + <input id="bulk-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 653 | - </label> | 638 | + <p class="hint">(g::t(lang, K::TokenHelp))</p> |
| 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> | | |
| 664 | </div> | 639 | </div> |
| 665 | <input type="hidden" name="owner" value=(owners.first().map(String::as_str).unwrap_or(""))> | 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 | </form> | 642 | </form> |
| 667 | }) | 643 | }) |
| 668 | } | 644 | } |
| @@ -694,81 +670,57 @@ async fn bulk_select( |
| 694 | form.owner.clone() | 670 | form.owner.clone() |
| 695 | }; | 671 | }; |
| 696 | Ok(view! { | 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 | csrf_field(token: csrf) | 676 | csrf_field(token: csrf) |
| 699 | <input type="hidden" name="stage" value="run"> | 677 | <input type="hidden" name="stage" value="run"> |
| 700 | <input type="hidden" name="source" value=(form.source.as_str())> | 678 | <input type="hidden" name="source" value=(form.source.as_str())> |
| 701 | <input type="hidden" name="instance" value=(form.instance.as_str())> | 679 | <input type="hidden" name="instance" value=(form.instance.as_str())> |
| 702 | <input type="hidden" name="token" value=(form.token.as_str())> | 680 | <input type="hidden" name="token" value=(form.token.as_str())> |
| 703 | <input type="hidden" name="from" value=(form.from.as_str())> | 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 | if empty { | 682 | if empty { |
| 715 | - empty_state(title: g::t(lang, K::BulkNone)) | 683 | + <p class="state">(g::t(lang, K::BulkNone))</p> |
| 716 | } else { | 684 | } else { |
| 717 | - <div class="newrepo-card import-into"> | 685 | + <div class="field"> |
| 718 | - <div class="action-row"> | 686 | + <label for="bulk-owner">(g::t(lang, K::TargetOwner))</label> |
| 719 | - <div class="action-text"> | 687 | + <select id="bulk-owner" name="owner"> |
| 720 | - <h3>(g::t(lang, K::TargetOwner))</h3> | 688 | + for name in owners.iter() { |
| 721 | - <p class="muted small">(g::t(lang, K::BulkOwnerHelp))</p> | 689 | + <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> |
| 722 | - </div> | 690 | + } |
| 723 | - <div class="action-control"> | 691 | + </select> |
| 724 | - <select name="owner" aria-label=(g::t(lang, K::TargetOwner))> | 692 | + <p class="hint">(g::t(lang, K::BulkOwnerHelp))</p> |
| 725 | - for name in owners.iter() { | 693 | + </div> |
| 726 | - <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> | 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> | 712 | + if repo.fork { |
| 729 | - </div> | 713 | + <span class="badge">(g::t(lang, K::BulkFork))</span> |
| 730 | - </div> | 714 | + } |
| 731 | - if form.source != "git" { | 715 | + if repo.archived { |
| 732 | - <div class="import-into-opts"> | 716 | + <span class="badge">(g::t(lang, K::BulkArchived))</span> |
| 733 | - option_boxes(lang: lang, opts: opts) | 717 | + } |
| 734 | - </div> | 718 | + (repo.description.as_str()) |
| | 719 | + </span> |
| | 720 | + </label> |
| 735 | } | 721 | } |
| 736 | </div> | 722 | </div> |
| 737 | - <div class="newrepo-card import-pick"> | 723 | + <button type="submit" class="primary">(g::t(lang, K::BulkImportSelected))</button> |
| 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> | | |
| 772 | } | 724 | } |
| 773 | </form> | 725 | </form> |
| 774 | }) | 726 | }) |
| @@ -1073,24 +1025,24 @@ async fn load_job_rows( |
| 1073 | #[component] | 1025 | #[component] |
| 1074 | async fn job_rows(lang: Lang, jobs: Vec<(ImportJob, Option<Repo>)>) -> Result<impl View> { | 1026 | async fn job_rows(lang: Lang, jobs: Vec<(ImportJob, Option<Repo>)>) -> Result<impl View> { |
| 1075 | Ok(view! { | 1027 | Ok(view! { |
| 1076 | - <ul class="item-list import-jobs"> | 1028 | + <div> |
| 1077 | for (job, repo) in jobs.iter() { | 1029 | for (job, repo) in jobs.iter() { |
| 1078 | - <li class="item import-job-row"> | 1030 | + <div class="line" data-kb-row=""> |
| 1079 | - <div class="item-main"> | 1031 | + <a class="name" href=(format!("/import/{}", job.id))>(job.source_ref.as_str())</a> |
| 1080 | - <a href=(format!("/import/{}", job.id)) class="import-job-name">(job.source_ref.as_str())</a> | 1032 | + <span class="val"> |
| 1081 | - <span class="muted small">(g::t(lang, K::JobStarted)) " " rel_time(lang: lang, stamp: job.created_at.as_str())</span> | 1033 | + <span class=(state_badge(lang, job.state).0)>(state_badge(lang, job.state).1)</span> |
| 1082 | - </div> | 1034 | + " · " (g::t(lang, K::JobStarted)) " " rel_time(lang: lang, stamp: job.created_at.as_str()) |
| 1083 | - if let Some(repo) = repo { | 1035 | + 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> | 1036 | + " · " <a class="act" href=(format!("/{}/{}", repo.owner_name, repo.name))>(format!("{}/{}", repo.owner_name, repo.name))</a> |
| 1085 | - } | 1037 | + } |
| 1086 | - <span class=(state_badge(lang, job.state).0)>(state_badge(lang, job.state).1)</span> | 1038 | + </span> |
| 1087 | - </li> | 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 | /// `more` says there are older ones, which the "View all" link opens. | 1046 | /// `more` says there are older ones, which the "View all" link opens. |
| 1095 | #[component] | 1047 | #[component] |
| 1096 | async fn recent_imports( | 1048 | async fn recent_imports( |
| @@ -1102,21 +1054,18 @@ async fn recent_imports( |
| 1102 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); | 1054 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); |
| 1103 | Ok(view! { | 1055 | Ok(view! { |
| 1104 | if !empty { | 1056 | if !empty { |
| 1105 | - <section class="card import-recent fit-pane"> | 1057 | + <section class="sec"> |
| 1106 | <h2>(g::t(lang, K::RecentImports))</h2> | 1058 | <h2>(g::t(lang, K::RecentImports))</h2> |
| 1107 | job_rows(lang: lang, jobs: jobs) | 1059 | job_rows(lang: lang, jobs: jobs) |
| 1108 | if more || retry { | 1060 | if more || retry { |
| 1109 | - <p class="small"> | 1061 | + <div class="acts"> |
| 1110 | if more { | 1062 | if more { |
| 1111 | - <a href="/import">(g::t(lang, K::ViewAll))</a> | 1063 | + <a class="act quiet" href="/import">(g::t(lang, K::ViewAll))</a> |
| 1112 | - } | | |
| 1113 | - if more && retry { | | |
| 1114 | - " · " | | |
| 1115 | } | 1064 | } |
| 1116 | if retry { | 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 | </section> | 1070 | </section> |
| 1122 | } | 1071 | } |
| @@ -1132,23 +1081,25 @@ async fn jobs_list( |
| 1132 | let empty = jobs.is_empty(); | 1081 | let empty = jobs.is_empty(); |
| 1133 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); | 1082 | let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); |
| 1134 | Ok(view! { | 1083 | Ok(view! { |
| 1135 | - <section class="page-head" data-live="/import/events"> | 1084 | + <section data-live="/import/events"> |
| 1136 | - <h1>(g::t(lang, K::JobsTitle))</h1> | 1085 | + <h1 class="sr-only">(g::t(lang, K::JobsTitle))</h1> |
| 1137 | if retry { | 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> | 1091 | + if let Some(message) = skipped { |
| 1141 | - if let Some(message) = skipped { | 1092 | + alert(message: message.as_str()) |
| 1142 | - alert(message: message.as_str()) | 1093 | + } |
| 1143 | - } | 1094 | + if empty { |
| 1144 | - if empty { | 1095 | + <p class="state">(g::t(lang, K::NoJobs))</p> |
| 1145 | - empty_state(title: g::t(lang, K::NoJobs), | 1096 | + <div class="acts"> |
| 1146 | - <a class="button" href="/new/import">(g::t(lang, K::ImportTitle))</a>) | 1097 | + <a class="act" href="/new/import">(g::t(lang, K::ImportTitle))</a> |
| 1147 | - } else { | 1098 | + </div> |
| 1148 | - <section class="card"> | 1099 | + } else { |
| 1149 | job_rows(lang: lang, jobs: jobs) | 1100 | job_rows(lang: lang, jobs: jobs) |
| 1150 | - </section> | 1101 | + } |
| 1151 | - } | 1102 | + </section> |
| 1152 | }) | 1103 | }) |
| 1153 | } | 1104 | } |
| 1154 | | 1105 | |
| @@ -1238,25 +1189,16 @@ async fn job_view( |
| 1238 | let empty_log = log.is_empty(); | 1189 | let empty_log = log.is_empty(); |
| 1239 | Ok(view! { | 1190 | Ok(view! { |
| 1240 | <section class="import-job" data-live=(live.as_deref()) data-live-state=(state_word)> | 1191 | <section class="import-job" data-live=(live.as_deref()) data-live-state=(state_word)> |
| 1241 | - <header class="newrepo-head page-head"> | 1192 | + <h1 class="h1">(job.source_ref.as_str())</h1> |
| 1242 | - <h1 class="import-job-title">(job.source_ref.as_str())</h1> | 1193 | + <p class="state"><span class=(badge_class)>(badge_text)</span></p> |
| 1243 | - <span class=(badge_class)>(badge_text)</span> | 1194 | + <section class="sec"> |
| 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"> | | |
| 1253 | if !stage.is_empty() { | 1195 | if !stage.is_empty() { |
| 1254 | - <div class="import-stage"> | 1196 | + <p class="state"> |
| 1255 | - <strong>(stage)</strong> | 1197 | + (stage) |
| 1256 | if has_progress { | 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 | if has_progress { | 1203 | if has_progress { |
| 1262 | <progress class="import-progress" value=(job.done) max=(job.total)></progress> | 1204 | <progress class="import-progress" value=(job.done) max=(job.total)></progress> |
| @@ -1266,22 +1208,31 @@ async fn job_view( |
| 1266 | if let Some(message) = error { | 1208 | if let Some(message) = error { |
| 1267 | alert(message: message.as_str()) | 1209 | alert(message: message.as_str()) |
| 1268 | } | 1210 | } |
| 1269 | - if failed { | 1211 | + if let Some(href) = repo_href.as_ref() { |
| 1270 | - <form method="post" action=(retry_action.as_str()) class="import-retry"> | 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 | csrf_field(token: csrf) | 1222 | csrf_field(token: csrf) |
| 1272 | - <label> | 1223 | + <div class="field"> |
| 1273 | - <span>(g::t(lang, K::TokenOptional))</span> | 1224 | + <label for="retry-token">(g::t(lang, K::TokenOptional))</label> |
| 1274 | - <input type="password" name="token" autocomplete="new-password" maxlength="1024"> | 1225 | + <input id="retry-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 1275 | - </label> | 1226 | + <p class="hint">(g::t(lang, K::JobRetryHelp))</p> |
| 1276 | - <p class="muted small">(g::t(lang, K::JobRetryHelp))</p> | 1227 | + </div> |
| 1277 | <button type="submit" class="primary">(g::t(lang, K::JobRetry))</button> | 1228 | <button type="submit" class="primary">(g::t(lang, K::JobRetry))</button> |
| 1278 | </form> | 1229 | </form> |
| 1279 | - } | 1230 | + </section> |
| 1280 | - </div> | 1231 | + } |
| 1281 | - <div class="newrepo-card"> | 1232 | + <section class="sec"> |
| 1282 | - <h2 class="import-log-title">(g::t(lang, K::JobProgress))</h2> | 1233 | + <h2>(g::t(lang, K::JobProgress))</h2> |
| 1283 | if empty_log { | 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 | } else { | 1236 | } else { |
| 1286 | <ol class="import-log"> | 1237 | <ol class="import-log"> |
| 1287 | for line in log.iter() { | 1238 | for line in log.iter() { |
| @@ -1289,7 +1240,7 @@ async fn job_view( |
| 1289 | } | 1240 | } |
| 1290 | </ol> | 1241 | </ol> |
| 1291 | } | 1242 | } |
| 1292 | - </div> | 1243 | + </section> |
| 1293 | </section> | 1244 | </section> |
| 1294 | }) | 1245 | }) |
| 1295 | } | 1246 | } |
| @@ -1458,54 +1409,38 @@ async fn retry_list(lang: Lang, csrf: &str, rows: Vec<(ImportJob, Repo)>) -> Res |
| 1458 | let count = rows.len(); | 1409 | let count = rows.len(); |
| 1459 | let empty = rows.is_empty(); | 1410 | let empty = rows.is_empty(); |
| 1460 | Ok(view! { | 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 | csrf_field(token: csrf) | 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 | if empty { | 1415 | if empty { |
| 1472 | - empty_state(title: g::t(lang, K::RetryNone)) | 1416 | + <p class="state">(g::t(lang, K::RetryNone))</p> |
| 1473 | } else { | 1417 | } else { |
| 1474 | - <div class="newrepo-card"> | 1418 | + <div class="field"> |
| 1475 | - <label> | 1419 | + <label for="retry-token">(g::t(lang, K::TokenOptional))</label> |
| 1476 | - <span>(g::t(lang, K::TokenOptional))</span> | 1420 | + <input id="retry-token" type="password" name="token" autocomplete="new-password" maxlength="1024"> |
| 1477 | - <input type="password" name="token" autocomplete="new-password" maxlength="1024"> | 1421 | + <p class="hint">(g::t(lang, K::RetryTokenHelp))</p> |
| 1478 | - </label> | | |
| 1479 | - <p class="muted small">(g::t(lang, K::RetryTokenHelp))</p> | | |
| 1480 | </div> | 1422 | </div> |
| 1481 | - <div class="newrepo-card import-pick"> | 1423 | + <label class="line" data-kb-row=""> |
| 1482 | - <label class="import-pick-row import-pick-all"> | 1424 | + <input type="checkbox" data-select-all=".import-pick-list"> |
| 1483 | - <input type="checkbox" data-select-all=".import-pick-list"> | 1425 | + <span class="name">(g::t(lang, K::BulkSelectAll))</span> |
| 1484 | - <span class="import-pick-main"> | 1426 | + <span class="val">(count)</span> |
| 1485 | - <span class="import-pick-title">(g::t(lang, K::BulkSelectAll))</span> | 1427 | + </label> |
| 1486 | - </span> | 1428 | + <div class="import-pick-list"> |
| 1487 | - <span class="muted small">(count)</span> | 1429 | + for (i, (job, repo)) in rows.iter().enumerate() { |
| 1488 | - </label> | 1430 | + <label class="line" data-kb-row=""> |
| 1489 | - <ul class="import-pick-list"> | 1431 | + <input type="checkbox" name=(format!("sel_{i}")) value=(job.id.as_str())> |
| 1490 | - for (i, (job, repo)) in rows.iter().enumerate() { | 1432 | + <span class="name">(format!("{}/{}", repo.owner_name, repo.name))</span> |
| 1491 | - <li> | 1433 | + <span class="val"> |
| 1492 | - <label class="import-pick-row"> | 1434 | + <span class="badge">(source_label(&job.source))</span> |
| 1493 | - <input type="checkbox" name=(format!("sel_{i}")) value=(job.id.as_str())> | 1435 | + " " (job.source_ref.as_str()) |
| 1494 | - <span class="import-pick-main"> | 1436 | + if let Some(message) = job.error.as_ref() { |
| 1495 | - <span class="import-pick-title"> | 1437 | + " · " (message.as_str()) |
| 1496 | - <span class="import-pick-name">(format!("{}/{}", repo.owner_name, repo.name))</span> | 1438 | + } |
| 1497 | - <span class="badge">(source_label(&job.source))</span> | 1439 | + </span> |
| 1498 | - </span> | 1440 | + </label> |
| 1499 | - <span class="muted small import-pick-desc">(job.source_ref.as_str())</span> | 1441 | + } |
| 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> | | |
| 1508 | </div> | 1442 | </div> |
| | 1443 | + <button type="submit" class="primary">(g::t(lang, K::RetrySelected))</button> |
| 1509 | } | 1444 | } |
| 1510 | </form> | 1445 | </form> |
| 1511 | }) | 1446 | }) |
| @@ -18,6 +18,7 @@ use crate::mail::account; |
| 18 | use crate::pages::admin_users::admin_only; | 18 | use crate::pages::admin_users::admin_only; |
| 19 | use crate::pages::passkeys::s; | 19 | use crate::pages::passkeys::s; |
| 20 | use crate::state::AppState; | 20 | use crate::state::AppState; |
| | 21 | +use crate::views::parts::reveal; |
| 21 | use crate::views::{alert, shell, user_facing_message}; | 22 | use crate::views::{alert, shell, user_facing_message}; |
| 22 | | 23 | |
| 23 | #[derive(Deserialize)] | 24 | #[derive(Deserialize)] |
| @@ -35,38 +36,29 @@ async fn invite_body( |
| 35 | notice: Option<&'static str>, | 36 | notice: Option<&'static str>, |
| 36 | error: Option<String>, | 37 | error: Option<String>, |
| 37 | ) -> Result<impl View> { | 38 | ) -> Result<impl View> { |
| | 39 | + let open = error.is_some(); |
| 38 | Ok(view! { | 40 | Ok(view! { |
| 39 | - <section class="page-head"> | 41 | + <h1 class="sr-only">(t(lang, Key::InvitesTitle))</h1> |
| 40 | - <h1>(t(lang, Key::InvitesTitle))</h1> | 42 | + <section class="sec"> |
| 41 | - </section> | 43 | + <h2>(s(lang, "Invite by email", "E-posta ile davet et"))</h2> |
| 42 | - <p class="muted page-lede">(t(lang, Key::InvitesSub))</p> | 44 | + <p class="hint">(t(lang, Key::InvitesSub))</p> |
| 43 | - if let Some(message) = notice { | 45 | + if let Some(message) = notice { |
| 44 | - <section class="card notice" role="status"> | 46 | + <p class="state" role="status">(message)</p> |
| 45 | - <p>(message)</p> | 47 | + } |
| 46 | - </section> | 48 | + <div class="acts"> |
| 47 | - } | 49 | + reveal(label: t(lang, Key::InvitesSubmit), id: Some("invite-email"), open: open, |
| 48 | - <section class="card rows-pane"> | 50 | + if let Some(message) = error { |
| 49 | - <div class="row-line"> | 51 | + alert(message: message.as_str()) |
| 50 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 52 | + } |
| 51 | - <div class="row-main"> | 53 | + <form method="post" action="/admin/invites" class="fields"> |
| 52 | - <h2 class="row-title">(s(lang, "Invite by email", "E-posta ile davet et"))</h2> | 54 | + <input type="hidden" name="csrf" value=(csrf)> |
| 53 | - </div> | 55 | + <div class="field"> |
| 54 | - <details class="row-action" open=(error.is_some())> | 56 | + <label for="invite-email">(t(lang, Key::Email))</label> |
| 55 | - <summary>(t(lang, Key::InvitesSubmit))</summary> | 57 | + <input id="invite-email" type="email" name="email" autocomplete="off" maxlength="254" required=(true)> |
| 56 | - <div class="row-panel"> | 58 | + </div> |
| 57 | - if let Some(message) = error { | 59 | + <button type="submit" class="primary">(t(lang, Key::InvitesSubmit))</button> |
| 58 | - alert(message: message.as_str()) | 60 | + </form> |
| 59 | - } | 61 | + ) |
| 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> | | |
| 70 | </div> | 62 | </div> |
| 71 | </section> | 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. | 84 | +/// Links between the issue-adjacent pages of a repo: Issues, Labels and Milestones. The one named |
| 85 | -fn subnav_class(active: &str, link: &str) -> &'static str { | 85 | +/// by `active` is the current page. |
| 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. | | |
| 94 | #[component] | 86 | #[component] |
| 95 | pub(crate) async fn issue_subnav(lang: Lang, title: String, active: String) -> Result<impl View> { | 87 | pub(crate) async fn issue_subnav(lang: Lang, title: String, active: String) -> Result<impl View> { |
| 96 | let issues = format!("/{title}/issues"); | 88 | let issues = format!("/{title}/issues"); |
| @@ -98,11 +90,26 @@ pub(crate) async fn issue_subnav(lang: Lang, title: String, active: String) -> R |
| 98 | let milestones = format!("/{title}/milestones"); | 90 | let milestones = format!("/{title}/milestones"); |
| 99 | // The repo's issue stream: the labels and milestones pages follow it (see `issues_live`). | 91 | // The repo's issue stream: the labels and milestones pages follow it (see `issues_live`). |
| 100 | let live = format!("/{title}/issues/live"); | 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 | Ok(view! { | 96 | Ok(view! { |
| 102 | - <nav class="subnav" aria-label=(g::t(lang, K::IssuePages)) data-live=(live.as_str()) data-live-now=""> | 97 | + <nav class="sub" 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> | 98 | + if on_issues { |
| 104 | - <a class=(subnav_class(&active, "labels")) href=(labels.as_str())>(g::t(lang, K::Labels))</a> | 99 | + <a href=(issues.as_str()) aria-current="page">(g::t(lang, K::Issues))</a> |
| 105 | - <a class=(subnav_class(&active, "milestones")) href=(milestones.as_str())>(g::t(lang, K::Milestones))</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 | </nav> | 113 | </nav> |
| 107 | }) | 114 | }) |
| 108 | } | 115 | } |
| @@ -194,9 +201,12 @@ pub(crate) async fn action_error_at( |
| 194 | back: String, | 201 | back: String, |
| 195 | ) -> Result<impl View> { | 202 | ) -> Result<impl View> { |
| 196 | Ok(view! { | 203 | Ok(view! { |
| 197 | - <section class="card"> | 204 | + <section class="sec"> |
| | 205 | + <h1 class="sr-only">(g::t(lang, K::CouldNotSave))</h1> |
| 198 | alert(message: message.as_str()) | 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 | </section> | 210 | </section> |
| 201 | }) | 211 | }) |
| 202 | } | 212 | } |
| @@ -31,6 +31,7 @@ use crate::views::{ |
| 31 | alert, avatar_url, display_name, iso_time, now_unix, relative_time, repo_href, short_oid, | 31 | alert, avatar_url, display_name, iso_time, now_unix, relative_time, repo_href, short_oid, |
| 32 | user_href, user_link, | 32 | user_href, user_link, |
| 33 | }; | 33 | }; |
| | 34 | +use crate::views::parts::{confirm_act, reveal}; |
| 34 | use crate::webhooks::emit::{Sender, emit_comment, emit_item_action}; | 35 | use crate::webhooks::emit::{Sender, emit_comment, emit_item_action}; |
| 35 | | 36 | |
| 36 | /// Which kind of item a page shows. It decides the URL segment of the item's own links and which | 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 | reactions, | 435 | reactions, |
| 435 | } = item; | 436 | } = item; |
| 436 | let profile = user_href(&login); | 437 | let profile = user_href(&login); |
| | 438 | + let has_acts = edit_href.is_some() || delete_href.is_some(); |
| 437 | Ok(view! { | 439 | Ok(view! { |
| 438 | - <article class="issue-item" id=(anchor.as_str())> | 440 | + <article class="thread-entry" id=(anchor.as_str())> |
| 439 | - <header class="issue-item-head"> | 441 | + <header class="thread-head"> |
| 440 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> | 442 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> |
| 441 | <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> | 443 | <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> |
| 442 | <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> | 444 | <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> |
| 443 | if let Some(href) = history_href { | 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 | </header> | 448 | </header> |
| 458 | if let Some(task) = tasks { | 449 | if let Some(task) = tasks { |
| 459 | <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> | 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 | if let Some(bar) = reactions { | 454 | if let Some(bar) = reactions { |
| 464 | reaction_row(lang: lang, bar: bar) | 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 | </article> | 467 | </article> |
| 467 | }) | 468 | }) |
| 468 | } | 469 | } |
| @@ -553,7 +554,7 @@ pub(crate) async fn event_item(line: EventLine) -> Result<impl View> { |
| 553 | after, | 554 | after, |
| 554 | } = line; | 555 | } = line; |
| 555 | Ok(view! { | 556 | Ok(view! { |
| 556 | - <div class="issue-event"> | 557 | + <div class="thread-event"> |
| 557 | <strong>(actor.as_str())</strong> | 558 | <strong>(actor.as_str())</strong> |
| 558 | " " | 559 | " " |
| 559 | (before.as_str()) | 560 | (before.as_str()) |
| @@ -608,8 +609,8 @@ pub(crate) async fn review_item(lang: Lang, review: ReviewView) -> Result<impl V |
| 608 | "review-verb" | 609 | "review-verb" |
| 609 | }; | 610 | }; |
| 610 | Ok(view! { | 611 | Ok(view! { |
| 611 | - <article class="issue-item review-item" id=(anchor.as_str())> | 612 | + <article class="thread-entry review-item" id=(anchor.as_str())> |
| 612 | - <header class="issue-item-head"> | 613 | + <header class="thread-head"> |
| 613 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> | 614 | <a href=(profile.as_str()) aria-label=(login.as_str())><img class="avatar avatar-sm" src=(avatar.as_str()) alt="" width="24" height="24"></a> |
| 614 | <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> | 615 | <strong>user_link(shown: author.as_str(), login: login.as_str())</strong> |
| 615 | <span class=(verb_class)>(verb)</span> | 616 | <span class=(verb_class)>(verb)</span> |
| @@ -878,7 +879,7 @@ pub(crate) fn reaction_bar_for( |
| 878 | .collect(); | 879 | .collect(); |
| 879 | let picker = Reaction::ALL | 880 | let picker = Reaction::ALL |
| 880 | .into_iter() | 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 | .collect(); | 883 | .collect(); |
| 883 | Some(ReactionBar { | 884 | Some(ReactionBar { |
| 884 | chips, | 885 | chips, |
| @@ -888,6 +889,21 @@ pub(crate) fn reaction_bar_for( |
| 888 | } | 889 | } |
| 889 | | 890 | |
| 890 | /// The hover text of a reaction: who made it, and how many more beyond the first names. | 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 | fn reaction_title(lang: Lang, users: &[String], count: usize) -> String { | 907 | fn reaction_title(lang: Lang, users: &[String], count: usize) -> String { |
| 892 | let names = users.join(", "); | 908 | let names = users.join(", "); |
| 893 | match count.saturating_sub(users.len()) { | 909 | match count.saturating_sub(users.len()) { |
| @@ -1067,35 +1083,36 @@ pub(crate) async fn labels_box( |
| 1067 | ) -> Result<impl View> { | 1083 | ) -> Result<impl View> { |
| 1068 | let any_attached = labels.iter().any(|row| row.attached); | 1084 | let any_attached = labels.iter().any(|row| row.attached); |
| 1069 | Ok(view! { | 1085 | Ok(view! { |
| 1070 | - <section class="issue-side-section"> | 1086 | + <div class="acts"> |
| 1071 | - <h2>(g::t(lang, K::Labels))</h2> | 1087 | + <span class="state"> |
| 1072 | - if write { | 1088 | + (g::t(lang, K::Labels)) ": " |
| 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 { | | |
| 1087 | if !any_attached { | 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"> | 1092 | + for row in labels.iter() { |
| 1091 | - for row in labels.iter() { | 1093 | + if row.attached { |
| 1092 | - if row.attached { | 1094 | + <span class=(row.chip.as_str())>(row.name.as_str())</span> |
| 1093 | - <span class=(row.chip.as_str())>(row.name.as_str())</span> | | |
| 1094 | - } | | |
| 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 | ) -> Result<impl View> { | 1127 | ) -> Result<impl View> { |
| 1111 | let text = names.join(", "); | 1128 | let text = names.join(", "); |
| 1112 | Ok(view! { | 1129 | Ok(view! { |
| 1113 | - <section class="issue-side-section"> | 1130 | + <div class="acts"> |
| 1114 | - <h2>(g::t(lang, K::Assignees))</h2> | 1131 | + <span class="state"> |
| 1115 | - if write { | 1132 | + (g::t(lang, K::Assignees)) ": " |
| 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 { | | |
| 1129 | if names.is_empty() { | 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"> | 1138 | + </span> |
| 1133 | - for name in names.iter() { | 1139 | + if write { |
| 1134 | - <li>(name.as_str())</li> | 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 | none_selected: bool, | 1171 | none_selected: bool, |
| 1151 | ) -> Result<impl View> { | 1172 | ) -> Result<impl View> { |
| 1152 | Ok(view! { | 1173 | Ok(view! { |
| 1153 | - <section class="issue-side-section"> | 1174 | + <div class="acts"> |
| 1154 | - <h2>(g::t(lang, K::MilestoneBox))</h2> | 1175 | + <span class="state"> |
| 1155 | - if write { | 1176 | + (g::t(lang, K::MilestoneBox)) ": " |
| 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 { | | |
| 1167 | if current.is_empty() { | 1177 | if current.is_empty() { |
| 1168 | - <p class="muted small">(g::t(lang, K::NoMilestone))</p> | 1178 | + (g::t(lang, K::NoMilestone)) |
| 1169 | } else { | 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 | .to_owned(); | 1219 | .to_owned(); |
| 1193 | let none = reason.is_none(); | 1220 | let none = reason.is_none(); |
| 1194 | Ok(view! { | 1221 | Ok(view! { |
| 1195 | - <section class="issue-side-section"> | 1222 | + <div class="acts"> |
| 1196 | - <h2>(g::t(lang, K::ConversationBox))</h2> | 1223 | + <span class="state"> |
| 1197 | - if write { | 1224 | + (g::t(lang, K::ConversationBox)) ": " |
| 1198 | - <form method="post" action=(action.as_str()) class="stack"> | 1225 | + if locked { |
| 1199 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 1226 | + (g::t(lang, K::LockedToCollaborators)) |
| 1200 | - if locked { | 1227 | + if !none { |
| 1201 | - <p class="muted small"> | 1228 | + " (" (reason_text.as_str()) ")" |
| 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 | } | 1229 | } |
| 1223 | - </form> | 1230 | + } else { |
| 1224 | - } else { | 1231 | + (g::t(lang, K::OpenToEveryone)) |
| 1225 | - <p class="muted small"> | 1232 | + } |
| 1226 | - if locked { | 1233 | + </span> |
| 1227 | - (g::t(lang, K::LockedToCollaborators)) | 1234 | + if write { |
| 1228 | - if !none { | 1235 | + reveal(label: g::t(lang, K::Edit), |
| 1229 | - " (" (reason_text.as_str()) ")" | 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 { | 1255 | + </form> |
| 1232 | - (g::t(lang, K::OpenToEveryone)) | 1256 | + ) |
| 1233 | - } | | |
| 1234 | - </p> | | |
| 1235 | } | 1257 | } |
| 1236 | - </section> | 1258 | + </div> |
| 1237 | }) | 1259 | }) |
| 1238 | } | 1260 | } |
| 1239 | | 1261 | |
| @@ -1299,25 +1321,28 @@ pub(crate) async fn comment_form( |
| 1299 | open: bool, | 1321 | open: bool, |
| 1300 | ) -> Result<impl View> { | 1322 | ) -> Result<impl View> { |
| 1301 | Ok(view! { | 1323 | Ok(view! { |
| 1302 | - <section class="card issue-comment"> | 1324 | + <section class="sec issue-comment"> |
| 1303 | - <h2 class="label">(g::t(lang, K::AddComment))</h2> | 1325 | + <h2>(g::t(lang, K::AddComment))</h2> |
| 1304 | if let Some(message) = error { | 1326 | if let Some(message) = error { |
| 1305 | alert(message: message.as_str()) | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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> | 1331 | + <div class="field"> |
| 1310 | - <div class="issue-actions"> | 1332 | + <label for="issue-comment-body">(g::t(lang, K::Comment))</label> |
| 1311 | - <button type="submit" class="primary" name="action" value="comment">(g::t(lang, K::Comment))</button> | 1333 | + <textarea id="issue-comment-body" name="body" rows="3">(draft.as_str())</textarea> |
| 1312 | - if can_close { | 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 | if open { | 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> | 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> |
| 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> | 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 | } else { | 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 | - } | 1344 | + </div> |
| 1320 | - </div> | 1345 | + } |
| 1321 | </form> | 1346 | </form> |
| 1322 | </section> | 1347 | </section> |
| 1323 | }) | 1348 | }) |
| @@ -20,6 +20,7 @@ use crate::pages::issue_meta::{ |
| 20 | use crate::pages::issue_parts::{ItemKind, bump_live}; | 20 | use crate::pages::issue_parts::{ItemKind, bump_live}; |
| 21 | use crate::pages::repo_ctx::load_repo; | 21 | use crate::pages::repo_ctx::load_repo; |
| 22 | use crate::state::AppState; | 22 | use crate::state::AppState; |
| | 23 | +use crate::views::parts::post_act; |
| 23 | use crate::views::shell; | 24 | use crate::views::shell; |
| 24 | | 25 | |
| 25 | path_param!(owner); | 26 | path_param!(owner); |
| @@ -91,21 +92,18 @@ pub(crate) async fn pin_box( |
| 91 | g::t(lang, K::PinIssue) | 92 | g::t(lang, K::PinIssue) |
| 92 | }; | 93 | }; |
| 93 | Ok(view! { | 94 | Ok(view! { |
| 94 | - <section class="issue-side-section"> | 95 | + <div class="acts"> |
| 95 | - <h2>(g::t(lang, K::Pinned))</h2> | 96 | + <span class="state"> |
| 96 | - if write { | 97 | + (g::t(lang, K::Pinned)) ": " |
| 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 { | | |
| 103 | if pinned { | 98 | if pinned { |
| 104 | - <p>(g::t(lang, K::PinnedTopNote))</p> | 99 | + (g::t(lang, K::PinnedTopNote)) |
| 105 | } else { | 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 | let reply = call(&s.site, "GET", "/tahinli/forge/issues", None, None).await; | 319 | let reply = call(&s.site, "GET", "/tahinli/forge/issues", None, None).await; |
| 320 | assert_eq!(reply.status, 200, "issue list"); | 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 | assert!( | 325 | assert!( |
| 323 | reply | 326 | reply |
| 324 | .body | 327 | .body |
| 325 | .contains(&format!("/tahinli/forge/issues/{number}\"")), | 328 | .contains(&format!("/tahinli/forge/issues/{number}\"")), |
| 326 | "pinned card links the pinned issue" | 329 | "pinned card links the pinned issue" |
| 327 | ); | 330 | ); |
| 328 | - let card_at = reply.body.find("pinned-card").expect("card"); | 331 | + let card_at = reply.body.find("aria-label=\"Pinned issues\"").expect("card"); |
| 329 | - let list_at = reply.body.find("issue-list").expect("list"); | 332 | + let list_at = reply.body.find("class=\"line issue-row\"").expect("list"); |
| 330 | assert!(card_at < list_at, "pinned cards sit above the list"); | 333 | assert!(card_at < list_at, "pinned cards sit above the list"); |
| 331 | | 334 | |
| 332 | let (_, first_number) = s.issues[0].clone(); | 335 | let (_, first_number) = s.issues[0].clone(); |
| @@ -94,39 +94,39 @@ async fn issue_page( |
| 94 | Ok(view! { cx => | 94 | Ok(view! { cx => |
| 95 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), | 95 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), |
| 96 | repo_head(head: header) | 96 | repo_head(head: header) |
| 97 | - <section class="issue-head" data-live=(live_href.as_str()) data-live-now=""> | 97 | + <section class="sec" 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> | 98 | + <h1 class="h1">(issue.title.as_str()) " " <span class="hint">(number_label.as_str())</span></h1> |
| 99 | - <p class="issue-byline"> | 99 | + <p class="hint"> |
| 100 | <span class=(state_class)>(state_text)</span> | 100 | <span class=(state_class)>(state_text)</span> |
| | 101 | + " · " |
| 101 | <strong>user_link(shown: author.as_str(), login: author_login.as_str())</strong> | 102 | <strong>user_link(shown: author.as_str(), login: author_login.as_str())</strong> |
| | 103 | + " " |
| 102 | (g::t(lang, K::OpenedThis)) | 104 | (g::t(lang, K::OpenedThis)) |
| | 105 | + " " |
| 103 | <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> | 106 | <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> |
| | 107 | + " " |
| 104 | (g::opened_after(lang)) | 108 | (g::opened_after(lang)) |
| 105 | " · " | 109 | " · " |
| 106 | (comments_label.as_str()) | 110 | (comments_label.as_str()) |
| 107 | </p> | 111 | </p> |
| 108 | </section> | 112 | </section> |
| 109 | - <div class="issue-layout"> | 113 | + <section class="sec"> |
| 110 | - <div class="issue-column fit-pane"> | 114 | + pin_box(lang: lang, write: write_meta, pinned: pinned, action: pin_action.clone(), csrf: csrf.clone()) |
| 111 | - discussion_timeline(lang: lang, discussion: discussion) | 115 | + item_sidebar(lang: lang, write: write_meta, base: issue_href.clone(), csrf: csrf.clone(), viewer: viewer_login, sidebar: sidebar, notify: notify) |
| 112 | - if can_comment { | 116 | + </section> |
| 113 | - comment_form(lang: lang, action: comment_action.clone(), state_action: comment_action.clone(), | 117 | + discussion_timeline(lang: lang, discussion: discussion) |
| 114 | - csrf: csrf.clone(), draft: draft, error: error, can_close: editable_issue, open: open) | 118 | + if can_comment { |
| 115 | - } | 119 | + comment_form(lang: lang, action: comment_action.clone(), state_action: comment_action.clone(), |
| 116 | - if archived { | 120 | + csrf: csrf.clone(), draft: draft, error: error, can_close: editable_issue, open: open) |
| 117 | - <p class="muted">(g::t(lang, K::ArchivedIssuesReadOnly))</p> | 121 | + } |
| 118 | - } | 122 | + if archived { |
| 119 | - if locked_for_viewer { | 123 | + <p class="hint">(g::t(lang, K::ArchivedIssuesReadOnly))</p> |
| 120 | - <p class="muted">(lock_notice.as_str())</p> | 124 | + } |
| 121 | - } else if !signed_in { | 125 | + if locked_for_viewer { |
| 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> | 126 | + <p class="hint">(lock_notice.as_str())</p> |
| 123 | - } | 127 | + } else if !signed_in { |
| 124 | - </div> | 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> |
| 125 | - <aside class="issue-sidebar fit-pane"> | 129 | + } |
| 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> | | |
| 130 | ) | 130 | ) |
| 131 | }) | 131 | }) |
| 132 | } | 132 | } |
| @@ -217,26 +217,26 @@ async fn edit_item_page( |
| 217 | Ok(view! { cx => | 217 | Ok(view! { cx => |
| 218 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 218 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 219 | repo_head(head: header) | 219 | repo_head(head: header) |
| 220 | - <section class="card issue-edit"> | 220 | + <section class="sec"> |
| 221 | - <h2>(heading.as_str())</h2> | 221 | + <h1 class="h1">(heading.as_str())</h1> |
| 222 | if let Some(message) = error { | 222 | if let Some(message) = error { |
| 223 | alert(message: message.as_str()) | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 226 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 227 | - <label> | 227 | + <div class="field"> |
| 228 | - <span>(g::t(lang, K::Title))</span> | 228 | + <label for="item-title">(g::t(lang, K::Title))</label> |
| 229 | - <input type="text" name="title" value=(title.as_str()) required=(true) autocomplete="off"> | 229 | + <input id="item-title" type="text" name="title" value=(title.as_str()) required=(true) autocomplete="off"> |
| 230 | - </label> | 230 | + </div> |
| 231 | - <label> | 231 | + <div class="field"> |
| 232 | - <span>(g::t(lang, K::Description))</span> | 232 | + <label for="item-body">(g::t(lang, K::Description))</label> |
| 233 | - <textarea name="body" rows="12">(body.as_str())</textarea> | 233 | + <textarea id="item-body" 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> | | |
| 238 | </div> | 234 | </div> |
| | 235 | + <button type="submit" class="primary">(g::t(lang, K::SaveChanges))</button> |
| 239 | </form> | 236 | </form> |
| | 237 | + <div class="acts"> |
| | 238 | + <a class="act quiet" href=(back.as_str())>(g::t(lang, K::Cancel))</a> |
| | 239 | + </div> |
| 240 | </section> | 240 | </section> |
| 241 | ) | 241 | ) |
| 242 | }) | 242 | }) |
| @@ -333,22 +333,22 @@ async fn edit_comment_page( |
| 333 | Ok(view! { cx => | 333 | Ok(view! { cx => |
| 334 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 334 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 335 | repo_head(head: header) | 335 | repo_head(head: header) |
| 336 | - <section class="card issue-edit"> | 336 | + <section class="sec"> |
| 337 | - <h2>(g::t(lang, K::EditComment))</h2> | 337 | + <h1 class="h1">(g::t(lang, K::EditComment))</h1> |
| 338 | if let Some(message) = error { | 338 | if let Some(message) = error { |
| 339 | alert(message: message.as_str()) | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 342 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 343 | - <label> | 343 | + <div class="field"> |
| 344 | - <span>(g::t(lang, K::Comment))</span> | 344 | + <label for="comment-body">(g::t(lang, K::Comment))</label> |
| 345 | - <textarea name="body" rows="10">(body.as_str())</textarea> | 345 | + <textarea id="comment-body" 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> | | |
| 350 | </div> | 346 | </div> |
| | 347 | + <button type="submit" class="primary">(g::t(lang, K::SaveComment))</button> |
| 351 | </form> | 348 | </form> |
| | 349 | + <div class="acts"> |
| | 350 | + <a class="act quiet" href=(back.as_str())>(g::t(lang, K::Cancel))</a> |
| | 351 | + </div> |
| 352 | </section> | 352 | </section> |
| 353 | ) | 353 | ) |
| 354 | }) | 354 | }) |
| @@ -26,7 +26,7 @@ use crate::pages::repo_ctx::{RepoHead, load_repo}; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| 27 | use crate::templates::{self, Template}; | 27 | use crate::templates::{self, Template}; |
| 28 | use crate::views::{ | 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 | shell, user_facing_message, user_link, | 30 | shell, user_facing_message, user_link, |
| 31 | }; | 31 | }; |
| 32 | use crate::webhooks::emit::{Sender, emit_issue}; | 32 | use crate::webhooks::emit::{Sender, emit_issue}; |
| @@ -242,9 +242,16 @@ pub(crate) fn stamp_unix(stamp: &str) -> i64 { |
| 242 | .map_or(0, |t| t.unix_timestamp()) | 242 | .map_or(0, |t| t.unix_timestamp()) |
| 243 | } | 243 | } |
| 244 | | 244 | |
| 245 | -/// Tab class for the state links. | 245 | +/// One link of a tab row. The current tab carries `aria-current`. |
| 246 | -pub(crate) fn state_tab_class(on: bool) -> &'static str { | 246 | +#[component] |
| 247 | - if on { "issue-tab current" } else { "issue-tab" } | 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 | pub(crate) struct AssigneeView { | 257 | pub(crate) struct AssigneeView { |
| @@ -493,82 +500,75 @@ async fn issues_list_page(cx: &Cx) -> Result<impl View> { |
| 493 | g::t(lang, K::NoIssuesYet) | 500 | g::t(lang, K::NoIssuesYet) |
| 494 | }; | 501 | }; |
| 495 | let state_word = sel.state; | 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 | let live_href = list_live_url(&owner_name, &repo_name); | 507 | let live_href = list_live_url(&owner_name, &repo_name); |
| 498 | let header = ctx.head(state, "issues").await?; | 508 | let header = ctx.head(state, "issues").await?; |
| 499 | Ok(view! { | 509 | Ok(view! { |
| 500 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), | 510 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), |
| 501 | repo_head(head: header) | 511 | repo_head(head: header) |
| 502 | - <section class="issue-pane fit-pane"> | 512 | + <div data-live=(live_href.as_str()) data-live-now=""> |
| 503 | - <div class="issue-toolbar" data-live=(live_href.as_str()) data-live-now=""> | 513 | + <h1 class="sr-only">(title.as_str())</h1> |
| 504 | - <nav class="issue-tabs" aria-label=(g::t(lang, K::IssuesByState))> | 514 | + <nav class="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> | 515 | + state_tab(href: open_href.as_str(), text: open_text.as_str(), current: open_on) |
| 506 | - <a class=(state_tab_class(state_word == "closed")) href=(closed_href.as_str())>(closed_text.as_str())</a> | 516 | + state_tab(href: closed_href.as_str(), text: closed_text.as_str(), current: closed_on) |
| 507 | - <a class=(state_tab_class(state_word == "all")) href=(all_href.as_str())>(all_text.as_str())</a> | 517 | + state_tab(href: all_href.as_str(), text: all_text.as_str(), current: all_on) |
| 508 | - </nav> | 518 | + </nav> |
| 509 | - <form method="get" action=(base.as_str()) class="issue-search"> | 519 | + <form method="get" action=(base.as_str())> |
| 510 | - <input type="hidden" name="state" value=(sel.state)> | 520 | + <input type="hidden" name="state" value=(sel.state)> |
| 511 | - <input type="hidden" name="label" value=(sel.label.as_str())> | 521 | + <input type="hidden" name="label" value=(sel.label.as_str())> |
| 512 | - <input type="hidden" name="milestone" value=(sel.milestone.as_str())> | 522 | + <input type="hidden" name="milestone" value=(sel.milestone.as_str())> |
| 513 | - <input type="hidden" name="author" value=(sel.author.as_str())> | 523 | + <input type="hidden" name="author" value=(sel.author.as_str())> |
| 514 | - <input type="hidden" name="assignee" value=(sel.assignee.as_str())> | 524 | + <input type="hidden" name="assignee" value=(sel.assignee.as_str())> |
| | 525 | + <div class="plain-search"> |
| 515 | <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"> | 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 | <select name="sort" aria-label=(g::t(lang, K::Sort))> | 530 | <select name="sort" aria-label=(g::t(lang, K::Sort))> |
| 517 | for option in sort_options.iter() { | 531 | for option in sort_options.iter() { |
| 518 | <option value=(option.value) selected=(option.selected)>(option.label)</option> | 532 | <option value=(option.value) selected=(option.selected)>(option.label)</option> |
| 519 | } | 533 | } |
| 520 | </select> | 534 | </select> |
| 521 | - <button type="submit" class="sr-only">(g::t(lang, K::Search))</button> | 535 | + <a href=(labels_page_href.as_str())>(g::t(lang, K::Labels))</a> |
| 522 | - </form> | 536 | + <a href=(milestones_href.as_str())>(g::t(lang, K::Milestones))</a> |
| 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> | | |
| 531 | if can_create { | 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 | </div> | 540 | </div> |
| 535 | - </div> | 541 | + </form> |
| 536 | if has_filters { | 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 | if !pinned.is_empty() { | 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 | <h2>(g::t(lang, K::Pinned))</h2> | 547 | <h2>(g::t(lang, K::Pinned))</h2> |
| 542 | - <ul class="pinned-list"> | 548 | + for card in pinned.iter() { |
| 543 | - for card in pinned.iter() { | 549 | + <a class="line" href=(card.href.as_str())> |
| 544 | - <li class="pinned-card"> | 550 | + <span class=(card.state_class) role="img" aria-label=(card.state_label)></span> |
| 545 | - <div class="issue-meta muted small"> | 551 | + <span class="name">(card.title.as_str())</span> |
| 546 | - <span class=(card.state_class) role="img" aria-label=(card.state_label)></span> | 552 | + <span class="val">(card.number_text.as_str()) " · " (card.comments_text.as_str())</span> |
| 547 | - <span>(card.number_text.as_str())</span> | 553 | + </a> |
| 548 | - <span>(card.comments_text.as_str())</span> | 554 | + } |
| 549 | - </div> | | |
| 550 | - <a class="pinned-title" href=(card.href.as_str())>(card.title.as_str())</a> | | |
| 551 | - </li> | | |
| 552 | - } | | |
| 553 | - </ul> | | |
| 554 | </section> | 555 | </section> |
| 555 | } | 556 | } |
| 556 | if rows.is_empty() { | 557 | if rows.is_empty() { |
| | 558 | + <p class="state">(empty_text)</p> |
| 557 | if has_filters { | 559 | if has_filters { |
| 558 | - empty_state(title: empty_text, | 560 | + <div class="acts"> |
| 559 | - <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> | 561 | + <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> |
| 560 | - ) | 562 | + </div> |
| 561 | - } else { | 563 | + } else if can_create { |
| 562 | - empty_state(title: empty_text, | 564 | + <div class="acts"> |
| 563 | - if can_create { | 565 | + <a class="act" href=(new_href.as_str()) data-palette-action="go">(g::t(lang, K::NewIssue))</a> |
| 564 | - <a class="button primary" href=(new_href.as_str()) data-palette-action="go">(g::t(lang, K::NewIssue))</a> | 566 | + </div> |
| 565 | - } | | |
| 566 | - ) | | |
| 567 | } | 567 | } |
| 568 | } else { | 568 | } else { |
| 569 | - <ul class="issue-list"> | 569 | + <div> |
| 570 | for row in rows.iter() { | 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 | <span class=(row.state_class) role="img" aria-label=(row.state_label)></span> | 572 | <span class=(row.state_class) role="img" aria-label=(row.state_label)></span> |
| 573 | <div class="issue-main"> | 573 | <div class="issue-main"> |
| 574 | <div class="issue-title-line"> | 574 | <div class="issue-title-line"> |
| @@ -596,32 +596,30 @@ async fn issues_list_page(cx: &Cx) -> Result<impl View> { |
| 596 | if let Some(tasks) = row.tasks_text.clone() { | 596 | if let Some(tasks) = row.tasks_text.clone() { |
| 597 | <span class="task-progress">(tasks.as_str())</span> | 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 | </div> | 605 | </div> |
| 600 | </div> | 606 | </div> |
| 601 | - <div class="issue-aside"> | 607 | + </div> |
| 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> | | |
| 610 | } | 608 | } |
| 611 | - </ul> | 609 | + </div> |
| 612 | } | 610 | } |
| 613 | if has_newer || has_older { | 611 | if has_newer || has_older { |
| 614 | - <nav class="pager"> | 612 | + <nav class="sub"> |
| 615 | if has_newer { | 613 | if has_newer { |
| 616 | <a href=(newer_href.as_str())>(g::t(lang, K::Newer))</a> | 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 | if has_older { | 617 | if has_older { |
| 620 | <a href=(older_href.as_str())>(g::t(lang, K::Older))</a> | 618 | <a href=(older_href.as_str())>(g::t(lang, K::Older))</a> |
| 621 | } | 619 | } |
| 622 | </nav> | 620 | </nav> |
| 623 | } | 621 | } |
| 624 | - </section> | 622 | + </div> |
| 625 | ) | 623 | ) |
| 626 | }) | 624 | }) |
| 627 | } | 625 | } |
| @@ -712,59 +710,53 @@ async fn new_issue_body( |
| 712 | let has_labels = !labels.is_empty(); | 710 | let has_labels = !labels.is_empty(); |
| 713 | Ok(view! { | 711 | Ok(view! { |
| 714 | repo_head(head: head) | 712 | repo_head(head: head) |
| 715 | - <section class="card issue-new fit-pane"> | 713 | + <h1 class="sr-only">(g::t(lang, K::NewIssue))</h1> |
| 716 | - <h2>(g::t(lang, K::NewIssue))</h2> | 714 | + if chooser_mode { |
| 717 | - if chooser_mode { | 715 | + <p class="state">(g::t(lang, K::ChooseTemplate))</p> |
| 718 | - <p class="muted">(g::t(lang, K::ChooseTemplate))</p> | 716 | + <div> |
| 719 | - <ul class="issue-list"> | 717 | + for row in rows.iter() { |
| 720 | - for row in rows.iter() { | 718 | + <a class="line" href=(row.href.as_str())> |
| 721 | - <li class="issue-row"> | 719 | + <span class="name">(row.name.as_str())</span> |
| 722 | - <div class="issue-main"> | 720 | + <span class="val">(row.about.as_str())</span> |
| 723 | - <a class="issue-title" href=(row.href.as_str())>(row.name.as_str())</a> | 721 | + </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()) | | |
| 738 | } | 722 | } |
| 739 | - <form method="post" action=(action.as_str()) class="stack"> | 723 | + </div> |
| 740 | - csrf_field(token: csrf.as_str()) | 724 | + <div class="acts"> |
| 741 | - <label> | 725 | + <a class="act" href=(blank.as_str())>(g::t(lang, K::BlankIssue))</a> |
| 742 | - <span>(g::t(lang, K::Title))</span> | 726 | + <a class="act quiet" href=(cancel.as_str())>(g::t(lang, K::Cancel))</a> |
| 743 | - <input type="text" name="title" value=(draft.title.as_str()) required=(true) autocomplete="off"> | 727 | + </div> |
| 744 | - </label> | 728 | + } else { |
| 745 | - <label> | 729 | + if let Some(message) = draft.error { |
| 746 | - <span>(g::t(lang, K::Description))</span> | 730 | + alert(message: message.as_str()) |
| 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> | | |
| 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 | format!("/{OWNER}/{REPO}/issues") | 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 | fn rows(html: &str) -> usize { | 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 | /// One pristine public fixture, in order: empty list and toolbar links, Turkish empty state, | 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 | use crate::pages::repo::repo_head; | 21 | use crate::pages::repo::repo_head; |
| 22 | use crate::pages::repo_ctx::load_repo; | 22 | use crate::pages::repo_ctx::load_repo; |
| 23 | use crate::state::AppState; | 23 | use crate::state::AppState; |
| | 24 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 24 | use crate::views::repo_list::{PageLink, pager, pager_links}; | 25 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 25 | use crate::views::{enc, shell}; | 26 | use crate::views::{enc, shell}; |
| 26 | | 27 | |
| @@ -59,6 +60,8 @@ struct CsrfForm { |
| 59 | | 60 | |
| 60 | /// One label as the page shows it. | 61 | /// One label as the page shows it. |
| 61 | struct LabelRow { | 62 | struct LabelRow { |
| | 63 | + /// The label's id, used to tie each edit field to its label. |
| | 64 | + key: String, |
| 62 | name: String, | 65 | name: String, |
| 63 | description: String, | 66 | description: String, |
| 64 | color: String, | 67 | color: String, |
| @@ -96,101 +99,87 @@ async fn labels_body( |
| 96 | Ok(view! { | 99 | Ok(view! { |
| 97 | repo_head(head: header) | 100 | repo_head(head: header) |
| 98 | if archived { | 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"> | 104 | + issue_subnav(lang: lang, title: frame.title.clone(), active: "labels".to_owned()) |
| 102 | - 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=""> |
| 103 | - </div> | | |
| 104 | - <section class="card rows-pane lang-list" data-live=(live.as_str()) data-live-now=""> | | |
| 105 | <h2 class="sr-only">(g::t(lang, K::Labels))</h2> | 106 | <h2 class="sr-only">(g::t(lang, K::Labels))</h2> |
| 106 | if can_triage { | 107 | if can_triage { |
| 107 | - <div class="row-line"> | 108 | + <section class="sec"> |
| 108 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 109 | + <h2>(g::t(lang, K::NewLabel))</h2> |
| 109 | - <div class="row-main"> | 110 | + if empty { |
| 110 | - <h2 class="row-title">(g::t(lang, K::NewLabel))</h2> | 111 | + <p class="state">(g::t(lang, K::NoLabelsYet))</p> |
| 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> | | |
| 120 | } | 112 | } |
| 121 | - <details class="row-action"> | 113 | + <div class="acts"> |
| 122 | - <summary>(g::t(lang, K::CreateLabel))</summary> | 114 | + if empty && !archived { |
| 123 | - <div class="row-panel"> | 115 | + post_act(label: g::t(lang, K::AddDefaultLabels), action: defaults_action.as_str(), csrf: csrf.as_str()) |
| 124 | - <form method="post" action=(labels_action.as_str()) class="stack"> | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 119 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 126 | - <label> | 120 | + <div class="field"> |
| 127 | - <span>(g::t(lang, K::Name))</span> | 121 | + <label for="label-create-name">(g::t(lang, K::Name))</label> |
| 128 | - <input type="text" name="name" autocomplete="off" required=(true) maxlength="50"> | 122 | + <input id="label-create-name" type="text" name="name" autocomplete="off" required=(true) maxlength="50"> |
| 129 | - </label> | 123 | + </div> |
| 130 | - <label> | 124 | + <div class="field"> |
| 131 | - <span>(g::t(lang, K::Color))</span> | 125 | + <label for="label-create-color">(g::t(lang, K::Color))</label> |
| 132 | - <input type="color" name="color" value="#ededed"> | 126 | + <input id="label-create-color" type="color" name="color" value="#ededed"> |
| 133 | - </label> | 127 | + </div> |
| 134 | - <label> | 128 | + <div class="field"> |
| 135 | - <span>(g::t(lang, K::Description))</span> | 129 | + <label for="label-create-description">(g::t(lang, K::Description))</label> |
| 136 | - <input type="text" name="description" autocomplete="off" maxlength="500"> | 130 | + <input id="label-create-description" type="text" name="description" autocomplete="off" maxlength="500"> |
| 137 | - </label> | 131 | + </div> |
| 138 | <button type="submit" class="primary">(g::t(lang, K::CreateLabel))</button> | 132 | <button type="submit" class="primary">(g::t(lang, K::CreateLabel))</button> |
| 139 | </form> | 133 | </form> |
| 140 | - </div> | 134 | + ) |
| 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> | | |
| 148 | </div> | 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() { | 140 | + <div> |
| 152 | - <div class="row-line" data-kb-row=""> | 141 | + for row in rows.iter() { |
| 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> | 142 | + <details class="row-open" data-kb-row=""> |
| 154 | - <div class="row-main"> | 143 | + <summary class="line"> |
| 155 | - <strong class="row-name"><a class=(row.chip_class.as_str()) href=(row.issues_href.as_str())>(row.name.as_str())</a></strong> | 144 | + <span class="name"><span class=(row.chip_class.as_str())>(row.name.as_str())</span></span> |
| 156 | - <p class="row-status"> | 145 | + <span class="val"> |
| 157 | - if !row.description.is_empty() { | 146 | + if !row.description.is_empty() { |
| 158 | - <span>(row.description.as_str())</span> " \u{b7} " | 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> | 177 | + </div> |
| 161 | - </p> | 178 | + </details> |
| 162 | - </div> | 179 | + } |
| 163 | - if can_triage { | 180 | + </div> |
| 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 | - } | | |
| 192 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | 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 | let open = counts.get(&label.id).copied().unwrap_or(0); | 206 | let open = counts.get(&label.id).copied().unwrap_or(0); |
| 218 | LabelRow { | 207 | LabelRow { |
| 219 | chip_class: format!("label-chip label-{}", label.id), | 208 | chip_class: format!("label-chip label-{}", label.id), |
| | 209 | + key: label.id.clone(), |
| 220 | issues_href: format!("/{title}/issues?label={}", enc(&label.name)), | 210 | issues_href: format!("/{title}/issues?label={}", enc(&label.name)), |
| 221 | open_text: g::open_label_count(lang, open), | 211 | open_text: g::open_label_count(lang, open), |
| 222 | edit_action: format!("{}/{}", labels_href(&title), label.id), | 212 | edit_action: format!("{}/{}", labels_href(&title), label.id), |
| @@ -78,22 +78,22 @@ async fn login_form( |
| 78 | passkeys: bool, | 78 | passkeys: bool, |
| 79 | ) -> Result<impl View> { | 79 | ) -> Result<impl View> { |
| 80 | Ok(view! { | 80 | Ok(view! { |
| 81 | - <section class="card narrow"> | 81 | + <section> |
| 82 | <h1>(t(lang, Key::LogIn))</h1> | 82 | <h1>(t(lang, Key::LogIn))</h1> |
| 83 | - if let Some(message) = error { | 83 | + <form data-hard="true" method="post" action="/login" class="fields"> |
| 84 | - alert(message: message.as_str()) | 84 | + if let Some(message) = error { |
| 85 | - } | 85 | + alert(message: message.as_str()) |
| 86 | - <form data-hard="true" method="post" action="/login" class="stack"> | 86 | + } |
| 87 | <input type="hidden" name="next" value=(next)> | 87 | <input type="hidden" name="next" value=(next)> |
| 88 | <input type="hidden" name="precsrf" value=(precsrf)> | 88 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 89 | - <label> | 89 | + <div class="field"> |
| 90 | - <span>(t(lang, Key::Username))</span> | 90 | + <label for="login-username">(t(lang, Key::Username))</label> |
| 91 | - <input type="text" name="username" value=(username) autocomplete="username webauthn" required=(true)> | 91 | + <input id="login-username" type="text" name="username" value=(username) autocomplete="username webauthn" required=(true)> |
| 92 | - </label> | 92 | + </div> |
| 93 | - <label> | 93 | + <div class="field"> |
| 94 | - <span>(t(lang, Key::Password))</span> | 94 | + <label for="login-password">(t(lang, Key::Password))</label> |
| 95 | - <input type="password" name="password" autocomplete="current-password" required=(true)> | 95 | + <input id="login-password" type="password" name="password" autocomplete="current-password" required=(true)> |
| 96 | - </label> | 96 | + </div> |
| 97 | <button type="submit" class="primary">(t(lang, Key::LogIn))</button> | 97 | <button type="submit" class="primary">(t(lang, Key::LogIn))</button> |
| 98 | </form> | 98 | </form> |
| 99 | if passkeys { | 99 | if passkeys { |
| @@ -269,18 +269,18 @@ async fn login_submit(cx: &Cx, Form(form): Form<LoginForm>) -> Result<impl View> |
| 269 | #[component] | 269 | #[component] |
| 270 | async fn two_factor_form(lang: Lang, precsrf: &str, error: Option<String>) -> Result<impl View> { | 270 | async fn two_factor_form(lang: Lang, precsrf: &str, error: Option<String>) -> Result<impl View> { |
| 271 | Ok(view! { | 271 | Ok(view! { |
| 272 | - <section class="card narrow"> | 272 | + <section> |
| 273 | <h1>(t(lang, Key::TwoFactorCheck))</h1> | 273 | <h1>(t(lang, Key::TwoFactorCheck))</h1> |
| 274 | - <p class="muted">(t(lang, Key::TwoFactorCheckSub))</p> | 274 | + <p class="hint">(t(lang, Key::TwoFactorCheckSub))</p> |
| 275 | - if let Some(message) = error { | 275 | + <form data-hard="true" method="post" action="/login/2fa" class="fields"> |
| 276 | - alert(message: message.as_str()) | 276 | + if let Some(message) = error { |
| 277 | - } | 277 | + alert(message: message.as_str()) |
| 278 | - <form data-hard="true" method="post" action="/login/2fa" class="stack"> | 278 | + } |
| 279 | <input type="hidden" name="precsrf" value=(precsrf)> | 279 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 280 | - <label> | 280 | + <div class="field"> |
| 281 | - <span>(t(lang, Key::Code))</span> | 281 | + <label for="login-code">(t(lang, Key::Code))</label> |
| 282 | - <input type="text" name="code" autocomplete="one-time-code" required=(true)> | 282 | + <input id="login-code" type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 283 | - </label> | 283 | + </div> |
| 284 | <button type="submit" class="primary">(t(lang, Key::Verify))</button> | 284 | <button type="submit" class="primary">(t(lang, Key::Verify))</button> |
| 285 | </form> | 285 | </form> |
| 286 | </section> | 286 | </section> |
| @@ -35,6 +35,7 @@ use crate::pages::pulls_merge::ERR_NOT_OPEN; |
| 35 | use crate::pages::repo::repo_head; | 35 | use crate::pages::repo::repo_head; |
| 36 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; | 36 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 37 | use crate::state::AppState; | 37 | use crate::state::AppState; |
| | 38 | +use crate::views::parts::confirm_act; |
| 38 | use crate::views::{rel_time, repo_href, shell}; | 39 | use crate::views::{rel_time, repo_href, shell}; |
| 39 | | 40 | |
| 40 | path_param!(owner); | 41 | path_param!(owner); |
| @@ -359,74 +360,85 @@ async fn queue_body( |
| 359 | ) -> Result<impl View> { | 360 | ) -> Result<impl View> { |
| 360 | let remove_label = g::t(lang, K::RemoveFromQueue); | 361 | let remove_label = g::t(lang, K::RemoveFromQueue); |
| 361 | let hint = g::t(lang, K::MergeQueueHint); | 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 | Ok(view! { | 369 | Ok(view! { |
| 363 | repo_head(head: head) | 370 | repo_head(head: head) |
| 364 | if !protected { | 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())> | 374 | + <div data-live=(live.as_str())> |
| 368 | - <div class="list-bar"> | 375 | + <nav class="tabs" aria-label=(g::t(lang, K::MergeQueueNav))> |
| 369 | - <nav class="issue-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> |
| 370 | - <a class=(tab_class(!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> |
| 371 | - <a class=(tab_class(history)) href=(history_href.as_str())>(g::t(lang, K::QueueHistory))</a> | 378 | + </nav> |
| 372 | - </nav> | | |
| 373 | - </div> | | |
| 374 | - <div class="list-scroll"> | | |
| 375 | if empty { | 379 | if empty { |
| 376 | - <p class="muted">(g::t(lang, K::QueueEmpty))</p> | 380 | + <p class="state">(g::t(lang, K::QueueEmpty))</p> |
| 377 | } else { | 381 | } else { |
| 378 | - <div class="table-wrap"> | 382 | + <div> |
| 379 | - <table class="queue-table"> | 383 | + for row in rows.iter() { |
| 380 | - <thead> | 384 | + if row.remove { |
| 381 | - <tr> | 385 | + <details class="row-open"> |
| 382 | - <th>(g::t(lang, K::QueueColPosition))</th> | 386 | + <summary class="line" data-kb-row=""> |
| 383 | - <th>(g::t(lang, K::QueueColPull))</th> | 387 | + <span class="name"><a href=(row.pull_href.as_str())>"#"(row.pull_number)" "(row.pull_title.as_str())</a></span> |
| 384 | - <th>(g::t(lang, K::QueueColBranch))</th> | 388 | + <span class="val"> |
| 385 | - <th>(g::t(lang, K::QueueColState))</th> | 389 | + if !row.position.is_empty() { |
| 386 | - <th>(g::t(lang, K::QueueColBy))</th> | 390 | + (g::t(lang, K::QueueColPosition)) " " (row.position.as_str()) " · " |
| 387 | - <th>(g::t(lang, K::QueueColQueued))</th> | 391 | + } |
| 388 | - <th>(g::t(lang, K::QueueColRun))</th> | 392 | + <span class=(row.state_class)>(row.state)</span> |
| 389 | - <th>(g::t(lang, K::QueueColReason))</th> | 393 | + " · " <code>(row.branch.as_str())</code> |
| 390 | - <th></th> | 394 | + " · " (row.by.as_str()) |
| 391 | - </tr> | 395 | + " · " rel_time(lang: lang, stamp: row.queued_at.as_str()) |
| 392 | - </thead> | 396 | + " · " |
| 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))> | | |
| 403 | if let Some(href) = row.run_href.as_ref() { | 397 | if let Some(href) = row.run_href.as_ref() { |
| 404 | <a href=(href.as_str())>(row.run_label.as_str())</a> | 398 | <a href=(href.as_str())>(row.run_label.as_str())</a> |
| 405 | } else { | 399 | } else { |
| 406 | - <span class="muted">(row.run_label.as_str())</span> | 400 | + <span>(row.run_label.as_str())</span> |
| 407 | } | 401 | } |
| 408 | - </td> | 402 | + if !row.reason.is_empty() { |
| 409 | - <td class="muted small" data-label=(g::t(lang, K::QueueColReason))>(row.reason.as_str())</td> | 403 | + " · " (row.reason.as_str()) |
| 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> | | |
| 416 | } | 404 | } |
| 417 | - </td> | 405 | + </span> |
| 418 | - </tr> | 406 | + </summary> |
| 419 | - } | 407 | + <div class="opened"> |
| 420 | - </tbody> | 408 | + confirm_act(lang: lang, label: remove_label, action: row.remove_action.as_str(), csrf: csrf.as_str(), note: Some(remove_note.clone())) |
| 421 | - </table> | 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 | </div> | 435 | </div> |
| 423 | } | 436 | } |
| 424 | - </div> | 437 | + <p class="hint">(hint)</p> |
| 425 | - <p class="list-foot muted small">(hint)</p> | | |
| 426 | </div> | 438 | </div> |
| 427 | }) | 439 | }) |
| 428 | } | 440 | } |
| 429 | | 441 | |
| 430 | -fn tab_class(on: bool) -> &'static str { | 442 | +fn current_tab(on: bool) -> Option<&'static str> { |
| 431 | - if on { "issue-tab on" } else { "issue-tab" } | 443 | + on.then_some("page") |
| 432 | } | 444 | } |
| @@ -25,6 +25,7 @@ use crate::pages::repo::repo_head; |
| 25 | use crate::pages::repo_ctx::load_repo; | 25 | use crate::pages::repo_ctx::load_repo; |
| 26 | use crate::render::markdown::render_markdown; | 26 | use crate::render::markdown::render_markdown; |
| 27 | use crate::state::AppState; | 27 | use crate::state::AppState; |
| | 28 | +use crate::views::parts::{confirm_act, reveal}; |
| 28 | use crate::views::repo_list::{PageLink, pager, pager_links}; | 29 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 29 | use crate::views::{enc, shell}; | 30 | use crate::views::{enc, shell}; |
| 30 | | 31 | |
| @@ -102,25 +103,21 @@ fn due_on_field(raw: &str) -> Option<&str> { |
| 102 | async fn state_tabs(lang: Lang, title: String, closed: bool) -> Result<impl View> { | 103 | async fn state_tabs(lang: Lang, title: String, closed: bool) -> Result<impl View> { |
| 103 | let open_href = format!("{}?state=open", milestones_href(&title)); | 104 | let open_href = format!("{}?state=open", milestones_href(&title)); |
| 104 | let closed_href = format!("{}?state=closed", milestones_href(&title)); | 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 | Ok(view! { | 106 | Ok(view! { |
| 116 | - <nav class="subnav" aria-label=(g::t(lang, K::MilestoneState))> | 107 | + <nav class="sub" aria-label=(g::t(lang, K::MilestoneState))> |
| 117 | - <a class=(open_class) href=(open_href.as_str())>(g::t(lang, K::Open))</a> | 108 | + if closed { |
| 118 | - <a class=(closed_class) href=(closed_href.as_str())>(g::t(lang, K::Closed))</a> | 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 | </nav> | 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 | #[component] | 121 | #[component] |
| 125 | async fn milestone_row( | 122 | async fn milestone_row( |
| 126 | lang: Lang, | 123 | lang: Lang, |
| @@ -133,11 +130,13 @@ async fn milestone_row( |
| 133 | let open_text = g::open_milestone_count(lang, row.open); | 130 | let open_text = g::open_milestone_count(lang, row.open); |
| 134 | let closed_text = g::closed_milestone_count(lang, row.closed); | 131 | let closed_text = g::closed_milestone_count(lang, row.closed); |
| 135 | Ok(view! { | 132 | Ok(view! { |
| 136 | - <div class="row-line" data-kb-row=""> | 133 | + <details class="row-open" 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> | 134 | + <summary class="line"> |
| 138 | - <div class="row-main"> | 135 | + <span class="name">(row.title.as_str())</span> |
| 139 | - <strong class="row-name">(row.title.as_str())</strong> | 136 | + <span class="val">(open_text.as_str()) " \u{b7} " (closed_text.as_str())</span> |
| 140 | - <p class="row-status"> | 137 | + </summary> |
| | 138 | + <div class="opened"> |
| | 139 | + <p class="state"> |
| 141 | if let Some(due) = row.due.as_deref() { | 140 | if let Some(due) = row.due.as_deref() { |
| 142 | (g::due_text(lang, due)) | 141 | (g::due_text(lang, due)) |
| 143 | if row.overdue { | 142 | if row.overdue { |
| @@ -146,25 +145,24 @@ async fn milestone_row( |
| 146 | } else { | 145 | } else { |
| 147 | (g::t(lang, K::NoDueDate)) | 146 | (g::t(lang, K::NoDueDate)) |
| 148 | } | 147 | } |
| 149 | - " \u{b7} " | 148 | + </p> |
| 150 | - <progress value=(row.closed) max=(max)></progress> | 149 | + <progress value=(row.closed) max=(max)></progress> |
| 151 | - " " | 150 | + <div class="sub"> |
| 152 | <a href=(row.open_href.as_str())>(open_text.as_str())</a> | 151 | <a href=(row.open_href.as_str())>(open_text.as_str())</a> |
| 153 | - " \u{b7} " | | |
| 154 | <a href=(row.closed_href.as_str())>(closed_text.as_str())</a> | 152 | <a href=(row.closed_href.as_str())>(closed_text.as_str())</a> |
| 155 | - </p> | 153 | + </div> |
| 156 | if !row.description_html.is_empty() { | 154 | if !row.description_html.is_empty() { |
| 157 | <div class="markdown-body">(Unescaped::new_unchecked(row.description_html.clone()))</div> | 155 | <div class="markdown-body">(Unescaped::new_unchecked(row.description_html.clone()))</div> |
| 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 | </div> | 164 | </div> |
| 160 | - if can_triage { | 165 | + </details> |
| 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> | | |
| 168 | }) | 166 | }) |
| 169 | } | 167 | } |
| 170 | | 168 | |
| @@ -267,57 +265,48 @@ async fn milestones_body( |
| 267 | Ok(view! { | 265 | Ok(view! { |
| 268 | repo_head(head: header) | 266 | repo_head(head: header) |
| 269 | if frame.archived { | 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"> | 270 | + issue_subnav(lang: lang, title: title.clone(), active: "milestones".to_owned()) |
| 273 | - issue_subnav(lang: lang, title: title.clone(), active: "milestones".to_owned()) | 271 | + state_tabs(lang: lang, title: title.clone(), closed: closed) |
| 274 | - state_tabs(lang: lang, title: title.clone(), closed: closed) | 272 | + <div class="lang-list" data-live=(live.as_str()) data-live-now=""> |
| 275 | - </div> | | |
| 276 | - <section class="card rows-pane lang-list" data-live=(live.as_str()) data-live-now=""> | | |
| 277 | if can_create { | 273 | if can_create { |
| 278 | - <div class="row-line"> | 274 | + <section class="sec"> |
| 279 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 275 | + <h2>(g::t(lang, K::NewMilestone))</h2> |
| 280 | - <div class="row-main"> | 276 | + if empty { |
| 281 | - <h2 class="row-title">(g::t(lang, K::NewMilestone))</h2> | 277 | + <p class="state">(empty_text)</p> |
| 282 | - if empty { | 278 | + } |
| 283 | - <p class="row-status">(empty_text)</p> | 279 | + <div class="acts"> |
| 284 | - } | 280 | + reveal(label: g::t(lang, K::CreateMilestone), id: Some("create-milestone"), open: false, |
| 285 | - </div> | 281 | + <form method="post" action=(create_action.as_str()) class="fields"> |
| 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"> | | |
| 290 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 282 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 291 | - <label> | 283 | + <div class="field"> |
| 292 | - <span>(g::t(lang, K::Title))</span> | 284 | + <label for="milestone-create-title">(g::t(lang, K::Title))</label> |
| 293 | - <input type="text" name="title" autocomplete="off" required=(true) maxlength="256"> | 285 | + <input id="milestone-create-title" type="text" name="title" autocomplete="off" required=(true) maxlength="256"> |
| 294 | - </label> | 286 | + </div> |
| 295 | - <label> | 287 | + <div class="field"> |
| 296 | - <span>(g::t(lang, K::Description))</span> | 288 | + <label for="milestone-create-description">(g::t(lang, K::Description))</label> |
| 297 | - <textarea name="description" rows="4"></textarea> | 289 | + <textarea id="milestone-create-description" name="description" rows="4"></textarea> |
| 298 | - </label> | 290 | + </div> |
| 299 | - <label> | 291 | + <div class="field"> |
| 300 | - <span>(g::t(lang, K::DueDate))</span> | 292 | + <label for="milestone-create-due">(g::t(lang, K::DueDate))</label> |
| 301 | - <input type="date" name="due_on"> | 293 | + <input id="milestone-create-due" type="date" name="due_on"> |
| 302 | - </label> | 294 | + </div> |
| 303 | <button type="submit" class="primary">(g::t(lang, K::CreateMilestone))</button> | 295 | <button type="submit" class="primary">(g::t(lang, K::CreateMilestone))</button> |
| 304 | </form> | 296 | </form> |
| 305 | - </div> | 297 | + ) |
| 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> | | |
| 313 | </div> | 298 | </div> |
| 314 | - </div> | 299 | + </section> |
| 315 | - } | 300 | + } else if empty { |
| 316 | - for row in rows.into_iter() { | 301 | + <p class="state">(empty_text)</p> |
| 317 | - milestone_row(lang: lang, row: row, csrf: row_csrf.clone(), can_triage: can_triage) | | |
| 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 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | 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 | Ok(view! { | 393 | Ok(view! { |
| 405 | repo_head(head: header) | 394 | repo_head(head: header) |
| 406 | issue_subnav(lang: lang, title: frame.title.clone(), active: "milestones".to_owned()) | 395 | issue_subnav(lang: lang, title: frame.title.clone(), active: "milestones".to_owned()) |
| 407 | - <section class="card"> | 396 | + <section class="sec"> |
| 408 | <h2>(g::t(lang, K::EditMilestone))</h2> | 397 | <h2>(g::t(lang, K::EditMilestone))</h2> |
| 409 | - <p><a href=(back.as_str())>(g::t(lang, K::BackToMilestones))</a></p> | 398 | + <p class="sub"><a href=(back.as_str())>(g::t(lang, K::BackToMilestones))</a></p> |
| 410 | - <form method="post" action=(action.as_str()) class="stack"> | 399 | + <form method="post" action=(action.as_str()) class="fields"> |
| 411 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 400 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 412 | - <label> | 401 | + <div class="field"> |
| 413 | - <span>(g::t(lang, K::Title))</span> | 402 | + <label for="milestone-edit-title">(g::t(lang, K::Title))</label> |
| 414 | - <input type="text" name="title" value=(title_value.as_str()) autocomplete="off" required=(true) maxlength="256"> | 403 | + <input id="milestone-edit-title" type="text" name="title" value=(title_value.as_str()) autocomplete="off" required=(true) maxlength="256"> |
| 415 | - </label> | 404 | + </div> |
| 416 | - <label> | 405 | + <div class="field"> |
| 417 | - <span>(g::t(lang, K::Description))</span> | 406 | + <label for="milestone-edit-description">(g::t(lang, K::Description))</label> |
| 418 | - <textarea name="description" rows="4">(description.as_str())</textarea> | 407 | + <textarea id="milestone-edit-description" name="description" rows="4">(description.as_str())</textarea> |
| 419 | - </label> | 408 | + </div> |
| 420 | - <label> | 409 | + <div class="field"> |
| 421 | - <span>(g::t(lang, K::DueDate))</span> | 410 | + <label for="milestone-edit-due">(g::t(lang, K::DueDate))</label> |
| 422 | - <input type="date" name="due_on" value=(due.as_str())> | 411 | + <input id="milestone-edit-due" type="date" name="due_on" value=(due.as_str())> |
| 423 | - </label> | 412 | + </div> |
| 424 | - <label> | 413 | + <div class="field"> |
| 425 | - <span>(g::t(lang, K::StateLabel))</span> | 414 | + <label for="milestone-edit-state">(g::t(lang, K::StateLabel))</label> |
| 426 | - <select name="state"> | 415 | + <select id="milestone-edit-state" name="state"> |
| 427 | <option value="open" selected=(is_open)>(g::t(lang, K::Open))</option> | 416 | <option value="open" selected=(is_open)>(g::t(lang, K::Open))</option> |
| 428 | <option value="closed" selected=(!is_open)>(g::t(lang, K::Closed))</option> | 417 | <option value="closed" selected=(!is_open)>(g::t(lang, K::Closed))</option> |
| 429 | </select> | 418 | </select> |
| 430 | - </label> | | |
| 431 | - <div> | | |
| 432 | - <button type="submit">(g::t(lang, K::SaveMilestone))</button> | | |
| 433 | </div> | 419 | </div> |
| | 420 | + <button type="submit" class="primary">(g::t(lang, K::SaveMilestone))</button> |
| 434 | </form> | 421 | </form> |
| 435 | </section> | 422 | </section> |
| 436 | }) | 423 | }) |
| @@ -22,7 +22,7 @@ use crate::live::{Topic, stream_wakes}; |
| 22 | use crate::pages::ci_runs::run_href; | 22 | use crate::pages::ci_runs::run_href; |
| 23 | use crate::state::AppState; | 23 | use crate::state::AppState; |
| 24 | use crate::views::repo_list::{PageLink, pager, pager_links}; | 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 | /// Most rows one section lists on the overview. | 27 | /// Most rows one section lists on the overview. |
| 28 | const SECTION_ROWS: usize = 8; | 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 | } = section; | 359 | } = section; |
| 360 | Ok(view! { | 360 | Ok(view! { |
| 361 | - <section class="card needs-section"> | 361 | + <section class="sec"> |
| 362 | - <h2 class="needs-head">(heading)</h2> | 362 | + <h2>(heading)</h2> |
| 363 | - <ul class="notif-list"> | 363 | + <div class="plain-rows"> |
| 364 | for row in rows.iter() { | 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 | if let Some(badge) = row.badge { | 367 | if let Some(badge) = row.badge { |
| 367 | <span class="badge">(badge)</span> | 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="val">(row.detail.as_str())</span> |
| 370 | - <span class="muted small">(row.detail.as_str())</span> | 371 | + <span class="val">rel_time(lang: lang, stamp: row.stamp.as_str())</span> |
| 371 | - <span class="muted small">rel_time(lang: lang, stamp: row.stamp.as_str())</span> | 372 | + </a> |
| 372 | - </li> | | |
| 373 | } | 373 | } |
| 374 | - </ul> | 374 | + </div> |
| 375 | if let Some((href, text)) = more { | 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 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | 380 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 379 | </section> | 381 | </section> |
| @@ -411,24 +413,26 @@ async fn needs_you(cx: &Cx) -> Result<impl View> { |
| 411 | let heading = ni::t(lang, K::NeedsYou); | 413 | let heading = ni::t(lang, K::NeedsYou); |
| 412 | Ok(view! { | 414 | Ok(view! { |
| 413 | shell(title: heading, viewer: Some(&viewer), | 415 | shell(title: heading, viewer: Some(&viewer), |
| 414 | - <section class="page-head" data-live=(live.as_str())> | 416 | + <section data-live=(live.as_str())> |
| 415 | - <h1>(heading)</h1> | 417 | + <h1 class="sr-only">(heading)</h1> |
| 416 | if let Some(back) = back { | 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 | </section> | 423 | </section> |
| 420 | if empty { | 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 | if grid { | 427 | if grid { |
| 424 | - <div class="needs-grid"> | 428 | + <div class="needs-page"> |
| 425 | for section in sections.into_iter() { | 429 | for section in sections.into_iter() { |
| 426 | need_section(lang: lang, section: section) | 430 | need_section(lang: lang, section: section) |
| 427 | } | 431 | } |
| 428 | </div> | 432 | </div> |
| 429 | } | 433 | } |
| 430 | if let Some(section) = full { | 434 | if let Some(section) = full { |
| 431 | - <div class="needs-full"> | 435 | + <div class="needs-page"> |
| 432 | need_section(lang: lang, section: section) | 436 | need_section(lang: lang, section: section) |
| 433 | </div> | 437 | </div> |
| 434 | } | 438 | } |
| @@ -18,12 +18,12 @@ use topcoat::view::{View, component, view}; |
| 18 | | 18 | |
| 19 | use crate::audit::{self, Actor, Target}; | 19 | use crate::audit::{self, Actor, Target}; |
| 20 | use crate::auth::{require_csrf, require_user}; | 20 | use crate::auth::{require_csrf, require_user}; |
| 21 | -use crate::i18n::community::{self as community, K as CommunityK}; | | |
| 22 | use crate::i18n::misc::{self as g, K}; | 21 | use crate::i18n::misc::{self as g, K}; |
| 23 | use crate::i18n::{self, Key, Lang}; | 22 | use crate::i18n::{self, Key, Lang}; |
| 24 | use crate::pages::org_ctx::may_create_repo_in; | 23 | use crate::pages::org_ctx::may_create_repo_in; |
| 25 | use crate::pages::repo_mirrors::{Checked, check_form_in, redacted_url}; | 24 | use crate::pages::repo_mirrors::{Checked, check_form_in, redacted_url}; |
| 26 | use crate::state::AppState; | 25 | use crate::state::AppState; |
| | 26 | +use crate::views::parts::reveal; |
| 27 | use crate::views::{alert, csrf_field, shell, user_facing_message}; | 27 | use crate::views::{alert, csrf_field, shell, user_facing_message}; |
| 28 | | 28 | |
| 29 | const MAX_DESCRIPTION_CHARS: usize = 350; | 29 | const MAX_DESCRIPTION_CHARS: usize = 350; |
| @@ -234,108 +234,73 @@ async fn new_repo_form( |
| 234 | let draft_mirror_username = draft.mirror_username; | 234 | let draft_mirror_username = draft.mirror_username; |
| 235 | let draft_mirror_interval = draft.mirror_interval; | 235 | let draft_mirror_interval = draft.mirror_interval; |
| 236 | Ok(view! { | 236 | Ok(view! { |
| 237 | - if let Some(message) = error { | 237 | + <h1 class="sr-only">(i18n::t(lang, Key::NewRepository))</h1> |
| 238 | - alert(message: message.as_str()) | 238 | + crate::pages::import::newrepo_tabs(lang: lang, active: "create") |
| 239 | - } | 239 | + <form method="post" action="/new" class="fields"> |
| 240 | - <form method="post" action="/new" class="newrepo-form"> | 240 | + if let Some(message) = error { |
| | 241 | + alert(message: message.as_str()) |
| | 242 | + } |
| 241 | csrf_field(token: csrf) | 243 | csrf_field(token: csrf) |
| 242 | - <header class="newrepo-head page-head"> | 244 | + <div class="field"> |
| 243 | - <h1>(i18n::t(lang, Key::NewRepository))</h1> | 245 | + <label for="new-owner">(g::t(lang, K::NewOwner))</label> |
| 244 | - crate::pages::import::newrepo_tabs(lang: lang, active: "create") | 246 | + <select id="new-owner" name="owner"> |
| 245 | - <div class="newrepo-head-actions"> | 247 | + for name in owners.iter() { |
| 246 | - <fieldset class="newrepo-visibility"> | 248 | + <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> |
| 247 | - <legend class="sr-only">(g::t(lang, K::VisibilityLegend))</legend> | 249 | + } |
| 248 | - <div class="segmented snippet-segmented"> | 250 | + </select> |
| 249 | - <label class="segment" title=(g::t(lang, K::PrivateHelp))> | 251 | + </div> |
| 250 | - <input type="radio" name="visibility" value="private" checked=(private)> | 252 | + <div class="field"> |
| 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> | 253 | + <label for="new-name">(g::t(lang, K::RepoName))</label> |
| 252 | - <span>(community::t(lang, CommunityK::VisibilityPrivate))</span> | 254 | + <input id="new-name" type="text" name="name" value=(draft.name) required=(true) maxlength="64" autocomplete="off" spellcheck="false"> |
| 253 | - </label> | 255 | + </div> |
| 254 | - <label class="segment" title=(g::t(lang, K::PublicHelp))> | 256 | + <div class="field"> |
| 255 | - <input type="radio" name="visibility" value="public" checked=(!private)> | 257 | + <label for="new-description">(g::t(lang, K::DescriptionOptional))</label> |
| 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> | 258 | + <textarea id="new-description" name="description" rows="3" maxlength="350">(draft.description)</textarea> |
| 257 | - <span>(community::t(lang, CommunityK::VisibilityPublic))</span> | 259 | + </div> |
| 258 | - </label> | 260 | + <div class="field"> |
| 259 | - </div> | 261 | + <label for="new-branch">(g::t(lang, K::DefaultBranch))</label> |
| 260 | - </fieldset> | 262 | + <input id="new-branch" type="text" name="default_branch" value=(branch) maxlength="255" autocomplete="off" spellcheck="false"> |
| 261 | - <button type="submit" class="primary">(g::t(lang, K::CreateRepository))</button> | 263 | + </div> |
| 262 | - </div> | 264 | + <label class="switch"> |
| 263 | - </header> | 265 | + <input type="checkbox" name="default_labels" value="on" checked=(default_labels)> |
| 264 | - <div class="newrepo-card"> | 266 | + <span>(g::t(lang, K::AddDefaultLabels))</span> |
| 265 | - <div class="newrepo-row newrepo-slug"> | 267 | + </label> |
| 266 | - <label class="newrepo-owner"> | 268 | + crate::pages::import::visibility_pick(lang: lang, private: private) |
| 267 | - <span>(g::t(lang, K::NewOwner))</span> | 269 | + <label class="switch"> |
| 268 | - <select name="owner"> | 270 | + <input type="checkbox" name="add_readme" value="on" checked=(add_readme)> |
| 269 | - for name in owners.iter() { | 271 | + <span>(g::t(lang, K::ReadmeLabel))</span> |
| 270 | - <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> | 272 | + </label> |
| 271 | - } | 273 | + <p class="hint">(g::t(lang, K::ReadmeHelp))</p> |
| 272 | - </select> | 274 | + <div class="field"> |
| 273 | - </label> | 275 | + <label for="new-license">(g::t(lang, K::LicenseLabel))</label> |
| 274 | - <span class="newrepo-slash" aria-hidden="true">("/")</span> | 276 | + <select id="new-license" name="license"> |
| 275 | - <label class="newrepo-name"> | 277 | + <option value="" selected=(draft_license.is_empty())>(g::t(lang, K::LicenseNone))</option> |
| 276 | - <span>(g::t(lang, K::RepoName))</span> | 278 | + for (id, label, _) in LICENSES.iter() { |
| 277 | - <input type="text" name="name" value=(draft.name) required=(true) maxlength="64" autocomplete="off" class="newrepo-mono"> | 279 | + <option value=(*id) selected=(*id == draft_license.as_str())>(*label)</option> |
| 278 | - </label> | 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 | </div> | 289 | </div> |
| 280 | - <label> | 290 | + <div class="field"> |
| 281 | - <span>(g::t(lang, K::DescriptionOptional))</span> | 291 | + <label for="new-mirror-username">(g::t(lang, K::UsernameOptional))</label> |
| 282 | - <textarea name="description" rows="3" maxlength="350">(draft.description)</textarea> | 292 | + <input id="new-mirror-username" type="text" name="mirror_username" value=(draft_mirror_username.as_str()) autocomplete="off" maxlength="255"> |
| 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> | | |
| 293 | </div> | 293 | </div> |
| 294 | - <div class="newrepo-files"> | 294 | + <div class="field"> |
| 295 | - <label class="inline newrepo-readme"> | 295 | + <label for="new-mirror-secret">(g::t(lang, K::PasswordOrToken))</label> |
| 296 | - <input type="checkbox" name="add_readme" value="on" checked=(add_readme)> | 296 | + <input id="new-mirror-secret" type="password" name="mirror_secret" autocomplete="new-password" maxlength="1024"> |
| 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> | | |
| 310 | </div> | 297 | </div> |
| 311 | - </div> | 298 | + <div class="field"> |
| 312 | - <details class="newrepo-mirror" open=(mirror_open)> | 299 | + <label for="new-mirror-interval">(g::t(lang, K::SyncInterval))</label> |
| 313 | - <summary> | 300 | + <input id="new-mirror-interval" type="number" name="mirror_interval" value=(draft_mirror_interval.as_str()) min="0" max="525600" step="1"> |
| 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> | | |
| 337 | </div> | 301 | </div> |
| 338 | - </details> | 302 | + ) |
| | 303 | + <button type="submit" class="primary">(g::t(lang, K::CreateRepository))</button> |
| 339 | </form> | 304 | </form> |
| 340 | }) | 305 | }) |
| 341 | } | 306 | } |
| @@ -49,8 +49,10 @@ async fn not_found_body(lang: Lang) -> Result<impl View> { |
| 49 | <section class="not-found"> | 49 | <section class="not-found"> |
| 50 | <p class="not-found-code">"404"</p> | 50 | <p class="not-found-code">"404"</p> |
| 51 | <h1>(title)</h1> | 51 | <h1>(title)</h1> |
| 52 | - <p class="muted">(hint)</p> | 52 | + <p class="state">(hint)</p> |
| 53 | - <a class="button primary" href="/">(back)</a> | 53 | + <div class="acts"> |
| | 54 | + <a class="act" href="/">(back)</a> |
| | 55 | + </div> |
| 54 | </section> | 56 | </section> |
| 55 | }) | 57 | }) |
| 56 | } | 58 | } |
| @@ -35,13 +35,10 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 35 | use crate::pages::repo_transfer::transfer_list_for; | 35 | use crate::pages::repo_transfer::transfer_list_for; |
| 36 | use crate::pages::star::return_path; | 36 | use crate::pages::star::return_path; |
| 37 | use crate::state::AppState; | 37 | use crate::state::AppState; |
| 38 | -use crate::views::{ | 38 | +use crate::views::parts::post_act; |
| 39 | - csrf_field, display_name, empty_state, iso_time, now_unix, relative_time, repo_href, shell, | 39 | +use crate::views::{csrf_field, display_name, iso_time, now_unix, relative_time, repo_href, shell}; |
| 40 | -}; | | |
| 41 | | 40 | |
| 42 | -/// Rows per inbox page: a group head and its rows, with the older link, fit the window's height | 41 | +/// Rows per inbox page. Older rows come behind the older link, so one page stays short. |
| 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. | | |
| 45 | const PAGE_SIZE: u32 = 8; | 42 | const PAGE_SIZE: u32 = 8; |
| 46 | | 43 | |
| 47 | path_param!(owner); | 44 | path_param!(owner); |
| @@ -1120,65 +1117,62 @@ async fn inbox_list( |
| 1120 | } else { | 1117 | } else { |
| 1121 | g::t(lang, K::NoUnreadNotifications) | 1118 | g::t(lang, K::NoUnreadNotifications) |
| 1122 | }; | 1119 | }; |
| 1123 | - let unread_class = if all { "" } else { "active" }; | 1120 | + let unread_current = if all { None } else { Some("page") }; |
| 1124 | - let all_class = if all { "active" } else { "" }; | 1121 | + let all_current = if all { Some("page") } else { None }; |
| 1125 | let unread_text = format!("{} ({unread_count})", g::t(lang, K::Unread)); | 1122 | let unread_text = format!("{} ({unread_count})", g::t(lang, K::Unread)); |
| 1126 | Ok(view! { | 1123 | Ok(view! { |
| 1127 | - <section class="page-head" data-live=(live.as_str())> | 1124 | + <div data-live=(live.as_str())> |
| 1128 | - <h1>(i18n::t(lang, Key::Notifications))</h1> | 1125 | + <h1 class="sr-only">(i18n::t(lang, Key::Notifications))</h1> |
| 1129 | - if !empty { | 1126 | + <nav class="tabs" aria-label=(g::t(lang, K::NotificationFilter))> |
| 1130 | - <form method="post" action="/notifications/mark_all_read" class="notif-inline-form"> | 1127 | + <a href="/notifications" aria-current=(unread_current)>(unread_text.as_str())</a> |
| 1131 | - csrf_field(token: csrf.as_str()) | 1128 | + <a href="/notifications?all=1" aria-current=(all_current)>(g::t(lang, K::AllTab))</a> |
| 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> | | |
| 1143 | <a href="/review-requests">(crate::i18n::authoring::t(lang, crate::i18n::authoring::K::ReviewRequestsTab))</a> | 1129 | <a href="/review-requests">(crate::i18n::authoring::t(lang, crate::i18n::authoring::K::ReviewRequestsTab))</a> |
| 1144 | </nav> | 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 | if empty { | 1137 | if empty { |
| 1146 | - empty_state(title: empty_text, | 1138 | + <section class="sec"> |
| | 1139 | + <p class="state">(empty_text)</p> |
| 1147 | if !all { | 1140 | if !all { |
| 1148 | - <a class="button" href="/notifications?all=1">(g::t(lang, K::ViewAllNotifications))</a> | 1141 | + <div class="acts"> |
| 1149 | - }) | 1142 | + <a class="act" href="/notifications?all=1">(g::t(lang, K::ViewAllNotifications))</a> |
| | 1143 | + </div> |
| | 1144 | + } |
| | 1145 | + </section> |
| 1150 | } | 1146 | } |
| 1151 | for group in groups.into_iter() { | 1147 | for group in groups.into_iter() { |
| 1152 | - <section class="card notif-group"> | 1148 | + <section class="sec"> |
| 1153 | - <header class="notif-group-head"> | 1149 | + <h2><a href=(group.href.as_str())>(group.heading.as_str())</a></h2> |
| 1154 | - <a class="notif-repo" href=(group.href.as_str())>(group.heading.as_str())</a> | 1150 | + <div class="acts"> |
| 1155 | - <form method="post" action=(group.mark_action.as_str()) class="notif-inline-form"> | 1151 | + post_act(label: g::t(lang, K::MarkAllRead), action: group.mark_action.as_str(), csrf: csrf.as_str()) |
| 1156 | - csrf_field(token: csrf.as_str()) | 1152 | + </div> |
| 1157 | - <button type="submit" class="link-button">(g::t(lang, K::MarkAllRead))</button> | 1153 | + <div class="notif-rows"> |
| 1158 | - </form> | | |
| 1159 | - </header> | | |
| 1160 | - <ul class="notif-list"> | | |
| 1161 | for row in group.rows.into_iter() { | 1154 | for row in group.rows.into_iter() { |
| 1162 | - <li class=(row.item_class) data-kb-row=""> | 1155 | + <div class=(row.item_class) data-kb-row=""> |
| 1163 | - <span class=(row.icon_class) aria-hidden="true"></span> | 1156 | + <a class="line" href=(row.open_href.as_str())> |
| 1164 | - <span class="notif-sr">(row.kind_label)</span> | 1157 | + <span class=(row.icon_class) aria-hidden="true"></span> |
| 1165 | - <a class="notif-title" href=(row.open_href.as_str())>(row.title_line.as_str())</a> | 1158 | + <span class="notif-sr">(row.kind_label)</span> |
| 1166 | - <span class="badge">(row.reason)</span> | 1159 | + <span class="name">(row.title_line.as_str())</span> |
| 1167 | - <span class="muted small">(row.activity.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> |
| 1168 | - <time class="muted small" data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | 1161 | + </a> |
| 1169 | if row.unread { | 1162 | if row.unread { |
| 1170 | - <form method="post" action=(row.read_action.as_str()) class="notif-inline-form"> | 1163 | + <div class="acts"> |
| 1171 | - csrf_field(token: csrf.as_str()) | 1164 | + post_act(label: g::t(lang, K::MarkRead), action: row.read_action.as_str(), csrf: csrf.as_str()) |
| 1172 | - <button type="submit" class="link-button">(g::t(lang, K::MarkRead))</button> | 1165 | + </div> |
| 1173 | - </form> | | |
| 1174 | } | 1166 | } |
| 1175 | - </li> | 1167 | + </div> |
| 1176 | } | 1168 | } |
| 1177 | - </ul> | 1169 | + </div> |
| 1178 | </section> | 1170 | </section> |
| 1179 | } | 1171 | } |
| 1180 | if let Some(href) = more { | 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 | </div> | 1177 | </div> |
| 1184 | }) | 1178 | }) |
| @@ -1200,13 +1194,12 @@ pub(crate) async fn notify_box( |
| 1200 | (g::t(lang, K::Subscribe), "subscribe") | 1194 | (g::t(lang, K::Subscribe), "subscribe") |
| 1201 | }; | 1195 | }; |
| 1202 | Ok(view! { | 1196 | Ok(view! { |
| 1203 | - <section class="card notif-box"> | 1197 | + <section class="sec"> |
| 1204 | <h2>(i18n::t(lang, Key::Notifications))</h2> | 1198 | <h2>(i18n::t(lang, Key::Notifications))</h2> |
| 1205 | - <p class="muted small">(reason.as_str())</p> | 1199 | + <p class="state">(reason.as_str())</p> |
| 1206 | - <form method="post" action=(action.as_str()) class="notif-inline-form"> | 1200 | + <div class="acts"> |
| 1207 | - csrf_field(token: csrf.as_str()) | 1201 | + post_act(label: label, action: action.as_str(), csrf: csrf.as_str(), fields: vec![("action".to_owned(), value_text.to_owned())]) |
| 1208 | - <button type="submit" name="action" value=(value_text)>(label)</button> | 1202 | + </div> |
| 1209 | - </form> | | |
| 1210 | </section> | 1203 | </section> |
| 1211 | }) | 1204 | }) |
| 1212 | } | 1205 | } |
| @@ -18,9 +18,8 @@ use crate::auth::{check_csrf, require_user}; |
| 18 | use crate::i18n::Lang; | 18 | use crate::i18n::Lang; |
| 19 | use crate::i18n::orgs::{self as g, K}; | 19 | use crate::i18n::orgs::{self as g, K}; |
| 20 | use crate::pages::packages; | 20 | use crate::pages::packages; |
| 21 | -use crate::pages::profile::profile_tabs; | | |
| 22 | use crate::state::AppState; | 21 | use crate::state::AppState; |
| 23 | -use crate::views::profile_items; | 22 | +use crate::views::{alert, profile_items}; |
| 24 | | 23 | |
| 25 | /// The query key that carries a notice on an org page. Its value is one of the fixed words in | 24 | /// The query key that carries a notice on an org page. Its value is one of the fixed words in |
| 26 | /// `NOTICES`, never user text. The notice lives in the URL, not in a cookie: a live refresh of the | 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 | .map(|(_, key, is_error)| (g::t(lang, *key), *is_error)) | 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 | 187 | +/// The org's name for screen readers (the path bar shows it), and its description as one hint line. |
| 189 | -/// sidebar (see `views::section_for`). | | |
| 190 | #[component] | 188 | #[component] |
| 191 | pub async fn org_head(name: String, description: String) -> Result<impl View> { | 189 | pub async fn org_head(name: String, description: String) -> Result<impl View> { |
| 192 | Ok(view! { | 190 | Ok(view! { |
| 193 | - <section class="page-head org-head"> | 191 | + <h1 class="sr-only">(name.as_str())</h1> |
| 194 | - <div class="org-head-text"> | 192 | + if !description.is_empty() { |
| 195 | - <h1>(name.as_str())</h1> | 193 | + <p class="hint">(description.as_str())</p> |
| 196 | - if !description.is_empty() { | 194 | + } |
| 197 | - <p class="muted">(description.as_str())</p> | | |
| 198 | - } | | |
| 199 | - </div> | | |
| 200 | - </section> | | |
| 201 | }) | 195 | }) |
| 202 | } | 196 | } |
| 203 | | 197 | |
| @@ -214,35 +208,67 @@ pub async fn org_tab_counts(state: &AppState, org: &User, viewer: &User) -> Resu |
| 214 | Ok((repos, packages)) | 208 | Ok((repos, packages)) |
| 215 | } | 209 | } |
| 216 | | 210 | |
| 217 | -/// The profile tab bar on an organization's member pages (members, teams). Only members reach | 211 | +/// The org's tab bar, in the shared tab look. Only members reach the member pages, so Members and |
| 218 | -/// them, so the Members and Teams tabs are always listed, and `current` marks the page's own. | 212 | +/// Teams are always listed; an owner also gets Settings. `current` marks the page's own tab. |
| 219 | #[component] | 213 | #[component] |
| 220 | pub async fn org_tabs( | 214 | pub async fn org_tabs( |
| 221 | lang: Lang, | 215 | lang: Lang, |
| 222 | name: String, | 216 | name: String, |
| 223 | current: String, | 217 | current: String, |
| | 218 | + owner: bool, |
| 224 | repo_count: u64, | 219 | repo_count: u64, |
| 225 | package_count: usize, | 220 | package_count: usize, |
| 226 | ) -> Result<impl View> { | 221 | ) -> Result<impl View> { |
| 227 | - let items = profile_items(lang, &name, true, false, true); | 222 | + let mut tabs: Vec<(String, String, bool, String, bool)> = |
| 228 | - let counts = vec![ | 223 | + profile_items(lang, &name, true, false, true) |
| 229 | - ("repositories", repo_count.to_string()), | 224 | + .into_iter() |
| 230 | - ("packages", package_count.to_string()), | 225 | + .map(|item| { |
| 231 | - ]; | 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 | Ok(view! { | 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 | #[component] | 264 | #[component] |
| 239 | pub async fn org_notice(notice: Option<(&'static str, bool)>) -> Result<impl View> { | 265 | pub async fn org_notice(notice: Option<(&'static str, bool)>) -> Result<impl View> { |
| 240 | Ok(view! { | 266 | Ok(view! { |
| 241 | if let Some((text, is_error)) = notice { | 267 | if let Some((text, is_error)) = notice { |
| 242 | if is_error { | 268 | if is_error { |
| 243 | - <section class="card error" role="alert">(text)</section> | 269 | + alert(message: text) |
| 244 | } else { | 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 | use crate::pages::passkeys; | 25 | use crate::pages::passkeys; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| | 27 | +use crate::views::parts::{confirm_act, reveal}; |
| 27 | use crate::views::{avatar_url, display_name, shell}; | 28 | use crate::views::{avatar_url, display_name, shell}; |
| 28 | | 29 | |
| 29 | path_param!(org); | 30 | path_param!(org); |
| @@ -87,80 +88,78 @@ async fn members_body( |
| 87 | let add_action = format!("{base}/members/add"); | 88 | let add_action = format!("{base}/members/add"); |
| 88 | Ok(view! { | 89 | Ok(view! { |
| 89 | <div data-live=(live.as_str())> | 90 | <div data-live=(live.as_str())> |
| 90 | - org_head(name: name.clone(), description: description) | 91 | + org_tabs(lang: lang, name: name.clone(), current: "members".to_owned(), owner: owner, repo_count: repo_count, package_count: package_count) |
| 91 | - org_tabs(lang: lang, name: name, current: "members".to_owned(), repo_count: repo_count, package_count: package_count) | 92 | + org_head(name: name, description: description) |
| 92 | org_notice(notice: notice) | 93 | org_notice(notice: notice) |
| 93 | - <section class="card rows-pane"> | 94 | + <section class="sec"> |
| | 95 | + <h2>(g::t(lang, K::Members))</h2> |
| 94 | if owner { | 96 | if owner { |
| 95 | - <div class="row-line"> | 97 | + <p class="hint">(g::t(lang, K::OwnersHelp))</p> |
| 96 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 98 | + <div class="acts"> |
| 97 | - <div class="row-main"> | 99 | + reveal(label: g::t(lang, K::AddMemberButton), id: Some("add-member"), |
| 98 | - <h2 class="row-title">(g::t(lang, K::AddMember))</h2> | 100 | + <form method="post" action=(add_action.as_str()) class="fields"> |
| 99 | - <p class="row-status">(g::t(lang, K::OwnersHelp))</p> | 101 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 100 | - </div> | 102 | + <div class="field"> |
| 101 | - <details class="row-action"> | 103 | + <label for="add-member-username">(g::t(lang, K::Username))</label> |
| 102 | - <summary>(g::t(lang, K::AddMemberButton))</summary> | 104 | + <input id="add-member-username" type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 103 | - <div class="row-panel"> | 105 | + </div> |
| 104 | - <form method="post" action=(add_action.as_str()) class="stack"> | 106 | + <div class="field"> |
| 105 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 107 | + <label for="add-member-role">(g::t(lang, K::Role))</label> |
| 106 | - <label> | 108 | + <select id="add-member-role" name="role"> |
| 107 | - <span>(g::t(lang, K::Username))</span> | 109 | + <option value="member" selected=(true)>(g::t(lang, K::RoleMember))</option> |
| 108 | - <input type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> | 110 | + <option value="owner">(g::t(lang, K::RoleOwner))</option> |
| 109 | - </label> | 111 | + </select> |
| 110 | - <label> | 112 | + </div> |
| 111 | - <span>(g::t(lang, K::Role))</span> | 113 | + <button type="submit" class="primary">(g::t(lang, K::AddMemberButton))</button> |
| 112 | - <select name="role"> | 114 | + </form> |
| 113 | - <option value="member" selected=(true)>(g::t(lang, K::RoleMember))</option> | 115 | + ) |
| 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> | | |
| 121 | </div> | 116 | </div> |
| 122 | } | 117 | } |
| 123 | - for row in rows.iter() { | 118 | + <div> |
| 124 | - <div class="row-line"> | 119 | + for row in rows.iter() { |
| 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> | | |
| 137 | if owner || row.is_self { | 120 | if owner || row.is_self { |
| 138 | - <div class="row-actions"> | 121 | + <details class="row-open"> |
| 139 | - if owner { | 122 | + <summary class="line" data-kb-row=""> |
| 140 | - <form method="post" action=(role_action.as_str()) class="row-form"> | 123 | + <span class="name org-who"> |
| 141 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 124 | + <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> |
| 142 | - <input type="hidden" name="user_id" value=(row.user_id.as_str())> | 125 | + <span>(row.label.as_str())</span> |
| 143 | - <select name="role" aria-label=(g::role_for(lang, row.username.as_str()))> | 126 | + </span> |
| 144 | - <option value="owner" selected=(row.is_owner)>(g::t(lang, K::RoleOwner))</option> | 127 | + <span class="val">(if row.is_owner { g::t(lang, K::RoleOwner) } else { g::t(lang, K::RoleMember) })</span> |
| 145 | - <option value="member" selected=(!row.is_owner)>(g::t(lang, K::RoleMember))</option> | 128 | + </summary> |
| 146 | - </select> | 129 | + <div class="opened"> |
| 147 | - <button type="submit">(g::t(lang, K::Save))</button> | 130 | + if owner { |
| 148 | - </form> | 131 | + <form method="post" action=(role_action.as_str()) class="fields"> |
| 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"> | | |
| 154 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 132 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 155 | <input type="hidden" name="user_id" value=(row.user_id.as_str())> | 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 | </form> | 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 | </div> | 149 | </div> |
| 159 | - </details> | 150 | + </div> |
| 160 | - </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> | 161 | + } |
| 163 | - } | 162 | + </div> |
| 164 | </section> | 163 | </section> |
| 165 | </div> | 164 | </div> |
| 166 | }) | 165 | }) |
| @@ -49,27 +49,23 @@ async fn new_org_form( |
| 49 | lang: Lang, | 49 | lang: Lang, |
| 50 | ) -> Result<impl View> { | 50 | ) -> Result<impl View> { |
| 51 | Ok(view! { | 51 | Ok(view! { |
| 52 | - <section class="page-head"> | 52 | + <h1 class="sr-only">(g::t(lang, K::NewOrganization))</h1> |
| 53 | - <h1>(g::t(lang, K::NewOrganization))</h1> | 53 | + <p class="hint">(g::t(lang, K::NewOrgIntro))</p> |
| 54 | - </section> | 54 | + if let Some(message) = error { |
| 55 | - <section class="card org-new"> | 55 | + alert(message: message.as_str()) |
| 56 | - <p class="muted small">(g::t(lang, K::NewOrgIntro))</p> | 56 | + } |
| 57 | - if let Some(message) = error { | 57 | + <form method="post" action="/org/new" class="fields"> |
| 58 | - alert(message: message.as_str()) | 58 | + csrf_field(token: csrf.as_str()) |
| 59 | - } | 59 | + <div class="field"> |
| 60 | - <form method="post" action="/org/new" class="stack"> | 60 | + <label for="org-new-name">(g::t(lang, K::OrgName))</label> |
| 61 | - csrf_field(token: csrf.as_str()) | 61 | + <input id="org-new-name" type="text" name="name" value=(name.as_str()) required=(true) maxlength="64" autocomplete="off"> |
| 62 | - <label> | 62 | + </div> |
| 63 | - <span>(g::t(lang, K::OrgName))</span> | 63 | + <div class="field"> |
| 64 | - <input type="text" name="name" value=(name.as_str()) required=(true) maxlength="64" autocomplete="off"> | 64 | + <label for="org-new-description">(g::t(lang, K::DescriptionOptional))</label> |
| 65 | - </label> | 65 | + <textarea id="org-new-description" name="description" rows="3" maxlength="2000">(description.as_str())</textarea> |
| 66 | - <label> | 66 | + </div> |
| 67 | - <span>(g::t(lang, K::DescriptionOptional))</span> | 67 | + <button type="submit" class="primary">(g::t(lang, K::CreateOrg))</button> |
| 68 | - <textarea name="description" rows="3" maxlength="2000">(description.as_str())</textarea> | 68 | + </form> |
| 69 | - </label> | | |
| 70 | - <button type="submit" class="primary">(g::t(lang, K::CreateOrg))</button> | | |
| 71 | - </form> | | |
| 72 | - </section> | | |
| 73 | }) | 69 | }) |
| 74 | } | 70 | } |
| 75 | | 71 | |
| @@ -22,11 +22,12 @@ use crate::i18n::orgs::{self as g, K}; |
| 22 | use crate::i18n::{self, Key, Lang, t}; | 22 | use crate::i18n::{self, Key, Lang, t}; |
| 23 | use crate::live::Topic; | 23 | use crate::live::Topic; |
| 24 | use crate::pages::org_ctx::{ | 24 | use crate::pages::org_ctx::{ |
| 25 | - DEFAULT_ROLES, load_org, notice_href, org_head, org_notice, require_form_csrf, require_owner, | 25 | + DEFAULT_ROLES, load_org, notice_href, org_notice, org_tab_counts, org_tabs, require_form_csrf, |
| 26 | - take_notice, | 26 | + require_owner, take_notice, |
| 27 | }; | 27 | }; |
| 28 | use crate::pages::settings_profile::store_avatar; | 28 | use crate::pages::settings_profile::store_avatar; |
| 29 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| | 30 | +use crate::views::parts::{confirm_act, reveal}; |
| 30 | use crate::views::{avatar_url, shell, user_facing_message}; | 31 | use crate::views::{avatar_url, shell, user_facing_message}; |
| 31 | | 32 | |
| 32 | path_param!(org); | 33 | path_param!(org); |
| @@ -78,6 +79,8 @@ async fn settings_body( |
| 78 | notice: Option<(&'static str, bool)>, | 79 | notice: Option<(&'static str, bool)>, |
| 79 | lang: Lang, | 80 | lang: Lang, |
| 80 | live: String, | 81 | live: String, |
| | 82 | + repo_count: u64, |
| | 83 | + package_count: usize, |
| 81 | ) -> Result<impl View> { | 84 | ) -> Result<impl View> { |
| 82 | let save_action = format!("{base}/settings"); | 85 | let save_action = format!("{base}/settings"); |
| 83 | let avatar_action = format!("{base}/settings/avatar"); | 86 | let avatar_action = format!("{base}/settings/avatar"); |
| @@ -86,101 +89,79 @@ async fn settings_body( |
| 86 | let confirm_label = g::type_to_confirm(lang, &name); | 89 | let confirm_label = g::type_to_confirm(lang, &name); |
| 87 | Ok(view! { | 90 | Ok(view! { |
| 88 | <div data-live=(live.as_str())> | 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 | org_notice(notice: notice) | 94 | org_notice(notice: notice) |
| 91 | - <section class="card rows-pane"> | 95 | + <form id="org-settings-form" method="post" action=(save_action.as_str())> |
| 92 | - <form id="org-settings-form" method="post" action=(save_action.as_str())> | 96 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 93 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 97 | + <section class="sec"> |
| 94 | - </form> | 98 | + <h2>(crate::pages::passkeys::s(lang, "Details", "Ayrıntılar"))</h2> |
| 95 | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Details", "Ayrıntılar"))</h2> | 99 | + <div class="field"> |
| 96 | - <label class="row-line row-field"> | 100 | + <label for="org-display-name">(g::t(lang, K::DisplayNameLabel))</label> |
| 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> | 101 | + <input id="org-display-name" type="text" name="display_name" maxlength="80" value=(display_name.as_str())> |
| 98 | - <span class="row-main"> | 102 | + </div> |
| 99 | - <span class="row-title">(g::t(lang, K::DisplayNameLabel))</span> | 103 | + <div class="field"> |
| 100 | - </span> | 104 | + <label for="org-description">(g::t(lang, K::Description))</label> |
| 101 | - <span class="row-control"> | 105 | + <textarea id="org-description" name="description" rows="2" maxlength="2000">(description.as_str())</textarea> |
| 102 | - <input form="org-settings-form" type="text" name="display_name" maxlength="80" value=(display_name.as_str())> | 106 | + </div> |
| 103 | - </span> | 107 | + </section> |
| 104 | - </label> | 108 | + <section class="sec"> |
| 105 | - <label class="row-line row-field"> | 109 | + <h2>(crate::pages::passkeys::s(lang, "Members", "Üyeler"))</h2> |
| 106 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 5h14v10H9l-4 4z"/></svg> | 110 | + <div class="field"> |
| 107 | - <span class="row-main"> | 111 | + <label for="org-default-role">(g::t(lang, K::DefaultRoleLabel))</label> |
| 108 | - <span class="row-title">(g::t(lang, K::Description))</span> | 112 | + <select id="org-default-role" name="default_repo_role"> |
| 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"> | | |
| 123 | for choice in DEFAULT_ROLES.iter() { | 113 | for choice in DEFAULT_ROLES.iter() { |
| 124 | <option value=(*choice) selected=(*choice == default_role.as_str())>(g::role_name(lang, choice))</option> | 114 | <option value=(*choice) selected=(*choice == default_role.as_str())>(g::role_name(lang, choice))</option> |
| 125 | } | 115 | } |
| 126 | </select> | 116 | </select> |
| 127 | - </span> | 117 | + <p class="hint">(g::t(lang, K::DefaultRoleHelp))</p> |
| 128 | - </label> | 118 | + </div> |
| 129 | - <label class="row-line row-field"> | 119 | + <label class="switch"> |
| 130 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 12l5 5L20 6"/></svg> | 120 | + <input type="checkbox" name="members_can_create" value="on" checked=(members_can_create)> |
| 131 | - <span class="row-main"> | 121 | + <span>(g::t(lang, K::MembersCanCreate))</span> |
| 132 | - <span class="row-title">(g::t(lang, K::MembersCanCreate))</span> | 122 | + </label> |
| 133 | - </span> | 123 | + <div class="acts"> |
| 134 | - <span class="row-control"> | 124 | + <button type="submit" class="primary">(g::t(lang, K::SaveSettings))</button> |
| 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> | | |
| 148 | </div> | 125 | </div> |
| 149 | - <div class="row-actions row-control"> | 126 | + </section> |
| 150 | - <form method="post" action=(avatar_action.as_str()) enctype="multipart/form-data" class="row-form profile-settings-avatar-upload"> | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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)> | 136 | + <div class="field"> |
| 153 | - <label class="profile-settings-avatar-item" for="org-settings-avatar-file">(t(lang, Key::UploadPhoto))</label> | 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 | <button type="submit" class="primary">(t(lang, Key::Upload))</button> | 140 | <button type="submit" class="primary">(t(lang, Key::Upload))</button> |
| 155 | </form> | 141 | </form> |
| 156 | - if has_avatar { | 142 | + ) |
| 157 | - <form method="post" action=(avatar_remove_action.as_str()) class="row-form"> | 143 | + if has_avatar { |
| 158 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 144 | + confirm_act(lang: lang, label: t(lang, Key::RemovePhoto), action: avatar_remove_action.as_str(), csrf: csrf.as_str()) |
| 159 | - <button type="submit" class="link-button">(t(lang, Key::RemovePhoto))</button> | 145 | + } |
| 160 | - </form> | | |
| 161 | - } | | |
| 162 | - </div> | | |
| 163 | </div> | 146 | </div> |
| 164 | </section> | 147 | </section> |
| 165 | - <section class="card rows-pane security-danger"> | 148 | + <section class="sec"> |
| 166 | - <div class="row-line"> | 149 | + <h2>(g::t(lang, K::DeleteOrg))</h2> |
| 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> | 150 | + <p class="hint">(g::t(lang, K::DeleteOrgIntro))</p> |
| 168 | - <div class="row-main"> | 151 | + <div class="acts"> |
| 169 | - <h2 class="row-title">(g::t(lang, K::DeleteOrg))</h2> | 152 | + <details class="reveal"> |
| 170 | - <p class="row-status">(g::t(lang, K::DeleteOrgIntro))</p> | 153 | + <summary class="act danger">(g::t(lang, K::DeleteOrg))</summary> |
| 171 | - </div> | 154 | + <form class="opened fields" method="post" action=(delete_action.as_str())> |
| 172 | - <details class="row-action danger"> | 155 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 173 | - <summary>(g::t(lang, K::DeleteOrg))</summary> | 156 | + <div class="field"> |
| 174 | - <div class="row-panel"> | 157 | + <label for="org-delete-confirm">(confirm_label.as_str())</label> |
| 175 | - <form method="post" action=(delete_action.as_str()) class="stack"> | 158 | + <input id="org-delete-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 176 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 159 | + </div> |
| 177 | - <label> | 160 | + <div class="acts"> |
| 178 | - <span>(confirm_label.as_str())</span> | 161 | + <button type="submit" class="act danger">(g::t(lang, K::DeleteOrg))</button> |
| 179 | - <input type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> | 162 | + <button type="button" class="act quiet" data-close-details="">(crate::pages::passkeys::s(lang, "Cancel", "Vazgeç"))</button> |
| 180 | - </label> | 163 | + </div> |
| 181 | - <button type="submit" class="danger">(g::t(lang, K::DeleteOrg))</button> | 164 | + </form> |
| 182 | - </form> | | |
| 183 | - </div> | | |
| 184 | </details> | 165 | </details> |
| 185 | </div> | 166 | </div> |
| 186 | </section> | 167 | </section> |
| @@ -209,11 +190,13 @@ async fn org_settings_page(cx: &Cx) -> Result<impl View> { |
| 209 | let base = ctx.href(""); | 190 | let base = ctx.href(""); |
| 210 | let csrf = ctx.viewer.1.csrf_token.clone(); | 191 | let csrf = ctx.viewer.1.csrf_token.clone(); |
| 211 | let live = ctx.href("/settings/events"); | 192 | let live = ctx.href("/settings/events"); |
| | 193 | + let (repo_count, package_count) = org_tab_counts(state, &ctx.org, &ctx.viewer.0).await?; |
| 212 | Ok(view! { cx => | 194 | Ok(view! { cx => |
| 213 | shell(title: title.as_str(), viewer: Some(&ctx.viewer), | 195 | shell(title: title.as_str(), viewer: Some(&ctx.viewer), |
| 214 | settings_body(name: name, display_name: display_name, description: description, | 196 | settings_body(name: name, display_name: display_name, description: description, |
| 215 | has_avatar: has_avatar, avatar_src: avatar_src, base: base, csrf: csrf, | 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 | use crate::pages::passkeys; | 25 | use crate::pages::passkeys; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| | 27 | +use crate::views::parts::{confirm_act, reveal}; |
| 27 | use crate::views::{avatar_url, display_name, repo_href, shell}; | 28 | use crate::views::{avatar_url, display_name, repo_href, shell}; |
| 28 | | 29 | |
| 29 | path_param!(org); | 30 | path_param!(org); |
| @@ -109,7 +110,6 @@ struct RepoChoice { |
| 109 | /// Everything the team page shows besides the notice. | 110 | /// Everything the team page shows besides the notice. |
| 110 | struct TeamPage { | 111 | struct TeamPage { |
| 111 | org_name: String, | 112 | org_name: String, |
| 112 | - org_description: String, | | |
| 113 | base: String, | 113 | base: String, |
| 114 | /// The URL of the team page's change stream. | 114 | /// The URL of the team page's change stream. |
| 115 | live: String, | 115 | live: String, |
| @@ -197,64 +197,59 @@ async fn teams_body( |
| 197 | ) -> Result<impl View> { | 197 | ) -> Result<impl View> { |
| 198 | let create_action = format!("{base}/teams/new"); | 198 | let create_action = format!("{base}/teams/new"); |
| 199 | Ok(view! { | 199 | Ok(view! { |
| 200 | - <div data-live=(live.as_str()) class="teams-page"> | 200 | + <div data-live=(live.as_str())> |
| 201 | - org_head(name: name.clone(), description: description) | 201 | + org_tabs(lang: lang, name: name.clone(), current: "teams".to_owned(), owner: owner, repo_count: repo_count, package_count: package_count) |
| 202 | - org_tabs(lang: lang, name: name, current: "teams".to_owned(), repo_count: repo_count, package_count: package_count) | 202 | + org_head(name: name, description: description) |
| 203 | org_notice(notice: notice) | 203 | org_notice(notice: notice) |
| 204 | - <section class="card rows-pane"> | 204 | + <section class="sec"> |
| 205 | - <div class="row-line"> | 205 | + <h2>(g::t(lang, K::Teams))</h2> |
| 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> | 206 | + <p class="hint">(g::t(lang, K::TeamsIntro))</p> |
| 207 | - <div class="row-main"> | 207 | + if owner { |
| 208 | - <h2 class="row-title">(if owner { g::t(lang, K::NewTeam) } else { g::t(lang, K::Teams) })</h2> | 208 | + <div class="acts"> |
| 209 | - <p class="row-status">(g::t(lang, K::TeamsIntro))</p> | 209 | + reveal(label: g::t(lang, K::CreateTeam), id: Some("new-team"), |
| 210 | - if rows.is_empty() { | 210 | + <form method="post" action=(create_action.as_str()) class="fields"> |
| 211 | - <p class="row-status">(g::t(lang, K::NoTeamsYet))</p> | 211 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 212 | - } | 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 | </div> | 235 | </div> |
| 214 | - if owner { | 236 | + } |
| 215 | - <details class="row-action" id="new-team"> | 237 | + if rows.is_empty() { |
| 216 | - <summary>(g::t(lang, K::CreateTeam))</summary> | 238 | + <p class="state">(g::t(lang, K::NoTeamsYet))</p> |
| 217 | - <div class="row-panel"> | 239 | + } |
| 218 | - <form method="post" action=(create_action.as_str()) class="stack"> | 240 | + <div> |
| 219 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 241 | + for row in rows.iter() { |
| 220 | - <label> | 242 | + <a class="line" href=(row.href.as_str()) data-kb-row=""> |
| 221 | - <span>(g::t(lang, K::Name))</span> | 243 | + <span class="name">(row.name.as_str())</span> |
| 222 | - <input type="text" name="name" autocomplete="off" required=(true) maxlength="64"> | 244 | + <span class="val"> |
| 223 | - </label> | 245 | + (g::coverage_text(lang, row.role, row.all_repos)) |
| 224 | - <label> | 246 | + if !row.description.is_empty() { |
| 225 | - <span>(g::t(lang, K::DescriptionOptional))</span> | 247 | + " · " (row.description.as_str()) |
| 226 | - <textarea name="description" rows="2" maxlength="350"></textarea> | 248 | + } |
| 227 | - </label> | 249 | + </span> |
| 228 | - <label> | 250 | + </a> |
| 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> | | |
| 244 | } | 251 | } |
| 245 | </div> | 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 | </section> | 253 | </section> |
| 259 | </div> | 254 | </div> |
| 260 | }) | 255 | }) |
| @@ -314,181 +309,136 @@ async fn team_body( |
| 314 | let has_description = !data.team_description.is_empty(); | 309 | let has_description = !data.team_description.is_empty(); |
| 315 | Ok(view! { | 310 | Ok(view! { |
| 316 | <div data-live=(data.live.as_str())> | 311 | <div data-live=(data.live.as_str())> |
| 317 | - org_head(name: data.org_name.clone(), description: data.org_description.clone()) | 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) |
| 318 | - org_tabs(lang: lang, name: data.org_name.clone(), current: "teams".to_owned(), repo_count: data.repo_count, package_count: data.package_count) | | |
| 319 | org_notice(notice: notice) | 313 | org_notice(notice: notice) |
| 320 | - <section class="card rows-pane"> | 314 | + <h1 class="h1">(data.team_name.as_str())</h1> |
| 321 | - <div class="row-line"> | 315 | + <p class="hint"> |
| 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> | 316 | + (g::coverage_text(lang, data.team_role, data.team_all_repos)) |
| 323 | - <div class="row-main"> | 317 | + if has_description { |
| 324 | - <h2 class="row-title">(data.team_name.as_str())</h2> | 318 | + " · " (data.team_description.as_str()) |
| 325 | - if has_description { | 319 | + } |
| 326 | - <p class="row-status">(data.team_description.as_str())</p> | 320 | + </p> |
| 327 | - } | 321 | + <section class="sec"> |
| 328 | - <p class="row-status">(g::coverage_text(lang, data.team_role, data.team_all_repos))</p> | 322 | + <h2>(g::t(lang, K::Members))</h2> |
| 329 | - </div> | | |
| 330 | - </div> | | |
| 331 | if owner { | 323 | if owner { |
| 332 | - <form id="team-settings-form" method="post" action=(update_action.as_str())> | 324 | + <div class="acts"> |
| 333 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 325 | + reveal(label: g::t(lang, K::AddToTeam), id: Some("add-member"), |
| 334 | - </form> | 326 | + <form method="post" action=(add_member_action.as_str()) class="fields"> |
| 335 | - <label class="row-line row-field"> | 327 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 336 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h10M4 17h7"/></svg> | 328 | + <div class="field"> |
| 337 | - <span class="row-main"> | 329 | + <label for="team-member-username">(g::t(lang, K::Username))</label> |
| 338 | - <span class="row-title">(g::t(lang, K::Name))</span> | 330 | + <input id="team-member-username" type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 339 | - </span> | 331 | + </div> |
| 340 | - <span class="row-control"> | 332 | + <button type="submit" class="primary">(g::t(lang, K::AddToTeam))</button> |
| 341 | - <input form="team-settings-form" type="text" name="name" value=(data.team_name.as_str()) autocomplete="off" required=(true) maxlength="64"> | 333 | + </form> |
| 342 | - </span> | 334 | + ) |
| 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> | | |
| 377 | </div> | 335 | </div> |
| 378 | } | 336 | } |
| 379 | - </section> | 337 | + if data.members.is_empty() { |
| 380 | - <section class="card rows-pane"> | 338 | + <p class="state">(g::t(lang, K::NoTeamMembers))</p> |
| 381 | - <div class="row-line"> | 339 | + } |
| 382 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 340 | + <div> |
| 383 | - <div class="row-main"> | 341 | + for member in data.members.iter() { |
| 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> | | |
| 416 | if owner { | 342 | if owner { |
| 417 | - <details class="row-menu"> | 343 | + <details class="row-open"> |
| 418 | - <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> | 344 | + <summary class="line" data-kb-row=""> |
| 419 | - <div class="row-menu-panel" role="menu"> | 345 | + <span class="name org-who"> |
| 420 | - <form method="post" action=(remove_member_action.as_str()) class="inline-form"> | 346 | + <img class="avatar avatar-sm" src=(member.avatar.as_str()) alt="" width="24" height="24"> |
| 421 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 347 | + <span>(member.label.as_str())</span> |
| 422 | - <input type="hidden" name="user_id" value=(member.user_id.as_str())> | 348 | + </span> |
| 423 | - <button type="submit" class="danger">(g::t(lang, K::Remove))</button> | 349 | + </summary> |
| 424 | - </form> | 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 | </div> | 355 | </div> |
| 426 | </details> | 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 | </div> | 366 | </div> |
| 460 | - for repo in data.repos.iter() { | 367 | + </section> |
| 461 | - <div class="row-line"> | 368 | + <section class="sec"> |
| 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> | 369 | + <h2>(g::t(lang, K::Repositories))</h2> |
| 463 | - <div class="row-main"> | 370 | + if owner && has_choices { |
| 464 | - <strong class="row-name"><a href=(repo.href.as_str())>(repo.title.as_str())</a></strong> | 371 | + <div class="acts"> |
| 465 | - </div> | 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 | if owner { | 393 | if owner { |
| 467 | - <details class="row-menu"> | 394 | + <details class="row-open"> |
| 468 | - <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> | 395 | + <summary class="line" data-kb-row=""> |
| 469 | - <div class="row-menu-panel" role="menu"> | 396 | + <span class="name">(repo.title.as_str())</span> |
| 470 | - <form method="post" action=(remove_repo_action.as_str()) class="inline-form"> | 397 | + </summary> |
| 471 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 398 | + <div class="opened"> |
| 472 | - <input type="hidden" name="repo_id" value=(repo.repo_id.as_str())> | 399 | + <a class="act quiet" href=(repo.href.as_str())>(passkeys::s(lang, "Open repository", "Depoyu aç"))</a> |
| 473 | - <button type="submit" class="danger">(g::t(lang, K::Unlink))</button> | 400 | + <div class="acts"> |
| 474 | - </form> | 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 | </div> | 403 | </div> |
| 476 | </details> | 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> | 410 | + } |
| 479 | - } | 411 | + </div> |
| 480 | </section> | 412 | </section> |
| 481 | if owner { | 413 | if owner { |
| 482 | - <section class="card rows-pane security-danger"> | 414 | + <section class="sec"> |
| 483 | - <div class="row-line"> | 415 | + <h2>(g::t(lang, K::Settings))</h2> |
| 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> | 416 | + <form id="team-settings-form" method="post" action=(update_action.as_str()) class="fields"> |
| 485 | - <div class="row-main"> | 417 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 486 | - <h2 class="row-title">(g::t(lang, K::DeleteTeam))</h2> | 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 | </div> | 421 | </div> |
| 488 | - <form method="post" action=(delete_action.as_str()) class="row-form"> | 422 | + <div class="field"> |
| 489 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 423 | + <label for="team-description">(g::t(lang, K::DescriptionOptional))</label> |
| 490 | - <button type="submit" class="danger">(g::t(lang, K::DeleteTeam))</button> | 424 | + <textarea id="team-description" name="description" rows="2" maxlength="350">(data.team_description.as_str())</textarea> |
| 491 | - </form> | 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 | </div> | 442 | </div> |
| 493 | </section> | 443 | </section> |
| 494 | } | 444 | } |
| @@ -535,7 +485,6 @@ async fn org_team_page(cx: &Cx) -> Result<impl View> { |
| 535 | repo_count, | 485 | repo_count, |
| 536 | package_count, | 486 | package_count, |
| 537 | org_name: ctx.org.username.clone(), | 487 | org_name: ctx.org.username.clone(), |
| 538 | - org_description: ctx.org.about.clone(), | | |
| 539 | base: ctx.href(&format!("/teams/{}", team.id)), | 488 | base: ctx.href(&format!("/teams/{}", team.id)), |
| 540 | live: ctx.href(&format!("/teams/{}/events", team.id)), | 489 | live: ctx.href(&format!("/teams/{}/events", team.id)), |
| 541 | owner: ctx.is_owner(), | 490 | owner: ctx.is_owner(), |
| @@ -296,8 +296,8 @@ async fn package_view(page: PackagePage) -> Result<impl View> { |
| 296 | let (repo_href, repo_text) = repo_link.unwrap_or_default(); | 296 | let (repo_href, repo_text) = repo_link.unwrap_or_default(); |
| 297 | let private = package.private; | 297 | let private = package.private; |
| 298 | let readme_on = !versions_tab; | 298 | let readme_on = !versions_tab; |
| 299 | - let readme_class = if readme_on { "tab active" } else { "tab" }; | 299 | + let readme_current: Option<&str> = readme_on.then_some("page"); |
| 300 | - let versions_class = if versions_tab { "tab active" } else { "tab" }; | 300 | + let versions_current: Option<&str> = versions_tab.then_some("page"); |
| 301 | let has_versions = !version_rows.is_empty(); | 301 | let has_versions = !version_rows.is_empty(); |
| 302 | let install = pk::t(lang, K::Install); | 302 | let install = pk::t(lang, K::Install); |
| 303 | let copy_label = pk::t(lang, K::CopyCommand); | 303 | let copy_label = pk::t(lang, K::CopyCommand); |
| @@ -305,78 +305,79 @@ async fn package_view(page: PackagePage) -> Result<impl View> { |
| 305 | let versions_label = pk::t(lang, K::PackageVersions); | 305 | let versions_label = pk::t(lang, K::PackageVersions); |
| 306 | let no_readme = pk::t(lang, K::NoReadme); | 306 | let no_readme = pk::t(lang, K::NoReadme); |
| 307 | Ok(view! { | 307 | Ok(view! { |
| 308 | - <article class="package-page" data-live=(events.as_str())> | 308 | + <div data-live=(events.as_str())> |
| 309 | - <header class="package-head"> | 309 | + <h1 class="h1">(package.name.as_str()) " " <span class="muted">(latest_text.as_str())</span></h1> |
| 310 | - <div> | 310 | + <p class="hint">(owner_name.as_str()) " / " (pk::t(lang, K::TabPackages))</p> |
| 311 | - <p class="muted small">(owner_name.as_str()) " / " (pk::t(lang, K::TabPackages))</p> | 311 | + if !description.is_empty() { |
| 312 | - <h1>(package.name.as_str()) " " <span class="muted">(latest_text.as_str())</span></h1> | 312 | + <p class="state">(description.as_str())</p> |
| 313 | - if !description.is_empty() { | 313 | + } |
| 314 | - <p class="muted">(description.as_str())</p> | 314 | + if private { |
| 315 | - } | 315 | + <p class="hint"><span class="badge">(pk::t(lang, K::PackagePrivate))</span></p> |
| 316 | - if private { | 316 | + } |
| 317 | - <span class="badge">(pk::t(lang, K::PackagePrivate))</span> | 317 | + if has_repo { |
| 318 | - } | 318 | + <p class="hint">(pk::t(lang, K::PackageRepoLink)) ": " <a href=(repo_href.as_str())>(repo_text.as_str())</a></p> |
| 319 | - if has_repo { | 319 | + } |
| 320 | - <p class="small">(pk::t(lang, K::PackageRepoLink)) ": " <a href=(repo_href.as_str())>(repo_text.as_str())</a></p> | 320 | + <section class="sec"> |
| 321 | - } | | |
| 322 | - </div> | | |
| 323 | - </header> | | |
| 324 | - <section class="package-install"> | | |
| 325 | <h2>(install)</h2> | 321 | <h2>(install)</h2> |
| 326 | - <p class="muted small">(pk::t(lang, K::InstallHelp))</p> | 322 | + <p class="hint">(pk::t(lang, K::InstallHelp))</p> |
| 327 | - <p class="small">(pk::t(lang, K::InstallRegistryConfig))</p> | 323 | + <p class="state">(pk::t(lang, K::InstallRegistryConfig))</p> |
| 328 | <div class="copy-box"> | 324 | <div class="copy-box"> |
| 329 | <code id="pkg-config">(config_block.as_str())</code> | 325 | <code id="pkg-config">(config_block.as_str())</code> |
| 330 | <button type="button" data-copy="pkg-config">(copy_label)</button> | 326 | <button type="button" data-copy="pkg-config">(copy_label)</button> |
| 331 | </div> | 327 | </div> |
| 332 | - <p class="small">(pk::t(lang, K::InstallAdd))</p> | 328 | + <p class="state">(pk::t(lang, K::InstallAdd))</p> |
| 333 | <div class="copy-box"> | 329 | <div class="copy-box"> |
| 334 | <code id="pkg-add">(add_cmd.as_str())</code> | 330 | <code id="pkg-add">(add_cmd.as_str())</code> |
| 335 | <button type="button" data-copy="pkg-add">(copy_label)</button> | 331 | <button type="button" data-copy="pkg-add">(copy_label)</button> |
| 336 | </div> | 332 | </div> |
| 337 | - <p class="small">(pk::t(lang, K::InstallPublish))</p> | 333 | + <p class="state">(pk::t(lang, K::InstallPublish))</p> |
| 338 | <div class="copy-box"> | 334 | <div class="copy-box"> |
| 339 | <code id="pkg-publish">(publish_cmd.as_str())</code> | 335 | <code id="pkg-publish">(publish_cmd.as_str())</code> |
| 340 | <button type="button" data-copy="pkg-publish">(copy_label)</button> | 336 | <button type="button" data-copy="pkg-publish">(copy_label)</button> |
| 341 | </div> | 337 | </div> |
| 342 | - <p class="small">(pk::t(lang, K::InstallLogin))</p> | 338 | + <p class="state">(pk::t(lang, K::InstallLogin))</p> |
| 343 | <div class="copy-box"> | 339 | <div class="copy-box"> |
| 344 | <code id="pkg-login">(login_cmd.as_str())</code> | 340 | <code id="pkg-login">(login_cmd.as_str())</code> |
| 345 | <button type="button" data-copy="pkg-login">(copy_label)</button> | 341 | <button type="button" data-copy="pkg-login">(copy_label)</button> |
| 346 | </div> | 342 | </div> |
| 347 | </section> | 343 | </section> |
| 348 | - <nav class="profile-tabs" aria-label=(package.name.as_str())> | 344 | + <nav class="tabs" aria-label=(package.name.as_str())> |
| 349 | - <a class=(readme_class) href=(readme_href.as_str())>(readme_label)</a> | 345 | + <a href=(readme_href.as_str()) aria-current=(readme_current)>(readme_label)</a> |
| 350 | - <a class=(versions_class) href=(versions_href.as_str())>(versions_label)</a> | 346 | + <a href=(versions_href.as_str()) aria-current=(versions_current)>(versions_label)</a> |
| 351 | </nav> | 347 | </nav> |
| 352 | if versions_tab { | 348 | if versions_tab { |
| 353 | if has_versions { | 349 | if has_versions { |
| 354 | - <ul class="item-list package-versions"> | 350 | + <div> |
| 355 | for (version, date, yanked, checksum) in version_rows.iter() { | 351 | for (version, date, yanked, checksum) in version_rows.iter() { |
| 356 | - <li> | 352 | + <details class="row-open" data-kb-row=""> |
| 357 | - <span class="repo-name">(version.as_str())</span> | 353 | + <summary class="line"> |
| 358 | - " " | 354 | + <span class="name"> |
| 359 | - <span class="muted small">rel_time(lang: lang, stamp: date.as_str())</span> | 355 | + (version.as_str()) |
| 360 | - if *yanked { | 356 | + if *yanked { |
| 361 | - " " | 357 | + " " <span class="badge">(pk::t(lang, K::VersionYanked))</span> |
| 362 | - <span class="badge">(pk::t(lang, K::VersionYanked))</span> | 358 | + } |
| 363 | - } | 359 | + </span> |
| 364 | - <br> | 360 | + <span class="val">rel_time(lang: lang, stamp: date.as_str())</span> |
| 365 | - <code class="small">(checksum.as_str())</code> | 361 | + </summary> |
| 366 | - </li> | 362 | + <div class="opened"> |
| | 363 | + <code class="hint">(checksum.as_str())</code> |
| | 364 | + </div> |
| | 365 | + </details> |
| 367 | } | 366 | } |
| 368 | - </ul> | 367 | + </div> |
| 369 | } else { | 368 | } else { |
| 370 | empty_state(title: pk::t(lang, K::NoVersions)) | 369 | empty_state(title: pk::t(lang, K::NoVersions)) |
| 371 | } | 370 | } |
| 372 | } else { | 371 | } else { |
| 373 | if has_readme { | 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 | } else { | 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 | pub async fn repo_packages_card(links: Vec<PackageLink>, lang: Lang) -> Result<impl View> { | 447 | pub async fn repo_packages_card(links: Vec<PackageLink>, lang: Lang) -> Result<impl View> { |
| 447 | let heading = pk::t(lang, K::TabPackages); | 448 | let heading = pk::t(lang, K::TabPackages); |
| 448 | Ok(view! { | 449 | Ok(view! { |
| 449 | - <section class="card repo-packages"> | 450 | + <section class="sec repo-packages"> |
| 450 | - <h3>(heading)</h3> | 451 | + <h2>(heading)</h2> |
| 451 | - <ul class="item-list"> | 452 | + <div> |
| 452 | for link in links.into_iter() { | 453 | for link in links.into_iter() { |
| 453 | - <li> | 454 | + <a class="line" href=(link.href.as_str()) data-kb-row=""> |
| 454 | - <a href=(link.href.as_str())>(link.name.as_str())</a> | 455 | + <span class="name">(link.name.as_str())</span> |
| 455 | - " " | 456 | + <span class="val">(link.latest.as_str())</span> |
| 456 | - <span class="muted small">(link.latest.as_str())</span> | 457 | + </a> |
| 457 | - </li> | | |
| 458 | } | 458 | } |
| 459 | - </ul> | 459 | + </div> |
| 460 | </section> | 460 | </section> |
| 461 | }) | 461 | }) |
| 462 | } | 462 | } |
| @@ -11,6 +11,7 @@ use crate::i18n::Lang; |
| 11 | use crate::i18n::packages::{self as pk, K}; | 11 | use crate::i18n::packages::{self as pk, K}; |
| 12 | use crate::package_ops; | 12 | use crate::package_ops; |
| 13 | use crate::state::AppState; | 13 | use crate::state::AppState; |
| | 14 | +use crate::views::parts::confirm_act; |
| 14 | use crate::views::{empty_state, enc, human_size, rel_time}; | 15 | use crate::views::{empty_state, enc, human_size, rel_time}; |
| 15 | | 16 | |
| 16 | /// What the container package page shows, prepared by the handler. | 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 | .collect(); | 112 | .collect(); |
| 112 | Ok(view! { | 113 | Ok(view! { |
| 113 | - <article class="package-page" data-live=(events.as_str())> | 114 | + <div data-live=(events.as_str())> |
| 114 | - <header class="package-head"> | 115 | + <h1 class="h1">(package.name.as_str()) " " <span class="muted">(newest_tag.as_str())</span></h1> |
| 115 | - <div> | 116 | + <p class="hint">(owner_name.as_str()) " / " (pk::t(lang, K::ContainerKind))</p> |
| 116 | - <p class="muted small">(owner_name.as_str()) " / " (pk::t(lang, K::ContainerKind))</p> | 117 | + if private { |
| 117 | - <h1>(package.name.as_str()) " " <span class="muted">(newest_tag.as_str())</span></h1> | 118 | + <p class="hint"><span class="badge">(pk::t(lang, K::PackagePrivate))</span></p> |
| 118 | - if private { | 119 | + } |
| 119 | - <span class="badge">(pk::t(lang, K::PackagePrivate))</span> | 120 | + <section class="sec"> |
| 120 | - } | | |
| 121 | - </div> | | |
| 122 | - </header> | | |
| 123 | - <section class="package-install"> | | |
| 124 | <h2>(pk::t(lang, K::Install))</h2> | 121 | <h2>(pk::t(lang, K::Install))</h2> |
| 125 | - <p class="muted small">(pk::t(lang, K::ContainerInstallHelp))</p> | 122 | + <p class="hint">(pk::t(lang, K::ContainerInstallHelp))</p> |
| 126 | - <p class="small">(pk::t(lang, K::ContainerLogin))</p> | 123 | + <p class="state">(pk::t(lang, K::ContainerLogin))</p> |
| 127 | <div class="copy-box"> | 124 | <div class="copy-box"> |
| 128 | <code id="oci-login">(login.as_str())</code> | 125 | <code id="oci-login">(login.as_str())</code> |
| 129 | <button type="button" data-copy="oci-login">(copy_label)</button> | 126 | <button type="button" data-copy="oci-login">(copy_label)</button> |
| 130 | </div> | 127 | </div> |
| 131 | if has_tags { | 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 | <div class="copy-box"> | 130 | <div class="copy-box"> |
| 134 | <code id="oci-pull">(pull.as_str())</code> | 131 | <code id="oci-pull">(pull.as_str())</code> |
| 135 | <button type="button" data-copy="oci-pull">(copy_label)</button> | 132 | <button type="button" data-copy="oci-pull">(copy_label)</button> |
| 136 | </div> | 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 | <div class="copy-box"> | 136 | <div class="copy-box"> |
| 140 | <code id="oci-push">(push.as_str())</code> | 137 | <code id="oci-push">(push.as_str())</code> |
| 141 | <button type="button" data-copy="oci-push">(copy_label)</button> | 138 | <button type="button" data-copy="oci-push">(copy_label)</button> |
| 142 | </div> | 139 | </div> |
| 143 | </section> | 140 | </section> |
| 144 | - <section class="package-tags"> | 141 | + <section class="sec"> |
| 145 | <h2>(pk::t(lang, K::ContainerTags)) " " <span class="tab-count">(tag_count.as_str())</span></h2> | 142 | <h2>(pk::t(lang, K::ContainerTags)) " " <span class="tab-count">(tag_count.as_str())</span></h2> |
| 146 | if has_tags { | 143 | if has_tags { |
| 147 | - <div class="table-wrap"> | 144 | + <div> |
| 148 | - <table class="table container-tags"> | 145 | + for (tag, short, full, size, created) in rows.iter() { |
| 149 | - <thead> | 146 | + <details class="row-open" data-kb-row=""> |
| 150 | - <tr> | 147 | + <summary class="line"> |
| 151 | - <th>(pk::t(lang, K::ContainerTag))</th> | 148 | + <span class="name"><code>(tag.as_str())</code></span> |
| 152 | - <th>(pk::t(lang, K::ContainerDigest))</th> | 149 | + <span class="val"><code>(short.as_str())</code> " · " (size.as_str()) " · " rel_time(lang: lang, stamp: created.as_str())</span> |
| 153 | - <th>(pk::t(lang, K::ContainerSize))</th> | 150 | + </summary> |
| 154 | - <th>(pk::t(lang, K::ContainerCreated))</th> | 151 | + <div class="opened"> |
| | 152 | + <code class="hint">(full.as_str())</code> |
| 155 | if can_delete { | 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> | 160 | + </div> |
| 159 | - </thead> | 161 | + </details> |
| 160 | - <tbody> | 162 | + } |
| 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> | | |
| 188 | </div> | 163 | </div> |
| 189 | } else { | 164 | } else { |
| 190 | empty_state(title: pk::t(lang, K::NoTags)) | 165 | empty_state(title: pk::t(lang, K::NoTags)) |
| 191 | } | 166 | } |
| 192 | </section> | 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 | /// One destination: its label, its path, what it is (`repo`, `org` or `page`) and its other words. | 248 | /// One destination: its label, its path, what it is (`repo`, `org` or `page`) and its other words. |
| 190 | fn destination(label: &str, href: &str, kind: &str, terms: &[&str]) -> Value { | 249 | fn destination(label: &str, href: &str, kind: &str, terms: &[&str]) -> Value { |
| 191 | let mut item = json!({ "label": label, "href": href, "kind": kind }); | 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 | let scan_key = format!("{}:{lang:?}:{}", user.id, forge_ci::build::display()); | 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 | let mut response = Response::new(Body::from(body.to_string().into_bytes())); | 481 | let mut response = Response::new(Body::from(body.to_string().into_bytes())); |
| 420 | let headers = response.headers_mut(); | 482 | let headers = response.headers_mut(); |
| 421 | headers.insert( | 483 | headers.insert( |
| @@ -43,6 +43,7 @@ use crate::mail::account::{PasskeyChange, send_passkey_notice}; |
| 43 | use crate::state::AppState; | 43 | use crate::state::AppState; |
| 44 | use crate::throttle::{self, LOGIN_IP_LIMIT}; | 44 | use crate::throttle::{self, LOGIN_IP_LIMIT}; |
| 45 | use crate::views::added_status; | 45 | use crate::views::added_status; |
| | 46 | +use crate::views::parts::{confirm_act, reveal}; |
| 46 | | 47 | |
| 47 | /// How long a started ceremony stays valid. | 48 | /// How long a started ceremony stays valid. |
| 48 | const CEREMONY_TTL: Duration = Duration::from_secs(5 * 60); | 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 | /// `nav.js` drives. The add form stays hidden until the browser proves it supports passkeys. | 651 | /// `nav.js` drives. The add form stays hidden until the browser proves it supports passkeys. |
| 651 | #[component] | 652 | #[component] |
| 652 | pub async fn passkeys_panel(lang: Lang, csrf: &str, panel: PasskeyPanel) -> Result<impl View> { | 653 | pub async fn passkeys_panel(lang: Lang, csrf: &str, panel: PasskeyPanel) -> Result<impl View> { |
| 653 | let PasskeyPanel { items, problem } = panel; | 654 | let PasskeyPanel { items, problem } = panel; |
| 654 | - let count = items.len(); | 655 | + let empty = items.is_empty(); |
| 655 | - let pill_class = if count > 0 { | 656 | + let count_text = format!("{} {}", items.len(), s(lang, "passkeys", "geçiş anahtarı")); |
| 656 | - "security-pill on" | | |
| 657 | - } else { | | |
| 658 | - "security-pill off" | | |
| 659 | - }; | | |
| 660 | - let pill_text = count.to_string(); | | |
| 661 | let usable = problem.is_none(); | 657 | let usable = problem.is_none(); |
| 662 | let problem_text = problem.map(|why| why.message(lang)); | 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 | Ok(view! { | 668 | Ok(view! { |
| 664 | - <div class="rows-block" data-passkeys=""> | 669 | + <section class="sec" id="passkeys" data-passkeys=""> |
| 665 | - <div class="row-line"> | 670 | + <h2>(s(lang, "Passkeys", "Geçiş anahtarları"))</h2> |
| 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> | 671 | + if empty { |
| 667 | - <div class="row-main"> | 672 | + <p class="state">(s(lang, "None", "Yok"))</p> |
| 668 | - <h2 class="row-title"> | 673 | + } else { |
| 669 | - <span>(s(lang, "Passkeys", "Geçiş anahtarları"))</span> | 674 | + <p class="state">(count_text.as_str())</p> |
| 670 | - <span class=(pill_class)>(pill_text.as_str())</span> | 675 | + } |
| 671 | - </h2> | 676 | + if let Some(text) = problem_text { |
| 672 | - if let Some(text) = problem_text { | 677 | + <p class="hint topic-warn">(text)</p> |
| 673 | - <p class="row-status warn">(text)</p> | 678 | + } else { |
| 674 | - } 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> |
| 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> | 680 | + } |
| 676 | - } | 681 | + if !empty { |
| 677 | - </div> | 682 | + <div> |
| 678 | - </div> | 683 | + for (item, rename_action, delete_action, field) in rows.into_iter() { |
| 679 | - if !items.is_empty() { | 684 | + <details class="row-open"> |
| 680 | - <ul class="security-devices"> | 685 | + <summary class="line"> |
| 681 | - for item in items.into_iter() { | 686 | + <span class="name">(item.name.as_str())</span> |
| 682 | - <li class="row-line security-device"> | 687 | + <span class="val">added_status(lang: lang, added: Some(item.created_at.as_str()), used: item.last_used_at.as_deref())</span> |
| 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> | 688 | + </summary> |
| 684 | - <div class="row-main"> | 689 | + <div class="opened"> |
| 685 | - <p class="row-title">(item.name.as_str())</p> | 690 | + <div class="acts"> |
| 686 | - <p class="row-status">added_status(lang: lang, added: Some(item.created_at.as_str()), used: item.last_used_at.as_deref())</p> | 691 | + reveal(label: s(lang, "Rename", "Yeniden adlandır"), |
| 687 | - </div> | 692 | + <form method="post" action=(rename_action.as_str()) class="fields"> |
| 688 | - <details class="row-action"> | 693 | + <input type="hidden" name="csrf" value=(csrf)> |
| 689 | - <summary>(s(lang, "Rename", "Yeniden adlandır"))</summary> | 694 | + <div class="field"> |
| 690 | - <div class="row-panel"> | 695 | + <label for=(field.as_str())>(s(lang, "Name", "Ad"))</label> |
| 691 | - <form method="post" action=(format!("/settings/security/passkeys/{}/rename", item.id)) class="stack"> | 696 | + <input id=(field.as_str()) type="text" name="name" value=(item.name.as_str()) maxlength="40" autocomplete="off" required=(true)> |
| 692 | - <input type="hidden" name="csrf" value=(csrf)> | 697 | + </div> |
| 693 | - <label> | 698 | + <button type="submit" class="primary">(t(lang, Key::Save))</button> |
| 694 | - <span>(s(lang, "Name", "Ad"))</span> | 699 | + </form> |
| 695 | - <input type="text" name="name" value=(item.name.as_str()) maxlength="40" autocomplete="off" required=(true)> | 700 | + ) |
| 696 | - </label> | 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())) |
| 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> | | |
| 710 | </div> | 702 | </div> |
| 711 | - </details> | 703 | + </div> |
| 712 | - </li> | 704 | + </details> |
| 713 | } | 705 | } |
| 714 | - </ul> | 706 | + </div> |
| 715 | } | 707 | } |
| 716 | if usable { | 708 | if usable { |
| 717 | - <form data-hard="true" data-passkey-add="" hidden=(true) class="row-panel passkey-add stack" action="/settings/security" method="get"> | 709 | + <div class="acts"> |
| 718 | - <input type="hidden" name="csrf" value=(csrf)> | 710 | + reveal(label: s(lang, "Add a passkey", "Geçiş anahtarı ekle"), |
| 719 | - <label> | 711 | + <form data-hard="true" data-passkey-add="" hidden=(true) action="/settings/security" method="get" class="fields"> |
| 720 | - <span>(s(lang, "Name for the new passkey", "Yeni geçiş anahtarının adı"))</span> | 712 | + <input type="hidden" name="csrf" value=(csrf)> |
| 721 | - <input type="text" name="name" maxlength="40" autocomplete="off" placeholder=(s(lang, "Laptop", "Dizüstü")) required=(true)> | 713 | + <div class="field"> |
| 722 | - </label> | 714 | + <label for="passkey-new-name">(s(lang, "Name for the new passkey", "Yeni geçiş anahtarının adı"))</label> |
| 723 | - <button type="submit" class="primary">(s(lang, "Add a passkey", "Geçiş anahtarı ekle"))</button> | 715 | + <input id="passkey-new-name" type="text" name="name" maxlength="40" autocomplete="off" placeholder=(s(lang, "Laptop", "Dizüstü")) required=(true)> |
| 724 | - <p class="passkey-error" role="alert" hidden=(true)></p> | 716 | + </div> |
| 725 | - </form> | 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 | pub async fn login_passkey(lang: Lang) -> Result<impl View> { | 730 | pub async fn login_passkey(lang: Lang) -> Result<impl View> { |
| 735 | Ok(view! { | 731 | Ok(view! { |
| 736 | <div class="passkey-login" data-passkey-login="" hidden=(true)> | 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 | <button type="button" class="passkey-button" data-passkey-signin="">(s(lang, "Sign in with a passkey", "Geçiş anahtarıyla giriş yap"))</button> | 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 | <p class="passkey-error" role="alert" hidden=(true)></p> | 735 | <p class="passkey-error" role="alert" hidden=(true)></p> |
| 740 | </div> | 736 | </div> |
| @@ -583,7 +583,13 @@ async fn passkey_pages_show_the_ui_and_admins_remove_all_passkeys() { |
| 583 | .await; | 583 | .await; |
| 584 | assert!(page.body.contains("data-passkey-add")); | 584 | assert!(page.body.contains("data-passkey-add")); |
| 585 | assert!(page.body.contains("Laptop")); | 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 | let login = send(&fx.router, "GET", "/login", None, &[]).await; | 593 | let login = send(&fx.router, "GET", "/login", None, &[]).await; |
| 588 | assert!(login.body.contains("data-passkey-signin")); | 594 | assert!(login.body.contains("data-passkey-signin")); |
| 589 | assert!(login.body.contains("autocomplete=\"username webauthn\"")); | 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 | let detail = format!("/admin/users/{}", fx.owner_id); | 598 | let detail = format!("/admin/users/{}", fx.owner_id); |
| 593 | let page = send(&fx.router, "GET", &detail, session_cookie(ADMIN_TOKEN), &[]).await; | 599 | let page = send(&fx.router, "GET", &detail, session_cookie(ADMIN_TOKEN), &[]).await; |
| 594 | assert_eq!(page.status, 200); | 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 | let uri = format!("{detail}/remove-passkeys"); | 604 | let uri = format!("{detail}/remove-passkeys"); |
| 598 | let denied = send( | 605 | let denied = send( |
| @@ -40,7 +40,7 @@ use crate::views::repo_list::{ |
| 40 | PageLink, RepoRow, SortLink, badge_class, pager, pager_links, repo_rows, sort_chips, | 40 | PageLink, RepoRow, SortLink, badge_class, pager, pager_links, repo_rows, sort_chips, |
| 41 | }; | 41 | }; |
| 42 | use crate::views::{ | 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 | path_param!(username); | 46 | path_param!(username); |
| @@ -520,10 +520,6 @@ fn profile_href(name: &str, tab: &str, q: &str, sort: &str, page: u64) -> String |
| 520 | href | 520 | href |
| 521 | } | 521 | } |
| 522 | | 522 | |
| 523 | -fn tab_class(on: bool) -> &'static str { | | |
| 524 | - if on { "tab active" } else { "tab" } | | |
| 525 | -} | | |
| 526 | - | | |
| 527 | /// Whether the viewer may read `repo`. Public repos, and repos the viewer owns or administers, | 523 | /// Whether the viewer may read `repo`. Public repos, and repos the viewer owns or administers, |
| 528 | /// need no role lookup. Other private repos get their collaborator and org roles, and `authorize` | 524 | /// need no role lookup. Other private repos get their collaborator and org roles, and `authorize` |
| 529 | /// makes the final call either way. | 525 | /// makes the final call either way. |
| @@ -619,11 +615,6 @@ async fn profile_card( |
| 619 | ]; | 615 | ]; |
| 620 | let base = format!("/{}", enc(&user.username)); | 616 | let base = format!("/{}", enc(&user.username)); |
| 621 | let overview_on = tab == "overview"; | 617 | let overview_on = tab == "overview"; |
| 622 | - let overview_class = if is_org { | | |
| 623 | - "org-overview" | | |
| 624 | - } else { | | |
| 625 | - "profile-overview" | | |
| 626 | - }; | | |
| 627 | let repos_on = tab == "repositories"; | 618 | let repos_on = tab == "repositories"; |
| 628 | let stars_on = tab == "stars"; | 619 | let stars_on = tab == "stars"; |
| 629 | let list_on = repos_on || stars_on; | 620 | let list_on = repos_on || stars_on; |
| @@ -655,31 +646,35 @@ async fn profile_card( |
| 655 | let new_repo_href = format!("/new?owner={}", enc(&user.username)); | 646 | let new_repo_href = format!("/new?owner={}", enc(&user.username)); |
| 656 | let settings_href = format!("/org/{}/settings", enc(&user.username)); | 647 | let settings_href = format!("/org/{}/settings", enc(&user.username)); |
| 657 | let members_href = format!("/org/{}/members", enc(&user.username)); | 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 | Ok(view! { | 653 | Ok(view! { |
| 659 | <article class="profile-page" data-live=(format!("/users/{}/events", user.username))> | 654 | <article class="profile-page" data-live=(format!("/users/{}/events", user.username))> |
| 660 | <header class="profile-head"> | 655 | <header class="profile-head"> |
| 661 | <img class=(avatar_class) src=(src) alt="" width=(avatar_px) height=(avatar_px)> | 656 | <img class=(avatar_class) src=(src) alt="" width=(avatar_px) height=(avatar_px)> |
| 662 | <div class="profile-id"> | 657 | <div class="profile-id"> |
| 663 | - <h1>(heading)</h1> | 658 | + <h1 class="h1">(heading)</h1> |
| 664 | if has_name { | 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 | if is_org { | 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 | if !is_org { | 665 | if !is_org { |
| 671 | - <p class="muted">(g::t(lang, K::LocalTime)) (local_time.as_str())</p> | 666 | + <p class="hint">(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> | | |
| 675 | } | 667 | } |
| 676 | - if is_org && (org_owner || org_can_create) { | 668 | + if has_acts { |
| 677 | - <div class="profile-org-actions"> | 669 | + <div class="acts"> |
| | 670 | + if edit_profile { |
| | 671 | + <a class="act" href="/settings/profile">(edit_label)</a> |
| | 672 | + } |
| 678 | if org_owner { | 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 | if org_can_create { | 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 | </div> | 679 | </div> |
| 685 | } | 680 | } |
| @@ -694,9 +689,8 @@ async fn profile_card( |
| 694 | contribution_calendar(calendar: calendar, selected: selected, lang: lang, base: base.clone(), | 689 | contribution_calendar(calendar: calendar, selected: selected, lang: lang, base: base.clone(), |
| 695 | live: Some(format!("/users/{}/events", user.username))) | 690 | live: Some(format!("/users/{}/events", user.username))) |
| 696 | } | 691 | } |
| 697 | - <div class=(overview_class)> | 692 | + <section class="sec profile-pinned"> |
| 698 | - <section class="profile-pinned"> | 693 | + <div class="topic-head"> |
| 699 | - <div class="profile-section-head"> | | |
| 700 | <h2>(pinned_heading)</h2> | 694 | <h2>(pinned_heading)</h2> |
| 701 | if let Some(menu) = pins_menu_data { | 695 | if let Some(menu) = pins_menu_data { |
| 702 | pins_menu(lang: lang, action: menu.action, csrf: menu.csrf, options: menu.options) | 696 | pins_menu(lang: lang, action: menu.action, csrf: menu.csrf, options: menu.options) |
| @@ -706,37 +700,28 @@ async fn profile_card( |
| 706 | <p class="alert" role="alert">(g::t(lang, K::PinsTooMany))</p> | 700 | <p class="alert" role="alert">(g::t(lang, K::PinsTooMany))</p> |
| 707 | } | 701 | } |
| 708 | if has_cards { | 702 | if has_cards { |
| 709 | - <ul class="pin-grid"> | 703 | + <ul class="repo-list"> |
| 710 | for card in cards.into_iter() { | 704 | for card in cards.into_iter() { |
| 711 | - <li class="pin-card"> | 705 | + <li class="line repo-item" data-kb-row=""> |
| 712 | - <div class="pin-head"> | 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> |
| 713 | - <a class="repo-name" href=(repo_href(&card.repo.owner_name, &card.repo.name, "", ""))> | 707 | + <span class=(badge_class(card.repo.visibility))>(i18n::visibility_label(lang, card.repo.visibility))</span> |
| 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> | | |
| 718 | if !card.repo.description.is_empty() { | 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 | </li> | 712 | </li> |
| 723 | } | 713 | } |
| 724 | </ul> | 714 | </ul> |
| 725 | } else { | 715 | } else { |
| 726 | - empty_state(title: g::t(lang, K::NoVisibleRepos)) | 716 | + <p class="state">(g::t(lang, K::NoVisibleRepos))</p> |
| 727 | } | 717 | } |
| 728 | </section> | 718 | </section> |
| 729 | if let Some(summary) = org { | 719 | if let Some(summary) = org { |
| 730 | - <section class="card profile-org"> | 720 | + <section class="sec profile-org"> |
| 731 | - <div class="profile-section-head"> | 721 | + <h2>(g::t(lang, K::Members))</h2> |
| 732 | - <h2>(g::t(lang, K::Members))</h2> | 722 | + <p class="hint">(g::members_and_teams(lang, summary.total, summary.teams))</p> |
| 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> | | |
| 738 | if summary.members.is_empty() { | 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 | } else { | 725 | } else { |
| 741 | <ul class="org-members"> | 726 | <ul class="org-members"> |
| 742 | for member in summary.members.into_iter() { | 727 | for member in summary.members.into_iter() { |
| @@ -749,108 +734,104 @@ async fn profile_card( |
| 749 | } | 734 | } |
| 750 | </ul> | 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 | </section> | 742 | </section> |
| 753 | } | 743 | } |
| 754 | - </div> | | |
| 755 | } | 744 | } |
| 756 | if list_on { | 745 | if list_on { |
| 757 | <section class="repo-listing"> | 746 | <section class="repo-listing"> |
| 758 | - <div class="repo-tools"> | 747 | + <form method="get" action=(base.as_str()) class="plain-search" role="search"> |
| 759 | - <form method="get" action=(base.as_str()) class="explore-search" role="search"> | 748 | + <input type="hidden" name="tab" value=(tab.as_str())> |
| 760 | - <input type="hidden" name="tab" value=(tab.as_str())> | 749 | + <input type="hidden" name="sort" value=(sort)> |
| 761 | - <input type="hidden" name="sort" value=(sort)> | 750 | + <input type="search" name="q" value=(q.as_str()) data-live-search="" |
| 762 | - <input type="search" name="q" value=(q.as_str()) data-live-search="" | 751 | + placeholder=(filter_label) aria-label=(filter_label)> |
| 763 | - placeholder=(filter_label) aria-label=(filter_label)> | 752 | + <button type="submit" class="act">(g::t(lang, K::Search))</button> |
| 764 | - <button type="submit">(g::t(lang, K::Search))</button> | 753 | + </form> |
| 765 | - </form> | 754 | + sort_chips(links: sort_links, lang: lang) |
| 766 | - if own_profile && repos_on { | 755 | + <p class="hint repo-count">(count_text.as_str())</p> |
| 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> | | |
| 774 | if has_rows { | 756 | if has_rows { |
| 775 | repo_rows(rows: rows, lang: lang) | 757 | repo_rows(rows: rows, lang: lang) |
| 776 | } else { | 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 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | 766 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 780 | </section> | 767 | </section> |
| 781 | } | 768 | } |
| 782 | if packages_on { | 769 | if packages_on { |
| 783 | - <section class="package-listing" data-live=(packages_events.as_str())> | 770 | + <section class="sec package-listing" data-live=(packages_events.as_str())> |
| 784 | - <div class="profile-section-head"> | 771 | + <h2>(pk::t(lang, PK::PackagesHeading))</h2> |
| 785 | - <h2>(pk::t(lang, PK::PackagesHeading))</h2> | 772 | + <p class="hint">(pk::t(lang, PK::PackagesHelp))</p> |
| 786 | - </div> | | |
| 787 | - <p class="muted small">(pk::t(lang, PK::PackagesHelp))</p> | | |
| 788 | if has_packages { | 773 | if has_packages { |
| 789 | - <ul class="item-list"> | 774 | + <div class="plain-rows"> |
| 790 | for row in package_rows.into_iter() { | 775 | for row in package_rows.into_iter() { |
| 791 | - <li> | 776 | + <div class="line" data-kb-row=""> |
| 792 | - <a class="repo-name" href=(row.href.as_str())>(row.name.as_str())</a> | 777 | + <a class="name" href=(row.href.as_str())>(row.name.as_str())</a> |
| 793 | - " " | | |
| 794 | if row.container { | 778 | if row.container { |
| 795 | <span class="badge">(pk::t(lang, PK::ContainerKind))</span> | 779 | <span class="badge">(pk::t(lang, PK::ContainerKind))</span> |
| 796 | - " " | | |
| 797 | } | 780 | } |
| 798 | - <span class="muted small">(row.latest.as_str())</span> | 781 | + <span class="val">(row.latest.as_str())</span> |
| 799 | - " " | 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> |
| 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> | | |
| 801 | if row.private { | 783 | if row.private { |
| 802 | - " " | | |
| 803 | <span class="badge">(pk::t(lang, PK::PackagePrivate))</span> | 784 | <span class="badge">(pk::t(lang, PK::PackagePrivate))</span> |
| 804 | } | 785 | } |
| 805 | if !row.description.is_empty() { | 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 | } else { | 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 | </section> | 795 | </section> |
| 815 | } | 796 | } |
| 816 | if snippets_on { | 797 | if snippets_on { |
| 817 | - <section class="snippet-listing"> | 798 | + <section class="sec snippet-listing"> |
| 818 | - <div class="profile-section-head"> | 799 | + <h2>(cm::t(lang, CK::Snippets))</h2> |
| 819 | - <h2>(cm::t(lang, CK::Snippets))</h2> | 800 | + if own_profile { |
| 820 | - if own_profile { | 801 | + <div class="acts"> |
| 821 | - <a class="button primary" href="/snippets/new">(cm::t(lang, CK::NewSnippet))</a> | 802 | + <a class="act" href="/snippets/new">(cm::t(lang, CK::NewSnippet))</a> |
| 822 | - } | 803 | + </div> |
| 823 | - </div> | 804 | + } |
| 824 | if has_snippets { | 805 | if has_snippets { |
| 825 | snippet_rows(lang: lang, rows: snippets) | 806 | snippet_rows(lang: lang, rows: snippets) |
| 826 | } else { | 807 | } else { |
| 827 | - empty_state(title: cm::t(lang, CK::NoSnippets)) | 808 | + <p class="state">(cm::t(lang, CK::NoSnippets))</p> |
| 828 | } | 809 | } |
| 829 | </section> | 810 | </section> |
| 830 | } | 811 | } |
| 831 | if orgs_on { | 812 | if orgs_on { |
| 832 | - <section class="profile-orgs"> | 813 | + <section class="sec profile-orgs"> |
| 833 | - <div class="profile-section-head"> | 814 | + <h2>(g::t(lang, K::Organizations))</h2> |
| 834 | - <h2>(g::t(lang, K::Organizations))</h2> | 815 | + if org_create_allowed { |
| 835 | - if org_create_allowed { | 816 | + <div class="acts"> |
| 836 | - <a class="button primary" href="/org/new">(g::t(lang, K::NewOrganization))</a> | 817 | + <a class="act" href="/org/new">(g::t(lang, K::NewOrganization))</a> |
| 837 | - } | 818 | + </div> |
| 838 | - </div> | 819 | + } |
| 839 | if has_orgs { | 820 | if has_orgs { |
| 840 | - <ul class="item-list org-rows"> | 821 | + <div class="plain-rows"> |
| 841 | for org in orgs.into_iter() { | 822 | for org in orgs.into_iter() { |
| 842 | - <li> | 823 | + <div class="line" data-kb-row=""> |
| 843 | <img class="avatar avatar-sm" src=(org.avatar.as_str()) alt="" width="24" height="24"> | 824 | <img class="avatar avatar-sm" src=(org.avatar.as_str()) alt="" width="24" height="24"> |
| 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 | if !org.display_name.is_empty() { | 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 | <span class="badge">(org.role)</span> | 829 | <span class="badge">(org.role)</span> |
| 849 | - </li> | 830 | + </div> |
| 850 | } | 831 | } |
| 851 | - </ul> | 832 | + </div> |
| 852 | } else { | 833 | } else { |
| 853 | - empty_state(title: g::t(lang, K::NoOrganizations)) | 834 | + <p class="state">(g::t(lang, K::NoOrganizations))</p> |
| 854 | } | 835 | } |
| 855 | </section> | 836 | </section> |
| 856 | } | 837 | } |
| @@ -868,7 +849,7 @@ pub async fn profile_tabs( |
| 868 | current: String, | 849 | current: String, |
| 869 | counts: Vec<(&'static str, String)>, | 850 | counts: Vec<(&'static str, String)>, |
| 870 | ) -> Result<impl View> { | 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 | .into_iter() | 853 | .into_iter() |
| 873 | .map(|item| { | 854 | .map(|item| { |
| 874 | let on = item.key == current; | 855 | let on = item.key == current; |
| @@ -880,21 +861,30 @@ pub async fn profile_tabs( |
| 880 | ( | 861 | ( |
| 881 | item.href, | 862 | item.href, |
| 882 | item.label.to_owned(), | 863 | item.label.to_owned(), |
| 883 | - tab_class(on), | 864 | + on, |
| 884 | count.unwrap_or_default(), | 865 | count.unwrap_or_default(), |
| 885 | has_count, | 866 | has_count, |
| 886 | ) | 867 | ) |
| 887 | }) | 868 | }) |
| 888 | .collect(); | 869 | .collect(); |
| 889 | Ok(view! { | 870 | Ok(view! { |
| 890 | - <nav class="profile-tabs" aria-label=(username.as_str())> | 871 | + <nav class="tabs" aria-label=(username.as_str())> |
| 891 | - for (href, label, class, count, has_count) in rows.into_iter() { | 872 | + for (href, label, on, count, has_count) in rows.into_iter() { |
| 892 | - <a class=(class) href=(href.as_str())> | 873 | + if on { |
| 893 | - (label.as_str()) | 874 | + <a href=(href.as_str()) aria-current="page"> |
| 894 | - if has_count { | 875 | + (label.as_str()) |
| 895 | - " " <span class="tab-count">(count.as_str())</span> | 876 | + if has_count { |
| 896 | - } | 877 | + " " <span class="tab-count">(count.as_str())</span> |
| 897 | - </a> | 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 | </nav> | 889 | </nav> |
| 900 | }) | 890 | }) |
| @@ -1018,7 +1008,10 @@ mod tests { |
| 1018 | !anon.contains("tahinli/shared-repo"), | 1008 | !anon.contains("tahinli/shared-repo"), |
| 1019 | "anonymous: shared repo" | 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 | // Another user sees the same public-only list and no edit button. | 1016 | // Another user sees the same public-only list and no edit button. |
| 1024 | let bob = site | 1017 | let bob = site |
| @@ -1040,7 +1033,10 @@ mod tests { |
| 1040 | !other.contains("tahinli/shared-repo"), | 1033 | !other.contains("tahinli/shared-repo"), |
| 1041 | "other user: shared repo" | 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 | // The owner sees every repo and the edit button. | 1041 | // The owner sees every repo and the edit button. |
| 1046 | let tahinli = user_id(&site.store, "tahinli").await; | 1042 | let tahinli = user_id(&site.store, "tahinli").await; |
| @@ -1049,7 +1045,7 @@ mod tests { |
| 1049 | assert!(owner.contains("tahinli/secret-repo"), "owner: private repo"); | 1045 | assert!(owner.contains("tahinli/secret-repo"), "owner: private repo"); |
| 1050 | assert!(owner.contains("tahinli/shared-repo"), "owner: shared repo"); | 1046 | assert!(owner.contains("tahinli/shared-repo"), "owner: shared repo"); |
| 1051 | assert!( | 1047 | assert!( |
| 1052 | - owner.contains("class=\"button profile-edit\" href=\"/settings/profile\""), | 1048 | + owner.contains("class=\"act\" href=\"/settings/profile\""), |
| 1053 | "owner: edit button" | 1049 | "owner: edit button" |
| 1054 | ); | 1050 | ); |
| 1055 | | 1051 | |
| @@ -1174,7 +1170,7 @@ mod tests { |
| 1174 | ); | 1170 | ); |
| 1175 | let (_, member_profile) = get(&site.router, "/forge-org", Some(&member_cookie)).await; | 1171 | let (_, member_profile) = get(&site.router, "/forge-org", Some(&member_cookie)).await; |
| 1176 | assert!( | 1172 | assert!( |
| 1177 | - !member_profile.contains("profile-edit"), | 1173 | + !member_profile.contains("href=\"/org/forge-org/settings\""), |
| 1178 | "org profile: member has no edit button" | 1174 | "org profile: member has no edit button" |
| 1179 | ); | 1175 | ); |
| 1180 | // Settings keeps a sidebar of its own pages, and its back link goes to the profile. | 1176 | // Settings keeps a sidebar of its own pages, and its back link goes to the profile. |
| @@ -1184,12 +1180,12 @@ mod tests { |
| 1184 | "org settings: pins live on the profile" | 1180 | "org settings: pins live on the profile" |
| 1185 | ); | 1181 | ); |
| 1186 | assert!( | 1182 | assert!( |
| 1187 | - !settings.contains("href=\"/org/forge-org/members\""), | 1183 | + !settings.contains("class=\"side-links\""), |
| 1188 | - "org settings: sidebar has no members link" | 1184 | + "org settings: no sidebar, so no members link beside the form" |
| 1189 | ); | 1185 | ); |
| 1190 | assert!( | 1186 | assert!( |
| 1191 | - settings.contains("class=\"side-link\" href=\"/forge-org\""), | 1187 | + settings.contains("href=\"/forge-org?tab=overview\""), |
| 1192 | - "org settings: back link goes to the profile" | 1188 | + "org settings: Overview tab goes to the profile" |
| 1193 | ); | 1189 | ); |
| 1194 | | 1190 | |
| 1195 | // Org pins show on the org profile, with an edit link for owners only. | 1191 | // Org pins show on the org profile, with an edit link for owners only. |
| @@ -1216,7 +1212,7 @@ mod tests { |
| 1216 | "org pins: anonymous has no edit link" | 1212 | "org pins: anonymous has no edit link" |
| 1217 | ); | 1213 | ); |
| 1218 | assert!( | 1214 | assert!( |
| 1219 | - owner.contains("class=\"button profile-edit\" href=\"/org/acme/settings\"") | 1215 | + owner.contains("class=\"act\" href=\"/org/acme/settings\"") |
| 1220 | && owner.contains("/new?owner=acme"), | 1216 | && owner.contains("/new?owner=acme"), |
| 1221 | "org profile: owner sees Edit organization and New repository" | 1217 | "org profile: owner sees Edit organization and New repository" |
| 1222 | ); | 1218 | ); |
| @@ -1245,7 +1241,7 @@ mod tests { |
| 1245 | let (_, anon) = get(&site.router, "/tahinli", None).await; | 1241 | let (_, anon) = get(&site.router, "/tahinli", None).await; |
| 1246 | assert!(anon.contains("<h2>Pinned</h2>"), "pins: section shown"); | 1242 | assert!(anon.contains("<h2>Pinned</h2>"), "pins: section shown"); |
| 1247 | assert_eq!( | 1243 | assert_eq!( |
| 1248 | - count(&anon, "class=\"pin-card\""), | 1244 | + count(&anon, "class=\"line repo-item\""), |
| 1249 | 1, | 1245 | 1, |
| 1250 | "pins: anonymous pin count" | 1246 | "pins: anonymous pin count" |
| 1251 | ); | 1247 | ); |
| @@ -1262,7 +1258,7 @@ mod tests { |
| 1262 | let cookie = sign_in(&site.store, &tahinli, "pins-owner-token").await; | 1258 | let cookie = sign_in(&site.store, &tahinli, "pins-owner-token").await; |
| 1263 | let (_, owner) = get(&site.router, "/tahinli", Some(&cookie)).await; | 1259 | let (_, owner) = get(&site.router, "/tahinli", Some(&cookie)).await; |
| 1264 | assert_eq!( | 1260 | assert_eq!( |
| 1265 | - count(&owner, "class=\"pin-card\""), | 1261 | + count(&owner, "class=\"line repo-item\""), |
| 1266 | 2, | 1262 | 2, |
| 1267 | "pins: owner pin count" | 1263 | "pins: owner pin count" |
| 1268 | ); | 1264 | ); |
| @@ -1300,22 +1296,22 @@ mod tests { |
| 1300 | let (status, body) = get(&site.router, "/tahinli", None).await; | 1296 | let (status, body) = get(&site.router, "/tahinli", None).await; |
| 1301 | assert_eq!(status, 200, "display name: page"); | 1297 | assert_eq!(status, 200, "display name: page"); |
| 1302 | assert!( | 1298 | assert!( |
| 1303 | - body.contains("<h1>Ahmet Kaan Gümüş</h1>"), | 1299 | + body.contains("<h1 class=\"h1\">Ahmet Kaan Gümüş</h1>"), |
| 1304 | "display name: heading {body}" | 1300 | "display name: heading {body}" |
| 1305 | ); | 1301 | ); |
| 1306 | assert!( | 1302 | assert!( |
| 1307 | - body.contains("<p class=\"muted\">tahinli</p>"), | 1303 | + body.contains("<p class=\"hint\">tahinli</p>"), |
| 1308 | "display name: username below {body}" | 1304 | "display name: username below {body}" |
| 1309 | ); | 1305 | ); |
| 1310 | | 1306 | |
| 1311 | site.store.set_display_name(&tahinli, " ").await.unwrap(); | 1307 | site.store.set_display_name(&tahinli, " ").await.unwrap(); |
| 1312 | let (_, body) = get(&site.router, "/tahinli", None).await; | 1308 | let (_, body) = get(&site.router, "/tahinli", None).await; |
| 1313 | assert!( | 1309 | assert!( |
| 1314 | - body.contains("<h1>tahinli</h1>"), | 1310 | + body.contains("<h1 class=\"h1\">tahinli</h1>"), |
| 1315 | "blank name: heading {body}" | 1311 | "blank name: heading {body}" |
| 1316 | ); | 1312 | ); |
| 1317 | assert!( | 1313 | assert!( |
| 1318 | - !body.contains("<p class=\"muted\">tahinli</p>"), | 1314 | + !body.contains("<p class=\"hint\">tahinli</p>"), |
| 1319 | "blank name: no username line {body}" | 1315 | "blank name: no username line {body}" |
| 1320 | ); | 1316 | ); |
| 1321 | } | 1317 | } |
| @@ -1384,7 +1380,7 @@ mod tests { |
| 1384 | let (status, first) = get(&site.router, "/tahinli?tab=repositories&sort=name", None).await; | 1380 | let (status, first) = get(&site.router, "/tahinli?tab=repositories&sort=name", None).await; |
| 1385 | assert_eq!(status, 200, "paging: first page"); | 1381 | assert_eq!(status, 200, "paging: first page"); |
| 1386 | assert_eq!( | 1382 | assert_eq!( |
| 1387 | - count(&first, "class=\"repo-name\""), | 1383 | + count(&first, "class=\"name repo-name\""), |
| 1388 | 30, | 1384 | 30, |
| 1389 | "paging: first page size" | 1385 | "paging: first page size" |
| 1390 | ); | 1386 | ); |
| @@ -1397,7 +1393,7 @@ mod tests { |
| 1397 | ) | 1393 | ) |
| 1398 | .await; | 1394 | .await; |
| 1399 | assert_eq!( | 1395 | assert_eq!( |
| 1400 | - count(&second, "class=\"repo-name\""), | 1396 | + count(&second, "class=\"name repo-name\""), |
| 1401 | 5, | 1397 | 5, |
| 1402 | "paging: second page size" | 1398 | "paging: second page size" |
| 1403 | ); | 1399 | ); |
| @@ -1413,7 +1409,7 @@ mod tests { |
| 1413 | // The name filter is a case-insensitive substring match. | 1409 | // The name filter is a case-insensitive substring match. |
| 1414 | let (_, body) = get(&site.router, "/tahinli?tab=repositories&q=BULK-1", None).await; | 1410 | let (_, body) = get(&site.router, "/tahinli?tab=repositories&q=BULK-1", None).await; |
| 1415 | assert_eq!( | 1411 | assert_eq!( |
| 1416 | - count(&body, "class=\"repo-name\""), | 1412 | + count(&body, "class=\"name repo-name\""), |
| 1417 | 10, | 1413 | 10, |
| 1418 | "filter: match count" | 1414 | "filter: match count" |
| 1419 | ); | 1415 | ); |
| @@ -67,14 +67,14 @@ pub(crate) async fn pins_menu( |
| 67 | ) -> Result<impl View> { | 67 | ) -> Result<impl View> { |
| 68 | Ok(view! { | 68 | Ok(view! { |
| 69 | <details class="pop pins-menu"> | 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 | <form method="post" action=(action.as_str()) class="pop-panel"> | 71 | <form method="post" action=(action.as_str()) class="pop-panel"> |
| 72 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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 | <ul class="pin-options"> | 74 | <ul class="pin-options"> |
| 75 | for option in options.into_iter() { | 75 | for option in options.into_iter() { |
| 76 | <li> | 76 | <li> |
| 77 | - <label> | 77 | + <label class="switch"> |
| 78 | <input type="checkbox" name="repo" value=(option.repo.id.as_str()) checked=(option.checked)> | 78 | <input type="checkbox" name="repo" value=(option.repo.id.as_str()) checked=(option.checked)> |
| 79 | <span>(option.repo.name.as_str())</span> | 79 | <span>(option.repo.name.as_str())</span> |
| 80 | </label> | 80 | </label> |
| @@ -33,6 +33,7 @@ use crate::pages::issue_parts::parse_number; |
| 33 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; | 33 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 34 | use crate::post_update::after_ref_update; | 34 | use crate::post_update::after_ref_update; |
| 35 | use crate::state::AppState; | 35 | use crate::state::AppState; |
| | 36 | +use crate::views::parts::{confirm_act, post_act}; |
| 36 | use crate::views::repo_href; | 37 | use crate::views::repo_href; |
| 37 | | 38 | |
| 38 | path_param!(owner); | 39 | path_param!(owner); |
| @@ -377,24 +378,25 @@ pub(crate) async fn branch_box( |
| 377 | action: Option<BranchAction>, | 378 | action: Option<BranchAction>, |
| 378 | error: Option<String>, | 379 | error: Option<String>, |
| 379 | ) -> Result<impl View> { | 380 | ) -> Result<impl View> { |
| | 381 | + let heading = crate::pages::passkeys::s(lang, "Branch", "Dal"); |
| 380 | Ok(view! { | 382 | Ok(view! { |
| 381 | - <section class="merge-box merge-muted"> | 383 | + <section class="sec merge-box merge-muted"> |
| | 384 | + <h2>(heading)</h2> |
| 382 | if let Some(text) = error { | 385 | if let Some(text) = error { |
| 383 | <p class="alert merge-error" role="alert">(text.as_str())</p> | 386 | <p class="alert merge-error" role="alert">(text.as_str())</p> |
| 384 | } | 387 | } |
| 385 | if let Some(a) = action { | 388 | if let Some(a) = action { |
| 386 | if a.restore { | 389 | if a.restore { |
| 387 | - <form method="post" action=(a.action.as_str()) class="stack"> | 390 | + <p class="state merge-headline">(g::t(lang, K::BranchPrefix)) <code>(a.branch.as_str())</code> (g::t(lang, K::BranchWasDeleted))</p> |
| 388 | - <input type="hidden" name="csrf" value=(a.csrf.as_str())> | 391 | + <div class="acts"> |
| 389 | - <p class="merge-headline">(g::t(lang, K::BranchPrefix)) <code>(a.branch.as_str())</code> (g::t(lang, K::BranchWasDeleted))</p> | 392 | + post_act(label: g::t(lang, K::RestoreBranch), action: a.action.as_str(), csrf: a.csrf.as_str()) |
| 390 | - <div><button type="submit">(g::t(lang, K::RestoreBranch))</button></div> | 393 | + </div> |
| 391 | - </form> | | |
| 392 | } else { | 394 | } else { |
| 393 | - <form method="post" action=(a.action.as_str()) class="stack"> | 395 | + <p class="state merge-headline">(g::t(lang, K::BranchPrefix)) <code>(a.branch.as_str())</code> (g::t(lang, K::BranchStillHere))</p> |
| 394 | - <input type="hidden" name="csrf" value=(a.csrf.as_str())> | 396 | + <div class="acts"> |
| 395 | - <p class="merge-headline">(g::t(lang, K::BranchPrefix)) <code>(a.branch.as_str())</code> (g::t(lang, K::BranchStillHere))</p> | 397 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteBranch), action: a.action.as_str(), csrf: a.csrf.as_str(), |
| 396 | - <div><button type="submit">(g::t(lang, K::DeleteBranch))</button></div> | 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())) |
| 397 | - </form> | 399 | + </div> |
| 398 | } | 400 | } |
| 399 | } | 401 | } |
| 400 | </section> | 402 | </section> |
| @@ -37,6 +37,7 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 37 | use crate::pages::tree::link_context; | 37 | use crate::pages::tree::link_context; |
| 38 | use crate::state::AppState; | 38 | use crate::state::AppState; |
| 39 | use crate::views::diff::{DiffLang, DiffOpts, LIMITS, LineComments, diff_section}; | 39 | use crate::views::diff::{DiffLang, DiffOpts, LIMITS, LineComments, diff_section}; |
| | 40 | +use crate::views::parts::confirm_act; |
| 40 | use crate::views::review_thread::ThreadCtx; | 41 | use crate::views::review_thread::ThreadCtx; |
| 41 | use crate::views::{alert, now_unix, repo_href, shell}; | 42 | use crate::views::{alert, now_unix, repo_href, shell}; |
| 42 | | 43 | |
| @@ -224,9 +225,9 @@ async fn files_pane( |
| 224 | FileItem { | 225 | FileItem { |
| 225 | href: row.index.map(|i| format!("?file={i}#file-{}", i + 1)), | 226 | href: row.index.map(|i| format!("?file={i}#file-{}", i + 1)), |
| 226 | class: if current { | 227 | class: if current { |
| 227 | - "pull-file current" | 228 | + "line pull-file current" |
| 228 | } else { | 229 | } else { |
| 229 | - "pull-file" | 230 | + "line pull-file" |
| 230 | }, | 231 | }, |
| 231 | additions: format!("+{}", row.additions), | 232 | additions: format!("+{}", row.additions), |
| 232 | deletions: format!("\u{2212}{}", row.deletions), | 233 | deletions: format!("\u{2212}{}", row.deletions), |
| @@ -242,42 +243,33 @@ async fn files_pane( |
| 242 | let hint = g::t(lang, K::ViewedHint); | 243 | let hint = g::t(lang, K::ViewedHint); |
| 243 | let viewed_files = g::t(lang, K::ViewedFiles); | 244 | let viewed_files = g::t(lang, K::ViewedFiles); |
| 244 | Ok(view! { | 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 | + <section class="sec 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 | + <h2>(heading)</h2> |
| 247 | - <span class="label">(heading)</span> | 248 | + if signed_in { |
| 248 | - if signed_in { | 249 | + <p class="hint" title=(hint)>(count.as_str())</p> |
| 249 | - <span class="pull-count" title=(hint)>(count.as_str())</span> | 250 | + } |
| 250 | - } | 251 | + <div> |
| 251 | - </div> | | |
| 252 | - <ul class="pull-file-list"> | | |
| 253 | for item in items.into_iter() { | 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 | if let Some(href) = item.href { | 254 | if let Some(href) = item.href { |
| 256 | - <a class="pull-file-link" href=(href.as_str())> | 255 | + <a class="name pull-file-link" href=(href.as_str())><span class="mono clip">(item.path.as_str())</span></a> |
| 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> | | |
| 261 | } else { | 256 | } else { |
| 262 | - <span class="pull-file-link"> | 257 | + <span class="name pull-file-link"><span class="mono clip">(item.path.as_str())</span></span> |
| 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> | 258 | + } |
| 264 | - <span class="mono clip">(item.path.as_str())</span> | 259 | + <span class="val pull-counts"><span class="ok">(item.additions.as_str())</span> <span class="bad">(item.deletions.as_str())</span></span> |
| 265 | - <span class="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 { |
| 266 | - </span> | 261 | + <span class="viewed-note">(changed)</span> |
| 267 | } | 262 | } |
| 268 | if signed_in && !archived { | 263 | if signed_in && !archived { |
| 269 | if item.state == MarkState::Viewed { | 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 | } else { | 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 { | 270 | + </div> |
| 276 | - <span class="viewed-note">(changed)</span> | | |
| 277 | - } | | |
| 278 | - </li> | | |
| 279 | } | 271 | } |
| 280 | - </ul> | 272 | + </div> |
| 281 | </section> | 273 | </section> |
| 282 | }) | 274 | }) |
| 283 | } | 275 | } |
| @@ -294,15 +286,17 @@ struct CheckItem { |
| 294 | async fn checks_pane(lang: Lang, items: Vec<CheckItem>) -> Result<impl View> { | 286 | async fn checks_pane(lang: Lang, items: Vec<CheckItem>) -> Result<impl View> { |
| 295 | let heading = passkeys::s(lang, "Checks", "Kontroller"); | 287 | let heading = passkeys::s(lang, "Checks", "Kontroller"); |
| 296 | Ok(view! { | 288 | Ok(view! { |
| 297 | - <section class="pane pull-checks"> | 289 | + <section class="sec pull-checks"> |
| 298 | - <div class="pull-cap"><span class="label">(heading)</span></div> | 290 | + <h2>(heading)</h2> |
| 299 | - for item in items.into_iter() { | 291 | + <div> |
| 300 | - <div class="pull-check"> | 292 | + for item in items.into_iter() { |
| 301 | - <span class=(item.dot)></span> | 293 | + <div class="line"> |
| 302 | - <span class="clip">(item.context.as_str())</span> | 294 | + <span class=(item.dot)></span> |
| 303 | - <time class="pull-time">(item.when.as_str())</time> | 295 | + <span class="name clip">(item.context.as_str())</span> |
| 304 | - </div> | 296 | + <span class="val"><time class="pull-time">(item.when.as_str())</time></span> |
| 305 | - } | 297 | + </div> |
| | 298 | + } |
| | 299 | + </div> |
| 306 | </section> | 300 | </section> |
| 307 | }) | 301 | }) |
| 308 | } | 302 | } |
| @@ -321,13 +315,11 @@ async fn diff_top( |
| 321 | let split_pressed = if split_on { "true" } else { "false" }; | 315 | let split_pressed = if split_on { "true" } else { "false" }; |
| 322 | let ws_pressed = if ws_on { "true" } else { "false" }; | 316 | let ws_pressed = if ws_on { "true" } else { "false" }; |
| 323 | Ok(view! { | 317 | Ok(view! { |
| 324 | - <div class="pull-diff-top"> | 318 | + <nav class="sub pull-diff-top" aria-label=(b::t(lang, b::K::DiffView))> |
| 325 | - <div class="seg" role="group" 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> |
| 326 | - <a class="seg-item" 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> |
| 327 | - <a class="seg-item" 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> |
| 328 | - </div> | 322 | + </nav> |
| 329 | - <a class="seg-item toggle" href=(ws.as_str()) aria-pressed=(ws_pressed)>(b::t(lang, b::K::IgnoreWhitespace))</a> | | |
| 330 | - </div> | | |
| 331 | }) | 323 | }) |
| 332 | } | 324 | } |
| 333 | | 325 | |
| @@ -408,20 +400,20 @@ async fn review_bar( |
| 408 | let comment = g::t(lang, K::CommentChoice).trim(); | 400 | let comment = g::t(lang, K::CommentChoice).trim(); |
| 409 | let placeholder = passkeys::s(lang, "Leave a comment", "Yorum bırakın"); | 401 | let placeholder = passkeys::s(lang, "Leave a comment", "Yorum bırakın"); |
| 410 | Ok(view! { | 402 | Ok(view! { |
| 411 | - <section class="review-bar pull-compose"> | 403 | + <section class="sec pull-compose"> |
| 412 | - <div class="pull-more"> | 404 | + <h2>(finish)</h2> |
| 413 | - <h2>(finish)</h2> | 405 | + <p class="hint">(pending_text.as_str())</p> |
| 414 | - <p class="muted">(pending_text.as_str())</p> | 406 | + <form id="review-form" method="post" action=(reviews_action.as_str()) class="fields" aria-label=(submit)> |
| 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)> | | |
| 421 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 407 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 422 | - <input class="pull-input" type="text" name="body" aria-label=(summary) placeholder=(placeholder)> | 408 | + <div class="field"> |
| 423 | - <button type="submit" class="btn primary" name="state" value="comment">(comment)</button> | 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 | </form> | 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 | </section> | 417 | </section> |
| 426 | }) | 418 | }) |
| 427 | } | 419 | } |
| @@ -597,24 +589,18 @@ async fn pull_files(cx: &Cx) -> Result<impl View> { |
| 597 | if let Some(message) = error { | 589 | if let Some(message) = error { |
| 598 | alert(message: message.as_str()) | 590 | alert(message: message.as_str()) |
| 599 | } | 591 | } |
| 600 | - <div class="fit-pane pull-page" data-live=(live.as_str())> | 592 | + <div class="pull-page" data-live=(live.as_str())> |
| 601 | - <div class="pull-cols"> | 593 | + files_pane(lang: lang, rows: rows, selected: selected, controls: controls) |
| 602 | - <div class="pull-left"> | 594 | + checks_pane(lang: lang, items: checks) |
| 603 | - files_pane(lang: lang, rows: rows, selected: selected, controls: controls) | 595 | + diff_top(lang: lang, unified: unified_href, split: split_href, ws: ws_href, split_on: split_on, ws_on: ws_on) |
| 604 | - checks_pane(lang: lang, items: checks) | 596 | + <div class="pull-diff"> |
| 605 | - </div> | 597 | + diff_section(diff: &diff, owner: owner.as_str(), repo: name.as_str(), |
| 606 | - <section class="pane pull-diff"> | 598 | + oid: pr.head_oid.as_str(), parent: parent.as_deref(), |
| 607 | - diff_top(lang: lang, unified: unified_href, split: split_href, ws: ws_href, split_on: split_on, ws_on: ws_on) | 599 | + subject: g::t(lang, K::ThisPullRequest), lang: DiffLang(lang), comments: comments, opts: section_opts) |
| 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> | | |
| 617 | </div> | 600 | </div> |
| | 601 | + if can_review { |
| | 602 | + review_bar(lang: lang, pr_href: href.clone(), csrf: csrf.clone(), pending: pending) |
| | 603 | + } |
| 618 | </div> | 604 | </div> |
| 619 | ) | 605 | ) |
| 620 | }) | 606 | }) |
| @@ -637,7 +623,8 @@ mod tests { |
| 637 | /// The page's own `<main>` element. The shell's header echoes the request URL (theme | 623 | /// The page's own `<main>` element. The shell's header echoes the request URL (theme |
| 638 | /// form `back` field), so the body checks are scoped to `<main>`. | 624 | /// form `back` field), so the body checks are scoped to `<main>`. |
| 639 | fn page_main(body: &str) -> &str { | 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 | .and_then(|(_, rest)| rest.split_once("</main>")) | 628 | .and_then(|(_, rest)| rest.split_once("</main>")) |
| 642 | .map(|(main, _)| main) | 629 | .map(|(main, _)| main) |
| 643 | .expect("page has a <main> element") | 630 | .expect("page has a <main> element") |
| @@ -783,7 +770,7 @@ mod tests { |
| 783 | body.contains("?comment=0:new:1#L-0-new-1"), | 770 | body.contains("?comment=0:new:1#L-0-new-1"), |
| 784 | "plus link: {body}" | 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 | // A well-formed `comment` param opens the form under its line. | 775 | // A well-formed `comment` param opens the form under its line. |
| 789 | let (status, body) = get( | 776 | let (status, body) = get( |
| @@ -848,7 +835,7 @@ mod tests { |
| 848 | assert!(!page_main(&body).contains("?comment="), "anonymous: {body}"); | 835 | assert!(!page_main(&body).contains("?comment="), "anonymous: {body}"); |
| 849 | assert!(!body.contains("id=\"L-"), "anonymous: {body}"); | 836 | assert!(!body.contains("id=\"L-"), "anonymous: {body}"); |
| 850 | assert!(!body.contains("name=\"file_index\""), "anonymous: {body}"); | 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 | assert!(!body.contains("class=\"diff-plus\""), "anonymous: {body}"); | 839 | assert!(!body.contains("class=\"diff-plus\""), "anonymous: {body}"); |
| 853 | | 840 | |
| 854 | // A known review error shows its message, an unknown code shows nothing. | 841 | // A known review error shows its message, an unknown code shows nothing. |
| @@ -484,22 +484,22 @@ async fn edit_page( |
| 484 | Ok(view! { cx => | 484 | Ok(view! { cx => |
| 485 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), | 485 | shell(title: page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 486 | repo_head(head: header) | 486 | repo_head(head: header) |
| 487 | - <section class="card issue-edit"> | 487 | + <section class="sec"> |
| 488 | <h2>(heading)</h2> | 488 | <h2>(heading)</h2> |
| 489 | if let Some(message) = error { | 489 | if let Some(message) = error { |
| 490 | alert(message: message) | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 493 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 494 | - <label> | 494 | + <label class="field"> |
| 495 | <span>(comment_label)</span> | 495 | <span>(comment_label)</span> |
| 496 | <textarea name="body" rows="10">(comment.body.as_str())</textarea> | 496 | <textarea name="body" rows="10">(comment.body.as_str())</textarea> |
| 497 | </label> | 497 | </label> |
| 498 | - <div class="issue-actions"> | 498 | + <button type="submit" class="primary">(save_label)</button> |
| 499 | - <button type="submit">(save_label)</button> | | |
| 500 | - <a href=(back.as_str())>(cancel_label)</a> | | |
| 501 | - </div> | | |
| 502 | </form> | 499 | </form> |
| | 500 | + <div class="acts"> |
| | 501 | + <a class="act quiet" href=(back.as_str())>(cancel_label)</a> |
| | 502 | + </div> |
| 503 | </section> | 503 | </section> |
| 504 | ) | 504 | ) |
| 505 | }) | 505 | }) |
| @@ -46,6 +46,7 @@ use crate::pages::review_requests::{load_reviewers, reviewers_box}; |
| 46 | use crate::state::AppState; | 46 | use crate::state::AppState; |
| 47 | use crate::views::commit_status::{StatusLang, StatusSummary, checks_summary, commit_status}; | 47 | use crate::views::commit_status::{StatusLang, StatusSummary, checks_summary, commit_status}; |
| 48 | use crate::views::diff::LIMITS; | 48 | use crate::views::diff::LIMITS; |
| | 49 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 49 | use crate::views::{alert, now_unix, repo_href, shell, short_oid, user_link}; | 50 | use crate::views::{alert, now_unix, repo_href, shell, short_oid, user_link}; |
| 50 | | 51 | |
| 51 | path_param!(owner); | 52 | path_param!(owner); |
| @@ -230,18 +231,11 @@ pub(crate) async fn pull_header(frame: Frame) -> Result<impl View> { |
| 230 | ) | 231 | ) |
| 231 | }); | 232 | }); |
| 232 | Ok(view! { | 233 | Ok(view! { |
| 233 | - <section class="issue-head pull-head" data-live=(live_url.as_str())> | 234 | + <section class="pull-head" data-live=(live_url.as_str())> |
| 234 | - <div class="pull-line1"> | 235 | + <h1 class="h1">(title.as_str()) " " <span class="issue-number">(number_label.as_str())</span></h1> |
| 235 | - <h1 class="issue-heading">(title.as_str()) " " <span class="issue-number">(number_label.as_str())</span></h1> | 236 | + <p class="hint"> |
| 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"> | | |
| 244 | <span class=(state_class)>(state_text)</span> | 237 | <span class=(state_class)>(state_text)</span> |
| | 238 | + " " |
| 245 | <strong> | 239 | <strong> |
| 246 | if author_known { | 240 | if author_known { |
| 247 | user_link(shown: author.as_str(), login: author.as_str()) | 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 | (author.as_str()) | 243 | (author.as_str()) |
| 250 | } | 244 | } |
| 251 | </strong> | 245 | </strong> |
| | 246 | + " " |
| 252 | if turkish { | 247 | if turkish { |
| 253 | (wants) <code>(head_label.as_str())</code> | 248 | (wants) <code>(head_label.as_str())</code> |
| 254 | (from) <code>(base_branch.as_str())</code> | 249 | (from) <code>(base_branch.as_str())</code> |
| @@ -258,22 +253,26 @@ pub(crate) async fn pull_header(frame: Frame) -> Result<impl View> { |
| 258 | (into) <code>(base_branch.as_str())</code> | 253 | (into) <code>(base_branch.as_str())</code> |
| 259 | } | 254 | } |
| 260 | (byline_end) | 255 | (byline_end) |
| | 256 | + " " |
| 261 | <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> | 257 | <time data-rel="true" datetime=(opened.iso.as_str()) title=(opened.absolute.as_str())>(opened.relative.as_str())</time> |
| 262 | if let Some(text) = totals_text { | 258 | if let Some(text) = totals_text { |
| | 259 | + " " |
| 263 | <span class="pull-totals">(text.as_str())</span> | 260 | <span class="pull-totals">(text.as_str())</span> |
| 264 | } | 261 | } |
| 265 | </p> | 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 | </section> | 269 | </section> |
| 267 | }) | 270 | }) |
| 268 | } | 271 | } |
| 269 | | 272 | |
| 270 | -/// Class for one sub-navigation link: the one named by `active` is marked current. | 273 | +/// The current tab carries `aria-current`; the others carry nothing. |
| 271 | -fn tab_class(active: &str, tab: &str) -> &'static str { | 274 | +fn current_tab(active: &str, tab: &str) -> Option<&'static str> { |
| 272 | - if active == tab { | 275 | + (active == tab).then_some("page") |
| 273 | - "subnav-link current" | | |
| 274 | - } else { | | |
| 275 | - "subnav-link" | | |
| 276 | - } | | |
| 277 | } | 276 | } |
| 278 | | 277 | |
| 279 | /// The pull request's sub-tabs, with their labels in `lang`. | 278 | /// The pull request's sub-tabs, with their labels in `lang`. |
| @@ -292,10 +291,10 @@ pub(crate) async fn pull_subnav_in( |
| 292 | let conversation = g::t(lang, K::TabConversation); | 291 | let conversation = g::t(lang, K::TabConversation); |
| 293 | let aria = g::t(lang, K::PullPages); | 292 | let aria = g::t(lang, K::PullPages); |
| 294 | Ok(view! { | 293 | Ok(view! { |
| 295 | - <nav class="subnav" aria-label=(aria)> | 294 | + <nav class="tabs" aria-label=(aria)> |
| 296 | - <a class=(tab_class(&active, "conversation")) href=(href.as_str())>(conversation)</a> | 295 | + <a aria-current=(current_tab(&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> | 296 | + <a aria-current=(current_tab(&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> | 297 | + <a aria-current=(current_tab(&active, "files")) href=(files_href.as_str())>(files_label.as_str())</a> |
| 299 | </nav> | 298 | </nav> |
| 300 | }) | 299 | }) |
| 301 | } | 300 | } |
| @@ -350,7 +349,8 @@ async fn merge_box( |
| 350 | flow: FlowView, | 349 | flow: FlowView, |
| 351 | lang: Lang, | 350 | lang: Lang, |
| 352 | ) -> Result<impl View> { | 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 | let required_heading = g::t(lang, K::RequiredChecksHeading); | 354 | let required_heading = g::t(lang, K::RequiredChecksHeading); |
| 355 | let style_rebase = g::t(lang, K::StyleRebase); | 355 | let style_rebase = g::t(lang, K::StyleRebase); |
| 356 | let style_merge_option = g::t(lang, K::StyleMergeCommit); | 356 | let style_merge_option = g::t(lang, K::StyleMergeCommit); |
| @@ -380,16 +380,17 @@ async fn merge_box( |
| 380 | let merge_button = g::t(lang, K::MergeButton); | 380 | let merge_button = g::t(lang, K::MergeButton); |
| 381 | Ok(view! { | 381 | Ok(view! { |
| 382 | <section class=(class.as_str())> | 382 | <section class=(class.as_str())> |
| | 383 | + <h2>(heading)</h2> |
| 383 | if let Some(text) = merge_error { | 384 | if let Some(text) = merge_error { |
| 384 | <p class="alert merge-error" role="alert">(text.as_str())</p> | 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 | if let Some(summary) = checks { | 388 | if let Some(summary) = checks { |
| 388 | checks_summary(summary: summary, lang: StatusLang(lang)) | 389 | checks_summary(summary: summary, lang: StatusLang(lang)) |
| 389 | } | 390 | } |
| 390 | if !required.is_empty() { | 391 | if !required.is_empty() { |
| 391 | <div class="required-checks"> | 392 | <div class="required-checks"> |
| 392 | - <p class="muted small">(required_heading)</p> | 393 | + <p class="hint">(required_heading)</p> |
| 393 | <ul class="required-check-list"> | 394 | <ul class="required-check-list"> |
| 394 | for row in required.iter() { | 395 | for row in required.iter() { |
| 395 | <li class=(row.class)><code>(row.context.as_str())</code><span>(row.label)</span></li> | 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 | </div> | 399 | </div> |
| 399 | } | 400 | } |
| 400 | if let Some(text) = approvals { | 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 | if let Some(text) = blocked { | 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 | if !conflicts.is_empty() { | 407 | if !conflicts.is_empty() { |
| 407 | <ul class="merge-files"> | 408 | <ul class="merge-files"> |
| @@ -411,71 +412,76 @@ async fn merge_box( |
| 411 | </ul> | 412 | </ul> |
| 412 | } | 413 | } |
| 413 | if let Some(href) = reload { | 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 | if let Some(f) = form { | 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 | <input type="hidden" name="csrf" value=(f.csrf.as_str())> | 421 | <input type="hidden" name="csrf" value=(f.csrf.as_str())> |
| 419 | <input type="hidden" name="head" value=(f.head.as_str())> | 422 | <input type="hidden" name="head" value=(f.head.as_str())> |
| 420 | <fieldset class="merge-styles"> | 423 | <fieldset class="merge-styles"> |
| 421 | <legend>(style_legend)</legend> | 424 | <legend>(style_legend)</legend> |
| 422 | - <label><input type="radio" name="style" value="merge" checked=(true)>(style_merge)</label> | 425 | + <label class="switch"><input type="radio" name="style" value="merge" checked=(true)><span>(style_merge)</span></label> |
| 423 | - <label><input type="radio" name="style" value="squash">(style_squash)</label> | 426 | + <label class="switch"><input type="radio" name="style" value="squash"><span>(style_squash)</span></label> |
| 424 | - <label><input type="radio" name="style" value="rebase">(style_rebase)</label> | 427 | + <label class="switch"><input type="radio" name="style" value="rebase"><span>(style_rebase)</span></label> |
| 425 | if f.ff { | 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 | </fieldset> | 431 | </fieldset> |
| 429 | - <label> | 432 | + <div class="field"> |
| 430 | - <span>(message_label)</span> | 433 | + <label for="merge-message">(message_label)</label> |
| 431 | - <textarea name="message" rows="3"></textarea> | 434 | + <textarea id="merge-message" name="message" rows="3"></textarea> |
| 432 | - </label> | 435 | + </div> |
| 433 | - <div><button type="submit" class="primary">(merge_button)</button></div> | 436 | + <button type="submit" class="primary">(merge_button)</button> |
| 434 | </form> | 437 | </form> |
| 435 | } | 438 | } |
| 436 | if let Some((text, action)) = queue_position { | 439 | if let Some((text, action)) = queue_position { |
| 437 | - <form method="post" action=(action.as_str()) class="merge-flow"> | 440 | + <p class="state">(text.as_str())</p> |
| 438 | - <input type="hidden" name="csrf" value=(flow_csrf.as_str())> | 441 | + <div class="acts"> |
| 439 | - <p class="merge-headline">(text.as_str())</p> | 442 | + confirm_act(lang: lang, label: queue_remove_label, action: action.as_str(), csrf: flow_csrf.as_str()) |
| 440 | - <button type="submit">(queue_remove_label)</button> | 443 | + </div> |
| 441 | - </form> | | |
| 442 | } | 444 | } |
| 443 | if let Some(action) = queue_add { | 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 | <input type="hidden" name="csrf" value=(flow_csrf.as_str())> | 447 | <input type="hidden" name="csrf" value=(flow_csrf.as_str())> |
| 446 | - <p class="muted small">(queue_hint)</p> | 448 | + <p class="hint">(queue_hint)</p> |
| 447 | - <select name="style" aria-label=(queue_add_label)> | 449 | + <div class="field"> |
| 448 | - <option value="merge">(style_merge_option.trim())</option> | 450 | + <label for="queue-style">(queue_add_label)</label> |
| 449 | - <option value="squash">(style_squash_option.trim())</option> | 451 | + <select id="queue-style" name="style"> |
| 450 | - <option value="rebase">(style_rebase.trim())</option> | 452 | + <option value="merge">(style_merge_option.trim())</option> |
| 451 | - </select> | 453 | + <option value="squash">(style_squash_option.trim())</option> |
| | 454 | + <option value="rebase">(style_rebase.trim())</option> |
| | 455 | + </select> |
| | 456 | + </div> |
| 452 | <button type="submit" class="primary">(queue_add_label)</button> | 457 | <button type="submit" class="primary">(queue_add_label)</button> |
| 453 | </form> | 458 | </form> |
| 454 | } | 459 | } |
| 455 | if let Some((text, action)) = auto_on { | 460 | if let Some((text, action)) = auto_on { |
| 456 | - <form method="post" action=(action.as_str()) class="merge-flow"> | 461 | + <p class="state">(text.as_str())</p> |
| 457 | - <input type="hidden" name="csrf" value=(flow_csrf.as_str())> | 462 | + <div class="acts"> |
| 458 | - <p class="muted small">(text.as_str())</p> | 463 | + post_act(label: disable_auto, action: action.as_str(), csrf: flow_csrf.as_str()) |
| 459 | - <button type="submit">(disable_auto)</button> | 464 | + </div> |
| 460 | - </form> | | |
| 461 | } | 465 | } |
| 462 | if let Some(action) = auto_enable { | 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 | <input type="hidden" name="csrf" value=(flow_csrf.as_str())> | 468 | <input type="hidden" name="csrf" value=(flow_csrf.as_str())> |
| 465 | - <p class="muted small">(auto_hint)</p> | 469 | + <p class="hint">(auto_hint)</p> |
| 466 | - <select name="style" aria-label=(enable_auto)> | 470 | + <div class="field"> |
| 467 | - <option value="merge">(style_merge_option.trim())</option> | 471 | + <label for="auto-style">(enable_auto)</label> |
| 468 | - <option value="squash">(style_squash_option.trim())</option> | 472 | + <select id="auto-style" name="style"> |
| 469 | - <option value="rebase">(style_rebase.trim())</option> | 473 | + <option value="merge">(style_merge_option.trim())</option> |
| 470 | - </select> | 474 | + <option value="squash">(style_squash_option.trim())</option> |
| 471 | - <button type="submit">(enable_auto)</button> | 475 | + <option value="rebase">(style_rebase.trim())</option> |
| | 476 | + </select> |
| | 477 | + </div> |
| | 478 | + <button type="submit" class="primary">(enable_auto)</button> |
| 472 | </form> | 479 | </form> |
| 473 | } | 480 | } |
| 474 | if let Some((action, label)) = draft_toggle { | 481 | if let Some((action, label)) = draft_toggle { |
| 475 | - <form method="post" action=(action.as_str()) class="merge-flow"> | 482 | + <div class="acts"> |
| 476 | - <input type="hidden" name="csrf" value=(flow_csrf.as_str())> | 483 | + post_act(label: label, action: action.as_str(), csrf: flow_csrf.as_str()) |
| 477 | - <button type="submit">(label)</button> | 484 | + </div> |
| 478 | - </form> | | |
| 479 | } | 485 | } |
| 480 | </section> | 486 | </section> |
| 481 | }) | 487 | }) |
| @@ -494,9 +500,11 @@ async fn merged_notice( |
| 494 | let prefix = g::t(lang, K::MergedByPrefix); | 500 | let prefix = g::t(lang, K::MergedByPrefix); |
| 495 | let middle = g::t(lang, K::MergedByMiddle); | 501 | let middle = g::t(lang, K::MergedByMiddle); |
| 496 | let as_sep = g::t(lang, K::MergedAsSep); | 502 | let as_sep = g::t(lang, K::MergedAsSep); |
| | 503 | + let heading = g::t(lang, K::StateMerged); |
| 497 | Ok(view! { | 504 | Ok(view! { |
| 498 | - <section class="merge-box merge-merged"> | 505 | + <section class="sec merge-box merge-merged"> |
| 499 | - <p class="merge-headline"> | 506 | + <h2>(heading)</h2> |
| | 507 | + <p class="state merge-headline"> |
| 500 | (prefix) <strong>user_link(shown: who.as_str(), login: who.as_str())</strong> (middle) | 508 | (prefix) <strong>user_link(shown: who.as_str(), login: who.as_str())</strong> (middle) |
| 501 | <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> | 509 | <time data-rel="true" datetime=(when.iso.as_str()) title=(when.absolute.as_str())>(when.relative.as_str())</time> |
| 502 | if !commit.is_empty() { | 510 | if !commit.is_empty() { |
| @@ -532,26 +540,30 @@ async fn review_box( |
| 532 | lang: Lang, | 540 | lang: Lang, |
| 533 | ) -> Result<impl View> { | 541 | ) -> Result<impl View> { |
| 534 | let dismiss_text = g::t(lang, K::DismissButton); | 542 | let dismiss_text = g::t(lang, K::DismissButton); |
| | 543 | + let heading = crate::pages::passkeys::s(lang, "Reviews", "İncelemeler"); |
| 535 | Ok(view! { | 544 | Ok(view! { |
| 536 | - <section class="review-box"> | 545 | + <section class="sec review-box"> |
| | 546 | + <h2>(heading)</h2> |
| 537 | if let Some(text) = approved { | 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 | if let Some(text) = approved_before { | 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 | if let Some(text) = changes { | 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 | for row in dismiss.iter() { | 556 | for row in dismiss.iter() { |
| 547 | - <form method="post" action=(row.action.as_str()) class="review-dismiss"> | 557 | + reveal(label: dismiss_text, |
| 548 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 558 | + <form method="post" action=(row.action.as_str()) class="fields review-dismiss"> |
| 549 | - <label> | 559 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 550 | - <span>(row.label.as_str())</span> | 560 | + <label class="field"> |
| 551 | - <input type="text" name="reason" required=(true)> | 561 | + <span>(row.label.as_str())</span> |
| 552 | - </label> | 562 | + <input type="text" name="reason" required=(true)> |
| 553 | - <button type="submit" class="link-button">(dismiss_text)</button> | 563 | + </label> |
| 554 | - </form> | 564 | + <button type="submit" class="primary">(dismiss_text)</button> |
| | 565 | + </form> |
| | 566 | + ) |
| 555 | } | 567 | } |
| 556 | </section> | 568 | </section> |
| 557 | }) | 569 | }) |
| @@ -599,27 +611,24 @@ async fn commit_list(rows: Vec<CommitRow>, lang: Lang) -> Result<impl View> { |
| 599 | let browse = g::t(lang, K::BrowseFiles); | 611 | let browse = g::t(lang, K::BrowseFiles); |
| 600 | Ok(view! { | 612 | Ok(view! { |
| 601 | if empty { | 613 | if empty { |
| 602 | - <p class="muted">(no_commits)</p> | 614 | + <p class="state">(no_commits)</p> |
| 603 | } else { | 615 | } else { |
| 604 | - <ul class="commit-list"> | 616 | + <div> |
| 605 | for row in rows.iter() { | 617 | for row in rows.iter() { |
| 606 | - <li class="commit-row"> | 618 | + <div class="line" data-kb-row=""> |
| 607 | - <div class="commit-main"> | 619 | + <span class="name"><a href=(row.commit_href.as_str())>(row.summary.as_str())</a></span> |
| 608 | - <a class="commit-summary" href=(row.commit_href.as_str())>(row.summary.as_str())</a> | 620 | + <span class="val"> |
| 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"> | | |
| 616 | commit_status(summary: row.status.clone(), lang: StatusLang(lang)) | 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> | 622 | + " " |
| 618 | - <a class="small muted" href=(row.tree_href.as_str())>(browse)</a> | 623 | + <a class="mono" href=(row.commit_href.as_str())>(row.short.as_str())</a> |
| 619 | - </div> | 624 | + " · " (row.author.as_str()) " " (committed) " " |
| 620 | - </li> | 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 | if let Some(message) = review_error { | 947 | if let Some(message) = review_error { |
| 939 | alert(message: message) | 948 | alert(message: message) |
| 940 | } | 949 | } |
| 941 | - <div class="issue-layout" data-live=(live.as_str())> | 950 | + <div data-live=(live.as_str())> |
| 942 | - <div class="issue-column fit-pane"> | 951 | + <div class="pull-topics"> |
| 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"> | | |
| 975 | item_sidebar(lang: lang, write: write_meta, base: href.clone(), csrf: csrf.clone(), viewer: viewer_login, sidebar: sidebar, notify: notify) | 952 | item_sidebar(lang: lang, write: write_meta, base: href.clone(), csrf: csrf.clone(), viewer: viewer_login, sidebar: sidebar, notify: notify) |
| 976 | reviewers_box(lang: lang, reviewers: reviewers) | 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 | </div> | 985 | </div> |
| 979 | ) | 986 | ) |
| 980 | }) | 987 | }) |
| @@ -1071,9 +1078,7 @@ async fn pull_commits(cx: &Cx) -> Result<impl View> { |
| 1071 | pull_header(frame: frame.clone()) | 1078 | pull_header(frame: frame.clone()) |
| 1072 | pull_subnav_in(lang: lang, href: href, active: "commits".to_owned(), | 1079 | pull_subnav_in(lang: lang, href: href, active: "commits".to_owned(), |
| 1073 | commits: frame.commit_count, files: frame.file_count) | 1080 | commits: frame.commit_count, files: frame.file_count) |
| 1074 | - <div class="issue-pane fit-pane"> | 1081 | + commit_list(rows: rows, lang: lang) |
| 1075 | - commit_list(rows: rows, lang: lang) | | |
| 1076 | - </div> | | |
| 1077 | ) | 1082 | ) |
| 1078 | }) | 1083 | }) |
| 1079 | } | 1084 | } |
| @@ -1145,7 +1150,8 @@ mod tests { |
| 1145 | /// The page's own `<main>` element. The shell's header also echoes the request URL | 1150 | /// The page's own `<main>` element. The shell's header also echoes the request URL |
| 1146 | /// (theme form `back` field), so checks about the page body are scoped to `<main>`. | 1151 | /// (theme form `back` field), so checks about the page body are scoped to `<main>`. |
| 1147 | fn page_main(body: &str) -> &str { | 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 | .and_then(|(_, rest)| rest.split_once("</main>")) | 1155 | .and_then(|(_, rest)| rest.split_once("</main>")) |
| 1150 | .map(|(main, _)| main) | 1156 | .map(|(main, _)| main) |
| 1151 | .expect("page has a <main> element") | 1157 | .expect("page has a <main> element") |
| @@ -17,13 +17,13 @@ use crate::i18n::pulls::{self as g, K}; |
| 17 | use crate::i18n::{self, Lang}; | 17 | use crate::i18n::{self, Lang}; |
| 18 | use crate::pages::issues_list::{ | 18 | use crate::pages::issues_list::{ |
| 19 | AssigneeView, LabelView, ListQuery, MilestoneView, Selection, SortOption, list_href, | 19 | AssigneeView, LabelView, ListQuery, MilestoneView, Selection, SortOption, list_href, |
| 20 | - stamp_unix, state_tab_class, | 20 | + stamp_unix, state_tab, |
| 21 | }; | 21 | }; |
| 22 | use crate::pages::repo::repo_head; | 22 | use crate::pages::repo::repo_head; |
| 23 | use crate::pages::repo_ctx::load_repo; | 23 | use crate::pages::repo_ctx::load_repo; |
| 24 | use crate::state::AppState; | 24 | use crate::state::AppState; |
| 25 | use crate::views::{ | 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 | path_param!(owner); | 29 | path_param!(owner); |
| @@ -261,6 +261,10 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> { |
| 261 | g::t(lang, K::NoPullRequestsMatch) | 261 | g::t(lang, K::NoPullRequestsMatch) |
| 262 | }; | 262 | }; |
| 263 | let state_word = sel.state; | 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 | let draft_label = g::t(lang, K::DraftBadge); | 268 | let draft_label = g::t(lang, K::DraftBadge); |
| 265 | let draft_sel = sel.draft; | 269 | let draft_sel = sel.draft; |
| 266 | | 270 | |
| @@ -269,20 +273,24 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> { |
| 269 | Ok(view! { | 273 | Ok(view! { |
| 270 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), | 274 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), extra_stylesheet: Some(labels_href.as_str()), |
| 271 | repo_head(head: header) | 275 | repo_head(head: header) |
| 272 | - <section class="issue-pane fit-pane"> | 276 | + <div data-live=(live_url.as_str())> |
| 273 | - <div class="issue-toolbar" data-live=(live_url.as_str())> | 277 | + <h1 class="sr-only">(title.as_str())</h1> |
| 274 | - <nav class="issue-tabs" aria-label=(g::t(lang, K::ListStateNavLabel))> | 278 | + <nav class="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> | 279 | + state_tab(href: open_href.as_str(), text: open_text.as_str(), current: open_on) |
| 276 | - <a class=(state_tab_class(state_word == "closed")) href=(closed_href.as_str())>(closed_text.as_str())</a> | 280 | + state_tab(href: closed_href.as_str(), text: closed_text.as_str(), current: closed_on) |
| 277 | - <a class=(state_tab_class(state_word == "all")) href=(all_href.as_str())>(all_text.as_str())</a> | 281 | + state_tab(href: all_href.as_str(), text: all_text.as_str(), current: all_on) |
| 278 | - </nav> | 282 | + </nav> |
| 279 | - <form method="get" action=(base.as_str()) class="issue-search"> | 283 | + <form method="get" action=(base.as_str())> |
| 280 | - <input type="hidden" name="state" value=(sel.state)> | 284 | + <input type="hidden" name="state" value=(sel.state)> |
| 281 | - <input type="hidden" name="label" value=(sel.label.as_str())> | 285 | + <input type="hidden" name="label" value=(sel.label.as_str())> |
| 282 | - <input type="hidden" name="milestone" value=(sel.milestone.as_str())> | 286 | + <input type="hidden" name="milestone" value=(sel.milestone.as_str())> |
| 283 | - <input type="hidden" name="author" value=(sel.author.as_str())> | 287 | + <input type="hidden" name="author" value=(sel.author.as_str())> |
| 284 | - <input type="hidden" name="assignee" value=(sel.assignee.as_str())> | 288 | + <input type="hidden" name="assignee" value=(sel.assignee.as_str())> |
| | 289 | + <div class="plain-search"> |
| 285 | <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"> | 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 | <select name="draft" aria-label=(g::t(lang, K::DraftFilterLabel)) data-autosubmit=(true)> | 294 | <select name="draft" aria-label=(g::t(lang, K::DraftFilterLabel)) data-autosubmit=(true)> |
| 287 | <option value="" selected=(draft_sel.is_empty())>(g::t(lang, K::DraftAny))</option> | 295 | <option value="" selected=(draft_sel.is_empty())>(g::t(lang, K::DraftAny))</option> |
| 288 | <option value="true" selected=(draft_sel == "true")>(g::t(lang, K::DraftOnly))</option> | 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 | <option value=(option.value) selected=(option.selected)>(option.label)</option> | 301 | <option value=(option.value) selected=(option.selected)>(option.label)</option> |
| 294 | } | 302 | } |
| 295 | </select> | 303 | </select> |
| 296 | - <button type="submit" class="sr-only">(g::t(lang, K::Search))</button> | 304 | + <a href=(queue_href.as_str())>(mq::t(lang, mq::K::MergeQueueTitle))</a> |
| 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> | | |
| 300 | if can_create { | 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 | </div> | 308 | </div> |
| 304 | - </div> | 309 | + </form> |
| 305 | if has_filters { | 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 | if rows.is_empty() { | 313 | if rows.is_empty() { |
| | 314 | + <p class="state">(empty_text)</p> |
| 309 | if has_filters { | 315 | if has_filters { |
| 310 | - empty_state(title: empty_text, | 316 | + <div class="acts"> |
| 311 | - <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> | 317 | + <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a> |
| 312 | - ) | 318 | + </div> |
| 313 | - } else if open_count + closed_count == 0 { | 319 | + } else if no_pulls_yet && can_create { |
| 314 | - empty_state(title: empty_text, | 320 | + <div class="acts"> |
| 315 | - if can_create { | 321 | + <a class="act" href=(compare_href.as_str()) data-palette-action="go">(g::t(lang, K::NewPullRequest))</a> |
| 316 | - <a class="button primary" href=(compare_href.as_str()) data-palette-action="go">(g::t(lang, K::NewPullRequest))</a> | 322 | + </div> |
| 317 | - } | | |
| 318 | - ) | | |
| 319 | - } else { | | |
| 320 | - empty_state(title: empty_text) | | |
| 321 | } | 323 | } |
| 322 | } else { | 324 | } else { |
| 323 | - <ul class="issue-list"> | 325 | + <div> |
| 324 | for row in rows.iter() { | 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 | <span class=(row.state_class) role="img" aria-label=(row.state_label)></span> | 328 | <span class=(row.state_class) role="img" aria-label=(row.state_label)></span> |
| 327 | <div class="issue-main"> | 329 | <div class="issue-main"> |
| 328 | <div class="issue-title-line"> | 330 | <div class="issue-title-line"> |
| @@ -357,32 +359,30 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> { |
| 357 | if let Some(text) = row.reviewers_text.clone() { | 359 | if let Some(text) = row.reviewers_text.clone() { |
| 358 | <span class="review-pending">(text.as_str())</span> | 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 | </div> | 368 | </div> |
| 361 | </div> | 369 | </div> |
| 362 | - <div class="issue-aside"> | 370 | + </div> |
| 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> | | |
| 371 | } | 371 | } |
| 372 | - </ul> | 372 | + </div> |
| 373 | } | 373 | } |
| 374 | if has_newer || has_older { | 374 | if has_newer || has_older { |
| 375 | - <nav class="pager"> | 375 | + <nav class="sub"> |
| 376 | if has_newer { | 376 | if has_newer { |
| 377 | <a href=(newer_href.as_str())>(g::t(lang, K::Newer))</a> | 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 | if has_older { | 380 | if has_older { |
| 381 | <a href=(older_href.as_str())>(g::t(lang, K::Older))</a> | 381 | <a href=(older_href.as_str())>(g::t(lang, K::Older))</a> |
| 382 | } | 382 | } |
| 383 | </nav> | 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 | fn rows(html: &str) -> usize { | 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 | const HEAD_OID: &str = "1111111111111111111111111111111111111111"; | 404 | const HEAD_OID: &str = "1111111111111111111111111111111111111111"; |
| @@ -19,7 +19,7 @@ use crate::pages::repo::repo_head; |
| 19 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; | 19 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 20 | use crate::pages::tree::{LastCommit, last_commit_view}; | 20 | use crate::pages::tree::{LastCommit, last_commit_view}; |
| 21 | use crate::views::commit_line::commit_line; | 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 | path_param!(owner); | 24 | path_param!(owner); |
| 25 | path_param!(repo); | 25 | path_param!(repo); |
| @@ -105,45 +105,36 @@ pub(crate) async fn ref_rows( |
| 105 | } | 105 | } |
| 106 | | 106 | |
| 107 | #[component] | 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 | let empty = rows.is_empty(); | 109 | let empty = rows.is_empty(); |
| 110 | Ok(view! { | 110 | Ok(view! { |
| 111 | if empty { | 111 | if empty { |
| 112 | - empty_state(title: g::t(lang, K::NothingHere)) | 112 | + <p class="state">(g::t(lang, K::NothingHere))</p> |
| 113 | } else { | 113 | } else { |
| 114 | - <div class="table-wrap"> | 114 | + <div> |
| 115 | - <table class="table refs-table"> | 115 | + for row in rows.into_iter() { |
| 116 | - <thead> | 116 | + if let Some(last) = row.last { |
| 117 | - <tr> | 117 | + <details class="row-open" data-kb-row=""> |
| 118 | - <th>(kind_label)</th> | 118 | + <summary class="line"> |
| 119 | - <th>(g::t(lang, K::LastCommitHeader))</th> | 119 | + <a class="name" href=(row.href)>(row.name)</a> |
| 120 | - <th class="age">(g::t(lang, K::AgeHeader))</th> | 120 | + if row.is_default { |
| 121 | - </tr> | 121 | + <span class="badge public">(g::t(lang, K::DefaultBadge))</span> |
| 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> | | |
| 142 | } | 122 | } |
| 143 | - </tr> | 123 | + <span class="val"><time datetime=(last.iso.clone()) title=(last.absolute)>(last.age)</time></span> |
| 144 | - } | 124 | + </summary> |
| 145 | - </tbody> | 125 | + <div class="opened"> |
| 146 | - </table> | 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 | </div> | 138 | </div> |
| 148 | } | 139 | } |
| 149 | }) | 140 | }) |
| @@ -193,14 +184,7 @@ async fn tags_page(cx: &Cx) -> Result<impl View> { |
| 193 | Ok(view! { | 184 | Ok(view! { |
| 194 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 185 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 195 | repo_head(head: header) | 186 | repo_head(head: header) |
| 196 | - <div class="lang-list fit-pane"> | 187 | + refs_table(rows: rows, lang: lang) |
| 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> | | |
| 204 | ) | 188 | ) |
| 205 | }) | 189 | }) |
| 206 | } | 190 | } |
| @@ -128,52 +128,52 @@ async fn register_form( |
| 128 | error: Option<String>, | 128 | error: Option<String>, |
| 129 | ) -> Result<impl View> { | 129 | ) -> Result<impl View> { |
| 130 | Ok(view! { | 130 | Ok(view! { |
| 131 | - <section class="card narrow"> | 131 | + <section> |
| 132 | <h1>(t(lang, Key::RegisterTitle))</h1> | 132 | <h1>(t(lang, Key::RegisterTitle))</h1> |
| 133 | if gate == Gate::NeedsInvite { | 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 | if gate == Gate::BadInvite { | 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 | if gate == Gate::Form { | 139 | if gate == Gate::Form { |
| 140 | if invited { | 140 | if invited { |
| 141 | - <p class="muted">(t(lang, Key::RegisterInviteSub))</p> | 141 | + <p class="hint">(t(lang, Key::RegisterInviteSub))</p> |
| 142 | } | 142 | } |
| 143 | if !invited { | 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 { | 146 | + <form data-hard="true" method="post" action="/register" class="fields"> |
| 147 | - alert(message: message.as_str()) | 147 | + if let Some(message) = error { |
| 148 | - } | 148 | + alert(message: message.as_str()) |
| 149 | - <form data-hard="true" method="post" action="/register" class="stack"> | 149 | + } |
| 150 | <input type="hidden" name="precsrf" value=(precsrf)> | 150 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 151 | <input type="hidden" name="invite" value=(invite)> | 151 | <input type="hidden" name="invite" value=(invite)> |
| 152 | - <label> | 152 | + <div class="field"> |
| 153 | - <span>(t(lang, Key::Username))</span> | 153 | + <label for="register-username">(t(lang, Key::Username))</label> |
| 154 | - <input type="text" name="username" value=(username) autocomplete="username" required=(true)> | 154 | + <input id="register-username" type="text" name="username" value=(username) autocomplete="username" required=(true)> |
| 155 | - </label> | 155 | + </div> |
| 156 | if invited { | 156 | if invited { |
| 157 | - <label> | 157 | + <div class="field"> |
| 158 | - <span>(t(lang, Key::Email))</span> | 158 | + <label for="register-email">(t(lang, Key::Email))</label> |
| 159 | - <input type="email" name="email" value=(email) readonly=(true)> | 159 | + <input id="register-email" type="email" name="email" value=(email) readonly=(true)> |
| 160 | - </label> | 160 | + </div> |
| 161 | } | 161 | } |
| 162 | if !invited { | 162 | if !invited { |
| 163 | - <label> | 163 | + <div class="field"> |
| 164 | - <span>(t(lang, Key::Email))</span> | 164 | + <label for="register-email">(t(lang, Key::Email))</label> |
| 165 | - <input type="email" name="email" value=(email) autocomplete="email" maxlength="254" required=(true)> | 165 | + <input id="register-email" type="email" name="email" value=(email) autocomplete="email" maxlength="254" required=(true)> |
| 166 | - </label> | 166 | + </div> |
| 167 | } | 167 | } |
| 168 | - <label> | 168 | + <div class="field"> |
| 169 | - <span>(t(lang, Key::Password))</span> | 169 | + <label for="register-password">(t(lang, Key::Password))</label> |
| 170 | - <input type="password" name="password" autocomplete="new-password" required=(true)> | 170 | + <input id="register-password" type="password" name="password" autocomplete="new-password" required=(true)> |
| 171 | - <small class="muted">(t(lang, Key::AtLeast12Chars))</small> | 171 | + <p class="hint">(t(lang, Key::AtLeast12Chars))</p> |
| 172 | - </label> | 172 | + </div> |
| 173 | - <label> | 173 | + <div class="field"> |
| 174 | - <span>(t(lang, Key::ConfirmPassword))</span> | 174 | + <label for="register-confirm">(t(lang, Key::ConfirmPassword))</label> |
| 175 | - <input type="password" name="confirm" autocomplete="new-password" required=(true)> | 175 | + <input id="register-confirm" type="password" name="confirm" autocomplete="new-password" required=(true)> |
| 176 | - </label> | 176 | + </div> |
| 177 | <button type="submit" class="primary">(t(lang, Key::RegisterSubmit))</button> | 177 | <button type="submit" class="primary">(t(lang, Key::RegisterSubmit))</button> |
| 178 | </form> | 178 | </form> |
| 179 | } | 179 | } |
| @@ -353,20 +353,20 @@ async fn verify_body( |
| 353 | mode: VerifyMode, | 353 | mode: VerifyMode, |
| 354 | ) -> Result<impl View> { | 354 | ) -> Result<impl View> { |
| 355 | Ok(view! { | 355 | Ok(view! { |
| 356 | - <section class="card narrow"> | 356 | + <section> |
| 357 | <h1>(t(lang, Key::VerifyTitle))</h1> | 357 | <h1>(t(lang, Key::VerifyTitle))</h1> |
| 358 | if mode == VerifyMode::Confirm { | 358 | if mode == VerifyMode::Confirm { |
| 359 | - <p class="muted">(t(lang, Key::VerifyConfirmSub))</p> | 359 | + <p class="hint">(t(lang, Key::VerifyConfirmSub))</p> |
| 360 | - <form data-hard="true" method="post" action=(format!("/verify/{token}")) class="stack"> | 360 | + <form data-hard="true" method="post" action=(format!("/verify/{token}")) class="fields"> |
| 361 | <input type="hidden" name="precsrf" value=(precsrf)> | 361 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 362 | <button type="submit" class="primary">(t(lang, Key::VerifyConfirm))</button> | 362 | <button type="submit" class="primary">(t(lang, Key::VerifyConfirm))</button> |
| 363 | </form> | 363 | </form> |
| 364 | } | 364 | } |
| 365 | if mode == VerifyMode::Done { | 365 | if mode == VerifyMode::Done { |
| 366 | - <p>(t(lang, Key::VerifyDone))</p> | 366 | + <p class="state">(t(lang, Key::VerifyDone))</p> |
| 367 | } | 367 | } |
| 368 | if mode == VerifyMode::Invalid { | 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 | </section> | 371 | </section> |
| 372 | }) | 372 | }) |
| @@ -44,6 +44,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 44 | use crate::release_ops::{self, CreateRelease, EditRelease, ReleaseError}; | 44 | use crate::release_ops::{self, CreateRelease, EditRelease, ReleaseError}; |
| 45 | use crate::render::markdown::render_markdown; | 45 | use crate::render::markdown::render_markdown; |
| 46 | use crate::state::AppState; | 46 | use crate::state::AppState; |
| | 47 | +use crate::views::parts::{confirm_act, reveal}; |
| 47 | use crate::views::repo_list::{PageLink, pager, pager_links}; | 48 | use crate::views::repo_list::{PageLink, pager, pager_links}; |
| 48 | use crate::views::{alert, empty_state, enc, now_unix, shell, user_link}; | 49 | use crate::views::{alert, empty_state, enc, now_unix, shell, user_link}; |
| 49 | | 50 | |
| @@ -363,68 +364,66 @@ async fn release_form( |
| 363 | let tag_hint = g::t(lang, K::TagHint); | 364 | let tag_hint = g::t(lang, K::TagHint); |
| 364 | let edit_tag_help = g::t(lang, K::EditTagHelp); | 365 | let edit_tag_help = g::t(lang, K::EditTagHelp); |
| 365 | Ok(view! { | 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 | if let Some(message) = draft.error { | 368 | if let Some(message) = draft.error { |
| 368 | alert(message: message.as_str()) | 369 | alert(message: message.as_str()) |
| 369 | } | 370 | } |
| 370 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 371 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 371 | if is_new { | 372 | if is_new { |
| 372 | // The tag and the target branch are short, so they share a row. | 373 | // The tag and the target branch are short, so they share a row. |
| 373 | - <div class="release-pair"> | 374 | + <div class="field-pair"> |
| 374 | - <label> | 375 | + <div class="field"> |
| 375 | - <span>(g::t(lang, K::Tag))</span> | 376 | + <label for="release-tag">(g::t(lang, K::Tag))</label> |
| 376 | - <input type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> | 377 | + <input id="release-tag" type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> |
| 377 | - </label> | 378 | + </div> |
| 378 | - <label> | 379 | + <div class="field"> |
| 379 | - <span>(g::t(lang, K::TargetBranch))</span> | 380 | + <label for="release-target">(g::t(lang, K::TargetBranch))</label> |
| 380 | - <select name="target"> | 381 | + <select id="release-target" name="target"> |
| 381 | for branch in branches.iter() { | 382 | for branch in branches.iter() { |
| 382 | <option value=(branch.as_str()) selected=(branch.as_str() == draft.target.as_str())>(branch.as_str())</option> | 383 | <option value=(branch.as_str()) selected=(branch.as_str() == draft.target.as_str())>(branch.as_str())</option> |
| 383 | } | 384 | } |
| 384 | </select> | 385 | </select> |
| 385 | - </label> | 386 | + </div> |
| 386 | - <p class="muted small">(tag_hint)</p> | | |
| 387 | </div> | 387 | </div> |
| | 388 | + <p class="hint">(tag_hint)</p> |
| 388 | } else { | 389 | } else { |
| 389 | - <label> | 390 | + <div class="field"> |
| 390 | - <span>(g::t(lang, K::Tag))</span> | 391 | + <label for="release-tag">(g::t(lang, K::Tag))</label> |
| 391 | - <input type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> | 392 | + <input id="release-tag" type="text" name="tag" value=(draft.tag.as_str()) required="required" maxlength="100" autocomplete="off" spellcheck="false"> |
| 392 | - </label> | 393 | + <p class="hint">(edit_tag_help)</p> |
| 393 | - <p class="muted small">(edit_tag_help)</p> | 394 | + </div> |
| 394 | if move_target { | 395 | if move_target { |
| 395 | - <label> | 396 | + <div class="field"> |
| 396 | - <span>(g::t(lang, K::EditTargetLabel))</span> | 397 | + <label for="release-target">(g::t(lang, K::EditTargetLabel))</label> |
| 397 | - <select name="target"> | 398 | + <select id="release-target" name="target"> |
| 398 | <option value="" selected=(draft.target.is_empty())>(g::t(lang, K::CurrentCommit))</option> | 399 | <option value="" selected=(draft.target.is_empty())>(g::t(lang, K::CurrentCommit))</option> |
| 399 | for branch in branches.iter() { | 400 | for branch in branches.iter() { |
| 400 | <option value=(branch.as_str()) selected=(branch.as_str() == draft.target.as_str())>(branch.as_str())</option> | 401 | <option value=(branch.as_str()) selected=(branch.as_str() == draft.target.as_str())>(branch.as_str())</option> |
| 401 | } | 402 | } |
| 402 | </select> | 403 | </select> |
| 403 | - </label> | 404 | + <p class="hint">(g::t(lang, K::TargetMoveHelp))</p> |
| 404 | - <p class="muted small">(g::t(lang, K::TargetMoveHelp))</p> | 405 | + </div> |
| 405 | } else { | 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 | + <div class="field"> |
| 410 | - <span>(g::t(lang, K::Title))</span> | 411 | + <label for="release-title">(g::t(lang, K::Title))</label> |
| 411 | - <input type="text" name="title" value=(draft.title.as_str()) required="required" maxlength="200"> | 412 | + <input id="release-title" type="text" name="title" value=(draft.title.as_str()) required="required" maxlength="200"> |
| 412 | - </label> | 413 | + </div> |
| 413 | - <label> | 414 | + <div class="field"> |
| 414 | - <span>(g::t(lang, K::ReleaseNotes))</span> | 415 | + <label for="release-body">(g::t(lang, K::ReleaseNotes))</label> |
| 415 | - <textarea name="body" rows="10">(draft.body.as_str())</textarea> | 416 | + <textarea id="release-body" name="body" rows="10">(draft.body.as_str())</textarea> |
| 416 | - </label> | 417 | + </div> |
| 417 | - <label class="inline"> | 418 | + <label class="switch"> |
| 418 | <input type="checkbox" name="prerelease" value="on" checked=(draft.prerelease)> | 419 | <input type="checkbox" name="prerelease" value="on" checked=(draft.prerelease)> |
| 419 | <span>(g::t(lang, K::PrereleaseHelp))</span> | 420 | <span>(g::t(lang, K::PrereleaseHelp))</span> |
| 420 | </label> | 421 | </label> |
| 421 | - <label class="inline"> | 422 | + <label class="switch"> |
| 422 | <input type="checkbox" name="draft" value="on" checked=(draft.draft)> | 423 | <input type="checkbox" name="draft" value="on" checked=(draft.draft)> |
| 423 | <span>(g::t(lang, K::DraftHelp))</span> | 424 | <span>(g::t(lang, K::DraftHelp))</span> |
| 424 | </label> | 425 | </label> |
| 425 | - <div> | 426 | + <button type="submit" class="primary">(submit)</button> |
| 426 | - <button type="submit" class="primary">(submit)</button> | | |
| 427 | - </div> | | |
| 428 | </form> | 427 | </form> |
| 429 | }) | 428 | }) |
| 430 | } | 429 | } |
| @@ -438,44 +437,43 @@ async fn asset_rows( |
| 438 | csrf: String, | 437 | csrf: String, |
| 439 | lang: Lang, | 438 | lang: Lang, |
| 440 | ) -> Result<impl View> { | 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 | Ok(view! { | 446 | Ok(view! { |
| 442 | - if assets.is_empty() { | 447 | + if rows.is_empty() { |
| 443 | - <p class="muted">(g::t(lang, K::NoAssetsYet))</p> | 448 | + <p class="state">(g::t(lang, K::NoAssetsYet))</p> |
| 444 | } else { | 449 | } else { |
| 445 | - <div class="table-wrap"> | 450 | + <div> |
| 446 | - <table class="table release-assets"> | 451 | + for (asset, action, file_id) in rows.into_iter() { |
| 447 | - <thead> | 452 | + <details class="row-open" data-kb-row=""> |
| 448 | - <tr> | 453 | + <summary class="line"> |
| 449 | - <th>(g::t(lang, K::File))</th> | 454 | + <span class="name">(asset.name.as_str())</span> |
| 450 | - <th>(g::t(lang, K::Size))</th> | 455 | + <span class="val">(asset.size.as_str()) " · " (g::download_count(lang, asset.downloads))</span> |
| 451 | - <th>(g::t(lang, K::Downloads))</th> | 456 | + </summary> |
| 452 | - <th>"SHA-256"</th> | 457 | + <div class="opened"> |
| 453 | - <th></th> | 458 | + <code class="hint">(asset.sha256.as_str())</code> |
| 454 | - </tr> | 459 | + <div class="acts"> |
| 455 | - </thead> | 460 | + <a class="act" href=(asset.href.as_str())>(g::t(lang, K::Download))</a> |
| 456 | - <tbody> | 461 | + reveal(label: g::t(lang, K::ReplaceAsset), |
| 457 | - for (asset, action) in assets.iter().zip(delete_actions.iter()) { | 462 | + <form method="post" action=(upload_action.as_str()) enctype="multipart/form-data" class="fields"> |
| 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"> | | |
| 465 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 463 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 466 | <input type="hidden" name="name" value=(asset.name.as_str())> | 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 | <button type="submit">(g::t(lang, K::ReplaceAsset))</button> | 469 | <button type="submit">(g::t(lang, K::ReplaceAsset))</button> |
| 469 | </form> | 470 | </form> |
| 470 | - <form method="post" action=(action.as_str()) class="inline-form"> | 471 | + ) |
| 471 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 472 | + confirm_act(lang: lang, label: i18n::t(lang, Key::Delete), action: action.as_str(), csrf: csrf.as_str()) |
| 472 | - <button type="submit">(i18n::t(lang, Key::Delete))</button> | 473 | + </div> |
| 473 | - </form> | 474 | + </div> |
| 474 | - </td> | 475 | + </details> |
| 475 | - </tr> | 476 | + } |
| 476 | - } | | |
| 477 | - </tbody> | | |
| 478 | - </table> | | |
| 479 | </div> | 477 | </div> |
| 480 | } | 478 | } |
| 481 | }) | 479 | }) |
| @@ -501,57 +499,60 @@ async fn list_body( |
| 501 | if is_error { | 499 | if is_error { |
| 502 | alert(message: text) | 500 | alert(message: text) |
| 503 | } else { | 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())> | 505 | + <div data-live=(live.as_str())> |
| 508 | - <div class="release-list-head list-bar"> | 506 | + <section class="sec"> |
| 509 | <h2>(g::t(lang, K::Releases))</h2> | 507 | <h2>(g::t(lang, K::Releases))</h2> |
| 510 | if let Some(href) = &new_href { | 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 | if cards.is_empty() { | 514 | if cards.is_empty() { |
| 515 | empty_state(title: g::t(lang, K::NoReleasesYet)) | 515 | empty_state(title: g::t(lang, K::NoReleasesYet)) |
| 516 | } | 516 | } |
| 517 | - <div class="list-scroll"> | | |
| 518 | for card in cards.iter() { | 517 | for card in cards.iter() { |
| 519 | - <article class="release-card" data-kb-row="" title=(card.body.as_str())> | 518 | + <details class="row-open" data-kb-row="" title=(card.body.as_str())> |
| 520 | - <code class="release-tag">(card.tag.as_str())</code> | 519 | + <summary class="line"> |
| 521 | - <h3> | 520 | + <span class="name"> |
| 522 | - <a href=(card.href.as_str())>(card.title.as_str())</a> | 521 | + (card.title.as_str()) |
| 523 | - if card.latest { | 522 | + if card.latest { |
| 524 | - " " <span class="badge latest">(g::t(lang, K::Latest))</span> | 523 | + " " <span class="badge latest">(g::t(lang, K::Latest))</span> |
| 525 | - } | 524 | + } |
| 526 | - if card.prerelease { | 525 | + if card.prerelease { |
| 527 | - " " <span class="badge">(g::t(lang, K::PreRelease))</span> | 526 | + " " <span class="badge">(g::t(lang, K::PreRelease))</span> |
| 528 | - } | 527 | + } |
| 529 | - if card.draft { | 528 | + if card.draft { |
| 530 | - " " <span class="badge draft">(g::t(lang, K::Draft))</span> | 529 | + " " <span class="badge draft">(g::t(lang, K::Draft))</span> |
| 531 | - } | 530 | + } |
| 532 | - </h3> | 531 | + </span> |
| 533 | - <span class="muted small release-meta"> | 532 | + <span class="val"> |
| 534 | - <time data-rel="true" datetime=(card.when.iso.as_str()) title=(card.when.absolute.as_str())>(card.when.relative.as_str())</time> | 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 | if !card.author.is_empty() { | 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> | 540 | + if !card.assets.is_empty() { |
| 539 | - if !card.assets.is_empty() { | 541 | + <div class="sub"> |
| 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"> | | |
| 543 | for asset in card.assets.iter() { | 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> | 545 | + </div> |
| 547 | - </details> | 546 | + } |
| 548 | - } | 547 | + <div class="acts"> |
| 549 | - <a class="small release-edit" href=(card.edit_href.as_str())>(g::t(lang, K::Edit))</a> | 548 | + <a class="act" href=(card.href.as_str())>(card.tag.as_str())</a> |
| 550 | - </article> | 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 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) | 554 | pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang) |
| 554 | - </section> | 555 | + </div> |
| 555 | }) | 556 | }) |
| 556 | } | 557 | } |
| 557 | | 558 | |
| @@ -635,7 +636,7 @@ async fn new_form_body( |
| 635 | ) -> Result<impl View> { | 636 | ) -> Result<impl View> { |
| 636 | Ok(view! { | 637 | Ok(view! { |
| 637 | repo_head(head: head) | 638 | repo_head(head: head) |
| 638 | - <section class="lang-form"> | 639 | + <section class="sec"> |
| 639 | <h2>(g::t(lang, K::NewRelease))</h2> | 640 | <h2>(g::t(lang, K::NewRelease))</h2> |
| 640 | 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 | 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 | </section> | 642 | </section> |
| @@ -810,14 +811,14 @@ async fn release_tag_page(cx: &Cx) -> Result<impl View> { |
| 810 | if is_error { | 811 | if is_error { |
| 811 | alert(message: text) | 812 | alert(message: text) |
| 812 | } else { | 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 | + <div data-live=(live.as_str())> |
| 817 | - <p class="muted small"> | 818 | + <nav class="sub"> |
| 818 | <a href=(all_href.as_str())>(g::t(lang, K::AllReleases))</a> | 819 | <a href=(all_href.as_str())>(g::t(lang, K::AllReleases))</a> |
| 819 | - </p> | 820 | + </nav> |
| 820 | - <h2> | 821 | + <h1 class="h1"> |
| 821 | (card.title.as_str()) | 822 | (card.title.as_str()) |
| 822 | if card.prerelease { | 823 | if card.prerelease { |
| 823 | " " <span class="badge">(g::t(lang, K::PreRelease))</span> | 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 | if card.draft { | 826 | if card.draft { |
| 826 | " " <span class="badge draft">(g::t(lang, K::Draft))</span> | 827 | " " <span class="badge draft">(g::t(lang, K::Draft))</span> |
| 827 | } | 828 | } |
| 828 | - </h2> | 829 | + </h1> |
| 829 | - <p class="muted small"> | 830 | + <p class="hint"> |
| 830 | <code>(card.tag.as_str())</code> | 831 | <code>(card.tag.as_str())</code> |
| 831 | " \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 | " \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 | if !card.author.is_empty() { | 833 | if !card.author.is_empty() { |
| @@ -834,45 +835,48 @@ async fn release_tag_page(cx: &Cx) -> Result<impl View> { |
| 834 | } | 835 | } |
| 835 | </p> | 836 | </p> |
| 836 | if !body_html.is_empty() { | 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> | 842 | + <section class="sec"> |
| 840 | - if card.assets.is_empty() { | 843 | + <h2>(g::t(lang, K::Assets))</h2> |
| 841 | - <p class="muted">(g::t(lang, K::NoAssets))</p> | 844 | + if card.assets.is_empty() { |
| 842 | - } else { | 845 | + <p class="state">(g::t(lang, K::NoAssets))</p> |
| 843 | - <ul class="release-asset-list"> | 846 | + } else { |
| 844 | for asset in card.assets.iter() { | 847 | for asset in card.assets.iter() { |
| 845 | - <li> | 848 | + <details class="row-open" data-kb-row=""> |
| 846 | - <a href=(asset.href.as_str())>(asset.name.as_str())</a> | 849 | + <summary class="line"> |
| 847 | - " (" (asset.size.as_str()) ", " (g::download_count(lang, asset.downloads)) ")" | 850 | + <span class="name">(asset.name.as_str())</span> |
| 848 | - <div class="muted small"><code>(asset.sha256.as_str())</code></div> | 851 | + <span class="val">(asset.size.as_str()) " · " (g::download_count(lang, asset.downloads))</span> |
| 849 | - </li> | 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> | 861 | + } |
| 852 | - } | 862 | + </section> |
| 853 | - <h3>(g::t(lang, K::SourceCode))</h3> | 863 | + <section class="sec"> |
| 854 | - <ul> | 864 | + <h2>(g::t(lang, K::SourceCode))</h2> |
| 855 | - <li><a href=(archive_tar.as_str())>"tar.gz"</a></li> | 865 | + <div class="acts"> |
| 856 | - <li><a href=(archive_zip.as_str())>"zip"</a></li> | 866 | + <a class="act" href=(archive_tar.as_str())>"tar.gz"</a> |
| 857 | - </ul> | 867 | + <a class="act" href=(archive_zip.as_str())>"zip"</a> |
| 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> | | |
| 873 | </div> | 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 | if is_error { | 907 | if is_error { |
| 904 | alert(message: text) | 908 | alert(message: text) |
| 905 | } else { | 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"> | 913 | + <nav class="sub"> |
| 910 | - <section class="lang-pane fit-pane"> | 914 | + <a href=(view_tag.as_str())>(g::t(lang, K::BackToRelease))</a> |
| 911 | - <p class="muted small"><a href=(view_tag.as_str())>(g::t(lang, K::BackToRelease))</a></p> | 915 | + </nav> |
| | 916 | + <section class="sec"> |
| 912 | <h2>(g::t(lang, K::EditRelease))</h2> | 917 | <h2>(g::t(lang, K::EditRelease))</h2> |
| 913 | 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)) | 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 | </section> | 919 | </section> |
| 915 | - <section class="lang-pane fit-pane"> | 920 | + <section class="sec"> |
| 916 | <h2>(g::t(lang, K::Assets))</h2> | 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 | asset_rows(assets: assets, delete_actions: delete_actions, upload_action: upload_action.clone(), csrf: csrf.clone(), lang: lang) | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 925 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 921 | - <label> | 926 | + <div class="field"> |
| 922 | - <span>(g::t(lang, K::File))</span> | 927 | + <label for="upload-file">(g::t(lang, K::File))</label> |
| 923 | - <input type="file" name="file" required="required"> | 928 | + <input id="upload-file" type="file" name="file" required="required"> |
| 924 | - </label> | | |
| 925 | - <div> | | |
| 926 | - <button type="submit">(g::t(lang, K::UploadAsset))</button> | | |
| 927 | </div> | 929 | </div> |
| | 930 | + <button type="submit" class="primary">(g::t(lang, K::UploadAsset))</button> |
| 928 | </form> | 931 | </form> |
| | 932 | + </section> |
| | 933 | + <section class="sec"> |
| 929 | <h2>(g::t(lang, K::DeleteRelease))</h2> | 934 | <h2>(g::t(lang, K::DeleteRelease))</h2> |
| 930 | - <p class="muted small">(g::t(lang, K::DeleteReleaseHelp))</p> | 935 | + <p class="hint">(g::t(lang, K::DeleteReleaseHelp))</p> |
| 931 | - <div> | 936 | + <div class="acts"> |
| 932 | - <details class="confirm-inline"> | 937 | + confirm_act(lang: lang, label: g::t(lang, K::DeleteRelease), action: delete_href.as_str(), csrf: csrf.as_str(), |
| 933 | - <summary class="button danger">(g::t(lang, K::DeleteRelease))</summary> | 938 | + fields: vec![("confirm".to_owned(), "on".to_owned())]) |
| 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> | | |
| 944 | </div> | 939 | </div> |
| 945 | </section> | 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 | description, | 78 | description, |
| 79 | archived, | 79 | archived, |
| 80 | active, | 80 | active, |
| 81 | - hide_search: _, | 81 | + hide_search, |
| 82 | can_admin, | 82 | can_admin, |
| 83 | can_delete: _, | 83 | can_delete: _, |
| 84 | open_issues, | 84 | open_issues, |
| @@ -154,19 +154,21 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> { |
| 154 | None => ("", "", None, String::new()), | 154 | None => ("", "", None, String::new()), |
| 155 | }; | 155 | }; |
| 156 | let live_attr = (!live.is_empty()).then(|| live.clone()); | 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 | 157 | + // The head: the path bar names the repo; the actions sit as text links under it, then the tabs, |
| 158 | - // the visibility and the counts and actions at the right end. | 158 | + // then the code search entry. |
| 159 | let has_origin = fork_line.is_some() || mirror_line.is_some(); | 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 | Ok(view! { | 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 | <h1 class="sr-only">(owner.as_str()) "/" (name.as_str())</h1> | 164 | <h1 class="sr-only">(owner.as_str()) "/" (name.as_str())</h1> |
| 163 | if has_origin { | 165 | if has_origin { |
| 164 | <div> | 166 | <div> |
| 165 | if let Some((href, label)) = fork_line { | 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 | if let Some(source) = mirror_line { | 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 | if let Some(at) = mirror_at.as_deref() { | 172 | if let Some(at) = mirror_at.as_deref() { |
| 171 | (mirror_before) rel_time(lang: lang, stamp: at) (mirror_after) | 173 | (mirror_before) rel_time(lang: lang, stamp: at) (mirror_after) |
| 172 | } else { | 174 | } else { |
| @@ -176,48 +178,49 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> { |
| 176 | } | 178 | } |
| 177 | </div> | 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) | 181 | + <div class="acts"> |
| 180 | - <div class="header-actions"> | | |
| 181 | // A private repo says so beside the star; public needs no mark outside the menu. | 182 | // A private repo says so beside the star; public needs no mark outside the menu. |
| 182 | if private { | 183 | if private { |
| 183 | <span class=(badge)>(vis)</span> | 184 | <span class=(badge)>(vis)</span> |
| 184 | } | 185 | } |
| 185 | - <div class="star-control"> | 186 | + if let Some((action, label, csrf)) = star_control { |
| 186 | - if let Some((action, label, csrf)) = star_control { | 187 | + <form method="post" action=(action.as_str()) class="act-form"> |
| 187 | - <form method="post" action=(action.as_str()) class="star-form"> | 188 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 188 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 189 | + <button type="submit" class="act" data-palette-action="post">(label.as_str())</button> |
| 189 | - <button type="submit" class="star-button" data-palette-action="post">(label.as_str())</button> | 190 | + </form> |
| 190 | - </form> | 191 | + } else { |
| 191 | - } else { | 192 | + <span class="hint" aria-label=(g::t(lang, K::StarsAria))>(anon_count.as_str())</span> |
| 192 | - <span class="muted" aria-label=(g::t(lang, K::StarsAria))>(anon_count.as_str())</span> | 193 | + } |
| 193 | - } | | |
| 194 | - </div> | | |
| 195 | <details class="menu head-more"> | 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 | <span aria-hidden="true">"…"</span> | 196 | <span aria-hidden="true">"…"</span> |
| 198 | </summary> | 197 | </summary> |
| 199 | <div class="menu-list head-more-list"> | 198 | <div class="menu-list head-more-list"> |
| 200 | <span class=(badge)>(vis)</span> | 199 | <span class=(badge)>(vis)</span> |
| 201 | if let Some((action, csrf)) = fork_control { | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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 | </form> | 204 | </form> |
| 206 | } | 205 | } |
| 207 | if let Some((action, csrf, level)) = watch_control { | 206 | if let Some((action, csrf, level)) = watch_control { |
| 208 | watch_form(lang: lang, action: action, csrf: csrf, level: level, watchers: watchers) | 207 | watch_form(lang: lang, action: action, csrf: csrf, level: level, watchers: watchers) |
| 209 | } else { | 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 | </div> | 212 | </div> |
| 214 | </details> | 213 | </details> |
| 215 | </div> | 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 | </section> | 221 | </section> |
| 217 | if archived { | 222 | if archived { |
| 218 | - <section class="card notice" role="status"> | 223 | + <p class="state" role="status">(g::t(lang, K::ArchivedNotice))</p> |
| 219 | - (g::t(lang, K::ArchivedNotice)) | | |
| 220 | - </section> | | |
| 221 | } | 224 | } |
| 222 | // The description belongs to the Code tab only; sub-pages keep the compact head. | 225 | // The description belongs to the Code tab only; sub-pages keep the compact head. |
| 223 | if active == "code" && !description.is_empty() { | 226 | if active == "code" && !description.is_empty() { |
| @@ -237,20 +240,17 @@ async fn clone_popover( |
| 237 | ) -> Result<impl View> { | 240 | ) -> Result<impl View> { |
| 238 | Ok(view! { | 241 | Ok(view! { |
| 239 | <details class="clone pop"> | 242 | <details class="clone pop"> |
| 240 | - <summary class="button primary"> | 243 | + <summary class="act">(g::t(lang, K::CloneTitle))</summary> |
| 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> | | |
| 244 | <div class="pop-panel"> | 244 | <div class="pop-panel"> |
| 245 | <label for="clone-https">"HTTPS"</label> | 245 | <label for="clone-https">"HTTPS"</label> |
| 246 | <input id="clone-https" class="mono" type="text" readonly=(true) value=(https.as_str())> | 246 | <input id="clone-https" class="mono" type="text" readonly=(true) value=(https.as_str())> |
| 247 | <span id="clone-https-text" hidden=(true)>(https.as_str())</span> | 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 | <label for="clone-ssh">"SSH"</label> | 249 | <label for="clone-ssh">"SSH"</label> |
| 250 | <input id="clone-ssh" class="mono" type="text" readonly=(true) value=(ssh.as_str())> | 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 | if let Some((zip, tar)) = downloads { | 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 | <a href=(zip)>(g::t(lang, K::DownloadZip))</a> | 254 | <a href=(zip)>(g::t(lang, K::DownloadZip))</a> |
| 255 | <a href=(tar)>(g::t(lang, K::DownloadTarGz))</a> | 255 | <a href=(tar)>(g::t(lang, K::DownloadTarGz))</a> |
| 256 | </nav> | 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, | 263 | +/// Head of the README pane, shared by the repo home and the tree pages: the file name, then the repo |
| 264 | -/// then the repo facts (licence, size, top language) and the Clone popover at the right. | 264 | +/// facts (licence, size, top language) and the Clone popover as text links on the same line. |
| 265 | #[component] | 265 | #[component] |
| 266 | pub(crate) async fn readme_head( | 266 | pub(crate) async fn readme_head( |
| 267 | label: String, | 267 | label: String, |
| @@ -272,12 +272,10 @@ pub(crate) async fn readme_head( |
| 272 | lang: Lang, | 272 | lang: Lang, |
| 273 | ) -> Result<impl View> { | 273 | ) -> Result<impl View> { |
| 274 | Ok(view! { | 274 | Ok(view! { |
| 275 | - <div class="canvas-head canvas-readme-head"> | 275 | + <div class="acts"> |
| 276 | - <span class="label">(label.as_str())</span> | 276 | + <span class="name">(label.as_str())</span> |
| 277 | - <div class="canvas-facts"> | 277 | + readme_meta(lang: lang, facts: facts) |
| 278 | - readme_meta(lang: lang, facts: facts) | 278 | + clone_popover(https: https, ssh: ssh, downloads: downloads, lang: lang) |
| 279 | - clone_popover(https: https, ssh: ssh, downloads: downloads, lang: lang) | | |
| 280 | - </div> | | |
| 281 | </div> | 279 | </div> |
| 282 | }) | 280 | }) |
| 283 | } | 281 | } |
| @@ -293,20 +291,20 @@ async fn branches_card( |
| 293 | ) -> Result<impl View> { | 291 | ) -> Result<impl View> { |
| 294 | let empty = branches.is_empty(); | 292 | let empty = branches.is_empty(); |
| 295 | Ok(view! { | 293 | Ok(view! { |
| 296 | - <section class="card"> | 294 | + <section class="sec"> |
| 297 | <h2>(g::t(lang, K::BranchesTitle))</h2> | 295 | <h2>(g::t(lang, K::BranchesTitle))</h2> |
| 298 | if empty { | 296 | if empty { |
| 299 | - <p class="muted">(g::t(lang, K::EmptyRepoPush))</p> | 297 | + <p class="state">(g::t(lang, K::EmptyRepoPush))</p> |
| 300 | - <p class="muted small">(g::t(lang, K::OverHttps))</p> | 298 | + <p class="hint">(g::t(lang, K::OverHttps))</p> |
| 301 | <pre class="code"><code>(push_https)</code></pre> | 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 | <pre class="code"><code>(push_ssh)</code></pre> | 301 | <pre class="code"><code>(push_ssh)</code></pre> |
| 304 | } else { | 302 | } else { |
| 305 | - <ul class="branch-list"> | 303 | + <div> |
| 306 | for branch in branches.into_iter() { | 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 | </section> | 309 | </section> |
| 312 | }) | 310 | }) |
| @@ -547,7 +545,7 @@ async fn repo_page(cx: &Cx) -> Result<impl View> { |
| 547 | // Two panes over the dock: the tree on the left, the README on the right. | 545 | // Two panes over the dock: the tree on the left, the README on the right. |
| 548 | <div class="repo-grid repo-home canvas-repo"> | 546 | <div class="repo-grid repo-home canvas-repo"> |
| 549 | <div class="repo-main canvas-files"> | 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 | ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags, | 549 | ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags, |
| 552 | branches_href: branches_href, tags_href: tags_href) | 550 | branches_href: branches_href, tags_href: tags_href) |
| 553 | file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), | 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 | use crate::pages::repo_settings::settings_frame; | 31 | use crate::pages::repo_settings::settings_frame; |
| 32 | use crate::pages::repo_settings_live::settings_head; | 32 | use crate::pages::repo_settings_live::settings_head; |
| 33 | use crate::state::AppState; | 33 | use crate::state::AppState; |
| | 34 | +use crate::views::parts::{confirm_act, reveal}; |
| 34 | use crate::views::{alert, avatar_url, display_name, shell}; | 35 | use crate::views::{alert, avatar_url, display_name, shell}; |
| 35 | | 36 | |
| 36 | path_param!(owner); | 37 | path_param!(owner); |
| @@ -156,7 +157,8 @@ fn collaborators_redirect(title: &str) -> SeeOther { |
| 156 | see_other(format!("/{title}/settings/collaborators")) | 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 | #[component] | 162 | #[component] |
| 161 | async fn collaborators_pane( | 163 | async fn collaborators_pane( |
| 162 | lang: Lang, | 164 | lang: Lang, |
| @@ -168,91 +170,77 @@ async fn collaborators_pane( |
| 168 | add_open: bool, | 170 | add_open: bool, |
| 169 | ) -> Result<impl View> { | 171 | ) -> Result<impl View> { |
| 170 | Ok(view! { | 172 | Ok(view! { |
| 171 | - <section class="card rows-pane"> | 173 | + <section class="sec"> |
| 172 | - <div class="row-line"> | 174 | + <h2>(g::t(lang, K::Collaborators))</h2> |
| 173 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 175 | + if rows.is_empty() { |
| 174 | - <div class="row-main"> | 176 | + <p class="state">(g::t(lang, K::NoCollaborators))</p> |
| 175 | - <h2 class="row-title">(g::t(lang, K::AddCollaboratorHeading))</h2> | 177 | + } else { |
| 176 | - if rows.is_empty() { | 178 | + <p class="hint">(g::t(lang, K::CollaboratorsHelp))</p> |
| 177 | - <p class="row-status">(g::t(lang, K::NoCollaborators))</p> | 179 | + } |
| 178 | - } else { | 180 | + <div> |
| 179 | - <p class="row-status">(g::t(lang, K::CollaboratorsHelp))</p> | 181 | + for row in rows.iter() { |
| 180 | - } | 182 | + <details class="row-open"> |
| 181 | - </div> | 183 | + <summary class="line"> |
| 182 | - <details class="row-action" open=(add_open)> | 184 | + <span class="name"> |
| 183 | - <summary>(g::t(lang, K::AddCollaboratorButton))</summary> | 185 | + <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> |
| 184 | - <div class="row-panel"> | 186 | + " " (row.label.as_str()) |
| 185 | - <h3>(g::t(lang, K::Roles))</h3> | 187 | + </span> |
| 186 | - <dl class="role-list"> | 188 | + <span class="val">(crate::i18n::orgs::role_name(lang, row.role.as_str()))</span> |
| 187 | - for entry in LEGEND.iter() { | 189 | + </summary> |
| 188 | - <dt>(entry.0.as_str())</dt> | 190 | + <div class="opened"> |
| 189 | - <dd>(g::t(lang, entry.1))</dd> | 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> | 194 | + <form method="post" action=(role_action.as_str()) class="fields"> |
| 192 | - <form method="post" action=(add_action.as_str()) class="stack" id="add-collaborator"> | 195 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 193 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 196 | + <input type="hidden" name="user_id" value=(row.user_id.as_str())> |
| 194 | - <label> | 197 | + <div class="field"> |
| 195 | - <span>(g::t(lang, K::Username))</span> | 198 | + <label for=(format!("collab-role-{}", row.user_id.as_str()))>(g::t(lang, K::Role))</label> |
| 196 | - <input type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> | 199 | + <select id=(format!("collab-role-{}", row.user_id.as_str())) name="role" aria-label=(g::role_for(lang, row.username.as_str()))> |
| 197 | - </label> | 200 | + for role in ROLES.iter() { |
| 198 | - <label> | 201 | + <option value=(role.as_str()) selected=(*role == row.role)>(crate::i18n::orgs::role_name(lang, role.as_str()))</option> |
| 199 | - <span>(g::t(lang, K::Role))</span> | 202 | + } |
| 200 | - <select name="role"> | 203 | + </select> |
| 201 | - for role in ROLES.iter() { | 204 | + </div> |
| 202 | - <option value=(role.as_str()) selected=(*role == Role::Read)>(role.as_str())</option> | 205 | + <button type="submit">(g::t(lang, K::SaveRole))</button> |
| 203 | - } | 206 | + </form> |
| 204 | - </select> | 207 | + <div class="acts"> |
| 205 | - </label> | 208 | + confirm_act(lang: lang, label: g::t(lang, K::Remove), action: remove_action.as_str(), csrf: csrf.as_str(), |
| 206 | - <p class="muted small">(g::t(lang, K::AddCollaboratorHelp))</p> | 209 | + fields: vec![("user_id".to_owned(), row.user_id.clone())], |
| 207 | - <div> | 210 | + note: Some(passkeys::s(lang, "They lose access to this repo at once.", "Bu repoya erişimi hemen kaybeder.").to_owned())) |
| 208 | - <button type="submit" class="primary">(g::t(lang, K::AddCollaboratorButton))</button> | | |
| 209 | </div> | 211 | </div> |
| 210 | - </form> | 212 | + </div> |
| 211 | - </div> | 213 | + </details> |
| 212 | - </details> | 214 | + } |
| 213 | </div> | 215 | </div> |
| 214 | - for row in rows.iter() { | 216 | + <div class="acts"> |
| 215 | - <div class="row-line"> | 217 | + reveal(label: g::t(lang, K::AddCollaboratorButton), id: Some("collab-add"), open: add_open, |
| 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> | 218 | + <p class="state">(g::t(lang, K::Roles))</p> |
| 217 | - <div class="row-main"> | 219 | + <dl class="role-list"> |
| 218 | - <strong class="row-name"> | 220 | + for entry in LEGEND.iter() { |
| 219 | - if row.label == row.username { | 221 | + <dt>(crate::i18n::orgs::role_name(lang, entry.0.as_str()))</dt> |
| 220 | - <a class="user-link" href=(format!("/{}", row.username.as_str()))> | 222 | + <dd>(g::t(lang, entry.1))</dd> |
| 221 | - <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> | 223 | + } |
| 222 | - <span>(row.label.as_str())</span> | 224 | + </dl> |
| 223 | - </a> | 225 | + <form method="post" action=(add_action.as_str()) class="fields" id="add-collaborator"> |
| 224 | - } else { | 226 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 225 | - <span class="user-link"> | 227 | + <div class="field"> |
| 226 | - <img class="avatar avatar-sm" src=(row.avatar.as_str()) alt="" width="24" height="24"> | 228 | + <label for="collab-username">(g::t(lang, K::Username))</label> |
| 227 | - <span>(row.label.as_str())</span> | 229 | + <input id="collab-username" type="text" name="username" autocomplete="off" spellcheck="false" required=(true)> |
| 228 | - </span> | 230 | + </div> |
| 229 | - } | 231 | + <div class="field"> |
| 230 | - </strong> | 232 | + <label for="collab-role">(g::t(lang, K::Role))</label> |
| 231 | - </div> | 233 | + <select id="collab-role" name="role"> |
| 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()))> | | |
| 237 | for role in ROLES.iter() { | 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 | </select> | 237 | </select> |
| 241 | - <button type="submit">(g::t(lang, K::SaveRole))</button> | 238 | + <p class="hint">(g::t(lang, K::AddCollaboratorHelp))</p> |
| 242 | - </form> | 239 | + </div> |
| 243 | - <details class="row-menu"> | 240 | + <button type="submit" class="primary">(g::t(lang, K::AddCollaboratorButton))</button> |
| 244 | - <summary class="button row-menu-btn" aria-label=(passkeys::s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> | 241 | + </form> |
| 245 | - <div class="row-menu-panel" role="menu"> | 242 | + ) |
| 246 | - <form method="post" action=(remove_action.as_str()) class="inline-form"> | 243 | + </div> |
| 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 | - } | | |
| 256 | </section> | 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 | #[component] | 267 | #[component] |
| 280 | async fn collaborators_body( | 268 | async fn collaborators_body( |
| 281 | lang: Lang, | 269 | lang: Lang, |
| @@ -300,7 +288,7 @@ async fn collaborators_body( |
| 300 | if is_error { | 288 | if is_error { |
| 301 | alert(message: text) | 289 | alert(message: text) |
| 302 | } else { | 290 | } else { |
| 303 | - <section class="card notice" role="status">(text)</section> | 291 | + <p class="state" role="status">(text)</p> |
| 304 | } | 292 | } |
| 305 | } | 293 | } |
| 306 | collaborators_pane(lang: lang, rows: rows, role_action: role_action, | 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 | use crate::pages::repo_settings::settings_frame; | 36 | use crate::pages::repo_settings::settings_frame; |
| 37 | use crate::pages::repo_settings_live::settings_head; | 37 | use crate::pages::repo_settings_live::settings_head; |
| 38 | use crate::state::AppState; | 38 | use crate::state::AppState; |
| | 39 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 39 | use crate::views::{ | 40 | use crate::views::{ |
| 40 | alert, enc, now_unix, rel_time_or_never, relative_time, shell, user_facing_message, | 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 | if is_error { | 405 | if is_error { |
| 405 | alert(message: text) | 406 | alert(message: text) |
| 406 | } else { | 407 | } else { |
| 407 | - <section class="card notice" role="status">(text)</section> | 408 | + <p class="state" role="status">(text)</p> |
| 408 | } | 409 | } |
| 409 | } | 410 | } |
| 410 | if archived { | 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 | (child) | 414 | (child) |
| 414 | ) | 415 | ) |
| @@ -421,6 +422,7 @@ async fn frame_top( |
| 421 | async fn mirror_form( | 422 | async fn mirror_form( |
| 422 | action: String, | 423 | action: String, |
| 423 | csrf: String, | 424 | csrf: String, |
| | 425 | + prefix: &'static str, |
| 424 | pull: bool, | 426 | pull: bool, |
| 425 | current_url: String, | 427 | current_url: String, |
| 426 | url: String, | 428 | url: String, |
| @@ -448,8 +450,12 @@ async fn mirror_form( |
| 448 | } else { | 450 | } else { |
| 449 | g::t(lang, K::SecretUnset) | 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 | Ok(view! { | 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 | if let Some(message) = error { | 459 | if let Some(message) = error { |
| 454 | alert(message: message.as_str()) | 460 | alert(message: message.as_str()) |
| 455 | } | 461 | } |
| @@ -458,41 +464,39 @@ async fn mirror_form( |
| 458 | <input type="hidden" name="direction" value=(direction)> | 464 | <input type="hidden" name="direction" value=(direction)> |
| 459 | } | 465 | } |
| 460 | if !current_url.is_empty() { | 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> | 469 | + <div class="field"> |
| 464 | - <span>(url_label)</span> | 470 | + <label for=(url_id.as_str())>(url_label)</label> |
| 465 | - <input type="url" name="url" value=(url.as_str()) autocomplete="off" spellcheck="false" required=(current_url.is_empty())> | 471 | + <input id=(url_id.as_str()) type="url" name="url" value=(url.as_str()) autocomplete="off" spellcheck="false" required=(current_url.is_empty())> |
| 466 | - </label> | 472 | + <p class="hint">(url_hint)</p> |
| 467 | - <p class="muted small">(url_hint)</p> | 473 | + </div> |
| 468 | - <label> | 474 | + <div class="field"> |
| 469 | - <span>(g::t(lang, K::UsernameOptional))</span> | 475 | + <label for=(username_id.as_str())>(g::t(lang, K::UsernameOptional))</label> |
| 470 | - <input type="text" name="username" value=(username.as_str()) autocomplete="off" maxlength="255"> | 476 | + <input id=(username_id.as_str()) type="text" name="username" value=(username.as_str()) autocomplete="off" maxlength="255"> |
| 471 | - </label> | 477 | + </div> |
| 472 | - <label> | 478 | + <div class="field"> |
| 473 | - <span>(g::t(lang, K::SecretOptional))</span> | 479 | + <label for=(secret_id.as_str())>(g::t(lang, K::SecretOptional))</label> |
| 474 | - <input type="password" name="secret" autocomplete="new-password" maxlength="1024"> | 480 | + <input id=(secret_id.as_str()) type="password" name="secret" autocomplete="new-password" maxlength="1024"> |
| 475 | - </label> | 481 | + <p class="hint">(secret_hint)</p> |
| 476 | - <p class="muted small">(secret_hint)</p> | 482 | + </div> |
| 477 | if has_secret { | 483 | if has_secret { |
| 478 | - <label class="inline"> | 484 | + <label class="switch"> |
| 479 | <input type="checkbox" name="clear_secret" value="on"> | 485 | <input type="checkbox" name="clear_secret" value="on"> |
| 480 | <span>(g::t(lang, K::ClearSecret))</span> | 486 | <span>(g::t(lang, K::ClearSecret))</span> |
| 481 | </label> | 487 | </label> |
| 482 | } | 488 | } |
| 483 | - <label> | 489 | + <div class="field"> |
| 484 | - <span>(g::t(lang, K::IntervalField))</span> | 490 | + <label for=(interval_id.as_str())>(g::t(lang, K::IntervalField))</label> |
| 485 | - <input type="number" name="interval" value=(interval.as_str()) min="0" max="525600" step="1"> | 491 | + <input id=(interval_id.as_str()) type="number" name="interval" value=(interval.as_str()) min="0" max="525600" step="1"> |
| 486 | - </label> | 492 | + </div> |
| 487 | if let Some(on) = enabled { | 493 | if let Some(on) = enabled { |
| 488 | - <label class="inline"> | 494 | + <label class="switch"> |
| 489 | <input type="checkbox" name="enabled" value="on" checked=(on)> | 495 | <input type="checkbox" name="enabled" value="on" checked=(on)> |
| 490 | <span>(g::t(lang, K::EnabledField))</span> | 496 | <span>(g::t(lang, K::EnabledField))</span> |
| 491 | </label> | 497 | </label> |
| 492 | } | 498 | } |
| 493 | - <div> | 499 | + <button type="submit" class="primary">(submit)</button> |
| 494 | - <button type="submit" class="primary">(submit)</button> | | |
| 495 | - </div> | | |
| 496 | </form> | 500 | </form> |
| 497 | }) | 501 | }) |
| 498 | } | 502 | } |
| @@ -518,94 +522,76 @@ async fn mirrors_list_body( |
| 518 | let push_open = draft.error.is_some(); | 522 | let push_open = draft.error.is_some(); |
| 519 | Ok(view! { | 523 | Ok(view! { |
| 520 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, | 524 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, |
| 521 | - <section class="card rows-pane"> | 525 | + <section class="sec"> |
| 522 | - if !archived { | 526 | + <h2>(g::t(lang, K::Mirrors))</h2> |
| 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 | - } | | |
| 565 | if archived && empty { | 527 | if archived && empty { |
| 566 | - <div class="row-line"> | 528 | + <p class="state">(g::t(lang, K::NoMirrors))</p> |
| 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> | | |
| 572 | } | 529 | } |
| 573 | for row in rows.iter() { | 530 | for row in rows.iter() { |
| 574 | - <div class="row-line"> | 531 | + <div class="line" data-kb-row=""> |
| 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> | 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> |
| 576 | - <div class="row-main"> | 533 | + <span class="val"> |
| 577 | - <strong class="row-name"> | 534 | + (row.direction)" · "(row.interval.as_str()) |
| 578 | - <span class=(row.dot_class) role="img" aria-label=(row.status_text) title=(row.status_text)></span> | 535 | + if !row.enabled { |
| 579 | - <a class="mirror-url" href=(row.href.as_str())>(row.url.as_str())</a> | 536 | + " · "(adm::t(lang, adm::K::Disabled)) |
| 580 | - </strong> | 537 | + } |
| 581 | - <p class="row-status"> | 538 | + " · " |
| 582 | - (row.direction)" · "(row.interval.as_str()) | 539 | + if row.last_sync_at.is_empty() { |
| 583 | - if !row.enabled { | 540 | + (g::t(lang, K::StatusNotRun)) |
| 584 | - " · "(adm::t(lang, adm::K::Disabled)) | 541 | + } else { |
| 585 | - } | 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) |
| 586 | - " · " | 543 | + } |
| 587 | - if row.last_sync_at.is_empty() { | 544 | + </span> |
| 588 | - (g::t(lang, K::StatusNotRun)) | 545 | + </div> |
| 589 | - } else { | 546 | + if !archived || !row.error.is_empty() { |
| 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) | 547 | + <div class="acts"> |
| 591 | - } | 548 | + if !archived { |
| 592 | - </p> | 549 | + post_act(label: g::t(lang, K::SyncNow), action: row.sync_action.as_str(), csrf: csrf.as_str()) |
| | 550 | + } |
| 593 | if !row.error.is_empty() { | 551 | if !row.error.is_empty() { |
| 594 | - <details class="mirror-failure"> | 552 | + reveal(label: g::t(lang, K::ErrorLabel), |
| 595 | - <summary>(g::t(lang, K::ErrorLabel))</summary> | | |
| 596 | <pre class="mirror-error">(row.error.as_str())</pre> | 553 | <pre class="mirror-error">(row.error.as_str())</pre> |
| 597 | - </details> | 554 | + ) |
| 598 | } | 555 | } |
| 599 | </div> | 556 | </div> |
| 600 | - if !archived { | 557 | + } |
| 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> | | |
| 607 | } | 558 | } |
| 608 | </section> | 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 | let current_url = redacted_url(&mirror.url); | 814 | let current_url = redacted_url(&mirror.url); |
| 829 | Ok(view! { | 815 | Ok(view! { |
| 830 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, | 816 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, |
| 831 | - <section class="card"> | 817 | + if archived { |
| 832 | - <h2>(mirror_kind(lang, mirror.direction))</h2> | 818 | + <section class="sec"> |
| 833 | - if archived { | 819 | + <h2>(mirror_kind(lang, mirror.direction))</h2> |
| 834 | - <p><code>(current_url.as_str())</code></p> | 820 | + <p class="state"><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> | 821 | + <p class="hint">(g::t(lang, K::LastSync))" " rel_time_or_never(lang: lang, stamp: mirror.last_sync_at.as_deref())</p> |
| 836 | if let Some(error) = mirror.last_error.clone() { | 822 | if let Some(error) = mirror.last_error.clone() { |
| 837 | <pre class="mirror-error">(error.as_str())</pre> | 823 | <pre class="mirror-error">(error.as_str())</pre> |
| 838 | } | 824 | } |
| 839 | - } else { | 825 | + </section> |
| 840 | - mirror_form(action: edit_action.clone(), csrf: csrf.clone(), pull: pull, | 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 | current_url: current_url.clone(), url: String::new(), username: draft.username, | 830 | current_url: current_url.clone(), url: String::new(), username: draft.username, |
| 842 | has_secret: mirror.has_secret, interval: draft.interval, enabled: Some(draft.enabled), | 831 | has_secret: mirror.has_secret, interval: draft.interval, enabled: Some(draft.enabled), |
| 843 | error: draft.error, submit: g::t(lang, K::SaveMirror), direction: "", lang: lang) | 832 | error: draft.error, submit: g::t(lang, K::SaveMirror), direction: "", lang: lang) |
| 844 | - } | 833 | + </section> |
| 845 | - </section> | 834 | + } |
| 846 | if !archived { | 835 | if !archived { |
| 847 | - <section class="card"> | 836 | + <section class="sec"> |
| 848 | <h2>(g::t(lang, K::SyncHeading))</h2> | 837 | <h2>(g::t(lang, K::SyncHeading))</h2> |
| 849 | - <p class="muted small">(g::t(lang, K::SyncIntro))</p> | 838 | + <p class="hint">(g::t(lang, K::SyncIntro))</p> |
| 850 | - <form method="post" action=(sync_action.as_str()) class="inline-form"> | 839 | + <div class="acts"> |
| 851 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 840 | + post_act(label: g::t(lang, K::SyncNow), action: sync_action.as_str(), csrf: csrf.as_str()) |
| 852 | - <button type="submit">(g::t(lang, K::SyncNow))</button> | 841 | + </div> |
| 853 | - </form> | | |
| 854 | </section> | 842 | </section> |
| 855 | - <section class="card"> | 843 | + <section class="sec"> |
| 856 | <h2>(g::t(lang, K::DeleteMirror))</h2> | 844 | <h2>(g::t(lang, K::DeleteMirror))</h2> |
| 857 | - <p class="muted small">(delete_text)</p> | 845 | + <p class="hint">(delete_text)</p> |
| 858 | - <div> | 846 | + <div class="acts"> |
| 859 | - <details class="confirm-inline"> | 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())) |
| 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> | | |
| 871 | </div> | 848 | </div> |
| 872 | </section> | 849 | </section> |
| 873 | } | 850 | } |
| @@ -25,6 +25,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 25 | use crate::pages::repo_settings::settings_frame; | 25 | use crate::pages::repo_settings::settings_frame; |
| 26 | use crate::pages::repo_settings_live::settings_head; | 26 | use crate::pages::repo_settings_live::settings_head; |
| 27 | use crate::state::AppState; | 27 | use crate::state::AppState; |
| | 28 | +use crate::views::parts::reveal; |
| 28 | use crate::views::{alert, shell}; | 29 | use crate::views::{alert, shell}; |
| 29 | | 30 | |
| 30 | path_param!(owner); | 31 | path_param!(owner); |
| @@ -125,61 +126,49 @@ async fn rename_body( |
| 125 | repo_head(head: head) | 126 | repo_head(head: head) |
| 126 | settings_frame(lang: lang, title: nav_title, current: "rename", can_delete: can_delete, | 127 | settings_frame(lang: lang, title: nav_title, current: "rename", can_delete: can_delete, |
| 127 | if let Some(key) = notice { | 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 | + <section class="sec"> |
| 131 | - <div class="row-line"> | 132 | + <h2>(g::t(lang, K::RenameRepo))</h2> |
| 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 | + <p class="hint">(g::t(lang, K::RenameHelp))</p> |
| 133 | - <div class="row-main"> | 134 | + <div class="acts"> |
| 134 | - <h2 class="row-title">(g::t(lang, K::RenameRepo))</h2> | 135 | + reveal(label: g::t(lang, K::RenameRepo), open: rename_open, |
| 135 | - <p class="row-status">(g::t(lang, K::RenameHelp))</p> | 136 | + if let Some(message) = rename_error { |
| 136 | - </div> | 137 | + alert(message: message.as_str()) |
| 137 | - <details class="row-action" open=(rename_open)> | 138 | + } |
| 138 | - <summary>(g::t(lang, K::RenameRepo))</summary> | 139 | + <form method="post" action=(rename_action.as_str()) class="fields"> |
| 139 | - <div class="row-panel"> | 140 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 140 | - if let Some(message) = rename_error { | 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 | alert(message: message.as_str()) | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 160 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 145 | - <label> | 161 | + <div class="field"> |
| 146 | - <span>(g::t(lang, K::NewName))</span> | 162 | + <label for="transfer-owner">(g::t(lang, K::NewOwnerLabel))</label> |
| 147 | - <input type="text" name="name" value=(rename_name.as_str()) autocomplete="off" spellcheck="false" required=(true)> | 163 | + <input id="transfer-owner" type="text" name="new_owner" value=(transfer_owner.as_str()) autocomplete="off" spellcheck="false" required=(true)> |
| 148 | - </label> | 164 | + </div> |
| 149 | - <button type="submit">(g::t(lang, K::RenameRepo))</button> | 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 | </form> | 170 | </form> |
| 151 | - </div> | 171 | + ) |
| 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> | | |
| 183 | </div> | 172 | </div> |
| 184 | </section> | 173 | </section> |
| 185 | } | 174 | } |
| @@ -18,11 +18,13 @@ use crate::audit::{self, Actor, Target}; |
| 18 | use crate::auth::{require_csrf, require_user}; | 18 | use crate::auth::{require_csrf, require_user}; |
| 19 | use crate::i18n::repo_admin::{self as g, K}; | 19 | use crate::i18n::repo_admin::{self as g, K}; |
| 20 | use crate::i18n::{self, Lang}; | 20 | use crate::i18n::{self, Lang}; |
| | 21 | +use crate::pages::passkeys; |
| 21 | use crate::pages::repo::repo_head; | 22 | use crate::pages::repo::repo_head; |
| 22 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | 23 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 23 | use crate::pages::repo_settings::settings_frame; | 24 | use crate::pages::repo_settings::settings_frame; |
| 24 | use crate::pages::repo_settings_live::settings_head; | 25 | use crate::pages::repo_settings_live::settings_head; |
| 25 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| | 27 | +use crate::views::parts::{confirm_act, reveal}; |
| 26 | use crate::views::{alert, enc, rel_time, shell}; | 28 | use crate::views::{alert, enc, rel_time, shell}; |
| 27 | | 29 | |
| 28 | path_param!(owner); | 30 | path_param!(owner); |
| @@ -166,19 +168,20 @@ async fn frame_top( |
| 166 | if is_error { | 168 | if is_error { |
| 167 | alert(message: text) | 169 | alert(message: text) |
| 168 | } else { | 170 | } else { |
| 169 | - <section class="card notice" role="status">(text)</section> | 171 | + <p class="state" role="status">(text)</p> |
| 170 | } | 172 | } |
| 171 | } | 173 | } |
| 172 | if archived { | 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 | (child) | 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. | 182 | +/// The add topic (a form that opens in place, closed to archived repos), then the list of secret |
| 181 | -/// `draft_name` and `error` come from a refused add; the value is never passed back, so the textarea is always empty. | 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 | #[component] | 185 | #[component] |
| 183 | async fn secrets_body( | 186 | async fn secrets_body( |
| 184 | lang: Lang, | 187 | lang: Lang, |
| @@ -196,69 +199,64 @@ async fn secrets_body( |
| 196 | let add_open = error.is_some(); | 199 | let add_open = error.is_some(); |
| 197 | Ok(view! { | 200 | Ok(view! { |
| 198 | frame_top(lang: lang, head: head, title: title.clone(), notice: notice, archived: archived, | 201 | frame_top(lang: lang, head: head, title: title.clone(), notice: notice, archived: archived, |
| 199 | - <section class="card rows-pane"> | 202 | + if !archived { |
| 200 | - if !archived { | 203 | + <section class="sec"> |
| 201 | - <div class="row-line" id="add-secret"> | 204 | + <h2>(g::t(lang, K::AddOrUpdate))</h2> |
| 202 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 205 | + <div class="acts"> |
| 203 | - <div class="row-main"> | 206 | + reveal(label: g::t(lang, K::SaveSecret), id: Some("add-secret"), open: add_open, |
| 204 | - <h2 class="row-title">(g::t(lang, K::AddOrUpdate))</h2> | 207 | + if let Some(message) = error { |
| 205 | - if rows.is_empty() { | 208 | + alert(message: message.as_str()) |
| 206 | - <p class="row-status">(g::t(lang, K::NoSecrets))</p> | | |
| 207 | - } else { | | |
| 208 | - <p class="row-status">(g::t(lang, K::SecretsHelp))</p> | | |
| 209 | } | 209 | } |
| 210 | - </div> | 210 | + <form method="post" action=(set_action.as_str()) class="fields"> |
| 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"> | | |
| 255 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 211 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 256 | - <input type="hidden" name="name" value=(row.name.as_str())> | 212 | + <div class="field"> |
| 257 | - <button type="submit" class="danger">(g::t(lang, K::Delete))</button> | 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 | </form> | 224 | </form> |
| 259 | - } | 225 | + ) |
| 260 | </div> | 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 | </section> | 260 | </section> |
| 263 | ) | 261 | ) |
| 264 | }) | 262 | }) |
| @@ -23,6 +23,7 @@ use crate::pages::repo::repo_head; |
| 23 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | 23 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 24 | use crate::pages::repo_settings_live::security_live_url; | 24 | use crate::pages::repo_settings_live::security_live_url; |
| 25 | use crate::state::AppState; | 25 | use crate::state::AppState; |
| | 26 | +use crate::views::parts::post_act; |
| 26 | use crate::views::{rel_time, shell}; | 27 | use crate::views::{rel_time, shell}; |
| 27 | | 28 | |
| 28 | path_param!(owner); | 29 | path_param!(owner); |
| @@ -58,7 +59,7 @@ struct AlertRow { |
| 58 | dismissed: bool, | 59 | dismissed: bool, |
| 59 | dismiss_action: String, | 60 | dismiss_action: String, |
| 60 | reopen_action: String, | 61 | reopen_action: String, |
| 61 | - fields: Vec<(&'static str, String)>, | 62 | + fields: Vec<(String, String)>, |
| 62 | } | 63 | } |
| 63 | | 64 | |
| 64 | fn title_of(ctx: &RepoCtx) -> String { | 65 | fn title_of(ctx: &RepoCtx) -> String { |
| @@ -101,10 +102,10 @@ fn row_of(alert: &Alert, title: &str, lang: Lang) -> AlertRow { |
| 101 | dismiss_action: format!("{base}/dismiss"), | 102 | dismiss_action: format!("{base}/dismiss"), |
| 102 | reopen_action: format!("{base}/reopen"), | 103 | reopen_action: format!("{base}/reopen"), |
| 103 | fields: vec![ | 104 | fields: vec![ |
| 104 | - ("advisory", key.advisory_id.clone()), | 105 | + ("advisory".to_owned(), key.advisory_id.clone()), |
| 105 | - ("ecosystem", key.ecosystem.clone()), | 106 | + ("ecosystem".to_owned(), key.ecosystem.clone()), |
| 106 | - ("package", key.package.clone()), | 107 | + ("package".to_owned(), key.package.clone()), |
| 107 | - ("version", key.version.clone()), | 108 | + ("version".to_owned(), key.version.clone()), |
| 108 | ], | 109 | ], |
| 109 | } | 110 | } |
| 110 | } | 111 | } |
| @@ -121,54 +122,39 @@ async fn security_body( |
| 121 | let open_count = rows.iter().filter(|r| r.open).count(); | 122 | let open_count = rows.iter().filter(|r| r.open).count(); |
| 122 | Ok(view! { | 123 | Ok(view! { |
| 123 | repo_head(head: head) | 124 | repo_head(head: head) |
| 124 | - <section class="card rows-pane"> | 125 | + <section class="sec"> |
| 125 | - <div class="row-line"> | 126 | + <h2>(i18n::t(lang, Key::Security))</h2> |
| 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 | + if !enabled { |
| 127 | - <div class="row-main"> | 128 | + <p class="state">(g::t(lang, K::SecurityOff))</p> |
| 128 | - <h2 class="row-title">(i18n::t(lang, Key::Security))</h2> | 129 | + } else { |
| 129 | - if !enabled { | 130 | + <p class="state">(g::dependencies_summary(lang, dependencies, open_count))</p> |
| 130 | - <p class="row-status">(g::t(lang, K::SecurityOff))</p> | 131 | + <p class="hint">(g::t(lang, K::LockfilesRead))</p> |
| 131 | - } else { | 132 | + } |
| 132 | - <p class="row-status">(g::dependencies_summary(lang, dependencies, open_count))</p> | 133 | + if rows.is_empty() { |
| 133 | - <p class="row-status">(g::t(lang, K::LockfilesRead))</p> | 134 | + <p class="state">(g::t(lang, K::NoAlerts))</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> | | |
| 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 | </section> | 158 | </section> |
| 173 | }) | 159 | }) |
| 174 | } | 160 | } |
| @@ -40,6 +40,7 @@ use crate::pages::repo::repo_head; |
| 40 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | 40 | use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 41 | use crate::pages::repo_settings_live::settings_head; | 41 | use crate::pages::repo_settings_live::settings_head; |
| 42 | use crate::state::AppState; | 42 | use crate::state::AppState; |
| | 43 | +use crate::views::parts::{confirm_act, post_act}; |
| 43 | use crate::views::{alert, enc, shell}; | 44 | use crate::views::{alert, enc, shell}; |
| 44 | | 45 | |
| 45 | path_param!(owner); | 46 | path_param!(owner); |
| @@ -254,9 +255,9 @@ async fn load_branch_names(ctx: &RepoCtx) -> Result<Vec<String>> { |
| 254 | pub async fn notice_banner_for(lang: Lang, title: Option<String>) -> Result<impl View> { | 255 | pub async fn notice_banner_for(lang: Lang, title: Option<String>) -> Result<impl View> { |
| 255 | Ok(view! { | 256 | Ok(view! { |
| 256 | if let Some(title) = title { | 257 | if let Some(title) = title { |
| 257 | - <section class="card notice" role="status"> | 258 | + <p class="state" role="status"> |
| 258 | (g::t(lang, K::RepoDeletedBefore))<code>(title)</code>(g::t(lang, K::RepoDeletedAfter)) | 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 | let action = format!("/{title}/settings/delete"); | 273 | let action = format!("/{title}/settings/delete"); |
| 273 | let open = error.is_some(); | 274 | let open = error.is_some(); |
| 274 | Ok(view! { | 275 | Ok(view! { |
| 275 | - <section class="card rows-pane security-danger"> | 276 | + <section class="sec"> |
| 276 | - <p class="security-danger-label">(g::t(lang, K::DangerZone))</p> | 277 | + <h2>(g::t(lang, K::DangerZone))</h2> |
| 277 | - <div class="row-line"> | 278 | + <p class="hint">(g::t(lang, K::DeleteRepoHelp))</p> |
| 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 | + <p class="hint">(g::t(lang, K::DeleteTrashHelp))</p> |
| 279 | - <div class="row-main"> | 280 | + <div class="acts"> |
| 280 | - <h2 class="row-title">(g::t(lang, K::DeleteRepo))</h2> | 281 | + <details class="reveal" open=(open)> |
| 281 | - <p class="row-status">(g::t(lang, K::DeleteRepoHelp))</p> | 282 | + <summary class="act danger">(g::t(lang, K::DeleteRepo))</summary> |
| 282 | - <p class="row-status">(g::t(lang, K::DeleteTrashHelp))</p> | 283 | + <div class="opened"> |
| 283 | - </div> | | |
| 284 | - <details class="row-action danger" open=(open)> | | |
| 285 | - <summary>(g::t(lang, K::DeleteRepo))</summary> | | |
| 286 | - <div class="row-panel"> | | |
| 287 | if let Some(message) = error { | 284 | if let Some(message) = error { |
| 288 | alert(message: message.as_str()) | 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 | <input type="hidden" name="csrf" value=(csrf)> | 288 | <input type="hidden" name="csrf" value=(csrf)> |
| 292 | - <label> | 289 | + <div class="field"> |
| 293 | - <span>(g::t(lang, K::TypeToConfirmBefore))<code>(title.clone())</code>(g::t(lang, K::TypeToConfirmAfter))</span> | 290 | + <label for="delete-confirm">(g::t(lang, K::TypeToConfirmBefore))<code>(title.clone())</code>(g::t(lang, K::TypeToConfirmAfter))</label> |
| 294 | - <input type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> | 291 | + <input id="delete-confirm" type="text" name="confirm" autocomplete="off" spellcheck="false" required=(true)> |
| 295 | - </label> | 292 | + </div> |
| 296 | - <button type="submit" class="danger">(g::t(lang, K::DeleteRepo))</button> | 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 | </form> | 297 | </form> |
| 298 | </div> | 298 | </div> |
| 299 | </details> | 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 | 305 | +/// The settings frame: the second-level links (`.sub`) above the page's own content (its children). |
| 306 | -/// right pane. Both fill the window below the repo head (see `.settings-layout` in `_lang_browse.scss`). | | |
| 307 | /// `current` names the section shown (`general`, `branches`, `webhooks`, ...) and gets `aria-current`. | 306 | /// `current` names the section shown (`general`, `branches`, `webhooks`, ...) and gets `aria-current`. |
| 308 | /// The General page's sections (`branches`, `discussions`, `danger`) are `?section=` links right after | 307 | /// The General page's sections (`branches`, `discussions`, `danger`) are `?section=` links right after |
| 309 | /// General; the danger link is only for a viewer who may delete the repo (`can_delete`). | 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 | let wiki = format!("/{title}/settings/wiki"); | 336 | let wiki = format!("/{title}/settings/wiki"); |
| 338 | let wiki_on = current == "wiki"; | 337 | let wiki_on = current == "wiki"; |
| 339 | Ok(view! { | 338 | Ok(view! { |
| 340 | - <div class="settings-layout fit-pane"> | 339 | + <nav class="sub" aria-label=(g::t(lang, K::SettingsNavLabel))> |
| 341 | - <nav class="settings-nav" aria-label=(g::t(lang, K::SettingsNavLabel))> | | |
| 342 | if general_on { | 340 | if general_on { |
| 343 | <a href=(general) aria-current="page">(g::t(lang, K::General))</a> | 341 | <a href=(general) aria-current="page">(g::t(lang, K::General))</a> |
| 344 | } else { | 342 | } else { |
| @@ -392,10 +390,7 @@ pub async fn settings_frame( |
| 392 | <a href=(wiki)>(crate::i18n::code::t(lang, crate::i18n::code::K::TabWiki))</a> | 390 | <a href=(wiki)>(crate::i18n::code::t(lang, crate::i18n::code::K::TabWiki))</a> |
| 393 | } | 391 | } |
| 394 | </nav> | 392 | </nav> |
| 395 | - <div class="settings-main"> | 393 | + (child) |
| 396 | - (child) | | |
| 397 | - </div> | | |
| 398 | - </div> | | |
| 399 | }) | 394 | }) |
| 400 | } | 395 | } |
| 401 | | 396 | |
| @@ -440,95 +435,56 @@ async fn general_section( |
| 440 | }) | 435 | }) |
| 441 | .collect(); | 436 | .collect(); |
| 442 | Ok(view! { | 437 | Ok(view! { |
| 443 | - <form method="post" action=(general_action) class="card rows-pane"> | 438 | + <section class="sec"> |
| 444 | - <label class="row-line row-field"> | 439 | + <h2>(g::t(lang, K::General))</h2> |
| 445 | - <span class="row-main"> | 440 | + <form method="post" action=(general_action) class="fields"> |
| 446 | - <span class="row-title">(g::t(lang, K::Description))</span> | 441 | + <div class="field"> |
| 447 | - <span class="row-status">(g::t(lang, K::DescriptionHelp))</span> | 442 | + <label for="repo-description">(g::t(lang, K::Description))</label> |
| 448 | - </span> | 443 | + <input id="repo-description" type="text" name="description" value=(description) maxlength="350" autocomplete="off"> |
| 449 | - <span class="row-control"> | 444 | + <p class="hint">(g::t(lang, K::DescriptionHelp))</p> |
| 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> | | |
| 459 | </div> | 445 | </div> |
| 460 | - } else { | 446 | + if options.is_empty() { |
| 461 | - <label class="row-line row-field"> | 447 | + <p class="state">(g::t(lang, K::DefaultBranch)) ": " (g::t(lang, K::NoBranchesYet))</p> |
| 462 | - <span class="row-main"> | 448 | + } else { |
| 463 | - <span class="row-title">(g::t(lang, K::DefaultBranch))</span> | 449 | + <div class="field"> |
| 464 | - </span> | 450 | + <label for="repo-default-branch">(g::t(lang, K::DefaultBranch))</label> |
| 465 | - <span class="row-control"> | 451 | + <select id="repo-default-branch" name="default_branch"> |
| 466 | - <select name="default_branch"> | | |
| 467 | for option in options.iter() { | 452 | for option in options.iter() { |
| 468 | <option value=(option.0.as_str()) selected=(option.1)>(option.0.as_str())</option> | 453 | <option value=(option.0.as_str()) selected=(option.1)>(option.0.as_str())</option> |
| 469 | } | 454 | } |
| 470 | </select> | 455 | </select> |
| 471 | - </span> | 456 | + </div> |
| 472 | - </label> | 457 | + } |
| 473 | - } | 458 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 474 | - <div class="row-foot"> | | |
| 475 | - <input type="hidden" name="csrf" value=(csrf.clone())> | | |
| 476 | <button type="submit" class="primary">(g::t(lang, K::SaveGeneral))</button> | 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 | </div> | 470 | </div> |
| 478 | - </form> | 471 | + </section> |
| 479 | | 472 | |
| 480 | - <section class="card rows-pane"> | 473 | + <section class="sec"> |
| 481 | - <div class="row-line"> | 474 | + <h2>(g::t(lang, K::ArchiveHeading))</h2> |
| 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> | 475 | + if archived { |
| 483 | - <div class="row-main"> | 476 | + <p class="hint">(g::t(lang, K::ArchivedHelp))</p> |
| 484 | - <h2 class="row-title">(g::t(lang, K::VisibilityHeading))</h2> | 477 | + <div class="acts"> |
| 485 | - <p class="row-status">(current_visibility)</p> | 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 | </div> | 480 | </div> |
| 487 | - <details class="row-action"> | 481 | + } else { |
| 488 | - <summary>(flip_label)</summary> | 482 | + <p class="hint">(g::t(lang, K::ArchiveHelp))</p> |
| 489 | - <div class="row-panel"> | 483 | + <div class="acts"> |
| 490 | - <p>(flip_confirm)</p> | 484 | + confirm_act(lang: lang, label: g::t(lang, K::ArchiveRepo), action: archive_action.as_str(), csrf: csrf.as_str(), |
| 491 | - <form method="post" action=(visibility_action) class="row-actions"> | 485 | + fields: vec![("archived".to_owned(), "1".to_owned())], note: Some(g::t(lang, K::ArchiveConfirm).to_owned())) |
| 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 | - } | | |
| 510 | </div> | 486 | </div> |
| 511 | - if archived { | 487 | + } |
| 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> | | |
| 532 | </section> | 488 | </section> |
| 533 | }) | 489 | }) |
| 534 | } | 490 | } |
| @@ -570,8 +526,8 @@ struct RulePill { |
| 570 | | 526 | |
| 571 | /// The pills that describe a rule in its card summary. A rule that sets nothing gets one muted pill. | 527 | /// The pills that describe a rule in its card summary. A rule that sets nothing gets one muted pill. |
| 572 | fn rule_pills(lang: Lang, rule: &BranchRule) -> Vec<RulePill> { | 528 | fn rule_pills(lang: Lang, rule: &BranchRule) -> Vec<RulePill> { |
| 573 | - let warn = "rule-pill warn"; | 529 | + let warn = "warn"; |
| 574 | - let plain = "rule-pill"; | 530 | + let plain = ""; |
| 575 | let mut pills = Vec::new(); | 531 | let mut pills = Vec::new(); |
| 576 | if rule.allow_force_push { | 532 | if rule.allow_force_push { |
| 577 | pills.push(pill(g::t(lang, K::ForcePushAllowed), warn)); | 533 | pills.push(pill(g::t(lang, K::ForcePushAllowed), warn)); |
| @@ -598,10 +554,10 @@ fn rule_pills(lang: Lang, rule: &BranchRule) -> Vec<RulePill> { |
| 598 | pills.push(pill(g::t(lang, K::RuleChangesShort), plain)); | 554 | pills.push(pill(g::t(lang, K::RuleChangesShort), plain)); |
| 599 | } | 555 | } |
| 600 | for check in &rule.required_checks { | 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 | if pills.is_empty() { | 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 | pills | 562 | pills |
| 607 | } | 563 | } |
| @@ -621,33 +577,10 @@ struct RuleCard { |
| 621 | draft: RuleDraft, | 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. | 580 | +/// The rule list: a line per rule, then a muted line for the default branch when no rule covers it, |
| 625 | -#[component] | 581 | +/// then the New rule line last. A rule opens in place with its rule's values, and the rule whose |
| 626 | -async fn switch_row( | 582 | +/// draft has an error opens with the draft instead. The New rule line opens with the draft when no |
| 627 | - name: String, | 583 | +/// rule takes it. The rows share one `name`, so opening one closes the rest. |
| 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. | | |
| 651 | #[component] | 584 | #[component] |
| 652 | async fn branch_rule_cards( | 585 | async fn branch_rule_cards( |
| 653 | lang: Lang, | 586 | lang: Lang, |
| @@ -662,47 +595,48 @@ async fn branch_rule_cards( |
| 662 | contexts: Vec<String>, | 595 | contexts: Vec<String>, |
| 663 | ) -> Result<impl View> { | 596 | ) -> Result<impl View> { |
| 664 | Ok(view! { | 597 | Ok(view! { |
| 665 | - <div class="rule-list"> | 598 | + <div> |
| 666 | for card in cards.iter() { | 599 | for card in cards.iter() { |
| 667 | - <details class="rule-row" name="branch-rule" open=(card.open)> | 600 | + <details class="row-open" name="branch-rule" open=(card.open)> |
| 668 | - <summary> | 601 | + <summary class="line"> |
| 669 | - <code class="rule-pattern">(card.draft.pattern.as_str())</code> | 602 | + <span class="name"><code>(card.draft.pattern.as_str())</code></span> |
| 670 | - <span class="rule-pills"> | 603 | + <span class="val rule-pills"> |
| 671 | for pill in card.pills.iter() { | 604 | for pill in card.pills.iter() { |
| 672 | <span class=(pill.class)>(pill.text.as_str())</span> | 605 | <span class=(pill.class)>(pill.text.as_str())</span> |
| 673 | } | 606 | } |
| 674 | </span> | 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 | </summary> | 608 | </summary> |
| 680 | - branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), | 609 | + <div class="opened"> |
| 681 | - delete_action: delete_action.clone(), rule_id: Some(card.id.clone()), | 610 | + branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), |
| 682 | - draft: card.draft.clone(), contexts: contexts.clone()) | 611 | + delete_action: delete_action.clone(), rule_id: Some(card.id.clone()), |
| | 612 | + draft: card.draft.clone(), contexts: contexts.clone()) |
| | 613 | + </div> |
| 683 | </details> | 614 | </details> |
| 684 | } | 615 | } |
| 685 | if builtin_row { | 616 | if builtin_row { |
| 686 | - <div class="rule-builtin"> | 617 | + <div class="line"> |
| 687 | - <code class="rule-pattern">(default_branch.as_str())</code> | 618 | + <span class="name"><code>(default_branch.as_str())</code></span> |
| 688 | - <span class="muted small">(g::t(lang, K::BuiltinRowText))</span> | 619 | + <span class="val">(g::t(lang, K::BuiltinRowText))</span> |
| 689 | </div> | 620 | </div> |
| 690 | } | 621 | } |
| 691 | - <details class="rule-row rule-new" name="branch-rule" open=(new_open)> | 622 | + <details class="row-open" name="branch-rule" open=(new_open)> |
| 692 | - <summary>"+ "(g::t(lang, K::NewRule))</summary> | 623 | + <summary class="line"> |
| 693 | - branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), | 624 | + <span class="name">"+ "(g::t(lang, K::NewRule))</span> |
| 694 | - delete_action: delete_action.clone(), rule_id: None, | 625 | + </summary> |
| 695 | - draft: new_draft, contexts: contexts.clone()) | 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 | </details> | 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 | </div> | 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 | 637 | +/// The rule form: the pattern, the pushes and merging switches, and the checks, with the save action |
| 703 | -/// the checks. Saving an existing pattern updates its rule. An existing rule also gets a Remove | 638 | +/// under them. 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 | 639 | +/// action, a confirm_act sibling of the rule form, because forms cannot nest. |
| 705 | -/// submits it through its `form` attribute. | | |
| 706 | #[component] | 640 | #[component] |
| 707 | async fn branch_rule_form( | 641 | async fn branch_rule_form( |
| 708 | lang: Lang, | 642 | lang: Lang, |
| @@ -725,87 +659,95 @@ async fn branch_rule_form( |
| 725 | required_checks, | 659 | required_checks, |
| 726 | error, | 660 | error, |
| 727 | } = draft; | 661 | } = draft; |
| 728 | - // The delete form's id and the rule id it posts, for an existing rule only. | 662 | + // Field ids are per rule, so two open rule forms never share an id. |
| 729 | - let remove = rule_id.map(|id| (format!("remove-rule-{id}"), 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 | Ok(view! { | 670 | Ok(view! { |
| 731 | - if let Some((remove_id, id)) = &remove { | 671 | + <form method="post" action=(save_action.as_str()) class="fields"> |
| 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"> | | |
| 738 | if let Some(message) = error { | 672 | if let Some(message) = error { |
| 739 | alert(message: message.as_str()) | 673 | alert(message: message.as_str()) |
| 740 | } | 674 | } |
| 741 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 675 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 742 | - <fieldset class="rule-section"> | 676 | + <div class="field"> |
| 743 | - <legend>(g::t(lang, K::SectionPattern))</legend> | 677 | + <label for=(pattern_id.as_str())>(g::t(lang, K::BranchPattern))</label> |
| 744 | - <input type="text" name="pattern" value=(pattern.as_str()) aria-label=(g::t(lang, K::BranchPattern)) autocomplete="off" spellcheck="false" required=(true)> | 678 | + <input id=(pattern_id.as_str()) type="text" name="pattern" value=(pattern.as_str()) 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> | 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 | </fieldset> | 698 | </fieldset> |
| 747 | - <div class="rule-pair"> | 699 | + <fieldset class="rule-group"> |
| 748 | - <fieldset class="rule-section"> | 700 | + <legend>(g::t(lang, K::SectionMerging))</legend> |
| 749 | - <legend>(g::t(lang, K::SectionPushes))</legend> | 701 | + <div class="field"> |
| 750 | - <div class="switch-list"> | 702 | + <label for=(approvals_id.as_str())>(g::t(lang, K::RequiredApprovals))</label> |
| 751 | - switch_row(name: "allow_force_push".to_owned(), checked: allow_force_push, | 703 | + <div class="runner-pill"> |
| 752 | - title: g::t(lang, K::AllowForcePush).to_owned(), | 704 | + <button type="button" class="runner-step" data-step="-1" aria-label=(passkeys::s(lang, "Fewer", "Azalt"))>"−"</button> |
| 753 | - description: Some(g::t(lang, K::ForcePushDesc).to_owned())) | 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())> |
| 754 | - switch_row(name: "allow_deletion".to_owned(), checked: allow_deletion, | 706 | + <button type="button" class="runner-step" data-step="1" aria-label=(passkeys::s(lang, "More", "Artır"))>"+"</button> |
| 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())) | | |
| 785 | </div> | 707 | </div> |
| 786 | - </fieldset> | 708 | + <p class="hint">(g::t(lang, K::ApprovalsHelp))</p> |
| 787 | - </div> | 709 | + </div> |
| 788 | - <fieldset class="rule-section"> | 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 | <legend>(g::t(lang, K::SectionChecks))</legend> | 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"> | 726 | + <div class="field"> |
| 791 | - <p class="muted small">(g::t(lang, K::RequiredChecksHelp))</p> | 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 | if !contexts.is_empty() { | 731 | if !contexts.is_empty() { |
| 793 | - <div class="context-picker"> | 732 | + <p class="hint">(g::t(lang, K::RecentContexts))</p> |
| 794 | - <span class="muted small">(g::t(lang, K::RecentContexts))</span> | 733 | + <div class="acts"> |
| 795 | for context in contexts.iter() { | 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 | </div> | 737 | </div> |
| 799 | } | 738 | } |
| 800 | </fieldset> | 739 | </fieldset> |
| 801 | - <div class="form-actions"> | 740 | + <div class="acts"> |
| 802 | <button type="submit" class="primary">(g::t(lang, K::SaveRule))</button> | 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> | 742 | + <button type="button" class="act quiet" 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 | - } | | |
| 807 | </div> | 743 | </div> |
| 808 | </form> | 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 | if is_error { | 880 | if is_error { |
| 939 | alert(message: text) | 881 | alert(message: text) |
| 940 | } else { | 882 | } else { |
| 941 | - <section class="card notice" role="status">(text)</section> | 883 | + <p class="state" role="status">(text)</p> |
| 942 | } | 884 | } |
| 943 | } | 885 | } |
| 944 | if section == "general" { | 886 | if section == "general" { |
| @@ -947,9 +889,9 @@ async fn settings_body( |
| 947 | visibility: visibility, archived: archived) | 889 | visibility: visibility, archived: archived) |
| 948 | } | 890 | } |
| 949 | if section == "branches" { | 891 | if section == "branches" { |
| 950 | - <section class="settings-section settings-rules"> | 892 | + <section class="sec"> |
| 951 | <h2>(g::t(lang, K::BranchProtection))</h2> | 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 | branch_rule_cards(lang: lang, cards: cards, builtin_row: builtin_row, default_branch: default_branch.clone(), | 895 | branch_rule_cards(lang: lang, cards: cards, builtin_row: builtin_row, default_branch: default_branch.clone(), |
| 954 | new_draft: new_draft, new_open: new_open, csrf: csrf.clone(), save_action: rules_action, | 896 | new_draft: new_draft, new_open: new_open, csrf: csrf.clone(), save_action: rules_action, |
| 955 | delete_action: delete_action, contexts: contexts) | 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 | 455 | +/// The README pane's header line: the license, the size and the top language, as text beside the |
| 456 | -/// right end. The full language split is the title. Nothing when the tree has no facts. | 456 | +/// file name. The full language split is the title. Nothing when the tree has no facts. |
| 457 | #[component] | 457 | #[component] |
| 458 | pub async fn readme_meta(lang: Lang, facts: Option<TreeFacts>) -> Result<impl View> { | 458 | pub async fn readme_meta(lang: Lang, facts: Option<TreeFacts>) -> Result<impl View> { |
| 459 | let facts = facts.unwrap_or_default(); | 459 | let facts = facts.unwrap_or_default(); |
| @@ -26,7 +26,8 @@ use crate::pages::repo::repo_head; |
| 26 | use crate::pages::repo_ctx::{RepoHead, load_repo}; | 26 | use crate::pages::repo_ctx::{RepoHead, load_repo}; |
| 27 | use crate::pages::repo_settings_live::{bump_settings, transfer_live_url}; | 27 | use crate::pages::repo_settings_live::{bump_settings, transfer_live_url}; |
| 28 | use crate::state::AppState; | 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 | path_param!(owner); | 32 | path_param!(owner); |
| 32 | path_param!(repo); | 33 | path_param!(repo); |
| @@ -74,40 +75,29 @@ async fn transfer_body( |
| 74 | ) -> Result<impl View> { | 75 | ) -> Result<impl View> { |
| 75 | Ok(view! { | 76 | Ok(view! { |
| 76 | repo_head(head: head) | 77 | repo_head(head: head) |
| 77 | - <section class="card"> | 78 | + <section class="sec"> |
| 78 | <h2>(g::t(lang, K::TransferTitle))</h2> | 79 | <h2>(g::t(lang, K::TransferTitle))</h2> |
| 79 | if let Some(summary) = summary.as_ref() { | 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 | + <p class="state">(summary.before.as_str()) rel_time(lang: lang, stamp: summary.expires_at.as_str()) (summary.after)</p> |
| 81 | - if let Some(action) = accept { | 82 | + <div class="acts"> |
| 82 | - <form method="post" action=(action.as_str()) class="stack"> | 83 | + if let Some(action) = accept { |
| 83 | - csrf_field(token: csrf.as_str()) | 84 | + post_act(label: g::t(lang, K::AcceptTransfer), action: action.as_str(), csrf: csrf.as_str()) |
| 84 | - <div> | 85 | + } |
| 85 | - <button type="submit">(g::t(lang, K::AcceptTransfer))</button> | 86 | + if let Some(action) = decline { |
| 86 | - </div> | 87 | + confirm_act(lang: lang, label: g::t(lang, K::DeclineTransfer), action: action.as_str(), csrf: csrf.as_str()) |
| 87 | - </form> | 88 | + } |
| 88 | - } | 89 | + if let Some(action) = cancel { |
| 89 | - if let Some(action) = decline { | 90 | + confirm_act(lang: lang, label: g::t(lang, K::CancelTransfer), action: action.as_str(), csrf: csrf.as_str()) |
| 90 | - <form method="post" action=(action.as_str()) class="stack"> | 91 | + } |
| 91 | - csrf_field(token: csrf.as_str()) | 92 | + </div> |
| 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 | - } | | |
| 105 | } | 93 | } |
| 106 | if summary.is_none() { | 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 | if let Some(href) = settings { | 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 | </section> | 102 | </section> |
| 113 | }) | 103 | }) |
| @@ -297,25 +287,17 @@ pub(crate) async fn transfer_list_for( |
| 297 | .collect(); | 287 | .collect(); |
| 298 | Ok(view! { | 288 | Ok(view! { |
| 299 | if !rows.is_empty() { | 289 | if !rows.is_empty() { |
| 300 | - <section class="card notif-group"> | 290 | + <section class="sec"> |
| 301 | - <header class="notif-group-head"> | 291 | + <h2>(g::t(lang, K::RepoTransfers))</h2> |
| 302 | - <h2>(g::t(lang, K::RepoTransfers))</h2> | 292 | + for row in rows.into_iter() { |
| 303 | - </header> | 293 | + <div class="line" data-kb-row=""> |
| 304 | - <ul class="notif-list"> | 294 | + <span class="name">(row.line.as_str())</span> |
| 305 | - for row in rows.into_iter() { | 295 | + </div> |
| 306 | - <li> | 296 | + <div class="acts"> |
| 307 | - <span class="notif-title">(row.line.as_str())</span> | 297 | + post_act(label: g::t(lang, K::Accept), action: row.accept.as_str(), csrf: csrf.as_str()) |
| 308 | - <form method="post" action=(row.accept.as_str()) class="notif-inline-form"> | 298 | + confirm_act(lang: lang, label: g::t(lang, K::Decline), action: row.decline.as_str(), csrf: csrf.as_str()) |
| 309 | - csrf_field(token: csrf.as_str()) | 299 | + </div> |
| 310 | - <button type="submit">(g::t(lang, K::Accept))</button> | 300 | + } |
| 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> | | |
| 319 | </section> | 301 | </section> |
| 320 | } | 302 | } |
| 321 | }) | 303 | }) |
| @@ -31,6 +31,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; |
| 31 | use crate::pages::repo_settings::settings_frame; | 31 | use crate::pages::repo_settings::settings_frame; |
| 32 | use crate::pages::repo_settings_live::settings_head; | 32 | use crate::pages::repo_settings_live::settings_head; |
| 33 | use crate::state::AppState; | 33 | use crate::state::AppState; |
| | 34 | +use crate::views::parts::{confirm_act, post_act, reveal}; |
| 34 | use crate::views::{alert, enc, now_unix, relative_time, shell}; | 35 | use crate::views::{alert, enc, now_unix, relative_time, shell}; |
| 35 | use crate::webhooks::client::{WebhookPolicy, validate_url}; | 36 | use crate::webhooks::client::{WebhookPolicy, validate_url}; |
| 36 | use crate::webhooks::emit::emit_ping; | 37 | use crate::webhooks::emit::emit_ping; |
| @@ -503,11 +504,11 @@ async fn frame_top( |
| 503 | if is_error { | 504 | if is_error { |
| 504 | alert(message: text) | 505 | alert(message: text) |
| 505 | } else { | 506 | } else { |
| 506 | - <section class="card notice" role="status">(text)</section> | 507 | + <p class="state" role="status">(text)</p> |
| 507 | } | 508 | } |
| 508 | } | 509 | } |
| 509 | if archived { | 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 | (child) | 513 | (child) |
| 513 | ) | 514 | ) |
| @@ -528,55 +529,41 @@ async fn hook_form( |
| 528 | lang: Lang, | 529 | lang: Lang, |
| 529 | ) -> Result<impl View> { | 530 | ) -> Result<impl View> { |
| 530 | Ok(view! { | 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 | if let Some(message) = error { | 533 | if let Some(message) = error { |
| 533 | alert(message: message.as_str()) | 534 | alert(message: message.as_str()) |
| 534 | } | 535 | } |
| 535 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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 | + <section class="sec"> |
| 537 | - <label class="row-line row-field"> | 538 | + <h2>(crate::pages::passkeys::s(lang, "Endpoint", "Uç nokta"))</h2> |
| 538 | - <span class="row-main"> | 539 | + <div class="field"> |
| 539 | - <span class="row-title">(g::t(lang, K::PayloadUrl))</span> | 540 | + <label for="hook-url">(g::t(lang, K::PayloadUrl))</label> |
| 540 | - <span class="row-status">(g::t(lang, K::UrlHintNew))</span> | 541 | + <input id="hook-url" type="url" name="url" value=(url.as_str()) autocomplete="off" spellcheck="false" required=(true)> |
| 541 | - </span> | 542 | + <p class="hint">(g::t(lang, K::UrlHintNew))</p> |
| 542 | - <span class="row-control"> | 543 | + </div> |
| 543 | - <input type="url" name="url" value=(url.as_str()) autocomplete="off" spellcheck="false" required=(true)> | 544 | + <div class="field"> |
| 544 | - </span> | 545 | + <label for="hook-secret">(g::t(lang, K::Secret))</label> |
| 545 | - </label> | 546 | + <input id="hook-secret" type="password" name="secret" autocomplete="new-password" maxlength="256"> |
| 546 | - <label class="row-line row-field"> | 547 | + <p class="hint">(secret_hint.as_str()) " " (g::t(lang, K::SignedWith))</p> |
| 547 | - <span class="row-main"> | 548 | + </div> |
| 548 | - <span class="row-title">(g::t(lang, K::Secret))</span> | 549 | + </section> |
| 549 | - <span class="row-status">(secret_hint.as_str()) (g::t(lang, K::SignedWith))</span> | 550 | + <section class="sec"> |
| 550 | - </span> | 551 | + <h2>(crate::pages::passkeys::s(lang, "Delivery", "Teslimat"))</h2> |
| 551 | - <span class="row-control"> | 552 | + <div class="field" role="group" aria-labelledby="hook-events-title"> |
| 552 | - <input type="password" name="secret" autocomplete="new-password" maxlength="256"> | 553 | + <p class="field-title" id="hook-events-title">(g::t(lang, K::Events))</p> |
| 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"> | | |
| 561 | for event in events.iter() { | 554 | for event in events.iter() { |
| 562 | - <label class="inline"> | 555 | + <label class="switch"> |
| 563 | <input type="checkbox" name=(event.name.as_str()) value="on" checked=(event.checked)> | 556 | <input type="checkbox" name=(event.name.as_str()) value="on" checked=(event.checked)> |
| 564 | <span>(event.label)</span> | 557 | <span>(event.label)</span> |
| 565 | </label> | 558 | </label> |
| 566 | } | 559 | } |
| 567 | - </span> | 560 | + </div> |
| 568 | - </div> | 561 | + <label class="switch"> |
| 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"> | | |
| 574 | <input type="checkbox" name="active" value="on" checked=(active)> | 562 | <input type="checkbox" name="active" value="on" checked=(active)> |
| 575 | - </span> | 563 | + <span>(g::t(lang, K::ActiveField))</span> |
| 576 | - </label> | 564 | + </label> |
| 577 | - <div class="row-foot"> | 565 | + </section> |
| 578 | - <button type="submit" class="primary">(submit)</button> | 566 | + <button type="submit" class="primary">(submit)</button> |
| 579 | - </div> | | |
| 580 | </form> | 567 | </form> |
| 581 | }) | 568 | }) |
| 582 | } | 569 | } |
| @@ -587,50 +574,52 @@ async fn hooks_list_body( |
| 587 | title: String, | 574 | title: String, |
| 588 | notice: Option<(&'static str, bool)>, | 575 | notice: Option<(&'static str, bool)>, |
| 589 | archived: bool, | 576 | archived: bool, |
| | 577 | + csrf: String, |
| 590 | rows: Vec<HookRow>, | 578 | rows: Vec<HookRow>, |
| 591 | lang: Lang, | 579 | lang: Lang, |
| 592 | ) -> Result<impl View> { | 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 | Ok(view! { | 585 | Ok(view! { |
| 595 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, | 586 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, |
| 596 | - <section class="card rows-pane"> | 587 | + <section class="sec"> |
| 597 | - <div class="row-line"> | 588 | + <h2>(g::t(lang, K::Webhooks))</h2> |
| 598 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 589 | + if empty { |
| 599 | - <div class="row-main"> | 590 | + <p class="state">(g::t(lang, K::NoWebhooks))</p> |
| 600 | - <h2 class="row-title">(g::t(lang, K::Webhooks))</h2> | 591 | + } else { |
| 601 | - if rows.is_empty() { | 592 | + <p class="hint">(g::t(lang, K::WebhooksIntro))</p> |
| 602 | - <p class="row-status">(g::t(lang, K::NoWebhooks))</p> | 593 | + } |
| 603 | - } else { | 594 | + if !archived { |
| 604 | - <p class="row-status">(g::t(lang, K::WebhooksIntro))</p> | 595 | + <div class="acts"> |
| 605 | - } | 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 | </div> | 601 | </div> |
| 607 | - if !archived { | 602 | + } |
| 608 | - <a href=(new_href.as_str()) class="button primary">(g::t(lang, K::AddWebhook))</a> | | |
| 609 | - } | | |
| 610 | - </div> | | |
| 611 | for row in rows.iter() { | 603 | for row in rows.iter() { |
| 612 | - <div class="row-line"> | 604 | + <a class="line" href=(row.href.as_str()) data-kb-row=""> |
| 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> | 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> |
| 614 | - <div class="row-main"> | 606 | + <span class="val"> |
| 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> | 607 | + if !row.events.is_empty() { |
| 616 | - <p class="row-status"> | 608 | + (row.events.as_str())" · " |
| 617 | - if !row.events.is_empty() { | 609 | + } |
| 618 | - (row.events.as_str())" · " | 610 | + if row.last_at.is_empty() { |
| 619 | - } | 611 | + (row.last_text) |
| 620 | - if row.last_at.is_empty() { | 612 | + } else { |
| 621 | - (row.last_text) | 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> |
| 622 | - } else { | 614 | + } |
| 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> | 615 | + if !row.problem.is_empty() { |
| 624 | - } | 616 | + " · "<span class="hook-problem">(row.problem)</span> |
| 625 | - if !row.problem.is_empty() { | 617 | + } |
| 626 | - " · "<span class="hook-problem">(row.problem)</span> | 618 | + if !row.active { |
| 627 | - } | 619 | + " · "(row.inactive_text) |
| 628 | - if !row.active { | 620 | + } |
| 629 | - " · "(row.inactive_text) | 621 | + </span> |
| 630 | - } | 622 | + </a> |
| 631 | - </p> | | |
| 632 | - </div> | | |
| 633 | - </div> | | |
| 634 | } | 623 | } |
| 635 | </section> | 624 | </section> |
| 636 | ) | 625 | ) |
| @@ -646,41 +635,33 @@ async fn delivery_list( |
| 646 | ) -> Result<impl View> { | 635 | ) -> Result<impl View> { |
| 647 | Ok(view! { | 636 | Ok(view! { |
| 648 | if deliveries.is_empty() { | 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 | for row in deliveries.iter() { | 640 | for row in deliveries.iter() { |
| 652 | - <details class="delivery"> | 641 | + <details class="row-open"> |
| 653 | - <summary> | 642 | + <summary class="line" data-kb-row=""> |
| 654 | - <span class=(format!("hook-state {}", row.state_class))>(row.state_text)</span> | 643 | + <span class="name"><span class=(format!("hook-state {}", row.state_class))>(row.state_text)</span> <code>(row.event.as_str())</code></span> |
| 655 | - " " | 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> |
| 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> | | |
| 663 | </summary> | 645 | </summary> |
| 664 | - <div class="delivery-body"> | 646 | + <div class="opened"> |
| 665 | - <p class="muted small">"Guid " <code>(row.guid.as_str())</code></p> | 647 | + <p class="hint">"Guid " <code>(row.guid.as_str())</code></p> |
| 666 | - <h4>(g::t(lang, K::RequestHeaders))</h4> | 648 | + <h3 class="part-title">(g::t(lang, K::RequestHeaders))</h3> |
| 667 | - <pre class="code-block">(row.request_headers.as_str())</pre> | 649 | + <pre class="code">(row.request_headers.as_str())</pre> |
| 668 | - <h4>(g::t(lang, K::RequestBody))</h4> | 650 | + <h3 class="part-title">(g::t(lang, K::RequestBody))</h3> |
| 669 | - <pre class="code-block">(row.request_body.as_str())</pre> | 651 | + <pre class="code">(row.request_body.as_str())</pre> |
| 670 | - <h4>(g::t(lang, K::Response))</h4> | 652 | + <h3 class="part-title">(g::t(lang, K::Response))</h3> |
| 671 | if !row.error.is_empty() { | 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> | 656 | + <p class="hint">(g::t(lang, K::Status))" " (row.status.as_str())</p> |
| 675 | - <h4>(g::t(lang, K::ResponseHeaders))</h4> | 657 | + <h3 class="part-title">(g::t(lang, K::ResponseHeaders))</h3> |
| 676 | - <pre class="code-block">(row.response_headers.as_str())</pre> | 658 | + <pre class="code">(row.response_headers.as_str())</pre> |
| 677 | - <h4>(g::t(lang, K::ResponseBody))</h4> | 659 | + <h3 class="part-title">(g::t(lang, K::ResponseBody))</h3> |
| 678 | - <pre class="code-block">(row.response_body.as_str())</pre> | 660 | + <pre class="code">(row.response_body.as_str())</pre> |
| 679 | if !archived { | 661 | if !archived { |
| 680 | - <form method="post" action=(row.redeliver_action.as_str()) class="inline-form"> | 662 | + <div class="acts"> |
| 681 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 663 | + post_act(label: g::t(lang, K::Redeliver), action: row.redeliver_action.as_str(), csrf: csrf.as_str()) |
| 682 | - <button type="submit">(g::t(lang, K::Redeliver))</button> | 664 | + </div> |
| 683 | - </form> | | |
| 684 | } | 665 | } |
| 685 | </div> | 666 | </div> |
| 686 | </details> | 667 | </details> |
| @@ -708,14 +689,10 @@ async fn hook_body( |
| 708 | Ok(view! { | 689 | Ok(view! { |
| 709 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, | 690 | frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang, |
| 710 | if archived { | 691 | if archived { |
| 711 | - <section class="card rows-pane"> | 692 | + <section class="sec"> |
| 712 | - <div class="row-line"> | 693 | + <h2>(crate::pages::passkeys::s(lang, "Endpoint", "Uç nokta"))</h2> |
| 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> | 694 | + <p class="state">(draft.url.as_str())</p> |
| 714 | - <div class="row-main"> | 695 | + <p class="hint">(g::t(lang, K::ArchivedHookNote))</p> |
| 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> | | |
| 719 | </section> | 696 | </section> |
| 720 | } else { | 697 | } else { |
| 721 | hook_form(action: edit_action.clone(), csrf: csrf.clone(), url: draft.url, | 698 | hook_form(action: edit_action.clone(), csrf: csrf.clone(), url: draft.url, |
| @@ -723,45 +700,25 @@ async fn hook_body( |
| 723 | error: draft.error, submit: g::t(lang, K::SaveWebhook), lang: lang) | 700 | error: draft.error, submit: g::t(lang, K::SaveWebhook), lang: lang) |
| 724 | } | 701 | } |
| 725 | if !archived { | 702 | if !archived { |
| 726 | - <section class="card rows-pane"> | 703 | + <section class="sec"> |
| 727 | - <div class="row-line"> | 704 | + <h2>(g::t(lang, K::Test))</h2> |
| 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> | 705 | + <p class="hint">(g::t(lang, K::TestIntro))</p> |
| 729 | - <div class="row-main"> | 706 | + <div class="acts"> |
| 730 | - <h2 class="row-title">(g::t(lang, K::Test))</h2> | 707 | + post_act(label: g::t(lang, K::SendTestPing), action: test_action.as_str(), csrf: csrf.as_str()) |
| 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> | | |
| 737 | </div> | 708 | </div> |
| 738 | </section> | 709 | </section> |
| 739 | } | 710 | } |
| 740 | - <section class="card"> | 711 | + <section class="sec"> |
| 741 | <h2>(g::t(lang, K::RecentDeliveries))</h2> | 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 | delivery_list(deliveries: deliveries, csrf: csrf.clone(), archived: archived, lang: lang) | 714 | delivery_list(deliveries: deliveries, csrf: csrf.clone(), archived: archived, lang: lang) |
| 744 | </section> | 715 | </section> |
| 745 | if !archived { | 716 | if !archived { |
| 746 | - <section class="card rows-pane security-danger"> | 717 | + <section class="sec"> |
| 747 | - <div class="row-line"> | 718 | + <h2>(g::t(lang, K::DeleteWebhook))</h2> |
| 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> | 719 | + <p class="hint">(g::t(lang, K::DeleteIntro))</p> |
| 749 | - <div class="row-main"> | 720 | + <div class="acts"> |
| 750 | - <h2 class="row-title">(g::t(lang, K::DeleteWebhook))</h2> | 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())) |
| 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> | | |
| 765 | </div> | 722 | </div> |
| 766 | </section> | 723 | </section> |
| 767 | } | 724 | } |
| @@ -775,7 +732,7 @@ async fn hooks_list_page(cx: &Cx) -> Result<impl View> { |
| 775 | let owner = path_param::<Owner>(cx); | 732 | let owner = path_param::<Owner>(cx); |
| 776 | let name = path_param::<Repo>(cx); | 733 | let name = path_param::<Repo>(cx); |
| 777 | let ctx = load_repo(cx, owner, name).await?; | 734 | let ctx = load_repo(cx, owner, name).await?; |
| 778 | - require_user(cx).await?; | 735 | + let (_, session) = require_user(cx).await?; |
| 779 | if !ctx.can_admin() { | 736 | if !ctx.can_admin() { |
| 780 | return Err(forbidden().into()); | 737 | return Err(forbidden().into()); |
| 781 | } | 738 | } |
| @@ -802,10 +759,11 @@ async fn hooks_list_page(cx: &Cx) -> Result<impl View> { |
| 802 | rows.push(hook_row(lang, tz, &frame.title, hook, last, &last_stamp)); | 759 | rows.push(hook_row(lang, tz, &frame.title, hook, last, &last_stamp)); |
| 803 | } | 760 | } |
| 804 | let notice = notice_from_query(cx, lang); | 761 | let notice = notice_from_query(cx, lang); |
| | 762 | + let csrf = session.csrf_token.clone(); |
| 805 | Ok(view! { | 763 | Ok(view! { |
| 806 | shell(title: frame.page_title.as_str(), viewer: ctx.viewer.as_ref(), | 764 | shell(title: frame.page_title.as_str(), viewer: ctx.viewer.as_ref(), |
| 807 | hooks_list_body(head: frame.head, title: frame.title, notice: notice, | 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 | let back = hooks_href(&title); | 804 | let back = hooks_href(&title); |
| 847 | Ok(view! { | 805 | Ok(view! { |
| 848 | frame_top(head: head, title: title.clone(), notice: None, archived: archived, lang: lang, | 806 | frame_top(head: head, title: title.clone(), notice: None, archived: archived, lang: lang, |
| 849 | - <section class="card rows-pane"> | 807 | + <section class="sec"> |
| 850 | - <div class="row-line"> | 808 | + <h2>(g::t(lang, K::AddWebhook))</h2> |
| 851 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 809 | + <p class="hint">(g::t(lang, K::AddWebhookIntro))</p> |
| 852 | - <div class="row-main"> | 810 | + <div class="acts"> |
| 853 | - <h2 class="row-title">(g::t(lang, K::AddWebhook))</h2> | 811 | + <a class="act quiet" href=(back.as_str())>(g::t(lang, K::BackToWebhooks))</a> |
| 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> | | |
| 857 | </div> | 812 | </div> |
| 858 | </section> | 813 | </section> |
| 859 | hook_form(action: action, csrf: csrf, url: draft.url, events: events, | 814 | hook_form(action: action, csrf: csrf, url: draft.url, events: events, |
| @@ -1766,7 +1721,10 @@ mod tests { |
| 1766 | assert!(body.contains(URL), "{body}"); | 1721 | assert!(body.contains(URL), "{body}"); |
| 1767 | assert!(body.contains("Add webhook"), "{body}"); | 1722 | assert!(body.contains("Add webhook"), "{body}"); |
| 1768 | assert!(body.contains("none yet"), "{body}"); | 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 | let (status, _, body) = send( | 1728 | let (status, _, body) = send( |
| 1771 | &fx.app, | 1729 | &fx.app, |
| 1772 | "GET", | 1730 | "GET", |
| @@ -13,6 +13,7 @@ use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; |
| 13 | use topcoat::router::request::uri; | 13 | use topcoat::router::request::uri; |
| 14 | use topcoat::router::response::Response; | 14 | use topcoat::router::response::Response; |
| 15 | use topcoat::router::{Body, StatusCode, page, path_param, route}; | 15 | use topcoat::router::{Body, StatusCode, page, path_param, route}; |
| | 16 | +use crate::views::parts::reveal; |
| 16 | use topcoat::view::{View, component, view}; | 17 | use topcoat::view::{View, component, view}; |
| 17 | | 18 | |
| 18 | use crate::auth::{current_user, require_user}; | 19 | use crate::auth::{current_user, require_user}; |
| @@ -23,7 +24,7 @@ use crate::notify; |
| 23 | use crate::pages::issue_parts::{ItemKind, check_write, may_change, parse_number}; | 24 | use crate::pages::issue_parts::{ItemKind, check_write, may_change, parse_number}; |
| 24 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; | 25 | use crate::pages::repo_ctx::{RepoCtx, load_repo}; |
| 25 | use crate::state::AppState; | 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 | path_param!(owner); | 29 | path_param!(owner); |
| 29 | path_param!(repo); | 30 | path_param!(repo); |
| @@ -209,34 +210,41 @@ pub(crate) async fn reviewers_box(lang: Lang, reviewers: ReviewersView) -> Resul |
| 209 | } = reviewers; | 210 | } = reviewers; |
| 210 | let message = error.map(|code| error_text(lang, code)); | 211 | let message = error.map(|code| error_text(lang, code)); |
| 211 | Ok(view! { | 212 | Ok(view! { |
| 212 | - <section class="issue-side-section reviewers-box" id="reviewers"> | 213 | + <section class="sec reviewers-box" id="reviewers"> |
| 213 | <h2>(ga::t(lang, AK::Reviewers))</h2> | 214 | <h2>(ga::t(lang, AK::Reviewers))</h2> |
| 214 | if let Some(message) = message { | 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 | if names.is_empty() { | 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 | for name in names.iter() { | 222 | for name in names.iter() { |
| 222 | - <li> | 223 | + <div class="line"> |
| 223 | - <a href=(format!("/{name}"))>(name.as_str())</a> | 224 | + <a class="name" href=(format!("/{name}"))>(name.as_str())</a> |
| 224 | if write { | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 227 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 227 | <input type="hidden" name="username" value=(name.as_str())> | 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 | </form> | 230 | </form> |
| 230 | } | 231 | } |
| 231 | - </li> | 232 | + </div> |
| 232 | } | 233 | } |
| 233 | - </ul> | 234 | + </div> |
| 234 | if write { | 235 | if write { |
| 235 | - <form method="post" action=(action.as_str()) class="stack"> | 236 | + <div class="acts"> |
| 236 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 237 | + reveal(label: ga::t(lang, AK::RequestReview), id: Some("request-review"), |
| 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 | + <form method="post" action=(action.as_str()) class="fields"> |
| 238 | - <div><button type="submit" name="action" value="request">(ga::t(lang, AK::RequestReview))</button></div> | 239 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 239 | - </form> | 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 | </section> | 249 | </section> |
| 242 | }) | 250 | }) |
| @@ -285,27 +293,23 @@ async fn review_requests(cx: &Cx) -> Result<impl View> { |
| 285 | let empty = rows.is_empty(); | 293 | let empty = rows.is_empty(); |
| 286 | Ok(view! { | 294 | Ok(view! { |
| 287 | shell(title: heading, viewer: Some(&viewer), | 295 | shell(title: heading, viewer: Some(&viewer), |
| 288 | - <section class="page-head" data-live="/review-requests/events"> | 296 | + <section data-live="/review-requests/events"> |
| 289 | - <h1>(heading)</h1> | 297 | + <h1 class="sr-only">(heading)</h1> |
| 290 | </section> | 298 | </section> |
| 291 | if empty { | 299 | if empty { |
| 292 | - <section class="card list-pane fit-pane"> | 300 | + <p class="state">(ga::t(lang, AK::NoReviewRequests))</p> |
| 293 | - empty_state(title: ga::t(lang, AK::NoReviewRequests)) | | |
| 294 | - </section> | | |
| 295 | } | 301 | } |
| 296 | if !empty { | 302 | if !empty { |
| 297 | - <section class="card list-pane fit-pane"> | 303 | + <div class="plain-rows"> |
| 298 | - <ul class="notif-list review-request-list"> | 304 | + for row in rows.iter() { |
| 299 | - for row in rows.iter() { | 305 | + <a class="line" href=(row.1.as_str()) data-kb-row=""> |
| 300 | - <li> | 306 | + <span class="name">(row.2.as_str())</span> |
| 301 | - <span class="muted small">(row.0.as_str())</span> | 307 | + <span class="val">(row.0.as_str())</span> |
| 302 | - <a class="notif-title" href=(row.1.as_str())>(row.2.as_str())</a> | 308 | + <span class="val">(row.3.as_str())</span> |
| 303 | - <span class="muted small">(row.3.as_str())</span> | 309 | + <span class="val">rel_time(lang: lang, stamp: row.4.as_str())</span> |
| 304 | - <span class="muted small">rel_time(lang: lang, stamp: row.4.as_str())</span> | 310 | + </a> |
| 305 | - </li> | 311 | + } |
| 306 | - } | 312 | + </div> |
| 307 | - </ul> | | |
| 308 | - </section> | | |
| 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 | 1 | +//! Page: appearance (`/settings/appearance`). The colour theme, the language, the sound alerts, and |
| 2 | -//! light and dark themes a background and an accent colour, and the side of the shell sidebar, | 2 | +//! for each of the light and dark themes a background and an accent colour, all stored per user. |
| 3 | -//! all stored per user. Every change | 3 | +//! Every change saves at once, so the form has no Save button. Anonymous visitors set the theme from |
| 4 | -//! saves at once, so the form has no Save button. Anonymous visitors set the theme from the footer | 4 | +//! the footer instead (see `pages/theme_cookie.rs`). Every POST checks the CSRF token first. |
| 5 | -//! instead (see `pages/theme_cookie.rs`). Every POST checks the CSRF token first. | | |
| 6 | | 5 | |
| 7 | use std::collections::HashMap; | 6 | use std::collections::HashMap; |
| 8 | | 7 | |
| @@ -35,9 +34,6 @@ pub const LANGUAGE_CODES: &[&str] = &["auto", "en", "tr"]; |
| 35 | /// Theme codes, in display order. | 34 | /// Theme codes, in display order. |
| 36 | const THEME_CODES: &[&str] = &["auto", "light", "dark"]; | 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 | /// The colour tabs, in display order: the light theme's colours, then the dark theme's. | 37 | /// The colour tabs, in display order: the light theme's colours, then the dark theme's. |
| 42 | const TAB_CODES: &[&str] = &["light", "dark"]; | 38 | const TAB_CODES: &[&str] = &["light", "dark"]; |
| 43 | | 39 | |
| @@ -169,7 +165,6 @@ struct AppearancePage { |
| 169 | tabs: Vec<Choice>, | 165 | tabs: Vec<Choice>, |
| 170 | light: ColourGroup, | 166 | light: ColourGroup, |
| 171 | dark: ColourGroup, | 167 | dark: ColourGroup, |
| 172 | - sidebar: Vec<Choice>, | | |
| 173 | /// Whether the run-finished tone is on: the sound switch's checked state. | 168 | /// Whether the run-finished tone is on: the sound switch's checked state. |
| 174 | sound_on: bool, | 169 | sound_on: bool, |
| 175 | } | 170 | } |
| @@ -180,14 +175,6 @@ pub fn sound_attr(prefs: Option<&HashMap<String, String>>) -> Option<&'static st |
| 180 | (stored == "on").then_some("on") | 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 | /// The label of a language code. The two native names stay as they are in every language. | 178 | /// The label of a language code. The two native names stay as they are in every language. |
| 192 | fn language_label(lang: Lang, code: &str) -> &'static str { | 179 | fn language_label(lang: Lang, code: &str) -> &'static str { |
| 193 | match code { | 180 | match code { |
| @@ -329,7 +316,7 @@ async fn colour_row(row: ColourRow) -> Result<impl View> { |
| 329 | "accent-swatch hue-swatch" | 316 | "accent-swatch hue-swatch" |
| 330 | }; | 317 | }; |
| 331 | Ok(view! { | 318 | Ok(view! { |
| 332 | - <div class="row-line row-field colour-line"> | 319 | + <div class="colour-line"> |
| 333 | <fieldset class="colour-picker" data-colour-row="true" data-kind=(kind) data-lightness=(lightness.as_str())> | 320 | <fieldset class="colour-picker" data-colour-row="true" data-kind=(kind) data-lightness=(lightness.as_str())> |
| 334 | <legend>(legend)</legend> | 321 | <legend>(legend)</legend> |
| 335 | <div class="colour-choices"> | 322 | <div class="colour-choices"> |
| @@ -439,107 +426,70 @@ async fn appearance_body(page: AppearancePage) -> Result<impl View> { |
| 439 | tabs, | 426 | tabs, |
| 440 | light, | 427 | light, |
| 441 | dark, | 428 | dark, |
| 442 | - sidebar, | | |
| 443 | sound_on, | 429 | sound_on, |
| 444 | } = page; | 430 | } = page; |
| 445 | Ok(view! { | 431 | Ok(view! { |
| 446 | - <div class="settings-layout"> | 432 | + <form id="appearance-form" method="post" action="/settings/appearance" class="appearance" data-appearance="true"> |
| 447 | - <section class="page-head"> | 433 | + <h1 class="sr-only">(g::t(lang, K::Appearance))</h1> |
| 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"> | | |
| 451 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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> | 435 | + <section class="sec"> |
| 453 | - <label class="row-line row-field"> | 436 | + <h2>(crate::pages::passkeys::s(lang, "Theme and language", "Tema ve dil"))</h2> |
| 454 | - <span class="row-main"> | 437 | + <div class="field-pair"> |
| 455 | - <span class="row-title">(g::t(lang, K::ThemeLabel))</span> | 438 | + <div class="field"> |
| 456 | - <span class="row-status">(g::t(lang, K::MatchSystemHelp))</span> | 439 | + <label for="theme">(g::t(lang, K::ThemeLabel))</label> |
| 457 | - </span> | 440 | + <select id="theme" name="theme" data-autosubmit="true"> |
| 458 | - <span class="row-control"> | 441 | + for choice in theme.into_iter() { |
| 459 | - <select name="theme" data-autosubmit="true"> | 442 | + <option value=(choice.value) selected=(choice.selected)>(choice.label)</option> |
| 460 | - for choice in theme.into_iter() { | 443 | + } |
| 461 | - <option value=(choice.value) selected=(choice.selected)>(choice.label)</option> | 444 | + </select> |
| 462 | - } | 445 | + <p class="hint">(g::t(lang, K::MatchSystemHelp))</p> |
| 463 | - </select> | 446 | + </div> |
| 464 | - </span> | 447 | + <div class="field"> |
| 465 | - </label> | 448 | + <label for="language">(g::t(lang, K::LanguageLabel))</label> |
| 466 | - <fieldset class="row-field colour-group" data-colour-group="true" data-tab=(tab)> | 449 | + <select id="language" name="language" data-autosubmit="true"> |
| 467 | - <legend class="row-title">(colours)</legend> | 450 | + for choice in language.into_iter() { |
| 468 | - <div class="segmented snippet-segmented colour-tabs" role="group"> | 451 | + <option value=(choice.value) selected=(choice.selected)>(choice.label)</option> |
| 469 | - for choice in tabs.into_iter() { | 452 | + } |
| 470 | - <label class="segment"> | 453 | + </select> |
| 471 | - <input type="radio" name="colour_tab" value=(choice.value) checked=(choice.selected) data-colour-tab=(choice.value)> | 454 | + </div> |
| 472 | - <span>(choice.label)</span> | | |
| 473 | - </label> | | |
| 474 | - } | | |
| 475 | </div> | 455 | </div> |
| 476 | - colour_panel(group: light) | 456 | + </section> |
| 477 | - colour_panel(group: dark) | 457 | + <section class="sec"> |
| 478 | - </fieldset> | 458 | + <h2>(colours)</h2> |
| 479 | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Layout and language", "Düzen ve dil"))</h2> | 459 | + <fieldset class="colour-group" data-colour-group="true" data-tab=(tab)> |
| 480 | - <label class="row-line row-field"> | 460 | + <legend class="sr-only">(colours)</legend> |
| 481 | - <span class="row-main"> | 461 | + <div class="tabs" role="group"> |
| 482 | - <span class="row-title">(g::t(lang, K::LanguageLabel))</span> | 462 | + for choice in tabs.into_iter() { |
| 483 | - </span> | 463 | + <label> |
| 484 | - <span class="row-control"> | 464 | + <input type="radio" name="colour_tab" value=(choice.value) checked=(choice.selected) data-colour-tab=(choice.value)> |
| 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"> | | |
| 502 | <span>(choice.label)</span> | 465 | <span>(choice.label)</span> |
| 503 | </label> | 466 | </label> |
| 504 | } | 467 | } |
| 505 | </div> | 468 | </div> |
| 506 | - </span> | 469 | + colour_panel(group: light) |
| 507 | - </div> | 470 | + colour_panel(group: dark) |
| 508 | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Sound alerts", "Sesli uyarılar"))</h2> | 471 | + </fieldset> |
| 509 | - <label class="row-line row-field sound-toggle"> | 472 | + </section> |
| 510 | - <span class="row-main"> | 473 | + <section class="sec"> |
| 511 | - <span class="row-title">(g::t(lang, K::SoundLabel))</span> | 474 | + <h2>(g::t(lang, K::SoundLabel))</h2> |
| 512 | - <span class="row-status">(g::t(lang, K::SoundSwitch))</span> | 475 | + <input type="hidden" name="sound_shown" value="1"> |
| 513 | - </span> | 476 | + <label class="switch"> |
| 514 | - <span class="row-control"> | 477 | + <input type="checkbox" name="sound" value="on" checked=(sound_on) data-autosubmit="true"> |
| 515 | - <input type="hidden" name="sound_shown" value="1"> | 478 | + <span>(g::t(lang, K::SoundSwitch))</span> |
| 516 | - <span class="sound-switch"> | 479 | + </label> |
| 517 | - <input type="checkbox" name="sound" value="on" checked=(sound_on) data-autosubmit="true" aria-label=(g::t(lang, K::SoundSwitch))> | 480 | + <p class="hint">(g::t(lang, K::SoundOwnRuns)) " · " (g::t(lang, K::SoundFootOwn))</p> |
| 518 | - <span class="sound-track"><span class="sound-knob"></span></span> | 481 | + <div class="line"> |
| 519 | - </span> | 482 | + <span class="name">(g::t(lang, K::SoundPassed))</span> |
| 520 | - </span> | 483 | + <span class="val">(g::t(lang, K::SoundPassedNote))</span> |
| 521 | - </label> | 484 | + <button type="button" class="act" data-sound-play="passed">(g::t(lang, K::SoundPlay))</button> |
| 522 | - <div class="row-line row-field"> | 485 | + </div> |
| 523 | - <span class="row-main"> | 486 | + <div class="line"> |
| 524 | - <span class="row-title">(g::t(lang, K::SoundPassed))</span> | 487 | + <span class="name">(g::t(lang, K::SoundFailed))</span> |
| 525 | - <span class="row-status">(g::t(lang, K::SoundPassedNote))</span> | 488 | + <span class="val">(g::t(lang, K::SoundFailedNote))</span> |
| 526 | - </span> | 489 | + <button type="button" class="act" data-sound-play="failed">(g::t(lang, K::SoundPlay))</button> |
| 527 | - <span class="row-control"> | 490 | + </div> |
| 528 | - <button type="button" class="btn" data-sound-play="passed">(g::t(lang, K::SoundPlay))</button> | 491 | + </section> |
| 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> | | |
| 541 | </form> | 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 | /// The side a viewer's stored value stands for. Anything but `right` is `left`, the default, which | 537 | /// The side a viewer's stored value stands for. Anything but `right` is `left`, the default, which |
| 588 | /// is also what the shell renders on `<html>` (see `views/mod.rs`). | 538 | /// is also what the shell renders on `<html>` (see `views/mod.rs`). |
| | 539 | +#[cfg(test)] |
| 589 | pub fn sidebar_stored(stored: &str) -> &'static str { | 540 | pub fn sidebar_stored(stored: &str) -> &'static str { |
| 590 | if stored == "right" { "right" } else { "left" } | 541 | if stored == "right" { "right" } else { "left" } |
| 591 | } | 542 | } |
| @@ -618,9 +569,6 @@ fn page_for( |
| 618 | tabs: choices(TAB_CODES, tab, |code| tab_label(lang, code)), | 569 | tabs: choices(TAB_CODES, tab, |code| tab_label(lang, code)), |
| 619 | light: colour_group(lang, false, &user.base_light, &user.accent), | 570 | light: colour_group(lang, false, &user.base_light, &user.accent), |
| 620 | dark: colour_group(lang, true, &user.base_dark, &user.accent_dark), | 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 | sound_on, | 572 | sound_on, |
| 625 | } | 573 | } |
| 626 | } | 574 | } |
| @@ -970,6 +918,5 @@ mod tests { |
| 970 | assert_eq!(sidebar_stored("right"), "right"); | 918 | assert_eq!(sidebar_stored("right"), "right"); |
| 971 | assert_eq!(sidebar_stored("left"), "left"); | 919 | assert_eq!(sidebar_stored("left"), "left"); |
| 972 | assert_eq!(sidebar_stored("bogus"), "left"); | 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 | let empty = exports.is_empty(); | 62 | let empty = exports.is_empty(); |
| 63 | let ttl_note = g::export_ttl_note(lang, exporter::EXPORT_TTL_DAYS); | 63 | let ttl_note = g::export_ttl_note(lang, exporter::EXPORT_TTL_DAYS); |
| 64 | Ok(view! { | 64 | Ok(view! { |
| 65 | - <section class="page-head"> | 65 | + <h1 class="sr-only">(g::t(lang, K::ExportTitle))</h1> |
| 66 | - <h1>(g::t(lang, K::ExportTitle))</h1> | | |
| 67 | - </section> | | |
| 68 | <div class="export-page" data-live=(live.as_deref()) data-live-state=(if building { "building" } else { "idle" })> | 66 | <div class="export-page" data-live=(live.as_deref()) data-live-state=(if building { "building" } else { "idle" })> |
| 69 | - <section class="card rows-pane"> | 67 | + <section class="sec"> |
| 70 | - <div class="row-line"> | 68 | + <h2>(crate::pages::passkeys::s(lang, "Archive", "Arşiv"))</h2> |
| 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> | 69 | + <p class="hint">(g::t(lang, K::ExportIntro))</p> |
| 72 | - <div class="row-main"> | 70 | + <p class="hint">(g::t(lang, K::ExportContents))</p> |
| 73 | - <h2 class="row-title">(crate::pages::passkeys::s(lang, "Archive", "Arşiv"))</h2> | 71 | + <p class="hint">(g::t(lang, K::ExportEmailNote)) " " (ttl_note.as_str())</p> |
| 74 | - <p class="row-status">(g::t(lang, K::ExportIntro))</p> | 72 | + <div class="acts"> |
| 75 | - <p class="row-status">(g::t(lang, K::ExportContents))</p> | 73 | + <form method="post" action="/settings/export" class="act-form"> |
| 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"> | | |
| 79 | csrf_field(token: csrf) | 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 | </form> | 76 | </form> |
| 82 | </div> | 77 | </div> |
| | 78 | + </section> |
| | 79 | + <section class="sec"> |
| | 80 | + <h2>(crate::pages::passkeys::s(lang, "Your archives", "Arşivleriniz"))</h2> |
| 83 | if empty { | 81 | if empty { |
| 84 | - <div class="row-line"> | 82 | + <p class="state">(g::t(lang, K::ExportNone))</p> |
| 85 | - <div class="row-main"> | | |
| 86 | - <p class="row-status">(g::t(lang, K::ExportNone))</p> | | |
| 87 | - </div> | | |
| 88 | - </div> | | |
| 89 | } | 83 | } |
| 90 | for export in exports.iter() { | 84 | for export in exports.iter() { |
| 91 | - <div class="row-line export-row"> | 85 | + <div class="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> | 86 | + <div class="line"> |
| 93 | - <div class="row-main"> | 87 | + <span class="name">(g::t(lang, K::ExportRequested)) " " rel_time(lang: lang, stamp: export.created_at.as_str())</span> |
| 94 | - <strong class="row-name">(g::t(lang, K::ExportRequested)) " " rel_time(lang: lang, stamp: export.created_at.as_str())</strong> | 88 | + <span class="val"> |
| 95 | - if export.state == ExportState::Ready { | 89 | + if export.state == ExportState::Ready { |
| 96 | - <p class="row-status"> | 90 | + (g::t(lang, K::ExportReady)) |
| 97 | - (g::t(lang, K::ExportSize)) ": " (human_size(lang, u64::try_from(export.size).unwrap_or(0))) | 91 | + } |
| 98 | - " · " (g::expires_label(lang)) " " rel_time(lang: lang, stamp: export.expires_at.as_str()) | 92 | + if export.state == ExportState::Building { |
| 99 | - </p> | 93 | + (g::t(lang, K::ExportBuilding)) |
| 100 | - } | 94 | + } |
| 101 | - if export.state == ExportState::Building { | 95 | + if export.state == ExportState::Failed { |
| 102 | - <progress class="import-progress export-progress"></progress> | 96 | + (g::t(lang, K::ExportFailed)) |
| 103 | - } | 97 | + } |
| 104 | - if let Some(message) = export.error.as_ref() { | 98 | + </span> |
| 105 | - alert(message: message.as_str()) | | |
| 106 | - } | | |
| 107 | </div> | 99 | </div> |
| 108 | if export.state == ExportState::Ready { | 100 | if export.state == ExportState::Ready { |
| 109 | - <span class="badge public">(g::t(lang, K::ExportReady))</span> | 101 | + <p class="hint"> |
| 110 | - <a class="button primary" href=(format!("/settings/export/{}/download", export.id))>(g::t(lang, K::ExportDownload))</a> | 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 | if export.state == ExportState::Building { | 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 { | 112 | + if let Some(message) = export.error.as_ref() { |
| 116 | - <span class="badge import-failed">(g::t(lang, K::ExportFailed))</span> | 113 | + alert(message: message.as_str()) |
| 117 | } | 114 | } |
| 118 | </div> | 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 | //! per user; a signed commit is badged Verified only when its signer's key is listed here. | 2 | //! per user; a signed commit is badged Verified only when its signer's key is listed here. |
| 3 | | 3 | |
| 4 | use forge_core::AuditAction; | 4 | use forge_core::AuditAction; |
| @@ -16,7 +16,9 @@ use crate::auth::{require_csrf, require_user}; |
| 16 | use crate::i18n::{self, Key, Lang, t}; | 16 | use crate::i18n::{self, Key, Lang, t}; |
| 17 | use crate::signatures; | 17 | use crate::signatures; |
| 18 | use crate::state::AppState; | 18 | use crate::state::AppState; |
| 19 | -use crate::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 | #[derive(Deserialize)] | 23 | #[derive(Deserialize)] |
| 22 | struct AddKeyForm { | 24 | struct AddKeyForm { |
| @@ -35,7 +37,7 @@ struct DeleteKeyForm { |
| 35 | } | 37 | } |
| 36 | | 38 | |
| 37 | #[component] | 39 | #[component] |
| 38 | -async fn gpg_view( | 40 | +pub(crate) async fn gpg_section( |
| 39 | lang: Lang, | 41 | lang: Lang, |
| 40 | csrf: &str, | 42 | csrf: &str, |
| 41 | keys: Vec<GpgKey>, | 43 | keys: Vec<GpgKey>, |
| @@ -43,69 +45,57 @@ async fn gpg_view( |
| 43 | error: Option<String>, | 45 | error: Option<String>, |
| 44 | available: bool, | 46 | available: bool, |
| 45 | ) -> Result<impl View> { | 47 | ) -> Result<impl View> { |
| | 48 | + let empty = keys.is_empty(); |
| | 49 | + let open = error.is_some(); |
| 46 | Ok(view! { | 50 | Ok(view! { |
| 47 | - <section class="page-head"> | 51 | + <section class="sec" id="gpg"> |
| 48 | - <h1>(t(lang, Key::GpgKeys))</h1> | 52 | + <h2>(t(lang, Key::GpgKeys))</h2> |
| 49 | - </section> | 53 | + if !available { |
| 50 | - if !available { | 54 | + <p class="hint">(t(lang, Key::GpgUnavailable))</p> |
| 51 | - <p class="notice">(t(lang, Key::GpgUnavailable))</p> | 55 | + } |
| 52 | - } | 56 | + if empty { |
| 53 | - <section class="card rows-pane"> | 57 | + <p class="state">(t(lang, Key::NoGpgKeys))</p> |
| 54 | - <div class="row-line"> | 58 | + } |
| 55 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 59 | + <div> |
| 56 | - <div class="row-main"> | 60 | + for key in keys.into_iter() { |
| 57 | - <h2 class="row-title">(t(lang, Key::AddGpgKeyTitle))</h2> | 61 | + <details class="row-open"> |
| 58 | - if keys.is_empty() { | 62 | + <summary class="line"> |
| 59 | - <p class="row-status">(t(lang, Key::NoGpgKeys))</p> | 63 | + <span class="name">(key.emails.join(", "))</span> |
| 60 | - } | 64 | + <span class="val">added_status(lang: lang, added: Some(key.created_at.as_str()), used: None)</span> |
| 61 | - </div> | 65 | + </summary> |
| 62 | - <details class="row-action" id="add-gpg-key" open=(error.is_some())> | 66 | + <div class="opened"> |
| 63 | - <summary>(t(lang, Key::AddKeyButton))</summary> | 67 | + <code class="hint">(key.fingerprint.clone())</code> |
| 64 | - <div class="row-panel"> | 68 | + <div class="acts"> |
| 65 | - if let Some(message) = error { | 69 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/gpg/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) |
| 66 | - alert(message: message.as_str()) | 70 | + </div> |
| 67 | - } | 71 | + </div> |
| 68 | - <form method="post" action="/settings/gpg" class="stack"> | 72 | + </details> |
| 69 | - <input type="hidden" name="csrf" value=(csrf)> | 73 | + } |
| 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> | | |
| 79 | </div> | 74 | </div> |
| 80 | - for key in keys.into_iter() { | 75 | + <div class="acts"> |
| 81 | - <div class="row-line"> | 76 | + reveal(label: t(lang, Key::AddKeyButton), id: Some("add-gpg-key"), open: open, |
| 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> | 77 | + if let Some(message) = error { |
| 83 | - <div class="row-main"> | 78 | + alert(message: message.as_str()) |
| 84 | - <strong class="row-name"><code>(key.fingerprint.clone())</code></strong> | 79 | + } |
| 85 | - <p class="row-status">(key.emails.join(", ")) " · " added_status(lang: lang, added: Some(key.created_at.as_str()), used: None)</p> | 80 | + <form method="post" action="/settings/gpg" class="fields"> |
| 86 | - </div> | | |
| 87 | - <form method="post" action="/settings/gpg/delete" class="row-form"> | | |
| 88 | <input type="hidden" name="csrf" value=(csrf)> | 81 | <input type="hidden" name="csrf" value=(csrf)> |
| 89 | - <input type="hidden" name="id" value=(key.id.clone())> | 82 | + <div class="field"> |
| 90 | - <button type="submit" class="danger">(t(lang, Key::Delete))</button> | 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 | </form> | 88 | </form> |
| 92 | - </div> | 89 | + ) |
| 93 | - } | 90 | + </div> |
| 94 | </section> | 91 | </section> |
| 95 | }) | 92 | }) |
| 96 | } | 93 | } |
| 97 | | 94 | |
| 98 | -#[page("/settings/gpg")] | 95 | +#[route(GET "/settings/gpg")] |
| 99 | -async fn gpg_page(cx: &Cx) -> Result<impl View> { | 96 | +async fn gpg_page(cx: &Cx) -> Result<SeeOther> { |
| 100 | - let viewer = require_user(cx).await?; | 97 | + require_user(cx).await?; |
| 101 | - let lang = i18n::lang(cx, Some(&viewer.0)); | 98 | + Ok(see_other("/settings/keys#gpg")) |
| 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 | - }) | | |
| 109 | } | 99 | } |
| 110 | | 100 | |
| 111 | #[page(POST "/settings/gpg")] | 101 | #[page(POST "/settings/gpg")] |
| @@ -137,7 +127,7 @@ async fn gpg_add(cx: &Cx, Form(form): Form<AddKeyForm>) -> Result<impl View> { |
| 137 | serde_json::Value::Null, | 127 | serde_json::Value::Null, |
| 138 | ) | 128 | ) |
| 139 | .await; | 129 | .await; |
| 140 | - return Err(see_other("/settings/gpg").into()); | 130 | + return Err(see_other("/settings/keys").into()); |
| 141 | } | 131 | } |
| 142 | Err(e) => match user_facing_message(&e) { | 132 | Err(e) => match user_facing_message(&e) { |
| 143 | Some(message) => message, | 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?; | 140 | + let draft = KeysDraft { |
| 151 | - let available = signatures::gpg_available(state).await; | 141 | + armored: form.armored.clone(), |
| 152 | - let csrf = viewer.1.csrf_token.clone(); | 142 | + gpg_error: Some(message), |
| | 143 | + ..KeysDraft::default() |
| | 144 | + }; |
| 153 | Ok(view! { | 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 | serde_json::Value::Null, | 170 | serde_json::Value::Null, |
| 179 | ) | 171 | ) |
| 180 | .await; | 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 | "the key survives refused deletes" | 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. | 160 | + // The GPG page now redirects to the keys page, which lists the key. |
| 161 | - let reply = call(&site, "GET", "/settings/gpg", Some(&cookie), None).await; | 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 | assert_eq!(reply.status, 200, "listing page"); | 171 | assert_eq!(reply.status, 200, "listing page"); |
| 163 | assert!( | 172 | assert!( |
| 164 | reply.body.contains(FINGERPRINT), | 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 | use base64::prelude::{BASE64_STANDARD, BASE64_STANDARD_NO_PAD, Engine as _}; | 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 | use serde::Deserialize; | 6 | use serde::Deserialize; |
| 6 | use sha2::{Digest, Sha256}; | 7 | use sha2::{Digest, Sha256}; |
| 7 | use topcoat::Result; | 8 | use topcoat::Result; |
| @@ -15,6 +16,9 @@ use crate::audit::{self, Actor, Target}; |
| 15 | use crate::auth::{require_csrf, require_user}; | 16 | use crate::auth::{require_csrf, require_user}; |
| 16 | use crate::i18n::{self, Key, Lang, t, unsupported_key_type}; | 17 | use crate::i18n::{self, Key, Lang, t, unsupported_key_type}; |
| 17 | use crate::state::AppState; | 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 | use crate::views::{added_status, alert, shell, user_facing_message}; | 22 | use crate::views::{added_status, alert, shell, user_facing_message}; |
| 19 | | 23 | |
| 20 | /// Algorithms accepted for web-registered keys. `ssh-rsa` is rejected with its own message. | 24 | /// Algorithms accepted for web-registered keys. `ssh-rsa` is rejected with its own message. |
| @@ -135,65 +139,95 @@ struct DeleteKeyForm { |
| 135 | id: String, | 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 | #[component] | 179 | #[component] |
| 139 | -async fn keys_view( | 180 | +async fn ssh_section( |
| 140 | lang: Lang, | 181 | lang: Lang, |
| 141 | csrf: &str, | 182 | csrf: &str, |
| 142 | keys: Vec<SshKey>, | 183 | keys: Vec<SshKey>, |
| 143 | public_key: &str, | 184 | public_key: &str, |
| 144 | error: Option<String>, | 185 | error: Option<String>, |
| 145 | ) -> Result<impl View> { | 186 | ) -> Result<impl View> { |
| | 187 | + let empty = keys.is_empty(); |
| | 188 | + let open = error.is_some(); |
| 146 | Ok(view! { | 189 | Ok(view! { |
| 147 | - <section class="page-head"> | 190 | + <section class="sec" id="ssh"> |
| 148 | - <h1>(t(lang, Key::SshKeys))</h1> | 191 | + <h2>(t(lang, Key::SshKeys))</h2> |
| 149 | - </section> | 192 | + if empty { |
| 150 | - <section class="card rows-pane"> | 193 | + <p class="state">(t(lang, Key::NoSshKeys))</p> |
| 151 | - <div class="row-line"> | 194 | + } |
| 152 | - <svg class="row-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg> | 195 | + <div> |
| 153 | - <div class="row-main"> | 196 | + for key in keys.into_iter() { |
| 154 | - <h2 class="row-title">(t(lang, Key::AddSshKeyTitle))</h2> | 197 | + <details class="row-open"> |
| 155 | - if keys.is_empty() { | 198 | + <summary class="line"> |
| 156 | - <p class="row-status">(t(lang, Key::NoSshKeys))</p> | 199 | + <span class="name">(key.title.clone())</span> |
| 157 | - } else { | 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> |
| 158 | - <p class="row-status">(t(lang, Key::PublicKeyHint))</p> | 201 | + </summary> |
| 159 | - } | 202 | + <div class="opened"> |
| 160 | - </div> | 203 | + <code class="hint">(key.fingerprint.clone())</code> |
| 161 | - <details class="row-action" id="add-key" open=(error.is_some())> | 204 | + <div class="acts"> |
| 162 | - <summary>(t(lang, Key::AddKeyButton))</summary> | 205 | + confirm_act(lang: lang, label: t(lang, Key::Delete), action: "/settings/keys/delete", csrf: csrf, fields: vec![("id".to_owned(), key.id.clone())]) |
| 163 | - <div class="row-panel"> | 206 | + </div> |
| 164 | - if let Some(message) = error { | 207 | + </div> |
| 165 | - alert(message: message.as_str()) | 208 | + </details> |
| 166 | - } | 209 | + } |
| 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> | | |
| 182 | </div> | 210 | </div> |
| 183 | - for key in keys.into_iter() { | 211 | + <div class="acts"> |
| 184 | - <div class="row-line"> | 212 | + reveal(label: t(lang, Key::AddKeyButton), id: Some("add-key"), open: open, |
| 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> | 213 | + if let Some(message) = error { |
| 186 | - <div class="row-main"> | 214 | + alert(message: message.as_str()) |
| 187 | - <strong class="row-name">(key.title.clone())</strong> | 215 | + } |
| 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> | 216 | + <form data-hard="true" method="post" action="/settings/keys" class="fields"> |
| 189 | - </div> | | |
| 190 | - <form method="post" action="/settings/keys/delete" class="row-form"> | | |
| 191 | <input type="hidden" name="csrf" value=(csrf)> | 217 | <input type="hidden" name="csrf" value=(csrf)> |
| 192 | - <input type="hidden" name="id" value=(key.id.clone())> | 218 | + <div class="field"> |
| 193 | - <button type="submit" class="danger">(t(lang, Key::Delete))</button> | 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 | </form> | 228 | </form> |
| 195 | - </div> | 229 | + ) |
| 196 | - } | 230 | + </div> |
| 197 | </section> | 231 | </section> |
| 198 | }) | 232 | }) |
| 199 | } | 233 | } |
| @@ -202,13 +236,9 @@ async fn keys_view( |
| 202 | async fn keys_page(cx: &Cx) -> Result<impl View> { | 236 | async fn keys_page(cx: &Cx) -> Result<impl View> { |
| 203 | let viewer = require_user(cx).await?; | 237 | let viewer = require_user(cx).await?; |
| 204 | let lang = i18n::lang(cx, Some(&viewer.0)); | 238 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 205 | - let keys = app_context::<AppState>(cx) | 239 | + let state = app_context::<AppState>(cx); |
| 206 | - .store | | |
| 207 | - .list_ssh_keys(&viewer.0.id) | | |
| 208 | - .await?; | | |
| 209 | - let csrf = viewer.1.csrf_token.clone(); | | |
| 210 | Ok(view! { | 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(); | 294 | + let draft = KeysDraft { |
| 265 | - | 295 | + public_key: form.public_key.clone(), |
| 266 | - let keys = store.list_ssh_keys(&viewer.0.id).await?; | 296 | + ssh_error: outcome.err(), |
| 267 | - let csrf = viewer.1.csrf_token.clone(); | 297 | + ..KeysDraft::default() |
| | 298 | + }; |
| 268 | Ok(view! { | 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 | use crate::i18n::push as push_text; | 18 | use crate::i18n::push as push_text; |
| 19 | use crate::i18n::{self, Key, Lang, t}; | 19 | use crate::i18n::{self, Key, Lang, t}; |
| 20 | use crate::state::AppState; | 20 | use crate::state::AppState; |
| | 21 | +use crate::views::parts::confirm_act; |
| 21 | use crate::views::{csrf_field, rel_time, shell}; | 22 | use crate::views::{csrf_field, rel_time, shell}; |
| 22 | | 23 | |
| 23 | #[query_params(error = bad_request)] | 24 | #[query_params(error = bad_request)] |
| @@ -69,108 +70,80 @@ async fn notifications_body(page: NotificationsPage) -> Result<impl View> { |
| 69 | // locked and the notes below say why. | 70 | // locked and the notes below say why. |
| 70 | let blocked = unverified_note.is_some() || server_note.is_some(); | 71 | let blocked = unverified_note.is_some() || server_note.is_some(); |
| 71 | Ok(view! { | 72 | Ok(view! { |
| 72 | - <div class="settings-layout"> | 73 | + <h1 class="sr-only">(t(lang, Key::Notifications))</h1> |
| 73 | - <section class="page-head"> | | |
| 74 | - <h1>(t(lang, Key::Notifications))</h1> | | |
| 75 | - </section> | | |
| 76 | if let Some(message) = notice { | 74 | if let Some(message) = notice { |
| 77 | - <section class="card notice" role="status"> | 75 | + <p class="state" role="status">(message.as_str())</p> |
| 78 | - <p>(message.as_str())</p> | | |
| 79 | - </section> | | |
| 80 | } | 76 | } |
| 81 | - <section class="card rows-pane"> | 77 | + <section class="sec" id="email"> |
| 82 | - <h2 class="rows-section">(crate::pages::passkeys::s(lang, "Email", "E-posta"))</h2> | 78 | + <h2>(crate::pages::passkeys::s(lang, "Email", "E-posta"))</h2> |
| 83 | <form id="notify-form" method="post" action="/settings/notifications" class="notify-form"> | 79 | <form id="notify-form" method="post" action="/settings/notifications" class="notify-form"> |
| 84 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 80 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 85 | </form> | 81 | </form> |
| 86 | - <label class="row-line row-field"> | 82 | + <label class="switch"> |
| 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> | 83 | + <input type="checkbox" form="notify-form" name="email_notifications" value="1" checked=(on) disabled=(blocked) data-autosubmit="true"> |
| 88 | - <span class="row-main"> | 84 | + <span>(t(lang, Key::EmailNotifyLabel))</span> |
| 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> | | |
| 101 | </label> | 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 | <noscript> | 93 | <noscript> |
| 103 | - <div class="row-foot"> | 94 | + <div class="acts"> |
| 104 | <button type="submit" form="notify-form" class="primary" disabled=(blocked)>(t(lang, Key::Save))</button> | 95 | <button type="submit" form="notify-form" class="primary" disabled=(blocked)>(t(lang, Key::Save))</button> |
| 105 | </div> | 96 | </div> |
| 106 | </noscript> | 97 | </noscript> |
| 107 | </section> | 98 | </section> |
| 108 | - <section class="card rows-pane push-card" data-push="true" data-live="/settings/notifications/push/events"> | 99 | + <section class="sec" id="device" data-push="true" data-live="/settings/notifications/push/events"> |
| 109 | - <div class="row-line"> | 100 | + <h2>(push_text::t(lang, push_text::K::DeviceHeading))</h2> |
| 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> | 101 | + <p class="state" data-push-state="on" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOn))</p> |
| 111 | - <div class="row-main"> | 102 | + <p class="state" data-push-state="off" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOff))</p> |
| 112 | - <h2 class="row-title">(push_text::t(lang, push_text::K::DeviceHeading))</h2> | 103 | + <p class="hint">(push_text::t(lang, push_text::K::DeviceHelp))</p> |
| 113 | - <p class="row-status">(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> |
| 114 | - <p class="row-status" data-push-state="on" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOn))</p> | 105 | + <p class="hint" role="note" data-push-state="https" hidden=(true)>(push_text::t(lang, push_text::K::DeviceNeedsHttps))</p> |
| 115 | - <p class="row-status" data-push-state="off" hidden=(true)>(push_text::t(lang, push_text::K::DeviceOff))</p> | 106 | + <p class="hint" role="note" data-push-state="ios" hidden=(true)>(push_text::t(lang, push_text::K::DeviceIosHint))</p> |
| 116 | - </div> | 107 | + <p class="hint" role="note" data-push-state="denied" hidden=(true)>(push_text::t(lang, push_text::K::DeviceDenied))</p> |
| 117 | - <div class="row-actions"> | 108 | + <p class="hint warn" role="alert" data-push-state="error" hidden=(true)>(push_text::t(lang, push_text::K::DeviceError))</p> |
| 118 | - <button type="button" class="primary" data-push-action="enable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOn))</button> | 109 | + <div class="acts"> |
| 119 | - <button type="button" data-push-action="disable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOff))</button> | 110 | + <button type="button" class="act" data-push-action="enable" hidden=(true)>(push_text::t(lang, push_text::K::TurnOn))</button> |
| 120 | - </div> | 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 | </div> | 116 | </div> |
| 122 | - <p class="notice" role="note" data-push-state="unsupported" hidden=(true)>(push_text::t(lang, push_text::K::DeviceUnsupported))</p> | 117 | + if !can_test { |
| 123 | - <p class="notice" role="note" data-push-state="https" hidden=(true)>(push_text::t(lang, push_text::K::DeviceNeedsHttps))</p> | 118 | + <p class="hint">(push_text::t(lang, push_text::K::TestNoDevices))</p> |
| 124 | - <p class="notice" role="note" data-push-state="ios" hidden=(true)>(push_text::t(lang, push_text::K::DeviceIosHint))</p> | 119 | + } |
| 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> | | |
| 140 | </section> | 120 | </section> |
| 141 | - <section class="card rows-pane"> | 121 | + <section class="sec" id="devices"> |
| 142 | - <div class="row-line"> | 122 | + <h2>(push_text::t(lang, push_text::K::DevicesHeading))</h2> |
| 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> | 123 | + if devices.is_empty() { |
| 144 | - <div class="row-main"> | 124 | + <p class="state">(push_text::t(lang, push_text::K::DevicesEmpty))</p> |
| 145 | - <h2 class="row-title">(push_text::t(lang, push_text::K::DevicesHeading))</h2> | 125 | + } |
| 146 | - if devices.is_empty() { | | |
| 147 | - <p class="row-status">(push_text::t(lang, push_text::K::DevicesEmpty))</p> | | |
| 148 | - } | | |
| 149 | - </div> | | |
| 150 | - </div> | | |
| 151 | for device in devices.into_iter() { | 126 | for device in devices.into_iter() { |
| 152 | - <div class="row-line"> | 127 | + <details class="row-open"> |
| 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> | 128 | + <summary class="line"> |
| 154 | - <div class="row-main"> | 129 | + <span class="name">(device.agent_label.as_str())</span> |
| 155 | - <strong class="row-name">(device.agent_label.as_str())</strong> | 130 | + <span class="val">(push_text::added_label(lang)) " " rel_time(lang: lang, stamp: device.created_at.as_str())</span> |
| 156 | - <p class="row-status">(push_text::added_label(lang)) " " rel_time(lang: lang, stamp: device.created_at.as_str())</p> | 131 | + </summary> |
| 157 | - <p class="row-status"> | 132 | + <div class="opened"> |
| | 133 | + <p class="hint"> |
| 158 | if let Some(stamp) = device.last_success_at.as_deref() { | 134 | if let Some(stamp) = device.last_success_at.as_deref() { |
| 159 | (push_text::last_delivered_label(lang)) " " rel_time(lang: lang, stamp: stamp) | 135 | (push_text::last_delivered_label(lang)) " " rel_time(lang: lang, stamp: stamp) |
| 160 | } else { | 136 | } else { |
| 161 | (push_text::t(lang, push_text::K::NeverDelivered)) | 137 | (push_text::t(lang, push_text::K::NeverDelivered)) |
| 162 | } | 138 | } |
| 163 | </p> | 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 | </div> | 143 | </div> |
| 165 | - <form method="post" action="/settings/notifications/push/remove" class="row-form"> | 144 | + </details> |
| 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> | | |
| 171 | } | 145 | } |
| 172 | </section> | 146 | </section> |
| 173 | - </div> | | |
| 174 | }) | 147 | }) |
| 175 | } | 148 | } |
| 176 | | 149 | |
| @@ -1,5 +1,5 @@ |
| 1 | //! Page: public profile (`/settings/profile`). One form saves the display name, the username | 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 | //! routes. Every POST checks the CSRF token first. | 3 | //! routes. Every POST checks the CSRF token first. |
| 4 | | 4 | |
| 5 | use std::sync::{Arc, OnceLock}; | 5 | use std::sync::{Arc, OnceLock}; |
| @@ -24,6 +24,7 @@ use crate::auth::{require_csrf, require_user}; |
| 24 | use crate::i18n::{self, Key, Lang, about_too_long, display_name_too_long, t}; | 24 | use crate::i18n::{self, Key, Lang, about_too_long, display_name_too_long, t}; |
| 25 | use crate::live::Topic; | 25 | use crate::live::Topic; |
| 26 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| | 27 | +use crate::views::parts::{confirm_act, reveal}; |
| 27 | use crate::views::{alert, avatar_url, shell, user_facing_message}; | 28 | use crate::views::{alert, avatar_url, shell, user_facing_message}; |
| 28 | | 29 | |
| 29 | /// Longest "about" text, in characters. | 30 | /// Longest "about" text, in characters. |
| @@ -137,100 +138,84 @@ async fn profile_body(page: ProfilePage) -> Result<impl View> { |
| 137 | has_avatar, | 138 | has_avatar, |
| 138 | zones, | 139 | zones, |
| 139 | } = page; | 140 | } = page; |
| | 141 | + let avatar_open = errors.avatar.is_some(); |
| 140 | Ok(view! { | 142 | Ok(view! { |
| 141 | - <div class="settings-layout"> | 143 | + <h1 class="sr-only">(t(lang, Key::Profile))</h1> |
| 142 | - <section class="page-head"> | | |
| 143 | - <h1>(t(lang, Key::Profile))</h1> | | |
| 144 | - </section> | | |
| 145 | if let Some(message) = notice { | 144 | if let Some(message) = notice { |
| 146 | - <section class="card notice" role="status"> | 145 | + <p class="state" role="status">(message)</p> |
| 147 | - <p>(message)</p> | | |
| 148 | - </section> | | |
| 149 | } | 146 | } |
| 150 | - <section class="card rows-pane"> | 147 | + <section class="sec"> |
| 151 | - <div class="row-line row-field profile-settings-avatar"> | 148 | + <h2>(t(lang, Key::Avatar))</h2> |
| 152 | - <img class="avatar profile-settings-avatar-img" src=(avatar_src.as_str()) alt=(t(lang, Key::AvatarAlt)) width="40" height="40"> | 149 | + <img class="avatar" src=(avatar_src.as_str()) alt=(t(lang, Key::AvatarAlt)) width="48" height="48"> |
| 153 | - <div class="row-main"> | 150 | + <p class="hint">(t(lang, Key::AvatarHint))</p> |
| 154 | - <h2 class="row-title">(t(lang, Key::Avatar))</h2> | 151 | + <div class="acts"> |
| 155 | - <p class="row-status">(t(lang, Key::AvatarHint))</p> | 152 | + reveal(label: t(lang, Key::UploadPhoto), open: avatar_open, |
| 156 | if let Some(message) = errors.avatar { | 153 | if let Some(message) = errors.avatar { |
| 157 | alert(message: message.as_str()) | 154 | alert(message: message.as_str()) |
| 158 | } | 155 | } |
| 159 | - </div> | 156 | + <form method="post" action="/settings/profile/avatar" enctype="multipart/form-data" class="fields"> |
| 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"> | | |
| 162 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 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)> | 158 | + <div class="field"> |
| 164 | - <label class="profile-settings-avatar-item" for="profile-settings-avatar-file">(t(lang, Key::UploadPhoto))</label> | 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 | <button type="submit" class="primary">(t(lang, Key::Upload))</button> | 162 | <button type="submit" class="primary">(t(lang, Key::Upload))</button> |
| 166 | </form> | 163 | </form> |
| 167 | - if has_avatar { | 164 | + ) |
| 168 | - <form method="post" action="/settings/profile/avatar/delete" class="row-form profile-settings-avatar-remove"> | 165 | + if has_avatar { |
| 169 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 166 | + confirm_act(lang: lang, label: t(lang, Key::RemovePhoto), action: "/settings/profile/avatar/delete", csrf: csrf.as_str()) |
| 170 | - <button type="submit" class="link-button">(t(lang, Key::RemovePhoto))</button> | 167 | + } |
| 171 | - </form> | | |
| 172 | - } | | |
| 173 | - </div> | | |
| 174 | </div> | 168 | </div> |
| 175 | - <form id="profile-form" method="post" action="/settings/profile" class="profile-form"> | 169 | + </section> |
| 176 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 170 | + <form id="profile-form" method="post" action="/settings/profile"> |
| 177 | - </form> | 171 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 178 | - <label class="row-line row-field"> | 172 | + <section class="sec"> |
| 179 | - <span class="row-main"> | 173 | + <div class="field"> |
| 180 | - <span class="row-title">(t(lang, Key::DisplayName))</span> | 174 | + <label for="profile-display-name">(t(lang, Key::DisplayName))</label> |
| 181 | - <span class="row-status" id="profile-display-name-hint">(t(lang, Key::DisplayNameHint))</span> | 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"> |
| 182 | - </span> | 176 | + <p class="hint" id="profile-display-name-hint">(t(lang, Key::DisplayNameHint))</p> |
| 183 | - <span class="row-control"> | 177 | + </div> |
| 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"> | 178 | + if let Some(message) = errors.display_name { |
| 185 | - </span> | 179 | + alert(message: message.as_str()) |
| 186 | - </label> | 180 | + } |
| 187 | - if let Some(message) = errors.display_name { | 181 | + </section> |
| 188 | - alert(message: message.as_str()) | 182 | + <section class="sec"> |
| 189 | - } | 183 | + <div class="field"> |
| 190 | - <label class="row-line row-field"> | 184 | + <label for="profile-username">(t(lang, Key::Username))</label> |
| 191 | - <span class="row-main"> | 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"> |
| 192 | - <span class="row-title">(t(lang, Key::Username))</span> | 186 | + <p class="hint" id="profile-username-hint">(t(lang, Key::UsernameHint))</p> |
| 193 | - <span class="row-status" id="profile-username-hint">(t(lang, Key::UsernameHint))</span> | 187 | + </div> |
| 194 | - </span> | 188 | + if let Some(message) = errors.username { |
| 195 | - <span class="row-control"> | 189 | + alert(message: message.as_str()) |
| 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"> | 190 | + } |
| 197 | - </span> | 191 | + </section> |
| 198 | - </label> | 192 | + <section class="sec"> |
| 199 | - if let Some(message) = errors.username { | 193 | + <div class="field"> |
| 200 | - alert(message: message.as_str()) | 194 | + <label for="profile-about">(t(lang, Key::About))</label> |
| 201 | - } | 195 | + <textarea id="profile-about" name="about" rows="6" maxlength="2000" aria-describedby="profile-about-hint">(draft.about.as_str())</textarea> |
| 202 | - <label class="row-line row-field"> | 196 | + <p class="hint" id="profile-about-hint">(t(lang, Key::AboutHint))</p> |
| 203 | - <span class="row-main"> | 197 | + </div> |
| 204 | - <span class="row-title">(t(lang, Key::About))</span> | 198 | + if let Some(message) = errors.about { |
| 205 | - <span class="row-status" id="profile-about-hint">(t(lang, Key::AboutHint))</span> | 199 | + alert(message: message.as_str()) |
| 206 | - </span> | 200 | + } |
| 207 | - <span class="row-control"> | 201 | + </section> |
| 208 | - <textarea id="profile-about" form="profile-form" name="about" rows="6" maxlength="2000" aria-describedby="profile-about-hint">(draft.about.as_str())</textarea> | 202 | + <section class="sec"> |
| 209 | - </span> | 203 | + <div class="field"> |
| 210 | - </label> | 204 | + <label for="profile-timezone">(t(lang, Key::Timezone))</label> |
| 211 | - if let Some(message) = errors.about { | 205 | + <select id="profile-timezone" name="timezone"> |
| 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"> | | |
| 220 | for zone in zones.into_iter() { | 206 | for zone in zones.into_iter() { |
| 221 | <option value=(zone.name.clone()) selected=(zone.selected)>(zone.name)</option> | 207 | <option value=(zone.name.clone()) selected=(zone.selected)>(zone.name)</option> |
| 222 | } | 208 | } |
| 223 | </select> | 209 | </select> |
| 224 | - </span> | 210 | + </div> |
| 225 | - </label> | 211 | + if let Some(message) = errors.timezone { |
| 226 | - if let Some(message) = errors.timezone { | 212 | + alert(message: message.as_str()) |
| 227 | - alert(message: message.as_str()) | 213 | + } |
| 228 | - } | 214 | + <div class="acts"> |
| 229 | - <div class="row-foot"> | 215 | + <button type="submit" class="primary">(t(lang, Key::Save))</button> |
| 230 | - <button type="submit" class="primary" form="profile-form">(t(lang, Key::Save))</button> | 216 | + </div> |
| 231 | - </div> | 217 | + </section> |
| 232 | - </section> | 218 | + </form> |
| 233 | - </div> | | |
| 234 | }) | 219 | }) |
| 235 | } | 220 | } |
| 236 | | 221 | |
| @@ -358,7 +343,7 @@ async fn profile_page(cx: &Cx) -> Result<impl View> { |
| 358 | ) | 343 | ) |
| 359 | .await?; | 344 | .await?; |
| 360 | Ok(view! { | 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 | let page = page_data(&viewer, lang, draft, errors, None).await?; | 387 | let page = page_data(&viewer, lang, draft, errors, None).await?; |
| 403 | return Ok(view! { | 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 | let page = page_data(&viewer, lang, Draft::from_user(&viewer.0), errors, None).await?; | 457 | let page = page_data(&viewer, lang, Draft::from_user(&viewer.0), errors, None).await?; |
| 473 | Ok(view! { | 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 | use crate::pages::passkeys::{PasskeyPanel, build_panel, passkeys_panel, s}; | 28 | use crate::pages::passkeys::{PasskeyPanel, build_panel, passkeys_panel, s}; |
| 29 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| 30 | use crate::throttle::{self, LOGIN_USER_LIMIT, TWO_FACTOR_USER_LIMIT}; | 30 | use crate::throttle::{self, LOGIN_USER_LIMIT, TWO_FACTOR_USER_LIMIT}; |
| | 31 | +use crate::views::parts::{post_act, reveal}; |
| 31 | use crate::views::{added_status, alert, rel_time, shell, user_facing_message}; | 32 | use crate::views::{added_status, alert, rel_time, shell, user_facing_message}; |
| 32 | | 33 | |
| 33 | /// Shortest and longest new passwords, in characters. | 34 | /// Shortest and longest new passwords, in characters. |
| @@ -156,7 +157,6 @@ struct DeviceView { |
| 156 | /// What the page needs to draw itself. | 157 | /// What the page needs to draw itself. |
| 157 | struct SecurityPage { | 158 | struct SecurityPage { |
| 158 | lang: Lang, | 159 | lang: Lang, |
| 159 | - csrf: String, | | |
| 160 | email: String, | 160 | email: String, |
| 161 | /// Whether the stored address has been verified. | 161 | /// Whether the stored address has been verified. |
| 162 | email_verified: bool, | 162 | email_verified: bool, |
| @@ -182,13 +182,14 @@ struct SecurityPage { |
| 182 | passkeys: PasskeyPanel, | 182 | passkeys: PasskeyPanel, |
| 183 | /// Repositories still owned by the user. Deletion is refused while there are any. | 183 | /// Repositories still owned by the user. Deletion is refused while there are any. |
| 184 | owned_repos: Vec<String>, | 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 | #[component] | 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 | let SecurityPage { | 191 | let SecurityPage { |
| 190 | lang, | 192 | lang, |
| 191 | - csrf, | | |
| 192 | email, | 193 | email, |
| 193 | email_verified, | 194 | email_verified, |
| 194 | stored_email, | 195 | stored_email, |
| @@ -206,26 +207,14 @@ async fn security_body(page: SecurityPage) -> Result<impl View> { |
| 206 | delete_error, | 207 | delete_error, |
| 207 | passkeys, | 208 | passkeys, |
| 208 | owned_repos, | 209 | owned_repos, |
| | 210 | + session_count, |
| 209 | } = page; | 211 | } = page; |
| 210 | let two_factor_on = two_factor.is_some(); | 212 | let two_factor_on = two_factor.is_some(); |
| 211 | - let codes_class = match &two_factor { | 213 | + let pending_set = pending.is_some(); |
| 212 | - Some(device) if device.codes_low => "row-status warn", | | |
| 213 | - _ => "row-status", | | |
| 214 | - }; | | |
| 215 | let password_open = password_error.is_some(); | 214 | let password_open = password_error.is_some(); |
| 216 | let email_open = email_error.is_some(); | 215 | let email_open = email_error.is_some(); |
| 217 | let email_set = !email.is_empty(); | 216 | let email_set = !email.is_empty(); |
| 218 | let show_resend = email_set && !email_verified; | 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 | let regenerate_error = two_factor_error | 218 | let regenerate_error = two_factor_error |
| 230 | .clone() | 219 | .clone() |
| 231 | .filter(|_| two_factor_panel == TwoFactorPanel::Regenerate); | 220 | .filter(|_| two_factor_panel == TwoFactorPanel::Regenerate); |
| @@ -237,258 +226,216 @@ async fn security_body(page: SecurityPage) -> Result<impl View> { |
| 237 | let disable_open = disable_error.is_some(); | 226 | let disable_open = disable_error.is_some(); |
| 238 | let delete_open = delete_error.is_some(); | 227 | let delete_open = delete_error.is_some(); |
| 239 | let delete_blocked = !owned_repos.is_empty(); | 228 | let delete_blocked = !owned_repos.is_empty(); |
| | 229 | + let sessions_line = format!("{session_count} {}", s(lang, "active", "etkin")); |
| 240 | Ok(view! { | 230 | Ok(view! { |
| 241 | - <div class="settings-layout"> | 231 | + <h1 class="sr-only">(t(lang, Key::Security))</h1> |
| 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> | | |
| 246 | if let Some(message) = notice { | 232 | if let Some(message) = notice { |
| 247 | - <section class="card notice" role="status"> | 233 | + <p class="state" role="status">(message)</p> |
| 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> | | |
| 262 | } | 234 | } |
| 263 | - <section class="card rows-pane"> | 235 | + <section class="sec" id="password"> |
| 264 | - <div class="row-line"> | 236 | + <h2>(t(lang, Key::Password))</h2> |
| 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> | 237 | + if let Some(stamp) = password_changed { |
| 266 | - <div class="row-main"> | 238 | + <p class="state">(i18n::last_changed_label(lang)) " " rel_time(lang: lang, stamp: stamp.as_str())</p> |
| 267 | - <h2 class="row-title">(t(lang, Key::Password))</h2> | 239 | + } |
| 268 | - if let Some(stamp) = password_changed { | 240 | + <div class="acts"> |
| 269 | - <p class="row-status">(i18n::last_changed_label(lang)) " " rel_time(lang: lang, stamp: stamp.as_str())</p> | 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> | 245 | + <form data-hard="true" method="post" action="/settings/security/password" class="fields"> |
| 272 | - <details class="row-action" open=(password_open)> | 246 | + <input type="hidden" name="csrf" value=(csrf)> |
| 273 | - <summary>(t(lang, Key::ChangeAction))</summary> | 247 | + <div class="field"> |
| 274 | - <div class="row-panel"> | 248 | + <label for="current-password">(t(lang, Key::CurrentPassword))</label> |
| 275 | - if let Some(message) = password_error { | 249 | + <input id="current-password" type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 276 | - alert(message: message.as_str()) | 250 | + </div> |
| 277 | - } | 251 | + <div class="field"> |
| 278 | - <form data-hard="true" method="post" action="/settings/security/password" class="stack"> | 252 | + <label for="new-password">(t(lang, Key::NewPassword))</label> |
| 279 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 253 | + <input id="new-password" type="password" name="new_password" autocomplete="new-password" minlength="10" maxlength="1024" required=(true)> |
| 280 | - <label> | 254 | + <p class="hint">(t(lang, Key::NewPasswordHint))</p> |
| 281 | - <span>(t(lang, Key::CurrentPassword))</span> | 255 | + </div> |
| 282 | - <input type="password" name="current_password" autocomplete="current-password" required=(true)> | 256 | + <div class="field"> |
| 283 | - </label> | 257 | + <label for="confirm-password">(t(lang, Key::ConfirmNewPassword))</label> |
| 284 | - <label> | 258 | + <input id="confirm-password" type="password" name="confirm_password" autocomplete="new-password" required=(true)> |
| 285 | - <span>(t(lang, Key::NewPassword))</span> | 259 | + </div> |
| 286 | - <input type="password" name="new_password" autocomplete="new-password" minlength="10" maxlength="1024" required=(true)> | 260 | + <button type="submit" class="primary">(t(lang, Key::ChangePassword))</button> |
| 287 | - <small class="muted">(t(lang, Key::NewPasswordHint))</small> | 261 | + </form> |
| 288 | - </label> | 262 | + ) |
| 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> | | |
| 297 | </div> | 263 | </div> |
| 298 | - <div class="row-line"> | 264 | + </section> |
| 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> | 265 | + <section class="sec" id="email"> |
| 300 | - <div class="row-main"> | 266 | + <h2>(t(lang, Key::Email))</h2> |
| 301 | - <h2 class="row-title">(t(lang, Key::Email))</h2> | 267 | + if stored_email.is_empty() { |
| 302 | - if stored_email.is_empty() { | 268 | + <p class="state">(t(lang, Key::EmailNoAddress))</p> |
| 303 | - <p class="row-status">(t(lang, Key::EmailNoAddress))</p> | 269 | + } else { |
| 304 | - } 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> |
| 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> | 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> | 277 | + <form method="post" action="/settings/security/email" class="fields"> |
| 308 | - if show_resend { | 278 | + <input type="hidden" name="csrf" value=(csrf)> |
| 309 | - <form method="post" action="/settings/security/email/resend" class="row-form"> | 279 | + <div class="field"> |
| 310 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 280 | + <label for="email-address">(t(lang, Key::Email))</label> |
| 311 | - <button type="submit">(t(lang, Key::VerifyResend))</button> | 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 | </form> | 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 | </div> | 293 | </div> |
| 335 | - <div class="rows-block"> | 294 | + </section> |
| 336 | - <div class="row-line"> | 295 | + <section class="sec" id="two-factor"> |
| 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> | 296 | + <h2>(t(lang, Key::TwoFactorAuth))</h2> |
| 338 | - <div class="row-main"> | 297 | + if let Some(list) = codes { |
| 339 | - <h2 class="row-title"> | 298 | + <div class="opened" data-once=""> |
| 340 | - <span>(t(lang, Key::TwoFactorAuth))</span> | 299 | + <p class="state">(t(lang, Key::RecoveryCodes))</p> |
| 341 | - <span class=(two_factor_pill_class)>(two_factor_pill_text)</span> | 300 | + <p class="hint">(t(lang, Key::RecoveryCodesSave))</p> |
| 342 | - </h2> | 301 | + <ul class="topic-list" id="recovery-codes"> |
| 343 | - if !two_factor_on && pending.is_none() { | 302 | + for code in list.into_iter() { |
| 344 | - <p class="row-status">(t(lang, Key::TwoFactorOffIntro))</p> | 303 | + <li><code>(code)</code></li> |
| 345 | - } | | |
| 346 | - if pending.is_some() { | | |
| 347 | - <p class="row-status">(t(lang, Key::SetupInProgress))</p> | | |
| 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 | </div> | 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 | </div> | 309 | </div> |
| 378 | - if let Some(device) = two_factor { | 310 | + } |
| 379 | - <ul class="security-devices"> | 311 | + if let Some(device) = two_factor { |
| 380 | - <li class="row-line security-device"> | 312 | + <p class="state">(t(lang, Key::PillOn)) " · " (device.name.as_str())</p> |
| 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> | 313 | + <p class="hint">added_status(lang: lang, added: device.added.as_deref(), used: device.used.as_deref())</p> |
| 382 | - <div class="row-main"> | 314 | + <p class="hint">(device.codes_line.as_str())</p> |
| 383 | - <p class="row-title">(device.name.as_str())</p> | 315 | + if device.codes_low { |
| 384 | - <p class="row-status">added_status(lang: lang, added: device.added.as_deref(), used: device.used.as_deref())</p> | 316 | + <p class="hint topic-warn">(t(lang, Key::CodesRunningLow))</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> | | |
| 415 | } | 317 | } |
| 416 | - if let Some((secret, uri)) = pending { | 318 | + <div class="acts"> |
| 417 | - <div class="row-panel security-setup"> | 319 | + reveal(label: t(lang, Key::RegenerateCodes), open: regenerate_open, |
| 418 | - <p>(t(lang, Key::TwoFactorPendingIntro))</p> | 320 | + if let Some(message) = regenerate_error { |
| 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 { | | |
| 422 | alert(message: message.as_str()) | 321 | alert(message: message.as_str()) |
| 423 | } | 322 | } |
| 424 | - <form data-hard="true" method="post" action="/settings/security/2fa/confirm" class="stack"> | 323 | + <form data-hard="true" method="post" action="/settings/security/2fa/recovery" class="fields"> |
| 425 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 324 | + <input type="hidden" name="csrf" value=(csrf)> |
| 426 | - <label> | 325 | + <p class="hint">(t(lang, Key::RegenerateCodesHint))</p> |
| 427 | - <span>(t(lang, Key::CodeFromApp))</span> | 326 | + <div class="field"> |
| 428 | - <input type="text" name="code" inputmode="numeric" autocomplete="one-time-code" maxlength="6" required=(true)> | 327 | + <label for="regenerate-code">(t(lang, Key::Code))</label> |
| 429 | - </label> | 328 | + <input id="regenerate-code" type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 430 | - <label> | 329 | + </div> |
| 431 | - <span>(t(lang, Key::DeviceName))</span> | 330 | + <button type="submit" class="primary">(t(lang, Key::RegenerateCodes))</button> |
| 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> | | |
| 436 | </form> | 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 | </div> | 396 | </div> |
| 440 | - passkeys_panel(lang: lang, csrf: csrf.as_str(), panel: passkeys) | | |
| 441 | </section> | 397 | </section> |
| 442 | - <section class="card rows-pane security-danger"> | 398 | + <section class="sec" id="danger"> |
| 443 | - <p class="security-danger-label">(t(lang, Key::DangerZone))</p> | 399 | + <h2>(t(lang, Key::DangerZone))</h2> |
| 444 | - <div class="row-line"> | 400 | + if delete_blocked { |
| 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> | 401 | + <p class="state">(t(lang, Key::TransferOrDeleteRepos))</p> |
| 446 | - <div class="row-main"> | 402 | + <ul class="topic-list"> |
| 447 | - <h2 class="row-title">(t(lang, Key::DeleteAccount))</h2> | 403 | + for name in owned_repos.into_iter() { |
| 448 | - if delete_blocked { | 404 | + <li class="line"><span class="name">(name)</span></li> |
| 449 | - <p class="row-status">(t(lang, Key::TransferOrDeleteRepos))</p> | | |
| 450 | - } else { | | |
| 451 | - <p class="row-status">(t(lang, Key::DeleteAccountIntro))</p> | | |
| 452 | } | 405 | } |
| 453 | - </div> | 406 | + </ul> |
| 454 | - if !delete_blocked { | 407 | + } else { |
| 455 | - <details class="row-action danger" open=(delete_open)> | 408 | + <p class="state">(t(lang, Key::DeleteAccountIntro))</p> |
| 456 | - <summary>(t(lang, Key::DeleteAccount))</summary> | 409 | + <div class="acts"> |
| 457 | - <div class="row-panel"> | 410 | + <details class="reveal" open=(delete_open)> |
| | 411 | + <summary class="act danger">(t(lang, Key::DeleteAccount))</summary> |
| | 412 | + <div class="opened"> |
| 458 | if let Some(message) = delete_error { | 413 | if let Some(message) = delete_error { |
| 459 | alert(message: message.as_str()) | 414 | alert(message: message.as_str()) |
| 460 | } | 415 | } |
| 461 | - <form data-hard="true" method="post" action="/settings/security/delete" class="stack"> | 416 | + <form data-hard="true" method="post" action="/settings/security/delete" class="fields"> |
| 462 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 417 | + <input type="hidden" name="csrf" value=(csrf)> |
| 463 | - <label> | 418 | + <div class="field"> |
| 464 | - <span>(t(lang, Key::CurrentPassword))</span> | 419 | + <label for="delete-password">(t(lang, Key::CurrentPassword))</label> |
| 465 | - <input type="password" name="current_password" autocomplete="current-password" required=(true)> | 420 | + <input id="delete-password" type="password" name="current_password" autocomplete="current-password" required=(true)> |
| 466 | - </label> | 421 | + </div> |
| 467 | if two_factor_on { | 422 | if two_factor_on { |
| 468 | - <label> | 423 | + <div class="field"> |
| 469 | - <span>(t(lang, Key::Code))</span> | 424 | + <label for="delete-code">(t(lang, Key::Code))</label> |
| 470 | - <input type="text" name="code" autocomplete="one-time-code" required=(true)> | 425 | + <input id="delete-code" type="text" name="code" autocomplete="one-time-code" required=(true)> |
| 471 | - </label> | 426 | + </div> |
| 472 | } | 427 | } |
| 473 | - <label> | 428 | + <div class="field"> |
| 474 | - <span>(t(lang, Key::TypeUsernameToConfirm))</span> | 429 | + <label for="delete-username">(t(lang, Key::TypeUsernameToConfirm))</label> |
| 475 | - <input type="text" name="confirm_username" autocomplete="off" required=(true)> | 430 | + <input id="delete-username" type="text" name="confirm_username" autocomplete="off" required=(true)> |
| 476 | - </label> | 431 | + </div> |
| 477 | - <button type="submit" class="danger">(t(lang, Key::DeleteAccount))</button> | 432 | + <button type="submit" class="act danger">(t(lang, Key::DeleteAccount))</button> |
| 478 | </form> | 433 | </form> |
| 479 | </div> | 434 | </div> |
| 480 | </details> | 435 | </details> |
| 481 | - } | 436 | + </div> |
| 482 | - if delete_blocked { | 437 | + } |
| 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> | | |
| 490 | </section> | 438 | </section> |
| 491 | - </div> | | |
| 492 | }) | 439 | }) |
| 493 | } | 440 | } |
| 494 | | 441 | |
| @@ -587,7 +534,6 @@ async fn build_page( |
| 587 | }; | 534 | }; |
| 588 | Ok(SecurityPage { | 535 | Ok(SecurityPage { |
| 589 | lang, | 536 | lang, |
| 590 | - csrf: viewer.1.csrf_token.clone(), | | |
| 591 | delete_error: shown.delete_error, | 537 | delete_error: shown.delete_error, |
| 592 | passkeys: build_panel(state, &viewer.0.id).await?, | 538 | passkeys: build_panel(state, &viewer.0.id).await?, |
| 593 | owned_repos, | 539 | owned_repos, |
| @@ -607,6 +553,7 @@ async fn build_page( |
| 607 | pending, | 553 | pending, |
| 608 | password_changed, | 554 | password_changed, |
| 609 | two_factor, | 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 | let lang = i18n::lang(cx, Some(&viewer.0)); | 574 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 628 | let page = build_page(state, lang, &viewer, shown).await?; | 575 | let page = build_page(state, lang, &viewer, shown).await?; |
| | 576 | + let csrf = viewer.1.csrf_token.clone(); |
| 629 | Ok(view! { | 577 | Ok(view! { |
| 630 | (status) | 578 | (status) |
| 631 | (headers) | 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 | assert!(page.body.contains("Added "), "{}", page.body); | 1621 | assert!(page.body.contains("Added "), "{}", page.body); |
| 1674 | assert!(page.body.contains("1 of 10 recovery codes unused")); | 1622 | assert!(page.body.contains("1 of 10 recovery codes unused")); |
| 1675 | assert!(page.body.contains("Running low")); | 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 | let bad = format!( | 1626 | let bad = format!( |
| 1679 | "csrf={CSRF}¤t_password=nope&code={}", | 1627 | "csrf={CSRF}¤t_password=nope&code={}", |
| @@ -1688,13 +1636,18 @@ mod tests { |
| 1688 | ) | 1636 | ) |
| 1689 | .await; | 1637 | .await; |
| 1690 | assert!(reply.body.contains("Current password is incorrect.")); | 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 | assert!( | 1643 | assert!( |
| 1692 | - reply.body.contains("row-action danger\" open"), | 1644 | + opened.contains("Turn off") |
| 1693 | - "turn-off panel should stay open: {}", | 1645 | + && opened.split("<details").next().is_some_and(|panel| panel |
| 1694 | - reply.body | 1646 | + .contains("action=\"/settings/security/2fa/disable\"")), |
| | 1647 | + "the open panel should be the turn-off form: {opened}" |
| 1695 | ); | 1648 | ); |
| 1696 | assert!( | 1649 | assert!( |
| 1697 | - !reply.body.contains("row-action\" open"), | 1650 | + !opened.contains("<details class=\"reveal\" open"), |
| 1698 | "only the turn-off panel should be open" | 1651 | "only the turn-off panel should be open" |
| 1699 | ); | 1652 | ); |
| 1700 | | 1653 | |
| @@ -13,7 +13,9 @@ use topcoat::view::{View, component, view}; |
| 13 | use crate::audit::{self, Actor, Target}; | 13 | use crate::audit::{self, Actor, Target}; |
| 14 | use crate::auth::{logout, require_csrf, require_user}; | 14 | use crate::auth::{logout, require_csrf, require_user}; |
| 15 | use crate::i18n::{self, Key, Lang, t}; | 15 | use crate::i18n::{self, Key, Lang, t}; |
| | 16 | +use crate::pages::passkeys::s; |
| 16 | use crate::state::AppState; | 17 | use crate::state::AppState; |
| | 18 | +use crate::views::parts::confirm_act; |
| 17 | use crate::views::{rel_time, shell}; | 19 | use crate::views::{rel_time, shell}; |
| 18 | use crate::web_push::agent_label; | 20 | use crate::web_push::agent_label; |
| 19 | | 21 | |
| @@ -39,15 +41,6 @@ fn session_label(lang: Lang, session: &Session) -> String { |
| 39 | .map_or_else(|| t(lang, Key::UnknownBrowser).to_owned(), agent_label) | 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 | #[component] | 44 | #[component] |
| 52 | async fn sessions_view( | 45 | async fn sessions_view( |
| 53 | lang: Lang, | 46 | lang: Lang, |
| @@ -57,50 +50,36 @@ async fn sessions_view( |
| 57 | ) -> Result<impl View> { | 50 | ) -> Result<impl View> { |
| 58 | let others = sessions.iter().filter(|s| s.id != current_id).count(); | 51 | let others = sessions.iter().filter(|s| s.id != current_id).count(); |
| 59 | Ok(view! { | 52 | Ok(view! { |
| 60 | - <section class="page-head"> | 53 | + <h1 class="sr-only">(t(lang, Key::Sessions))</h1> |
| 61 | - <h1>(t(lang, Key::Sessions))</h1> | 54 | + if others > 0 { |
| 62 | - if others > 0 { | 55 | + <div class="acts"> |
| 63 | - <form method="post" action="/settings/sessions/revoke-others" class="inline-form"> | 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())) |
| 64 | - <input type="hidden" name="csrf" value=(csrf)> | 57 | + </div> |
| 65 | - <button type="submit" class="danger">(t(lang, Key::RevokeAllOthers))</button> | 58 | + } |
| 66 | - </form> | 59 | + <div> |
| 67 | - } | | |
| 68 | - </section> | | |
| 69 | - <section class="card rows-pane session-pane"> | | |
| 70 | for session in sessions.into_iter() { | 60 | for session in sessions.into_iter() { |
| 71 | - <div class="row-line"> | 61 | + <details class="row-open"> |
| 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> | 62 | + <summary class="line"> |
| 73 | - <div class="row-main"> | 63 | + <span class="name">(session_label(lang, &session))</span> |
| 74 | - <strong class="row-name"><a href=(format!("/settings/sessions/{}", session.id)) data-dialog=(format!("session-{}", session.id))>(session_label(lang, &session))</a></strong> | 64 | + <span class="val"> |
| 75 | - if session.id == current_id { | 65 | + if session.id == current_id { |
| 76 | - <span class="badge public">(t(lang, Key::ThisSession))</span> | 66 | + (t(lang, Key::ThisSession)) " · " |
| 77 | - } | 67 | + } |
| 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> | 68 | + (i18n::dated_label(lang, Key::LastSeen)) " " rel_time(lang: lang, stamp: session.last_seen.as_str()) |
| 79 | - <dialog class="session-dialog" id=(format!("session-{}", session.id)) aria-labelledby=(format!("session-{}-title", session.id))> | 69 | + </span> |
| 80 | - <div class="session-dialog-head"> | 70 | + </summary> |
| 81 | - <h2 id=(format!("session-{}-title", session.id))>(session_label(lang, &session))</h2> | 71 | + <div class="opened"> |
| 82 | - <form method="dialog"> | 72 | + session_details(lang: lang, csrf: csrf, session: session.clone(), current: session.id == current_id) |
| 83 | - <button type="submit">(t(lang, Key::Close))</button> | 73 | + <p class="back-act"><a class="act" href=(format!("/settings/sessions/{}", session.id))>(s(lang, "Open page", "Sayfayı aç"))</a></p> |
| 84 | - </form> | | |
| 85 | - </div> | | |
| 86 | - session_details(lang: lang, csrf: csrf, session: session.clone(), current: session.id == current_id) | | |
| 87 | - </dialog> | | |
| 88 | </div> | 74 | </div> |
| 89 | - if session.id != current_id { | 75 | + </details> |
| 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> | | |
| 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 | 81 | +/// The facts about one session, shared by its row 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. | 82 | +/// when it is the current session, the key/value grid, and the revoke action for any other one. |
| 104 | #[component] | 83 | #[component] |
| 105 | async fn session_details( | 84 | async fn session_details( |
| 106 | lang: Lang, | 85 | lang: Lang, |
| @@ -124,7 +103,7 @@ async fn session_details( |
| 124 | let id = session.id.clone(); | 103 | let id = session.id.clone(); |
| 125 | Ok(view! { | 104 | Ok(view! { |
| 126 | if current { | 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 | <dl class="kv-grid"> | 108 | <dl class="kv-grid"> |
| 130 | <div><dt>(t(lang, Key::UserAgent))</dt><dd>(user_agent.as_str())</dd></div> | 109 | <div><dt>(t(lang, Key::UserAgent))</dt><dd>(user_agent.as_str())</dd></div> |
| @@ -135,11 +114,9 @@ async fn session_details( |
| 135 | <div><dt>(t(lang, Key::ExpiresAt))</dt><dd>rel_time(lang: lang, stamp: session.expires_at.as_str())</dd></div> | 114 | <div><dt>(t(lang, Key::ExpiresAt))</dt><dd>rel_time(lang: lang, stamp: session.expires_at.as_str())</dd></div> |
| 136 | </dl> | 115 | </dl> |
| 137 | if !current { | 116 | if !current { |
| 138 | - <form method="post" action="/settings/sessions/revoke"> | 117 | + <div class="acts"> |
| 139 | - <input type="hidden" name="csrf" value=(csrf)> | 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())) |
| 140 | - <input type="hidden" name="id" value=(id.as_str())> | 119 | + </div> |
| 141 | - <button type="submit" class="danger">(t(lang, Key::Revoke))</button> | | |
| 142 | - </form> | | |
| 143 | } | 120 | } |
| 144 | }) | 121 | }) |
| 145 | } | 122 | } |
| @@ -152,13 +129,10 @@ async fn session_detail_view( |
| 152 | current: bool, | 129 | current: bool, |
| 153 | ) -> Result<impl View> { | 130 | ) -> Result<impl View> { |
| 154 | Ok(view! { | 131 | Ok(view! { |
| 155 | - <section class="page-head"> | 132 | + <h1 class="h1">(session_label(lang, &session))</h1> |
| 156 | - <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> |
| 157 | - </section> | 134 | + session_details(lang: lang, csrf: csrf, session: session.clone(), current: current) |
| 158 | - <section class="card"> | 135 | + <p class="back-act"><a class="act" href="/settings/sessions">(t(lang, Key::BackToSessions))</a></p> |
| 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> | | |
| 162 | }) | 136 | }) |
| 163 | } | 137 | } |
| 164 | | 138 | |
| @@ -280,7 +254,7 @@ mod tests { |
| 280 | const CSRF: &str = "sessions-test-csrf"; | 254 | const CSRF: &str = "sessions-test-csrf"; |
| 281 | | 255 | |
| 282 | #[tokio::test] | 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 | let dir = tempfile::tempdir().expect("tempdir"); | 258 | let dir = tempfile::tempdir().expect("tempdir"); |
| 285 | let state = crate::test_support::test_state(dir.path()).await; | 259 | let state = crate::test_support::test_state(dir.path()).await; |
| 286 | let store = state.store.clone(); | 260 | let store = state.store.clone(); |
| @@ -307,9 +281,10 @@ mod tests { |
| 307 | assert_eq!(res.status().as_u16(), 200); | 281 | assert_eq!(res.status().as_u16(), 200); |
| 308 | let body = to_bytes(res.into_body(), usize::MAX).await.expect("body"); | 282 | let body = to_bytes(res.into_body(), usize::MAX).await.expect("body"); |
| 309 | let html = String::from_utf8_lossy(&body); | 283 | let html = String::from_utf8_lossy(&body); |
| 310 | - let id = format!("session-{}", current.id); | 284 | + assert!(html.contains("<details class=\"row-open\">")); |
| 311 | - assert!(html.contains(&format!("<dialog class=\"session-dialog\" id=\"{id}\""))); | 285 | + assert!(html.contains("<div class=\"opened\">")); |
| 312 | - assert!(html.contains(&format!("data-dialog=\"{id}\""))); | 286 | + assert!(html.contains("<dl class=\"kv-grid\">")); |
| | 287 | + assert!(html.contains(&format!("href=\"/settings/sessions/{}\"", current.id))); |
| 313 | } | 288 | } |
| 314 | | 289 | |
| 315 | #[tokio::test] | 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 | use std::time::Duration; | 3 | use std::time::Duration; |
| 4 | | 4 | |
| @@ -22,9 +22,10 @@ use crate::auth::{require_csrf, require_user}; |
| 22 | use crate::i18n::packages::{self as pk, K as PK}; | 22 | use crate::i18n::packages::{self as pk, K as PK}; |
| 23 | use crate::i18n::releases_ci::{self as rc, K as RC}; | 23 | use crate::i18n::releases_ci::{self as rc, K as RC}; |
| 24 | use crate::i18n::{self, Key, Lang, t, token_name_length}; | 24 | use crate::i18n::{self, Key, Lang, t, token_name_length}; |
| 25 | -use crate::pages::admin_runners::confirm_post; | 25 | +use crate::pages::settings_keys::{KeysDraft, keys_page_view}; |
| 26 | use crate::state::AppState; | 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 | /// Scopes are fixed to `repo` for M1. | 30 | /// Scopes are fixed to `repo` for M1. |
| 30 | const SCOPES: &[&str] = &["repo"]; | 31 | const SCOPES: &[&str] = &["repo"]; |
| @@ -51,18 +52,11 @@ struct DeleteTokenForm { |
| 51 | id: String, | 52 | id: String, |
| 52 | } | 53 | } |
| 53 | | 54 | |
| 54 | -/// The question the delete popover asks before a token is revoked. | 55 | +/// What deleting a token costs. |
| 55 | -fn delete_message(lang: Lang, name: &str) -> String { | 56 | +fn delete_message(lang: Lang) -> &'static str { |
| 56 | match lang { | 57 | match lang { |
| 57 | - Lang::Tr => format!("{name} silinsin mi? Bu token ile çalışan her şey hemen durur."), | 58 | + Lang::Tr => "Bu token ile çalışan her şey hemen durur.", |
| 58 | - _ => format!("Delete token {name}? Anything using it stops working at once."), | 59 | + _ => "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", | | |
| 66 | } | 60 | } |
| 67 | } | 61 | } |
| 68 | | 62 | |
| @@ -78,102 +72,93 @@ fn expiry_days(choice: &str) -> Option<u64> { |
| 78 | } | 72 | } |
| 79 | | 73 | |
| 80 | #[component] | 74 | #[component] |
| 81 | -async fn tokens_view( | 75 | +pub(crate) async fn tokens_section( |
| 82 | lang: Lang, | 76 | lang: Lang, |
| 83 | csrf: &str, | 77 | csrf: &str, |
| 84 | tokens: Vec<AccessToken>, | 78 | tokens: Vec<AccessToken>, |
| 85 | created: Option<String>, | 79 | created: Option<String>, |
| 86 | error: Option<String>, | 80 | error: Option<String>, |
| 87 | ) -> Result<impl View> { | 81 | ) -> Result<impl View> { |
| | 82 | + let empty = tokens.is_empty(); |
| | 83 | + let open = error.is_some(); |
| 88 | Ok(view! { | 84 | Ok(view! { |
| 89 | - <section class="page-head"> | 85 | + <section class="sec" id="tokens"> |
| 90 | - <h1>(t(lang, Key::AccessTokens))</h1> | 86 | + <h2>(t(lang, Key::AccessTokens))</h2> |
| 91 | - </section> | 87 | + if let Some(token) = created { |
| 92 | - if let Some(token) = created { | 88 | + <div class="opened" role="status" data-once=""> |
| 93 | - <section class="card notice" role="status" data-once=""> | 89 | + <p class="state">(t(lang, Key::YourNewToken))</p> |
| 94 | - <h2>(t(lang, Key::YourNewToken))</h2> | 90 | + <p class="hint">(t(lang, Key::CopyNow))</p> |
| 95 | - <p>(t(lang, Key::CopyNow))</p> | 91 | + <div class="copy-box"> |
| 96 | - <div class="copy-box"> | 92 | + <pre class="code"><code id="new-token">(token)</code></pre> |
| 97 | - <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> |
| 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> | | |
| 150 | </div> | 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 | </div> | 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 | </section> | 146 | </section> |
| 155 | }) | 147 | }) |
| 156 | } | 148 | } |
| 157 | | 149 | |
| 158 | -#[page("/settings/tokens")] | 150 | +#[route(GET "/settings/tokens")] |
| 159 | -async fn tokens_page(cx: &Cx) -> Result<impl View> { | 151 | +async fn tokens_page(cx: &Cx) -> Result<SeeOther> { |
| 160 | - let viewer = require_user(cx).await?; | 152 | + require_user(cx).await?; |
| 161 | - let lang = i18n::lang(cx, Some(&viewer.0)); | 153 | + Ok(see_other("/settings/keys#tokens")) |
| 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 | - }) | | |
| 170 | } | 154 | } |
| 171 | | 155 | |
| 172 | #[page(POST "/settings/tokens")] | 156 | #[page(POST "/settings/tokens")] |
| 173 | async fn tokens_create(cx: &Cx, Form(form): Form<CreateTokenForm>) -> Result<impl View> { | 157 | async fn tokens_create(cx: &Cx, Form(form): Form<CreateTokenForm>) -> Result<impl View> { |
| 174 | let viewer = require_csrf(cx, &form.csrf).await?; | 158 | let viewer = require_csrf(cx, &form.csrf).await?; |
| 175 | let lang = i18n::lang(cx, Some(&viewer.0)); | 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 | let name = form.name.trim(); | 162 | let name = form.name.trim(); |
| 178 | | 163 | |
| 179 | // Some(message) on invalid input; otherwise the new token to show once. | 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 | // The response may carry the plaintext token, so keep it out of caches. | 209 | // The response may carry the plaintext token, so keep it out of caches. |
| 225 | response_headers(cx).append(CACHE_CONTROL, HeaderValue::from_static("no-store")); | 210 | response_headers(cx).append(CACHE_CONTROL, HeaderValue::from_static("no-store")); |
| 226 | - let tokens = store.list_tokens(&viewer.0.id).await?; | 211 | + let draft = KeysDraft { |
| 227 | - let csrf = viewer.1.csrf_token.clone(); | 212 | + token: created, |
| | 213 | + token_error: error, |
| | 214 | + ..KeysDraft::default() |
| | 215 | + }; |
| 228 | Ok(view! { | 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 | .await; | 238 | .await; |
| 251 | } | 239 | } |
| 252 | - Ok(see_other("/settings/tokens")) | 240 | + Ok(see_other("/settings/keys")) |
| 253 | } | 241 | } |
| 254 | | 242 | |
| 255 | #[cfg(test)] | 243 | #[cfg(test)] |
| @@ -42,31 +42,31 @@ async fn setup_form( |
| 42 | error: Option<String>, | 42 | error: Option<String>, |
| 43 | ) -> Result<impl View> { | 43 | ) -> Result<impl View> { |
| 44 | Ok(view! { | 44 | Ok(view! { |
| 45 | - <section class="card narrow"> | 45 | + <section> |
| 46 | <h1>(t(lang, Key::WelcomeToForge))</h1> | 46 | <h1>(t(lang, Key::WelcomeToForge))</h1> |
| 47 | - <p class="muted">(t(lang, Key::SetupSub))</p> | 47 | + <p class="hint">(t(lang, Key::SetupSub))</p> |
| 48 | - if let Some(message) = error { | 48 | + <form data-hard="true" method="post" action="/setup" class="fields"> |
| 49 | - alert(message: message.as_str()) | 49 | + if let Some(message) = error { |
| 50 | - } | 50 | + alert(message: message.as_str()) |
| 51 | - <form data-hard="true" method="post" action="/setup" class="stack"> | 51 | + } |
| 52 | <input type="hidden" name="precsrf" value=(precsrf)> | 52 | <input type="hidden" name="precsrf" value=(precsrf)> |
| 53 | - <label> | 53 | + <div class="field"> |
| 54 | - <span>(t(lang, Key::Username))</span> | 54 | + <label for="setup-username">(t(lang, Key::Username))</label> |
| 55 | - <input type="text" name="username" value=(username) autocomplete="username" required=(true)> | 55 | + <input id="setup-username" type="text" name="username" value=(username) autocomplete="username" required=(true)> |
| 56 | - </label> | 56 | + </div> |
| 57 | - <label> | 57 | + <div class="field"> |
| 58 | - <span>(t(lang, Key::EmailOptional))</span> | 58 | + <label for="setup-email">(t(lang, Key::EmailOptional))</label> |
| 59 | - <input type="email" name="email" value=(email) autocomplete="email"> | 59 | + <input id="setup-email" type="email" name="email" value=(email) autocomplete="email"> |
| 60 | - </label> | 60 | + </div> |
| 61 | - <label> | 61 | + <div class="field"> |
| 62 | - <span>(t(lang, Key::Password))</span> | 62 | + <label for="setup-password">(t(lang, Key::Password))</label> |
| 63 | - <input type="password" name="password" autocomplete="new-password" required=(true)> | 63 | + <input id="setup-password" type="password" name="password" autocomplete="new-password" required=(true)> |
| 64 | - <small class="muted">(t(lang, Key::AtLeast12Chars))</small> | 64 | + <p class="hint">(t(lang, Key::AtLeast12Chars))</p> |
| 65 | - </label> | 65 | + </div> |
| 66 | - <label> | 66 | + <div class="field"> |
| 67 | - <span>(t(lang, Key::ConfirmPassword))</span> | 67 | + <label for="setup-confirm">(t(lang, Key::ConfirmPassword))</label> |
| 68 | - <input type="password" name="confirm" autocomplete="new-password" required=(true)> | 68 | + <input id="setup-confirm" type="password" name="confirm" autocomplete="new-password" required=(true)> |
| 69 | - </label> | 69 | + </div> |
| 70 | <button type="submit" class="primary">(t(lang, Key::CreateAdmin))</button> | 70 | <button type="submit" class="primary">(t(lang, Key::CreateAdmin))</button> |
| 71 | </form> | 71 | </form> |
| 72 | </section> | 72 | </section> |
| @@ -27,6 +27,7 @@ use crate::pages::snippets_live::{bump_snippet, item_live_url, list_live_url}; |
| 27 | use crate::render::highlight::highlight_lines; | 27 | use crate::render::highlight::highlight_lines; |
| 28 | use crate::render::markdown::render_markdown; | 28 | use crate::render::markdown::render_markdown; |
| 29 | use crate::state::AppState; | 29 | use crate::state::AppState; |
| | 30 | +use crate::views::parts::confirm_act; |
| 30 | use crate::views::{alert, empty_state, rel_time, shell, user_facing_message}; | 31 | use crate::views::{alert, empty_state, rel_time, shell, user_facing_message}; |
| 31 | | 32 | |
| 32 | path_param!(id); | 33 | path_param!(id); |
| @@ -276,18 +277,14 @@ async fn owned(cx: &Cx, user: &User, snippet_id: &str) -> Result<Snippet> { |
| 276 | #[component] | 277 | #[component] |
| 277 | pub(crate) async fn snippet_rows(lang: Lang, rows: Vec<ListRow>) -> Result<impl View> { | 278 | pub(crate) async fn snippet_rows(lang: Lang, rows: Vec<ListRow>) -> Result<impl View> { |
| 278 | Ok(view! { | 279 | Ok(view! { |
| 279 | - <ul class="item-list snippet-list"> | 280 | + <div class="snippet-list"> |
| 280 | for row in rows.into_iter() { | 281 | for row in rows.into_iter() { |
| 281 | - <li class="item"> | 282 | + <a class="line" href=(format!("/snippets/{}", row.id)) data-kb-row=""> |
| 282 | - <div class="item-main"> | 283 | + <span class="name">(row.title)</span> |
| 283 | - <a href=(format!("/snippets/{}", row.id))><strong>(row.title)</strong></a> | 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> |
| 284 | - <span class="muted small"> | 285 | + </a> |
| 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> | | |
| 289 | } | 286 | } |
| 290 | - </ul> | 287 | + </div> |
| 291 | }) | 288 | }) |
| 292 | } | 289 | } |
| 293 | | 290 | |
| @@ -299,19 +296,19 @@ async fn snippet_list_body( |
| 299 | live: Option<String>, | 296 | live: Option<String>, |
| 300 | ) -> Result<impl View> { | 297 | ) -> Result<impl View> { |
| 301 | Ok(view! { | 298 | Ok(view! { |
| 302 | - <section class="page-head" data-live=(live.as_deref())> | 299 | + <div data-live=(live.as_deref())> |
| 303 | - <h1>(g::t(lang, K::Snippets))</h1> | 300 | + <h1 class="sr-only">(g::t(lang, K::Snippets))</h1> |
| 304 | if signed_in { | 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 | if rows.is_empty() { | 306 | if rows.is_empty() { |
| 310 | empty_state(title: g::t(lang, K::NoSnippets)) | 307 | empty_state(title: g::t(lang, K::NoSnippets)) |
| 311 | } else { | 308 | } else { |
| 312 | snippet_rows(lang: lang, rows: rows) | 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 | name="tab" value=(number.to_string()) checked=(checked)> | 352 | name="tab" value=(number.to_string()) checked=(checked)> |
| 356 | <label class="snippet-tab" for=(format!("snippet-tab-{number}"))>(label)</label> | 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 | </div> | 355 | </div> |
| 365 | - <span class="snippet-count muted small">(counter)</span> | 356 | + <p class="hint snippet-count">(counter)</p> |
| 366 | </div> | 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 | for (index, slot) in slots.into_iter().enumerate() { | 363 | for (index, slot) in slots.into_iter().enumerate() { |
| 368 | <fieldset class=(format!("snippet-panel snippet-panel-{}", slot.number))> | 364 | <fieldset class=(format!("snippet-panel snippet-panel-{}", slot.number))> |
| 369 | <legend class="sr-only">(g::t(lang, K::FileLabel))(index + 1)</legend> | 365 | <legend class="sr-only">(g::t(lang, K::FileLabel))(index + 1)</legend> |
| 370 | - <div class="snippet-slot-head"> | 366 | + <div class="field"> |
| 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> | 367 | + <label for=(format!("snippet-name-{}", slot.number))>(g::t(lang, K::FileName))</label> |
| 372 | - <input type="text" class="snippet-name" name=(format!("name_{}", slot.number)) value=(slot.name) | 368 | + <input type="text" id=(format!("snippet-name-{}", slot.number)) 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))> | 369 | + maxlength="100" placeholder=(g::t(lang, K::FileNamePlaceholder))> |
| 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 | - } | | |
| 380 | </div> | 370 | </div> |
| 381 | - <textarea class="code snippet-content" name=(format!("content_{}", slot.number)) | 371 | + <div class="field"> |
| 382 | - spellcheck="false" aria-label=(g::t(lang, K::FileContents))>(slot.content)</textarea> | 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 | </fieldset> | 382 | </fieldset> |
| 384 | } | 383 | } |
| 385 | </div> | 384 | </div> |
| @@ -416,44 +415,37 @@ async fn snippet_form( |
| 416 | if let Some(message) = error { | 415 | if let Some(message) = error { |
| 417 | alert(message: message.as_str()) | 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 | <input type="hidden" name="csrf" value=(csrf)> | 420 | <input type="hidden" name="csrf" value=(csrf)> |
| 421 | - <header class="snippet-head page-head"> | 421 | + <div class="field"> |
| 422 | - <h1>(heading)</h1> | 422 | + <label for="snippet-title">(g::t(lang, K::Title))</label> |
| 423 | - <div class="snippet-head-actions"> | 423 | + <input id="snippet-title" type="text" class="snippet-title" name="title" value=(title) maxlength="120" required=(true) |
| 424 | - <fieldset class="snippet-visibility"> | 424 | + placeholder=(g::t(lang, K::SnippetTitlePlaceholder))> |
| 425 | - <legend class="sr-only">(g::t(lang, K::Visibility))</legend> | 425 | + </div> |
| 426 | - <div class="segmented snippet-segmented"> | 426 | + <div class="field"> |
| 427 | - <label class="segment" title=(g::t(lang, K::PublicOption))> | 427 | + <label for="snippet-description">(g::t(lang, K::Description))</label> |
| 428 | - <input type="radio" name="visibility" value="public" checked=(public)> | 428 | + <input id="snippet-description" type="text" class="snippet-desc" name="description" value=(description) maxlength="1000" |
| 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> | 429 | + placeholder=(g::t(lang, K::DescriptionOptional))> |
| 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) | | |
| 456 | </div> | 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 | </form> | 449 | </form> |
| 458 | }) | 450 | }) |
| 459 | } | 451 | } |
| @@ -476,31 +468,28 @@ async fn snippet_body( |
| 476 | let history_href = format!("/snippets/{snippet_id}/revisions"); | 468 | let history_href = format!("/snippets/{snippet_id}/revisions"); |
| 477 | let delete_action = format!("/snippets/{snippet_id}/delete"); | 469 | let delete_action = format!("/snippets/{snippet_id}/delete"); |
| 478 | Ok(view! { | 470 | Ok(view! { |
| 479 | - <section class="page-head snippet-view-head" data-live=(live.as_deref())> | 471 | + <div data-live=(live.as_deref())> |
| 480 | - <h1>(title)</h1> | 472 | + <h1 class="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> | 473 | + <p class="hint">(owner) " · " (visibility) " · " (g::updated_before(lang)) rel_time(lang: lang, stamp: updated_at) (g::updated_after(lang))</p> |
| 482 | - </section> | 474 | + </div> |
| 483 | if !description.is_empty() { | 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))> | 478 | + <nav class="sub" aria-label=(g::t(lang, K::SnippetNav))> |
| 487 | - <a class="button" href=(history_href)>(g::t(lang, K::Revisions))</a> | 479 | + <a 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 | - } | | |
| 495 | </nav> | 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 | for file in files.into_iter() { | 487 | for file in files.into_iter() { |
| 497 | - <section class="file snippet-file"> | 488 | + <section class="sec snippet-file"> |
| 498 | - <header class="file-head"> | 489 | + <h2>(file.name.clone())</h2> |
| 499 | - <strong>(file.name.clone())</strong> | 490 | + <nav class="sub" aria-label=(g::t(lang, K::FileNav))> |
| 500 | - <nav class="file-actions" aria-label=(g::t(lang, K::FileNav))> | 491 | + <a href=(file.raw.clone())>(g::t(lang, K::Raw))</a> |
| 501 | - <a href=(file.raw.clone())>(g::t(lang, K::Raw))</a> | 492 | + </nav> |
| 502 | - </nav> | | |
| 503 | - </header> | | |
| 504 | if file.markdown { | 493 | if file.markdown { |
| 505 | <div class="markdown-body">(Unescaped::new_unchecked(file.body.clone()))</div> | 494 | <div class="markdown-body">(Unescaped::new_unchecked(file.body.clone()))</div> |
| 506 | } else if file.highlighted { | 495 | } else if file.highlighted { |
| @@ -511,7 +500,7 @@ async fn snippet_body( |
| 511 | </section> | 500 | </section> |
| 512 | } | 501 | } |
| 513 | if !is_owner { | 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 | let back = format!("/snippets/{snippet_id}"); | 516 | let back = format!("/snippets/{snippet_id}"); |
| 528 | let heading = g::revisions_of(lang, title); | 517 | let heading = g::revisions_of(lang, title); |
| 529 | Ok(view! { | 518 | Ok(view! { |
| 530 | - <section class="page-head" data-live=(live.as_deref())> | 519 | + <div data-live=(live.as_deref())> |
| 531 | - <h1>(heading.as_str())</h1> | 520 | + <h1 class="h1">(heading.as_str())</h1> |
| 532 | - <a href=(back)>(g::t(lang, K::BackToSnippet))</a> | 521 | + <nav class="sub"> |
| 533 | - </section> | 522 | + <a href=(back)>(g::t(lang, K::BackToSnippet))</a> |
| 534 | - <section class="card list-pane fit-pane"> | 523 | + </nav> |
| 535 | - if revisions.is_empty() { | 524 | + </div> |
| 536 | - <p class="muted">(g::t(lang, K::NoRevisions))</p> | 525 | + if revisions.is_empty() { |
| 537 | - } else { | 526 | + <p class="state">(g::t(lang, K::NoRevisions))</p> |
| 538 | - <ul class="item-list"> | 527 | + } else { |
| 539 | - for rev in revisions.into_iter() { | 528 | + <div> |
| 540 | - <li class="item"> | 529 | + for rev in revisions.into_iter() { |
| 541 | - <div class="item-main"> | 530 | + <div class="line" data-kb-row=""> |
| 542 | - <strong>(g::t(lang, K::RevisionLabel))(rev.number)</strong> | 531 | + <span class="name">(g::t(lang, K::RevisionLabel))(rev.number)</span> |
| 543 | - <span class="muted small"> | 532 | + <span class="val">(rev.author) " · " rel_time(lang: lang, stamp: rev.at.as_str()) " · " (rev.file_names)</span> |
| 544 | - (rev.author) " · " rel_time(lang: lang, stamp: rev.at.as_str()) " · " (rev.file_names) | 533 | + </div> |
| 545 | - </span> | 534 | + } |
| 546 | - </div> | 535 | + </div> |
| 547 | - </li> | 536 | + } |
| 548 | - } | | |
| 549 | - </ul> | | |
| 550 | - } | | |
| 551 | - </section> | | |
| 552 | }) | 537 | }) |
| 553 | } | 538 | } |
| 554 | | 539 | |
| @@ -383,13 +383,13 @@ pub async fn load_readme( |
| 383 | } | 383 | } |
| 384 | | 384 | |
| 385 | /// One row of a listing: a stretched link to the entry (the whole row is the target), its icon, | 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 | #[component] | 387 | #[component] |
| 388 | pub async fn tree_table(rows: Vec<EntryRow>, lang: Lang) -> Result<impl View> { | 388 | pub async fn tree_table(rows: Vec<EntryRow>, lang: Lang) -> Result<impl View> { |
| 389 | Ok(view! { | 389 | Ok(view! { |
| 390 | - <div class="table-wrap tree-list"> | 390 | + <div class="tree-list"> |
| 391 | for row in rows.into_iter() { | 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 | <span class="tree-kind"> | 393 | <span class="tree-kind"> |
| 394 | if row.kind == "dir" { | 394 | if row.kind == "dir" { |
| 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> | 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 | repo_head(head: header) | 526 | repo_head(head: header) |
| 527 | <div class="repo-grid repo-home canvas-repo tree-browse"> | 527 | <div class="repo-grid repo-home canvas-repo tree-browse"> |
| 528 | <div class="repo-main canvas-files"> | 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 | ref_selector(lang: lang, label: mi::t(lang, MK::RefLabel), current: ref_name.clone(), branches: branches, tags: tags, | 530 | ref_selector(lang: lang, label: mi::t(lang, MK::RefLabel), current: ref_name.clone(), branches: branches, tags: tags, |
| 531 | branches_href: branches_href, tags_href: tags_href) | 531 | branches_href: branches_href, tags_href: tags_href) |
| 532 | file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref) | 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 | .collect() | 147 | .collect() |
| 148 | } | 148 | } |
| 149 | | 149 | |
| 150 | -/// The header every wiki screen shares: the page title on the left, then the wiki's own | 150 | +/// The header every wiki screen shares: the page name as its heading when the screen has links |
| 151 | -/// navigation as a button row (Home, All pages, any page-specific `extra` links such as Edit | 151 | +/// of its own (a page, its history, an edit), then the wiki's navigation as second-level text |
| 152 | -/// or History) with "New page" as the primary action on the far right for writers. | 152 | +/// links (Home, All pages, any page-specific `extra` links) with "New page" as an action. |
| 153 | #[component] | 153 | #[component] |
| 154 | async fn wiki_head( | 154 | async fn wiki_head( |
| 155 | lang: Lang, | 155 | lang: Lang, |
| @@ -163,20 +163,25 @@ async fn wiki_head( |
| 163 | let home = repo_href(&owner, &repo, "wiki", ""); | 163 | let home = repo_href(&owner, &repo, "wiki", ""); |
| 164 | let pages = repo_href(&owner, &repo, "wiki", "-/pages"); | 164 | let pages = repo_href(&owner, &repo, "wiki", "-/pages"); |
| 165 | let new = repo_href(&owner, &repo, "wiki", "-/new"); | 165 | let new = repo_href(&owner, &repo, "wiki", "-/new"); |
| | 166 | + let heading_shown = !extra.is_empty(); |
| 166 | Ok(view! { | 167 | Ok(view! { |
| 167 | - <section class="page-head wiki-head" data-live=(live.as_deref())> | 168 | + <div data-live=(live.as_deref())> |
| 168 | - <h1>(title.as_str())</h1> | 169 | + if heading_shown { |
| 169 | - <nav class="wiki-actions" aria-label=(g::t(lang, K::PageNav))> | 170 | + <h1 class="h1">(title.as_str())</h1> |
| 170 | - <a class="button" href=(home)>(g::t(lang, K::Home))</a> | 171 | + } else { |
| 171 | - <a class="button" href=(pages)>(g::t(lang, K::AllPages))</a> | 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 | for (label, href) in extra.into_iter() { | 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 | if can_write { | 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 | </nav> | 183 | </nav> |
| 179 | - </section> | 184 | + </div> |
| 180 | }) | 185 | }) |
| 181 | } | 186 | } |
| 182 | | 187 | |
| @@ -205,7 +210,7 @@ fn page_links( |
| 205 | #[component] | 210 | #[component] |
| 206 | async fn wiki_view_body(html: String) -> Result<impl View> { | 211 | async fn wiki_view_body(html: String) -> Result<impl View> { |
| 207 | Ok(view! { | 212 | Ok(view! { |
| 208 | - <section class="card wiki-page fit-pane"> | 213 | + <section class="sec wiki-page"> |
| 209 | <div class="markdown-body">(Unescaped::new_unchecked(html))</div> | 214 | <div class="markdown-body">(Unescaped::new_unchecked(html))</div> |
| 210 | </section> | 215 | </section> |
| 211 | }) | 216 | }) |
| @@ -220,13 +225,11 @@ async fn wiki_empty_body( |
| 220 | ) -> Result<impl View> { | 225 | ) -> Result<impl View> { |
| 221 | let new = repo_href(&owner, &repo, "wiki", "-/new"); | 226 | let new = repo_href(&owner, &repo, "wiki", "-/new"); |
| 222 | Ok(view! { | 227 | Ok(view! { |
| 223 | - <section class="card wiki-page fit-pane"> | 228 | + empty_state(title: g::t(lang, K::WikiNoPages), |
| 224 | - empty_state(title: g::t(lang, K::WikiNoPages), | 229 | + if can_write { |
| 225 | - if can_write { | 230 | + <a class="act" href=(new.as_str())>(g::t(lang, K::CreateFirstPage))</a> |
| 226 | - <a class="button primary" href=(new.as_str())>(g::t(lang, K::CreateFirstPage))</a> | 231 | + } |
| 227 | - } | 232 | + ) |
| 228 | - ) | | |
| 229 | - </section> | | |
| 230 | }) | 233 | }) |
| 231 | } | 234 | } |
| 232 | | 235 | |
| @@ -245,43 +248,35 @@ async fn wiki_list_body( |
| 245 | }) | 248 | }) |
| 246 | .collect(); | 249 | .collect(); |
| 247 | Ok(view! { | 250 | Ok(view! { |
| 248 | - <section class="card wiki-page fit-pane"> | 251 | + if rows.is_empty() { |
| 249 | - if rows.is_empty() { | 252 | + empty_state(title: g::t(lang, K::NoPagesYet)) |
| 250 | - empty_state(title: g::t(lang, K::NoPagesYet)) | 253 | + } else { |
| 251 | - } else { | 254 | + <div class="wiki-pages"> |
| 252 | - <ul class="item-list wiki-pages"> | 255 | + for (title, href) in rows.into_iter() { |
| 253 | - for (title, href) in rows.into_iter() { | 256 | + <a class="line" href=(href) data-kb-row=""> |
| 254 | - <li class="item"><a href=(href)>(title.as_str())</a></li> | 257 | + <span class="name">(title.as_str())</span> |
| 255 | - } | 258 | + </a> |
| 256 | - </ul> | 259 | + } |
| 257 | - } | 260 | + </div> |
| 258 | - </section> | 261 | + } |
| 259 | }) | 262 | }) |
| 260 | } | 263 | } |
| 261 | | 264 | |
| 262 | #[component] | 265 | #[component] |
| 263 | async fn wiki_history_body(lang: Lang, rows: Vec<RevisionRow>) -> Result<impl View> { | 266 | async fn wiki_history_body(lang: Lang, rows: Vec<RevisionRow>) -> Result<impl View> { |
| 264 | Ok(view! { | 267 | Ok(view! { |
| 265 | - <section class="card wiki-page fit-pane"> | 268 | + if rows.is_empty() { |
| 266 | - if rows.is_empty() { | 269 | + empty_state(title: g::t(lang, K::NoChangesYet)) |
| 267 | - empty_state(title: g::t(lang, K::NoChangesYet)) | 270 | + } else { |
| 268 | - } else { | 271 | + <div class="wiki-history"> |
| 269 | - <div class="table-wrap"> | 272 | + for row in rows.into_iter() { |
| 270 | - <table class="table wiki-history"> | 273 | + <a class="line" href=(row.href) data-kb-row=""> |
| 271 | - <tbody> | 274 | + <span class="name">(row.subject.as_str())</span> |
| 272 | - for row in rows.into_iter() { | 275 | + <span class="val"><code>(row.short.as_str())</code> " · " (row.author.as_str()) " · " rel_time(lang: lang, stamp: row.when.as_str())</span> |
| 273 | - <tr> | 276 | + </a> |
| 274 | - <td class="nowrap"><a href=(row.href)><code>(row.short.as_str())</code></a></td> | 277 | + } |
| 275 | - <td>(row.subject.as_str())</td> | 278 | + </div> |
| 276 | - <td class="muted small nowrap">(row.author.as_str())</td> | 279 | + } |
| 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> | | |
| 285 | }) | 280 | }) |
| 286 | } | 281 | } |
| 287 | | 282 | |
| @@ -297,29 +292,29 @@ async fn wiki_edit_body( |
| 297 | error: Option<String>, | 292 | error: Option<String>, |
| 298 | ) -> Result<impl View> { | 293 | ) -> Result<impl View> { |
| 299 | Ok(view! { | 294 | Ok(view! { |
| 300 | - <section class="card wiki-page fit-pane"> | 295 | + <section class="sec wiki-page"> |
| 301 | - <form method="post" action=(action.as_str()) class="stack wiki-form"> | 296 | + <form method="post" action=(action.as_str()) class="fields wiki-form"> |
| 302 | if let Some(message) = error { | 297 | if let Some(message) = error { |
| 303 | alert(message: message.as_str()) | 298 | alert(message: message.as_str()) |
| 304 | } | 299 | } |
| 305 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 300 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 306 | <input type="hidden" name="base" value=(base.as_str())> | 301 | <input type="hidden" name="base" value=(base.as_str())> |
| 307 | if is_new { | 302 | if is_new { |
| 308 | - <label> | 303 | + <div class="field"> |
| 309 | - <span>(g::t(lang, K::PageName))</span> | 304 | + <label for="wiki-name">(g::t(lang, K::PageName))</label> |
| 310 | - <input type="text" name="name" value=(name.as_str()) maxlength="100" required=(true) pattern="[A-Za-z0-9_-]+"> | 305 | + <input id="wiki-name" 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> | 306 | + <p class="hint">(g::t(lang, K::PageNameHint))</p> |
| 312 | - </label> | 307 | + </div> |
| 313 | } | 308 | } |
| 314 | - <label> | 309 | + <div class="field"> |
| 315 | - <span>(g::t(lang, K::ContentMarkdown))</span> | 310 | + <label for="wiki-content">(g::t(lang, K::ContentMarkdown))</label> |
| 316 | - <textarea name="content" rows="24" spellcheck="false">(content.as_str())</textarea> | 311 | + <textarea id="wiki-content" name="content" rows="24" spellcheck="false">(content.as_str())</textarea> |
| 317 | - <small class="muted">(g::t(lang, K::WikiLinkHint))</small> | 312 | + <p class="hint">(g::t(lang, K::WikiLinkHint))</p> |
| 318 | - </label> | 313 | + </div> |
| 319 | - <label> | 314 | + <div class="field"> |
| 320 | - <span>(g::t(lang, K::Summary))</span> | 315 | + <label for="wiki-message">(g::t(lang, K::Summary))</label> |
| 321 | - <input type="text" name="message" maxlength="200" autocomplete="off"> | 316 | + <input id="wiki-message" type="text" name="message" maxlength="200" autocomplete="off"> |
| 322 | - </label> | 317 | + </div> |
| 323 | <button type="submit" class="primary">(g::t(lang, K::SavePage))</button> | 318 | <button type="submit" class="primary">(g::t(lang, K::SavePage))</button> |
| 324 | </form> | 319 | </form> |
| 325 | </section> | 320 | </section> |
| @@ -519,10 +514,18 @@ async fn edit_screen( |
| 519 | } else { | 514 | } else { |
| 520 | name.replace('-', " ") | 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 | Ok(view! { cx => | 525 | Ok(view! { cx => |
| 523 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | 526 | shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), |
| 524 | repo_head(head: header) | 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 | wiki_edit_body(lang: lang, action: action, csrf: csrf, base: base, name: name.clone(), is_new: is_new, content: content, error: error) | 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 | enabled: bool, | 688 | enabled: bool, |
| 686 | ) -> Result<impl View> { | 689 | ) -> Result<impl View> { |
| 687 | Ok(view! { | 690 | Ok(view! { |
| 688 | - <form method="post" action=(action.as_str()) class="card rows-pane wiki-form"> | 691 | + <section class="sec"> |
| 689 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 692 | + <h2>(g::t(lang, K::WikiSettings))</h2> |
| 690 | - <label class="row-line row-field"> | 693 | + <form method="post" action=(action.as_str()) class="fields wiki-form"> |
| 691 | - <span class="row-main"> | 694 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 692 | - <span class="row-title">(g::t(lang, K::EnableWiki))</span> | 695 | + <label class="switch"> |
| 693 | - <span class="row-status">(g::t(lang, K::WikiDisabledHint))</span> | | |
| 694 | - </span> | | |
| 695 | - <span class="row-control"> | | |
| 696 | <input type="checkbox" name="enabled" value="1" checked=(enabled)> | 696 | <input type="checkbox" name="enabled" value="1" checked=(enabled)> |
| 697 | - </span> | 697 | + <span>(g::t(lang, K::EnableWiki))</span> |
| 698 | - </label> | 698 | + </label> |
| 699 | - <div class="row-foot"> | 699 | + <p class="hint">(g::t(lang, K::WikiDisabledHint))</p> |
| 700 | <button type="submit" class="primary">(g::t(lang, K::Save))</button> | 700 | <button type="submit" class="primary">(g::t(lang, K::Save))</button> |
| 701 | - </div> | 701 | + </form> |
| 702 | - </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 | /// The contexts of one commit: icon, context name, description and a details link. | 168 | /// The contexts of one commit: icon, context name, description and a details link. |
| 152 | #[component] | 169 | #[component] |
| 153 | pub async fn status_list(items: Vec<StatusItem>, lang: Lang) -> Result<impl View> { | 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 | <span class=(item.icon_class.as_str())>(item.icon)</span> | 175 | <span class=(item.icon_class.as_str())>(item.icon)</span> |
| 159 | <code>(item.context.as_str())</code> | 176 | <code>(item.context.as_str())</code> |
| 160 | if item.has_description { | 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 | if item.has_link { | 180 | if item.has_link { |
| 164 | <a class="small" href=(item.link.as_str()) rel="nofollow noopener noreferrer">(g::t(lang, K::DetailsLink))</a> | 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 | diff_toolbar(bar: bar, lang: lang) | 567 | diff_toolbar(bar: bar, lang: lang) |
| 568 | } | 568 | } |
| 569 | if truncated_files { | 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 | if no_files { | 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 | } else { | 574 | } else { |
| 575 | <ul class="diff-index"> | 575 | <ul class="diff-index"> |
| 576 | for item in nav.iter() { | 576 | for item in nav.iter() { |
| @@ -596,19 +596,15 @@ async fn diff_toolbar(bar: Toolbar, lang: Lang) -> Result<impl View> { |
| 596 | let split_on = if bar.split { "true" } else { "false" }; | 596 | let split_on = if bar.split { "true" } else { "false" }; |
| 597 | let ws_on = if bar.ignore_ws { "true" } else { "false" }; | 597 | let ws_on = if bar.ignore_ws { "true" } else { "false" }; |
| 598 | Ok(view! { | 598 | Ok(view! { |
| 599 | - <div class="diff-toolbar"> | 599 | + <nav class="sub diff-toolbar" aria-label=(b::t(lang, b::K::DiffView))> |
| 600 | - <div class="seg" role="group" 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 class="seg-item" 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 class="seg-item" 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> |
| 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> | | |
| 605 | if let Some((patch, diff)) = bar.downloads { | 603 | if let Some((patch, diff)) = bar.downloads { |
| 606 | - <span class="diff-downloads"> | 604 | + <a class="act quiet" href=(patch.as_str()) title=(b::t(lang, b::K::PatchTitle))>(b::t(lang, b::K::PatchLink))</a> |
| 607 | - <a 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> |
| 608 | - <a href=(diff.as_str()) title=(b::t(lang, b::K::DiffTitle))>(b::t(lang, b::K::DiffLink))</a> | | |
| 609 | - </span> | | |
| 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 | <header class="diff-file-header"> | 625 | <header class="diff-file-header"> |
| 630 | <code class="diff-path">(file.label.as_str())</code> | 626 | <code class="diff-path">(file.label.as_str())</code> |
| 631 | <span class="diff-file-meta"> | 627 | <span class="diff-file-meta"> |
| 632 | - <span class="muted small">(file.status)</span> | 628 | + <span class="hint">(file.status)</span> |
| 633 | <span class="diff-stats"><span class="add">(add_label.as_str())</span> " " <span class="del">(del_label.as_str())</span></span> | 629 | <span class="diff-stats"><span class="add">(add_label.as_str())</span> " " <span class="del">(del_label.as_str())</span></span> |
| 634 | </span> | 630 | </span> |
| 635 | </header> | 631 | </header> |
| 636 | if file.binary { | 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 | } else { | 634 | } else { |
| 639 | if file.truncated { | 635 | if file.truncated { |
| 640 | if file.has_blob { | 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 | } else { | 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 | if has_rows { | 642 | if has_rows { |
| @@ -803,25 +799,25 @@ async fn inline_comment_form(form: InlineForm, lang: Lang) -> Result<impl View> |
| 803 | }; | 799 | }; |
| 804 | let suggest_label = pr_g::t(lang, PrK::SuggestChange); | 800 | let suggest_label = pr_g::t(lang, PrK::SuggestChange); |
| 805 | Ok(view! { | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 803 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 808 | <input type="hidden" name="file_index" value=(file_index.as_str())> | 804 | <input type="hidden" name="file_index" value=(file_index.as_str())> |
| 809 | <input type="hidden" name="side" value=(side)> | 805 | <input type="hidden" name="side" value=(side)> |
| 810 | <input type="hidden" name="line" value=(line.as_str())> | 806 | <input type="hidden" name="line" value=(line.as_str())> |
| 811 | <input type="hidden" name="head_oid" value=(head_oid.as_str())> | 807 | <input type="hidden" name="head_oid" value=(head_oid.as_str())> |
| 812 | - <label> | 808 | + <div class="field"> |
| 813 | - <span>(g::t(lang, K::CommentLabel))</span> | 809 | + <label for="inline-comment-body">(g::t(lang, K::CommentLabel))</label> |
| 814 | - <textarea name="body" rows="4"></textarea> | 810 | + <textarea id="inline-comment-body" name="body" rows="4"></textarea> |
| 815 | - </label> | 811 | + </div> |
| 816 | - <div class="issue-actions"> | 812 | + <div class="acts"> |
| 817 | - <button type="submit" name="action" value="single">(g::t(lang, K::AddSingleComment))</button> | 813 | + <button type="submit" class="primary" name="action" value="single">(g::t(lang, K::AddSingleComment))</button> |
| 818 | if can_review { | 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 | if let Some(text) = suggest_line { | 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 | </div> | 821 | </div> |
| 826 | </form> | 822 | </form> |
| 827 | }) | 823 | }) |
| @@ -5,6 +5,7 @@ pub mod commit_line; |
| 5 | pub mod commit_status; | 5 | pub mod commit_status; |
| 6 | pub mod diff; | 6 | pub mod diff; |
| 7 | pub mod heatmap; | 7 | pub mod heatmap; |
| | 8 | +pub mod parts; |
| 8 | pub mod repo_list; | 9 | pub mod repo_list; |
| 9 | pub mod review_thread; | 10 | pub mod review_thread; |
| 10 | pub mod timeline; | 11 | pub mod timeline; |
| @@ -392,7 +393,6 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> |
| 392 | let admin_label = ad::t(lang, AK::AdminArea); | 393 | let admin_label = ad::t(lang, AK::AdminArea); |
| 393 | let logout_label = t(lang, Key::LogOut); | 394 | let logout_label = t(lang, Key::LogOut); |
| 394 | let bell_title = i18n::t(lang, Key::Notifications); | 395 | let bell_title = i18n::t(lang, Key::Notifications); |
| 395 | - let explore_label = t(lang, Key::Explore); | | |
| 396 | let open_label = mi::t(lang, MK::OpenNotifications); | 396 | let open_label = mi::t(lang, MK::OpenNotifications); |
| 397 | let clear_label = mi::t(lang, MK::ClearNotifications); | 397 | let clear_label = mi::t(lang, MK::ClearNotifications); |
| 398 | let clear_title = mi::t(lang, MK::MarkAllRead); | 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 | </form> | 443 | </form> |
| 444 | </div> | 444 | </div> |
| 445 | </details> | 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 | <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> | 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 | if corner.unread > 0 { | 447 | if corner.unread > 0 { |
| 449 | <span class="bell-count">(corner.unread.to_string())</span> | 448 | <span class="bell-count">(corner.unread.to_string())</span> |
| @@ -524,8 +523,7 @@ pub async fn shell( |
| 524 | } else { | 523 | } else { |
| 525 | None | 524 | None |
| 526 | }; | 525 | }; |
| 527 | - let section_menu = section.clone(); | 526 | + let width = page_width(uri(__cx).path()); |
| 528 | - let site_shell = section.as_ref().is_some_and(|s| s.site); | | |
| 529 | let theme_attr = crate::theme::data_theme(__cx, viewer.map(|(user, _)| user)); | 527 | let theme_attr = crate::theme::data_theme(__cx, viewer.map(|(user, _)| user)); |
| 530 | // The relative-time wording and the server's clock, for nav.js to keep `<time data-rel>` labels current. | 528 | // The relative-time wording and the server's clock, for nav.js to keep `<time data-rel>` labels current. |
| 531 | let rel_words_attr = rel_words(lang); | 529 | let rel_words_attr = rel_words(lang); |
| @@ -588,7 +586,7 @@ pub async fn shell( |
| 588 | let anonymous = viewer.is_none(); | 586 | let anonymous = viewer.is_none(); |
| 589 | let search_label = o::t(lang, OK::SearchPublicRepos); | 587 | let search_label = o::t(lang, OK::SearchPublicRepos); |
| 590 | let palette_label = br::t(lang, br::K::PaletteOpen).to_owned(); | 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 | // The path bar: one segment per part of the request path, the last one unlinked. | 590 | // The path bar: one segment per part of the request path, the last one unlinked. |
| 593 | let segments = path_segments(uri(__cx).path(), title); | 591 | let segments = path_segments(uri(__cx).path(), title); |
| 594 | let path_attr = segments | 592 | let path_attr = segments |
| @@ -694,20 +692,14 @@ pub async fn shell( |
| 694 | </head> | 692 | </head> |
| 695 | <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)> | 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 | <header class="topbar"> | 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 | <a class="wordmark" href="/"> | 695 | <a class="wordmark" href="/"> |
| 708 | <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> | 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 | "forge" | 697 | "forge" |
| 710 | </a> | 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 | <nav class="pathbar" aria-label=(mi::t(lang, MK::BreadcrumbNav))> | 703 | <nav class="pathbar" aria-label=(mi::t(lang, MK::BreadcrumbNav))> |
| 712 | if signed_in { | 704 | if signed_in { |
| 713 | <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> | 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 | </nav> | 733 | </nav> |
| 742 | if signed_in { | 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 | <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)) | 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 | 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()) | 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 | data-runs-label=(runs_label) aria-live="polite"> | 737 | data-runs-label=(runs_label) aria-live="polite"> |
| @@ -767,9 +756,6 @@ pub async fn shell( |
| 767 | <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> | 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 | <input type="search" name="q" placeholder=(search_label) aria-label=(search_label)> | 757 | <input type="search" name="q" placeholder=(search_label) aria-label=(search_label)> |
| 769 | </form> | 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 | <form class="theme-form" method="post" action="/-/theme"> | 759 | <form class="theme-form" method="post" action="/-/theme"> |
| 774 | if let Some(csrf) = theme_csrf { | 760 | if let Some(csrf) = theme_csrf { |
| 775 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 761 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| @@ -788,7 +774,6 @@ pub async fn shell( |
| 788 | } | 774 | } |
| 789 | </button> | 775 | </button> |
| 790 | </form> | 776 | </form> |
| 791 | - <a class="topbar-link" href="/explore">(t(lang, Key::Explore))</a> | | |
| 792 | <a class="button primary" href="/login">(t(lang, Key::LogIn))</a> | 777 | <a class="button primary" href="/login">(t(lang, Key::LogIn))</a> |
| 793 | } | 778 | } |
| 794 | </header> | 779 | </header> |
| @@ -804,14 +789,12 @@ pub async fn shell( |
| 804 | </form> | 789 | </form> |
| 805 | </div> | 790 | </div> |
| 806 | } | 791 | } |
| 807 | - <div class=(if site_shell { "shell shell-site" } else { "shell" })> | 792 | + <div class="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 | - } | | |
| 813 | <div class="shell-body"> | 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 | (child) | 798 | (child) |
| 816 | </main> | 799 | </main> |
| 817 | <footer class="site-footer"> | 800 | <footer class="site-footer"> |
| @@ -851,86 +834,67 @@ pub struct NavItem { |
| 851 | pub key: &'static str, | 834 | pub key: &'static str, |
| 852 | pub href: String, | 835 | pub href: String, |
| 853 | pub label: &'static str, | 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 | #[derive(Clone)] | 840 | #[derive(Clone)] |
| 859 | pub struct Section { | 841 | pub struct Section { |
| 860 | pub title: String, | 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 | pub items: Vec<NavItem>, | 843 | pub items: Vec<NavItem>, |
| 865 | pub current: &'static str, | 844 | pub current: &'static str, |
| 866 | /// The stream the section's pages follow, or empty when they follow none. | 845 | /// The stream the section's pages follow, or empty when they follow none. |
| 867 | pub live: &'static str, | 846 | pub live: &'static str, |
| 868 | - /// True for the site-wide sections (admin and the user's settings), which lay their pages out | 847 | +} |
| 869 | - /// as panes across the window. An organization's settings keep their own layout. | 848 | + |
| 870 | - pub site: bool, | 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 | pub fn admin_items(lang: Lang) -> Vec<NavItem> { | 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 | key, | 873 | key, |
| 876 | href: href.to_owned(), | 874 | href: href.to_owned(), |
| 877 | label, | 875 | label, |
| 878 | - icon, | | |
| 879 | }; | 876 | }; |
| 880 | vec![ | 877 | vec![ |
| 881 | - item("users", "/admin/users", ad::t(lang, AK::Users), "users"), | 878 | + item("users", "/admin/users", ad::t(lang, AK::Users)), |
| 882 | - item( | 879 | + item("invites", "/admin/invites", ad::t(lang, AK::Invites)), |
| 883 | - "health", | 880 | + item("runners", "/admin/runners", ad::t(lang, AK::Runners)), |
| 884 | - "/admin/health", | 881 | + item("server", "/admin/server", ad::t(lang, AK::ServerSettings)), |
| 885 | - crate::i18n::accounts::t(lang, crate::i18n::accounts::A::Health), | 882 | + item("mail", "/admin/mail", ad::t(lang, AK::Mail)), |
| 886 | - "health", | 883 | + item("backups", "/admin/backups", ad::t(lang, AK::Backups)), |
| 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 | - ), | | |
| 914 | item( | 884 | item( |
| 915 | "replication", | 885 | "replication", |
| 916 | "/admin/replication", | 886 | "/admin/replication", |
| 917 | ad::t(lang, AK::Replication), | 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 | /// The profile tab bar in its order, for a person's or an organization's profile: overview, | 898 | /// The profile tab bar in its order, for a person's or an organization's profile: overview, |
| 935 | /// repositories, snippets and stars (people only), packages, organizations (the viewer's own | 899 | /// repositories, snippets and stars (people only), packages, organizations (the viewer's own |
| 936 | /// profile only) and, for an organization the viewer belongs to, members and teams. The hrefs are | 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 | org_member: bool, | 907 | org_member: bool, |
| 944 | ) -> Vec<NavItem> { | 908 | ) -> Vec<NavItem> { |
| 945 | let profile = format!("/{}", enc(username)); | 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 | key, | 911 | key, |
| 948 | href: format!("{profile}?tab={key}"), | 912 | href: format!("{profile}?tab={key}"), |
| 949 | label, | 913 | label, |
| 950 | - icon, | | |
| 951 | }; | 914 | }; |
| 952 | let mut items = vec![ | 915 | let mut items = vec![ |
| 953 | - tab("overview", o::t(lang, OK::TabOverview), "profile"), | 916 | + tab("overview", o::t(lang, OK::TabOverview)), |
| 954 | - tab("repositories", o::t(lang, OK::Repositories), ""), | 917 | + tab("repositories", o::t(lang, OK::Repositories)), |
| 955 | ]; | 918 | ]; |
| 956 | if !is_org { | 919 | if !is_org { |
| 957 | - items.push(tab("snippets", cm::t(lang, CK::Snippets), "")); | 920 | + items.push(tab("snippets", cm::t(lang, CK::Snippets))); |
| 958 | - items.push(tab("stars", o::t(lang, OK::TabStars), "")); | 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 | if own_profile { | 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 | if is_org && org_member { | 927 | if is_org && org_member { |
| 965 | let org = format!("/org/{}", enc(username)); | 928 | let org = format!("/org/{}", enc(username)); |
| @@ -967,13 +930,11 @@ pub fn profile_items( |
| 967 | key: "members", | 930 | key: "members", |
| 968 | href: format!("{org}/members"), | 931 | href: format!("{org}/members"), |
| 969 | label: o::t(lang, OK::Members), | 932 | label: o::t(lang, OK::Members), |
| 970 | - icon: "users", | | |
| 971 | }); | 933 | }); |
| 972 | items.push(NavItem { | 934 | items.push(NavItem { |
| 973 | key: "teams", | 935 | key: "teams", |
| 974 | href: format!("{org}/teams"), | 936 | href: format!("{org}/teams"), |
| 975 | label: o::t(lang, OK::Teams), | 937 | label: o::t(lang, OK::Teams), |
| 976 | - icon: "teams", | | |
| 977 | }); | 938 | }); |
| 978 | } | 939 | } |
| 979 | items | 940 | items |
| @@ -986,7 +947,6 @@ pub fn global_items(lang: Lang, can_create_org: bool) -> Vec<NavItem> { |
| 986 | key, | 947 | key, |
| 987 | href: href.to_owned(), | 948 | href: href.to_owned(), |
| 988 | label, | 949 | label, |
| 989 | - icon: "", | | |
| 990 | }; | 950 | }; |
| 991 | let mut items = vec![ | 951 | let mut items = vec![ |
| 992 | item("explore", "/explore", t(lang, Key::Explore)), | 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 | pub fn settings_items(lang: Lang) -> Vec<NavItem> { | 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 | key, | 980 | key, |
| 1020 | href: href.to_owned(), | 981 | href: href.to_owned(), |
| 1021 | label, | 982 | label, |
| 1022 | - icon, | | |
| 1023 | }; | 983 | }; |
| 1024 | vec![ | 984 | vec![ |
| 1025 | - item( | 985 | + item("profile", "/settings/profile", t(lang, Key::Profile)), |
| 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 | - ), | | |
| 1057 | item( | 986 | item( |
| 1058 | "appearance", | 987 | "appearance", |
| 1059 | "/settings/appearance", | 988 | "/settings/appearance", |
| 1060 | mi::t(lang, MK::Appearance), | 989 | mi::t(lang, MK::Appearance), |
| 1061 | - "appearance", | | |
| 1062 | ), | 990 | ), |
| 1063 | item( | 991 | item( |
| 1064 | - "export", | 992 | + "notifications", |
| 1065 | - "/settings/export", | 993 | + "/settings/notifications", |
| 1066 | - mg::t(lang, MGK::SettingsExport), | 994 | + t(lang, Key::Notifications), |
| 1067 | - "export", | | |
| 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 | 1002 | +/// The tabs for a path under `/admin` or `/settings`, or `None` elsewhere. Picked from the path |
| 1073 | -/// the path alone, so every page under those prefixes gets it. `/settings/security/log` is | 1003 | +/// alone, so every page under those prefixes gets them. A page folded into another tab marks that |
| 1074 | -/// Security's page, so it highlights Security. | 1004 | +/// tab: sessions are part of Security, and GPG keys and tokens part of Keys. |
| 1075 | pub fn section_for(lang: Lang, path: &str) -> Option<Section> { | 1005 | pub fn section_for(lang: Lang, path: &str) -> Option<Section> { |
| 1076 | let mut parts = path.trim_matches('/').split('/'); | 1006 | let mut parts = path.trim_matches('/').split('/'); |
| 1077 | let first = parts.next()?; | 1007 | let first = parts.next()?; |
| @@ -1079,30 +1009,13 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { |
| 1079 | let (title, items) = match first { | 1009 | let (title, items) = match first { |
| 1080 | "admin" => (ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), | 1010 | "admin" => (ad::t(lang, AK::AdminArea).to_owned(), admin_items(lang)), |
| 1081 | "settings" => (o::t(lang, OK::Settings).to_owned(), settings_items(lang)), | 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 | _ => return None, | 1012 | _ => return None, |
| 1105 | }; | 1013 | }; |
| | 1014 | + let second = match second { |
| | 1015 | + "sessions" => "security", |
| | 1016 | + "gpg" | "tokens" => "keys", |
| | 1017 | + other => other, |
| | 1018 | + }; |
| 1106 | let current = items | 1019 | let current = items |
| 1107 | .iter() | 1020 | .iter() |
| 1108 | .find(|item| item.key == second) | 1021 | .find(|item| item.key == second) |
| @@ -1115,123 +1028,34 @@ pub fn section_for(lang: Lang, path: &str) -> Option<Section> { |
| 1115 | }; | 1028 | }; |
| 1116 | Some(Section { | 1029 | Some(Section { |
| 1117 | title, | 1030 | title, |
| 1118 | - back: t(lang, Key::BackToSite), | | |
| 1119 | - back_href: "/".to_owned(), | | |
| 1120 | items, | 1031 | items, |
| 1121 | current, | 1032 | current, |
| 1122 | live, | 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 | 1037 | +/// One row of text tabs, with `aria-current="page"` on the current one. |
| 1128 | -/// `aria-current="page"` on the current one. | | |
| 1129 | #[component] | 1038 | #[component] |
| 1130 | -async fn section_nav( | 1039 | +async fn section_tabs( |
| 1131 | - title: &str, | 1040 | + label: &str, |
| 1132 | - back: &str, | | |
| 1133 | - back_href: &str, | | |
| 1134 | items: Vec<NavItem>, | 1041 | items: Vec<NavItem>, |
| 1135 | current: &str, | 1042 | current: &str, |
| 1136 | live: &str, | 1043 | live: &str, |
| 1137 | ) -> Result<impl View> { | 1044 | ) -> Result<impl View> { |
| 1138 | let live = (!live.is_empty()).then_some(live); | 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 | .into_iter() | 1047 | .into_iter() |
| 1141 | .map(|item| { | 1048 | .map(|item| { |
| 1142 | let on = item.key == current; | 1049 | let on = item.key == current; |
| 1143 | - let class = if on { "side-link on" } else { "side-link" }; | 1050 | + (item, on) |
| 1144 | - (item, on, class) | | |
| 1145 | }) | 1051 | }) |
| 1146 | .collect(); | 1052 | .collect(); |
| 1147 | Ok(view! { | 1053 | Ok(view! { |
| 1148 | - <nav class="side-links" aria-label=(back)> | 1054 | + <nav class="tabs" aria-label=(label) data-live=(live)> |
| 1149 | - <a class="side-link" href=(back_href)> | 1055 | + for (item, on) in links.into_iter() { |
| 1150 | - nav_icon(name: "back") | 1056 | + <a href=(item.href) aria-current=(on.then_some("page"))>(item.label)</a> |
| 1151 | - (back) | 1057 | + } |
| 1152 | - </a> | | |
| 1153 | </nav> | 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 | #[default] child: Child<'_>, | 1119 | #[default] child: Child<'_>, |
| 1296 | ) -> Result<impl View> { | 1120 | ) -> Result<impl View> { |
| 1297 | Ok(view! { | 1121 | Ok(view! { |
| 1298 | - <div class="empty-state"> | 1122 | + <div class="sec empty-state"> |
| 1299 | - <p class="empty-state-title">(title)</p> | 1123 | + <p class="state">(title)</p> |
| 1300 | if let Some(hint) = hint { | 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 | </div> | 1128 | </div> |
| 1305 | }) | 1129 | }) |
| 1306 | } | 1130 | } |
| @@ -2070,7 +1894,7 @@ mod shell_tests { |
| 2070 | assert!(tag.contains("defer"), "{tag}"); | 1894 | assert!(tag.contains("defer"), "{tag}"); |
| 2071 | assert_no_inline_scripts(&html); | 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 | assert!(html.contains("data-hard=\"true\" method=\"post\" action=\"/login\"")); | 1898 | assert!(html.contains("data-hard=\"true\" method=\"post\" action=\"/login\"")); |
| 2075 | | 1899 | |
| 2076 | // An anonymous page renders the default colours. | 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 | Ok(view! { | 52 | Ok(view! { |
| 53 | <ul class="repo-list"> | 53 | <ul class="repo-list"> |
| 54 | for row in rows.into_iter() { | 54 | for row in rows.into_iter() { |
| 55 | - <li class="repo-item" data-kb-row=""> | 55 | + <li class="line repo-item" data-kb-row=""> |
| 56 | - <a class="repo-name" href=(row.href.as_str())>(row.title.as_str())</a> | 56 | + <a class="name repo-name" href=(row.href.as_str())>(row.title.as_str())</a> |
| 57 | <span class=(badge_class(row.visibility))>(i18n::visibility_label(lang, row.visibility))</span> | 57 | <span class=(badge_class(row.visibility))>(i18n::visibility_label(lang, row.visibility))</span> |
| 58 | if !row.description.is_empty() { | 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 | "\u{2605} " (row.stars.to_string()) | 62 | "\u{2605} " (row.stars.to_string()) |
| 63 | (before) | 63 | (before) |
| 64 | <time data-rel="true" datetime=(row.when.iso.as_str()) title=(row.when.absolute.as_str())>(row.when.relative.as_str())</time> | 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 | #[component] | 81 | #[component] |
| 82 | pub async fn sort_chips(links: Vec<SortLink>, lang: Lang) -> Result<impl View> { | 82 | pub async fn sort_chips(links: Vec<SortLink>, lang: Lang) -> Result<impl View> { |
| 83 | Ok(view! { | 83 | Ok(view! { |
| 84 | - <nav class="explore-sort" aria-label=(g::t(lang, K::SortNav))> | 84 | + <nav class="sub" aria-label=(g::t(lang, K::SortNav))> |
| 85 | - <span class="muted small">(g::t(lang, K::SortBy))</span> | 85 | + <span>(g::t(lang, K::SortBy))</span> |
| 86 | for link in links.into_iter() { | 86 | for link in links.into_iter() { |
| 87 | if link.current { | 87 | if link.current { |
| 88 | <span class="current" aria-current="true">(link.label)</span> | 88 | <span class="current" aria-current="true">(link.label)</span> |
| @@ -15,6 +15,7 @@ use crate::i18n::Lang; |
| 15 | use crate::i18n::pulls_review::{self as g, K}; | 15 | use crate::i18n::pulls_review::{self as g, K}; |
| 16 | use crate::pages::issue_parts::When; | 16 | use crate::pages::issue_parts::When; |
| 17 | use crate::render::markdown::{LinkContext, render_markdown}; | 17 | use crate::render::markdown::{LinkContext, render_markdown}; |
| | 18 | +use crate::views::parts::{confirm_act, post_act}; |
| 18 | use crate::views::{avatar_url, display_name, now_unix, user_href, user_link}; | 19 | use crate::views::{avatar_url, display_name, now_unix, user_href, user_link}; |
| 19 | | 20 | |
| 20 | /// What the Apply control of a suggestion shows. A root without a state shows the diff only. | 21 | /// What the Apply control of a suggestion shows. A root without a state shows the diff only. |
| @@ -350,14 +351,10 @@ async fn thread_actions( |
| 350 | return_to: String, | 351 | return_to: String, |
| 351 | ) -> Result<impl View> { | 352 | ) -> Result<impl View> { |
| 352 | Ok(view! { | 353 | Ok(view! { |
| 353 | - <div class="review-thread-actions"> | 354 | + <div class="acts review-thread-actions"> |
| 354 | if let Some(action) = resolve_action { | 355 | if let Some(action) = resolve_action { |
| 355 | - <form method="post" action=(action.as_str()) class="review-inline"> | 356 | + post_act(label: resolve_label.as_str(), action: action.as_str(), csrf: csrf.as_str(), |
| 356 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 357 | + fields: vec![("resolved".to_owned(), resolve_value.clone()), ("return".to_owned(), return_to.clone())]) |
| 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> | | |
| 361 | } | 358 | } |
| 362 | </div> | 359 | </div> |
| 363 | }) | 360 | }) |
| @@ -373,16 +370,14 @@ async fn reply_form( |
| 373 | let label = g::t(lang, K::ReplyLabel); | 370 | let label = g::t(lang, K::ReplyLabel); |
| 374 | let button = g::t(lang, K::ReplyButton); | 371 | let button = g::t(lang, K::ReplyButton); |
| 375 | Ok(view! { | 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 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 374 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 378 | <input type="hidden" name="return" value=(return_to.as_str())> | 375 | <input type="hidden" name="return" value=(return_to.as_str())> |
| 379 | - <label> | 376 | + <label class="field"> |
| 380 | <span>(label)</span> | 377 | <span>(label)</span> |
| 381 | <textarea name="body" rows="3"></textarea> | 378 | <textarea name="body" rows="3"></textarea> |
| 382 | </label> | 379 | </label> |
| 383 | - <div class="issue-actions"> | 380 | + <button type="submit" class="primary">(button)</button> |
| 384 | - <button type="submit">(button)</button> | | |
| 385 | - </div> | | |
| 386 | </form> | 381 | </form> |
| 387 | }) | 382 | }) |
| 388 | } | 383 | } |
| @@ -408,6 +403,7 @@ async fn thread_comment( |
| 408 | let edited = g::t(lang, K::Edited); | 403 | let edited = g::t(lang, K::Edited); |
| 409 | let edit = g::t(lang, K::EditLink); | 404 | let edit = g::t(lang, K::EditLink); |
| 410 | let delete = g::t(lang, K::DeleteButton); | 405 | let delete = g::t(lang, K::DeleteButton); |
| | 406 | + let has_acts = edit_href.is_some() || delete_href.is_some(); |
| 411 | Ok(view! { | 407 | Ok(view! { |
| 412 | <article class="review-comment"> | 408 | <article class="review-comment"> |
| 413 | <header class="review-comment-head"> | 409 | <header class="review-comment-head"> |
| @@ -417,23 +413,22 @@ async fn thread_comment( |
| 417 | if let Some(href) = history_href { | 413 | if let Some(href) = history_href { |
| 418 | <a class="issue-edited" href=(href.as_str())>(edited)</a> | 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 | </header> | 416 | </header> |
| 433 | for part in parts.into_iter() { | 417 | for part in parts.into_iter() { |
| 434 | comment_part(part: part, csrf: csrf.clone(), return_to: return_to.clone(), | 418 | comment_part(part: part, csrf: csrf.clone(), return_to: return_to.clone(), |
| 435 | lang: lang) | 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 | </article> | 432 | </article> |
| 438 | }) | 433 | }) |
| 439 | } | 434 | } |
| @@ -475,12 +470,10 @@ async fn comment_part( |
| 475 | <div class="review-suggestion-line add"><span class="review-suggestion-sign">(added_sign)</span><code>(line.as_str())</code></div> | 470 | <div class="review-suggestion-line add"><span class="review-suggestion-sign">(added_sign)</span><code>(line.as_str())</code></div> |
| 476 | } | 471 | } |
| 477 | if let Some(action) = apply_action { | 472 | if let Some(action) = apply_action { |
| 478 | - <form method="post" action=(action.as_str()) class="review-suggestion-apply"> | 473 | + <div class="acts review-suggestion-apply"> |
| 479 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 474 | + post_act(label: apply_label, action: action.as_str(), csrf: csrf.as_str(), |
| 480 | - <input type="hidden" name="return" value=(return_to.as_str())> | 475 | + fields: vec![("block".to_owned(), block.clone()), ("return".to_owned(), return_to.clone())]) |
| 481 | - <input type="hidden" name="block" value=(block.as_str())> | 476 | + </div> |
| 482 | - <button type="submit">(apply_label)</button> | | |
| 483 | - </form> | | |
| 484 | } | 477 | } |
| 485 | if outdated { | 478 | if outdated { |
| 486 | <p class="review-suggestion-outdated">(outdated_text)</p> | 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 | python3 "$ROOT/scripts/audit/seed.py" "http://127.0.0.1:$PORT" "$OUT" 2>&1 | tee "$OUT/seed.log" | 89 | python3 "$ROOT/scripts/audit/seed.py" "http://127.0.0.1:$PORT" "$OUT" 2>&1 | tee "$OUT/seed.log" |
| 90 | fi | 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 | echo "[run] screenshots" | 99 | echo "[run] screenshots" |
| 93 | AUDIT_PROXY_PORT="${AUDIT_PROXY_PORT:-$((PORT + 10))}" \ | 100 | AUDIT_PROXY_PORT="${AUDIT_PROXY_PORT:-$((PORT + 10))}" \ |
| 94 | python3 "$ROOT/scripts/audit/shoot.py" "http://127.0.0.1:$PORT" "$OUT" "$ROOT/crates/forge-web/src" 2>&1 | tee "$OUT/shoot.log" | 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 | def main(): | 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 | os.makedirs(SHOTS, exist_ok=True) | 539 | os.makedirs(SHOTS, exist_ok=True) |
| 532 | os.makedirs(os.path.join(OUT, "tmp"), exist_ok=True) | 540 | os.makedirs(os.path.join(OUT, "tmp"), exist_ok=True) |
| 533 | try: | 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 | @media (max-width: 600px) { | 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 | .reset-link { | 59 | .reset-link { |
| @@ -349,14 +68,6 @@ dialog.session-dialog { |
| 349 | user-select: all; | 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 | // A status dot: the summary's, and each service row's. | 71 | // A status dot: the summary's, and each service row's. |
| 361 | .health-dot { | 72 | .health-dot { |
| 362 | display: inline-block; | 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 | // The data directory's usage bar: 8px tall, the fill turns red at 90%. | 95 | // The data directory's usage bar: 8px tall, the fill turns red at 90%. |
| 394 | .health-path { | 96 | .health-path { |
| 395 | margin-top: 4px; | 97 | margin-top: 4px; |
| 396 | overflow-wrap: anywhere; | 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 | background: var(--warn); | 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 | // Phone: the status word goes under the name, indented to line up with it. | 11 | // Phone: the status word goes under the name, indented to line up with it. |
| 74 | @media (max-width: 600px) { | 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 | // A small-range number on the server settings page steps like the runner's Max: the pill keeps its | 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 | .head-more-list { | 74 | .head-more-list { |
| 91 | right: 0; | 75 | right: 0; |
| 92 | display: flex; | 76 | display: flex; |
| @@ -5,8 +5,6 @@ |
| 5 | // is the colour fade on the name. The hover colour of a tree name is restored at the end. | 5 | // is the colour fade on the name. The hover colour of a tree name is restored at the end. |
| 6 | | 6 | |
| 7 | // The base state, for every row in these lists: the name is --text-2. | 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 | [data-kb-row] .commit-summary, | 8 | [data-kb-row] .commit-summary, |
| 11 | .repo-item .repo-name, | 9 | .repo-item .repo-name, |
| 12 | .pin-card .repo-name { | 10 | .pin-card .repo-name { |
| @@ -14,8 +12,6 @@ |
| 14 | } | 12 | } |
| 15 | | 13 | |
| 16 | @media (prefers-reduced-motion: no-preference) { | 14 | @media (prefers-reduced-motion: no-preference) { |
| 17 | - .tree-table tbody tr .tree-label > a, | | |
| 18 | - .tree-table tbody tr .tree-label > span, | | |
| 19 | [data-kb-row] .commit-summary, | 15 | [data-kb-row] .commit-summary, |
| 20 | .repo-item .repo-name, | 16 | .repo-item .repo-name, |
| 21 | .pin-card .repo-name { | 17 | .pin-card .repo-name { |
| @@ -24,8 +20,6 @@ |
| 24 | } | 20 | } |
| 25 | | 21 | |
| 26 | // Level 1: slightly brighter than the base. | 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 | [data-kb-row][data-heat="1"] .commit-summary, | 23 | [data-kb-row][data-heat="1"] .commit-summary, |
| 30 | .repo-item[data-heat="1"] .repo-name, | 24 | .repo-item[data-heat="1"] .repo-name, |
| 31 | .pin-card[data-heat="1"] .repo-name { | 25 | .pin-card[data-heat="1"] .repo-name { |
| @@ -33,8 +27,6 @@ |
| 33 | } | 27 | } |
| 34 | | 28 | |
| 35 | // Level 2: brighter. | 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 | [data-kb-row][data-heat="2"] .commit-summary, | 30 | [data-kb-row][data-heat="2"] .commit-summary, |
| 39 | .repo-item[data-heat="2"] .repo-name, | 31 | .repo-item[data-heat="2"] .repo-name, |
| 40 | .pin-card[data-heat="2"] .repo-name { | 32 | .pin-card[data-heat="2"] .repo-name { |
| @@ -42,8 +34,6 @@ |
| 42 | } | 34 | } |
| 43 | | 35 | |
| 44 | // Level 3: the newest rows. The name is --text and bold, and the time is --text. | 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 | [data-kb-row][data-heat="3"] .commit-summary, | 37 | [data-kb-row][data-heat="3"] .commit-summary, |
| 48 | .repo-item[data-heat="3"] .repo-name, | 38 | .repo-item[data-heat="3"] .repo-name, |
| 49 | .pin-card[data-heat="3"] .repo-name { | 39 | .pin-card[data-heat="3"] .repo-name { |
| @@ -55,7 +45,3 @@ |
| 55 | color: var(--text); | 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 | // Commit page: one line under the title holds the hash, signature, author, time, parents, checks | 3 | // Commit page: one line under the title holds the hash, signature, author, time, parents, checks |
| 63 | // and the Browse files link. It wraps on a narrow window and never becomes a card. | 4 | // and the Browse files link. It wraps on a narrow window and never becomes a card. |
| @@ -82,7 +23,4 @@ |
| 82 | flex: 0 0 auto; | 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. | 1 | + |
| 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 | -} | | |
| 18 | | 2 | |
| 19 | // Branch protection: the rules are a list pane, the rule being edited fills the pane beside it. The | 3 | // Branch protection: the rules are a list pane, the rule being edited fills the pane beside it. The |
| 20 | // rows stay one `details` group, so the panes are drawn by the list and the open row's form is laid | 4 | // rows stay one `details` group, so the panes are drawn by the list and the open row's form is laid |
| 21 | // over the right one: opening a row needs no script and closes the row that was open. | 5 | // over the right one: opening a row needs no script and closes the row that was open. |
| 22 | @media (min-width: 900px) { | 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 | .rule-list { | 8 | .rule-list { |
| 31 | position: relative; | 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 | .rule-section { | 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 | .rule-form .switch-row:first-child { | 158 | .rule-form .switch-row:first-child { |
| 191 | border-top: 0; | 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 | // Branch protection rows: the open row differs from a closed one only in its background. Both keep | 163 | // Branch protection rows: the open row differs from a closed one only in its background. Both keep |
| 203 | // the Edit text and a right chevron, so nothing swaps when a row opens. | 164 | // the Edit text and a right chevron, so nothing swaps when a row opens. |
| 204 | .rule-row > summary .rule-chevron, | 165 | .rule-row > summary .rule-chevron, |
| @@ -223,17 +184,6 @@ |
| 223 | | 184 | |
| 224 | // The sound row spans the left column, so its label stays on one line beside the switch. | 185 | // The sound row spans the left column, so its label stays on one line beside the switch. |
| 225 | @media (min-width: 1100px) { | 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 | // so the page fits one screen. The form is `display: contents` so its two blocks join this grid. | 3 | // so the page fits one screen. The form is `display: contents` so its two blocks join this grid. |
| 4 | // The sound card sits outside the form: its Play buttons must not be inside it. | 4 | // The sound card sits outside the form: its Play buttons must not be inside it. |
| 5 | @media (min-width: 1100px) { | 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 | @media (prefers-reduced-motion: reduce) { | 9 | @media (prefers-reduced-motion: reduce) { |
| 100 | - .sound-knob { | 10 | + |
| 101 | - } | | |
| 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 | .review-request-list li { | 109 | .review-request-list li { |
| 118 | display: flex; | 110 | display: flex; |
| 119 | flex-wrap: wrap; | 111 | flex-wrap: wrap; |
| @@ -17,51 +17,6 @@ |
| 17 | overflow: hidden; | 17 | overflow: hidden; |
| 18 | background: var(--surface); | 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 | // Split view: two sides per row, code wraps instead of scrolling sideways. | 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 | .button.small { | 334 | .button.small { |
| 404 | height: 28px; | 335 | height: 28px; |
| 405 | padding: 0 10px; | 336 | padding: 0 10px; |
| 406 | font-size: 0.8125rem; | 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 | .confirm-inline { | 340 | .confirm-inline { |
| 434 | display: inline-block; | 341 | display: inline-block; |
| 435 | max-width: 100%; | 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 | @media (max-width: 720px) { | 356 | @media (max-width: 720px) { |
| 475 | - .branch-table .branch-actions { | 357 | + |
| 476 | - text-align: left; | | |
| 477 | - } | | |
| 478 | } | 358 | } |
| @@ -39,11 +39,6 @@ |
| 39 | padding-bottom: 20px; | 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 | // The accent wash shows through on signed-in pages: the shell itself paints nothing. | 42 | // The accent wash shows through on signed-in pages: the shell itself paints nothing. |
| 48 | .shell, | 43 | .shell, |
| 49 | .shell-body { | 44 | .shell-body { |
| @@ -74,8 +69,7 @@ |
| 74 | } | 69 | } |
| 75 | | 70 | |
| 76 | // The tab row: 36px, one hairline, the active tab a 2px accent rule on it. | 71 | // The tab row: 36px, one hairline, the active tab a 2px accent rule on it. |
| 77 | - .repo-tabs, | 72 | + .repo-tabs { |
| 78 | - .page-head { | | |
| 79 | min-height: 36px; | 73 | min-height: 36px; |
| 80 | } | 74 | } |
| 81 | | 75 | |
| @@ -4,92 +4,7 @@ |
| 4 | // Page heads: one 40px row, the right action centred in it at 32px, so at least 4px of the | 4 | // Page heads: one 40px row, the right action centred in it at 32px, so at least 4px of the |
| 5 | // row sits under the button before the rule. | 5 | // row sits under the button before the rule. |
| 6 | @media (min-width: 900px) { | 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 | // Heatmap: the last column's month label ends at the grid's edge and runs back over the | 10 | // Heatmap: the last column's month label ends at the grid's edge and runs back over the |
| @@ -98,38 +13,11 @@ |
| 98 | justify-self: end; | 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 | // Explore: one pane with the shared 14px inset, nothing more. | 16 | // Explore: one pane with the shared 14px inset, nothing more. |
| 128 | .explore { | 17 | .explore { |
| 129 | padding: 0; | 18 | padding: 0; |
| 130 | } | 19 | } |
| 131 | | 20 | |
| 132 | -.explore > .explore-toolbar, | | |
| 133 | .explore > ul, | 21 | .explore > ul, |
| 134 | .explore > .repo-list { | 22 | .explore > .repo-list { |
| 135 | margin: 0; | 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 | @keyframes commits-beat { | 3 | @keyframes commits-beat { |
| 235 | 50% { | 4 | 50% { |
| @@ -238,35 +7,11 @@ |
| 238 | } | 7 | } |
| 239 | | 8 | |
| 240 | @media (prefers-reduced-motion: reduce) { | 9 | @media (prefers-reduced-motion: reduce) { |
| 241 | - .commits-fit .commits-dot.live { | 10 | + |
| 242 | - animation: none; | | |
| 243 | - } | | |
| 244 | } | 11 | } |
| 245 | | 12 | |
| 246 | // Below 900px the page stacks and the pane is as tall as its rows. | 13 | // Below 900px the page stacks and the pane is as tall as its rows. |
| 247 | @media (max-width: 899px) { | 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 | padding: 0 14px; | 52 | padding: 0 14px; |
| 53 | overflow-y: auto; | 53 | overflow-y: auto; |
| 54 | | 54 | |
| 55 | - > .issue-side-section, | 55 | + > .issue-side-section { |
| 56 | - > .notif-box { | | |
| 57 | margin: 0; | 56 | margin: 0; |
| 58 | padding: 14px 0; | 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 | gap: 12px; | 80 | gap: 12px; |
| 88 | padding: 4px 0 14px; | 81 | padding: 4px 0 14px; |
| 89 | | 82 | |
| 90 | - .remove-form { | | |
| 91 | - margin: 0 0 0 auto; | | |
| 92 | - } | | |
| 93 | } | 83 | } |
| 94 | | 84 | |
| 95 | .label-edit-form { | 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 | // A side pane matches the pane beside it. | 177 | // A side pane matches the pane beside it. |
| 202 | @media (min-width: 900px) { | 178 | @media (min-width: 900px) { |
| 203 | - .fit-split > .fit-side { | 179 | + |
| 204 | - align-self: stretch; | | |
| 205 | - } | | |
| 206 | } | 180 | } |
| 207 | | 181 | |
| 208 | // Blame: a commit takes two lines; going further back is a small mark on the first. | 182 | // Blame: a commit takes two lines; going further back is a small mark on the first. |
| @@ -102,7 +102,6 @@ |
| 102 | | 102 | |
| 103 | // Panes: the list sits in one pane with a 1px border, 10px radius and no shadow. | 103 | // Panes: the list sits in one pane with a 1px border, 10px radius and no shadow. |
| 104 | .lang-list, | 104 | .lang-list, |
| 105 | -.list-pane, | | |
| 106 | .explore { | 105 | .explore { |
| 107 | box-shadow: none; | 106 | box-shadow: none; |
| 108 | border: 1px solid var(--border); | 107 | border: 1px solid var(--border); |
| @@ -111,162 +110,6 @@ |
| 111 | overflow: hidden; | 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 | // Repo rows (Explore and the profile tabs): mono name, visibility, the description clipped in | 113 | // Repo rows (Explore and the profile tabs): mono name, visibility, the description clipped in |
| 271 | // --text-2, then stars and the update age on the right. | 114 | // --text-2, then stars and the update age on the right. |
| 272 | .repo-list > .repo-item { | 115 | .repo-list > .repo-item { |
| @@ -315,8 +158,6 @@ |
| 315 | | 158 | |
| 316 | // Notification, Needs you and review request rows: reason as a small mono tag, the title, the | 159 | // Notification, Needs you and review request rows: reason as a small mono tag, the title, the |
| 317 | // repo or detail, the age and the row's own actions. | 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 | .review-request-list > li { | 161 | .review-request-list > li { |
| 321 | display: flex; | 162 | display: flex; |
| 322 | flex-wrap: nowrap; | 163 | flex-wrap: nowrap; |
| @@ -328,16 +169,6 @@ |
| 328 | overflow: hidden; | 169 | overflow: hidden; |
| 329 | border-bottom: 1px solid var(--border); | 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 | > .badge { | 172 | > .badge { |
| 342 | flex: none; | 173 | flex: none; |
| 343 | font-family: var(--mono); | 174 | font-family: var(--mono); |
| @@ -345,28 +176,11 @@ |
| 345 | } | 176 | } |
| 346 | | 177 | |
| 347 | > .muted, | 178 | > .muted, |
| 348 | - > time, | 179 | + > time { |
| 349 | - > .notif-inline-form { | | |
| 350 | flex: none; | 180 | flex: none; |
| 351 | white-space: nowrap; | 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 | // Issue rows: the assignee sits in a fixed 24px slot at the right, so the columns line up whether | 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 | .lang-list > .empty-state { | 229 | .lang-list > .empty-state { |
| 441 | padding: 16px 14px; | 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 | // Labels: the colour is a 32px swatch with its label to the left and a border, like the inputs. | 233 | // Labels: the colour is a 32px swatch with its label to the left and a border, like the inputs. |
| 465 | label:has(> input[type="color"]) { | 234 | label:has(> input[type="color"]) { |
| 466 | display: flex; | 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 | // Pull Files: long diff lines scroll inside their file's body; the file header stays put. | 266 | // Pull Files: long diff lines scroll inside their file's body; the file header stays put. |
| 508 | .pull-diff-scroll { | 267 | .pull-diff-scroll { |
| 509 | min-width: 0; | 268 | min-width: 0; |
| @@ -37,27 +37,8 @@ |
| 37 | border-radius: 10px; | 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 | // Tree pane: the branch selector and the go-to-file tag share the head; the rows scroll below. | 40 | // Tree pane: the branch selector and the go-to-file tag share the head; the rows scroll below. |
| 57 | .canvas-files { | 41 | .canvas-files { |
| 58 | - .canvas-head { | | |
| 59 | - padding-right: 10px; | | |
| 60 | - } | | |
| 61 | | 42 | |
| 62 | .ref-select { | 43 | .ref-select { |
| 63 | position: relative; | 44 | position: relative; |
| @@ -229,21 +210,6 @@ |
| 229 | | 210 | |
| 230 | // README pane: the file name at the left, the facts and Clone at the right. | 211 | // README pane: the file name at the left, the facts and Clone at the right. |
| 231 | .canvas-readme { | 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 | .readme-meta { | 214 | .readme-meta { |
| 249 | overflow: hidden; | 215 | overflow: hidden; |
| @@ -604,18 +570,6 @@ |
| 604 | stroke-linejoin: round; | 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 | // Tree pane with no README: the message sits on the pane head's 14px inset, not the body's 24px. | 573 | // Tree pane with no README: the message sits on the pane head's 14px inset, not the body's 24px. |
| 620 | .repo-home.canvas-repo .canvas-readme .canvas-body:has(> .empty-state) { | 574 | .repo-home.canvas-repo .canvas-readme .canvas-body:has(> .empty-state) { |
| 621 | padding: 14px; | 575 | padding: 14px; |
| @@ -652,7 +606,3 @@ dialog.finder .finder-input { |
| 652 | padding-right: 9px; | 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 | // Repo listing toolbar: the search takes the free width, and the New repository button sits beside it. | 3 | // Repo listing toolbar: the search takes the free width, and the New repository button sits beside it. |
| 63 | .repo-tools { | 4 | .repo-tools { |
| @@ -66,11 +7,6 @@ |
| 66 | gap: 8px; | 7 | gap: 8px; |
| 67 | align-items: center; | 8 | align-items: center; |
| 68 | | 9 | |
| 69 | - .explore-search { | | |
| 70 | - flex: 1 1 320px; | | |
| 71 | - margin: 0; | | |
| 72 | - } | | |
| 73 | - | | |
| 74 | .button { | 10 | .button { |
| 75 | flex: none; | 11 | flex: none; |
| 76 | } | 12 | } |
| @@ -84,7 +20,6 @@ |
| 84 | justify-content: space-between; | 20 | justify-content: space-between; |
| 85 | gap: 8px 16px; | 21 | gap: 8px 16px; |
| 86 | | 22 | |
| 87 | - .explore-sort, | | |
| 88 | p { | 23 | p { |
| 89 | margin: 0; | 24 | margin: 0; |
| 90 | } | 25 | } |
| @@ -97,8 +32,6 @@ |
| 97 | flex-direction: column; | 32 | flex-direction: column; |
| 98 | gap: 10px; | 33 | gap: 10px; |
| 99 | | 34 | |
| 100 | - > .explore-search, | | |
| 101 | - > .explore-sort, | | |
| 102 | > p { | 35 | > p { |
| 103 | margin: 0; | 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 | // Organization header: the avatar is 96px (the person's is larger), and the Edit organization and | 100 | // Organization header: the avatar is 96px (the person's is larger), and the Edit organization and |
| 182 | // New repository buttons sit in one row under the description line. | 101 | // New repository buttons sit in one row under the description line. |
| 183 | .profile-avatar.org-avatar { | 102 | .profile-avatar.org-avatar { |
| @@ -185,32 +104,8 @@ |
| 185 | height: 96px; | 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 | @media (min-width: 900px) { | 107 | @media (min-width: 900px) { |
| 211 | - .org-overview { | 108 | + |
| 212 | - grid-template-columns: minmax(0, 1fr) 320px; | | |
| 213 | - } | | |
| 214 | } | 109 | } |
| 215 | | 110 | |
| 216 | .profile-org { | 111 | .profile-org { |
| @@ -8,37 +8,4 @@ |
| 8 | text-align: left; | 8 | text-align: left; |
| 9 | color: var(--muted); | 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 | margin-bottom: 0; | 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 | // Instance health (/admin/health): the storage and services cards sit side by side, under the | 11 | // Instance health (/admin/health): the storage and services cards sit side by side, under the |
| 18 | // summary. The alerts and the footnote span both columns. | 12 | // summary. The alerts and the footnote span both columns. |
| 19 | @media (min-width: 900px) { | 13 | @media (min-width: 900px) { |
| @@ -22,33 +16,12 @@ |
| 22 | grid-template-columns: repeat(2, minmax(0, 1fr)); | 16 | grid-template-columns: repeat(2, minmax(0, 1fr)); |
| 23 | column-gap: 16px; | 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 | // User detail (/admin/users/{id}): the actions and the danger zone side by side, under the header. | 22 | // User detail (/admin/users/{id}): the actions and the danger zone side by side, under the header. |
| 38 | @media (min-width: 900px) { | 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 | // Mail settings (/admin/mail): the SMTP form runs three fields across, the actions span the row. | 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 | @media (min-width: 900px) { | 3 | @media (min-width: 900px) { |
| 24 | // A card that is a pane with a form in it: no bottom margin (the pane fills the window), and the | 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 | // The pane clips its overflow, so the focus ring of the card edges gets a little room. | 34 | // The pane clips its overflow, so the focus ring of the card edges gets a little room. |
| 55 | padding: 4px; | 35 | padding: 4px; |
| 56 | | 36 | |
| 57 | - .snippet-doc, | | |
| 58 | .snippet-files { | 37 | .snippet-files { |
| 59 | flex: 1 1 auto; | 38 | flex: 1 1 auto; |
| 60 | min-height: 0; | 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 | // The form's two cards share a row on the widest windows; the header and the notes span both. | 60 | // The form's two cards share a row on the widest windows; the header and the notes span both. |
| 100 | @media (min-width: 1200px) { | 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 | // One-screen layout of notifications, security log and audit log. See _fit.scss. | 1 | // One-screen layout of notifications, security log and audit log. See _fit.scss. |
| 2 | @media (min-width: 900px) { | 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 | @media (min-width: 900px) { | 3 | @media (min-width: 900px) { |
| 19 | - .settings-split { | 4 | + |
| 20 | - grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); | | |
| 21 | - } | | |
| 22 | } | 5 | } |
| 23 | | 6 | |
| 24 | // The new webhook form: the fields in the left column, the event list in the right one. | 7 | // The new webhook form: the fields in the left column, the event list in the right one. |
| 25 | @media (min-width: 900px) { | 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 | @media (max-width: 899px) { | 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 | background: var(--danger); | 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 | // The last delivery's state when it was not ok. | 9 | // The last delivery's state when it was not ok. |
| 56 | .hook-problem { | 10 | .hook-problem { |
| 57 | color: var(--danger); | 11 | color: var(--danger); |
| @@ -59,12 +13,5 @@ |
| 59 | | 13 | |
| 60 | // Phone: the sync button goes under the name, the rows stack. | 14 | // Phone: the sync button goes under the name, the rows stack. |
| 61 | @media (max-width: 600px) { | 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 | .import-pick-list { | 3 | .import-pick-list { |
| 128 | max-height: 60vh; | 4 | max-height: 60vh; |
| @@ -131,80 +7,6 @@ |
| 131 | overflow-y: auto; | 7 | overflow-y: auto; |
| 132 | list-style: none; | 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 | .import-job { | 12 | .import-job { |
| @@ -215,38 +17,6 @@ |
| 215 | min-width: 0; | 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 | .import-progress { | 20 | .import-progress { |
| 251 | width: 100%; | 21 | width: 100%; |
| 252 | height: 8px; | 22 | height: 8px; |
| @@ -264,17 +34,6 @@ |
| 264 | color: var(--alert-text); | 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 | .import-log-title { | 37 | .import-log-title { |
| 279 | margin: 0; | 38 | margin: 0; |
| 280 | font-size: 0.9375rem; | 39 | font-size: 0.9375rem; |
| @@ -313,44 +72,18 @@ |
| 313 | max-width: 960px; | 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 | .export-row { | 75 | .export-row { |
| 327 | display: flex; | 76 | display: flex; |
| 328 | flex-wrap: wrap; | 77 | flex-wrap: wrap; |
| 329 | align-items: center; | 78 | align-items: center; |
| 330 | gap: 8px 14px; | 79 | gap: 8px 14px; |
| 331 | | 80 | |
| 332 | - .item-main { | | |
| 333 | - flex: 1 1 240px; | | |
| 334 | - min-width: 0; | | |
| 335 | - } | | |
| 336 | } | 81 | } |
| 337 | | 82 | |
| 338 | .export-progress { | 83 | .export-progress { |
| 339 | width: 120px; | 84 | width: 120px; |
| 340 | } | 85 | } |
| 341 | | 86 | |
| 342 | -.export-error { | | |
| 343 | - list-style: none; | | |
| 344 | - | | |
| 345 | - .alert { | | |
| 346 | - margin: 0; | | |
| 347 | - } | | |
| 348 | -} | | |
| 349 | - | | |
| 350 | @media (max-width: 560px) { | 87 | @media (max-width: 560px) { |
| 351 | - .import-pick-row, | 88 | + |
| 352 | - .import-into { | | |
| 353 | - padding-left: 14px; | | |
| 354 | - padding-right: 14px; | | |
| 355 | - } | | |
| 356 | } | 89 | } |