Skip to content

Edit Branch rule on a protection toggle change

What does this MR do and why?

  • trigger editBranchRuleMutation on the protection-toggle change
  • add helper functions for each branchProtection edit (onEnableForcePushToggle, onEnableCodeOwnersToggle, onEditAllowedToMerge) for granular control over the loading states and toast messages
  • add a utility function (getAccessLevelInputFromEdges) to prepare data for editBranchRuleMutation

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Previously, the toggles where not connected to the backend. Here's a demo of them working now:

Screen_Recording_2024-06-04_at_15.16.01

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Open Rails console. In your terminal: rails c
  2. Enable the feature flag:
Feature.enable(:edit_branch_rules)
  1. In a project, go to Settings / Repository
  2. Expand Branch rules section.
  3. Choose an existing rule or create one.
  4. Navigate to Branch rule details page.
  5. You should not see Allow force push, when Allowed to push and merge is empty.
  6. Change the value of Allowed to push and merge in Settings / Repository / Protected branches
  7. Visit branch rule page again, notice the section Allow force push rendered.
  8. Change the value of the toggle
  9. You can also update Allowed to merge section and see if the toggles persist their values.
  10. Note: there is a known bug about the empty MR approval rule being duplicated.

Related to #438970 (closed)

Edited by Paulina Sedlak-Jakubowska

Merge request reports