Allow resetting merge request approval rules to project defaults
Follow-up to #199795 (closed), which adds indicators next to approval rules that have been overridden or to approval rules that are new (created specifically for that MR).
Problem
If a user has overridden or created an approval rule in the merge request, and they want to abide by the organization's policies, it's a manual process that can be very difficult. They must manually consult the project settings (if they have the right permissions) and compare the project approval rules with the rules in the merge request. Then, after examination, they must manually remove the overridden or new rules.
Proposal
To facilitate this we can allow them to reset merge request approval rules to project defaults:
That Reset to project defaults
button does the following:
- Removes any rules that were manually added to that MR.
- Reapplies the project-defined rules, effectively reverting any changes that were made to them (or re-adding them if they were deleted in that MR).
- Displays a Toast with an
Undo
button. - All of these actions are performed without any page reload.
The new “state” of the approvals rules for that MR should only be saved when the user presses the Save changes button.
Testing
- Unit/integration tests should provide sufficient coverage, given that the proposal makes it more convenient to update rules, rather than changing how rules function.
- It might be worthwhile including at least one new feature spec to confirm that approval rules are applied as expected after they're reset.