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