Commit beb1f438 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'bvl-port-ee-improvements-from-maintainer-push' into 'master'

Port changes from EE: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4885 (Maintainer push to fork)

See merge request gitlab-org/gitlab-ce!17629
parents 1558bd12 12e68d62
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
}, },
}; };
</script> </script>
<template> <template>
<section class="mr-info-list mr-maintainer-edit"> <section class="mr-info-list mr-links">
<p v-if="maintainerEditAllowed"> <p v-if="maintainerEditAllowed">
{{ s__("mrWidget|Allows edits from maintainers") }} {{ s__("mrWidget|Allows edits from maintainers") }}
</p> </p>
......
...@@ -453,8 +453,7 @@ ...@@ -453,8 +453,7 @@
} }
} }
.mr-links, .mr-links {
.mr-maintainer-edit {
padding-left: $status-icon-size + $status-icon-margin; padding-left: $status-icon-size + $status-icon-margin;
} }
......
# Allow maintainer pushes for merge requests accross forks # Allow maintainer pushes for merge requests across forks
This feature is available for merge requests across forked projects that are This feature is available for merge requests across forked projects that are
publicly accessible. It makes it easier for maintainers of projects to collaborate publicly accessible. It makes it easier for maintainers of projects to collaborate
......
...@@ -63,15 +63,12 @@ module Gitlab ...@@ -63,15 +63,12 @@ module Gitlab
request_cache def can_push_to_branch?(ref) request_cache def can_push_to_branch?(ref)
return false unless can_access_git? return false unless can_access_git?
return false unless user.can?(:push_code, project) || project.branch_allows_maintainer_push?(user, ref)
if protected?(ProtectedBranch, project, ref) if protected?(ProtectedBranch, project, ref)
return true if project.user_can_push_to_empty_repo?(user) project.user_can_push_to_empty_repo?(user) || protected_branch_accessible_to?(ref, action: :push)
protected_branch_accessible_to?(ref, action: :push)
elsif user.can?(:push_code, project)
true
else else
project.branch_allows_maintainer_push?(user, ref) true
end end
end end
......
...@@ -2,22 +2,39 @@ import Vue from 'vue'; ...@@ -2,22 +2,39 @@ import Vue from 'vue';
import maintainerEditComponent from '~/vue_merge_request_widget/components/mr_widget_maintainer_edit.vue'; import maintainerEditComponent from '~/vue_merge_request_widget/components/mr_widget_maintainer_edit.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
describe('MRWidgetAuthor', () => { describe('RWidgetMaintainerEdit', () => {
let Component;
let vm; let vm;
beforeEach(() => { beforeEach(() => {
const Component = Vue.extend(maintainerEditComponent); Component = Vue.extend(maintainerEditComponent);
vm = mountComponent(Component, {
maintainerEditAllowed: true,
});
}); });
afterEach(() => { afterEach(() => {
vm.$destroy(); vm.$destroy();
}); });
it('renders the message when maintainers are allowed to edit', () => { describe('when a maintainer is allowed to edit', () => {
expect(vm.$el.textContent.trim()).toEqual('Allows edits from maintainers'); beforeEach(() => {
vm = mountComponent(Component, {
maintainerEditAllowed: true,
});
});
it('it renders the message', () => {
expect(vm.$el.textContent.trim()).toEqual('Allows edits from maintainers');
});
});
describe('when a maintainer is not allowed to edit', () => {
beforeEach(() => {
vm = mountComponent(Component, {
maintainerEditAllowed: false,
});
});
it('hides the message', () => {
expect(vm.$el.textContent.trim()).toEqual('');
});
}); });
}); });
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