Skip to content

Implement the ability to add branch Protections

Description

As part of the MVC for organizing rules based on branches, we need to implement the ability to add branch protections.

Scope

The scope of this issue includes:

  • Implement branch/wildcard dropdown
  • Implement the Access level dropdowns
  • Implement Push access checkbox
  • Implement 'realtime' saving (use existing endpoint)

Implementation plan

issue note
Branch rules MVC: Implement frontend skeleton (#362205 - closed)
Implement the ability to add branch Protections (#362212 - closed) 👈 this issue
Implement the ability to add Merge Request appr... (#362214 - closed)
Branch rules MVC: Add GraphQL endpoint to delet... (#362219 - closed)
Branch rules MVC: List branch rules under Repos... (#362217 - closed) blocked by #362219 (closed)
Implement the ability to Delete a Branch rule (#362218 - closed) blocked by #362219 (closed)

Update editBranchRule mutation to include these fields

Mockups

Figma

Allowed to merge

  • Allows editing of roles, users, and groups
  • Default:
    • Roles: Administrators, Maintainers
  • Empty state text: No one is allowed to merge changes.
  • On change, display toast "Allowed to merge updated"
    • Undo action would be nice to have.
Default Edit - default Edit - filled Allowed to merge updated
image image image image

Allowed to push and merge

  • Allows editing of roles, users, groups, and deploy keys
  • Default: (empty)
  • Empty state text: Everyone is required to submit a merge request for changes.
  • On change, display toast "Allowed to push and merge updated"
    • Undo action would be nice to have.
Default Edit - filled Allowed to push and merge updated
image image image

Toggles

  • Allow force push toggle is only displayed when there "allowed to push and merge" is populated
    • Default off
  • Requires code owner approval
    • Default off
  • Toast displayed when toggle changes
Allow force push enabled Require code owners approval enabled
image image

Everyone is required to submit a merge request for changes

It is not obvious that you need to set roles to "No one" in protected branches to enforce the fact that everyone is required to submit a merge request for changes. Here is our guidance in our docs. This is compounded by the fact that you could select a role as "No one" but still include users and groups - selecting the role of "No one" is redundant in this scenario.

To help with convey this scenario to make it clear for users who want to enforce merge requests for branches like these related issues Branch protection rule: Require a pull request ... (#384939 - closed) and Introduce a direct way to require merge request... (#388102)

Introducing toggle to require merge request Toggled true "Everyone is required to submit a merge request"
image image image
Edited by Joe Woodward