From 881b74629c13edc34c9066ff81b0e9534cc680bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 27 Oct 2026 20:15:11 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20branch=20protection=20r?= =?UTF-8?q?ules=20are=20compact=20rows=20in=20one=20list,=20one=20open=20a?= =?UTF-8?q?t=20a=20time,=20with=20a=20left-aligned=20two-column=20editor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-web/src/i18n/repo_admin.rs | 12 ++ crates/forge-web/src/pages/repo_settings.rs | 150 +++++++------- .../forge-web/tests/e2e/repo_settings_e2e.rs | 8 +- style/main.scss | 187 ++++++++---------- 4 files changed, 179 insertions(+), 178 deletions(-) diff --git a/crates/forge-web/src/i18n/repo_admin.rs b/crates/forge-web/src/i18n/repo_admin.rs index 0692087..7ace125 100644 --- a/crates/forge-web/src/i18n/repo_admin.rs +++ b/crates/forge-web/src/i18n/repo_admin.rs @@ -29,6 +29,7 @@ pub enum K { BranchRuleRemoved, BranchRuleSaved, BuiltinRowText, + CancelRule, CancelTransfer, ChangeVisibility, CollabAdded, @@ -50,6 +51,7 @@ pub enum K { Description, DescriptionHelp, DescriptionLong, + EditRule, EnterUsername, EnterValue, ForcePushAllowed, @@ -79,6 +81,7 @@ pub enum K { PrivateOption, PublicOption, Remove, + RemoveRule, RenameHelp, RenameRepo, RenameTransferNav, @@ -219,6 +222,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { (BuiltinRowText, Tr) => { " (varsayılan dal): varsayılan olarak korunur; bunu değiştirmek için bir kural ekleyin." } + (CancelRule, En) => "Cancel", + (CancelRule, Tr) => "Vazgeç", (CancelTransfer, En) => "Cancel transfer", (CancelTransfer, Tr) => "Devri iptal et", (ChangeVisibility, En) => "Change visibility", @@ -281,6 +286,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { (DescriptionLong, Tr) => { "Açıklama en fazla 350 karakter olabilir. Hiçbir şey kaydedilmedi." } + (EditRule, En) => "Edit", + (EditRule, Tr) => "Düzenle", (EnterUsername, En) => "Enter a username.", (EnterUsername, Tr) => "Bir kullanıcı adı girin.", (EnterValue, En) => "Enter a value.", @@ -355,6 +362,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { (PublicOption, Tr) => "Herkese açık: herkes okuyabilir", (Remove, En) => "Remove", (Remove, Tr) => "Kaldır", + (RemoveRule, En) => "Remove rule", + (RemoveRule, Tr) => "Kuralı kaldır", (RenameHelp, En) => { "Letters, digits, '.', '_' and '-'. The old name keeps working: its web and clone URLs redirect to the new name." } @@ -674,6 +683,7 @@ mod tests { K::BranchRuleRemoved, K::BranchRuleSaved, K::BuiltinRowText, + K::CancelRule, K::CancelTransfer, K::ChangeVisibility, K::CollabAdded, @@ -695,6 +705,7 @@ mod tests { K::Description, K::DescriptionHelp, K::DescriptionLong, + K::EditRule, K::EnterUsername, K::EnterValue, K::ForcePushAllowed, @@ -724,6 +735,7 @@ mod tests { K::PrivateOption, K::PublicOption, K::Remove, + K::RemoveRule, K::RenameHelp, K::RenameRepo, K::RenameTransferNav, diff --git a/crates/forge-web/src/pages/repo_settings.rs b/crates/forge-web/src/pages/repo_settings.rs index 8f5849f..87666dc 100644 --- a/crates/forge-web/src/pages/repo_settings.rs +++ b/crates/forge-web/src/pages/repo_settings.rs @@ -525,9 +525,10 @@ async fn switch_row( }) } -/// The rule cards, then a muted row for the default branch when no rule covers it, then the New -/// rule card. A card opens with its rule's values. The card whose draft has an error opens with -/// the draft instead, and the New rule card opens with the draft when no card takes it. +/// The rule list: one bordered box with a row per rule, then a muted row for the default branch +/// when no rule covers it, then the New rule row last. A rule row opens with its rule's values, +/// and the row whose draft has an error opens with the draft instead. The New rule row opens with +/// the draft when no rule row takes it. The rows share one `name`, so opening one closes the rest. #[component] async fn branch_rule_cards( lang: Lang, @@ -544,52 +545,51 @@ async fn branch_rule_cards( Ok(view! {
for card in cards.iter() { -
-
-
- - - (card.draft.pattern.as_str()) - - for pill in card.pills.iter() { - (pill.text.as_str()) - } - - - - - branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), - draft: card.draft.clone(), contexts: contexts.clone()) -
-
- - - -
-
-
+
+ + (card.draft.pattern.as_str()) + + for pill in card.pills.iter() { + (pill.text.as_str()) + } + + + (g::t(lang, K::EditRule)) + + + + branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), + delete_action: delete_action.clone(), rule_id: Some(card.id.clone()), + draft: card.draft.clone(), contexts: contexts.clone()) +
} if builtin_row { -
+
(default_branch.as_str()) (g::t(lang, K::BuiltinRowText))
} +
+ "+ "(g::t(lang, K::NewRule)) + branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), + delete_action: delete_action.clone(), rule_id: None, + draft: new_draft, contexts: contexts.clone()) +
-
- "+ "(g::t(lang, K::NewRule)) - branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), - draft: new_draft, contexts: contexts.clone()) -
}) } -/// The rule form, in four sections. Saving an existing pattern updates its rule. +/// The rule form: the pattern, the pushes and merging switches side by side on wide screens, and +/// the checks. Saving an existing pattern updates its rule. An existing rule also gets a Remove +/// button. Its delete form is a sibling of the rule form, because forms cannot nest, and the button +/// submits it through its `form` attribute. #[component] async fn branch_rule_form( lang: Lang, csrf: String, save_action: String, + delete_action: String, + rule_id: Option, draft: RuleDraft, contexts: Vec, ) -> Result { @@ -605,7 +605,15 @@ async fn branch_rule_form( required_checks, error, } = draft; + // The delete form's id and the rule id it posts, for an existing rule only. + let remove = rule_id.map(|id| (format!("remove-rule-{id}"), id)); Ok(view! { + if let Some((remove_id, id)) = &remove { +
+ + +
+ }
if let Some(message) = error { alert(message: message.as_str()) @@ -619,39 +627,41 @@ async fn branch_rule_form(

(g::t(lang, K::PatternHelpA))"*"(g::t(lang, K::PatternHelpB))"**"(g::t(lang, K::PatternHelpC))"/"(g::t(lang, K::PatternHelpD))

-
- (g::t(lang, K::SectionPushes)) -
- switch_row(name: "allow_force_push".to_owned(), checked: allow_force_push, - title: g::t(lang, K::AllowForcePush).to_owned(), - description: Some(g::t(lang, K::ForcePushDesc).to_owned())) - switch_row(name: "allow_deletion".to_owned(), checked: allow_deletion, - title: g::t(lang, K::AllowDeletion).to_owned(), - description: Some(g::t(lang, K::DeletionDesc).to_owned())) - switch_row(name: "restrict_push".to_owned(), checked: restrict_push, - title: g::t(lang, K::RestrictPushTitle).to_owned(), - description: Some(g::t(lang, K::RestrictPushDesc).to_owned())) -
-
-
- (g::t(lang, K::SectionMerging)) -
- - switch_row(name: "block_on_changes_requested".to_owned(), checked: block_on_changes_requested, - title: g::t(lang, K::BlockWhileChanges).to_owned(), description: None) - switch_row(name: "require_up_to_date".to_owned(), checked: require_up_to_date, - title: g::t(lang, K::RequireUpToDate).to_owned(), description: None) - switch_row(name: "require_merge_queue".to_owned(), checked: require_merge_queue, - title: mq::t(lang, mq::K::RequireMergeQueue).to_owned(), - description: Some(mq::t(lang, mq::K::RequireMergeQueueHint).to_owned())) -
-
+
+
+ (g::t(lang, K::SectionPushes)) +
+ switch_row(name: "allow_force_push".to_owned(), checked: allow_force_push, + title: g::t(lang, K::AllowForcePush).to_owned(), + description: Some(g::t(lang, K::ForcePushDesc).to_owned())) + switch_row(name: "allow_deletion".to_owned(), checked: allow_deletion, + title: g::t(lang, K::AllowDeletion).to_owned(), + description: Some(g::t(lang, K::DeletionDesc).to_owned())) + switch_row(name: "restrict_push".to_owned(), checked: restrict_push, + title: g::t(lang, K::RestrictPushTitle).to_owned(), + description: Some(g::t(lang, K::RestrictPushDesc).to_owned())) +
+
+
+ (g::t(lang, K::SectionMerging)) +
+ + switch_row(name: "block_on_changes_requested".to_owned(), checked: block_on_changes_requested, + title: g::t(lang, K::BlockWhileChanges).to_owned(), description: None) + switch_row(name: "require_up_to_date".to_owned(), checked: require_up_to_date, + title: g::t(lang, K::RequireUpToDate).to_owned(), description: None) + switch_row(name: "require_merge_queue".to_owned(), checked: require_merge_queue, + title: mq::t(lang, mq::K::RequireMergeQueue).to_owned(), + description: Some(mq::t(lang, mq::K::RequireMergeQueueHint).to_owned())) +
+
+
(g::t(lang, K::SectionChecks))
- + + + if let Some((remove_id, _)) = &remove { + + }
}) diff --git a/crates/forge-web/tests/e2e/repo_settings_e2e.rs b/crates/forge-web/tests/e2e/repo_settings_e2e.rs index 1ff5a4b..21b7a96 100644 --- a/crates/forge-web/tests/e2e/repo_settings_e2e.rs +++ b/crates/forge-web/tests/e2e/repo_settings_e2e.rs @@ -365,11 +365,11 @@ async fn repo_settings_deletes_rows_when_repo_dir_is_missing() { ); } -/// The rule cards of the branch rules list in page order, each as its pattern followed by the texts -/// of its summary pills. The built-in default-branch card has no rule behind it, so it is skipped. +/// The rule rows of the branch rules list in page order, each as its pattern followed by the texts +/// of its summary pills. The built-in default-branch row has no rule behind it, so it is skipped. fn branch_rows(body: &str) -> Vec> { let doc = scraper::Html::parse_document(body); - let cards = scraper::Selector::parse("div.rule-card:not(.rule-builtin)").expect("selector"); + let cards = scraper::Selector::parse("details.rule-row:not(.rule-new)").expect("selector"); let pattern = scraper::Selector::parse("summary code.rule-pattern").expect("selector"); let pills = scraper::Selector::parse("summary .rule-pill").expect("selector"); let text = |el: scraper::ElementRef| el.text().collect::().trim().to_owned(); @@ -383,7 +383,7 @@ fn branch_rows(body: &str) -> Vec> { .collect() } -/// The card for `pattern` as its cells (see `branch_rows`), if the list has one. +/// The row for `pattern` as its cells (see `branch_rows`), if the list has one. fn rule_row(body: &str, pattern: &str) -> Option> { branch_rows(body) .into_iter() diff --git a/style/main.scss b/style/main.scss index 6803b57..1fdb656 100644 --- a/style/main.scss +++ b/style/main.scss @@ -2764,46 +2764,34 @@ code { } // branch protection -// Settings page: one card per rule (a summary with its pills and the form when open), a muted row -// for the default branch when no rule covers it, and a dashed New rule card at the end. +// Settings page: one bordered list of rules. Each rule is a row: a one-line summary (pattern, pills, +// Edit and a chevron) that opens its form below it. The default-branch row, when no rule covers it, +// is a plain muted row, and New rule is the last row. .rule-list { display: flex; flex-direction: column; - gap: 10px; margin-bottom: 10px; -} - -.rule-card { + overflow: hidden; border: 1px solid var(--border); - border-radius: var(--radius-lg); + border-radius: var(--radius-md); background: var(--surface); -} - -// The rule card's bordered box holds the summary and the form, with Remove beside the summary row. -.rule-card-head { - display: flex; - align-items: flex-start; - - > .rule-details { - flex: 1 1 auto; - min-width: 0; - } - > .remove-form { - flex: none; - margin: 10px 12px 0 0; + > * + * { + border-top: 1px solid var(--border); } } -.rule-details { +// A rule row: the summary is one 44px line, and the form under it sits on the page background. +.rule-row { > summary { - display: flex; + display: grid; + grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto; align-items: center; gap: 12px; - padding: 12px 16px; + height: 44px; + padding: 0 14px; cursor: pointer; list-style: none; - border-radius: var(--radius-lg); &::-webkit-details-marker { display: none; @@ -2814,16 +2802,24 @@ code { } } - &[open] > summary { - border-bottom: 1px solid var(--border); + > .rule-form { + border-top: 1px solid var(--border); + background: var(--bg); + } + + // The summary's Edit text and chevron. The chevron points down when closed and up when open. + > summary .rule-end { + display: flex; + align-items: center; + gap: 8px; + color: var(--muted); + font-size: 12px; } - // The summary's chevron points down when closed and up when open. > summary .rule-chevron { flex: none; width: 7px; height: 7px; - margin: 0 4px 0 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); @@ -2835,33 +2831,32 @@ code { } } -.rule-summary-main { - display: flex; - flex: 1 1 auto; - flex-direction: column; - align-items: flex-start; - gap: 6px; - min-width: 0; -} - .rule-pattern { + min-width: 0; padding: 0; background: none; font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--text); - overflow-wrap: anywhere; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } +// The pills share the middle column. When they run out of room, the last ones are cut off. .rule-pills { display: flex; - flex-wrap: wrap; + flex-wrap: nowrap; gap: 6px; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; } .rule-pill { display: inline-flex; + flex: none; align-items: center; padding: 1px 8px; border: 1px solid var(--border); @@ -2889,16 +2884,14 @@ code { } } -// The built-in default-branch row: muted, dashed, not a card to open. +// The built-in default-branch row: muted, one line, not clickable. .rule-builtin { - display: flex; - flex-direction: column; - align-items: flex-start; - gap: 6px; - padding: 12px 16px; - border-style: dashed; - border-color: var(--border-strong); - background: none; + display: grid; + grid-template-columns: minmax(0, auto) minmax(0, 1fr); + align-items: center; + gap: 12px; + height: 44px; + padding: 0 14px; color: var(--muted); .rule-pattern { @@ -2906,47 +2899,22 @@ code { } } -// New rule: a dashed row that becomes a card once open. +// New rule: the last row, its one line in the accent colour. .rule-new { - border: 0; - background: none; - > summary { - display: block; - padding: 12px 16px; - border: 1px dashed var(--border-strong); - border-radius: var(--radius-lg); - color: var(--muted); + display: flex; + align-items: center; + height: 44px; + padding: 0 14px; + color: var(--accent-ink); font-weight: 600; - text-align: center; cursor: pointer; list-style: none; - - &::-webkit-details-marker { - display: none; - } - - &:hover { - border-color: var(--accent); - color: var(--accent); - } - } - - &[open] { - border: 1px solid var(--border); - border-radius: var(--radius-lg); - background: var(--surface); - } - - &[open] > summary { - border-style: none; - border-bottom: 1px solid var(--border); - border-radius: var(--radius-lg) var(--radius-lg) 0 0; - color: var(--text); } } -// The rule form: four sections, each with a small uppercase legend. +// The rule form: four sections, each with a small uppercase legend. Pushes and Merging sit side by +// side on wide screens. .rule-form { display: flex; flex-direction: column; @@ -2958,8 +2926,29 @@ code { max-width: 28rem; } + input[name="pattern"] { + max-width: 320px; + } + .form-actions { - justify-content: flex-end; + align-items: center; + + > .danger { + margin-left: auto; + } + } +} + +.rule-pair { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 20px; +} + +@media (min-width: 900px) { + .rule-pair { + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 24px; } } @@ -3004,15 +2993,16 @@ code { border-radius: var(--radius-md); } -// A row is a label: text on the left, the toggle or a number input on the right. Rows are split by -// a 1px divider. +// A row is a label: the text in the left column, the toggle or a number input in the right one. +// Rows are split by a 1px divider. .switch-row { - display: flex; + display: grid; + grid-template-columns: minmax(0, 1fr) auto; align-items: center; - justify-content: space-between; - gap: 16px; - padding: 12px 0; + column-gap: 16px; + padding: 10px 0; border-top: 1px solid var(--border); + text-align: left; cursor: pointer; &:first-child { @@ -3080,23 +3070,8 @@ code { } input[type="number"] { - flex: none; - width: 72px; - max-width: 72px; - } -} - -@media (max-width: 600px) { - .rule-details > summary { - padding: 10px 12px; - } - - .rule-form { - padding: 12px; - } - - .rule-card-head > .remove-form { - margin-right: 8px; + width: 64px; + max-width: 64px; } }