Draft: Offer the approval removal settings as radio options

What does this MR do and why?

Adds the rule-mode control for the remove_code_owner_approvals_with_new_commit approval setting introduced in !242393 (merged). That MR added YAML and backend support plus the indicator on the project merge request approval settings page, but rule mode had no way to set it. This MR targets 14088-add-codeowner-setting-in-policy (242393's branch), not master, so the diff only shows the editor changes. Retarget to master once 242393 merges.

  • remove_approvals_with_new_commit and remove_code_owner_approvals_with_new_commit are mutually exclusive, so rule mode now renders one When a commit is added: radio group (Keep approvals / Remove all approvals / Remove approvals by Code Owners if their files changed), matching the project settings page.
  • The group label is a legend for an accessible name. Each option keeps its own tooltip.
  • Selecting an option writes both keys so they can never both be enabled.
  • from_yaml.js rejects a policy with both keys enabled, mirroring the JSON schema constraint from the first MR.
  • The Code Owner option renders when approval_policy_selective_code_owner_removals is enabled, or when the policy being edited already has that key — so editing an existing policy with the flag off doesn't silently strip the setting.
  • Flag off and key absent: unchanged behavior, remove_approvals_with_new_commit stays a plain checkbox.

Changed: settings.js, settings_item.vue, settings_section.vue, editor_component.vue, from_yaml.js, both security/policies_controller.rb files (push the flag to the frontend), and four Jest specs.

Screenshots or screen recordings

Verified in the policy editor against a local GDK (flightjs/Flight, flag enabled) under Advanced > Merge request approval settings.

Recording (3x), hovering each option's tooltip then walking through all three choices, with the .yaml preview tracking each selection:

Before: remove all (the default) After: Code Owner option selected
1-default-remove-all 3-code-owners-selected

Editor showing a saved policy with the new option selected:

e2e-0-policy

  • The three options render as one radio group.
  • The .yaml preview tracks each selection.
  • With the flag off, the group is not rendered and the existing setting stays a checkbox.

No console errors beyond pre-existing Vue development warnings.

How to set up and validate locally

  1. Enable the approval_policy_selective_code_owner_removals feature flag.
  2. Open a merge request approval policy in the policy editor, rule mode, and expand Advanced > Merge request approval settings.
  3. The When a commit is added: group offers Keep approvals / Remove all approvals / Remove approvals by Code Owners if their files changed; the .yaml preview updates with each choice.
  4. Disable the flag and reload: the group is gone and remove_approvals_with_new_commit is a checkbox again.

References

Notes for reviewers

  • The three radio strings duplicate identical ApprovalSettings| strings from the project settings page. That's the established per-namespace i18n convention here, not an oversight.
  • Deliberately out of scope: hardening getEnabled in settings_item.vue against { enabled: false }. Follow-up.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Merge request reports

Loading
Loading