Implement the ability to add branch Protections
### Description As part of the [MVC](https://gitlab.com/gitlab-org/gitlab/-/issues/351468) 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~~ * Handled by https://gitlab.com/gitlab-org/gitlab/-/issues/388128 * Implement the Access level dropdowns * Implement Push access checkbox * Implement 'realtime' saving (use existing endpoint) ### Implementation plan <details> <summary>Details</summary> | issue | note | | ------ | ------ | | https://gitlab.com/gitlab-org/gitlab/-/issues/362205+ | | | https://gitlab.com/gitlab-org/gitlab/-/issues/362212+ | :point_left: **this issue** | | https://gitlab.com/gitlab-org/gitlab/-/issues/362214+ | | | https://gitlab.com/gitlab-org/gitlab/-/issues/362219+ | | | https://gitlab.com/gitlab-org/gitlab/-/issues/362217+ | :warning: blocked by https://gitlab.com/gitlab-org/gitlab/-/issues/362219 | | https://gitlab.com/gitlab-org/gitlab/-/issues/362218+ | :warning: blocked by https://gitlab.com/gitlab-org/gitlab/-/issues/362219 | Update `editBranchRule` mutation to include these fields </details> ### Mockups <details> <summary>Details</summary> [Figma](https://www.figma.com/file/eq2nf3B8MhB9xKrC0VzbPf/Repository?type=design&node-id=916%3A5174&mode=design&t=zrP2cLygKOMQqcde-1) </details> #### 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. <details> <summary>Details</summary> | Default | Edit - default | Edit - filled | Allowed to merge updated | ------ | ------ | ------ | ------ | |![image](/uploads/7e4eff818126593d683238c8c0dbe115/image.png) | ![image](/uploads/c9ca41b0a9326f281bdcf2517fdc8b67/image.png) | ![image](/uploads/7249b9d254f4909837b45ba36f05c8e2/image.png) | ![image](/uploads/79c1a1267277fb9b5a386a6a2f205022/image.png) | </details> #### 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. <details> <summary>Details</summary> | Default | Edit - filled | Allowed to push and merge updated | | ------ | ------ | ------ | | ![image](/uploads/a8b5cd5e408d28ce812dd113ffef2760/image.png) | ![image](/uploads/14ebda453de8006c55af5a273c0f516d/image.png) | ![image](/uploads/cf66b5fff20dc33cfe00a6fd1c4ee627/image.png) | </details> #### 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 <details> <summary>Details</summary> | Allow force push enabled | Require code owners approval enabled | | ------ | ------ | | ![image](/uploads/aa642f32dc8f8f09d1af7b88241bbcb2/image.png) | ![image](/uploads/d498a68ea2bae78b0a8fbfa3b5b3d818/image.png) | </details> #### Everyone is required to submit a merge request for changes <details> <summary>Details</summary> 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](https://docs.gitlab.com/ee/user/project/protected_branches.html#require-everyone-to-submit-merge-requests-for-a-protected-branch). 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 https://gitlab.com/gitlab-org/gitlab/-/issues/384939+ and https://gitlab.com/gitlab-org/gitlab/-/issues/388102+ | Introducing toggle to require merge request | Toggled true | "Everyone is required to submit a merge request" | | ------ | ------ | ------ | | ![image](/uploads/dc48a30fa296d3ed3800bf16eb30b1d4/image.png) | ![image](/uploads/4c9b867b621eec17c03e83e5c7d3afdc/image.png) | ![image](/uploads/f2587c283d5302c0eefff32102f3b9d2/image.png) | </details>
epic