Actions inside a page (Rename repository, Transfer repository, Browse files, Cancel and every other quiet word) are drawn in the accent's ink at weight 600, so they no longer read as hints or headings
Browse files at this commit409776fe6448a7b9c66edc9edd771ec1848c76c1Parent: 24d3e50All checks have passed
Show checks
ci/buildSucceededDetails
- style
- actions inside a page (Rename repository, Transfer repository, Browse files, Cancel and every other quiet word) are drawn in the accent's ink at weight 600, so they no longer read as hints or headings
- the file finder's search box keeps its full height when the list is long
- openable commit rows line up with the others, and on a phone every commit row reads the subject, then who, when, the hash and Browse files on the text edge 🐛 fix: an existing branch rule shows its pattern as fixed text and saves with Save changes, the New rule form adds with Add rule, and adding a rule for a pattern that already has one is refused instead of overwriting it
- a renamed or transferred repo's old address answers 307 with no-store instead of 301, so a browser never keeps sending a reused name to the old repo ✅ test: the audit shoots the branch protection section
11 changed files +123 -38
- crates/forge-e2e/tests/e2e/repo_rename_e2e.rs +8 -8
- crates/forge-e2e/tests/e2e/repo_settings_e2e.rs +12 -1
- crates/forge-e2e/tests/e2e/repo_transfer_e2e.rs +1 -1
- crates/forge-web-base/src/i18n/repo_admin.rs +2 -2
- crates/forge-web/src/pages/repo_ctx.rs +11 -6
- crates/forge-web/src/pages/repo_settings.rs +55 -14
- docs/ui-language.md +1 -1
- scripts/audit/shoot.py +2 -0
- style/_browse.scss +3 -0
- style/_min_code.scss +14 -0
- style/_one.scss +14 -5
crates/forge-e2e/tests/e2e/repo_rename_e2e.rsmodified+8 -8
| @@ -250,15 +250,15 @@ async fn repo_rename_end_to_end() { | |||
| 250 | 200 | 250 | 200 |
| 251 | ); | 251 | ); |
| 252 | 252 | ||
| 253 | - // The old web URL 301s to the same path under the new name, and keeps the query. | 253 | + // The old web URL 307s to the same path under the new name, and keeps the query. |
| 254 | let old_tree = http.get("/bob/pub/tree/main/src", None).await; | 254 | let old_tree = http.get("/bob/pub/tree/main/src", None).await; |
| 255 | - assert_eq!(old_tree.status, 301, "old tree URL"); | 255 | + assert_eq!(old_tree.status, 307, "old tree URL"); |
| 256 | assert_eq!( | 256 | assert_eq!( |
| 257 | old_tree.header(LOCATION).as_deref(), | 257 | old_tree.header(LOCATION).as_deref(), |
| 258 | Some("/bob/newpub/tree/main/src") | 258 | Some("/bob/newpub/tree/main/src") |
| 259 | ); | 259 | ); |
| 260 | let old_query = http.get("/bob/pub?tab=x", None).await; | 260 | let old_query = http.get("/bob/pub?tab=x", None).await; |
| 261 | - assert_eq!(old_query.status, 301, "old repo URL with query"); | 261 | + assert_eq!(old_query.status, 307, "old repo URL with query"); |
| 262 | assert_eq!( | 262 | assert_eq!( |
| 263 | old_query.header(LOCATION).as_deref(), | 263 | old_query.header(LOCATION).as_deref(), |
| 264 | Some("/bob/newpub?tab=x") | 264 | Some("/bob/newpub?tab=x") |
| @@ -407,7 +407,7 @@ async fn repo_rename_end_to_end() { | |||
| 407 | 200 | 407 | 200 |
| 408 | ); | 408 | ); |
| 409 | let moved = http.get("/bob/newpub/tree/main/src", None).await; | 409 | let moved = http.get("/bob/newpub/tree/main/src", None).await; |
| 410 | - assert_eq!(moved.status, 301, "old owner and name"); | 410 | + assert_eq!(moved.status, 307, "old owner and name"); |
| 411 | assert_eq!( | 411 | assert_eq!( |
| 412 | moved.header(LOCATION).as_deref(), | 412 | moved.header(LOCATION).as_deref(), |
| 413 | Some("/carol/newpub/tree/main/src") | 413 | Some("/carol/newpub/tree/main/src") |
| @@ -416,7 +416,7 @@ async fn repo_rename_end_to_end() { | |||
| 416 | // A chain: bob/pub -> bob/newpub -> carol/newpub. The oldest name still redirects, and its | 416 | // A chain: bob/pub -> bob/newpub -> carol/newpub. The oldest name still redirects, and its |
| 417 | // clone URL still works for an anonymous fetch of this public repo. | 417 | // clone URL still works for an anonymous fetch of this public repo. |
| 418 | let chained = http.get("/bob/pub/tree/main/src", None).await; | 418 | let chained = http.get("/bob/pub/tree/main/src", None).await; |
| 419 | - assert_eq!(chained.status, 301, "chained redirect"); | 419 | + assert_eq!(chained.status, 307, "chained redirect"); |
| 420 | assert_eq!( | 420 | assert_eq!( |
| 421 | chained.header(LOCATION).as_deref(), | 421 | chained.header(LOCATION).as_deref(), |
| 422 | Some("/carol/newpub/tree/main/src") | 422 | Some("/carol/newpub/tree/main/src") |
| @@ -443,11 +443,11 @@ async fn repo_rename_end_to_end() { | |||
| 443 | assert_eq!(taken_over.status, 200, "new repo takes over the old name"); | 443 | assert_eq!(taken_over.status, 200, "new repo takes over the old name"); |
| 444 | assert_eq!( | 444 | assert_eq!( |
| 445 | http.get("/bob/newpub", None).await.status, | 445 | http.get("/bob/newpub", None).await.status, |
| 446 | - 301, | 446 | + 307, |
| 447 | "the other old name still redirects" | 447 | "the other old name still redirects" |
| 448 | ); | 448 | ); |
| 449 | 449 | ||
| 450 | - // A private repo renamed away: an anonymous or unrelated viewer gets 404, the owner gets 301. | 450 | + // A private repo renamed away: an anonymous or unrelated viewer gets 404, the owner gets 307. |
| 451 | let csrf = csrf_for(&http, &bob).await; | 451 | let csrf = csrf_for(&http, &bob).await; |
| 452 | let secret_rename = http | 452 | let secret_rename = http |
| 453 | .post_form( | 453 | .post_form( |
| @@ -469,7 +469,7 @@ async fn repo_rename_end_to_end() { | |||
| 469 | "missing repo looks the same" | 469 | "missing repo looks the same" |
| 470 | ); | 470 | ); |
| 471 | let owner_view = http.get("/bob/secret", Some(&bob)).await; | 471 | let owner_view = http.get("/bob/secret", Some(&bob)).await; |
| 472 | - assert_eq!(owner_view.status, 301, "owner follows the redirect"); | 472 | + assert_eq!(owner_view.status, 307, "owner follows the redirect"); |
| 473 | assert_eq!(owner_view.header(LOCATION).as_deref(), Some("/bob/secret2")); | 473 | assert_eq!(owner_view.header(LOCATION).as_deref(), Some("/bob/secret2")); |
| 474 | // Git clients get the same answer for a hidden repo as for a missing one. | 474 | // Git clients get the same answer for a hidden repo as for a missing one. |
| 475 | let hidden_git = http | 475 | let hidden_git = http |
crates/forge-e2e/tests/e2e/repo_settings_e2e.rsmodified+12 -1
| @@ -523,11 +523,22 @@ async fn branch_protection_end_to_end() { | |||
| 523 | let updated = http | 523 | let updated = http |
| 524 | .post_form( | 524 | .post_form( |
| 525 | "/bob/app/settings/branches", | 525 | "/bob/app/settings/branches", |
| 526 | - &[("csrf", &owner_csrf), ("pattern", "main")], | 526 | + &[("csrf", &owner_csrf), ("pattern", "main"), ("existing", "1")], |
| 527 | Some(&bob), | 527 | Some(&bob), |
| 528 | ) | 528 | ) |
| 529 | .await; | 529 | .await; |
| 530 | assert_eq!(updated.status, 303, "update rule: {}", updated.body); | 530 | assert_eq!(updated.status, 303, "update rule: {}", updated.body); |
| 531 | + | ||
| 532 | + // Adding a new rule for a pattern that has one is refused instead of overwriting it. | ||
| 533 | + let duplicate = http | ||
| 534 | + .post_form( | ||
| 535 | + "/bob/app/settings/branches", | ||
| 536 | + &[("csrf", &owner_csrf), ("pattern", "main")], | ||
| 537 | + Some(&bob), | ||
| 538 | + ) | ||
| 539 | + .await; | ||
| 540 | + assert_eq!(duplicate.status, 200, "duplicate rule re-renders the page"); | ||
| 541 | + assert!(duplicate.body.contains("already exists"), "duplicate rule names the clash"); | ||
| 531 | let page = http | 542 | let page = http |
| 532 | .get("/bob/app/settings?section=branches", Some(&bob)) | 543 | .get("/bob/app/settings?section=branches", Some(&bob)) |
| 533 | .await; | 544 | .await; |
crates/forge-e2e/tests/e2e/repo_transfer_e2e.rsmodified+1 -1
| @@ -185,5 +185,5 @@ async fn repo_transfer_offers_declines_cancels_and_org_targets() { | |||
| 185 | assert_eq!(accepted.header(LOCATION).as_deref(), Some("/acme/pub")); | 185 | assert_eq!(accepted.header(LOCATION).as_deref(), Some("/acme/pub")); |
| 186 | assert_eq!(http.get("/acme/pub", Some(&bob)).await.status, 200); | 186 | assert_eq!(http.get("/acme/pub", Some(&bob)).await.status, 200); |
| 187 | let old = http.get("/bob/pub", Some(&bob)).await; | 187 | let old = http.get("/bob/pub", Some(&bob)).await; |
| 188 | - assert_eq!(old.status, 301, "old owner and name redirect"); | 188 | + assert_eq!(old.status, 307, "old owner and name redirect"); |
| 189 | } | 189 | } |
crates/forge-web-base/src/i18n/repo_admin.rsmodified+2 -2
| @@ -359,9 +359,9 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 359 | (PatternHelpB, Tr) => " tek yol parçası içinde eşleşir, ", | 359 | (PatternHelpB, Tr) => " tek yol parçası içinde eşleşir, ", |
| 360 | (PatternHelpC, En) => " matches across ", | 360 | (PatternHelpC, En) => " matches across ", |
| 361 | (PatternHelpC, Tr) => " ise ", | 361 | (PatternHelpC, Tr) => " ise ", |
| 362 | - (PatternHelpD, En) => ". Saving an existing pattern updates its rule.", | 362 | + (PatternHelpD, En) => ".", |
| 363 | (PatternHelpD, Tr) => { | 363 | (PatternHelpD, Tr) => { |
| 364 | - " işaretini de aşarak eşleşir. Var olan bir deseni kaydetmek, kuralını günceller." | 364 | + " işaretini de aşarak eşleşir." |
| 365 | } | 365 | } |
| 366 | (PendingTransfers, En) => "Pending transfers", | 366 | (PendingTransfers, En) => "Pending transfers", |
| 367 | (PendingTransfers, Tr) => "Bekleyen devirler", | 367 | (PendingTransfers, Tr) => "Bekleyen devirler", |
crates/forge-web/src/pages/repo_ctx.rsmodified+11 -6
| @@ -1,6 +1,6 @@ | |||
| 1 | //! Shared lookup for every repo page: resolve owner/name, authorize Read for the viewer, | 1 | //! Shared lookup for every repo page: resolve owner/name, authorize Read for the viewer, |
| 2 | //! and return 404 for both missing and hidden repos so private repos are never revealed. | 2 | //! and return 404 for both missing and hidden repos so private repos are never revealed. |
| 3 | -//! A past owner/name (a redirect left by a rename or transfer) gets a 301 to the current URL | 3 | +//! A past owner/name (a redirect left by a rename or transfer) gets a 307 to the current URL |
| 4 | //! when the viewer may read the repo it now points at. | 4 | //! when the viewer may read the repo it now points at. |
| 5 | 5 | ||
| 6 | use std::path::PathBuf; | 6 | use std::path::PathBuf; |
| @@ -8,7 +8,7 @@ use std::path::PathBuf; | |||
| 8 | use forge_core::authz::{Action, authorize}; | 8 | use forge_core::authz::{Action, authorize}; |
| 9 | use forge_core::{Repo, Role, Session, Store, User, Visibility, WatchLevel}; | 9 | use forge_core::{Repo, Role, Session, Store, User, Visibility, WatchLevel}; |
| 10 | use forge_git::repo::repo_path; | 10 | use forge_git::repo::repo_path; |
| 11 | -use http::{HeaderValue, header::LOCATION}; | 11 | +use http::{HeaderValue, header::{CACHE_CONTROL, LOCATION}}; |
| 12 | use topcoat::Result; | 12 | use topcoat::Result; |
| 13 | use topcoat::context::{Cx, app_context}; | 13 | use topcoat::context::{Cx, app_context}; |
| 14 | use topcoat::router::error::not_found; | 14 | use topcoat::router::error::not_found; |
| @@ -125,7 +125,7 @@ pub struct WatchButton { | |||
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | /// Raised by `load_repo` when the requested owner/name is a past name of a repo the viewer may | 127 | /// Raised by `load_repo` when the requested owner/name is a past name of a repo the viewer may |
| 128 | -/// read. The `repo_moved` layer turns it into a 301 to `location`. | 128 | +/// read. The `repo_moved` layer turns it into a 307 to `location`. |
| 129 | #[derive(Debug)] | 129 | #[derive(Debug)] |
| 130 | pub struct RepoMoved { | 130 | pub struct RepoMoved { |
| 131 | pub location: String, | 131 | pub location: String, |
| @@ -414,7 +414,7 @@ async fn moved_location( | |||
| 414 | ))) | 414 | ))) |
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | -/// Wraps every request (no path) so a `RepoMoved` error becomes a 301. Registered explicitly on the | 417 | +/// Wraps every request (no path) so a `RepoMoved` error becomes a 307. Registered explicitly on the |
| 418 | /// public router in `boot.rs`: a `#[layer("/")]` would clash with the security-headers layer. | 418 | /// public router in `boot.rs`: a `#[layer("/")]` would clash with the security-headers layer. |
| 419 | pub struct RepoMovedLayer; | 419 | pub struct RepoMovedLayer; |
| 420 | 420 | ||
| @@ -428,7 +428,7 @@ impl Layer for RepoMovedLayer { | |||
| 428 | } | 428 | } |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | -/// Turns a `RepoMoved` error from a handler into a 301 with the new location, and a `RawDownload` | 431 | +/// Turns a `RepoMoved` error from a handler into a 307 with the new location, and a `RawDownload` |
| 432 | /// into its plain-text response. Other errors pass through unchanged. | 432 | /// into its plain-text response. Other errors pass through unchanged. |
| 433 | async fn repo_moved(cx: &Cx, body: Body, next: Next<'_>) -> Result<Response> { | 433 | async fn repo_moved(cx: &Cx, body: Body, next: Next<'_>) -> Result<Response> { |
| 434 | let error = match next.run(cx, body).await { | 434 | let error = match next.run(cx, body).await { |
| @@ -444,13 +444,18 @@ async fn repo_moved(cx: &Cx, body: Body, next: Next<'_>) -> Result<Response> { | |||
| 444 | match error.downcast_ref::<RepoMoved>() { | 444 | match error.downcast_ref::<RepoMoved>() { |
| 445 | Some(moved) => { | 445 | Some(moved) => { |
| 446 | let mut response = Response::new(Body::empty()); | 446 | let mut response = Response::new(Body::empty()); |
| 447 | - *response.status_mut() = StatusCode::MOVED_PERMANENTLY; | 447 | + // Temporary and uncached: an old name can be taken by a new repo later, and a browser |
| 448 | + // that cached a 301 would keep sending its visitors to the renamed repo. | ||
| 449 | + *response.status_mut() = StatusCode::TEMPORARY_REDIRECT; | ||
| 448 | // Owner and repo names are plain ASCII and the query came from a valid URI, so this | 450 | // Owner and repo names are plain ASCII and the query came from a valid URI, so this |
| 449 | // only fails on a corrupt location; a 404 is the safe answer then. | 451 | // only fails on a corrupt location; a 404 is the safe answer then. |
| 450 | let Ok(location) = HeaderValue::from_str(&moved.location) else { | 452 | let Ok(location) = HeaderValue::from_str(&moved.location) else { |
| 451 | return Err(not_found().into()); | 453 | return Err(not_found().into()); |
| 452 | }; | 454 | }; |
| 453 | response.headers_mut().insert(LOCATION, location); | 455 | response.headers_mut().insert(LOCATION, location); |
| 456 | + response | ||
| 457 | + .headers_mut() | ||
| 458 | + .insert(CACHE_CONTROL, HeaderValue::from_static("no-store")); | ||
| 454 | Ok(response) | 459 | Ok(response) |
| 455 | } | 460 | } |
| 456 | None => Err(error), | 461 | None => Err(error), |
crates/forge-web/src/pages/repo_settings.rsmodified+55 -14
| @@ -153,6 +153,10 @@ struct BranchForm { | |||
| 153 | /// Required check contexts, separated by commas or new lines. | 153 | /// Required check contexts, separated by commas or new lines. |
| 154 | #[serde(default)] | 154 | #[serde(default)] |
| 155 | required_checks: String, | 155 | required_checks: String, |
| 156 | + /// Set by an existing rule's form, whose pattern is fixed. Without it the form adds a rule, and | ||
| 157 | + /// a pattern that already has one is refused rather than overwriting it. | ||
| 158 | + #[serde(default)] | ||
| 159 | + existing: Option<String>, | ||
| 156 | } | 160 | } |
| 157 | 161 | ||
| 158 | #[derive(Deserialize)] | 162 | #[derive(Deserialize)] |
| @@ -609,6 +613,7 @@ async fn branch_rule_form( | |||
| 609 | require_merge_queue, | 613 | require_merge_queue, |
| 610 | required_checks, | 614 | required_checks, |
| 611 | error, | 615 | error, |
| 616 | + is_new: _, | ||
| 612 | } = draft; | 617 | } = draft; |
| 613 | // Field ids are per rule, so two open rule forms never share an id. | 618 | // Field ids are per rule, so two open rule forms never share an id. |
| 614 | let prefix = match &rule_id { | 619 | let prefix = match &rule_id { |
| @@ -624,11 +629,23 @@ async fn branch_rule_form( | |||
| 624 | alert(message: message.as_str()) | 629 | alert(message: message.as_str()) |
| 625 | } | 630 | } |
| 626 | <input type="hidden" name="csrf" value=(csrf.as_str())> | 631 | <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 627 | - <div class="field"> | 632 | + // An existing rule's pattern is fixed: this form only changes what the rule does. A |
| 628 | - <label for=(pattern_id.as_str())>(g::t(lang, K::BranchPattern))</label> | 633 | + // different pattern is a new rule, added from the New rule line. |
| 629 | - <input id=(pattern_id.as_str()) type="text" name="pattern" value=(pattern.as_str()) autocomplete="off" spellcheck="false" required=(true)> | 634 | + if rule_id.is_some() { |
| 630 | - <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> | 635 | + <input type="hidden" name="pattern" value=(pattern.as_str())> |
| 631 | - </div> | 636 | + <input type="hidden" name="existing" value="1"> |
| 637 | + <div class="field"> | ||
| 638 | + <span class="field-label">(g::t(lang, K::BranchPattern))</span> | ||
| 639 | + <span class="field-value"><code>(pattern.as_str())</code></span> | ||
| 640 | + <p class="hint">(passkeys::s(lang, "For another branch, add a new rule.", "Başka bir dal için yeni bir kural ekle."))</p> | ||
| 641 | + </div> | ||
| 642 | + } else { | ||
| 643 | + <div class="field"> | ||
| 644 | + <label for=(pattern_id.as_str())>(g::t(lang, K::BranchPattern))</label> | ||
| 645 | + <input id=(pattern_id.as_str()) type="text" name="pattern" value=(pattern.as_str()) autocomplete="off" spellcheck="false" required=(true)> | ||
| 646 | + <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> | ||
| 647 | + </div> | ||
| 648 | + } | ||
| 632 | // Each group is a field: its name in the label column, its boxes in the control column, each | 649 | // Each group is a field: its name in the label column, its boxes in the control column, each |
| 633 | // box with its note beside it. | 650 | // box with its note beside it. |
| 634 | <div class="field"> | 651 | <div class="field"> |
| @@ -696,7 +713,11 @@ async fn branch_rule_form( | |||
| 696 | } | 713 | } |
| 697 | </div> | 714 | </div> |
| 698 | <div class="acts"> | 715 | <div class="acts"> |
| 699 | - <button type="submit" class="primary">(g::t(lang, K::SaveRule))</button> | 716 | + if rule_id.is_some() { |
| 717 | + <button type="submit" class="primary">(passkeys::s(lang, "Save changes", "Değişiklikleri kaydet"))</button> | ||
| 718 | + } else { | ||
| 719 | + <button type="submit" class="primary">(passkeys::s(lang, "Add rule", "Kuralı ekle"))</button> | ||
| 720 | + } | ||
| 700 | <button type="button" class="act quiet" data-close-details="">(g::t(lang, K::CancelRule))</button> | 721 | <button type="button" class="act quiet" data-close-details="">(g::t(lang, K::CancelRule))</button> |
| 701 | </div> | 722 | </div> |
| 702 | </form> | 723 | </form> |
| @@ -722,6 +743,8 @@ struct RuleDraft { | |||
| 722 | require_merge_queue: bool, | 743 | require_merge_queue: bool, |
| 723 | required_checks: String, | 744 | required_checks: String, |
| 724 | error: Option<String>, | 745 | error: Option<String>, |
| 746 | + /// True for the New rule form's draft, so a refused new rule never opens an existing rule's card. | ||
| 747 | + is_new: bool, | ||
| 725 | } | 748 | } |
| 726 | 749 | ||
| 727 | impl RuleDraft { | 750 | impl RuleDraft { |
| @@ -738,6 +761,7 @@ impl RuleDraft { | |||
| 738 | require_merge_queue: rule.require_merge_queue, | 761 | require_merge_queue: rule.require_merge_queue, |
| 739 | required_checks: rule.required_checks.join(", "), | 762 | required_checks: rule.required_checks.join(", "), |
| 740 | error: None, | 763 | error: None, |
| 764 | + is_new: false, | ||
| 741 | } | 765 | } |
| 742 | } | 766 | } |
| 743 | 767 | ||
| @@ -754,6 +778,7 @@ impl RuleDraft { | |||
| 754 | require_merge_queue: false, | 778 | require_merge_queue: false, |
| 755 | required_checks: String::new(), | 779 | required_checks: String::new(), |
| 756 | error: None, | 780 | error: None, |
| 781 | + is_new: true, | ||
| 757 | } | 782 | } |
| 758 | } | 783 | } |
| 759 | } | 784 | } |
| @@ -803,7 +828,7 @@ async fn settings_body( | |||
| 803 | let mut cards = Vec::with_capacity(rules.len()); | 828 | let mut cards = Vec::with_capacity(rules.len()); |
| 804 | for rule in rules { | 829 | for rule in rules { |
| 805 | let card_draft = match draft.take() { | 830 | let card_draft = match draft.take() { |
| 806 | - Some(d) if d.error.is_some() && d.pattern == rule.pattern => d, | 831 | + Some(d) if d.error.is_some() && !d.is_new && d.pattern == rule.pattern => d, |
| 807 | other => { | 832 | other => { |
| 808 | draft = other; | 833 | draft = other; |
| 809 | RuleDraft::from_rule(&rule) | 834 | RuleDraft::from_rule(&rule) |
| @@ -1261,10 +1286,25 @@ async fn settings_branch_save(cx: &Cx, Form(form): Form<BranchForm>) -> Result<i | |||
| 1261 | let pattern = form.pattern.trim().to_owned(); | 1286 | let pattern = form.pattern.trim().to_owned(); |
| 1262 | let title = format!("{}/{}", ctx.repo.owner_name, ctx.repo.name); | 1287 | let title = format!("{}/{}", ctx.repo.owner_name, ctx.repo.name); |
| 1263 | 1288 | ||
| 1264 | - let flags = match validate_pattern(&pattern) | 1289 | + let is_new = form.existing.is_none(); |
| 1265 | - .map_err(|e| e.to_string()) | 1290 | + let taken = is_new |
| 1266 | - .and_then(|()| parse_rule_flags(lang, &form)) | 1291 | + && app_context::<AppState>(cx) |
| 1267 | - { | 1292 | + .store |
| 1293 | + .list_branch_rules(&ctx.repo.id) | ||
| 1294 | + .await? | ||
| 1295 | + .iter() | ||
| 1296 | + .any(|rule| rule.pattern == pattern); | ||
| 1297 | + let checked = if taken { | ||
| 1298 | + Err(passkeys::s( | ||
| 1299 | + lang, | ||
| 1300 | + "A rule for this pattern already exists. Pick it in the list to change it.", | ||
| 1301 | + "Bu desen için zaten bir kural var. Değiştirmek için listeden onu seç.", | ||
| 1302 | + ) | ||
| 1303 | + .to_owned()) | ||
| 1304 | + } else { | ||
| 1305 | + validate_pattern(&pattern).map_err(|e| e.to_string()) | ||
| 1306 | + }; | ||
| 1307 | + let flags = match checked.and_then(|()| parse_rule_flags(lang, &form)) { | ||
| 1268 | Ok(flags) => flags, | 1308 | Ok(flags) => flags, |
| 1269 | Err(message) => { | 1309 | Err(message) => { |
| 1270 | let rules = app_context::<AppState>(cx) | 1310 | let rules = app_context::<AppState>(cx) |
| @@ -1285,6 +1325,7 @@ async fn settings_branch_save(cx: &Cx, Form(form): Form<BranchForm>) -> Result<i | |||
| 1285 | require_merge_queue: form.require_merge_queue.is_some(), | 1325 | require_merge_queue: form.require_merge_queue.is_some(), |
| 1286 | required_checks: form.required_checks.clone(), | 1326 | required_checks: form.required_checks.clone(), |
| 1287 | error: Some(message), | 1327 | error: Some(message), |
| 1328 | + is_new, | ||
| 1288 | }, | 1329 | }, |
| 1289 | delete_error: None, | 1330 | delete_error: None, |
| 1290 | contexts: app_context::<AppState>(cx) | 1331 | contexts: app_context::<AppState>(cx) |
| @@ -1439,7 +1480,7 @@ mod tests { | |||
| 1439 | let (status, _) = post_rule( | 1480 | let (status, _) = post_rule( |
| 1440 | &app, | 1481 | &app, |
| 1441 | &cookie, | 1482 | &cookie, |
| 1442 | - &[("pattern", "main"), ("required_approvals", "")], | 1483 | + &[("pattern", "main"), ("existing", "1"), ("required_approvals", "")], |
| 1443 | ) | 1484 | ) |
| 1444 | .await; | 1485 | .await; |
| 1445 | assert_eq!(status, 303); | 1486 | assert_eq!(status, 303); |
| @@ -1454,7 +1495,7 @@ mod tests { | |||
| 1454 | &app, | 1495 | &app, |
| 1455 | &cookie, | 1496 | &cookie, |
| 1456 | &[ | 1497 | &[ |
| 1457 | - ("pattern", "main"), | 1498 | + ("pattern", "main"), ("existing", "1"), |
| 1458 | ("required_approvals", "21"), | 1499 | ("required_approvals", "21"), |
| 1459 | ("restrict_push", "on"), | 1500 | ("restrict_push", "on"), |
| 1460 | ], | 1501 | ], |
| @@ -1473,7 +1514,7 @@ mod tests { | |||
| 1473 | let (status, body) = post_rule( | 1514 | let (status, body) = post_rule( |
| 1474 | &app, | 1515 | &app, |
| 1475 | &cookie, | 1516 | &cookie, |
| 1476 | - &[("pattern", "main"), ("required_approvals", "two")], | 1517 | + &[("pattern", "main"), ("existing", "1"), ("required_approvals", "two")], |
| 1477 | ) | 1518 | ) |
| 1478 | .await; | 1519 | .await; |
| 1479 | assert_eq!(status, 200); | 1520 | assert_eq!(status, 200); |
docs/ui-language.mdmodified+1 -1
| @@ -80,7 +80,7 @@ no `margin-left:auto`, no `justify-content:space-between`, no second column at t | |||
| 80 | - **Time range**: every log has a When filter (Any time, Last hour, Last 24 hours, Last 7 days, Last | 80 | - **Time range**: every log has a When filter (Any time, Last hour, Last 24 hours, Last 7 days, Last |
| 81 | 30 days, Today, Dates…). Dates… shows From and To day fields in the viewer's timezone, and the tools | 81 | 30 days, Today, Dates…). Dates… shows From and To day fields in the viewer's timezone, and the tools |
| 82 | row starts with the count of entries that match, so "how many sign-ins last week" is one glance. | 82 | row starts with the count of entries that match, so "how many sign-ins last week" is one glance. |
| 83 | -- **Tool**: `.act`, a quiet word (14px, dim, radius 12). `.act.danger` for destructive. This is what goes in | 83 | +- **Tool**: `.act`, a word in the accent's ink (14px, 600, radius 12), never the dim colour of a hint. `.act.danger` for destructive. This is what goes in |
| 84 | tools rows, in rows and in `.acts`. | 84 | tools rows, in rows and in `.acts`. |
| 85 | - `reveal(label, id, open)`: a tool that opens its form in place. `open` when a form came back with an error. | 85 | - `reveal(label, id, open)`: a tool that opens its form in place. `open` when a form came back with an error. |
| 86 | In a `.fields` form its word starts on the controls' edge. What should not be one click away | 86 | In a `.fields` form its word starts on the controls' edge. What should not be one click away |
scripts/audit/shoot.pymodified+2 -0
| @@ -446,6 +446,8 @@ def concrete(pat): | |||
| 446 | res += [(f"/{o}/{s['private_repo']}", "private"), (f"/{s['org']}/{s['org_repo']}", "org-empty")] | 446 | res += [(f"/{o}/{s['private_repo']}", "private"), (f"/{s['org']}/{s['org_repo']}", "org-empty")] |
| 447 | if pat == "/{username}": | 447 | if pat == "/{username}": |
| 448 | res += [(f"/{s['org']}", "org"), (f"/{o}?tab=stars", "stars"), (f"/{o}?tab=repositories", "repos")] | 448 | res += [(f"/{s['org']}", "org"), (f"/{o}?tab=stars", "stars"), (f"/{o}?tab=repositories", "repos")] |
| 449 | + if pat == "/{owner}/{repo}/settings": | ||
| 450 | + res += [(f"/{o}/{r}/settings?section=branches", "branches")] | ||
| 449 | if pat == "/{owner}/{repo}/issues": | 451 | if pat == "/{owner}/{repo}/issues": |
| 450 | res += [(f"/{o}/{r}/issues?state=closed", "closed")] | 452 | res += [(f"/{o}/{r}/issues?state=closed", "closed")] |
| 451 | if pat == "/{owner}/{repo}/pulls/{number}": | 453 | if pat == "/{owner}/{repo}/pulls/{number}": |
style/_browse.scssmodified+3 -0
| @@ -261,6 +261,7 @@ dialog.finder { | |||
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | .finder-input { | 263 | .finder-input { |
| 264 | + flex: none; | ||
| 264 | width: 100%; | 265 | width: 100%; |
| 265 | height: var(--control-h); | 266 | height: var(--control-h); |
| 266 | box-sizing: border-box; | 267 | box-sizing: border-box; |
| @@ -271,6 +272,8 @@ dialog.finder { | |||
| 271 | margin: 0; | 272 | margin: 0; |
| 272 | padding: 0; | 273 | padding: 0; |
| 273 | list-style: none; | 274 | list-style: none; |
| 275 | + flex: 1 1 auto; | ||
| 276 | + min-height: 0; | ||
| 274 | overflow-y: auto; | 277 | overflow-y: auto; |
| 275 | max-height: 50vh; | 278 | max-height: 50vh; |
| 276 | font-family: var(--mono); | 279 | font-family: var(--mono); |
style/_min_code.scssmodified+14 -0
| @@ -57,3 +57,17 @@ main .repo-grid.repo-home .browse-bar .finder-open { | |||
| 57 | .repo-strip .strip-chips { | 57 | .repo-strip .strip-chips { |
| 58 | margin-left: 0; | 58 | margin-left: 0; |
| 59 | } | 59 | } |
| 60 | + | ||
| 61 | +// Browse files keeps the row's spacing: its padding is for the hover shape, not extra room, so a | ||
| 62 | +// wrapped one starts on the row's text edge like the facts above it. | ||
| 63 | +.commits-r > a.act { | ||
| 64 | + margin-left: -10px; | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +// On a phone every commit row has the same two lines: the subject, then who, when, the hash, its | ||
| 68 | +// checks and Browse files. | ||
| 69 | +@media (max-width: 700px) { | ||
| 70 | + .commits-r > .name { | ||
| 71 | + flex-basis: 100%; | ||
| 72 | + } | ||
| 73 | +} | ||
style/_one.scssmodified+14 -5
| @@ -292,7 +292,7 @@ button.icon-btn, | |||
| 292 | } | 292 | } |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | -// An action inside content: a quiet word that lights up when pointed at. | 295 | +// An action inside content: a word in the accent's ink, so it never reads as a hint or a heading. |
| 296 | 296 | ||
| 297 | a.act, | 297 | a.act, |
| 298 | span.act, | 298 | span.act, |
| @@ -309,11 +309,11 @@ button.link-button, | |||
| 309 | border-radius: 12px; | 309 | border-radius: 12px; |
| 310 | background: none; | 310 | background: none; |
| 311 | box-shadow: none; | 311 | box-shadow: none; |
| 312 | - color: var(--muted); | 312 | + color: var(--accent-ink); |
| 313 | cursor: pointer; | 313 | cursor: pointer; |
| 314 | font-family: var(--font); | 314 | font-family: var(--font); |
| 315 | font-size: 14px; | 315 | font-size: 14px; |
| 316 | - font-weight: 500; | 316 | + font-weight: 600; |
| 317 | line-height: 1; | 317 | line-height: 1; |
| 318 | text-decoration: none; | 318 | text-decoration: none; |
| 319 | white-space: nowrap; | 319 | white-space: nowrap; |
| @@ -321,7 +321,7 @@ button.link-button, | |||
| 321 | &:hover { | 321 | &:hover { |
| 322 | border: 0; | 322 | border: 0; |
| 323 | background: var(--surface-2); | 323 | background: var(--surface-2); |
| 324 | - color: var(--text); | 324 | + color: var(--accent-ink); |
| 325 | text-decoration: none; | 325 | text-decoration: none; |
| 326 | } | 326 | } |
| 327 | 327 | ||
| @@ -1446,6 +1446,7 @@ a.line:hover .name, | |||
| 1446 | 1446 | ||
| 1447 | .sheet > .sec > .line, | 1447 | .sheet > .sec > .line, |
| 1448 | .sheet > .sec > .commits-list > .line, | 1448 | .sheet > .sec > .commits-list > .line, |
| 1449 | +.sheet > .sec > .commits-list > .row-open > .line, | ||
| 1449 | .sheet > .sec > .row-open > .line { | 1450 | .sheet > .sec > .row-open > .line { |
| 1450 | margin: 0 -18px; | 1451 | margin: 0 -18px; |
| 1451 | padding-right: 18px; | 1452 | padding-right: 18px; |
| @@ -1470,7 +1471,8 @@ a.line:hover .name, | |||
| 1470 | border-bottom: 1px solid var(--border); | 1471 | border-bottom: 1px solid var(--border); |
| 1471 | } | 1472 | } |
| 1472 | 1473 | ||
| 1473 | -.sheet > .sec > .row-open > .opened { | 1474 | +.sheet > .sec > .row-open > .opened, |
| 1475 | +.sheet > .sec > .commits-list > .row-open > .opened { | ||
| 1474 | margin: 0 -18px; | 1476 | margin: 0 -18px; |
| 1475 | padding-right: 18px; | 1477 | padding-right: 18px; |
| 1476 | padding-left: 18px; | 1478 | padding-left: 18px; |
| @@ -3636,3 +3638,10 @@ details.log-group { | |||
| 3636 | padding-bottom: 4px; | 3638 | padding-bottom: 4px; |
| 3637 | } | 3639 | } |
| 3638 | } | 3640 | } |
| 3641 | + | ||
| 3642 | +// A fixed value in a field's control column (an existing branch rule's pattern) stands on its label's line. | ||
| 3643 | +.field > .field-value { | ||
| 3644 | + padding-top: 8px; | ||
| 3645 | + font-size: 15px; | ||
| 3646 | + line-height: 22px; | ||
| 3647 | +} | ||