Commit a2ab3c5d authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch...

Merge branch '325989-add-prevent-users-from-modifying-mr-approval-rules-to-group-level' into 'master'

Add Prevent users from modifying MR approval rules to group level

See merge request gitlab-org/gitlab!57844
parents 8ef5a6d0 b7c5e9bc
......@@ -35,11 +35,13 @@ export default {
links: {
preventAuthorApprovalDocsAnchor:
'allowing-merge-request-authors-to-approve-their-own-merge-requests',
preventMrApprovalRuleEditDocsAnchor: 'editing--overriding-approval-rules-per-merge-request',
requireUserPasswordDocsAnchor: 'require-authentication-when-approving-a-merge-request',
removeApprovalsOnPushDocsAnchor: 'resetting-approvals-on-push',
},
i18n: {
authorApprovalLabel: __('Prevent MR approvals by the author.'),
preventMrApprovalRuleEditLabel: __('Prevent users from modifying MR approval rules.'),
requireUserPasswordLabel: __('Require user password for approvals.'),
removeApprovalsOnPushLabel: __(
'Remove all approvals in a merge request when new commits are pushed to its source branch.',
......@@ -58,6 +60,12 @@ export default {
:anchor="$options.links.preventAuthorApprovalDocsAnchor"
data-testid="prevent-author-approval"
/>
<approval-settings-checkbox
v-model="settings.preventMrApprovalRuleEdit"
:label="$options.i18n.preventMrApprovalRuleEditLabel"
:anchor="$options.links.preventMrApprovalRuleEditDocsAnchor"
data-testid="prevent-mr-approval-rule-edit"
/>
<approval-settings-checkbox
v-model="settings.requireUserPassword"
:label="$options.i18n.requireUserPasswordLabel"
......
......@@ -26,6 +26,7 @@ export const fetchSettings = ({ commit }, endpoint) => {
export const updateSettings = ({ commit, state }, endpoint) => {
const payload = {
allow_author_approval: !state.settings.preventAuthorApproval,
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,
};
......
......@@ -6,6 +6,7 @@ export default {
},
[types.RECEIVE_SETTINGS_SUCCESS](state, data) {
state.settings.preventAuthorApproval = !data.allow_author_approval;
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.isLoading = false;
......@@ -18,6 +19,7 @@ export default {
},
[types.UPDATE_SETTINGS_SUCCESS](state, data) {
state.settings.preventAuthorApproval = !data.allow_author_approval;
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.isLoading = false;
......
......@@ -50,10 +50,11 @@ 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'}
${'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'}
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-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'}
`('with $testid checkbox', ({ testid, setting, label, anchor }) => {
let checkbox = null;
......
......@@ -74,6 +74,7 @@ describe('EE approvals group settings module actions', () => {
state = {
settings: {
preventAuthorApproval: false,
preventMrApprovalRuleEdit: false,
requireUserPassword: false,
removeApprovalsOnPush: false,
},
......@@ -84,6 +85,7 @@ describe('EE approvals group settings module actions', () => {
it('dispatches the request and updates payload', () => {
const data = {
allow_author_approval: true,
allow_overrides_to_approver_list_per_merge_request: true,
require_password_to_approve: true,
retain_approvals_on_push: true,
};
......
......@@ -20,11 +20,13 @@ describe('Group settings store mutations', () => {
it('updates settings', () => {
mutations.RECEIVE_SETTINGS_SUCCESS(state, {
allow_author_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.preventMrApprovalRuleEdit).toBe(false);
expect(state.settings.requireUserPassword).toBe(true);
expect(state.settings.removeApprovalsOnPush).toBe(false);
expect(state.isLoading).toBe(false);
......@@ -51,11 +53,13 @@ describe('Group settings store mutations', () => {
it('updates settings', () => {
mutations.UPDATE_SETTINGS_SUCCESS(state, {
allow_author_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.preventMrApprovalRuleEdit).toBe(false);
expect(state.settings.requireUserPassword).toBe(true);
expect(state.settings.removeApprovalsOnPush).toBe(false);
expect(state.isLoading).toBe(false);
......
......@@ -23297,6 +23297,9 @@ msgstr ""
msgid "Prevent users from modifying MR approval rules in projects and merge requests."
msgstr ""
msgid "Prevent users from modifying MR approval rules."
msgstr ""
msgid "Prevent users from performing write operations on GitLab while performing maintenance."
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