forge
Explore
Log in

Don't you dare go Hollow

Branch protection rules are cards with summary pills that open their own form, grouped into sections with switches

Browse files at this commit

5d315842027b1fdee125d053fe6849e5b940a494Ahmet Kaan GümüşParent: 749adab
  • style
    • branch protection rules are cards with summary pills that open their own form, grouped into sections with switches
Show full message
💄 style: branch protection rules are cards with summary pills that open their own form, grouped into sections with switches
crates/forge-web/src/i18n/repo_admin.rsmodified+52 -54
@@ -10,7 +10,6 @@ pub enum K {
10 AddCollaboratorHeading,10 AddCollaboratorHeading,
11 AddCollaboratorHelp,11 AddCollaboratorHelp,
12 AddOrUpdate,12 AddOrUpdate,
13- AddOrUpdateRule,
14 AllowDeletion,13 AllowDeletion,
15 AllowForcePush,14 AllowForcePush,
16 AlreadyOwner,15 AlreadyOwner,
@@ -47,31 +46,31 @@ pub enum K {
47 DeleteRepoHelp,46 DeleteRepoHelp,
48 DeleteTrashHelp,47 DeleteTrashHelp,
49 DeletionAllowed,48 DeletionAllowed,
49+ DeletionDesc,
50 Description,50 Description,
51 DescriptionHelp,51 DescriptionHelp,
52 DescriptionLong,52 DescriptionLong,
53 EnterUsername,53 EnterUsername,
54 EnterValue,54 EnterValue,
55 ForcePushAllowed,55 ForcePushAllowed,
56+ ForcePushDesc,
56 General,57 General,
57 GeneralSaved,58 GeneralSaved,
58 IUnderstand,59 IUnderstand,
59 InvalidRole,60 InvalidRole,
60 LastUpdated,61 LastUpdated,
61- MergePushRules,
62 Mirrors,62 Mirrors,
63 Name,63 Name,
64 NameRule,64 NameRule,
65 NewName,65 NewName,
66 NewOwnerLabel,66 NewOwnerLabel,
67+ NewRule,
67 NoBranchesYet,68 NoBranchesYet,
68 NoCollaborators,69 NoCollaborators,
69 NoPendingTransfer,70 NoPendingTransfer,
70- NoRule,
71 NoSecrets,71 NoSecrets,
72 NotCollaborator,72 NotCollaborator,
73 OwnerIsMember,73 OwnerIsMember,
74- PatternColumn,
75 PatternHelpA,74 PatternHelpA,
76 PatternHelpB,75 PatternHelpB,
77 PatternHelpC,76 PatternHelpC,
@@ -91,7 +90,8 @@ pub enum K {
91 RepoUnarchived,90 RepoUnarchived,
92 RequireUpToDate,91 RequireUpToDate,
93 RequiredApprovals,92 RequiredApprovals,
94- RestrictPush,93+ RestrictPushDesc,
94+ RestrictPushTitle,
95 Role,95 Role,
96 RoleAdminDesc,96 RoleAdminDesc,
97 RoleMaintainDesc,97 RoleMaintainDesc,
@@ -100,12 +100,13 @@ pub enum K {
100 RoleTriageDesc,100 RoleTriageDesc,
101 RoleUpdated,101 RoleUpdated,
102 RoleWriteDesc,102 RoleWriteDesc,
103- RuleChangesBlock,
104- RuleRestrictPush,
105- RuleUpToDate,
106 RequiredChecks,103 RequiredChecks,
107 RequiredChecksHelp,104 RequiredChecksHelp,
108 RecentContexts,105 RecentContexts,
106+ RuleChangesShort,
107+ RuleNoExtra,
108+ RulePrOnly,
109+ RuleUpToDateShort,
109 SaveGeneral,110 SaveGeneral,
110 SaveRole,111 SaveRole,
111 SaveRule,112 SaveRule,
@@ -116,6 +117,10 @@ pub enum K {
116 SecretSaved,117 SecretSaved,
117 Secrets,118 Secrets,
118 SecretsHelp,119 SecretsHelp,
120+ SectionChecks,
121+ SectionMerging,
122+ SectionPattern,
123+ SectionPushes,
119 SettingsNavLabel,124 SettingsNavLabel,
120 StartTransferLink,125 StartTransferLink,
121 TransferHelp,126 TransferHelp,
@@ -156,8 +161,6 @@ pub fn t(lang: Lang, key: K) -> &'static str {
156 }161 }
157 (AddOrUpdate, En) => "Add or update a secret",162 (AddOrUpdate, En) => "Add or update a secret",
158 (AddOrUpdate, Tr) => "Gizli anahtar ekle veya güncelle",163 (AddOrUpdate, Tr) => "Gizli anahtar ekle veya güncelle",
159- (AddOrUpdateRule, En) => "Add or update a rule",
160- (AddOrUpdateRule, Tr) => "Kural ekle veya güncelle",
161 (AllowDeletion, En) => "Allow deletion",164 (AllowDeletion, En) => "Allow deletion",
162 (AllowDeletion, Tr) => "Silmeye izin verilir",165 (AllowDeletion, Tr) => "Silmeye izin verilir",
163 (AllowForcePush, En) => "Allow force pushes",166 (AllowForcePush, En) => "Allow force pushes",
@@ -262,7 +265,9 @@ pub fn t(lang: Lang, key: K) -> &'static str {
262 }265 }
263 (DeletionAllowed, En) => "Deletion allowed",266 (DeletionAllowed, En) => "Deletion allowed",
264 (DeletionAllowed, Tr) => "Silmeye izin var",267 (DeletionAllowed, Tr) => "Silmeye izin var",
268+ (DeletionDesc, En) => "The branch can be deleted.",
265 (Description, En) => "Description",269 (Description, En) => "Description",
270+ (DeletionDesc, Tr) => "Dal silinebilir.",
266 (Description, Tr) => "Açıklama",271 (Description, Tr) => "Açıklama",
267 (DescriptionHelp, En) => {272 (DescriptionHelp, En) => {
268 "Up to 350 characters, on one line. It is shown under the repository name."273 "Up to 350 characters, on one line. It is shown under the repository name."
@@ -282,7 +287,9 @@ pub fn t(lang: Lang, key: K) -> &'static str {
282 (EnterValue, Tr) => "Bir değer girin.",287 (EnterValue, Tr) => "Bir değer girin.",
283 (ForcePushAllowed, En) => "Force push allowed",288 (ForcePushAllowed, En) => "Force push allowed",
284 (ForcePushAllowed, Tr) => "Zorla gönderime izin var",289 (ForcePushAllowed, Tr) => "Zorla gönderime izin var",
290+ (ForcePushDesc, En) => "Rewriting history with git push --force is allowed.",
285 (General, En) => "General",291 (General, En) => "General",
292+ (ForcePushDesc, Tr) => "git push --force ile geçmişin yeniden yazılmasına izin verilir.",
286 (General, Tr) => "Genel",293 (General, Tr) => "Genel",
287 (GeneralSaved, En) => "General settings saved.",294 (GeneralSaved, En) => "General settings saved.",
288 (GeneralSaved, Tr) => "Genel ayarlar kaydedildi.",295 (GeneralSaved, Tr) => "Genel ayarlar kaydedildi.",
@@ -292,8 +299,6 @@ pub fn t(lang: Lang, key: K) -> &'static str {
292 (InvalidRole, Tr) => "Geçerli bir rol seçin.",299 (InvalidRole, Tr) => "Geçerli bir rol seçin.",
293 (LastUpdated, En) => "Last updated",300 (LastUpdated, En) => "Last updated",
294 (LastUpdated, Tr) => "Son güncelleme",301 (LastUpdated, Tr) => "Son güncelleme",
295- (MergePushRules, En) => "Merge and push rules",
296- (MergePushRules, Tr) => "Birleştirme ve gönderme kuralları",
297 (Mirrors, En) => "Mirrors",302 (Mirrors, En) => "Mirrors",
298 (Mirrors, Tr) => "Yansılar",303 (Mirrors, Tr) => "Yansılar",
299 (Name, En) => "Name",304 (Name, En) => "Name",
@@ -308,16 +313,16 @@ pub fn t(lang: Lang, key: K) -> &'static str {
308 (NewName, Tr) => "Yeni ad",313 (NewName, Tr) => "Yeni ad",
309 (NewOwnerLabel, En) => "New owner (username)",314 (NewOwnerLabel, En) => "New owner (username)",
310 (NewOwnerLabel, Tr) => "Yeni sahip (kullanıcı adı)",315 (NewOwnerLabel, Tr) => "Yeni sahip (kullanıcı adı)",
316+ (NewRule, En) => "New rule",
311 (NoBranchesYet, En) => {317 (NoBranchesYet, En) => {
312 "No branches yet. The default branch can be chosen after the first push."318 "No branches yet. The default branch can be chosen after the first push."
313 }319 }
320+ (NewRule, Tr) => "Yeni kural",
314 (NoBranchesYet, Tr) => "Henüz dal yok. Varsayılan dal, ilk gönderimden sonra seçilebilir.",321 (NoBranchesYet, Tr) => "Henüz dal yok. Varsayılan dal, ilk gönderimden sonra seçilebilir.",
315 (NoCollaborators, En) => "No collaborators yet. Add one below.",322 (NoCollaborators, En) => "No collaborators yet. Add one below.",
316 (NoCollaborators, Tr) => "Henüz ortak çalışan yok. Aşağıdan bir ortak çalışan ekleyin.",323 (NoCollaborators, Tr) => "Henüz ortak çalışan yok. Aşağıdan bir ortak çalışan ekleyin.",
317 (NoPendingTransfer, En) => "No transfer is pending for this repository.",324 (NoPendingTransfer, En) => "No transfer is pending for this repository.",
318 (NoPendingTransfer, Tr) => "Bu depo için bekleyen bir devir yok.",325 (NoPendingTransfer, Tr) => "Bu depo için bekleyen bir devir yok.",
319- (NoRule, En) => "none",
320- (NoRule, Tr) => "yok",
321 (NoSecrets, En) => "No secrets yet.",326 (NoSecrets, En) => "No secrets yet.",
322 (NoSecrets, Tr) => "Henüz gizli anahtar yok.",327 (NoSecrets, Tr) => "Henüz gizli anahtar yok.",
323 (NotCollaborator, En) => "That user is not a collaborator on this repo.",328 (NotCollaborator, En) => "That user is not a collaborator on this repo.",
@@ -328,8 +333,6 @@ pub fn t(lang: Lang, key: K) -> &'static str {
328 (OwnerIsMember, Tr) => {333 (OwnerIsMember, Tr) => {
329 "Depo sahibi zaten tam erişimli bir üyedir ve ortak çalışan olarak eklenemez."334 "Depo sahibi zaten tam erişimli bir üyedir ve ortak çalışan olarak eklenemez."
330 }335 }
331- (PatternColumn, En) => "Pattern",
332- (PatternColumn, Tr) => "Desen",
333 (PatternHelpA, En) => "A branch name, or a pattern: ",336 (PatternHelpA, En) => "A branch name, or a pattern: ",
334 (PatternHelpA, Tr) => "Bir dal adı veya desen: ",337 (PatternHelpA, Tr) => "Bir dal adı veya desen: ",
335 (PatternHelpB, En) => " matches within one path segment and ",338 (PatternHelpB, En) => " matches within one path segment and ",
@@ -380,13 +383,11 @@ pub fn t(lang: Lang, key: K) -> &'static str {
380 }383 }
381 (RequiredApprovals, En) => "Required approvals (0 to 20)",384 (RequiredApprovals, En) => "Required approvals (0 to 20)",
382 (RequiredApprovals, Tr) => "Gerekli onay sayısı (0 ile 20 arası)",385 (RequiredApprovals, Tr) => "Gerekli onay sayısı (0 ile 20 arası)",
383- (RestrictPush, En) => {386+ (RestrictPushDesc, En) => "Direct pushes are limited to repo admins.",
384- "Only accept changes through pull requests (direct pushes are limited to repo admins)"387+ (RestrictPushTitle, En) => "Only accept changes through pull requests",
385- }
386- (RestrictPush, Tr) => {
387- "Değişiklikler yalnızca çekme istekleri üzerinden kabul edilir (doğrudan gönderimler depo yöneticileriyle sınırlıdır)"
388- }
389 (Role, En) => "Role",388 (Role, En) => "Role",
389+ (RestrictPushDesc, Tr) => "Doğrudan gönderimler depo yöneticileriyle sınırlıdır.",
390+ (RestrictPushTitle, Tr) => "Değişiklikler yalnızca çekme istekleri üzerinden kabul edilir",
390 (Role, Tr) => "Rol",391 (Role, Tr) => "Rol",
391 (RoleAdminDesc, En) => "full repo settings except delete and transfer",392 (RoleAdminDesc, En) => "full repo settings except delete and transfer",
392 (RoleAdminDesc, Tr) => "silme ve devir dışında tüm depo ayarları",393 (RoleAdminDesc, Tr) => "silme ve devir dışında tüm depo ayarları",
@@ -402,10 +403,6 @@ pub fn t(lang: Lang, key: K) -> &'static str {
402 (RoleUpdated, Tr) => "Rol güncellendi.",403 (RoleUpdated, Tr) => "Rol güncellendi.",
403 (RoleWriteDesc, En) => "push",404 (RoleWriteDesc, En) => "push",
404 (RoleWriteDesc, Tr) => "gönderme (push)",405 (RoleWriteDesc, Tr) => "gönderme (push)",
405- (RuleChangesBlock, En) => "changes requested block merges",
406- (RuleChangesBlock, Tr) => "değişiklik istenmesi birleştirmeyi engeller",
407- (RuleRestrictPush, En) => "direct pushes limited to admins",
408- (RuleRestrictPush, Tr) => "doğrudan gönderimler yöneticilerle sınırlı",
409 (RequiredChecks, En) => "Required status checks",406 (RequiredChecks, En) => "Required status checks",
410 (RequiredChecks, Tr) => "Gerekli durum denetimleri",407 (RequiredChecks, Tr) => "Gerekli durum denetimleri",
411 (RequiredChecksHelp, En) => {408 (RequiredChecksHelp, En) => {
@@ -416,9 +413,15 @@ pub fn t(lang: Lang, key: K) -> &'static str {
416 }413 }
417 (RecentContexts, En) => "Recently seen:",414 (RecentContexts, En) => "Recently seen:",
418 (RecentContexts, Tr) => "Son görülenler:",415 (RecentContexts, Tr) => "Son görülenler:",
419- (RuleUpToDate, En) => "head must be up to date with base",416+ (RuleChangesShort, En) => "Blocks on changes requested",
420- (RuleUpToDate, Tr) => "kaynak dal, hedef dalın güncel hâlini içermelidir",417+ (RuleNoExtra, En) => "No extra rules",
418+ (RulePrOnly, En) => "PR only",
419+ (RuleUpToDateShort, En) => "Up to date",
421 (SaveGeneral, En) => "Save general settings",420 (SaveGeneral, En) => "Save general settings",
421+ (RuleChangesShort, Tr) => "değişiklik istenirse engeller",
422+ (RuleNoExtra, Tr) => "Ek kural yok",
423+ (RulePrOnly, Tr) => "yalnızca PR",
424+ (RuleUpToDateShort, Tr) => "güncel",
422 (SaveGeneral, Tr) => "Genel ayarları kaydet",425 (SaveGeneral, Tr) => "Genel ayarları kaydet",
423 (SaveRole, En) => "Save",426 (SaveRole, En) => "Save",
424 (SaveRole, Tr) => "Kaydet",427 (SaveRole, Tr) => "Kaydet",
@@ -442,7 +445,15 @@ pub fn t(lang: Lang, key: K) -> &'static str {
442 (SecretsHelp, Tr) => {445 (SecretsHelp, Tr) => {
443 "Gizli anahtarlar, bu deponun CI işlerine ortam değişkeni olarak aktarılır. Değerler yalnızca yazılabilir: kaydedildikten sonra geri okunamazlar ve bir gizli anahtarı güncellemek değerini değiştirir."446 "Gizli anahtarlar, bu deponun CI işlerine ortam değişkeni olarak aktarılır. Değerler yalnızca yazılabilir: kaydedildikten sonra geri okunamazlar ve bir gizli anahtarı güncellemek değerini değiştirir."
444 }447 }
448+ (SectionChecks, En) => "Status checks",
449+ (SectionMerging, En) => "Merging",
450+ (SectionPattern, En) => "Pattern",
451+ (SectionPushes, En) => "Pushes",
445 (SettingsNavLabel, En) => "Settings",452 (SettingsNavLabel, En) => "Settings",
453+ (SectionChecks, Tr) => "Durum denetimleri",
454+ (SectionMerging, Tr) => "Birleştirme",
455+ (SectionPattern, Tr) => "Desen",
456+ (SectionPushes, Tr) => "Gönderimler",
446 (SettingsNavLabel, Tr) => "Ayarlar",457 (SettingsNavLabel, Tr) => "Ayarlar",
447 (StartTransferLink, En) => "Start or change a transfer in the settings",458 (StartTransferLink, En) => "Start or change a transfer in the settings",
448 (StartTransferLink, Tr) => "Ayarlarda devir başlatın veya değiştirin",459 (StartTransferLink, Tr) => "Ayarlarda devir başlatın veya değiştirin",
@@ -625,24 +636,6 @@ pub fn role_for(lang: Lang, username: &str) -> String {
625 }636 }
626 }637 }
627 638
628-/// `yes` or `no` for a rule column.
629-pub fn yes_no(lang: Lang, value: bool) -> &'static str {
630- match (lang, value) {
631- (Lang::En, true) => "yes",
632- (Lang::En, false) => "no",
633- (Lang::Tr, true) => "evet",
634- (Lang::Tr, false) => "hayır",
635- }
636-}
637-
638-/// The number of required status checks in a rule summary.
639-pub fn checks_count(lang: Lang, n: usize) -> String {
640- match lang {
641- Lang::En => format!("{n} required check{}", if n == 1 { "" } else { "s" }),
642- Lang::Tr => format!("{n} gerekli denetim"),
643- }
644-}
645-
646 /// The number of required approvals in a rule summary.639 /// The number of required approvals in a rule summary.
647 pub fn approvals_count(lang: Lang, n: u32) -> String {640 pub fn approvals_count(lang: Lang, n: u32) -> String {
648 match lang {641 match lang {
@@ -662,7 +655,6 @@ mod tests {
662 K::AddCollaboratorHeading,655 K::AddCollaboratorHeading,
663 K::AddCollaboratorHelp,656 K::AddCollaboratorHelp,
664 K::AddOrUpdate,657 K::AddOrUpdate,
665- K::AddOrUpdateRule,
666 K::AllowDeletion,658 K::AllowDeletion,
667 K::AllowForcePush,659 K::AllowForcePush,
668 K::AlreadyOwner,660 K::AlreadyOwner,
@@ -699,31 +691,31 @@ mod tests {
699 K::DeleteRepoHelp,691 K::DeleteRepoHelp,
700 K::DeleteTrashHelp,692 K::DeleteTrashHelp,
701 K::DeletionAllowed,693 K::DeletionAllowed,
694+ K::DeletionDesc,
702 K::Description,695 K::Description,
703 K::DescriptionHelp,696 K::DescriptionHelp,
704 K::DescriptionLong,697 K::DescriptionLong,
705 K::EnterUsername,698 K::EnterUsername,
706 K::EnterValue,699 K::EnterValue,
707 K::ForcePushAllowed,700 K::ForcePushAllowed,
701+ K::ForcePushDesc,
708 K::General,702 K::General,
709 K::GeneralSaved,703 K::GeneralSaved,
710 K::IUnderstand,704 K::IUnderstand,
711 K::InvalidRole,705 K::InvalidRole,
712 K::LastUpdated,706 K::LastUpdated,
713- K::MergePushRules,
714 K::Mirrors,707 K::Mirrors,
715 K::Name,708 K::Name,
716 K::NameRule,709 K::NameRule,
717 K::NewName,710 K::NewName,
718 K::NewOwnerLabel,711 K::NewOwnerLabel,
712+ K::NewRule,
719 K::NoBranchesYet,713 K::NoBranchesYet,
720 K::NoCollaborators,714 K::NoCollaborators,
721 K::NoPendingTransfer,715 K::NoPendingTransfer,
722- K::NoRule,
723 K::NoSecrets,716 K::NoSecrets,
724 K::NotCollaborator,717 K::NotCollaborator,
725 K::OwnerIsMember,718 K::OwnerIsMember,
726- K::PatternColumn,
727 K::PatternHelpA,719 K::PatternHelpA,
728 K::PatternHelpB,720 K::PatternHelpB,
729 K::PatternHelpC,721 K::PatternHelpC,
@@ -743,7 +735,8 @@ mod tests {
743 K::RepoUnarchived,735 K::RepoUnarchived,
744 K::RequireUpToDate,736 K::RequireUpToDate,
745 K::RequiredApprovals,737 K::RequiredApprovals,
746- K::RestrictPush,738+ K::RestrictPushDesc,
739+ K::RestrictPushTitle,
747 K::Role,740 K::Role,
748 K::RoleAdminDesc,741 K::RoleAdminDesc,
749 K::RoleMaintainDesc,742 K::RoleMaintainDesc,
@@ -752,12 +745,13 @@ mod tests {
752 K::RoleTriageDesc,745 K::RoleTriageDesc,
753 K::RoleUpdated,746 K::RoleUpdated,
754 K::RoleWriteDesc,747 K::RoleWriteDesc,
755- K::RuleChangesBlock,
756- K::RuleRestrictPush,
757- K::RuleUpToDate,
758 K::RequiredChecks,748 K::RequiredChecks,
759 K::RequiredChecksHelp,749 K::RequiredChecksHelp,
760 K::RecentContexts,750 K::RecentContexts,
751+ K::RuleChangesShort,
752+ K::RuleNoExtra,
753+ K::RulePrOnly,
754+ K::RuleUpToDateShort,
761 K::SaveGeneral,755 K::SaveGeneral,
762 K::SaveRole,756 K::SaveRole,
763 K::SaveRule,757 K::SaveRule,
@@ -768,6 +762,10 @@ mod tests {
768 K::SecretSaved,762 K::SecretSaved,
769 K::Secrets,763 K::Secrets,
770 K::SecretsHelp,764 K::SecretsHelp,
765+ K::SectionChecks,
766+ K::SectionMerging,
767+ K::SectionPattern,
768+ K::SectionPushes,
771 K::SettingsNavLabel,769 K::SettingsNavLabel,
772 K::StartTransferLink,770 K::StartTransferLink,
773 K::TransferHelp,771 K::TransferHelp,
crates/forge-web/src/pages/repo_settings.rsmodified+210 -117
@@ -448,149 +448,212 @@ fn parse_rule_flags(lang: Lang, form: &BranchForm) -> std::result::Result<RuleFl
448 })448 })
449 }449 }
450 450
451-/// A short list of the merge and push rules a rule sets, or "none".451+/// One pill in a rule card's summary: its text and its classes.
452-fn rule_summary(lang: Lang, rule: &BranchRule) -> String {452+struct RulePill {
453- let mut parts = Vec::new();453+ text: String,
454- if rule.required_approvals > 0 {454+ class: &'static str,
455- parts.push(g::approvals_count(lang, rule.required_approvals));455+}
456+
457+/// The pills that describe a rule in its card summary. A rule that sets nothing gets one muted pill.
458+fn rule_pills(lang: Lang, rule: &BranchRule) -> Vec<RulePill> {
459+ let warn = "rule-pill warn";
460+ let plain = "rule-pill";
461+ let mut pills = Vec::new();
462+ if rule.allow_force_push {
463+ pills.push(pill(g::t(lang, K::ForcePushAllowed), warn));
456 }464 }
457- if rule.block_on_changes_requested {465+ if rule.allow_deletion {
458- parts.push(g::t(lang, K::RuleChangesBlock).to_owned());466+ pills.push(pill(g::t(lang, K::DeletionAllowed), warn));
459 }467 }
460- if rule.require_up_to_date {468+ if rule.required_approvals > 0 {
461- parts.push(g::t(lang, K::RuleUpToDate).to_owned());469+ pills.push(pill(&g::approvals_count(lang, rule.required_approvals), plain));
462 }470 }
463 if rule.restrict_push {471 if rule.restrict_push {
464- parts.push(g::t(lang, K::RuleRestrictPush).to_owned());472+ pills.push(pill(g::t(lang, K::RulePrOnly), plain));
473+ }
474+ if rule.require_up_to_date {
475+ pills.push(pill(g::t(lang, K::RuleUpToDateShort), plain));
465 }476 }
466 if rule.require_merge_queue {477 if rule.require_merge_queue {
467- parts.push(mq::t(lang, mq::K::RuleMergeQueue).to_owned());478+ pills.push(pill(mq::t(lang, mq::K::RuleMergeQueue), plain));
468 }479 }
469- if !rule.required_checks.is_empty() {480+ if rule.block_on_changes_requested {
470- parts.push(g::checks_count(lang, rule.required_checks.len()));481+ pills.push(pill(g::t(lang, K::RuleChangesShort), plain));
471 }482 }
472- if parts.is_empty() {483+ for check in &rule.required_checks {
473- g::t(lang, K::NoRule).to_owned()484+ pills.push(pill(&format!("\u{2713} {check}"), "rule-pill check"));
474- } else {
475- parts.join("; ")
476 }485 }
486+ if pills.is_empty() {
487+ pills.push(pill(g::t(lang, K::RuleNoExtra), "rule-pill muted"));
488+ }
489+ pills
490+}
491+
492+fn pill(text: &str, class: &'static str) -> RulePill {
493+ RulePill {
494+ text: text.to_owned(),
495+ class,
496+ }
497+}
498+
499+/// A rule as the settings page shows it: its id, its summary pills, and the form it opens with.
500+struct RuleCard {
501+ id: String,
502+ pills: Vec<RulePill>,
503+ open: bool,
504+ draft: RuleDraft,
505+}
506+
507+/// One switch row: a title with an optional muted line under it, and a toggle on the right.
508+#[component]
509+async fn switch_row(
510+ name: String,
511+ checked: bool,
512+ title: String,
513+ description: Option<String>,
514+) -> Result<impl View> {
515+ Ok(view! {
516+ <label class="switch-row">
517+ <span class="switch-text">
518+ <span class="switch-title">(title.as_str())</span>
519+ if let Some(text) = description {
520+ <span class="switch-desc">(text.as_str())</span>
521+ }
522+ </span>
523+ <input type="checkbox" name=(name.as_str()) value="on" checked=(checked)>
524+ </label>
525+ })
477 }526 }
478 527
479-/// The rules table. A muted built-in row stands in for the default branch when no rule matches it.528+/// The rule cards, then a muted row for the default branch when no rule covers it, then the New
529+/// rule card. A card opens with its rule's values. The card whose draft has an error opens with
530+/// the draft instead, and the New rule card opens with the draft when no card takes it.
480 #[component]531 #[component]
481-async fn branch_rules_table(532+async fn branch_rule_cards(
482 lang: Lang,533 lang: Lang,
483- rules: Vec<BranchRule>,534+ cards: Vec<RuleCard>,
484- default_branch: String,
485 builtin_row: bool,535 builtin_row: bool,
486- delete_action: String,536+ default_branch: String,
537+ new_draft: RuleDraft,
538+ new_open: bool,
487 csrf: String,539 csrf: String,
540+ save_action: String,
541+ delete_action: String,
542+ contexts: Vec<String>,
488 ) -> Result<impl View> {543 ) -> Result<impl View> {
489 Ok(view! {544 Ok(view! {
490- <div class="table-wrap">545+ <div class="rule-list">
491- <table class="table branch-rules">546+ for card in cards.iter() {
492- <thead>547+ <div class="rule-card">
493- <tr>548+ <div class="rule-card-head">
494- <th>(g::t(lang, K::PatternColumn))</th>549+ <details class="rule-details" open=(card.open)>
495- <th>(g::t(lang, K::ForcePushAllowed))</th>550+ <summary>
496- <th>(g::t(lang, K::DeletionAllowed))</th>551+ <span class="rule-summary-main">
497- <th>(g::t(lang, K::MergePushRules))</th>552+ <code class="rule-pattern">(card.draft.pattern.as_str())</code>
498- <th><span class="sr-only">(g::t(lang, K::Remove))</span></th>553+ <span class="rule-pills">
499- </tr>554+ for pill in card.pills.iter() {
500- </thead>555+ <span class=(pill.class)>(pill.text.as_str())</span>
501- <tbody>556+ }
502- for rule in rules.iter() {557+ </span>
503- <tr>558+ </span>
504- <td><code>(rule.pattern.as_str())</code></td>559+ <span class="rule-chevron" aria-hidden="true"></span>
505- <td>(g::yes_no(lang, rule.allow_force_push))</td>560+ </summary>
506- <td>(g::yes_no(lang, rule.allow_deletion))</td>561+ branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(),
507- <td>(rule_summary(lang, rule))</td>562+ draft: card.draft.clone(), contexts: contexts.clone())
508- <td>563+ </details>
509- <form method="post" action=(delete_action.as_str()) class="remove-form">564+ <form method="post" action=(delete_action.as_str()) class="remove-form">
510- <input type="hidden" name="csrf" value=(csrf.as_str())>565+ <input type="hidden" name="csrf" value=(csrf.as_str())>
511- <input type="hidden" name="rule_id" value=(rule.id.as_str())>566+ <input type="hidden" name="rule_id" value=(card.id.as_str())>
512- <button type="submit">(g::t(lang, K::Remove))</button>567+ <button type="submit">(g::t(lang, K::Remove))</button>
513- </form>568+ </form>
514- </td>569+ </div>
515- </tr>570+ </div>
516- }571+ }
517- if builtin_row {572+ if builtin_row {
518- <tr class="muted">573+ <div class="rule-card rule-builtin">
519- <td colspan="5"><code>(default_branch.as_str())</code>(g::t(lang, K::BuiltinRowText))</td>574+ <code class="rule-pattern">(default_branch.as_str())</code>
520- </tr>575+ <span class="muted small">(g::t(lang, K::BuiltinRowText))</span>
521- }576+ </div>
522- </tbody>577+ }
523- </table>
524 </div>578 </div>
579+ <details class="rule-card rule-new" open=(new_open)>
580+ <summary>"+ "(g::t(lang, K::NewRule))</summary>
581+ branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(),
582+ draft: new_draft, contexts: contexts.clone())
583+ </details>
525 })584 })
526 }585 }
527 586
528-/// The add/update form. Saving an existing pattern updates its rule.587+/// The rule form, in four sections. Saving an existing pattern updates its rule.
529 #[component]588 #[component]
530 async fn branch_rule_form(589 async fn branch_rule_form(
531 lang: Lang,590 lang: Lang,
532 csrf: String,591 csrf: String,
533 save_action: String,592 save_action: String,
534- pattern: String,593+ draft: RuleDraft,
535- allow_force_push: bool,
536- allow_deletion: bool,
537- required_approvals: String,
538- block_on_changes_requested: bool,
539- require_up_to_date: bool,
540- restrict_push: bool,
541- require_merge_queue: bool,
542- required_checks: String,
543 contexts: Vec<String>,594 contexts: Vec<String>,
544- error: Option<String>,
545 ) -> Result<impl View> {595 ) -> Result<impl View> {
596+ let RuleDraft {
597+ pattern,
598+ allow_force_push,
599+ allow_deletion,
600+ required_approvals,
601+ block_on_changes_requested,
602+ require_up_to_date,
603+ restrict_push,
604+ require_merge_queue,
605+ required_checks,
606+ error,
607+ } = draft;
546 Ok(view! {608 Ok(view! {
547- <form method="post" action=(save_action.as_str()) class="stack branch-form">609+ <form method="post" action=(save_action.as_str()) class="rule-form">
548 if let Some(message) = error {610 if let Some(message) = error {
549 alert(message: message.as_str())611 alert(message: message.as_str())
550 }612 }
551 <input type="hidden" name="csrf" value=(csrf.as_str())>613 <input type="hidden" name="csrf" value=(csrf.as_str())>
552- <div class="rule-group">614+ <fieldset class="rule-section">
615+ <legend>(g::t(lang, K::SectionPattern))</legend>
553 <label>616 <label>
554 <span>(g::t(lang, K::BranchPattern))</span>617 <span>(g::t(lang, K::BranchPattern))</span>
555 <input type="text" name="pattern" value=(pattern.as_str()) autocomplete="off" spellcheck="false" required=(true)>618 <input type="text" name="pattern" value=(pattern.as_str()) autocomplete="off" spellcheck="false" required=(true)>
556 </label>619 </label>
557 <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>620 <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>
558- </div>621+ </fieldset>
559- <div class="rule-group">622+ <fieldset class="rule-section">
560- <label class="inline">623+ <legend>(g::t(lang, K::SectionPushes))</legend>
561- <input type="checkbox" name="allow_force_push" value="on" checked=(allow_force_push)>624+ <div class="switch-list">
562- <span>(g::t(lang, K::AllowForcePush))</span>625+ switch_row(name: "allow_force_push".to_owned(), checked: allow_force_push,
563- </label>626+ title: g::t(lang, K::AllowForcePush).to_owned(),
564- <label class="inline">627+ description: Some(g::t(lang, K::ForcePushDesc).to_owned()))
565- <input type="checkbox" name="allow_deletion" value="on" checked=(allow_deletion)>628+ switch_row(name: "allow_deletion".to_owned(), checked: allow_deletion,
566- <span>(g::t(lang, K::AllowDeletion))</span>629+ title: g::t(lang, K::AllowDeletion).to_owned(),
567- </label>630+ description: Some(g::t(lang, K::DeletionDesc).to_owned()))
568- </div>631+ switch_row(name: "restrict_push".to_owned(), checked: restrict_push,
569- <div class="rule-group">632+ title: g::t(lang, K::RestrictPushTitle).to_owned(),
570- <label>633+ description: Some(g::t(lang, K::RestrictPushDesc).to_owned()))
571- <span>(g::t(lang, K::RequiredApprovals))</span>634+ </div>
572- <input type="number" name="required_approvals" min="0" max="20" step="1" inputmode="numeric" value=(required_approvals.as_str())>635+ </fieldset>
573- </label>636+ <fieldset class="rule-section">
574- <p class="muted small">(g::t(lang, K::ApprovalsHelp))</p>637+ <legend>(g::t(lang, K::SectionMerging))</legend>
575- <label class="inline">638+ <div class="switch-list">
576- <input type="checkbox" name="block_on_changes_requested" value="on" checked=(block_on_changes_requested)>639+ <label class="switch-row">
577- <span>(g::t(lang, K::BlockWhileChanges))</span>640+ <span class="switch-text">
578- </label>641+ <span class="switch-title">(g::t(lang, K::RequiredApprovals))</span>
579- <label class="inline">642+ <span class="switch-desc">(g::t(lang, K::ApprovalsHelp))</span>
580- <input type="checkbox" name="require_up_to_date" value="on" checked=(require_up_to_date)>643+ </span>
581- <span>(g::t(lang, K::RequireUpToDate))</span>644+ <input type="number" name="required_approvals" min="0" max="20" step="1" inputmode="numeric" value=(required_approvals.as_str())>
582- </label>645+ </label>
583- <label class="inline">646+ switch_row(name: "block_on_changes_requested".to_owned(), checked: block_on_changes_requested,
584- <input type="checkbox" name="restrict_push" value="on" checked=(restrict_push)>647+ title: g::t(lang, K::BlockWhileChanges).to_owned(), description: None)
585- <span>(g::t(lang, K::RestrictPush))</span>648+ switch_row(name: "require_up_to_date".to_owned(), checked: require_up_to_date,
586- </label>649+ title: g::t(lang, K::RequireUpToDate).to_owned(), description: None)
587- <label class="inline">650+ switch_row(name: "require_merge_queue".to_owned(), checked: require_merge_queue,
588- <input type="checkbox" name="require_merge_queue" value="on" checked=(require_merge_queue)>651+ title: mq::t(lang, mq::K::RequireMergeQueue).to_owned(),
589- <span>(mq::t(lang, mq::K::RequireMergeQueue))</span>652+ description: Some(mq::t(lang, mq::K::RequireMergeQueueHint).to_owned()))
590- </label>653+ </div>
591- <p class="muted small check-help">(mq::t(lang, mq::K::RequireMergeQueueHint))</p>654+ </fieldset>
592- </div>655+ <fieldset class="rule-section">
593- <div class="rule-group">656+ <legend>(g::t(lang, K::SectionChecks))</legend>
594 <label>657 <label>
595 <span>(g::t(lang, K::RequiredChecks))</span>658 <span>(g::t(lang, K::RequiredChecks))</span>
596 <input type="text" name="required_checks" value=(required_checks.as_str()) autocomplete="off" spellcheck="false" placeholder="ci/test, ci/lint">659 <input type="text" name="required_checks" value=(required_checks.as_str()) autocomplete="off" spellcheck="false" placeholder="ci/test, ci/lint">
@@ -604,7 +667,7 @@ async fn branch_rule_form(
604 }667 }
605 </div>668 </div>
606 }669 }
607- </div>670+ </fieldset>
608 <div class="form-actions">671 <div class="form-actions">
609 <button type="submit">(g::t(lang, K::SaveRule))</button>672 <button type="submit">(g::t(lang, K::SaveRule))</button>
610 </div>673 </div>
@@ -613,6 +676,7 @@ async fn branch_rule_form(
613 }676 }
614 677
615 /// The form values to show: the pattern and checkboxes, plus any validation error.678 /// The form values to show: the pattern and checkboxes, plus any validation error.
679+#[derive(Clone)]
616 struct RuleDraft {680 struct RuleDraft {
617 pattern: String,681 pattern: String,
618 allow_force_push: bool,682 allow_force_push: bool,
@@ -627,6 +691,22 @@ struct RuleDraft {
627 }691 }
628 692
629 impl RuleDraft {693 impl RuleDraft {
694+ /// The values a saved rule opens with.
695+ fn from_rule(rule: &BranchRule) -> Self {
696+ Self {
697+ pattern: rule.pattern.clone(),
698+ allow_force_push: rule.allow_force_push,
699+ allow_deletion: rule.allow_deletion,
700+ required_approvals: rule.required_approvals.to_string(),
701+ block_on_changes_requested: rule.block_on_changes_requested,
702+ require_up_to_date: rule.require_up_to_date,
703+ restrict_push: rule.restrict_push,
704+ require_merge_queue: rule.require_merge_queue,
705+ required_checks: rule.required_checks.join(", "),
706+ error: None,
707+ }
708+ }
709+
630 /// The default values for the add form, with the default branch as the pattern.710 /// The default values for the add form, with the default branch as the pattern.
631 fn for_default_branch(default_branch: &str) -> Self {711 fn for_default_branch(default_branch: &str) -> Self {
632 Self {712 Self {
@@ -682,6 +762,27 @@ async fn settings_body(
682 delete_error,762 delete_error,
683 contexts,763 contexts,
684 } = page;764 } = page;
765+ // A card takes the draft when the draft has an error and the pattern is its rule's pattern.
766+ // Every other card opens with its saved values. A draft no card takes goes to the New rule card.
767+ let mut draft = Some(draft);
768+ let mut cards = Vec::with_capacity(rules.len());
769+ for rule in rules {
770+ let card_draft = match draft.take() {
771+ Some(d) if d.error.is_some() && d.pattern == rule.pattern => d,
772+ other => {
773+ draft = other;
774+ RuleDraft::from_rule(&rule)
775+ }
776+ };
777+ cards.push(RuleCard {
778+ id: rule.id.clone(),
779+ pills: rule_pills(lang, &rule),
780+ open: card_draft.error.is_some(),
781+ draft: card_draft,
782+ });
783+ }
784+ let new_draft = draft.unwrap_or_else(|| RuleDraft::for_default_branch(&default_branch));
785+ let new_open = cards.is_empty() || new_draft.error.is_some();
685 let (description, visibility) = (head.description.clone(), head.visibility);786 let (description, visibility) = (head.description.clone(), head.visibility);
686 let discussions_on = head.discussions;787 let discussions_on = head.discussions;
687 let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error));788 let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error));
@@ -701,17 +802,9 @@ async fn settings_body(
701 <section class="card">802 <section class="card">
702 <h2>(g::t(lang, K::BranchProtection))</h2>803 <h2>(g::t(lang, K::BranchProtection))</h2>
703 <p class="muted small">(g::t(lang, K::BranchProtectionHelp))</p>804 <p class="muted small">(g::t(lang, K::BranchProtectionHelp))</p>
704- branch_rules_table(lang: lang, rules: rules, default_branch: default_branch.clone(),805+ branch_rule_cards(lang: lang, cards: cards, builtin_row: builtin_row, default_branch: default_branch.clone(),
705- builtin_row: builtin_row, delete_action: delete_action, csrf: csrf.clone())806+ new_draft: new_draft, new_open: new_open, csrf: csrf.clone(), save_action: rules_action,
706- <h3>(g::t(lang, K::AddOrUpdateRule))</h3>807+ delete_action: delete_action, contexts: contexts)
707- branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: rules_action, pattern: draft.pattern,
708- allow_force_push: draft.allow_force_push, allow_deletion: draft.allow_deletion,
709- required_approvals: draft.required_approvals,
710- block_on_changes_requested: draft.block_on_changes_requested,
711- require_up_to_date: draft.require_up_to_date, restrict_push: draft.restrict_push,
712- require_merge_queue: draft.require_merge_queue,
713- required_checks: draft.required_checks, contexts: contexts,
714- error: draft.error)
715 </section>808 </section>
716 discussions_card(lang: lang, action: format!("/{title}/settings/discussions"), csrf: csrf.clone(), enabled: discussions_on)809 discussions_card(lang: lang, action: format!("/{title}/settings/discussions"), csrf: csrf.clone(), enabled: discussions_on)
717 if can_delete {810 if can_delete {
crates/forge-web/tests/e2e/repo_settings_e2e.rsmodified+19 -34
@@ -365,26 +365,29 @@ async fn repo_settings_deletes_rows_when_repo_dir_is_missing() {
365 );365 );
366 }366 }
367 367
368-/// Rows of the branch rules table as their cell texts, in page order. The built-in default-branch368+/// The rule cards of the branch rules list in page order, each as its pattern followed by the texts
369-/// row is a single cell with a `colspan`, so it appears as a one-cell row.369+/// of its summary pills. The built-in default-branch card has no rule behind it, so it is skipped.
370 fn branch_rows(body: &str) -> Vec<Vec<String>> {370 fn branch_rows(body: &str) -> Vec<Vec<String>> {
371 let doc = scraper::Html::parse_document(body);371 let doc = scraper::Html::parse_document(body);
372- let rows = scraper::Selector::parse("table.branch-rules tbody tr").expect("selector");372+ let cards = scraper::Selector::parse("div.rule-card:not(.rule-builtin)").expect("selector");
373- let cells = scraper::Selector::parse("td").expect("selector");373+ let pattern = scraper::Selector::parse("summary code.rule-pattern").expect("selector");
374- doc.select(&rows)374+ let pills = scraper::Selector::parse("summary .rule-pill").expect("selector");
375- .map(|row| {375+ let text = |el: scraper::ElementRef| el.text().collect::<String>().trim().to_owned();
376- row.select(&cells)376+ doc.select(&cards)
377- .map(|cell| cell.text().collect::<String>().trim().to_owned())377+ .map(|card| {
378- .collect()378+ let mut cells: Vec<String> =
379+ card.select(&pattern).next().map(text).into_iter().collect();
380+ cells.extend(card.select(&pills).map(text));
381+ cells
379 })382 })
380 .collect()383 .collect()
381 }384 }
382 385
383-/// The cells of the rule row for `pattern`, if the table has one.386+/// The card for `pattern` as its cells (see `branch_rows`), if the list has one.
384 fn rule_row(body: &str, pattern: &str) -> Option<Vec<String>> {387 fn rule_row(body: &str, pattern: &str) -> Option<Vec<String>> {
385 branch_rows(body)388 branch_rows(body)
386 .into_iter()389 .into_iter()
387- .find(|cells| cells.first().is_some_and(|c| c == pattern) && cells.len() == 5)390+ .find(|cells| cells.first().is_some_and(|c| c == pattern))
388 }391 }
389 392
390 /// Owner adds, updates, invalidates and removes branch rules. A Write collaborator and an Admin393 /// Owner adds, updates, invalidates and removes branch rules. A Write collaborator and an Admin
@@ -485,14 +488,8 @@ async fn branch_protection_end_to_end() {
485 );488 );
486 assert_eq!(489 assert_eq!(
487 rule_row(&page.body, "main"),490 rule_row(&page.body, "main"),
488- Some(vec![491+ Some(vec!["main".into(), "Force push allowed".into()]),
489- "main".into(),492+ "main card after add"
490- "yes".into(),
491- "no".into(),
492- "none".into(),
493- "Remove".into()
494- ]),
495- "main row after add"
496 );493 );
497 assert!(494 assert!(
498 !page.body.contains("(default branch): protected by default"),495 !page.body.contains("(default branch): protected by default"),
@@ -511,14 +508,8 @@ async fn branch_protection_end_to_end() {
511 let page = http.get("/bob/app/settings", Some(&bob)).await;508 let page = http.get("/bob/app/settings", Some(&bob)).await;
512 assert_eq!(509 assert_eq!(
513 rule_row(&page.body, "main"),510 rule_row(&page.body, "main"),
514- Some(vec![511+ Some(vec!["main".into(), "No extra rules".into()]),
515- "main".into(),512+ "main card after update"
516- "no".into(),
517- "no".into(),
518- "none".into(),
519- "Remove".into()
520- ]),
521- "main row after update"
522 );513 );
523 assert_eq!(514 assert_eq!(
524 branch_rows(&page.body).len(),515 branch_rows(&page.body).len(),
@@ -648,13 +639,7 @@ async fn branch_protection_end_to_end() {
648 let page = http.get("/bob/app/settings", Some(&carol)).await;639 let page = http.get("/bob/app/settings", Some(&carol)).await;
649 assert_eq!(640 assert_eq!(
650 rule_row(&page.body, "release/*"),641 rule_row(&page.body, "release/*"),
651- Some(vec![642+ Some(vec!["release/*".into(), "Force push allowed".into()]),
652- "release/*".into(),
653- "yes".into(),
654- "no".into(),
655- "none".into(),
656- "Remove".into()
657- ]),
658 "admin collaborator's rule"643 "admin collaborator's rule"
659 );644 );
660 let carol_delete_rule = http645 let carol_delete_rule = http
style/main.scssmodified+307 -33
@@ -2704,66 +2704,340 @@ code {
2704 }2704 }
2705 2705
2706 // branch protection2706 // branch protection
2707-// Settings page: rules table with a Remove form per row, then the add/update form.2707+// Settings page: one card per rule (a summary with its pills and the form when open), a muted row
2708-.branch-rules {2708+// for the default branch when no rule covers it, and a dashed New rule card at the end.
2709- // Data columns size to their content; the rule summary takes the slack and the action sits at the end.2709+.rule-list {
2710- th:nth-child(4),2710+ display: flex;
2711- td:nth-child(4) {2711+ flex-direction: column;
2712- width: 100%;2712+ gap: 10px;
2713+ margin-bottom: 10px;
2714+}
2715+
2716+.rule-card {
2717+ border: 1px solid var(--border);
2718+ border-radius: var(--radius-lg);
2719+ background: var(--surface);
2720+}
2721+
2722+// The rule card's bordered box holds the summary and the form, with Remove beside the summary row.
2723+.rule-card-head {
2724+ display: flex;
2725+ align-items: flex-start;
2726+
2727+ > .rule-details {
2728+ flex: 1 1 auto;
2729+ min-width: 0;
2713 }2730 }
2714 2731
2715- th:last-child,2732+ > .remove-form {
2716- td:last-child {2733+ flex: none;
2717- text-align: right;2734+ margin: 10px 12px 0 0;
2718- white-space: nowrap;
2719 }2735 }
2736+}
2720 2737
2721- .remove-form {2738+.rule-details {
2722- margin: 0;2739+ > summary {
2723 display: flex;2740 display: flex;
2724- justify-content: flex-end;2741+ align-items: center;
2742+ gap: 12px;
2743+ padding: 12px 16px;
2744+ cursor: pointer;
2745+ list-style: none;
2746+ border-radius: var(--radius-lg);
2725 2747
2726- button {2748+ &::-webkit-details-marker {
2727- width: auto;2749+ display: none;
2750+ }
2751+
2752+ &:hover {
2753+ background: var(--surface-2);
2728 }2754 }
2729 }2755 }
2730 2756
2731- tr.muted td {2757+ &[open] > summary {
2758+ border-bottom: 1px solid var(--border);
2759+ }
2760+
2761+ // The summary's chevron points down when closed and up when open.
2762+ > summary .rule-chevron {
2763+ flex: none;
2764+ width: 7px;
2765+ height: 7px;
2766+ margin: 0 4px 0 8px;
2767+ border-right: 2px solid var(--muted);
2768+ border-bottom: 2px solid var(--muted);
2769+ transform: rotate(45deg);
2770+ transition: transform 0.15s ease;
2771+ }
2772+
2773+ &[open] > summary .rule-chevron {
2774+ transform: rotate(-135deg);
2775+ }
2776+}
2777+
2778+.rule-summary-main {
2779+ display: flex;
2780+ flex: 1 1 auto;
2781+ flex-direction: column;
2782+ align-items: flex-start;
2783+ gap: 6px;
2784+ min-width: 0;
2785+}
2786+
2787+.rule-pattern {
2788+ padding: 0;
2789+ background: none;
2790+ font-family: var(--mono);
2791+ font-size: 15px;
2792+ font-weight: 600;
2793+ color: var(--text);
2794+ overflow-wrap: anywhere;
2795+}
2796+
2797+.rule-pills {
2798+ display: flex;
2799+ flex-wrap: wrap;
2800+ gap: 6px;
2801+}
2802+
2803+.rule-pill {
2804+ display: inline-flex;
2805+ align-items: center;
2806+ padding: 1px 8px;
2807+ border: 1px solid var(--border);
2808+ border-radius: var(--radius-full);
2809+ background: var(--surface-2);
2810+ color: var(--text-2);
2811+ font-size: 12px;
2812+ line-height: 18px;
2813+ white-space: nowrap;
2814+
2815+ &.warn {
2816+ border-color: var(--warn);
2817+ background: color-mix(in srgb, var(--warn) 14%, transparent);
2818+ color: var(--warn);
2819+ }
2820+
2821+ &.check {
2822+ font-family: var(--mono);
2823+ }
2824+
2825+ &.muted {
2826+ border-style: dashed;
2827+ background: none;
2732 color: var(--muted);2828 color: var(--muted);
2733 }2829 }
2734 }2830 }
2735 2831
2736-// Rule form: fields share one width, the approvals count is narrow, and each group of related2832+// The built-in default-branch row: muted, dashed, not a card to open.
2737-// fields sits apart from the next. Help text stays under its field.2833+.rule-builtin {
2738-.branch-form {2834+ display: flex;
2739- max-width: 40rem;2835+ flex-direction: column;
2740- gap: 24px;2836+ align-items: flex-start;
2837+ gap: 6px;
2838+ padding: 12px 16px;
2839+ border-style: dashed;
2840+ border-color: var(--border-strong);
2841+ background: none;
2842+ color: var(--muted);
2843+
2844+ .rule-pattern {
2845+ color: var(--muted);
2846+ }
2847+}
2848+
2849+// New rule: a dashed row that becomes a card once open.
2850+.rule-new {
2851+ border: 0;
2852+ background: none;
2853+
2854+ > summary {
2855+ display: block;
2856+ padding: 12px 16px;
2857+ border: 1px dashed var(--border-strong);
2858+ border-radius: var(--radius-lg);
2859+ color: var(--muted);
2860+ font-weight: 600;
2861+ text-align: center;
2862+ cursor: pointer;
2863+ list-style: none;
2864+
2865+ &::-webkit-details-marker {
2866+ display: none;
2867+ }
2868+
2869+ &:hover {
2870+ border-color: var(--accent);
2871+ color: var(--accent);
2872+ }
2873+ }
2874+
2875+ &[open] {
2876+ border: 1px solid var(--border);
2877+ border-radius: var(--radius-lg);
2878+ background: var(--surface);
2879+ }
2880+
2881+ &[open] > summary {
2882+ border-style: none;
2883+ border-bottom: 1px solid var(--border);
2884+ border-radius: var(--radius-lg) var(--radius-lg) 0 0;
2885+ color: var(--text);
2886+ }
2887+}
2888+
2889+// The rule form: four sections, each with a small uppercase legend.
2890+.rule-form {
2891+ display: flex;
2892+ flex-direction: column;
2893+ gap: 20px;
2894+ min-width: 0;
2895+ padding: 16px;
2741 2896
2742 input[type="text"] {2897 input[type="text"] {
2743 max-width: 28rem;2898 max-width: 28rem;
2744 }2899 }
2745 2900
2746- input[type="number"] {2901+ .form-actions {
2747- width: 8rem;2902+ justify-content: flex-end;
2748- max-width: 8rem;2903+ }
2904+}
2905+
2906+.rule-section {
2907+ display: flex;
2908+ flex-direction: column;
2909+ gap: 8px;
2910+ min-width: 0;
2911+ margin: 0;
2912+ padding: 0;
2913+ border: 0;
2914+
2915+ > legend {
2916+ padding: 0;
2917+ margin-bottom: 2px;
2918+ color: var(--muted);
2919+ font-size: 0.6875rem;
2920+ font-weight: 600;
2921+ letter-spacing: 0.06em;
2922+ text-transform: uppercase;
2923+ }
2924+
2925+ > p.muted.small {
2926+ margin: 0;
2927+ max-width: 28rem;
2928+ }
2929+
2930+ > label {
2931+ max-width: 28rem;
2932+ }
2933+
2934+ > .context-picker {
2935+ margin-top: 2px;
2936+ }
2937+}
2938+
2939+.switch-list {
2940+ display: flex;
2941+ flex-direction: column;
2942+ padding: 0 14px;
2943+ border: 1px solid var(--border);
2944+ border-radius: var(--radius-md);
2945+}
2946+
2947+// A row is a label: text on the left, the toggle or a number input on the right. Rows are split by
2948+// a 1px divider.
2949+.switch-row {
2950+ display: flex;
2951+ align-items: center;
2952+ justify-content: space-between;
2953+ gap: 16px;
2954+ padding: 12px 0;
2955+ border-top: 1px solid var(--border);
2956+ cursor: pointer;
2957+
2958+ &:first-child {
2959+ border-top: 0;
2749 }2960 }
2750 2961
2751- .rule-group {2962+ > .switch-text {
2752 display: flex;2963 display: flex;
2753 flex-direction: column;2964 flex-direction: column;
2754- gap: 8px;2965+ gap: 2px;
2966+ min-width: 0;
2967+ }
2755 2968
2756- > p.muted.small {2969+ .switch-title {
2757- max-width: 28rem;2970+ color: var(--text);
2758- margin: -4px 0 0;2971+ font-size: 14px;
2972+ font-weight: 500;
2973+ line-height: 20px;
2974+ }
2975+
2976+ .switch-desc {
2977+ color: var(--muted);
2978+ font-size: 12px;
2979+ line-height: 1.4;
2980+ }
2981+
2982+ input[type="checkbox"] {
2983+ appearance: none;
2984+ -webkit-appearance: none;
2985+ position: relative;
2986+ flex: none;
2987+ width: 34px;
2988+ height: 20px;
2989+ margin: 0;
2990+ padding: 0;
2991+ border-radius: var(--radius-full);
2992+ background: var(--border-strong);
2993+ cursor: pointer;
2994+ transition: background 0.15s ease;
2995+
2996+ &::after {
2997+ content: "";
2998+ position: absolute;
2999+ top: 2px;
3000+ left: 2px;
3001+ width: 16px;
3002+ height: 16px;
3003+ border-radius: 50%;
3004+ background: var(--surface);
3005+ transition: transform 0.15s ease;
2759 }3006 }
2760 3007
2761- // Help for a checkbox lines up with its label text, past the box.3008+ &:checked {
2762- > p.check-help {3009+ background: var(--accent);
2763- margin-left: 24px;3010+ }
2764- max-width: 28rem;3011+
3012+ &:checked::after {
3013+ transform: translateX(14px);
3014+ }
3015+
3016+ &:focus-visible {
3017+ outline: 2px solid var(--focus);
3018+ outline-offset: 2px;
2765 }3019 }
2766 }3020 }
3021+
3022+ input[type="number"] {
3023+ flex: none;
3024+ width: 72px;
3025+ max-width: 72px;
3026+ }
3027+}
3028+
3029+@media (max-width: 600px) {
3030+ .rule-details > summary {
3031+ padding: 10px 12px;
3032+ }
3033+
3034+ .rule-form {
3035+ padding: 12px;
3036+ }
3037+
3038+ .rule-card-head > .remove-form {
3039+ margin-right: 8px;
3040+ }
2767 }3041 }
2768 3042
2769 // labels & milestones3043 // labels & milestones