Commit c9b65766 authored by Miguel Rincon's avatar Miguel Rincon

Merge branch '247903-add-prevent-approval-to-group-level' into 'master'

Add prevent approval by committers to group-level MR approval settings

See merge request gitlab-org/gitlab!55355
parents bfa3d1fd 7c8b3cd2
......@@ -38,10 +38,14 @@ export default {
preventMrApprovalRuleEditDocsAnchor: 'editing--overriding-approval-rules-per-merge-request',
requireUserPasswordDocsAnchor: 'require-authentication-when-approving-a-merge-request',
removeApprovalsOnPushDocsAnchor: 'resetting-approvals-on-push',
preventCommittersApprovalAnchor: 'prevent-approval-of-merge-requests-by-their-committers',
},
i18n: {
authorApprovalLabel: __('Prevent MR approvals by the author.'),
preventMrApprovalRuleEditLabel: __('Prevent users from modifying MR approval rules.'),
preventCommittersApprovalLabel: __(
'Prevent approval of merge requests by merge request committers.',
),
requireUserPasswordLabel: __('Require user password for approvals.'),
removeApprovalsOnPushLabel: __(
'Remove all approvals in a merge request when new commits are pushed to its source branch.',
......@@ -78,6 +82,12 @@ export default {
:anchor="$options.links.removeApprovalsOnPushDocsAnchor"
data-testid="remove-approvals-on-push"
/>
<approval-settings-checkbox
v-model="settings.preventCommittersApproval"
:label="$options.i18n.preventCommittersApprovalLabel"
:anchor="$options.links.preventCommittersApprovalAnchor"
data-testid="prevent-committers-approval"
/>
</gl-form-group>
<gl-button type="submit" variant="success" category="primary" :disabled="isLoading">
{{ $options.i18n.saveChanges }}
......
......@@ -29,6 +29,7 @@ export const updateSettings = ({ commit, state }, endpoint) => {
allow_overrides_to_approver_list_per_merge_request: !state.settings.preventMrApprovalRuleEdit,
require_password_to_approve: state.settings.requireUserPassword,
retain_approvals_on_push: !state.settings.removeApprovalsOnPush,
allow_committer_approval: !state.settings.preventCommittersApproval,
};
commit(types.REQUEST_UPDATE_SETTINGS);
......
......@@ -9,6 +9,7 @@ export default {
state.settings.preventMrApprovalRuleEdit = !data.allow_overrides_to_approver_list_per_merge_request;
state.settings.requireUserPassword = data.require_password_to_approve;
state.settings.removeApprovalsOnPush = !data.retain_approvals_on_push;
state.settings.preventCommittersApproval = !data.allow_committer_approval;
state.isLoading = false;
},
[types.RECEIVE_SETTINGS_ERROR](state) {
......@@ -22,6 +23,7 @@ export default {
state.settings.preventMrApprovalRuleEdit = !data.allow_overrides_to_approver_list_per_merge_request;
state.settings.requireUserPassword = data.require_password_to_approve;
state.settings.removeApprovalsOnPush = !data.retain_approvals_on_push;
state.settings.preventCommittersApproval = !data.allow_committer_approval;
state.isLoading = false;
},
[types.UPDATE_SETTINGS_ERROR](state) {
......
......@@ -52,6 +52,7 @@ describe('ApprovalSettings', () => {
describe.each`
testid | setting | label | anchor
${'prevent-author-approval'} | ${'preventAuthorApproval'} | ${'Prevent MR approvals by the author.'} | ${'allowing-merge-request-authors-to-approve-their-own-merge-requests'}
${'prevent-committers-approval'} | ${'preventCommittersApproval'} | ${'Prevent approval of merge requests by merge request committers.'} | ${'prevent-approval-of-merge-requests-by-their-committers'}
${'prevent-mr-approval-rule-edit'} | ${'preventMrApprovalRuleEdit'} | ${'Prevent users from modifying MR approval rules.'} | ${'editing--overriding-approval-rules-per-merge-request'}
${'require-user-password'} | ${'requireUserPassword'} | ${'Require user password for approvals.'} | ${'require-authentication-when-approving-a-merge-request'}
${'remove-approvals-on-push'} | ${'removeApprovalsOnPush'} | ${'Remove all approvals in a merge request when new commits are pushed to its source branch.'} | ${'resetting-approvals-on-push'}
......
......@@ -74,6 +74,7 @@ describe('EE approvals group settings module actions', () => {
state = {
settings: {
preventAuthorApproval: false,
preventCommittersApproval: false,
preventMrApprovalRuleEdit: false,
requireUserPassword: false,
removeApprovalsOnPush: false,
......@@ -85,6 +86,7 @@ describe('EE approvals group settings module actions', () => {
it('dispatches the request and updates payload', () => {
const data = {
allow_author_approval: true,
allow_committer_approval: true,
allow_overrides_to_approver_list_per_merge_request: true,
require_password_to_approve: true,
retain_approvals_on_push: true,
......
......@@ -20,12 +20,14 @@ describe('Group settings store mutations', () => {
it('updates settings', () => {
mutations.RECEIVE_SETTINGS_SUCCESS(state, {
allow_author_approval: true,
allow_committer_approval: true,
allow_overrides_to_approver_list_per_merge_request: true,
require_password_to_approve: true,
retain_approvals_on_push: true,
});
expect(state.settings.preventAuthorApproval).toBe(false);
expect(state.settings.preventCommittersApproval).toBe(false);
expect(state.settings.preventMrApprovalRuleEdit).toBe(false);
expect(state.settings.requireUserPassword).toBe(true);
expect(state.settings.removeApprovalsOnPush).toBe(false);
......
......@@ -23525,6 +23525,9 @@ msgstr ""
msgid "Prevent adding new members to project membership within this group"
msgstr ""
msgid "Prevent approval of merge requests by merge request committers."
msgstr ""
msgid "Prevent environment from auto-stopping"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment