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