Add policy badge for block_branch_modification in branch rules UI
What does this MR do and why?
Extends the PolicyBadge and DisabledByPolicyPopover pattern to cover block_branch_modification in the branch rules UI. Previously, only prevent_pushing_and_force_pushing showed policy indicators (badge + lock/warning icon) in branch rules. The block_branch_modification setting only disabled the Delete Rule button. Now users see clear visual feedback across all affected settings sections when a security policy blocks branch modification.
This follows the exact same pattern established in !221912 (merged) for prevent_pushing_and_force_pushing.
Changes
-
EE list page query: Add
modificationBlockedByPolicyandwarnModificationBlockedByPolicyfields -
EE branch_rule.vue: Extend
showPolicyBadgeto include modification blocking; addisEnforcedByAnyPolicycomputed to aggregate multiple policy types for the badge variant -
CE index.vue (detail page): Pass
modificationBlockedByPolicy/warnModificationBlockedByPolicyto "Allowed to merge", "Allowed to push", and Force push sections -
CE branch_rule.vue: Add
isEnforcedByAnyPolicystub; update PolicyBadge/PopOver bindings - Tests: Comprehensive coverage for enforced mode, warn mode, and combined policies
No backend changes needed — all GraphQL fields already exist.
References
- Related to #575666 (closed)
- Follows pattern from !221912 (merged) (
prevent_pushing_and_force_pushingpolicy badge)
Screenshots or screen recordings
| Before | After |
|---|---|
No policy indicator for block_branch_modification on list or detail pages |
|
![]() |
How to set up and validate locally
- Go to Project > Secure > Policies > New approval policy
- Create a policy with
block_branch_modification: trueenabled:- First test in warn mode, then test in enforced mode
- Go to Settings > Repository > Branch Rules
- Verify the branch rules list page:
- A PolicyBadge should appear next to the branch name (e.g., "Enforced by policy" or "Policy warn mode")
- Click View details on a branch rule
- Verify the branch rule detail page:
- "Allowed to merge" section: Edit button should be disabled (enforced) with lock icon popover, or show warning icon (warn mode)
- "Allowed to push and merge" section: Same behavior
- Force push toggle: Should be disabled (enforced) with lock icon popover
- Delete rule button: Should already be disabled (existing behavior, unchanged)
- Verify that without any blocking policy, all sections behave normally (no badges, no popovers)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
